From 992b68811f8697ff3bf93ff10288d93022f58f53 Mon Sep 17 00:00:00 2001 From: George Hazan <ghazan@miranda.im> Date: Tue, 13 Nov 2018 21:48:27 +0300 Subject: TopToolBar -> g_plugin --- plugins/TopToolBar/src/toolbar.cpp | 34 +++++++++++++++++----------------- plugins/TopToolBar/src/toolbarwnd.cpp | 10 +++++----- plugins/TopToolBar/src/topbutton.cpp | 34 +++++++++++++++++----------------- plugins/TopToolBar/src/ttbopt.cpp | 12 ++++++------ 4 files changed, 45 insertions(+), 45 deletions(-) (limited to 'plugins/TopToolBar') diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp index 633f9ad155..24873ae5ce 100644 --- a/plugins/TopToolBar/src/toolbar.cpp +++ b/plugins/TopToolBar/src/toolbar.cpp @@ -51,7 +51,7 @@ void InsertSBut(int i) void LoadAllSButs() { //must be locked - int cnt = db_get_b(0, TTB_OPTDIR, "ServiceCnt", 0); + int cnt = g_plugin.getByte("ServiceCnt", 0); if (cnt > 0) { for (int i = 1; i <= cnt; i++) InsertSBut(i); @@ -83,14 +83,14 @@ void LoadAllLButs() { TTBButton ttb = {}; - int cnt = db_get_b(0, TTB_OPTDIR, "LaunchCnt", 0); + int cnt = g_plugin.getByte("LaunchCnt", 0); for (int i = 0; i < cnt; i++) { char buf[255], buf1[10], buf2[100]; _itoa(i, buf1, 10); AS(buf2, "Launch", buf1); - ptrA szName(db_get_sa(0, TTB_OPTDIR, AS(buf, buf2, "_name"))); - ptrW wszProgram(db_get_wsa(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"))); + ptrA szName(g_plugin.getStringA(AS(buf, buf2, "_name"))); + ptrW wszProgram(g_plugin.getWStringA(AS(buf, buf2, "_lpath"))); if (szName == nullptr || wszProgram == nullptr) continue; @@ -109,7 +109,7 @@ void LoadAllSeparators() { TTBButton ttb = {}; - int cnt = db_get_b(0, TTB_OPTDIR, "SepCnt", 0); + int cnt = g_plugin.getByte("SepCnt", 0); for (int i = 0; i < cnt; i++) { ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL; ttb.wParamDown = i; @@ -126,8 +126,8 @@ int SaveAllButtonsOptions() for (auto &it : Buttons) it->SaveSettings(&SeparatorCnt, &LaunchCnt); } - db_set_b(0, TTB_OPTDIR, "SepCnt", SeparatorCnt); - db_set_b(0, TTB_OPTDIR, "LaunchCnt", LaunchCnt); + g_plugin.setByte("SepCnt", SeparatorCnt); + g_plugin.setByte("LaunchCnt", LaunchCnt); return 0; } @@ -623,23 +623,23 @@ static LRESULT CALLBACK TTBButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA int LoadToolbarModule() { if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - if (!db_get_b(0, TTB_OPTDIR, "WarningDone", 0)) + if (!g_plugin.getByte("WarningDone", 0)) MessageBox(nullptr, TranslateT("Frames service has not been found, so plugin will be disabled.\nTo run it you need to install and / or enable contact list plugin that supports it:\n- Modern contact list\n- Clist nicer\nYou can get them at https://wiki.miranda-ng.org/Download"), TranslateT("TopToolBar"), 0); - db_set_b(0, TTB_OPTDIR, "WarningDone", 1); + g_plugin.setByte("WarningDone", 1); return 1; } g_ctrl = (TTBCtrl *)mir_calloc(sizeof(TTBCtrl)); - g_ctrl->nButtonHeight = db_get_dw(0, TTB_OPTDIR, "BUTTHEIGHT", DEFBUTTHEIGHT); - g_ctrl->nButtonWidth = db_get_dw(0, TTB_OPTDIR, "BUTTWIDTH", DEFBUTTWIDTH); - g_ctrl->nButtonSpace = db_get_dw(0, TTB_OPTDIR, "BUTTGAP", DEFBUTTGAP); - g_ctrl->nLastHeight = db_get_dw(0, TTB_OPTDIR, "LastHeight", DEFBUTTHEIGHT); + g_ctrl->nButtonHeight = g_plugin.getDword("BUTTHEIGHT", DEFBUTTHEIGHT); + g_ctrl->nButtonWidth = g_plugin.getDword("BUTTWIDTH", DEFBUTTWIDTH); + g_ctrl->nButtonSpace = g_plugin.getDword("BUTTGAP", DEFBUTTGAP); + g_ctrl->nLastHeight = g_plugin.getDword("LastHeight", DEFBUTTHEIGHT); - g_ctrl->bFlatButtons = db_get_b(0, TTB_OPTDIR, "UseFlatButton", true); - g_ctrl->bSingleLine = db_get_b(0, TTB_OPTDIR, "SingleLine", true); - g_ctrl->bAutoSize = db_get_b(0, TTB_OPTDIR, "AutoSize", true); + g_ctrl->bFlatButtons = g_plugin.getByte("UseFlatButton", true); + g_ctrl->bSingleLine = g_plugin.getByte("SingleLine", true); + g_ctrl->bAutoSize = g_plugin.getByte("AutoSize", true); - db_unset(NULL, TTB_OPTDIR, "WarningDone"); + g_plugin.delSetting("WarningDone"); HookEvent(ME_SYSTEM_MODULELOAD, OnPluginLoad); HookEvent(ME_SYSTEM_MODULEUNLOAD, OnPluginUnload); diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp index 88a918cc29..64a33e849c 100644 --- a/plugins/TopToolBar/src/toolbarwnd.cpp +++ b/plugins/TopToolBar/src/toolbarwnd.cpp @@ -131,7 +131,7 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_WINDOWPOSCHANGING: case WM_SIZE: if (g_ctrl->nLastHeight != HIWORD(lParam)) { - db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam)); + g_plugin.setDword("LastHeight", g_ctrl->nLastHeight = HIWORD(lParam)); ArrangeButtons(); } if (supressRepos) { @@ -289,18 +289,18 @@ void CALLBACK OnEventFire() int LoadBackgroundOptions() { - bkColour = db_get_dw(0, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR); + bkColour = g_plugin.getDword("BkColour", TTBDEFAULT_BKCOLOUR); if (hBmpBackground) { DeleteObject(hBmpBackground); hBmpBackground = nullptr; } - if (db_get_b(0, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) { - ptrW tszBitmapName(db_get_wsa(NULL, TTB_OPTDIR, "BkBitmap")); + if (g_plugin.getByte("UseBitmap", TTBDEFAULT_USEBITMAP)) { + ptrW tszBitmapName(g_plugin.getWStringA("BkBitmap")); if (tszBitmapName != NULL) hBmpBackground = Bitmap_Load(tszBitmapName); } - backgroundBmpUse = db_get_w(0, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE); + backgroundBmpUse = g_plugin.getWord("BkBmpUse", TTBDEFAULT_BKBMPUSE); RECT rc; GetClientRect(g_ctrl->hWnd, &rc); diff --git a/plugins/TopToolBar/src/topbutton.cpp b/plugins/TopToolBar/src/topbutton.cpp index 7a4c357ac7..9b5a9aa685 100644 --- a/plugins/TopToolBar/src/topbutton.cpp +++ b/plugins/TopToolBar/src/topbutton.cpp @@ -58,7 +58,7 @@ void TopButtonInt::CreateWnd() if (dwFlags & TTBBF_ASPUSHBUTTON) SendMessage(hwnd, BUTTONSETASPUSHBTN, 1, 0); - if (db_get_b(0, TTB_OPTDIR, "UseFlatButton", 1)) + if (g_plugin.getByte("UseFlatButton", 1)) SendMessage(hwnd, BUTTONSETASFLATBTN, TRUE, 0); EnableWindow(hwnd, (dwFlags & TTBBF_DISABLED) ? FALSE : TRUE); @@ -84,8 +84,8 @@ void TopButtonInt::LoadSettings() char buf2[20]; AS(buf2, "Sep", buf1); - 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) + arrangedpos = g_plugin.getByte(AS(buf, buf2, "_Position"), Buttons.getCount()); + if (g_plugin.getByte(AS(buf, buf2, "_Visible"), oldv) > 0) dwFlags |= TTBBF_VISIBLE; } else if ((dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) { @@ -95,18 +95,18 @@ void TopButtonInt::LoadSettings() AS(buf2, "Launch", buf1); mir_free(pszName); - pszName = db_get_sa(0, TTB_OPTDIR, AS(buf, buf2, "_name")); + pszName = g_plugin.getStringA(AS(buf, buf2, "_name")); mir_free(ptszProgram); - ptszProgram = db_get_wsa(0, TTB_OPTDIR, AS(buf, buf2, "_lpath")); + ptszProgram = g_plugin.getWStringA(AS(buf, buf2, "_lpath")); - 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) + arrangedpos = g_plugin.getByte(AS(buf, buf2, "_Position"), Buttons.getCount()); + if (g_plugin.getByte(AS(buf, buf2, "_Visible"), oldv) > 0) dwFlags |= TTBBF_VISIBLE; } else { - 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) + arrangedpos = g_plugin.getByte(AS(buf, pszName, "_Position"), Buttons.getCount()); + if (g_plugin.getByte(AS(buf, pszName, "_Visible"), oldv) > 0) dwFlags |= TTBBF_VISIBLE; } @@ -124,8 +124,8 @@ void TopButtonInt::SaveSettings(int *SepCnt, int *LaunchCnt) char buf2[20]; AS(buf2, "Sep", buf1); - db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos); - db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), isVisible()); + 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)) { char buf1[10]; @@ -133,14 +133,14 @@ void TopButtonInt::SaveSettings(int *SepCnt, int *LaunchCnt) char buf2[20]; AS(buf2, "Launch", buf1); - db_set_s(0, TTB_OPTDIR, AS(buf, buf2, "_name"), pszName); - db_set_ws(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"), ptszProgram); - db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos); - db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), isVisible()); + g_plugin.setString(AS(buf, buf2, "_name"), pszName); + g_plugin.setWString(AS(buf, buf2, "_lpath"), ptszProgram); + g_plugin.setByte(AS(buf, buf2, "_Position"), arrangedpos); + g_plugin.setByte(AS(buf, buf2, "_Visible"), isVisible()); } else { - db_set_b(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), arrangedpos); - db_set_b(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), isVisible()); + g_plugin.setByte(AS(buf, pszName, "_Position"), arrangedpos); + g_plugin.setByte(AS(buf, pszName, "_Visible"), isVisible()); } } diff --git a/plugins/TopToolBar/src/ttbopt.cpp b/plugins/TopToolBar/src/ttbopt.cpp index 45642f84dc..6c9f76ef2a 100644 --- a/plugins/TopToolBar/src/ttbopt.cpp +++ b/plugins/TopToolBar/src/ttbopt.cpp @@ -379,13 +379,13 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR g_ctrl->bAutoSize = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTORESIZE); g_ctrl->bSingleLine = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SINGLELINE); - db_set_dw(0, TTB_OPTDIR, "BUTTHEIGHT", g_ctrl->nButtonHeight); - db_set_dw(0, TTB_OPTDIR, "BUTTWIDTH", g_ctrl->nButtonWidth); - db_set_dw(0, TTB_OPTDIR, "BUTTGAP", g_ctrl->nButtonSpace); + g_plugin.setDword("BUTTHEIGHT", g_ctrl->nButtonHeight); + g_plugin.setDword("BUTTWIDTH", g_ctrl->nButtonWidth); + g_plugin.setDword("BUTTGAP", g_ctrl->nButtonSpace); - db_set_b(0, TTB_OPTDIR, "UseFlatButton", g_ctrl->bFlatButtons); - db_set_b(0, TTB_OPTDIR, "SingleLine", g_ctrl->bSingleLine); - db_set_b(0, TTB_OPTDIR, "AutoSize", g_ctrl->bAutoSize); + g_plugin.setByte("UseFlatButton", g_ctrl->bFlatButtons); + g_plugin.setByte("SingleLine", g_ctrl->bSingleLine); + g_plugin.setByte("AutoSize", g_ctrl->bAutoSize); SaveTree(hwndDlg); RecreateWindows(); -- cgit v1.2.3