[PATCH] winecfg: Add menu font settings to desktop integration tab
Nigel Liang
ncliang at gmail.com
Wed Jul 25 17:01:52 CDT 2007
diff --git a/programs/winecfg/En.rc b/programs/winecfg/En.rc
index 5972c3b..e61bf29 100644
--- a/programs/winecfg/En.rc
+++ b/programs/winecfg/En.rc
@@ -200,6 +200,11 @@ BEGIN
CONTROL "Link to:",IDC_LINK_SFPATH,"Button",BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED,15,195,50,13
EDITTEXT IDC_EDIT_SFPATH,65,195,145,13,ES_AUTOHSCROLL|WS_TABSTOP|WS_DISABLED
PUSHBUTTON "Browse",IDC_BROWSE_SFPATH,215,195,30,13,WS_DISABLED
+ GROUPBOX " Menu Font ",IDC_STATIC,8,216,244,50
+ LTEXT "Font: ",IDC_STATIC,20,230,40,10
+ COMBOBOX IDC_MENUFONT_COMBO,55,228,186,30,CBS_DROPDOWNLIST|CBS_SORT|WS_VSCROLL|WS_TABSTOP
+ LTEXT "Size: ",IDC_STATIC,20,249,40,10
+ COMBOBOX IDC_MENUFONT_SIZECOMBO,55,247,50,30,CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP
END
STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h
index 811a115..5f0fb29 100644
--- a/programs/winecfg/resource.h
+++ b/programs/winecfg/resource.h
@@ -228,3 +228,6 @@ #define IDC_SYSPARAMS_ACTIVE_TITLE
#define IDC_SYSPARAMS_ACTIVE_TITLE_TEXT 8413
#define IDC_SYSPARAMS_INACTIVE_TITLE 8414
#define IDC_SYSPARAMS_INACTIVE_TITLE_TEXT 8415
+
+#define IDC_MENUFONT_COMBO 8416
+#define IDC_MENUFONT_SIZECOMBO 8417
diff --git a/programs/winecfg/theme.c b/programs/winecfg/theme.c
index 4f3a377..5bae8c8 100644
--- a/programs/winecfg/theme.c
+++ b/programs/winecfg/theme.c
@@ -43,6 +43,16 @@ #include "winecfg.h"
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
+#define MAXBUFLEN 256
+#define MINMENUFONTSIZE 8
+#define MAXMENUFONTSIZE 20
+#define DEFMENUFONTSIZE 12
+
+static const WCHAR desktop[] = { 'd', 'e', 's', 'k', 't', 'o', 'p', 0 };
+static const WCHAR menufont[] = { 'M', 'e', 'n', 'u', 'F', 'o', 'n', 't', 0 };
+static const WCHAR menufontsize[] =
+ { 'M', 'e', 'n', 'u', 'F', 'o', 'n', 't', 'S', 'i', 'z', 'e', 0 };
+
/* UXTHEME functions not in the headers */
typedef struct tagTHEMENAMES
@@ -960,6 +970,120 @@ static void on_draw_item(HWND hDlg, WPAR
}
}
+static long wcstolong(WCHAR * wcs)
+{
+ int i;
+ long lRet = 0;
+ BOOL bNeg = FALSE;
+
+ for (i = 0; wcs[i] != '\0'; i++) {
+ if (i == 0 && wcs[i] == '-') {
+ bNeg = TRUE;
+ continue;
+ }
+
+ lRet = lRet * 10 + (wcs[i] - '0');
+ }
+ return (bNeg ? -lRet : lRet);
+}
+
+static WCHAR *longtow(long num, WCHAR *wcs)
+{
+ static const WCHAR str[] = { '%', 'l', 'd', 0 };
+ wsprintfW(wcs, str, num);
+ return wcs;
+}
+
+static INT read_menu_font(WCHAR * szMenuFont)
+{
+ static const WCHAR tahoma[] = { 'T', 'a', 'h', 'o', 'm', 'a', 0 };
+ return GetProfileStringW(desktop, menufont, tahoma, szMenuFont,
+ sizeof(szMenuFont));
+}
+
+static BOOL write_menu_font(WCHAR * szMenuFont)
+{
+ return WriteProfileStringW(desktop, menufont, szMenuFont);
+}
+
+static long read_menu_font_size()
+{
+ WCHAR szMenuFontSize[MAXBUFLEN];
+ GetProfileStringW(desktop, menufontsize, NULL, szMenuFontSize,
+ sizeof(WCHAR) * MAXBUFLEN);
+ WINE_TRACE("MenuFontSize: %s\n", wine_dbgstr_w(szMenuFontSize));
+ return wcstolong(szMenuFontSize);
+}
+
+static BOOL write_menu_font_size(WCHAR * szMenuFontSize)
+{
+ return WriteProfileStringW(desktop, menufontsize, szMenuFontSize);
+}
+
+static void write_menu_font_profile(HWND hDlg)
+{
+ WCHAR szBuf[MAXBUFLEN];
+ HWND hMenuFontCombo = GetDlgItem(hDlg, IDC_MENUFONT_COMBO);
+ HWND hMenuFontSizeCombo = GetDlgItem(hDlg, IDC_MENUFONT_SIZECOMBO);
+ int i;
+
+ i = SendMessageW(hMenuFontCombo, CB_GETCURSEL, 0, 0);
+ SendMessageW(hMenuFontCombo, CB_GETLBTEXT, i, (LPARAM) szBuf);
+ write_menu_font(szBuf);
+
+ i = SendMessageW(hMenuFontSizeCombo, CB_GETCURSEL, 0, 0);
+ SendMessageW(hMenuFontSizeCombo, CB_GETLBTEXT, i, (LPARAM) szBuf);
+ write_menu_font_size(szBuf);
+}
+
+BOOL CALLBACK init_menu_font_combo_callback(ENUMLOGFONT * lpelf,
+ NEWTEXTMETRIC * lpntm,
+ DWORD FontType,
+ LPARAM lparam)
+{
+ HWND hMenuFontCombo = (HWND) lparam;
+ LOGFONT lf = lpelf->elfLogFont;
+ if (SendMessageW(hMenuFontCombo, CB_FINDSTRINGEXACT, 0,
+ (LPARAM) lf.lfFaceName) == CB_ERR)
+ SendMessageW(hMenuFontCombo, CB_ADDSTRING, 0, (LPARAM) lf.lfFaceName);
+ return 1;
+}
+
+static void init_menu_font_combo(HWND hDlg)
+{
+ WCHAR szDefMenuFont[MAXBUFLEN];
+ HDC hdc = GetDC(0);
+ HWND hMenuFontCombo = GetDlgItem(hDlg, IDC_MENUFONT_COMBO);
+
+ EnumFontFamiliesW(hdc, NULL, (FONTENUMPROCW) init_menu_font_combo_callback,
+ (LPARAM) hMenuFontCombo);
+
+ read_menu_font(szDefMenuFont);
+ WINE_TRACE("MenuFont: %s\n", wine_dbgstr_w(szDefMenuFont));
+ SendMessageW(hMenuFontCombo, CB_SELECTSTRING, 0, (LPARAM) szDefMenuFont);
+}
+
+static void init_menu_font_size_combo(HWND hDlg)
+{
+ WCHAR szSize[MAXBUFLEN];
+ HWND hMenuFontSizeCombo = GetDlgItem(hDlg, IDC_MENUFONT_SIZECOMBO);
+ int i;
+
+ for (i = MINMENUFONTSIZE; i <= MAXMENUFONTSIZE; i++) {
+ longtow(i, szSize);
+ SendMessageW(hMenuFontSizeCombo, CB_ADDSTRING, 0, (LPARAM) szSize);
+ }
+
+ i = read_menu_font_size();
+ WINE_TRACE("read_menu_font_size returned: %d\n", i);
+ if (i)
+ longtow(i, szSize);
+ else
+ longtow(DEFMENUFONTSIZE, szSize);
+
+ SendMessageW(hMenuFontSizeCombo, CB_SELECTSTRING, 0, (LPARAM) szSize);
+}
+
INT_PTR CALLBACK
ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@@ -969,6 +1093,8 @@ ThemeDlgProc (HWND hDlg, UINT uMsg, WPAR
init_shell_folder_listview_headers(hDlg);
update_shell_folder_listview(hDlg);
read_sysparams(hDlg);
+ init_menu_font_combo(hDlg);
+ init_menu_font_size_combo(hDlg);
break;
case WM_DESTROY:
@@ -1083,6 +1209,7 @@ ThemeDlgProc (HWND hDlg, UINT uMsg, WPAR
apply_sysparams();
read_shell_folder_link_targets();
update_shell_folder_listview(hDlg);
+ write_menu_font_profile(hDlg);
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
break;
}
--
1.4.1
More information about the wine-patches
mailing list