From e3e88c7a6a8ce0477259a14d166c94d0765eea3b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 2 May 2018 20:57:50 -0400 Subject: [PATCH] And migrated the font dialog. --- windows/_rc2bin/out | 64 --------------------------- windows/fontdialog.cpp | 99 +++++++++++++++++++++++++++++++++++++++++- windows/resources.rc | 31 ------------- 3 files changed, 98 insertions(+), 96 deletions(-) diff --git a/windows/_rc2bin/out b/windows/_rc2bin/out index 0868bb66..824ca2fd 100644 --- a/windows/_rc2bin/out +++ b/windows/_rc2bin/out @@ -1,69 +1,5 @@ // because Windows doesn't really support resources in static libraries, we have to embed this directly; oh well -static const uint8_t rcFontDialog[] = { - 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xC4, 0x00, 0xC8, 0x80, - 0x0A, 0x00, 0x0D, 0x00, 0x36, 0x00, 0xF3, 0x00, - 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, - 0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x53, 0x00, - 0x65, 0x00, 0x67, 0x00, 0x6F, 0x00, 0x65, 0x00, - 0x20, 0x00, 0x55, 0x00, 0x49, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x50, 0x07, 0x00, 0x07, 0x00, - 0x62, 0x00, 0x09, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x82, 0x00, 0x26, 0x00, 0x46, 0x00, - 0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x3A, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x41, 0x0B, 0x21, 0x50, - 0x07, 0x00, 0x10, 0x00, 0x62, 0x00, 0x4C, 0x00, - 0xE8, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x85, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50, - 0x72, 0x00, 0x07, 0x00, 0x4A, 0x00, 0x09, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x00, - 0x46, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, - 0x20, 0x00, 0x73, 0x00, 0x74, 0x00, 0x26, 0x00, - 0x79, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x3A, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x41, 0x0A, 0x21, 0x50, - 0x72, 0x00, 0x10, 0x00, 0x4A, 0x00, 0x4C, 0x00, - 0xE9, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x85, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50, - 0xC6, 0x00, 0x07, 0x00, 0x24, 0x00, 0x09, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x00, - 0x26, 0x00, 0x53, 0x00, 0x69, 0x00, 0x7A, 0x00, - 0x65, 0x00, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x41, 0x0B, 0x21, 0x50, 0xC6, 0x00, 0x10, 0x00, - 0x24, 0x00, 0x4C, 0x00, 0xEA, 0x03, 0x00, 0x00, - 0xFF, 0xFF, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x02, 0x50, 0x07, 0x00, 0x61, 0x00, - 0xE3, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x80, 0x00, 0x53, 0x00, 0x61, 0x00, - 0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x02, 0x40, - 0x09, 0x00, 0x6A, 0x00, 0xE0, 0x00, 0x3C, 0x00, - 0xEB, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00, - 0x41, 0x00, 0x61, 0x00, 0x42, 0x00, 0x62, 0x00, - 0x59, 0x00, 0x79, 0x00, 0x5A, 0x00, 0x7A, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x50, - 0x8D, 0x00, 0xB5, 0x00, 0x2D, 0x00, 0x0E, 0x00, - 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0x00, - 0x4F, 0x00, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x50, 0xBE, 0x00, 0xB5, 0x00, - 0x2D, 0x00, 0x0E, 0x00, 0x02, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0x80, 0x00, 0x43, 0x00, 0x61, 0x00, - 0x6E, 0x00, 0x63, 0x00, 0x65, 0x00, 0x6C, 0x00, - 0x00, 0x00, 0x00, 0x00, -}; -static_assert(ARRAYSIZE(rcFontDialog) == 476, "wrong size for resource rcFontDialog"); - static const uint8_t rcColorDialog[] = { 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC4, 0x00, 0xC8, 0x80, diff --git a/windows/fontdialog.cpp b/windows/fontdialog.cpp index ea02a416..fa9c1d0d 100644 --- a/windows/fontdialog.cpp +++ b/windows/fontdialog.cpp @@ -591,9 +591,106 @@ static INT_PTR CALLBACK fontDialogDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, L return FALSE; } +// because Windows doesn't really support resources in static libraries, we have to embed this directly; oh well +/* +// this is for our custom DirectWrite-based font dialog (see fontdialog.cpp) +// this is based on the "New Font Dialog with Syslink" in Microsoft's font.dlg +// LONGTERM look at localization +// LONGTERM make it look tighter and nicer like the real one, including the actual heights of the font family and style comboboxes +rcFontDialog DIALOGEX 13, 54, 243, 200 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK +CAPTION "Font" +FONT 9, "Segoe UI" +BEGIN + LTEXT "&Font:", -1, 7, 7, 98, 9 + COMBOBOX rcFontFamilyCombobox, 7, 16, 98, 76, + CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL | + CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS + + LTEXT "Font st&yle:", -1, 114, 7, 74, 9 + COMBOBOX rcFontStyleCombobox, 114, 16, 74, 76, + CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL | + WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS + + LTEXT "&Size:", -1, 198, 7, 36, 9 + COMBOBOX rcFontSizeCombobox, 198, 16, 36, 76, + CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL | + CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS + + GROUPBOX "Sample", -1, 7, 97, 227, 70, WS_GROUP + CTEXT "AaBbYyZz", rcFontSamplePlacement, 9, 106, 224, 60, SS_NOPREFIX | NOT WS_VISIBLE + + DEFPUSHBUTTON "OK", IDOK, 141, 181, 45, 14, WS_GROUP + PUSHBUTTON "Cancel", IDCANCEL, 190, 181, 45, 14, WS_GROUP +END +*/ +static const uint8_t data_rcFontDialog[] = { + 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xC4, 0x00, 0xC8, 0x80, + 0x0A, 0x00, 0x0D, 0x00, 0x36, 0x00, 0xF3, 0x00, + 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, + 0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x53, 0x00, + 0x65, 0x00, 0x67, 0x00, 0x6F, 0x00, 0x65, 0x00, + 0x20, 0x00, 0x55, 0x00, 0x49, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x50, 0x07, 0x00, 0x07, 0x00, + 0x62, 0x00, 0x09, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x82, 0x00, 0x26, 0x00, 0x46, 0x00, + 0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x3A, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x41, 0x0B, 0x21, 0x50, + 0x07, 0x00, 0x10, 0x00, 0x62, 0x00, 0x4C, 0x00, + 0xE8, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x85, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50, + 0x72, 0x00, 0x07, 0x00, 0x4A, 0x00, 0x09, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x00, + 0x46, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, + 0x20, 0x00, 0x73, 0x00, 0x74, 0x00, 0x26, 0x00, + 0x79, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x3A, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x41, 0x0A, 0x21, 0x50, + 0x72, 0x00, 0x10, 0x00, 0x4A, 0x00, 0x4C, 0x00, + 0xE9, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x85, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50, + 0xC6, 0x00, 0x07, 0x00, 0x24, 0x00, 0x09, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x00, + 0x26, 0x00, 0x53, 0x00, 0x69, 0x00, 0x7A, 0x00, + 0x65, 0x00, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0x0B, 0x21, 0x50, 0xC6, 0x00, 0x10, 0x00, + 0x24, 0x00, 0x4C, 0x00, 0xEA, 0x03, 0x00, 0x00, + 0xFF, 0xFF, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x02, 0x50, 0x07, 0x00, 0x61, 0x00, + 0xE3, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x80, 0x00, 0x53, 0x00, 0x61, 0x00, + 0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x02, 0x40, + 0x09, 0x00, 0x6A, 0x00, 0xE0, 0x00, 0x3C, 0x00, + 0xEB, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00, + 0x41, 0x00, 0x61, 0x00, 0x42, 0x00, 0x62, 0x00, + 0x59, 0x00, 0x79, 0x00, 0x5A, 0x00, 0x7A, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x50, + 0x8D, 0x00, 0xB5, 0x00, 0x2D, 0x00, 0x0E, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0x00, + 0x4F, 0x00, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x50, 0xBE, 0x00, 0xB5, 0x00, + 0x2D, 0x00, 0x0E, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0x80, 0x00, 0x43, 0x00, 0x61, 0x00, + 0x6E, 0x00, 0x63, 0x00, 0x65, 0x00, 0x6C, 0x00, + 0x00, 0x00, 0x00, 0x00, +}; +static_assert(ARRAYSIZE(data_rcFontDialog) == 476, "wrong size for resource rcFontDialog"); + BOOL uiprivShowFontDialog(HWND parent, struct fontDialogParams *params) { - switch (DialogBoxParamW(hInstance, MAKEINTRESOURCE(rcFontDialog), parent, fontDialogDlgProc, (LPARAM) params)) { + switch (DialogBoxIndirectParamW(hInstance, (const DLGTEMPLATE *) data_rcFontDialog, parent, fontDialogDlgProc, (LPARAM) params)) { case 1: // cancel return FALSE; case 2: // ok diff --git a/windows/resources.rc b/windows/resources.rc index 4ec9c492..1dfff92e 100644 --- a/windows/resources.rc +++ b/windows/resources.rc @@ -12,37 +12,6 @@ ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "libui.manifest" #endif -// this is for our custom DirectWrite-based font dialog (see fontdialog.cpp) -// this is based on the "New Font Dialog with Syslink" in Microsoft's font.dlg -// LONGTERM look at localization -// LONGTERM make it look tighter and nicer like the real one, including the actual heights of the font family and style comboboxes -rcFontDialog DIALOGEX 13, 54, 243, 200 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK -CAPTION "Font" -FONT 9, "Segoe UI" -BEGIN - LTEXT "&Font:", -1, 7, 7, 98, 9 - COMBOBOX rcFontFamilyCombobox, 7, 16, 98, 76, - CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL | - CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS - - LTEXT "Font st&yle:", -1, 114, 7, 74, 9 - COMBOBOX rcFontStyleCombobox, 114, 16, 74, 76, - CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL | - WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS - - LTEXT "&Size:", -1, 198, 7, 36, 9 - COMBOBOX rcFontSizeCombobox, 198, 16, 36, 76, - CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL | - CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS - - GROUPBOX "Sample", -1, 7, 97, 227, 70, WS_GROUP - CTEXT "AaBbYyZz", rcFontSamplePlacement, 9, 106, 224, 60, SS_NOPREFIX | NOT WS_VISIBLE - - DEFPUSHBUTTON "OK", IDOK, 141, 181, 45, 14, WS_GROUP - PUSHBUTTON "Cancel", IDCANCEL, 190, 181, 45, 14, WS_GROUP -END - rcColorDialog DIALOGEX 13, 54, 344, 209 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK CAPTION "Color"