Implemented the correct behavior for the initial display of the size combobox of the font dialog. At this point we can move straight to manipulating the uiDrawFontDescriptors.

This commit is contained in:
Pietro Gagliardi 2016-04-17 21:11:55 -04:00
parent 0e75a6f950
commit 40d673fb01
2 changed files with 25 additions and 9 deletions

View File

@ -38,8 +38,16 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
cf.hwndOwner = GetAncestor(b->hwnd, GA_ROOT); // TODO didn't we have a function for this cf.hwndOwner = GetAncestor(b->hwnd, GA_ROOT); // TODO didn't we have a function for this
showFontDialog(cf.hwndOwner); showFontDialog(cf.hwndOwner);
cf.lpLogFont = &(b->font); cf.lpLogFont = &(b->font);
ZeroMemory(&(b->font), sizeof(LOGFONTW));
b->font.lfFaceName[0]='A';
b->font.lfFaceName[1]='r';
b->font.lfFaceName[2]='i';
b->font.lfFaceName[3]='a';
b->font.lfFaceName[4]='l';
b->font.lfFaceName[5]=0;
b->font.lfHeight=-15*96/72;
// TODO CF_FORCEFONTEXIST? CF_INACTIVEFONTS? CF_NOSCRIPTSEL? CF_USESTYLE? // TODO CF_FORCEFONTEXIST? CF_INACTIVEFONTS? CF_NOSCRIPTSEL? CF_USESTYLE?
if (b->already) // if (b->already)
cf.Flags = CF_INITTOLOGFONTSTRUCT; cf.Flags = CF_INITTOLOGFONTSTRUCT;
if (ChooseFontW(&cf) != FALSE) { if (ChooseFontW(&cf) != FALSE) {
b->already = TRUE; b->already = TRUE;

View File

@ -428,6 +428,7 @@ static struct fontDialog *beginFontDialog(HWND hwnd, LPARAM lParam)
WCHAR *wname; WCHAR *wname;
LRESULT pos; LRESULT pos;
HWND samplePlacement; HWND samplePlacement;
WCHAR wsize[512]; // this should be way more than enough
HRESULT hr; HRESULT hr;
f = uiNew(struct fontDialog); f = uiNew(struct fontDialog);
@ -457,14 +458,21 @@ static struct fontDialog *beginFontDialog(HWND hwnd, LPARAM lParam)
for (i = 0; defaultSizes[i].text != NULL; i++) for (i = 0; defaultSizes[i].text != NULL; i++)
cbInsertString(f->sizeCombobox, defaultSizes[i].text, (WPARAM) i); cbInsertString(f->sizeCombobox, defaultSizes[i].text, (WPARAM) i);
// TODO make this proper // TODO use the selected size
cbSetCurSel(f->sizeCombobox, 2); // the real font dialog:
sizeChanged(f); // - if the chosen font size is in the list, it selects that item AND makes it topmost
// - if the chosen font size is not in the list, don't bother
/*TODO // and finally put 10 at the top to imitate ChooseFont() // we'll simulate it by setting the text to a %f representation, then pretending as if it was entered
if (SendMessageW(f->sizeCombobox, CB_SETTOPINDEX, (WPARAM) ten, 0) != 0) // TODO is 512 the correct number to pass to _snwprintf()?
logLastError("error making 10 visible in the size combobox in beginFontDialog()"); // TODO will this revert to scientific notation?
*/ _snwprintf(wsize, 512, L"%g", 10.0);
// TODO make this a setWindowText()
if (SendMessageW(f->sizeCombobox, WM_SETTEXT, 0, (LPARAM) wsize) != (LRESULT) TRUE)
logLastError("error setting size combobox to initial font size in beginFontDialog()");
sizeEdited(f);
if (cbGetCurSel(f->sizeCombobox, &pos))
if (SendMessageW(f->sizeCombobox, CB_SETTOPINDEX, (WPARAM) pos, 0) != 0)
logLastError("error making chosen size topmost in the size combobox in beginFontDialog()");
// note: we can't add ES_NUMBER to the combobox entry (it seems to disable the entry instead?!), so we must do validation when the box is dmissed; TODO // note: we can't add ES_NUMBER to the combobox entry (it seems to disable the entry instead?!), so we must do validation when the box is dmissed; TODO