diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-07-24 09:26:39 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-07-24 09:26:39 +0000 |
commit | 1e92bf5cf72665b5fec103a0a70d734340725539 (patch) | |
tree | 7f9dc318b0e18b2cd55e2604c309eb006c11f278 /plugins/TopToolBar/src/InternalButtons.cpp | |
parent | cd441faefd073cfd368d815f4237d7b4996a1063 (diff) |
StopSpamPlus, TipperYM, TooltipNotify, TopToolBar, TranslitSwitcher, UserGuide: changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@1159 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TopToolBar/src/InternalButtons.cpp')
-rw-r--r-- | plugins/TopToolBar/src/InternalButtons.cpp | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/plugins/TopToolBar/src/InternalButtons.cpp b/plugins/TopToolBar/src/InternalButtons.cpp new file mode 100644 index 0000000000..7fcdc1cef8 --- /dev/null +++ b/plugins/TopToolBar/src/InternalButtons.cpp @@ -0,0 +1,121 @@ +
+#include "common.h"
+
+#define TTBI_GROUPSHOWHIDE "TTBInternal/GroupShowHide"
+#define TTBI_SOUNDSONOFF "TTBInternal/SoundsOnOFF"
+#define TTBI_MAINMENUBUTT "TTBInternal/MainMenuBUTT"
+
+extern HINSTANCE hInst;
+
+static HWND hwndContactTree;
+
+struct
+{
+ char *name, *pszService;
+ int iconidUp, iconidDn;
+ char *tooltipUp, *tooltipDn;
+ HANDLE hButton;
+}
+static stdButtons[] =
+{
+ { "Show only Online Users", MS_CLIST_SETHIDEOFFLINE, IDI_SHOWONLINEUP, IDI_SHOWONLINEDN, "Hide Offline Users", "Show All Users" },
+ { "Groups On/Off", TTBI_GROUPSHOWHIDE, IDI_GROUPSUP, IDI_GROUPSDN, "Hide Groups", "Show Groups" },
+ { "Sounds Enable/Disable", TTBI_SOUNDSONOFF, IDI_SOUNDUP, IDI_SOUNDDN, "Disable Sounds", "Enable Sounds" },
+
+ { "Show Options Page", "Options/OptionsCommand", IDI_OPTIONSUP, 0, "Show Options" },
+ { "Minimize Button", MS_CLIST_SHOWHIDE, IDI_MINIMIZEUP, 0, NULL },
+ { "Find/Add Contacts", MS_FINDADD_FINDADD, IDI_FINDADDUP, 0, NULL },
+ { "Show Main Menu", TTBI_MAINMENUBUTT, IDI_MIRANDAUP, 0, "Show Main Menu" }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+int OnSettingChanging(WPARAM wParam, LPARAM lParam)
+{
+ DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING *)lParam;
+ if (wParam != 0 || dbcws == NULL)
+ return 0;
+
+ if ( !strcmp(dbcws->szModule, "CList")) {
+ if ( !strcmp(dbcws->szSetting, "HideOffline"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED);
+
+ else if (!strcmp(dbcws->szSetting, "UseGroups"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED);
+ }
+
+ else if (!strcmp(dbcws->szModule, "Skin")) {
+ if (!strcmp(dbcws->szSetting, "UseSound"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton, (dbcws->value.bVal) ? TTBST_RELEASED : TTBST_PUSHED);
+ }
+
+ return 0;
+}
+
+INT_PTR TTBInternalMainMenuButt(WPARAM wParam, LPARAM lParam)
+{
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN, 0, 0);
+
+ POINT pt;
+ GetCursorPos(&pt);
+ TrackPopupMenu(hMenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL);
+ return 0;
+}
+
+INT_PTR TTBInternalGroupShowHide(WPARAM wParam, LPARAM lParam)
+{
+ int newVal = !(GetWindowLongPtr(hwndContactTree, GWL_STYLE)&CLS_USEGROUPS);
+ db_set_b(NULL, "CList", "UseGroups", (BYTE)newVal);
+ SendMessage(hwndContactTree, CLM_SETUSEGROUPS, newVal, 0);
+ return 0;
+}
+
+INT_PTR TTBInternalSoundsOnOff(WPARAM wParam, LPARAM lParam)
+{
+ int newVal = !(db_get_b(NULL, "Skin", "UseSound", 1));
+ db_set_b(NULL, "Skin", "UseSound", (BYTE)newVal);
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+int InitInternalButtons(WPARAM, LPARAM)
+{
+ hwndContactTree = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0);
+
+ CreateServiceFunction(TTBI_GROUPSHOWHIDE, TTBInternalGroupShowHide);
+ CreateServiceFunction(TTBI_SOUNDSONOFF, TTBInternalSoundsOnOff);
+ CreateServiceFunction(TTBI_MAINMENUBUTT, TTBInternalMainMenuButt);
+
+ TTBButton ttb = { 0 };
+ ttb.cbSize = sizeof(ttb);
+
+ for (int i=0; i < SIZEOF(stdButtons); i++) {
+ ttb.name = stdButtons[i].name;
+ ttb.pszService = stdButtons[i].pszService;
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_INTERNAL;
+ if ((ttb.pszTooltipDn = stdButtons[i].tooltipDn) != NULL)
+ ttb.dwFlags |= TTBBF_SHOWTOOLTIP;
+ ttb.pszTooltipUp = stdButtons[i].tooltipUp;
+ ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidUp), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ if (stdButtons[i].iconidDn) {
+ ttb.dwFlags |= TTBBF_ASPUSHBUTTON;
+ ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidDn), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ }
+ else ttb.hIconDn = NULL;
+
+ stdButtons[i].hButton = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
+ }
+
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton,
+ db_get_b(NULL, "CList", "HideOffline", 0) ? TTBST_PUSHED : TTBST_RELEASED);
+
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton,
+ db_get_b(NULL, "CList", "UseGroups", 1) ? TTBST_PUSHED : TTBST_RELEASED);
+
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton,
+ db_get_b(NULL, "Skin", "UseSound", 1) ? TTBST_RELEASED : TTBST_PUSHED);
+
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnSettingChanging);
+ return 0;
+}
|