diff options
-rw-r--r-- | plugins/TopToolBar/src/stdafx.h | 293 | ||||
-rw-r--r-- | plugins/TopToolBar/src/toolbar.cpp | 42 | ||||
-rw-r--r-- | plugins/TopToolBar/src/toolbarwnd.cpp | 28 | ||||
-rw-r--r-- | plugins/TopToolBar/src/topbutton.cpp | 14 | ||||
-rw-r--r-- | plugins/TopToolBar/src/ttbopt.cpp | 136 |
5 files changed, 254 insertions, 259 deletions
diff --git a/plugins/TopToolBar/src/stdafx.h b/plugins/TopToolBar/src/stdafx.h index 8a86393492..9f1442acf8 100644 --- a/plugins/TopToolBar/src/stdafx.h +++ b/plugins/TopToolBar/src/stdafx.h @@ -1,147 +1,148 @@ -#ifndef TTB_COMMON_H
-#define TTB_COMMON_H
-
-#include <windows.h>
-#include <commctrl.h>
-#include <stddef.h>
-
-#include <newpluginapi.h>
-#include <m_database.h>
-#include <m_skin.h>
-#include <m_clistint.h>
-#include <m_cluiframes.h>
-#include <m_clc.h>
-#include <m_findadd.h>
-#include <m_langpack.h>
-#include <m_options.h>
-#include <m_button.h>
-#include <m_icolib.h>
-
-#include <m_toptoolbar.h>
-
-#include "resource.h"
-#include "version.h"
-#include "BkgrCfg.h"
-
-#define TTB_BUTTON_CLASS L"TopToolbarButtonClass"
-
-#define TTB_REPOSBUTTONS (WM_USER+10)
-#define TTB_UPDATEFRAMEVISIBILITY (WM_USER+11)
-
-#define TTBDEFAULT_BKBMPUSE CLB_STRETCH
-#define TTBDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE)
-#define TTBDEFAULT_USEBITMAP 0
-#define TTBDEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT)
-
-#define TTBBF_INTERNAL 0x1000000
-#define TTBBF_OPTIONAL 0x2000000
-
-struct CMPlugin : public PLUGIN<CMPlugin>
-{
- CMPlugin();
-
- int Load() override;
- int Unload() override;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// TopButtonInt class
-
-struct TopButtonInt : public MZeroedObject
-{
- ~TopButtonInt();
-
- uint32_t CheckFlags(uint32_t Flags);
- void CreateWnd(void);
- void LoadSettings(void);
- void SaveSettings(int *SepCnt, int *LaunchCnt);
- void SetBitmap(void);
-
- __inline bool isSep() const
- { return (dwFlags & TTBBF_ISSEPARATOR) != 0;
- }
-
- __inline bool isVisible() const
- { return (dwFlags & TTBBF_VISIBLE) != 0;
- }
-
- HWND hwnd;
- int id;
- BOOL bPushed;
- int dwFlags;
- int x, y, arrangedpos;
- HICON hIconUp, hIconDn;
- HANDLE hIconHandleUp, hIconHandleDn;
-
- char *pszService;
- wchar_t *ptszProgram;
- char *pszName;
- wchar_t *ptszTooltip;
-
- LPARAM lParamUp;
- WPARAM wParamUp;
- LPARAM lParamDown;
- WPARAM wParamDown;
-
- HPLUGIN pPlugin;
- wchar_t *ptszTooltipUp, *ptszTooltipDn;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-int TTBOptInit(WPARAM wParam, LPARAM lParam);
-//append string
-char __inline *AS(char *str, const char *setting, char *addstr);
-
-TopButtonInt* CreateButton(TTBButton* but);
-
-int LoadBackgroundOptions();
-
-int ArrangeButtons();
-
-#define DEFBUTTWIDTH 20
-#define DEFBUTTHEIGHT 20
-#define DEFBUTTGAP 1
-
-#define SEPWIDTH 3
-
-extern TTBCtrl* g_ctrl;
-
-extern LIST<TopButtonInt> Buttons;
-extern HBITMAP hBmpBackground;
-extern mir_cs csButtonsHook;
-extern pfnCustomProc g_CustomProc;
-extern LPARAM g_CustomProcParam;
-extern HANDLE hTTBModuleLoaded;
-extern IconItem iconList[];
-
-void AddToOptions(TopButtonInt* b);
-void RemoveFromOptions(int id);
-
-//append string
-char *AS(char *str, const char *setting, char *addstr)
-{
- if (str != nullptr) {
- mir_strcpy(str, setting);
- mir_strcat(str, addstr);
- }
- return str;
-}
-
-#define TTB_LAUNCHSERVICE "TTB/LaunchService"
-
-TopButtonInt* idtopos(int id, int* pPos = nullptr);
-
-INT_PTR TTBAddButton(WPARAM, LPARAM);
-INT_PTR TTBRemoveButton(WPARAM, LPARAM);
-
-void InitInternalButtons(void);
-
-int LoadToolbarModule(void);
-int UnloadToolbarModule(void);
-
-int SaveAllButtonsOptions(void);
-
-void LoadAllSeparators();
void LoadAllLButs();
-
+#ifndef TTB_COMMON_H +#define TTB_COMMON_H + +#include <windows.h> +#include <commctrl.h> +#include <stddef.h> + +#include <newpluginapi.h> +#include <m_database.h> +#include <m_skin.h> +#include <m_clistint.h> +#include <m_cluiframes.h> +#include <m_clc.h> +#include <m_findadd.h> +#include <m_langpack.h> +#include <m_options.h> +#include <m_button.h> +#include <m_icolib.h> + +#include <m_toptoolbar.h> + +#include "resource.h" +#include "version.h" +#include "BkgrCfg.h" + +#define TTB_BUTTON_CLASS L"TopToolbarButtonClass" + +#define TTB_REPOSBUTTONS (WM_USER+10) +#define TTB_UPDATEFRAMEVISIBILITY (WM_USER+11) + +#define TTBDEFAULT_BKBMPUSE CLB_STRETCH +#define TTBDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE) +#define TTBDEFAULT_USEBITMAP 0 +#define TTBDEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT) + +#define TTBBF_INTERNAL 0x1000000 +#define TTBBF_OPTIONAL 0x2000000 + +struct CMPlugin : public PLUGIN<CMPlugin> +{ + CMPlugin(); + + int Load() override; + int Unload() override; +}; + +/////////////////////////////////////////////////////////////////////////////// +// TopButtonInt class + +struct TopButtonInt : public MZeroedObject +{ + ~TopButtonInt(); + + uint32_t CheckFlags(uint32_t Flags); + void CreateWnd(void); + void LoadSettings(void); + void SaveSettings(int *SepCnt, int *LaunchCnt); + void SetBitmap(void); + + __inline bool isSep() const + { return (dwFlags & TTBBF_ISSEPARATOR) != 0; + } + + __inline bool isVisible() const + { return (dwFlags & TTBBF_VISIBLE) != 0; + } + + HWND hwnd; + int id; + BOOL bPushed; + int dwFlags; + int x, y, arrangedpos; + HICON hIconUp, hIconDn; + HANDLE hIconHandleUp, hIconHandleDn; + + char *pszService; + wchar_t *ptszProgram; + char *pszName; + wchar_t *ptszTooltip; + + LPARAM lParamUp; + WPARAM wParamUp; + LPARAM lParamDown; + WPARAM wParamDown; + + HPLUGIN pPlugin; + wchar_t *ptszTooltipUp, *ptszTooltipDn; +}; + +/////////////////////////////////////////////////////////////////////////////// + +int TTBOptInit(WPARAM wParam, LPARAM lParam); +//append string +__inline char* AS(char *str, const char *setting, char *addstr); + +TopButtonInt* CreateButton(TTBButton* but); + +int LoadBackgroundOptions(); + +int ArrangeButtons(); + +#define DEFBUTTWIDTH 20 +#define DEFBUTTHEIGHT 20 +#define DEFBUTTGAP 1 + +#define SEPWIDTH 3 + +extern TTBCtrl *g_ctrl; + +extern LIST<TopButtonInt> g_arButtons; +extern HBITMAP hBmpBackground; +extern mir_cs csButtonsHook; +extern pfnCustomProc g_CustomProc; +extern LPARAM g_CustomProcParam; +extern HANDLE hTTBModuleLoaded; +extern IconItem iconList[]; + +void AddToOptions(TopButtonInt* b); +void RemoveFromOptions(int id); + +//append string +char *AS(char *str, const char *setting, char *addstr) +{ + if (str != nullptr) { + mir_strcpy(str, setting); + mir_strcat(str, addstr); + } + return str; +} + +#define TTB_LAUNCHSERVICE "TTB/LaunchService" + +TopButtonInt* idtopos(int id, int* pPos = nullptr); + +INT_PTR TTBAddButton(WPARAM, LPARAM); +INT_PTR TTBRemoveButton(WPARAM, LPARAM); + +void InitInternalButtons(void); + +int LoadToolbarModule(void); +int UnloadToolbarModule(void); + +int SaveAllButtonsOptions(void); + +void LoadAllSeparators(); +void LoadAllLButs(); + #endif
\ No newline at end of file diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp index b7cc9633ef..f7eb887558 100644 --- a/plugins/TopToolBar/src/toolbar.cpp +++ b/plugins/TopToolBar/src/toolbar.cpp @@ -21,14 +21,14 @@ int sortfunc(const TopButtonInt *a, const TopButtonInt *b) return a->arrangedpos - b->arrangedpos;
}
-LIST<TopButtonInt> Buttons(8, sortfunc);
+LIST<TopButtonInt> g_arButtons(8, sortfunc);
TopButtonInt *idtopos(int id, int *pPos)
{
- for (auto &it : Buttons)
+ for (auto &it : g_arButtons)
if (it->id == id) {
if (pPos)
- *pPos = Buttons.indexOf(&it);
+ *pPos = g_arButtons.indexOf(&it);
return it;
}
@@ -61,7 +61,7 @@ void LoadAllSButs() //----- Launch buttons -----
INT_PTR LaunchService(WPARAM, LPARAM lParam)
{
- for (auto &it : Buttons) {
+ for (auto &it : g_arButtons) {
if (!(it->dwFlags & TTBBF_ISLBUTTON) || it->wParamDown != (WPARAM)lParam)
continue;
@@ -123,7 +123,7 @@ int SaveAllButtonsOptions() int LaunchCnt = 0;
{
mir_cslock lck(csButtonsHook);
- for (auto &it : Buttons)
+ for (auto &it : g_arButtons)
it->SaveSettings(&SeparatorCnt, &LaunchCnt);
}
g_plugin.setByte("SepCnt", SeparatorCnt);
@@ -136,7 +136,7 @@ static bool nameexists(const char *name) if (name == nullptr)
return false;
- for (auto &it : Buttons)
+ for (auto &it : g_arButtons)
if (!mir_strcmp(it->pszName, name))
return true;
@@ -218,7 +218,7 @@ int ArrangeButtons() int i, nextX = 0, y = 0;
int nButtonCount = 0;
- for (auto &it : Buttons)
+ for (auto &it : g_arButtons)
if (it->hwnd)
nButtonCount++;
@@ -235,8 +235,8 @@ int ArrangeButtons() bWasButttonBefore = false;
nUsedWidth = 0;
- for (i = iFirstButtonId; i < Buttons.getCount(); i++) {
- TopButtonInt *b = Buttons[i];
+ for (i = iFirstButtonId; i < g_arButtons.getCount(); i++) {
+ TopButtonInt *b = g_arButtons[i];
if (b->hwnd == nullptr)
continue;
@@ -252,7 +252,7 @@ int ArrangeButtons() }
for (i = iFirstButtonId; i < iLastButtonId; i++) {
- TopButtonInt *b = Buttons[i];
+ TopButtonInt *b = g_arButtons[i];
if (b->hwnd == nullptr)
continue;
@@ -268,8 +268,8 @@ int ArrangeButtons() else
nextX += g_ctrl->nButtonWidth + g_ctrl->nButtonSpace;
} else {
- if (nullptr != Buttons[i]->hwnd) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, Buttons[i]->hwnd, nullptr, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);
+ if (nullptr != g_arButtons[i]->hwnd) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, g_arButtons[i]->hwnd, nullptr, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);
}
}
@@ -282,11 +282,11 @@ int ArrangeButtons() if (g_ctrl->bSingleLine)
break;
}
- while (iFirstButtonId < Buttons.getCount() && y >= 0 && (g_ctrl->bAutoSize || (y + g_ctrl->nButtonHeight <= rcClient.bottom - rcClient.top)));
+ while (iFirstButtonId < g_arButtons.getCount() && y >= 0 && (g_ctrl->bAutoSize || (y + g_ctrl->nButtonHeight <= rcClient.bottom - rcClient.top)));
- for (i = iLastButtonId; i < Buttons.getCount(); i++)
- if (nullptr != Buttons[i]->hwnd) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, Buttons[i]->hwnd, nullptr, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);
+ for (i = iLastButtonId; i < g_arButtons.getCount(); i++)
+ if (nullptr != g_arButtons[i]->hwnd) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, g_arButtons[i]->hwnd, nullptr, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);
if (hdwp)
EndDeferWindowPos(hdwp);
@@ -317,7 +317,7 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam) return -1;
}
mir_cslock lck(csButtonsHook);
- Buttons.insert(b);
+ g_arButtons.insert(b);
g_ctrl->bOrderChanged = TRUE;
ArrangeButtons();
@@ -338,7 +338,7 @@ INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM) RemoveFromOptions(b->id);
- Buttons.remove(idx);
+ g_arButtons.remove(idx);
delete b;
g_ctrl->bOrderChanged = TRUE;
@@ -500,7 +500,7 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam) int OnIconChange(WPARAM, LPARAM)
{
mir_cslock lck(csButtonsHook);
- for (auto &b : Buttons) {
+ for (auto &b : g_arButtons) {
if (!b->hIconHandleUp && !b->hIconHandleDn)
continue;
@@ -558,7 +558,7 @@ int OnPluginUnload(WPARAM wParam, LPARAM) bool bNeedUpdate = false;
mir_cslock lck(csButtonsHook);
- for (auto &it : Buttons.rev_iter())
+ for (auto &it : g_arButtons.rev_iter())
if (it->pPlugin == pPlugin) {
TTBRemoveButton(it->id, 0);
bNeedUpdate = true;
@@ -682,7 +682,7 @@ int UnloadToolbarModule() {
DestroyHookableEvent(hTTBModuleLoaded);
- for (auto &it : Buttons)
+ for (auto &it : g_arButtons)
delete it;
mir_free(g_ctrl);
diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp index 64a33e849c..2d11410c4c 100644 --- a/plugins/TopToolBar/src/toolbarwnd.cpp +++ b/plugins/TopToolBar/src/toolbarwnd.cpp @@ -44,16 +44,16 @@ static void PaintToolbar(HWND hwnd) int maxy = backgroundBmpUse & CLBF_TILEV ? rcPaint->bottom : y+1; int destw, desth; - switch(backgroundBmpUse & CLBM_TYPE) { + switch (backgroundBmpUse & CLBM_TYPE) { case CLB_STRETCH: if (backgroundBmpUse & CLBF_PROPORTIONAL) { if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) { desth = clRect.bottom; - destw = desth * bmp.bmWidth/bmp.bmHeight; + destw = desth * bmp.bmWidth / bmp.bmHeight; } else { destw = clRect.right; - desth = destw * bmp.bmHeight/bmp.bmWidth; + desth = destw * bmp.bmHeight / bmp.bmWidth; } } else { @@ -64,9 +64,9 @@ static void PaintToolbar(HWND hwnd) case CLB_STRETCHH: if (backgroundBmpUse & CLBF_PROPORTIONAL) { destw = clRect.right; - desth = destw * bmp.bmHeight/bmp.bmWidth; + desth = destw * bmp.bmHeight / bmp.bmWidth; if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT) - desth = g_ctrl->nButtonHeight+2; + desth = g_ctrl->nButtonHeight + 2; } else { destw = clRect.right; @@ -76,7 +76,7 @@ static void PaintToolbar(HWND hwnd) case CLB_STRETCHV: if (backgroundBmpUse & CLBF_PROPORTIONAL) { desth = clRect.bottom; - destw = desth*bmp.bmWidth/bmp.bmHeight; + destw = desth * bmp.bmWidth / bmp.bmHeight; } else { destw = bmp.bmWidth; @@ -87,7 +87,7 @@ static void PaintToolbar(HWND hwnd) destw = bmp.bmWidth; desth = bmp.bmHeight; if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT) - desth = g_ctrl->nButtonHeight+2; + desth = g_ctrl->nButtonHeight + 2; break; } @@ -100,7 +100,7 @@ static void PaintToolbar(HWND hwnd) } DeleteDC(hdcBmp); } - BitBlt(hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, hdcMem, rcPaint->left, rcPaint->top, SRCCOPY); + BitBlt(hdc, rcPaint->left, rcPaint->top, rcPaint->right - rcPaint->left, rcPaint->bottom - rcPaint->top, hdcMem, rcPaint->left, rcPaint->top, SRCCOPY); SelectObject(hdcMem, hOldBmp); DeleteDC(hdcMem); DeleteObject(hBmpOsb); @@ -115,7 +115,7 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara { static bool supressRepos = false; - switch(msg) { + switch (msg) { case WM_CREATE: g_ctrl->hWnd = hwnd; PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); @@ -143,7 +143,7 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case TTB_REPOSBUTTONS: if (g_ctrl->hWnd == hwnd) { int iHeight = ArrangeButtons(); - if ( g_ctrl->bAutoSize) { + if (g_ctrl->bAutoSize) { RECT rcClient; GetClientRect(g_ctrl->hWnd, &rcClient); rcClient.bottom -= rcClient.top; @@ -165,7 +165,7 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if (db_get_b(0, "CLUI", "ClientAreaDrag", 0)) { POINT pt; GetCursorPos(&pt); - return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y)); + return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); } return 0; @@ -177,7 +177,7 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA); if (id != 0) { mir_cslock lck(csButtonsHook); - TopButtonInt* b = idtopos(id); + TopButtonInt *b = idtopos(id); if (b == nullptr || b->isSep()) return 0; @@ -244,7 +244,7 @@ void CALLBACK OnEventFire() if (parent == nullptr) // no clist, no buttons return; - WNDCLASS wndclass = {0}; + WNDCLASS wndclass = { 0 }; wndclass.lpfnWndProc = TopToolBarProc; wndclass.cbWndExtra = sizeof(void *); wndclass.hInstance = g_plugin.getInst(); @@ -253,7 +253,7 @@ void CALLBACK OnEventFire() wndclass.lpszClassName = pluginname; RegisterClass(&wndclass); - g_ctrl->pButtonList = (SortedList *)&Buttons; + g_ctrl->pButtonList = (SortedList *)&g_arButtons; g_ctrl->hWnd = CreateWindow(pluginname, L"Toolbar", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 0, g_ctrl->nLastHeight, parent, nullptr, g_plugin.getInst(), nullptr); diff --git a/plugins/TopToolBar/src/topbutton.cpp b/plugins/TopToolBar/src/topbutton.cpp index 5fe01c3106..0588dfe46e 100644 --- a/plugins/TopToolBar/src/topbutton.cpp +++ b/plugins/TopToolBar/src/topbutton.cpp @@ -84,11 +84,11 @@ void TopButtonInt::LoadSettings() char buf2[20];
AS(buf2, "Sep", buf1);
- arrangedpos = g_plugin.getByte(AS(buf, buf2, "_Position"), Buttons.getCount());
+ arrangedpos = g_plugin.getByte(AS(buf, buf2, "_Position"), g_arButtons.getCount());
if (g_plugin.getByte(AS(buf, buf2, "_Visible"), oldv) > 0)
dwFlags |= TTBBF_VISIBLE;
}
- else if ((dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) {
+ else if ((dwFlags & TTBBF_ISLBUTTON) && (dwFlags & TTBBF_INTERNAL)) {
char buf1[10];
_itoa(wParamDown, buf1, 10);
char buf2[20];
@@ -96,21 +96,21 @@ void TopButtonInt::LoadSettings() mir_free(pszName);
pszName = g_plugin.getStringA(AS(buf, buf2, "_name"));
-
+
mir_free(ptszProgram);
ptszProgram = g_plugin.getWStringA(AS(buf, buf2, "_lpath"));
- arrangedpos = g_plugin.getByte(AS(buf, buf2, "_Position"), Buttons.getCount());
+ arrangedpos = g_plugin.getByte(AS(buf, buf2, "_Position"), g_arButtons.getCount());
if (g_plugin.getByte(AS(buf, buf2, "_Visible"), oldv) > 0)
dwFlags |= TTBBF_VISIBLE;
}
else {
- arrangedpos = g_plugin.getByte(AS(buf, pszName, "_Position"), Buttons.getCount());
+ arrangedpos = g_plugin.getByte(AS(buf, pszName, "_Position"), g_arButtons.getCount());
if (g_plugin.getByte(AS(buf, pszName, "_Visible"), oldv) > 0)
dwFlags |= TTBBF_VISIBLE;
}
- if (Buttons.getIndex(this) != -1)
+ if (g_arButtons.getIndex(this) != -1)
arrangedpos = maxid++;
}
@@ -127,7 +127,7 @@ void TopButtonInt::SaveSettings(int *SepCnt, int *LaunchCnt) g_plugin.setByte(AS(buf, buf2, "_Position"), arrangedpos);
g_plugin.setByte(AS(buf, buf2, "_Visible"), isVisible());
}
- else if (LaunchCnt && (dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) {
+ else if (LaunchCnt && (dwFlags & TTBBF_ISLBUTTON) && (dwFlags & TTBBF_INTERNAL)) {
char buf1[10];
_itoa(LaunchCnt[0]++, buf1, 10);
char buf2[20];
diff --git a/plugins/TopToolBar/src/ttbopt.cpp b/plugins/TopToolBar/src/ttbopt.cpp index 3c6db1e5c4..7cc8dc1d7d 100644 --- a/plugins/TopToolBar/src/ttbopt.cpp +++ b/plugins/TopToolBar/src/ttbopt.cpp @@ -11,14 +11,14 @@ struct OrderData /////////////////////////////////////////////////////////////////////////////////////////
-static HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST il)
+static HTREEITEM AddLine(HWND hTree, TopButtonInt *b, HTREEITEM hItem, HIMAGELIST il)
{
TVINSERTSTRUCT tvis = {};
tvis.hInsertAfter = hItem;
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
int index;
- wchar_t* tmp;
+ wchar_t *tmp;
if (b->dwFlags & TTBBF_ISSEPARATOR) {
tvis.item.pszText = L"------------------";
@@ -33,7 +33,7 @@ static HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST }
else index = ImageList_AddIcon(il, b->hIconUp);
- tmp = mir_a2u( b->pszName );
+ tmp = mir_a2u(b->pszName);
tvis.item.pszText = TranslateW(tmp);
}
tvis.item.iImage = tvis.item.iSelectedImage = index;
@@ -55,13 +55,13 @@ static int BuildTree(HWND hwndDlg) dat->himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
TreeView_SetImageList(hTree, dat->himlButtonIcons, TVSIL_NORMAL);
- SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree,GWL_STYLE)|TVS_NOHSCROLL);
+ SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE) | TVS_NOHSCROLL);
TreeView_DeleteAllItems(hTree);
- if (Buttons.getCount() == 0)
+ if (g_arButtons.getCount() == 0)
return FALSE;
- for (auto &it : Buttons)
+ for (auto &it : g_arButtons)
AddLine(hTree, it, TVI_LAST, dat->himlButtonIcons);
return TRUE;
}
@@ -77,13 +77,13 @@ static void SaveTree(HWND hwndDlg) LIST<TopButtonInt> tmpList(8);
- while(tvi.hItem != nullptr) {
+ while (tvi.hItem != nullptr) {
TreeView_GetItem(hTree, &tvi);
- TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
- Buttons.remove(btn);
+ TopButtonInt *btn = (TopButtonInt *)tvi.lParam;
+ g_arButtons.remove(btn);
- if (TreeView_GetCheckState(hTree,tvi.hItem))
+ if (TreeView_GetCheckState(hTree, tvi.hItem))
btn->dwFlags |= TTBBF_VISIBLE;
else
btn->dwFlags &= ~TTBBF_VISIBLE;
@@ -95,9 +95,9 @@ static void SaveTree(HWND hwndDlg) }
{
mir_cslock lck(csButtonsHook);
- for (auto &it : Buttons)
+ for (auto &it : g_arButtons)
delete it;
- Buttons = tmpList;
+ g_arButtons = tmpList;
}
SaveAllButtonsOptions();
}
@@ -109,14 +109,13 @@ void CancelProcess(HWND hwndDlg) TVITEM tvi = { 0 };
tvi.hItem = TreeView_GetRoot(hTree);
- while(tvi.hItem != nullptr) {
+ while (tvi.hItem != nullptr) {
tvi.stateMask = TVIS_STATEIMAGEMASK;
tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
TreeView_GetItem(hTree, &tvi);
- TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
-
- if (btn ->dwFlags & TTBBF_OPTIONAL)
+ auto *btn = (TopButtonInt *)tvi.lParam;
+ if (btn->dwFlags & TTBBF_OPTIONAL)
delete btn;
tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
@@ -127,7 +126,7 @@ static void RecreateWindows() {
{
mir_cslock lck(csButtonsHook);
- for (auto &b : Buttons) {
+ for (auto &b : g_arButtons) {
if (b->hwnd) {
if (g_ctrl->bHardUpdate) {
DestroyWindow(b->hwnd);
@@ -145,11 +144,11 @@ static void RecreateWindows() /////////////////////////////////////////////////////////////////////////////////////////
// external functions
-void AddToOptions(TopButtonInt* b)
+void AddToOptions(TopButtonInt *b)
{
if (OptionshWnd) {
HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE);
- OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);
+ OrderData *dat = (OrderData *)GetWindowLongPtr(hTree, GWLP_USERDATA);
AddLine(hTree, b, TVI_LAST, dat->himlButtonIcons);
}
}
@@ -162,15 +161,15 @@ void RemoveFromOptions(int id) tvi.hItem = TreeView_GetRoot(hTree);
tvi.mask = TVIF_PARAM | TVIF_HANDLE;
- TopButtonInt* btn;
- while(tvi.hItem != nullptr) {
+ TopButtonInt *btn;
+ while (tvi.hItem != nullptr) {
TreeView_GetItem(hTree, &tvi);
- btn = (TopButtonInt*)tvi.lParam;
+ btn = (TopButtonInt *)tvi.lParam;
if (btn->id == id) {
- // delete if was changed
+ // delete if was changed
if (btn->dwFlags & TTBBF_OPTIONAL)
delete btn;
- TreeView_DeleteItem(hTree,tvi.hItem);
+ TreeView_DeleteItem(hTree, tvi.hItem);
break;
}
@@ -185,28 +184,28 @@ void RemoveFromOptions(int id) static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
- OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);
+ OrderData *dat = (OrderData *)GetWindowLongPtr(hTree, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- dat = (OrderData*)malloc( sizeof(OrderData));
+ dat = (OrderData *)malloc(sizeof(OrderData));
SetWindowLongPtr(hTree, GWLP_USERDATA, (LONG_PTR)dat);
dat->dragging = 0;
- SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE)|TVS_NOHSCROLL);
+ SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE) | TVS_NOHSCROLL);
SetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, g_ctrl->nButtonHeight, FALSE);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETRANGE, 0, MAKELONG(50,10));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonHeight,0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETRANGE, 0, MAKELONG(50, 10));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonHeight, 0));
SetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, g_ctrl->nButtonWidth, FALSE);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, MAKELONG(50,10));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonWidth,0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, MAKELONG(50, 10));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonWidth, 0));
SetDlgItemInt(hwndDlg, IDC_BUTTGAP, g_ctrl->nButtonSpace, FALSE);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETRANGE, 0, MAKELONG(20,0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonSpace,0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETRANGE, 0, MAKELONG(20, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonSpace, 0));
CheckDlgButton(hwndDlg, IDC_USEFLAT, g_ctrl->bFlatButtons ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTORESIZE, g_ctrl->bAutoSize ? BST_CHECKED : BST_UNCHECKED);
@@ -222,7 +221,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_COMMAND:
if (HIWORD(wParam) == EN_CHANGE && OptionshWnd) {
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_ENAME: case IDC_EPATH:
break;
default:
@@ -235,12 +234,11 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int ctrlid = LOWORD(wParam);
//----- Launch buttons -----
-
if (ctrlid == IDC_BROWSE) {
wchar_t str[MAX_PATH];
- OPENFILENAME ofn = {0};
-
GetDlgItemText(hwndDlg, IDC_EPATH, str, _countof(str));
+
+ OPENFILENAME ofn = {};
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
ofn.hInstance = nullptr;
@@ -250,18 +248,15 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ofn.nMaxFile = _countof(str);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = L"exe";
- if (!GetOpenFileName(&ofn))
- break;
-
- SetDlgItemText(hwndDlg, IDC_EPATH, str);
-
+ if (GetOpenFileName(&ofn))
+ SetDlgItemText(hwndDlg, IDC_EPATH, str);
break;
}
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
if (ctrlid == IDC_LBUTTONSET) {
- TVITEM tvi ={0};
+ TVITEM tvi = { 0 };
tvi.hItem = TreeView_GetSelection(hTree);
if (tvi.hItem == nullptr)
break;
@@ -269,8 +264,8 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR tvi.mask = TVIF_PARAM;
TreeView_GetItem(hTree, &tvi);
- TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
- wchar_t buf [256];
+ TopButtonInt *btn = (TopButtonInt *)tvi.lParam;
+ wchar_t buf[256];
// probably, condition not needs
if (btn->dwFlags & TTBBF_ISLBUTTON) {
if (!(btn->dwFlags & TTBBF_OPTIONAL)) {
@@ -308,10 +303,10 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
ttb.name = LPGEN("Default");
ttb.program = L"Execute Path";
- TopButtonInt* b = CreateButton(&ttb);
+ TopButtonInt *b = CreateButton(&ttb);
// get selection for insert
- TVITEM tvi = {0};
+ TVITEM tvi = { 0 };
tvi.hItem = TreeView_GetSelection(hTree);
// insert item
@@ -327,10 +322,10 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR // create button
TTBButton ttb = {};
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL;
- TopButtonInt* b = CreateButton(&ttb);
+ TopButtonInt *b = CreateButton(&ttb);
// get selection for insert
- TVITEM tvi = {0};
+ TVITEM tvi = { 0 };
tvi.hItem = TreeView_GetSelection(hTree);
// insert item
@@ -341,7 +336,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR }
if (ctrlid == IDC_REMOVEBUTTON) {
- TVITEM tvi = {0};
+ TVITEM tvi = { 0 };
tvi.hItem = TreeView_GetSelection(hTree);
if (tvi.hItem == nullptr)
break;
@@ -349,7 +344,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR tvi.mask = TVIF_PARAM;
TreeView_GetItem(hTree, &tvi);
- TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
+ TopButtonInt *btn = (TopButtonInt *)tvi.lParam;
// if button enabled for separator and launch only, no need condition
// except possible service button introducing
if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) {
@@ -357,7 +352,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (btn->dwFlags & TTBBF_OPTIONAL)
delete btn;
- TreeView_DeleteItem(hTree,tvi.hItem);
+ TreeView_DeleteItem(hTree, tvi.hItem);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
@@ -367,14 +362,14 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
g_ctrl->nButtonHeight = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, nullptr, FALSE);
g_ctrl->nButtonWidth = GetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, nullptr, FALSE);
g_ctrl->nButtonSpace = GetDlgItemInt(hwndDlg, IDC_BUTTGAP, nullptr, FALSE);
-
+
g_ctrl->bFlatButtons = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_USEFLAT);
g_ctrl->bAutoSize = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_AUTORESIZE);
g_ctrl->bSingleLine = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_SINGLELINE);
@@ -422,12 +417,11 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (hti == nullptr)
break;
- TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam;
+ auto *btn = (TopButtonInt *)((LPNMTREEVIEW)lParam)->itemNew.lParam;
mir_cslock lck(csButtonsHook);
-
if (btn->dwFlags & TTBBF_ISLBUTTON) {
- bool enable = (btn->dwFlags & TTBBF_INTERNAL) !=0;
+ bool enable = (btn->dwFlags & TTBBF_INTERNAL) != 0;
EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), enable);
EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), enable);
@@ -443,8 +437,8 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
}
else {
- EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVEBUTTON),
- (btn->dwFlags & TTBBF_ISSEPARATOR)?TRUE:FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON),
+ (btn->dwFlags & TTBBF_ISSEPARATOR) ? TRUE : FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
@@ -467,13 +461,13 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ScreenToClient(hTree, &hti.pt);
TreeView_HitTest(hTree, &hti);
if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
- HTREEITEM it=hti.hItem;
- hti.pt.y -= TreeView_GetItemHeight(hTree)/2;
+ HTREEITEM it = hti.hItem;
+ hti.pt.y -= TreeView_GetItemHeight(hTree) / 2;
TreeView_HitTest(hTree, &hti);
- if (!(hti.flags&TVHT_ABOVE))
- TreeView_SetInsertMark(hTree,hti.hItem,1);
- else
- TreeView_SetInsertMark(hTree,it,0);
+ if (!(hti.flags & TVHT_ABOVE))
+ TreeView_SetInsertMark(hTree, hti.hItem, 1);
+ else
+ TreeView_SetInsertMark(hTree, it, 0);
}
else {
if (hti.flags & TVHT_ABOVE) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
@@ -494,18 +488,18 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR hti.pt.y = (short)HIWORD(lParam);
ClientToScreen(hwndDlg, &hti.pt);
ScreenToClient(hTree, &hti.pt);
- hti.pt.y -= TreeView_GetItemHeight(hTree)/2;
+ hti.pt.y -= TreeView_GetItemHeight(hTree) / 2;
TreeView_HitTest(hTree, &hti);
if (dat->hDragItem == hti.hItem)
break;
- if (hti.flags&TVHT_ABOVE)
- hti.hItem=TVI_FIRST;
+ if (hti.flags & TVHT_ABOVE)
+ hti.hItem = TVI_FIRST;
TVITEM tvi;
- tvi.mask = TVIF_HANDLE|TVIF_PARAM;
- tvi.hItem = (HTREEITEM) dat->hDragItem;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = (HTREEITEM)dat->hDragItem;
TreeView_GetItem(hTree, &tvi);
- if ( (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || (hti.hItem==TVI_FIRST)) {
+ if ((hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || (hti.hItem == TVI_FIRST)) {
TVINSERTSTRUCT tvis;
wchar_t name[128];
tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
|