From 1cd07657a749b8a3e5f7cccc42ac4afc07cefa3b Mon Sep 17 00:00:00 2001 From: mataes2007 Date: Thu, 28 Apr 2011 10:47:54 +0000 Subject: added action copy to clipboard git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@58 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- popup/res/copy.ico | Bin 0 -> 2038 bytes popup/resource.h | 1 + popup/resource.rc | 1 + popup/src/actions.cpp | 21 +++++++++++++-------- popup/src/config.h | 1 + popup/src/icons.cpp | 3 ++- popup/src/icons.h | 1 + popup/src/popup_wnd2.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- 8 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 popup/res/copy.ico diff --git a/popup/res/copy.ico b/popup/res/copy.ico new file mode 100644 index 0000000..9dab230 Binary files /dev/null and b/popup/res/copy.ico differ diff --git a/popup/resource.h b/popup/resource.h index dc04aee..f6ce149 100644 --- a/popup/resource.h +++ b/popup/resource.h @@ -35,6 +35,7 @@ #define IDI_ACT_CLOSE 208 #define IDI_ACT_PINNED 209 #define IDI_ACT_PIN 210 +#define IDI_ACT_COPY 211 #define IDI_OPT_GROUP 213 #define IDI_OPT_FULLSCREEN 215 #define IDI_OPT_BLOCK 216 diff --git a/popup/resource.rc b/popup/resource.rc index 1b0ce29..bb72927 100644 --- a/popup/resource.rc +++ b/popup/resource.rc @@ -53,6 +53,7 @@ IDI_OPT_FULLSCREEN ICON "res\\fullscreen.ico" IDI_OPT_BLOCK ICON "res\\block.ico" IDI_OPT_FAVORITE ICON "res\\favorite.ico" IDI_ACT_REPLY ICON "res\\reply.ico" +IDI_ACT_COPY ICON "res\\copy.ico" ///////////////////////////////////////////////////////////////////////////// // diff --git a/popup/src/actions.cpp b/popup/src/actions.cpp index 43cd83b..32ad120 100644 --- a/popup/src/actions.cpp +++ b/popup/src/actions.cpp @@ -44,13 +44,14 @@ void LoadActions() { POPUPACTION actions[] = { - { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_REPLY,0), "General/Quick reply", PAF_ENABLED}, - { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_MESS,0), "General/Send message", PAF_ENABLED}, - { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_INFO,0), "General/User details", 0}, - { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_MENU,0), "General/Contact menu", PAF_ENABLED}, - { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_ADD,0), "General/Add permanently", PAF_ENABLED}, - { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_PIN,0), "General/Pin popup", PAF_ENABLED}, - { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_CLOSE,0), "General/Dismiss popup", PAF_ENABLED}, + { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_REPLY,0), "General/Quick reply", 0}, + { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_MESS,0), "General/Send message", 0}, + { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_INFO,0), "General/User details", 0}, + { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_MENU,0), "General/Contact menu", 0}, + { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_ADD,0), "General/Add permanently", 0}, + { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_PIN,0), "General/Pin popup", 0}, + { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_CLOSE,0), "General/Dismiss popup", 0}, + { sizeof(POPUPACTION), IcoLib_GetIcon(ICO_ACT_COPY,0), "General/Copy to clipboard", 0}, //remove popup action #if defined(_DEBUG) @@ -116,7 +117,7 @@ DWORD MouseOverride(HWND hCombo, int number) { DWORD dwItem = 0; DWORD ItemActive = 0; - if(number<0 || number >6) + if(number<0 || number >7) number = 0; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("no overwrite")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 0); @@ -146,6 +147,10 @@ DWORD MouseOverride(HWND hCombo, int number) SendMessage(hCombo, CB_SETITEMDATA, dwItem, 6); if(number == 6) ItemActive = dwItem; + dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("Copy to clipboard")); + SendMessage(hCombo, CB_SETITEMDATA, dwItem, 7); + if(number == 7) + ItemActive = dwItem; return ItemActive; } diff --git a/popup/src/config.h b/popup/src/config.h index 64ff3f2..6b293ba 100644 --- a/popup/src/config.h +++ b/popup/src/config.h @@ -137,6 +137,7 @@ extern GLOBAL_WND_CLASSES g_wndClass; #define ACT_DEF_DISMISS 0x00100000 #define ACT_DEF_PIN 0x00200000 #define ACT_DEF_REPLY 0x00400000 +#define ACT_DEF_COPY 0x00800000 void LoadOptions(); diff --git a/popup/src/icons.cpp b/popup/src/icons.cpp index c65d0e2..cb6e87d 100644 --- a/popup/src/icons.cpp +++ b/popup/src/icons.cpp @@ -76,7 +76,8 @@ static ICODESC icoDesc[] = { ICO_ACT_INFO, _T("User Details"), _T(SECT_POPUP) _T(SECT_POPUP_ACT), 0, IDI_ACT_INFO, NULL, -1 }, { ICO_ACT_MENU, _T("Contact Menu"), _T(SECT_POPUP) _T(SECT_POPUP_ACT), 0, IDI_ACT_MENU, NULL, -1 }, { ICO_ACT_ADD, _T("Add Contact Permanently"), _T(SECT_POPUP) _T(SECT_POPUP_ACT), 0, IDI_ACT_ADD, NULL, -1 }, - { ICO_ACT_CLOSE, _T("Dismiss Popup"), _T(SECT_POPUP) _T(SECT_POPUP_ACT), 0, IDI_ACT_CLOSE, NULL, -1 } + { ICO_ACT_CLOSE, _T("Dismiss Popup"), _T(SECT_POPUP) _T(SECT_POPUP_ACT), 0, IDI_ACT_CLOSE, NULL, -1 }, + { ICO_ACT_COPY, _T("Copy to clipboard"), _T(SECT_POPUP) _T(SECT_POPUP_ACT), 0, IDI_ACT_COPY, NULL, -1 } }; diff --git a/popup/src/icons.h b/popup/src/icons.h index 879e40c..532e7ce 100644 --- a/popup/src/icons.h +++ b/popup/src/icons.h @@ -60,6 +60,7 @@ Last change by : $Author: Merlin_de $ #define ICO_ACT_PIN MODULNAME"_act_pin" #define ICO_ACT_PINNED MODULNAME"_act_pinned" #define ICO_ACT_CLOSE MODULNAME"_act_close" +#define ICO_ACT_COPY MODULNAME"_act_copy" #define ICO_OPT_RELOAD MODULNAME"_opt_reload" #define ICO_OPT_RESIZE MODULNAME"_opt_resize" diff --git a/popup/src/popup_wnd2.cpp b/popup/src/popup_wnd2.cpp index 1e680c3..8dab680 100644 --- a/popup/src/popup_wnd2.cpp +++ b/popup/src/popup_wnd2.cpp @@ -704,6 +704,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultUsr && DBGetContactSettingByte(m_hContact, "CList", "NotOnList", 0) && IsActionEnabled("General/Add permanently")) ++m_actionCount; if (enableDefaultGen && (m_iTimeout != -1) && IsActionEnabled("General/Pin popup")) ++m_actionCount; if (enableDefaultGen && IsActionEnabled("General/Dismiss popup")) ++m_actionCount; + if (enableDefaultGen && IsActionEnabled("General/Copy to clipboard")) ++m_actionCount; int iAction = fixActions(theActions, count, m_actionCount); @@ -716,7 +717,6 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) m_actions[iAction].actionA.lParam = ACT_DEF_REPLY; ++iAction; } - if (enableDefaultUsr && isIm && IsActionEnabled("General/Send message")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); @@ -771,6 +771,15 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) m_actions[iAction].actionA.lParam = ACT_DEF_DISMISS; ++iAction; } + if (enableDefaultGen && IsActionEnabled("General/Copy to clipboard")) + { + m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); + m_actions[iAction].actionA.lchIcon = IcoLib_GetIcon(ICO_ACT_COPY,iconSize); + lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/Copy to clipboard"); + m_actions[iAction].actionA.wParam = 0; + m_actions[iAction].actionA.lParam = ACT_DEF_COPY; + ++iAction; + } } return m_actionCount; @@ -1371,6 +1380,35 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara case ACT_DEF_DISMISS: PUDeletePopUp(m_hwnd); break; + case ACT_DEF_COPY: + { + #ifdef UNICODE + #define CF_TCHAR CF_UNICODETEXT + #else + #define CF_TCHAR CF_TEXT + #endif + HGLOBAL clipbuffer; + static TCHAR * buffer, *text; + char* sztext = NULL; + text = this->m_lpwzText; + if (!text) + { + sztext = this->m_lpzText; + text = mir_a2t(sztext); + } + OpenClipboard(m_hwnd); + EmptyClipboard(); + clipbuffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, (lstrlen(text)+1) * sizeof(TCHAR)); + buffer = (TCHAR *)GlobalLock(clipbuffer); + lstrcpy(buffer, text); + GlobalUnlock(clipbuffer); + SetClipboardData(CF_TCHAR, clipbuffer); + CloseClipboard(); + if (sztext) + mir_free(text); + PUDeletePopUp(m_hwnd); + break; + } } break; } @@ -1436,6 +1474,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara case 4:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MENU); break; case 5:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DISMISS); break; case 6:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_PIN); break; + case 7:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_COPY); break; } }else{ lock(); @@ -1458,6 +1497,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara case 4:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MENU); break; case 5:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DISMISS); break; case 6:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_PIN); break; + case 7:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_COPY); break; } } break; @@ -1474,6 +1514,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara case 4:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MENU); break; case 5:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DISMISS); break; case 6:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_PIN); break; + case 7:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_COPY); break; } return TRUE; }else{ -- cgit v1.2.3