diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-12 06:20:51 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-12 06:20:51 +0000 |
commit | 6c2ab603d2456c41ec977fb3fc18666439a10785 (patch) | |
tree | 75c6284dd78895e4cc7ec6b7db198e06ebdcfaa1 /plugins | |
parent | 987abc0e1d9f8f32d5565701743b40d6c0326e9e (diff) |
- fix for the button arrange procedure;
- fix for the icons' enabling/disabling;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@913 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ExternalAPI/m_toptoolbar.h | 4 | ||||
-rw-r--r-- | plugins/TopToolBar/InternalButtons.cpp | 6 | ||||
-rw-r--r-- | plugins/TopToolBar/common.h | 4 | ||||
-rw-r--r-- | plugins/TopToolBar/toolbar.cpp | 70 | ||||
-rw-r--r-- | plugins/TopToolBar/toolbarwnd.cpp | 7 | ||||
-rw-r--r-- | plugins/TopToolBar/topbutton.cpp | 28 | ||||
-rw-r--r-- | plugins/TopToolBar/ttbopt.cpp | 23 |
7 files changed, 73 insertions, 69 deletions
diff --git a/plugins/ExternalAPI/m_toptoolbar.h b/plugins/ExternalAPI/m_toptoolbar.h index 40735aa17c..6b72a179da 100644 --- a/plugins/ExternalAPI/m_toptoolbar.h +++ b/plugins/ExternalAPI/m_toptoolbar.h @@ -163,8 +163,8 @@ struct TTBCtrl int nButtonWidth;
int nButtonHeight;
int nButtonSpace;
- int nLastHeight; // fix against recursion in WM_SIZE
- int nLineCount;
+ int nLastHeight; // fix against recursion in WM_SIZE
+ BOOL bOrderChanged; // set by buttons' arrange procedure if the buttons' order was changed
BOOL bFlatButtons, bAutoSize, bSingleLine;
SortedList* pButtonList;
diff --git a/plugins/TopToolBar/InternalButtons.cpp b/plugins/TopToolBar/InternalButtons.cpp index 6f758142c7..7fcdc1cef8 100644 --- a/plugins/TopToolBar/InternalButtons.cpp +++ b/plugins/TopToolBar/InternalButtons.cpp @@ -65,15 +65,15 @@ INT_PTR TTBInternalMainMenuButt(WPARAM wParam, LPARAM lParam) INT_PTR TTBInternalGroupShowHide(WPARAM wParam, LPARAM lParam)
{
int newVal = !(GetWindowLongPtr(hwndContactTree, GWL_STYLE)&CLS_USEGROUPS);
- DBWriteContactSettingByte(NULL, "CList", "UseGroups", (BYTE)newVal);
+ 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 = !(DBGetContactSettingByte(NULL, "Skin", "UseSound", 1));
- DBWriteContactSettingByte(NULL, "Skin", "UseSound", (BYTE)newVal);
+ int newVal = !(db_get_b(NULL, "Skin", "UseSound", 1));
+ db_set_b(NULL, "Skin", "UseSound", (BYTE)newVal);
return 0;
}
diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h index 3a79ff3b59..996c3bf50f 100644 --- a/plugins/TopToolBar/common.h +++ b/plugins/TopToolBar/common.h @@ -66,6 +66,10 @@ struct TopButtonInt { return (dwFlags & TTBBF_ISSEPARATOR) != 0;
}
+ __inline bool isVisible() const
+ { return (dwFlags & TTBBF_VISIBLE) != 0;
+ }
+
HWND hwnd;
int id;
BOOL bPushed;
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp index ac81128d50..2b6f7f52f2 100644 --- a/plugins/TopToolBar/toolbar.cpp +++ b/plugins/TopToolBar/toolbar.cpp @@ -51,7 +51,7 @@ void InsertSBut(int i) ttb.cbSize = sizeof(ttb);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = TTBBF_VISIBLE|TTBBF_ISSBUTTON|TTBBF_INTERNAL;
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSBUTTON | TTBBF_INTERNAL;
ttb.wParamDown = i;
TTBAddButton(( WPARAM )&ttb, 0);
}
@@ -59,7 +59,7 @@ void InsertSBut(int i) void LoadAllSButs()
{
//must be locked
- int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "ServiceCnt", 0);
+ int cnt = db_get_b(0, TTB_OPTDIR, "ServiceCnt", 0);
if (cnt > 0) {
for (int i = 1; i<=cnt; i++)
InsertSBut(i);
@@ -96,7 +96,7 @@ void InsertLBut(int i) void LoadAllLButs()
{
//must be locked
- int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "LaunchCnt", 0);
+ int cnt = db_get_b(0, TTB_OPTDIR, "LaunchCnt", 0);
for (int i = 0; i < cnt; i++)
InsertLBut(i);
}
@@ -115,7 +115,7 @@ void InsertSeparator(int i) void LoadAllSeparators()
{
//must be locked
- int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "SepCnt", 0);
+ int cnt = db_get_b(0, TTB_OPTDIR, "SepCnt", 0);
for (int i = 0; i < cnt; i++)
InsertSeparator(i);
}
@@ -129,8 +129,8 @@ int SaveAllButtonsOptions() for (int i = 0; i < Buttons.getCount(); i++)
Buttons[i]->SaveSettings(&SeparatorCnt, &LaunchCnt);
}
- DBWriteContactSettingByte(0, TTB_OPTDIR, "SepCnt", SeparatorCnt);
- DBWriteContactSettingByte(0, TTB_OPTDIR, "LaunchCnt", LaunchCnt);
+ db_set_b(0, TTB_OPTDIR, "SepCnt", SeparatorCnt);
+ db_set_b(0, TTB_OPTDIR, "LaunchCnt", LaunchCnt);
return 0;
}
@@ -286,40 +286,32 @@ int ArrangeButtons() GetClientRect(g_ctrl->hWnd, &rcClient);
int nBarSize = rcClient.right - rcClient.left;
if (nBarSize == 0)
- return g_ctrl->nButtonHeight;
-
- g_ctrl->nLineCount = 0;
+ return 0;
+ int nLineCount = 0;
int i, ypos = 1, xpos = g_ctrl->nButtonSpace, nextX = 0, y = 0;
int newheight = g_ctrl->nButtonHeight+1;
- LIST<TopButtonInt> tmpList = Buttons;
- for (i=tmpList.getCount()-1; i >= 0; i--) {
- TopButtonInt *b = tmpList[i];
- if (b->hwnd == NULL || !(b->dwFlags & TTBBF_VISIBLE)) {
- ShowWindow(b->hwnd, SW_HIDE);
- tmpList.remove(i);
- }
- }
-
- if (tmpList.getCount() == 0)
- return g_ctrl->nButtonHeight;
+ if (Buttons.getCount() == 0)
+ return 0;
- HDWP hdwp = BeginDeferWindowPos(tmpList.getCount());
+ HDWP hdwp = BeginDeferWindowPos(Buttons.getCount());
bool bWasButttonBefore;
int nUsedWidth, iFirstButtonId = 0, iLastButtonId = 0;
do
{
- g_ctrl->nLineCount++;
+ nLineCount++;
bWasButttonBefore = false;
nUsedWidth = 0;
- for (i=iFirstButtonId; i < tmpList.getCount(); i++) {
- TopButtonInt *b = tmpList[i];
+ for (i=iFirstButtonId; i < Buttons.getCount(); i++) {
+ TopButtonInt *b = Buttons[i];
- int width = (b->isSep()) ? SEPWIDTH+2 : g_ctrl->nButtonWidth + ((bWasButttonBefore) ? g_ctrl->nButtonSpace : 0);
+ int width = 0;
+ if ( b->isVisible())
+ width = (b->isSep()) ? SEPWIDTH+2 : g_ctrl->nButtonWidth + ((bWasButttonBefore) ? g_ctrl->nButtonSpace : 0);
if (nUsedWidth + width > nBarSize)
break;
@@ -331,13 +323,20 @@ int ArrangeButtons() int nFreeSpace = nBarSize - nUsedWidth;
for (i=iFirstButtonId; i < iLastButtonId; i++) {
- TopButtonInt *b = tmpList[i];
-
- hdwp = DeferWindowPos(hdwp, b->hwnd, NULL, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
- if ( b->isSep())
- nextX += SEPWIDTH+2;
- else
- nextX += g_ctrl->nButtonWidth + g_ctrl->nButtonSpace;
+ TopButtonInt *b = Buttons[i];
+
+ bool bOldVisible = IsWindowVisible(b->hwnd) != 0;
+ if (bOldVisible != b->isVisible())
+ g_ctrl->bOrderChanged = TRUE;
+
+ if ( b->isVisible()) {
+ hdwp = DeferWindowPos(hdwp, b->hwnd, NULL, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
+ if ( b->isSep())
+ nextX += SEPWIDTH+2;
+ else
+ nextX += g_ctrl->nButtonWidth + g_ctrl->nButtonSpace;
+ }
+ else hdwp = DeferWindowPos(hdwp, Buttons[i]->hwnd, NULL, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);
}
if (iFirstButtonId == iLastButtonId)
@@ -349,15 +348,12 @@ int ArrangeButtons() if (g_ctrl->bSingleLine)
break;
}
- while (iFirstButtonId < tmpList.getCount() && y >= 0 && (g_ctrl->bAutoSize || (y + g_ctrl->nButtonHeight <= rcClient.bottom - rcClient.top)));
-
- for (i=iFirstButtonId; i < tmpList.getCount(); i++)
- hdwp = DeferWindowPos(hdwp, tmpList[i]->hwnd, NULL, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);
+ while (iFirstButtonId < Buttons.getCount() && y >= 0 && (g_ctrl->bAutoSize || (y + g_ctrl->nButtonHeight <= rcClient.bottom - rcClient.top)));
if (hdwp)
EndDeferWindowPos(hdwp);
- return (g_ctrl->nButtonHeight + g_ctrl->nButtonSpace)*g_ctrl->nLineCount - g_ctrl->nButtonSpace;
+ return (g_ctrl->nButtonHeight + g_ctrl->nButtonSpace)*nLineCount - g_ctrl->nButtonSpace;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/TopToolBar/toolbarwnd.cpp b/plugins/TopToolBar/toolbarwnd.cpp index 31cf435935..d082464b4f 100644 --- a/plugins/TopToolBar/toolbarwnd.cpp +++ b/plugins/TopToolBar/toolbarwnd.cpp @@ -163,7 +163,7 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara return 0;
case WM_LBUTTONDOWN:
- if (DBGetContactSettingByte(NULL, "CLUI", "ClientAreaDrag", 0)) {
+ if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) {
POINT pt;
GetCursorPos(&pt);
return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y));
@@ -217,6 +217,9 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara }
}
+ if (g_ctrl->bOrderChanged)
+ bResize = TRUE, g_ctrl->bOrderChanged = FALSE;
+
if ((curvis != vis || bResize) && vis != -1) {
INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, g_ctrl->hFrame), 0);
frameopt &= ~F_VISIBLE;
@@ -308,7 +311,7 @@ int LoadBackgroundOptions() hBmpBackground = NULL;
}
- if (DBGetContactSettingByte(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) {
+ if (db_get_b(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) {
DBVARIANT dbv;
if (!DBGetContactSetting(NULL, TTB_OPTDIR, "BkBitmap", &dbv)) {
hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
diff --git a/plugins/TopToolBar/topbutton.cpp b/plugins/TopToolBar/topbutton.cpp index 34a6c4d5df..8e2f8a1cfd 100644 --- a/plugins/TopToolBar/topbutton.cpp +++ b/plugins/TopToolBar/topbutton.cpp @@ -59,7 +59,7 @@ void TopButtonInt::CreateWnd() if (dwFlags & TTBBF_ASPUSHBUTTON)
SendMessage(hwnd, BUTTONSETASPUSHBTN, 1, 0);
- if (DBGetContactSettingByte(0, TTB_OPTDIR, "UseFlatButton", 1))
+ if (db_get_b(0, TTB_OPTDIR, "UseFlatButton", 1))
SendMessage(hwnd, BUTTONSETASFLATBTN, TRUE, 0);
EnableWindow(hwnd,(dwFlags & TTBBF_DISABLED)?FALSE:TRUE);
@@ -76,7 +76,7 @@ void TopButtonInt::LoadSettings() {
char buf[255];
- BYTE oldv = (dwFlags & TTBBF_VISIBLE) != 0;
+ BYTE oldv = isVisible();
dwFlags = dwFlags & (~TTBBF_VISIBLE);
if (dwFlags & TTBBF_ISSEPARATOR) {
@@ -85,8 +85,8 @@ void TopButtonInt::LoadSettings() char buf2[20];
AS(buf2, "Sep", buf1);
- arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount());
- if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
+ arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount());
+ if ( db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
dwFlags |= TTBBF_VISIBLE;
}
else if ((dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) {
@@ -101,13 +101,13 @@ void TopButtonInt::LoadSettings() mir_free(ptszProgram);
ptszProgram = DBGetStringT(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"));
- arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount());
- if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
+ arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount());
+ if ( db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
dwFlags |= TTBBF_VISIBLE;
}
else {
- arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), Buttons.getCount());
- if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), oldv) > 0 )
+ arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), Buttons.getCount());
+ if ( db_get_b(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), oldv) > 0 )
dwFlags |= TTBBF_VISIBLE;
}
@@ -125,8 +125,8 @@ void TopButtonInt::SaveSettings(int *SepCnt, int *LaunchCnt) char buf2[20];
AS(buf2, "Sep", buf1);
- DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos);
- DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), dwFlags & TTBBF_VISIBLE);
+ db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos);
+ db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), isVisible());
}
else if (LaunchCnt && (dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) {
char buf1[10];
@@ -136,12 +136,12 @@ void TopButtonInt::SaveSettings(int *SepCnt, int *LaunchCnt) DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, buf2, "_name"), pszName);
DBWriteContactSettingTString(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"), ptszProgram);
- DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos);
- DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), dwFlags & TTBBF_VISIBLE);
+ db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos);
+ db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), isVisible());
}
else {
- DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), arrangedpos);
- DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), dwFlags & TTBBF_VISIBLE);
+ db_set_b(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), arrangedpos);
+ db_set_b(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), isVisible());
}
}
diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp index 1938a710cd..3fa0b1916c 100644 --- a/plugins/TopToolBar/ttbopt.cpp +++ b/plugins/TopToolBar/ttbopt.cpp @@ -43,8 +43,7 @@ static HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST if (!(b->dwFlags & TTBBF_ISSEPARATOR))
mir_free(tmp);
- TreeView_SetCheckState(hTree, hti, (b->dwFlags & TTBBF_VISIBLE) ? TRUE : FALSE);
-
+ TreeView_SetCheckState(hTree, hti, b->isVisible());
return hti;
}
@@ -127,17 +126,19 @@ void CancelProcess(HWND hwndDlg) static void RecreateWindows()
{
- if (g_ctrl->hWnd)
- PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0);
-
- mir_cslock lck(csButtonsHook);
- for (int i = 0; i < Buttons.getCount(); i++) {
- TopButtonInt *b = Buttons[i];
- if (b->hwnd) {
- DestroyWindow(b->hwnd);
- b->CreateWnd();
+ {
+ mir_cslock lck(csButtonsHook);
+ for (int i = 0; i < Buttons.getCount(); i++) {
+ TopButtonInt *b = Buttons[i];
+ if (b->hwnd) {
+ DestroyWindow(b->hwnd);
+ b->CreateWnd();
+ }
}
}
+
+ if (g_ctrl->hWnd)
+ PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
|