summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src/utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-06 14:22:46 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-06 14:23:55 +0300
commitc8e8e884a6a632c5766eddab2d84c6a6b2216d6c (patch)
treedb983f5c371bd7f3c5190dcd6f6f3171947ad105 /plugins/Scriver/src/utils.cpp
parent8271ae317370f9c27de576075a2d779ccaf9a560 (diff)
StdMsg & Scriver:
- switched to the toolbar buttons instead of the fixed button set; - switched to the shared windows list
Diffstat (limited to 'plugins/Scriver/src/utils.cpp')
-rw-r--r--plugins/Scriver/src/utils.cpp72
1 files changed, 27 insertions, 45 deletions
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp
index e52f9db5cc..2bf9c3c699 100644
--- a/plugins/Scriver/src/utils.cpp
+++ b/plugins/Scriver/src/utils.cpp
@@ -434,54 +434,36 @@ void SetToolTipRect(HWND hwndParent, HWND hwndTT, RECT *rect)
SendMessage(hwndTT, TTM_NEWTOOLRECT, 0, (LPARAM)&ti);
}
-/* toolbar-related stuff, to be moved to a separate file */
-
-HDWP ResizeToolbar(HWND hwnd, HDWP hdwp, int width, int vPos, int height, int cControls, const ToolbarButton *buttons, int controlVisibility)
+void SetButtonsPos(HWND hwndDlg)
{
- HWND hCtrl;
- int i;
- int lPos = 0;
- int rPos = width;
- for (i = 0; i < cControls; i++) {
- if (!buttons[i].alignment && (controlVisibility & (1 << i))) {
- lPos += buttons[i].spacing;
- hCtrl = GetDlgItem(hwnd, buttons[i].controlId);
- if (NULL != hCtrl) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hCtrl, 0, lPos, vPos, buttons[i].width, height, SWP_NOZORDER);
- lPos += buttons[i].width;
+ HDWP hdwp = BeginDeferWindowPos(Srmm_GetButtonCount());
+
+ RECT rc;
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_SPLITTERY), &rc);
+ POINT pt = { 0, rc.top };
+ ScreenToClient(hwndDlg, &pt);
+ pt.y -= 20;
+
+ GetClientRect(hwndDlg, &rc);
+ int iLeftX = 2, iRightX = rc.right - 2;
+ int iGap = db_get_b(NULL, SRMMMOD, "ButtonsBarGap", 1);
+
+ CustomButtonData *cbd;
+ for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
+ HWND hwndButton = GetDlgItem(hwndDlg, cbd->m_dwButtonCID);
+ if (hwndButton == NULL)
+ continue;
+
+ int width = iGap + ((cbd->m_dwArrowCID) ? 34 : 22);
+ if (cbd->m_bRSided) {
+ iRightX -= width;
+ hdwp = DeferWindowPos(hdwp, hwndButton, NULL, iRightX, pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
- }
- for (i = cControls - 1; i >= 0; i--) {
- if (buttons[i].alignment && (controlVisibility & (1 << i))) {
- rPos -= buttons[i].spacing + buttons[i].width;
- hCtrl = GetDlgItem(hwnd, buttons[i].controlId);
- if (NULL != hCtrl) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hCtrl, 0, rPos, vPos, buttons[i].width, height, SWP_NOZORDER);
+ else {
+ hdwp = DeferWindowPos(hdwp, hwndButton, NULL, iLeftX, pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ iLeftX += width;
}
}
- return hdwp;
-}
-
-void ShowToolbarControls(HWND hwndDlg, int cControls, const ToolbarButton* buttons, int controlVisibility, int state)
-{
- for (int i = 0; i < cControls; i++)
- ShowWindow(GetDlgItem(hwndDlg, buttons[i].controlId), (controlVisibility & (1 << i)) ? state : SW_HIDE);
-}
-
-int GetToolbarWidth(int cControls, const ToolbarButton *buttons)
-{
- int w = 0;
- for (int i = 0; i < cControls; i++)
- w += buttons[i].width + buttons[i].spacing;
-
- return w;
-}
-
-BOOL IsToolbarVisible(int cControls, int visibilityFlags)
-{
- for (int i = 0; i < cControls; i++)
- if (visibilityFlags & (1 << i))
- return TRUE;
- return FALSE;
+ EndDeferWindowPos(hdwp);
}