use UTF-8 for string representation
This commit is contained in:
		
							parent
							
								
									009e7e7647
								
							
						
					
					
						commit
						8fc84938bf
					
				@ -203,7 +203,7 @@ namespace detail
 | 
			
		||||
		void default_native_font(const font_ptr_t&);
 | 
			
		||||
		unsigned font_size_to_height(unsigned) const;
 | 
			
		||||
		unsigned font_height_to_size(unsigned) const;
 | 
			
		||||
		font_ptr_t make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strick_out);
 | 
			
		||||
		font_ptr_t make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strick_out);
 | 
			
		||||
 | 
			
		||||
		Display* open_display();
 | 
			
		||||
		void close_display();
 | 
			
		||||
 | 
			
		||||
@ -80,7 +80,7 @@ namespace detail
 | 
			
		||||
 | 
			
		||||
	struct font_tag
 | 
			
		||||
	{
 | 
			
		||||
		nana::string name;
 | 
			
		||||
		native_string_type name;
 | 
			
		||||
		unsigned height;
 | 
			
		||||
		unsigned weight;
 | 
			
		||||
		bool italic;
 | 
			
		||||
@ -186,7 +186,7 @@ namespace detail
 | 
			
		||||
		void default_native_font(const font_ptr_t&);
 | 
			
		||||
		unsigned font_size_to_height(unsigned) const;
 | 
			
		||||
		unsigned font_height_to_size(unsigned) const;
 | 
			
		||||
		font_ptr_t make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
 | 
			
		||||
		font_ptr_t make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
 | 
			
		||||
 | 
			
		||||
		static platform_spec& instance();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -174,13 +174,25 @@ namespace nana
 | 
			
		||||
		{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		categorize(window wd, const nana::string& text, bool visible = true)
 | 
			
		||||
		categorize(window wd, const std::string& text_utf8, bool visible = true)
 | 
			
		||||
			: categorize(wd, ::nana::rectangle(), visible)
 | 
			
		||||
		{
 | 
			
		||||
			this->caption(text);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		categorize(window wd, const nana::char_t* text, bool visible = true)
 | 
			
		||||
		categorize(window wd, const char* text_utf8, bool visible = true)
 | 
			
		||||
			: categorize(wd, ::nana::rectangle(), visible)
 | 
			
		||||
		{
 | 
			
		||||
			this->caption(text);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		categorize(window wd, const std::wstring& text, bool visible = true)
 | 
			
		||||
			: categorize(wd, ::nana::rectangle(), visible)
 | 
			
		||||
		{
 | 
			
		||||
			this->caption(text);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		categorize(window wd, const wchar_t* text, bool visible = true)
 | 
			
		||||
			: categorize(wd, ::nana::rectangle(), visible)
 | 
			
		||||
		{
 | 
			
		||||
			this->caption(text);
 | 
			
		||||
@ -206,7 +218,7 @@ namespace nana
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/// Erases a child category with a specified name from current category.
 | 
			
		||||
		categorize& childset_erase(const nana::string& name)
 | 
			
		||||
		categorize& childset_erase(const std::string& name)
 | 
			
		||||
		{
 | 
			
		||||
			if(this->get_drawer_trigger().childset_erase(name))
 | 
			
		||||
				API::update_window(*this);
 | 
			
		||||
@ -220,13 +232,13 @@ namespace nana
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/// Sets the splitter string
 | 
			
		||||
		categorize& splitstr(const nana::string& sstr)
 | 
			
		||||
		categorize& splitstr(const std::string& sstr)
 | 
			
		||||
		{
 | 
			
		||||
			this->get_drawer_trigger().splitstr(sstr);
 | 
			
		||||
			return *this;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		nana::string splitstr() const
 | 
			
		||||
		std::string splitstr() const
 | 
			
		||||
		{
 | 
			
		||||
			return this->get_drawer_trigger().splitstr();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -434,7 +434,7 @@ namespace nana{ namespace widgets{	namespace skeletons
 | 
			
		||||
			};
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		::std::wstring	font;
 | 
			
		||||
		::std::string	font;
 | 
			
		||||
		std::size_t		font_size;
 | 
			
		||||
		bool	bold;
 | 
			
		||||
		bool	bold_empty;	//bold should be ignored if bold_empty is true
 | 
			
		||||
@ -706,7 +706,7 @@ namespace nana{ namespace widgets{	namespace skeletons
 | 
			
		||||
					if(token::string != tknizer.read())
 | 
			
		||||
						throw std::runtime_error("");
 | 
			
		||||
 | 
			
		||||
					fp->font = tknizer.idstr();
 | 
			
		||||
					fp->font = to_utf8(tknizer.idstr());
 | 
			
		||||
					break;
 | 
			
		||||
				case token::size:
 | 
			
		||||
					if(token::equal != tknizer.read())
 | 
			
		||||
 | 
			
		||||
@ -36,14 +36,14 @@ namespace nana
 | 
			
		||||
			font();
 | 
			
		||||
			font(drawable_type);
 | 
			
		||||
			font(const font&);
 | 
			
		||||
			font(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
 | 
			
		||||
			font(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
 | 
			
		||||
			~font();
 | 
			
		||||
			bool empty() const;
 | 
			
		||||
			void make(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
 | 
			
		||||
			void make_raw(const char_t*, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
 | 
			
		||||
			void make(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
 | 
			
		||||
			void make_raw(const ::std::string& name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
 | 
			
		||||
 | 
			
		||||
			void set_default() const;
 | 
			
		||||
			::nana::string name() const;
 | 
			
		||||
			::std::string name() const;
 | 
			
		||||
			unsigned size() const;
 | 
			
		||||
			bool bold() const;
 | 
			
		||||
			unsigned height() const;
 | 
			
		||||
 | 
			
		||||
@ -32,8 +32,6 @@ namespace paint
 | 
			
		||||
		image();
 | 
			
		||||
		image(const image&);
 | 
			
		||||
		image(image&&);
 | 
			
		||||
		//image(const nana::char_t* file);
 | 
			
		||||
		//image(const nana::string& filename);	//deprecated
 | 
			
		||||
		image(const ::nana::experimental::filesystem::path& file);
 | 
			
		||||
 | 
			
		||||
		template<typename Source>
 | 
			
		||||
@ -45,7 +43,6 @@ namespace paint
 | 
			
		||||
		~image();
 | 
			
		||||
		image& operator=(const image& rhs);
 | 
			
		||||
		image& operator=(image&&);
 | 
			
		||||
		//bool open(const nana::string& filename);	//deprecated
 | 
			
		||||
		bool open(const ::nana::experimental::filesystem::path& file);
 | 
			
		||||
		
 | 
			
		||||
		/// Opens an icon from a specified buffer
 | 
			
		||||
 | 
			
		||||
@ -515,7 +515,7 @@ namespace detail
 | 
			
		||||
		atombase_.xdnd_finished = ::XInternAtom(display_, "XdndFinished", False);
 | 
			
		||||
 | 
			
		||||
		//Create default font object.
 | 
			
		||||
		def_font_ptr_ = make_native_font(0, font_size_to_height(10), 400, false, false, false);
 | 
			
		||||
		def_font_ptr_ = make_native_font(nullptr, font_size_to_height(10), 400, false, false, false);
 | 
			
		||||
		msg_dispatcher_ = new msg_dispatcher(display_);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -550,10 +550,10 @@ namespace detail
 | 
			
		||||
		return height;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	platform_spec::font_ptr_t platform_spec::make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
 | 
			
		||||
	platform_spec::font_ptr_t platform_spec::make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
 | 
			
		||||
	{
 | 
			
		||||
		font_ptr_t ref;
 | 
			
		||||
#if defined(NANA_UNICODE)
 | 
			
		||||
#if 1 //Xft
 | 
			
		||||
		if(0 == name || *name == 0)
 | 
			
		||||
			name = STR("*");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -207,7 +207,7 @@ namespace detail
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
		::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof metrics, &metrics, 0);
 | 
			
		||||
		def_font_ptr_ = make_native_font(metrics.lfMessageFont.lfFaceName, font_size_to_height(9), 400, false, false, false);
 | 
			
		||||
		def_font_ptr_ = make_native_font(utf8_cast(metrics.lfMessageFont.lfFaceName).c_str(), font_size_to_height(9), 400, false, false, false);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const platform_spec::font_ptr_t& platform_spec::default_native_font() const
 | 
			
		||||
@ -238,12 +238,15 @@ namespace detail
 | 
			
		||||
		return height;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	platform_spec::font_ptr_t platform_spec::make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
 | 
			
		||||
	platform_spec::font_ptr_t platform_spec::make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
 | 
			
		||||
	{
 | 
			
		||||
		::LOGFONT logfont;
 | 
			
		||||
		memset(&logfont, 0, sizeof logfont);
 | 
			
		||||
 | 
			
		||||
		strcpy(logfont.lfFaceName, (name && *name ? name : def_font_ptr_->name.c_str()));
 | 
			
		||||
		if (name && *name)
 | 
			
		||||
			strcpy(logfont.lfFaceName, utf8_cast(name).c_str());
 | 
			
		||||
		else
 | 
			
		||||
			strcpy(logfont.lfFaceName, def_font_ptr_->name.c_str());
 | 
			
		||||
 | 
			
		||||
		logfont.lfCharSet = DEFAULT_CHARSET;
 | 
			
		||||
		HDC hdc = ::GetDC(0);
 | 
			
		||||
 | 
			
		||||
@ -259,7 +259,7 @@ namespace nana
 | 
			
		||||
					return fp->bold;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				const nana::string& _m_fontname(nana::widgets::skeletons::fblock* fp)
 | 
			
		||||
				const std::string& _m_fontname(nana::widgets::skeletons::fblock* fp)
 | 
			
		||||
				{
 | 
			
		||||
					while(fp->font.empty())
 | 
			
		||||
					{
 | 
			
		||||
@ -274,13 +274,13 @@ namespace nana
 | 
			
		||||
				{
 | 
			
		||||
					if(fp != fblock_)
 | 
			
		||||
					{
 | 
			
		||||
						const nana::string& name = _m_fontname(fp);
 | 
			
		||||
						auto& name = _m_fontname(fp);
 | 
			
		||||
						auto fontsize = static_cast<unsigned>(_m_font_size(fp));
 | 
			
		||||
						bool bold = _m_bold(fp);
 | 
			
		||||
 | 
			
		||||
						if((fontsize != font_.size()) || bold != font_.bold() || name != font_.name())
 | 
			
		||||
						{
 | 
			
		||||
							font_.make(name.data(), fontsize, bold);
 | 
			
		||||
							font_.make(name, fontsize, bold);
 | 
			
		||||
							graph.typeface(font_);
 | 
			
		||||
						}
 | 
			
		||||
						fblock_ = fp;
 | 
			
		||||
@ -606,7 +606,7 @@ namespace nana
 | 
			
		||||
				::nana::paint::font font_;
 | 
			
		||||
				struct def_font_tag
 | 
			
		||||
				{
 | 
			
		||||
					::nana::string font_name;
 | 
			
		||||
					::std::string font_name;
 | 
			
		||||
					std::size_t font_size;
 | 
			
		||||
					bool	font_bold;
 | 
			
		||||
					::nana::color fgcolor;
 | 
			
		||||
 | 
			
		||||
@ -79,7 +79,7 @@ namespace paint
 | 
			
		||||
				impl_->font_ptr = rhs.impl_->font_ptr;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		font::font(const nana::char_t* name, unsigned size, bool bold, bool italic, bool underline, bool strike_out)
 | 
			
		||||
		font::font(const std::string& name, unsigned size, bool bold, bool italic, bool underline, bool strike_out)
 | 
			
		||||
			: impl_(new impl_type)
 | 
			
		||||
		{
 | 
			
		||||
			make(name, size, bold, italic, underline, strike_out);
 | 
			
		||||
@ -95,17 +95,17 @@ namespace paint
 | 
			
		||||
			return ((nullptr == impl_) || (nullptr == impl_->font_ptr));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		void font::make(const nana::char_t* name, unsigned size, bool bold, bool italic, bool underline, bool strike_out)
 | 
			
		||||
		void font::make(const std::string& name, unsigned size, bool bold, bool italic, bool underline, bool strike_out)
 | 
			
		||||
		{
 | 
			
		||||
			size = nana::detail::platform_spec::instance().font_size_to_height(size);
 | 
			
		||||
			make_raw(name, size, bold ? 700 : 400, italic, underline, strike_out);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		void font::make_raw(const nana::char_t*name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
 | 
			
		||||
		void font::make_raw(const std::string& name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
 | 
			
		||||
		{
 | 
			
		||||
			if(impl_)
 | 
			
		||||
			{
 | 
			
		||||
				auto t = nana::detail::platform_spec::instance().make_native_font(name, height, weight, italic, underline, strike_out);
 | 
			
		||||
				auto t = nana::detail::platform_spec::instance().make_native_font(name.c_str(), height, weight, italic, underline, strike_out);
 | 
			
		||||
				if(t)
 | 
			
		||||
					impl_->font_ptr = t;
 | 
			
		||||
			}
 | 
			
		||||
@ -119,10 +119,11 @@ namespace paint
 | 
			
		||||
			nana::detail::platform_spec::instance().default_native_font(impl_->font_ptr);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		nana::string font::name() const
 | 
			
		||||
		std::string font::name() const
 | 
			
		||||
		{
 | 
			
		||||
			if(empty()) return nana::string();
 | 
			
		||||
			return impl_->font_ptr->name;
 | 
			
		||||
			if(empty()) return std::string();
 | 
			
		||||
 | 
			
		||||
			return to_utf8(impl_->font_ptr->name);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		unsigned font::size() const
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user