Пример #1
0
		widget& widget::caption(std::string utf8)
		{
			::nana::throw_not_utf8(utf8);
			native_string_type str = to_nstring(utf8);
			_m_caption(std::move(str));
			return *this;
		}
Пример #2
0
		void insert(std::size_t pos, std::wstring text, value_type value = {})
		{
			if (pos > length())
				throw std::out_of_range("tabbar::insert invalid position");

			this->get_drawer_trigger().insert(pos, to_nstring(std::move(text)), std::move(value));
			API::update_window(*this);
		}
Пример #3
0
		void widget::i18n(i18n_eval eval)
		{
			if (handle())
			{
				native_string_type str = to_nstring(eval());
				_m_caption(std::move(str));
				internationalization_parts::set_eval(handle(), std::move(eval));
			}
		}
Пример #4
0
		tabbar& append(std::wstring text, window attach_wd, value_type value = {})
		{
			if (attach_wd && API::empty_window(attach_wd))
				throw std::invalid_argument("Appening a tab to a tabbar - error: tabbar.attach: invalid window handle");

			this->get_drawer_trigger().insert(::nana::npos, to_nstring(std::move(text)), std::move(value));
			if (attach_wd)
				this->attach(this->get_drawer_trigger().length() - 1, attach_wd);
			
			API::update_window(*this);
			return *this;
		}
Пример #5
0
		widget& widget::caption(std::wstring text)
		{
			native_string_type str = to_nstring(text);
			_m_caption(std::move(str));
			return *this;
		}
Пример #6
0
		textbox& textbox::from(double d)
		{
			_m_caption(to_nstring(d));
			return *this;
		}
Пример #7
0
		textbox& textbox::from(int n)
		{
			_m_caption(to_nstring(n));
			return *this;
		}
Пример #8
0
	static std::shared_ptr<platform_abstraction::font> font_factory(::std::string font_family, double size_pt, const platform_abstraction::font::font_style& fs, internal_font::path_type ttf)
	{
		using native_font_type = platform_abstraction::font::native_font_type;
#ifdef NANA_WINDOWS
		std::wstring wfont_family = to_nstring(font_family);

		//Make sure the length of font family less than LF_FACESIZE which is defined by Windows
		if (wfont_family.length() + 1 > LF_FACESIZE)
			wfont_family.clear();

		//Translate pt to px
		auto hDC = ::GetDC(nullptr);
		auto font_height = -static_cast<LONG>(size_pt * ::GetDeviceCaps(hDC, LOGPIXELSY) / 72);
		::ReleaseDC(nullptr, hDC);

		if (wfont_family.empty() || (0 == font_height))
		{
			//Create default font object.
			NONCLIENTMETRICS metrics = {};
			metrics.cbSize = sizeof metrics;
#if(WINVER >= 0x0600)
#if defined(NANA_MINGW)
			OSVERSIONINFO osvi = {};
			osvi.dwOSVersionInfoSize = sizeof(osvi);
			::GetVersionEx(&osvi);
			if (osvi.dwMajorVersion < 6)
				metrics.cbSize -= sizeof(metrics.iPaddedBorderWidth);
#else
			if (!IsWindowsVistaOrGreater())
				metrics.cbSize -= sizeof(metrics.iPaddedBorderWidth);
#endif
#endif
			::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof metrics, &metrics, 0);

			if (wfont_family.empty())
			{
				wfont_family = metrics.lfMessageFont.lfFaceName;
				font_family = to_utf8(wfont_family);
			}

			if (0 == font_height)
				font_height = metrics.lfMessageFont.lfHeight;
		}


		::LOGFONT lf{};

		std::wcscpy(lf.lfFaceName, wfont_family.c_str());
		lf.lfHeight = font_height;
		lf.lfCharSet = DEFAULT_CHARSET;
		lf.lfWeight = fs.weight;
		lf.lfQuality = PROOF_QUALITY;
		lf.lfPitchAndFamily = FIXED_PITCH;
		lf.lfItalic = fs.italic;
		lf.lfUnderline = fs.underline;
		lf.lfStrikeOut = fs.strike_out;

		auto fd = ::CreateFontIndirect(&lf);
#elif defined(NANA_X11)
		auto disp = ::nana::detail::platform_spec::instance().open_display();
#	ifdef NANA_USE_XFT
		if(font_family.empty())
			font_family = '*';

		std::string pat_str = font_family + '-' + std::to_string(size_pt ? size_pt : platform_abstraction::font_default_pt());
		auto pat = ::XftNameParse(pat_str.c_str());
		XftResult res;
		auto match_pat = ::XftFontMatch(disp, ::XDefaultScreen(disp), pat, &res);

		::XftFont* fd = nullptr;
		if (match_pat)
			fd = ::XftFontOpenPattern(disp, match_pat);
#	else
		std::string pat_str;
		if (font_family.empty())
			pat_str = "-misc-fixed-*";
		else
			pat_str = "-misc-fixed-" + font_family;

		char ** missing_list;
		int missing_count;
		char * defstr;
		XFontSet fd = ::XCreateFontSet(display_, const_cast<char*>(pat_str.c_str()), &missing_list, &missing_count, &defstr);
#	endif
#endif
		if (fd)
			return std::make_shared<internal_font>(std::move(ttf), std::move(font_family), size_pt, fs, reinterpret_cast<native_font_type>(fd));
		return{};
	}
Пример #9
0
		void text(std::size_t pos, const std::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
		{
			this->get_drawer_trigger().text(pos, to_nstring(str));
		}
Пример #10
0
		void push_back(std::string text)  /// Append a new item.
		{
			this->get_drawer_trigger().insert(::nana::npos, to_nstring(std::move(text)), value_type());
			API::update_window(*this);
		}