diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-17 18:38:21 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-17 18:38:21 +0300 |
commit | 198a9ac1c0b93073543858b1d9b311a8006c61d9 (patch) | |
tree | 3ed40154a65cc9eac8091f8493ac6f8ab335abf7 /plugins/Scriver/src | |
parent | fe2500aa99137c9ce35907c118745d65a0c0c07e (diff) |
duplicate code removed from Scriver
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r-- | plugins/Scriver/src/globals.cpp | 10 | ||||
-rw-r--r-- | plugins/Scriver/src/globals.h | 1 | ||||
-rw-r--r-- | plugins/Scriver/src/input.cpp | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 69 | ||||
-rw-r--r-- | plugins/Scriver/src/resource.h | 8 | ||||
-rw-r--r-- | plugins/Scriver/src/tabs.cpp | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/utils.cpp | 66 | ||||
-rw-r--r-- | plugins/Scriver/src/utils.h | 2 |
8 files changed, 10 insertions, 150 deletions
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 6a3947ab60..cc69569287 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -222,7 +222,6 @@ void LoadGlobalIcons() ImageList_RemoveAll(g_dat.hButtonIconList);
ImageList_RemoveAll(g_dat.hChatButtonIconList);
ImageList_RemoveAll(g_dat.hHelperIconList);
- ImageList_RemoveAll(g_dat.hSearchEngineIconList);
for (auto &it : buttonIcons) {
if (it == 0)
@@ -238,12 +237,6 @@ void LoadGlobalIcons() int overlayIcon = g_plugin.addImgListIcon(g_dat.hHelperIconList, IDI_OVERLAY);
ImageList_SetOverlayImage(g_dat.hHelperIconList, overlayIcon, 1);
-
- for (int i = IDI_GOOGLE; i < IDI_LASTICON; i++) {
- HICON hIcon = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(i), IMAGE_ICON, 0, 0, 0);
- ImageList_AddIcon(g_dat.hSearchEngineIconList, hIcon);
- DestroyIcon(hIcon);
- }
}
static struct { UINT cpId; const wchar_t *cpName; } cpTable[] =
@@ -310,7 +303,6 @@ void InitGlobals() g_dat.hChatButtonIconList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
g_dat.hTabIconList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
g_dat.hHelperIconList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
- g_dat.hSearchEngineIconList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
g_dat.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
g_dat.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
LoadInfobarFonts();
@@ -329,8 +321,6 @@ void FreeGlobals() ImageList_Destroy(g_dat.hChatButtonIconList);
if (g_dat.hHelperIconList)
ImageList_Destroy(g_dat.hHelperIconList);
- if (g_dat.hSearchEngineIconList)
- ImageList_Destroy(g_dat.hSearchEngineIconList);
mir_free(g_dat.tabIconListUsage);
WindowList_Destroy(g_dat.hParentWindowList);
diff --git a/plugins/Scriver/src/globals.h b/plugins/Scriver/src/globals.h index b6adba5887..1701681025 100644 --- a/plugins/Scriver/src/globals.h +++ b/plugins/Scriver/src/globals.h @@ -115,7 +115,6 @@ struct GlobalMessageData HIMAGELIST hButtonIconList;
HIMAGELIST hChatButtonIconList;
HIMAGELIST hHelperIconList;
- HIMAGELIST hSearchEngineIconList;
HBRUSH hInfobarBrush;
int toolbarPosition;
HWND hFocusWnd;
diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp index dac0407d63..db9ba52e01 100644 --- a/plugins/Scriver/src/input.cpp +++ b/plugins/Scriver/src/input.cpp @@ -33,7 +33,7 @@ void InputAreaContextMenu(HWND hwnd, WPARAM, LPARAM lParam, MCONTACT hContact) CHARRANGE sel, all = { 0, -1 };
HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT));
- HMENU hSubMenu = GetSubMenu(hMenu, 2);
+ HMENU hSubMenu = GetSubMenu(hMenu, 0);
TranslateMenu(hSubMenu);
SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin == sel.cpMax) {
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index be01814c2a..10e5c954f9 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -949,75 +949,6 @@ LRESULT CMsgDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) SetFocus(m_message.GetHwnd());
}
break;
-
- case WM_CONTEXTMENU:
- HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT));
- HMENU hSubMenu = GetSubMenu(hMenu, 0);
- TranslateMenu(hSubMenu);
-
- CHARRANGE sel, all = { 0, -1 };
- m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
- if (sel.cpMin == sel.cpMax)
- EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED);
-
- POINT pt;
- if (lParam == 0xFFFFFFFF) {
- m_log.SendMsg(EM_POSFROMCHAR, (WPARAM)&pt, (LPARAM)sel.cpMax);
- ClientToScreen(m_log.GetHwnd(), &pt);
- }
- else {
- pt.x = GET_X_LPARAM(lParam);
- pt.y = GET_Y_LPARAM(lParam);
- }
-
- POINT ptl = pt;
- ScreenToClient(m_log.GetHwnd(), &ptl);
- ptrW pszWord(GetRichTextWord(m_log.GetHwnd(), &ptl));
- if (pszWord && pszWord[0]) {
- wchar_t szMenuText[4096];
- mir_snwprintf(szMenuText, TranslateT("Look up '%s':"), pszWord.get());
- ModifyMenu(hSubMenu, 5, MF_STRING | MF_BYPOSITION, 5, szMenuText);
- SetSearchEngineIcons(hMenu, g_dat.hSearchEngineIconList);
- }
- else ModifyMenu(hSubMenu, 5, MF_STRING | MF_GRAYED | MF_BYPOSITION, 5, TranslateT("No word to look up"));
-
- m_bInMenu = true;
- int uID = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_log.GetHwnd(), nullptr);
- m_bInMenu = false;
-
- switch (uID) {
- case IDM_COPY:
- m_log.SendMsg(WM_COPY, 0, 0);
- break;
-
- case IDM_COPYALL:
- m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&all);
- m_log.SendMsg(WM_COPY, 0, 0);
- m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
- break;
-
- case IDM_SELECTALL:
- m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&all);
- break;
-
- case IDM_CLEAR:
- ClearLog();
- break;
-
- case IDM_SEARCH_GOOGLE:
- case IDM_SEARCH_BING:
- case IDM_SEARCH_YANDEX:
- case IDM_SEARCH_YAHOO:
- case IDM_SEARCH_WIKIPEDIA:
- case IDM_SEARCH_FOODNETWORK:
- case IDM_SEARCH_GOOGLE_MAPS:
- case IDM_SEARCH_GOOGLE_TRANSLATE:
- SearchWord(pszWord, uID - IDM_SEARCH_GOOGLE + SEARCHENGINE_GOOGLE);
- PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
- break;
- }
- DestroyMenu(hMenu);
- return TRUE;
}
return CSuper::WndProc_Log(msg, wParam, lParam);
diff --git a/plugins/Scriver/src/resource.h b/plugins/Scriver/src/resource.h index bef57bae9d..5c449cdd48 100644 --- a/plugins/Scriver/src/resource.h +++ b/plugins/Scriver/src/resource.h @@ -229,14 +229,6 @@ #define IDM_CLOSETAB 40020
#define IDM_CLOSEOTHERTABS 40021
#define IDM_TOPMOST 40040
-#define IDM_SEARCH_GOOGLE 40080
-#define IDM_SEARCH_BING 40081
-#define IDM_SEARCH_YANDEX 40082
-#define IDM_SEARCH_WIKIPEDIA 40083
-#define IDM_SEARCH_GOOGLE_MAPS 40084
-#define IDM_SEARCH_GOOGLE_TRANSLATE 40085
-#define IDM_SEARCH_YAHOO 40086
-#define IDM_SEARCH_FOODNETWORK 40087
#define ID_MESS 50001
#define ID_COPYALL 50006
#define ID_Menu 50026
diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp index f2ea48ab19..d8b7ea07dc 100644 --- a/plugins/Scriver/src/tabs.cpp +++ b/plugins/Scriver/src/tabs.cpp @@ -948,7 +948,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara if (tabId != -1) {
CMsgDialog *pDlg = GetChildFromTab(dat->m_hwndTabs, tabId);
HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT));
- HMENU hSubMenu = GetSubMenu(hMenu, 3);
+ HMENU hSubMenu = GetSubMenu(hMenu, 1);
TranslateMenu(hSubMenu);
HMENU hUserMenu = (HMENU)SendMessage(pDlg->GetHwnd(), DM_GETCONTEXTMENU, 0, 0);
if (hUserMenu != nullptr) {
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index d268ab4c62..4d80e51e98 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -72,38 +72,6 @@ wchar_t* limitText(wchar_t *text, int limit) return text;
}
-wchar_t* GetRichTextWord(HWND hwnd, POINT *ptl)
-{
- long iCharIndex, start, end, iRes;
- wchar_t *pszWord = GetRichEditSelection(hwnd);
- if (pszWord == nullptr) {
- iCharIndex = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)ptl);
- if (iCharIndex >= 0) {
- start = SendMessage(hwnd, EM_FINDWORDBREAK, WB_LEFT, iCharIndex); //-iChars;
- end = SendMessage(hwnd, EM_FINDWORDBREAK, WB_RIGHT, iCharIndex); //-iChars;
- if (end - start > 0) {
- TEXTRANGE tr;
- CHARRANGE cr;
- memset(&tr, 0, sizeof(TEXTRANGE));
- pszWord = (wchar_t*)mir_alloc(sizeof(wchar_t) * (end - start + 1));
- cr.cpMin = start;
- cr.cpMax = end;
- tr.chrg = cr;
- tr.lpstrText = pszWord;
- iRes = SendMessage(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
- if (iRes <= 0) {
- mir_free(pszWord);
- pszWord = nullptr;
- }
- }
- }
- }
- if (pszWord != nullptr)
- rtrimText(pszWord);
-
- return pszWord;
-}
-
static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
MessageSendQueueItem *msi = (MessageSendQueueItem *)dwCookie;
@@ -137,7 +105,7 @@ wchar_t *GetRichEditSelection(HWND hwnd) int MeasureMenuItem(WPARAM, LPARAM lParam)
{
LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
- if (mis->itemData != (ULONG_PTR)g_dat.hButtonIconList && mis->itemData != (ULONG_PTR)g_dat.hSearchEngineIconList && mis->itemData != (ULONG_PTR)g_dat.hChatButtonIconList)
+ if (mis->itemData != (ULONG_PTR)g_dat.hButtonIconList && mis->itemData != (ULONG_PTR)g_dat.hChatButtonIconList)
return FALSE;
mis->itemWidth = max(0, GetSystemMetrics(SM_CXSMICON) - GetSystemMetrics(SM_CXMENUCHECK) + 4);
@@ -147,17 +115,11 @@ int MeasureMenuItem(WPARAM, LPARAM lParam) int DrawMenuItem(WPARAM, LPARAM lParam)
{
- int y;
- int id;
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
- if (dis->itemData != (ULONG_PTR)g_dat.hButtonIconList && dis->itemData != (ULONG_PTR)g_dat.hSearchEngineIconList && dis->itemData != (ULONG_PTR)g_dat.hChatButtonIconList) {
+ if (dis->itemData != (ULONG_PTR)g_dat.hButtonIconList && dis->itemData != (ULONG_PTR)g_dat.hChatButtonIconList)
return FALSE;
- }
- id = dis->itemID;
- if (id >= IDM_SEARCH_GOOGLE) {
- id -= IDM_SEARCH_GOOGLE;
- }
- y = (dis->rcItem.bottom - dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2 + 1;
+
+ int y = (dis->rcItem.bottom - dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2 + 1;
if (dis->itemState & ODS_SELECTED) {
if (dis->itemState & ODS_CHECKED) {
RECT rc;
@@ -166,10 +128,10 @@ int DrawMenuItem(WPARAM, LPARAM lParam) rc.top = y;
rc.bottom = rc.top + GetSystemMetrics(SM_CYSMICON) + 2;
FillRect(dis->hDC, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
- ImageList_DrawEx((HIMAGELIST)dis->itemData, id, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_DEFAULT, ILD_SELECTED);
+ ImageList_DrawEx((HIMAGELIST)dis->itemData, dis->itemID, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_DEFAULT, ILD_SELECTED);
}
else
- ImageList_DrawEx((HIMAGELIST)dis->itemData, id, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_DEFAULT, ILD_FOCUS);
+ ImageList_DrawEx((HIMAGELIST)dis->itemData, dis->itemID, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_DEFAULT, ILD_FOCUS);
}
else {
if (dis->itemState & ODS_CHECKED) {
@@ -189,10 +151,10 @@ int DrawMenuItem(WPARAM, LPARAM lParam) (GetBValue(menuCol) + GetBValue(hiliteCol)) / 2));
FillRect(dis->hDC, &rc, hBrush);
DeleteObject(hBrush);
- ImageList_DrawEx((HIMAGELIST)dis->itemData, id, dis->hDC, 2, y, 0, 0, CLR_NONE, GetSysColor(COLOR_MENU), ILD_BLEND25);
+ ImageList_DrawEx((HIMAGELIST)dis->itemData, dis->itemID, dis->hDC, 2, y, 0, 0, CLR_NONE, GetSysColor(COLOR_MENU), ILD_BLEND25);
}
else
- ImageList_DrawEx((HIMAGELIST)dis->itemData, id, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ ImageList_DrawEx((HIMAGELIST)dis->itemData, dis->itemID, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
}
return TRUE;
}
@@ -265,18 +227,6 @@ void SearchWord(wchar_t *word, int engine) }
}
-void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList)
-{
- for (int i = 0; i < IDI_LASTICON - IDI_GOOGLE; i++) {
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_BITMAP | MIIM_DATA;
- mii.hbmpItem = HBMMENU_CALLBACK;
- mii.dwItemData = (ULONG_PTR)hImageList;
- SetMenuItemInfo(hMenu, IDM_SEARCH_GOOGLE + i, FALSE, &mii);
- }
-}
-
void CMsgDialog::GetContactUniqueId(char *buf, int maxlen)
{
ptrW id(Contact_GetInfo(CNF_UNIQUEID, m_hContact, m_szProto));
diff --git a/plugins/Scriver/src/utils.h b/plugins/Scriver/src/utils.h index dc03c0aba9..9f0bed1256 100644 --- a/plugins/Scriver/src/utils.h +++ b/plugins/Scriver/src/utils.h @@ -37,11 +37,9 @@ enum SEARCHENGINES { wchar_t *limitText(wchar_t *text, int limit);
void logInfo(const char *fmt, ...);
wchar_t *GetRichEditSelection(HWND hwnd);
-wchar_t *GetRichTextWord(HWND hwnd, POINT *pt);
void SearchWord(wchar_t * word, int engine);
int MeasureMenuItem(WPARAM wParam, LPARAM lParam);
int DrawMenuItem(WPARAM wParam, LPARAM lParam);
-void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList);
HWND CreateToolTip(HWND hwndParent, LPTSTR ptszText, LPTSTR ptszTitle, RECT *rect);
void SetToolTipText(HWND hwndParent, HWND hwndTT, LPTSTR ptszText, LPTSTR ptszTitle);
void SetToolTipRect(HWND hwndParent, HWND hwndTT, RECT* rect);
|