Exemple #1
0
const char *CfgLangDialog::GetId()
{ 
	int n = _list.GetCurrent();
	if (n <= 0 ) return "+";
	if (n == 1) return "-";
	n-=2;
	if (n >= nodeList->count()) return "+";
	return nodeList->get(n).id.ptr();
}
Exemple #2
0
void StyleOptDialog::RefreshFontInfo()
{
	int count = pList->count();
	int cur = fontList.GetCurrent();
	
	const char *s = "";
	if (count>=0 && cur>=0 && cur<count)
	{
		int n = fontList.GetCurrentInt();
		if (pList->get(n).newFont.ptr())
			s = pList->get(n).newFont->printable_name();
		else
		if (pList->get(n).oldFont)
			s = pList->get(n).oldFont->printable_name();
	}
		
	fontNameStatic.SetText(utf8_to_unicode(s).ptr());
}
Exemple #3
0
bool StyleOptDialog::Command(int id, int subId, Win *win, void *data)
{
	
	if (win == &fontList)
	{
		RefreshFontInfo();
		return true;
	}
#ifdef _WIN32
	if (id == CMD_CHFONT)
	{
		int count = pList->count();
		int cur = fontList.GetCurrent();
	
		if (count<=0 || cur<0 || cur>=count) return true;

		LOGFONT lf;
		carray<char> *pUri = pList->get(fontList.GetCurrentInt()).pUri;
		cfont::UriToLogFont(&lf, pUri && pUri->ptr() ?  pUri->ptr() : 0);

		CHOOSEFONT cf;
		memset(&cf,0,sizeof(cf));
		cf.lStructSize = sizeof(cf);
		cf.hwndOwner = GetID();
		cf.lpLogFont = &lf;
		cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_INITTOLOGFONTSTRUCT ;

		if (pList->get(fontList.GetCurrentInt()).fixed)
			cf.Flags |= CF_FIXEDPITCHONLY;


		if (ChooseFont(&cf))
		{
			cptr<cfont> p = new cfont(cfont::LogFontToUru(lf).ptr());
			if (p.ptr()) {
				pList->get(fontList.GetCurrentInt()).newFont = p;
				RefreshFontInfo();
			}
		}

		return true;
	}

#else
	if (id == CMD_CHFONT)
	{
		int count = pList->count();
		int cur = fontList.GetCurrent();
	
		if (count<=0 || cur<0 || cur>=count) return true;
		
		carray<char> *pUri = pList->get(fontList.GetCurrentInt()).pUri;
		
		cptr<cfont> p = SelectFTFont((NCDialogParent*)Parent(), pList->get(fontList.GetCurrentInt()).fixed, (pUri && pUri->ptr()) ? pUri->ptr() : 0 );
		if (p.ptr()) {
			pList->get(fontList.GetCurrentInt()).newFont = p;
			RefreshFontInfo();
		}
		
		return true;
	}
	
	if (id == CMD_CHFONTX11)
	{
		int count = pList->count();
		int cur = fontList.GetCurrent();
	
		if (count<=0 || cur<0 || cur>=count) return true;

		cptr<cfont> p = SelectX11Font((NCDialogParent*)Parent(), pList->get(fontList.GetCurrentInt()).fixed);
		if (p.ptr()) {
			pList->get(fontList.GetCurrentInt()).newFont = p;
			RefreshFontInfo();
		}
		
		return true;
	}
#endif
	
	return NCVertDialog::Command(id, subId, win, data);
}