--- /dev/null
+#include <precomp.h>\r
+\r
+\r
+int CALLBACK\r
+EnumFontSizes(ENUMLOGFONTEX *lpelfe,\r
+ NEWTEXTMETRICEX *lpntme,\r
+ DWORD FontType,\r
+ LPARAM lParam)\r
+{\r
+ static int ttsizes[] = { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 };\r
+ TCHAR ach[100];\r
+\r
+ BOOL fTrueType = (lpelfe->elfLogFont.lfOutPrecision == OUT_STROKE_PRECIS) ? TRUE : FALSE;\r
+\r
+ HWND hwndCombo = (HWND)lParam;\r
+ INT i, idx;\r
+\r
+ if (fTrueType)\r
+ {\r
+ for (i = 0; i < (sizeof(ttsizes) / sizeof(ttsizes[0])); i++)\r
+ {\r
+ wsprintf(ach, _T("%d"), ttsizes[i]);\r
+ idx = (INT)SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)ach);\r
+ SendMessage(hwndCombo, CB_SETITEMDATA, idx, ttsizes[i]);\r
+ }\r
+ return 0;\r
+ }\r
+\r
+ return 1;\r
+}\r
+\r
+\r
+/* Font-enumeration callback */\r
+int CALLBACK\r
+EnumFontNames(ENUMLOGFONTEX *lpelfe,\r
+ NEWTEXTMETRICEX *lpntme,\r
+ DWORD FontType,\r
+ LPARAM lParam)\r
+{\r
+ HWND hwndCombo = (HWND)lParam;\r
+ TCHAR *pszName = lpelfe->elfLogFont.lfFaceName;\r
+\r
+ /* make sure font doesn't already exist in our list */\r
+ if(SendMessage(hwndCombo,\r
+ CB_FINDSTRING,\r
+ 0,\r
+ (LPARAM)pszName) == CB_ERR)\r
+ {\r
+ INT idx;\r
+ BOOL fFixed;\r
+ BOOL fTrueType;\r
+\r
+ /* add the font */\r
+ idx = (INT)SendMessage(hwndCombo,\r
+ CB_ADDSTRING,\r
+ 0,\r
+ (LPARAM)pszName);\r
+\r
+ /* record the font's attributes (Fixedwidth and Truetype) */\r
+ fFixed = (lpelfe->elfLogFont.lfPitchAndFamily & FIXED_PITCH) ? TRUE : FALSE;\r
+ fTrueType = (lpelfe->elfLogFont.lfOutPrecision == OUT_STROKE_PRECIS) ? TRUE : FALSE;\r
+\r
+ /* store this information in the list-item's userdata area */\r
+ SendMessage(hwndCombo,\r
+ CB_SETITEMDATA,\r
+ idx,\r
+ MAKEWPARAM(fFixed, fTrueType));\r
+ }\r
+\r
+ return 1;\r
+}\r
+\r
+\r
+VOID\r
+FillFontSizeComboList(HWND hwndCombo)\r
+{\r
+ LOGFONT lf = { 0 };\r
+ HDC hdc = GetDC(hwndCombo);\r
+\r
+ /* default size */\r
+ INT cursize = 12;\r
+ INT i, count, nearest = 0;\r
+\r
+ HFONT hFont = GetStockObject(DEFAULT_GUI_FONT);\r
+\r
+ SendMessage(hwndCombo,\r
+ WM_SETFONT,\r
+ (WPARAM)hFont,\r
+ 0);\r
+\r
+ lf.lfCharSet = DEFAULT_CHARSET;\r
+ lf.lfPitchAndFamily = 0;\r
+\r
+ /* empty the list */\r
+ SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);\r
+\r
+ /* enumerate font sizes */\r
+ EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontSizes, (LONG)hwndCombo, 0);\r
+\r
+ /* set selection to first item */\r
+ count = (INT)SendMessage(hwndCombo, CB_GETCOUNT, 0, 0);\r
+\r
+ for(i = 0; i < count; i++)\r
+ {\r
+ INT n = (INT)SendMessage(hwndCombo, CB_GETITEMDATA, i, 0);\r
+\r
+ if (n <= cursize)\r
+ nearest = i;\r
+ }\r
+\r
+ SendMessage(hwndCombo, CB_SETCURSEL, nearest, 0);\r
+\r
+ ReleaseDC(hwndCombo, hdc);\r
+}\r
+\r
+\r
+/* Initialize the font-list by enumeration all system fonts */\r
+VOID\r
+FillFontStyleComboList(HWND hwndCombo)\r
+{\r
+ HDC hdc = GetDC(hwndCombo);\r
+ LOGFONT lf;\r
+\r
+ /* FIXME: draw each font in its own style */\r
+ HFONT hFont = GetStockObject(DEFAULT_GUI_FONT);\r
+ SendMessage(hwndCombo,\r
+ WM_SETFONT,\r
+ (WPARAM)hFont,\r
+ 0);\r
+\r
+ /* FIXME: set this in relation to the widest string */\r
+ SendMessage(hwndCombo, CB_SETDROPPEDWIDTH, 150, 0);\r
+\r
+ lf.lfCharSet = ANSI_CHARSET; // DEFAULT_CHARSET;\r
+ lf.lfFaceName[0] = _T('\0'); // all fonts\r
+ lf.lfPitchAndFamily = 0;\r
+\r
+ /* store the list of fonts in the combo */\r
+ EnumFontFamiliesEx(hdc,\r
+ &lf,\r
+ (FONTENUMPROC)EnumFontNames,\r
+ (LPARAM)hwndCombo, 0);\r
+\r
+ ReleaseDC(hwndCombo,\r
+ hdc);\r
+\r
+ SendMessage(hwndCombo,\r
+ CB_SETCURSEL,\r
+ 0,\r
+ 0);\r
+}\r