summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-10 15:50:53 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-10 15:50:53 +0300
commit5fea43e9b07b966fe023105bfd9a224bfbb00e7b (patch)
tree5868406c223c0ed4cca707f258dc55c331844298 /plugins
parent271558cf6114d70da75ed474d7c04fa707ae3369 (diff)
- ability to pass a button's text to a toolbar button;
- common code moved into the core
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp4
-rw-r--r--plugins/Scriver/src/chat/window.cpp13
-rw-r--r--plugins/Scriver/src/msgdialog.cpp14
-rw-r--r--plugins/TabSRMM/src/buttonsbar.cpp70
4 files changed, 40 insertions, 61 deletions
diff --git a/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp b/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp
index 2fcbfe320a..d2a35adc46 100644
--- a/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp
+++ b/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp
@@ -59,8 +59,8 @@ static int lua_ModifyButton(lua_State *L)
INT_PTR res = Srmm_ModifyButton(bbb);
lua_pushinteger(L, res);
- mir_free(bbb->pszModuleName);
- mir_free(bbb->pwszTooltip);
+ mir_free((void*)bbb->pszModuleName);
+ mir_free((void*)bbb->pwszTooltip);
mir_free(bbb);
return 1;
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp
index aa3746fb5b..8c503be2c7 100644
--- a/plugins/Scriver/src/chat/window.cpp
+++ b/plugins/Scriver/src/chat/window.cpp
@@ -941,18 +941,7 @@ static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
mir_subclassWindow(GetDlgItem(hwndDlg, IDC_CHAT_BKGCOLOR), ButtonSubclassProc);
mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), MessageSubclassProc);
- CustomButtonData *cbd;
- for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
- if (!cbd->m_bChatButton)
- continue;
-
- HWND hwndButton = CreateWindowEx(0, L"MButtonClass", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, cbd->m_iButtonWidth, 22, hwndDlg, (HMENU)cbd->m_dwButtonCID, g_hInst, NULL);
- SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0);
- if (cbd->m_pwszTooltip)
- SendMessage(hwndButton, BUTTONADDTOOLTIP, LPARAM(cbd->m_pwszTooltip), BATF_UNICODE);
- if (cbd->m_hIcon)
- SendMessage(hwndButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon));
- }
+ Srmm_CreateToolbarIcons(hwndDlg, BBBF_ISCHATBUTTON);
RECT minEditInit;
GetWindowRect(GetDlgItem(hwndDlg, IDC_MESSAGE), &minEditInit);
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 93d659545d..fd24b73a60 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -755,19 +755,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
PostMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETSEL, len, len);
}
- CustomButtonData *cbd;
- for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
- if (!cbd->m_bIMButton)
- continue;
-
- HWND hwndButton = CreateWindowEx(0, L"MButtonClass", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, cbd->m_iButtonWidth, 22, hwndDlg, (HMENU)cbd->m_dwButtonCID, g_hInst, NULL);
- SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0);
- if (cbd->m_pwszTooltip)
- SendMessage(hwndButton, BUTTONADDTOOLTIP, LPARAM(cbd->m_pwszTooltip), BATF_UNICODE);
- if (cbd->m_hIcon)
- SendMessage(hwndButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon));
- }
-
+ Srmm_CreateToolbarIcons(hwndDlg, BBBF_ISIMBUTTON);
SendMessage(hwndDlg, DM_CHANGEICONS, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETOLECALLBACK, 0, (LPARAM)&reOleCallback);
diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp
index 6d08d323cb..27bbf632c7 100644
--- a/plugins/TabSRMM/src/buttonsbar.cpp
+++ b/plugins/TabSRMM/src/buttonsbar.cpp
@@ -156,25 +156,23 @@ void BB_InitDlgButtons(TWindowData *dat)
HWND hdlg = dat->hwnd;
if (hdlg == 0)
return;
- RECT rect;
- RECT rcSplitter;
- POINT ptSplitter;
- int splitterY;
+
BYTE gap = DPISCALEX_S(db_get_b(NULL, SRMSGMOD, "ButtonsBarGap", 1));
+ RECT rcSplitter;
GetWindowRect(GetDlgItem(hdlg, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter);
- ptSplitter.x = 0;
- ptSplitter.y = rcSplitter.top;
+ POINT ptSplitter = { 0, rcSplitter.top };
ScreenToClient(hdlg, &ptSplitter);
+ RECT rect;
GetClientRect(hdlg, &rect);
- splitterY = ptSplitter.y - DPISCALEY_S(1);
+ int splitterY = ptSplitter.y - DPISCALEY_S(1);
- HWND hwndBtn = NULL;
dat->bbLSideWidth = dat->bbRSideWidth = 0;
CustomButtonData *cbd;
for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
+ HWND hwndBtn = GetDlgItem(hdlg, cbd->m_dwButtonCID);
if (((dat->bType == SESSIONTYPE_IM && cbd->m_bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->m_bChatButton))) {
if (!cbd->m_bHidden) {
if (cbd->m_bRSided)
@@ -184,37 +182,41 @@ void BB_InitDlgButtons(TWindowData *dat)
}
if (!cbd->m_bHidden && !cbd->m_bCanBeHidden)
dat->iButtonBarReallyNeeds += cbd->m_iButtonWidth + gap;
- if (!cbd->m_bSeparator && !GetDlgItem(hdlg, cbd->m_dwButtonCID)) {
+
+ if (cbd->m_bSeparator)
+ continue;
+
+ if (hwndBtn == NULL) {
int x = cbd->m_bRSided ? rect.right - dat->bbRSideWidth + gap : 2 + dat->bbLSideWidth;
hwndBtn = CreateWindowEx(0, L"MButtonClass", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP, x, splitterY, cbd->m_iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->m_dwButtonCID, g_hInst, NULL);
+ if (hwndBtn == NULL)
+ continue;
CustomizeButton(hwndBtn);
}
- if (!cbd->m_bSeparator && hwndBtn) {
- SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, CSkin::IsThemed(), 0);
- if (cbd->m_hIcon)
- SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon));
- if (cbd->m_pwszTooltip)
- SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateW(cbd->m_pwszTooltip), BATF_UNICODE);
- SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
- SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0);
-
- if (hwndBtn) {
- if (cbd->m_dwArrowCID)
- SendMessage(hwndBtn, BUTTONSETARROW, cbd->m_dwArrowCID, 0);
- if (cbd->m_bPushButton)
- SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
- }
- }
- }
- else if (GetDlgItem(hdlg, cbd->m_dwButtonCID))
- DestroyWindow(GetDlgItem(hdlg, cbd->m_dwButtonCID));
-
- if (cbd->m_bDisabled)
- EnableWindow(hwndBtn, 0);
- if (cbd->m_bHidden)
- ShowWindow(hwndBtn, SW_HIDE);
+ SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, CSkin::IsThemed(), 0);
+ if (cbd->m_hIcon)
+ SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon));
+ if (cbd->m_pwszText)
+ SetWindowTextW(hwndBtn, cbd->m_pwszText);
+ if (cbd->m_pwszTooltip)
+ SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateW(cbd->m_pwszTooltip), BATF_UNICODE);
+ SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
+ SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0);
+
+ if (cbd->m_dwArrowCID)
+ SendMessage(hwndBtn, BUTTONSETARROW, cbd->m_dwArrowCID, 0);
+ if (cbd->m_bPushButton)
+ SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
+
+ if (cbd->m_bDisabled)
+ EnableWindow(hwndBtn, 0);
+ if (cbd->m_bHidden)
+ ShowWindow(hwndBtn, SW_HIDE);
+ }
+ else if (hwndBtn)
+ DestroyWindow(hwndBtn);
}
}