diff options
author | George Hazan <george.hazan@gmail.com> | 2012-12-02 18:19:49 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-12-02 18:19:49 +0000 |
commit | c4582dd65b444e5dae29ada7cc3f6c9a9c20edf3 (patch) | |
tree | 17a8627550b202d62df8e1df76d2585d3d0cdeaa /plugins/BasicHistory | |
parent | 5ea5feb7e052ca45af7bc9ed76e4a252bd71950d (diff) |
new easy standard way of registering icons: Icon_Register
git-svn-id: http://svn.miranda-ng.org/main/trunk@2601 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/BasicHistory')
-rw-r--r-- | plugins/BasicHistory/src/BasicHistory.cpp | 91 | ||||
-rw-r--r-- | plugins/BasicHistory/src/HistoryWindow.cpp | 48 | ||||
-rw-r--r-- | plugins/BasicHistory/src/HistoryWindow.h | 2 | ||||
-rw-r--r-- | plugins/BasicHistory/src/RichHtmlExport.cpp | 10 | ||||
-rw-r--r-- | plugins/BasicHistory/src/stdafx.h | 4 |
5 files changed, 61 insertions, 94 deletions
diff --git a/plugins/BasicHistory/src/BasicHistory.cpp b/plugins/BasicHistory/src/BasicHistory.cpp index 482641463e..c9b6920d67 100644 --- a/plugins/BasicHistory/src/BasicHistory.cpp +++ b/plugins/BasicHistory/src/BasicHistory.cpp @@ -26,13 +26,9 @@ HINSTANCE hInst; HCURSOR hCurSplitNS, hCurSplitWE;
HANDLE g_hMainThread=NULL;
-extern HINSTANCE hInst;
-
HANDLE hServiceShowContactHistory, hServiceDeleteAllContactHistory, hServiceExecuteTask;
HANDLE *hEventIcons = NULL;
-int iconsNum;
-HANDLE hPlusIcon, hMinusIcon, hFindNextIcon, hFindPrevIcon;
-HANDLE hPlusExIcon, hMinusExIcon;
+int iconsNum = 3;
HANDLE hToolbarButton;
HGENMENU hContactMenu, hDeleteContactMenu;
HGENMENU hTaskMainMenu;
@@ -193,63 +189,30 @@ void InitTaskMenuItems() }
}
+IconItem iconList[] =
+{
+ { LPGEN("Incoming message"), "BasicHistory_in", IDI_INM },
+ { LPGEN("Outgoing message"), "BasicHistory_out", IDI_OUTM },
+ { LPGEN("Status change"), "BasicHistory_status", IDI_STATUS },
+ { LPGEN("Show Contacts"), "BasicHistory_show", IDI_SHOW },
+ { LPGEN("Hide Contacts"), "BasicHistory_hide", IDI_HIDE },
+ { LPGEN("Find Next"), "BasicHistory_findnext", IDI_FINDNEXT },
+ { LPGEN("Find Previous"), "BasicHistory_findprev", IDI_FINDPREV },
+ { LPGEN("Plus in export"), "BasicHistory_plusex", IDI_PLUSEX },
+ { LPGEN("Minus in export"), "BasicHistory_minusex", IDI_MINUSEX },
+};
+
void InitIcolib()
{
- TCHAR stzFile[MAX_PATH];
- GetModuleFileName(hInst, stzFile, MAX_PATH);
-
- SKINICONDESC sid = { sizeof(sid) };
- sid.cx = sid.cy = 16;
- sid.ptszDefaultFile = stzFile;
- sid.pszSection = LPGEN("History");
- sid.flags = SIDF_PATH_TCHAR;
-
- iconsNum = 3;
- hEventIcons = new HANDLE[iconsNum];
- sid.pszName = "BasicHistory_in";
- sid.pszDescription = LPGEN("Incoming message");
- sid.iDefaultIndex = -IDI_INM;
- hEventIcons[0] = Skin_AddIcon(&sid);
-
- sid.pszName = "BasicHistory_out";
- sid.pszDescription = LPGEN("Outgoing message");
- sid.iDefaultIndex = -IDI_OUTM;
- hEventIcons[1] = Skin_AddIcon(&sid);
-
- sid.pszName = "BasicHistory_status";
- sid.pszDescription = LPGEN("Statuschange");
- sid.iDefaultIndex = -IDI_STATUS;
- hEventIcons[2] = Skin_AddIcon(&sid);
-
- sid.pszName = "BasicHistory_show";
- sid.pszDescription = LPGEN("Show Contacts");
- sid.iDefaultIndex = -IDI_SHOW;
- hPlusIcon = Skin_AddIcon(&sid);
-
- sid.pszName = "BasicHistory_hide";
- sid.pszDescription = LPGEN("Hide Contacts");
- sid.iDefaultIndex = -IDI_HIDE;
- hMinusIcon = Skin_AddIcon(&sid);
-
- sid.pszName = "BasicHistory_findnext";
- sid.pszDescription = LPGEN("Find Next");
- sid.iDefaultIndex = -IDI_FINDNEXT;
- hFindNextIcon = Skin_AddIcon(&sid);
-
- sid.pszName = "BasicHistory_findprev";
- sid.pszDescription = LPGEN("Find Previous");
- sid.iDefaultIndex = -IDI_FINDPREV;
- hFindPrevIcon = Skin_AddIcon(&sid);
-
- sid.pszName = "BasicHistory_plusex";
- sid.pszDescription = LPGEN("Plus in export");
- sid.iDefaultIndex = -IDI_PLUSEX;
- hPlusExIcon = Skin_AddIcon(&sid);
-
- sid.pszName = "BasicHistory_minusex";
- sid.pszDescription = LPGEN("Minus in export");
- sid.iDefaultIndex = -IDI_MINUSEX;
- hMinusExIcon = Skin_AddIcon(&sid);
+}
+
+HICON LoadIconEx(int iconId, int big)
+{
+ for (int i=0; i < SIZEOF(iconList); i++)
+ if ( iconList[i].defIconID == iconId)
+ return Skin_GetIconByHandle(iconList[i].hIcolib, big);
+
+ return 0;
}
INT_PTR ShowContactHistory(WPARAM wParam, LPARAM lParam)
@@ -328,16 +291,22 @@ extern "C" int __declspec(dllexport) Load(void) DuplicateHandle(GetCurrentProcess(),GetCurrentThread(),GetCurrentProcess(),&g_hMainThread,0,FALSE,DUPLICATE_SAME_ACCESS);
mir_getTMI(&tmi);
mir_getLP(&pluginInfo);
+
hCurSplitNS = LoadCursor(NULL, IDC_SIZENS);
hCurSplitWE = LoadCursor(NULL, IDC_SIZEWE);
+
hServiceShowContactHistory = CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, ShowContactHistory);
hServiceDeleteAllContactHistory = CreateServiceFunction(MS_HISTORY_DELETEALLCONTACTHISTORY, HistoryWindow::DeleteAllUserHistory);
hServiceExecuteTask = CreateServiceFunction(MS_HISTORY_EXECUTE_TASK, ExecuteTaskService);
+
Options::instance = new Options();
+
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_OPT_INITIALISE, Options::InitOptions);
+
EventList::Init();
- InitIcolib();
+
+ Icon_Register(hInst, LPGEN("History"), iconList, SIZEOF(iconList));
return 0;
}
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index dfde02eb0b..98ca26771c 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -26,12 +26,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define MODULE "BasicHistory"
extern HINSTANCE hInst;
-extern HCURSOR hCurSplitNS, hCurSplitWE;
-extern HANDLE *hEventIcons;
+extern HCURSOR hCurSplitNS, hCurSplitWE;
extern int iconsNum;
-extern HANDLE hPlusIcon, hMinusIcon, hFindNextIcon, hFindPrevIcon;
extern bool g_SmileyAddAvail;
extern char* metaContactProto;
+extern IconItem iconList[];
#define DM_HREBUILD (WM_USER+11)
#define DM_SPLITTERMOVED (WM_USER+15)
@@ -56,7 +55,7 @@ HistoryWindow::HistoryWindow(HANDLE _hContact) : isLoading(false),
isGroupImages(false),
allIconNumber(0),
- eventIcoms(NULL),
+ eventIcons(NULL),
bkBrush(NULL),
bkFindBrush(NULL),
hSystem(NULL),
@@ -80,13 +79,13 @@ HistoryWindow::HistoryWindow(HANDLE _hContact) : HistoryWindow::~HistoryWindow()
{
- if(eventIcoms != NULL)
+ if(eventIcons != NULL)
{
for(int i = 0; i < iconsNum; ++i)
- if(eventIcoms[i] != NULL)
- Skin_ReleaseIcon(eventIcoms[i]);
+ if(eventIcons[i] != NULL)
+ Skin_ReleaseIcon(eventIcons[i]);
- delete[] eventIcoms;
+ delete[] eventIcons;
}
if(plusIco != NULL)
@@ -1203,8 +1202,8 @@ void HistoryWindow::Initialise() ScreenToClient(hWnd, &pt);
listOryginalPos = pt.x;
- plusIco = Skin_GetIconByHandle(hPlusIcon, 1);
- minusIco = Skin_GetIconByHandle(hMinusIcon, 1);
+ plusIco = LoadIconEx(IDI_SHOW, 1);
+ minusIco = LoadIconEx(IDI_HIDE, 1);
SendDlgItemMessage( hWnd, IDC_SHOWHIDE, BUTTONSETASPUSHBTN, TRUE, 0 );
SendDlgItemMessage( hWnd, IDC_SHOWHIDE, BUTTONSETASFLATBTN, TRUE, 0 );
if(hContact == NULL || Options::instance->showContacts)
@@ -1241,22 +1240,21 @@ void HistoryWindow::Initialise() if(himlSmall)
{
allIconNumber = iconsNum + 3;
- eventIcoms = new HICON[allIconNumber];
- for(int i = 0; i < iconsNum; ++i)
- {
- eventIcoms[i] = hEventIcons[i] == NULL ? NULL : Skin_GetIconByHandle(hEventIcons[i]);
- ImageList_AddIcon(himlSmall, eventIcoms[i]);
+ eventIcons = new HICON[allIconNumber];
+ for(int i = 0; i < iconsNum; ++i) {
+ eventIcons[i] = Skin_GetIconByHandle( iconList[i].hIcolib );
+ ImageList_AddIcon(himlSmall, eventIcons[i]);
}
int id = iconsNum;
- eventIcoms[id] = LoadSkinnedIcon(SKINICON_EVENT_FILE);
- ImageList_AddIcon(himlSmall, eventIcoms[id]);
+ eventIcons[id] = LoadSkinnedIcon(SKINICON_EVENT_FILE);
+ ImageList_AddIcon(himlSmall, eventIcons[id]);
- eventIcoms[++id] = LoadSkinnedIcon(SKINICON_EVENT_URL);
- ImageList_AddIcon(himlSmall, eventIcoms[id]);
+ eventIcons[++id] = LoadSkinnedIcon(SKINICON_EVENT_URL);
+ ImageList_AddIcon(himlSmall, eventIcons[id]);
- eventIcoms[++id] = LoadSkinnedIcon(SKINICON_OTHER_WINDOWS);
- ImageList_AddIcon(himlSmall, eventIcoms[id]);
+ eventIcons[++id] = LoadSkinnedIcon(SKINICON_OTHER_WINDOWS);
+ ImageList_AddIcon(himlSmall, eventIcons[id]);
if((isGroupImages = Options::instance->groupShowEvents) != false)
ListView_SetImageList(listWindow, himlSmall, LVSIL_SMALL);
@@ -1284,9 +1282,9 @@ void HistoryWindow::Initialise() HIMAGELIST himlButtons = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 3, 3);
if(himlButtons)
{
- findNextIco = Skin_GetIconByHandle(hFindNextIcon);
+ findNextIco = LoadIconEx(IDI_FINDNEXT);
ImageList_AddIcon(himlButtons, findNextIco);
- findPrevIco = Skin_GetIconByHandle(hFindPrevIcon);
+ findPrevIco = LoadIconEx(IDI_FINDPREV);
ImageList_AddIcon(himlButtons, findPrevIco);
configIco = LoadSkinnedIcon(SKINICON_OTHER_OPTIONS);
ImageList_AddIcon(himlButtons, configIco);
@@ -1608,14 +1606,14 @@ void HistoryWindow::SelectEventGroup(int sel) HICON ico;
if(GetEventIcon(lastMe, data.eventType, imId))
{
- ico = eventIcoms[imId];
+ ico = eventIcons[imId];
}
else
{
ico = GetEventCoreIcon(hDbEvent);
if(ico == NULL)
{
- ico = eventIcoms[imId];
+ ico = eventIcons[imId];
}
}
diff --git a/plugins/BasicHistory/src/HistoryWindow.h b/plugins/BasicHistory/src/HistoryWindow.h index 5575c6c11e..afc00c787d 100644 --- a/plugins/BasicHistory/src/HistoryWindow.h +++ b/plugins/BasicHistory/src/HistoryWindow.h @@ -56,7 +56,7 @@ private: LONG splitterOrgY;
LONG splitterX;
LONG splitterOrgX;
- HICON *eventIcoms;
+ HICON *eventIcons;
int allIconNumber;
HICON plusIco, minusIco, findNextIco, findPrevIco, configIco, deleteIco;
WNDPROC OldSplitterProc;
diff --git a/plugins/BasicHistory/src/RichHtmlExport.cpp b/plugins/BasicHistory/src/RichHtmlExport.cpp index d1254e4dcc..3a000f0744 100644 --- a/plugins/BasicHistory/src/RichHtmlExport.cpp +++ b/plugins/BasicHistory/src/RichHtmlExport.cpp @@ -27,8 +27,6 @@ RichHtmlExport::~RichHtmlExport() }
extern HINSTANCE hInst;
-extern HANDLE *hEventIcons;
-extern HANDLE hPlusExIcon, hMinusExIcon;
extern bool g_SmileyAddAvail;
std::wstring MakeTextHtmled(const std::wstring& message, std::queue<std::pair<size_t, size_t> >* positionMap = NULL)
@@ -318,19 +316,19 @@ void RichHtmlExport::WriteHeader(const std::wstring &fileName, const std::wstrin ExtractFile(IDR_CSS, css);
ExtractFile(IDR_JS, folder + _T("\\history.js"));
- HICON ico = Skin_GetIconByHandle(hPlusExIcon);
+ HICON ico = LoadIconEx(IDI_PLUSEX);
IcoSave(folder + _T("\\pnode.ico"), ico);
Skin_ReleaseIcon(ico);
- ico = Skin_GetIconByHandle(hMinusExIcon);
+ ico = LoadIconEx(IDI_MINUSEX);
IcoSave(folder + _T("\\mnode.ico"), ico);
Skin_ReleaseIcon(ico);
- ico = Skin_GetIconByHandle(hEventIcons[0]);
+ ico = LoadIconEx(IDI_INM);
IcoSave(folder + _T("\\event0.ico"), ico);
Skin_ReleaseIcon(ico);
- ico = Skin_GetIconByHandle(hEventIcons[1]);
+ ico = LoadIconEx(IDI_OUTM);
IcoSave(folder + _T("\\event1.ico"), ico);
Skin_ReleaseIcon(ico);
diff --git a/plugins/BasicHistory/src/stdafx.h b/plugins/BasicHistory/src/stdafx.h index 1be1d46674..32ef7720e7 100644 --- a/plugins/BasicHistory/src/stdafx.h +++ b/plugins/BasicHistory/src/stdafx.h @@ -86,4 +86,6 @@ #define HISTORY_HK_ALLCONTACTS 117
#define EVENTTYPE_STATUSCHANGE 25368
-#define EVENTTYPE_SMTPSIMPLE 2350
\ No newline at end of file +#define EVENTTYPE_SMTPSIMPLE 2350
+
+HICON LoadIconEx(int iconId, int big = 0);
|