diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-10-15 14:24:14 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-10-15 14:24:14 +0000 |
commit | 6c47d058b5138771da59c417e223fc7ad1ce001c (patch) | |
tree | a84aecb6abc13a77c8da4982aaf99457afee8847 /tipper/options.cpp | |
parent | 283b4ae7cb3ca185b9a9eb1e629b9f7278be55de (diff) |
rearranged options pages to make more room
added 'keep avatar original size' option
added background image with stretch option
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@366 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'tipper/options.cpp')
-rw-r--r-- | tipper/options.cpp | 198 |
1 files changed, 148 insertions, 50 deletions
diff --git a/tipper/options.cpp b/tipper/options.cpp index b601039..1da2d8a 100644 --- a/tipper/options.cpp +++ b/tipper/options.cpp @@ -5,6 +5,8 @@ #include <commctrl.h> #include "str_utils.h" +#include <commdlg.h> + Options options; #define WMU_ENABLE_LIST_BUTTONS (WM_USER + 0x030) @@ -310,6 +312,10 @@ void SaveOptions() { DBWriteContactSettingWord(0, MODULE, "LabelHAlign", options.label_halign); DBWriteContactSettingWord(0, MODULE, "ValueVAlign", options.value_valign); DBWriteContactSettingWord(0, MODULE, "ValueHAlign", options.value_halign); + + DBWriteContactSettingByte(0, MODULE, "NoAvatarResize", options.no_resize_av ? 1 : 0); + DBWriteContactSettingTString(0, MODULE, "BackgroundFilename", options.bg_fn); + DBWriteContactSettingByte(0, MODULE, "StretchBgImg", options.stretch_bg_img ? 1 : 0); } void LoadOptions() { @@ -430,6 +436,14 @@ void LoadOptions() { SaveOptions(); } + options.no_resize_av = (DBGetContactSettingByte(0, MODULE, "NoAvatarResize", 0) == 1); + DBVARIANT dbv; + if(!DBGetContactSettingTString(0, MODULE, "BackgroundFilename", &dbv)) { + _tcsncpy(options.bg_fn, dbv.ptszVal, MAX_PATH); + DBFreeVariant(&dbv); + } else + options.bg_fn[0] = 0; + options.stretch_bg_img = (DBGetContactSettingByte(0, MODULE, "StretchBgImg", 0) == 1); } static BOOL CALLBACK DlgProcAddItem(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -560,7 +574,7 @@ static BOOL CALLBACK DlgProcAddSubst(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return 0; } -static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { +static BOOL CALLBACK DlgProcOptContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_INITDIALOG: @@ -886,15 +900,86 @@ static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return 0; } - -static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { +static BOOL CALLBACK DlgProcOptWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); + SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_MINWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_MINHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, options.win_width, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, options.win_max_height, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, options.min_width, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, options.min_height, FALSE); + + SetDlgItemInt(hwndDlg, IDC_ED_TRANS, options.opacity, FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_TRANSBG, options.trans_bg); CheckDlgButton(hwndDlg, IDC_CHK_NOFOCUS, options.show_no_focus ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_CHK_SBAR, options.status_bar_tips ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_BORDER, options.border); + CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, options.round); + CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, options.av_round); + + CheckDlgButton(hwndDlg, IDC_CHK_ANIMATE, options.animate); + CheckDlgButton(hwndDlg, IDC_CHK_SHADOW, options.drop_shadow); + + SendDlgItemMessage(hwndDlg, IDC_SPIN_HOVER, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 5)); + SetDlgItemInt(hwndDlg, IDC_ED_HOVER, options.time_in, FALSE); + break; + case WM_COMMAND: + if ( HIWORD( wParam ) == CBN_SELCHANGE) { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } else if ( HIWORD( wParam ) == BN_CLICKED ) { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + case WM_NOTIFY: + if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) { + BOOL trans; + int new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE); + if(trans) options.win_width = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, &trans, FALSE); + if(trans) options.min_width = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE); + if(trans) options.win_max_height = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, &trans, FALSE); + if(trans) options.min_height = new_val; + + new_val = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &trans, FALSE); + if(trans) options.opacity = new_val; + options.trans_bg = IsDlgButtonChecked(hwndDlg, IDC_CHK_TRANSBG) ? true : false; + + new_val = GetDlgItemInt(hwndDlg, IDC_ED_HOVER, &trans, FALSE); + if(trans) options.time_in = new_val; + + options.border = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_BORDER)) ? true : false; + options.round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS)) ? true : false; + options.av_round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false; + options.animate = IsDlgButtonChecked(hwndDlg, IDC_CHK_ANIMATE) ? true : false; + options.drop_shadow = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHADOW) ? true : false; + + options.show_no_focus = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOFOCUS) ? true : false; + options.status_bar_tips = IsDlgButtonChecked(hwndDlg, IDC_CHK_SBAR) ? true : false; + + SaveOptions(); + return TRUE; + } + break; + } + return 0; +} + +static BOOL CALLBACK DlgProcOptLayout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + + switch ( msg ) { + case WM_INITDIALOG: + TranslateDialogDefault( hwndDlg ); SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left")); SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right")); @@ -954,39 +1039,36 @@ static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)options.av_layout, 0); - SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_MINWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_MINHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(99, 0)); SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16)); SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); SendDlgItemMessage(hwndDlg, IDC_SPIN_TEXTPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); SendDlgItemMessage(hwndDlg, IDC_SPIN_AVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_HOVER, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 5)); SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0)); - SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, options.win_width, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, options.win_max_height, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, options.min_width, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, options.min_height, FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_NORESIZEAV, options.no_resize_av); + if(options.no_resize_av) { + HWND hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE); + EnableWindow(hw, FALSE); + hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE); + EnableWindow(hw, FALSE); + } SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, options.av_size, FALSE); SetDlgItemInt(hwndDlg, IDC_ED_INDENT, options.text_indent, FALSE); SetDlgItemInt(hwndDlg, IDC_ED_PADDING, options.padding, FALSE); SetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, options.text_padding, FALSE); SetDlgItemInt(hwndDlg, IDC_ED_AVPADDING, options.av_padding, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_HOVER, options.time_in, FALSE); SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, options.sidebar_width, FALSE); - - SetDlgItemInt(hwndDlg, IDC_ED_TRANS, options.opacity, FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_BORDER, options.border); - CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, options.round); - CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, options.av_round); - - CheckDlgButton(hwndDlg, IDC_CHK_ANIMATE, options.animate); - CheckDlgButton(hwndDlg, IDC_CHK_SHADOW, options.drop_shadow); - CheckDlgButton(hwndDlg, IDC_CHK_TRANSBG, options.trans_bg); +
+ SetDlgItemText(hwndDlg, IDC_ED_BGFN, options.bg_fn);
+ CheckDlgButton(hwndDlg, IDC_CHK_STRETCHBG, options.stretch_bg_img); + if(!ServiceExists(MS_IMG_LOAD)) { + HWND hw = GetDlgItem(hwndDlg, IDC_ED_BGFN); + EnableWindow(hw, FALSE); + hw = GetDlgItem(hwndDlg, IDC_CHK_STRETCHBG); + EnableWindow(hw, FALSE); + } return FALSE; case WM_COMMAND: @@ -995,21 +1077,39 @@ static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } else if ( HIWORD( wParam ) == BN_CLICKED ) { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + if(LOWORD(wParam) == IDC_BTN_BROWSE) { + TCHAR tempBgFn[MAX_PATH]; + tempBgFn[0] = 0; + OPENFILENAME ofn={0};
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = hwndDlg;
+ ofn.lpstrFile = tempBgFn;
+ ofn.lpstrFilter=_T("All Files (*.*)\0*.*\0\0");
+ ofn.nFilterIndex = 1;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags=OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = _T(".");
+ ofn.lpstrDefExt=_T("");
+ if (GetOpenFileName(&ofn)) {
+ SetDlgItemText(hwndDlg, IDC_ED_BGFN, tempBgFn);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + }
+ } else { + if(LOWORD(wParam) == IDC_CHK_NORESIZEAV) { + bool checked = IsDlgButtonChecked(hwndDlg, IDC_CHK_NORESIZEAV); + HWND hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE); + EnableWindow(hw, !checked); + hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE); + EnableWindow(hw, !checked); + } + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) { BOOL trans; int new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE); - if(trans) options.win_width = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, &trans, FALSE); - if(trans) options.min_width = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE); - if(trans) options.win_max_height = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, &trans, FALSE); - if(trans) options.min_height = new_val; new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE); if(trans) options.av_size = new_val; new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE); @@ -1020,8 +1120,6 @@ static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if(trans) options.text_padding = new_val; new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVPADDING, &trans, FALSE); if(trans) options.av_padding = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_HOVER, &trans, FALSE); - if(trans) options.time_in = new_val; new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE); if(trans) options.sidebar_width = new_val; @@ -1029,18 +1127,6 @@ static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM options.av_layout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0); options.pos = (PopupPosition)SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_GETCURSEL, 0, 0); - new_val = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &trans, FALSE); - if(trans) options.opacity = new_val; - options.border = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_BORDER)) ? true : false; - options.round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS)) ? true : false; - options.av_round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false; - options.animate = IsDlgButtonChecked(hwndDlg, IDC_CHK_ANIMATE) ? true : false; - options.drop_shadow = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHADOW) ? true : false; - options.trans_bg = IsDlgButtonChecked(hwndDlg, IDC_CHK_TRANSBG) ? true : false; - - options.show_no_focus = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOFOCUS) ? true : false; - options.status_bar_tips = IsDlgButtonChecked(hwndDlg, IDC_CHK_SBAR) ? true : false; - switch(SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_GETCURSEL, 0, 0)) { case 0: options.label_valign = DT_TOP; break; case 1: options.label_valign = DT_VCENTER; break; @@ -1061,6 +1147,10 @@ static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case 1: options.value_halign = DT_RIGHT; break; } + options.no_resize_av = IsDlgButtonChecked(hwndDlg, IDC_CHK_NORESIZEAV) ? true : false; + GetDlgItemText(hwndDlg, IDC_ED_BGFN, options.bg_fn, MAX_PATH); + options.stretch_bg_img = IsDlgButtonChecked(hwndDlg, IDC_CHK_STRETCHBG) ? true : false; + SaveOptions(); return TRUE; } @@ -1083,20 +1173,28 @@ int OptInit(WPARAM wParam, LPARAM lParam) { odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1); - odp.pszTab = Translate("Appearance"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_WINDOW); + odp.pszTab = Translate("Window"); + odp.pszTitle = (mirVir >= 0x00060000 ? Translate("Tooltips") : Translate("Tooltips View"));; + odp.pszGroup = Translate("Customize"); + odp.nIDBottomSimpleControl = 0; + odp.pfnDlgProc = DlgProcOptWindow; + CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp ); + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_LAYOUT); + odp.pszTab = Translate("Layout"); odp.pszTitle = (mirVir >= 0x00060000 ? Translate("Tooltips") : Translate("Tooltips View"));; odp.pszGroup = Translate("Customize"); odp.nIDBottomSimpleControl = 0; - odp.pfnDlgProc = DlgProcOpts1; + odp.pfnDlgProc = DlgProcOptLayout; CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp ); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT2); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CONTENT); odp.pszTab = Translate("Content"); odp.pszTitle = (mirVir >= 0x00060000 ? Translate("Tooltips") : Translate("Tooltips Content"));; odp.pszGroup = Translate("Customize"); odp.nIDBottomSimpleControl = 0; - odp.pfnDlgProc = DlgProcOpts2; + odp.pfnDlgProc = DlgProcOptContent; CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp ); return 0; |