From c4582dd65b444e5dae29ada7cc3f6c9a9c20edf3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 2 Dec 2012 18:19:49 +0000 Subject: 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 --- plugins/NotesAndReminders/src/globals.h | 2 +- plugins/NotesAndReminders/src/main.cpp | 80 ++++++++++------------------- plugins/NotesAndReminders/src/notes.cpp | 12 ++--- plugins/NotesAndReminders/src/options.cpp | 2 +- plugins/NotesAndReminders/src/reminders.cpp | 6 +-- 5 files changed, 39 insertions(+), 63 deletions(-) (limited to 'plugins/NotesAndReminders/src') diff --git a/plugins/NotesAndReminders/src/globals.h b/plugins/NotesAndReminders/src/globals.h index ecdae3cf1c..83fd2ce3ae 100644 --- a/plugins/NotesAndReminders/src/globals.h +++ b/plugins/NotesAndReminders/src/globals.h @@ -138,7 +138,7 @@ extern int g_notesListGeom[4]; extern int g_notesListColGeom[4]; extern HWND HKHwnd; -extern HANDLE hIconLibItem[]; +extern IconItem iconList[]; // these defs are only used to emphasize that SYSTEMTIMEtoFILETIME/FILETIMEtoSYSTEMTIME only convert the data type, // it does not apply any time conversion/correction like UTC to local etc. (if input is local, then output is local too) diff --git a/plugins/NotesAndReminders/src/main.cpp b/plugins/NotesAndReminders/src/main.cpp index a94eee9a94..f4a60f787c 100644 --- a/plugins/NotesAndReminders/src/main.cpp +++ b/plugins/NotesAndReminders/src/main.cpp @@ -90,53 +90,29 @@ INT_PTR PluginMenuCommandDeleteReminders(WPARAM w,LPARAM l) return 0; } -struct +IconItem iconList[] = { - char* szDescr; - char* szName; - int defIconID; -} -static const iconList[] = -{ - { LPGEN("New Reminder"), "AddReminder", IDI_ADDREMINDER}, - { LPGEN("Delete All Notes"), "DeleteIcon", IDI_DELETEICON}, - { LPGEN("New Note"), "NoteIcon", IDI_NOTEICON}, - { LPGEN("Show/Hide Notes"), "ShowHide", IDI_SHOWHIDE}, - { LPGEN("On Top Caption Icon"), "CaptionIcon", IDI_CAPTIONICON}, - { LPGEN("Delete All Reminders"), "DeleteReminder", IDI_DELETEREMINDER}, - { LPGEN("View Reminders"), "ViewReminders", IDI_VIEWREMINDERS}, - { LPGEN("Not on Top Caption Icon"), "CaptionIconNotTop", IDI_CAPTIONICONNOTTOP}, - { LPGEN("Hide Note Icon"), "HideNote", IDI_HIDENOTE}, - { LPGEN("Remove Note Icon"), "RemoveNote", IDI_REMOVENOTE}, - { LPGEN("Reminder Icon"), "Reminder", IDI_REMINDER}, - { LPGEN("Bring All to Front"), "BringFront", IDI_BRINGFRONT}, - { LPGEN("Play Sound Icon"), "PlaySound", IDI_PLAYSOUND}, - { LPGEN("View Notes"), "ViewNotes", IDI_VIEWNOTES}, - { LPGEN("New Note"), "NewNote", IDI_NOTEICON}, - { LPGEN("New Reminder"), "NewReminder", IDI_ADDREMINDER} + { LPGEN("New Reminder"), "AddReminder", IDI_ADDREMINDER }, + { LPGEN("Delete All Notes"), "DeleteIcon", IDI_DELETEICON }, + { LPGEN("New Note"), "NoteIcon", IDI_NOTEICON }, + { LPGEN("Show/Hide Notes"), "ShowHide", IDI_SHOWHIDE }, + { LPGEN("On Top Caption Icon"), "CaptionIcon", IDI_CAPTIONICON }, + { LPGEN("Delete All Reminders"), "DeleteReminder", IDI_DELETEREMINDER }, + { LPGEN("View Reminders"), "ViewReminders", IDI_VIEWREMINDERS }, + { LPGEN("Not on Top Caption Icon"), "CaptionIconNotTop", IDI_CAPTIONICONNOTTOP }, + { LPGEN("Hide Note Icon"), "HideNote", IDI_HIDENOTE }, + { LPGEN("Remove Note Icon"), "RemoveNote", IDI_REMOVENOTE }, + { LPGEN("Reminder Icon"), "Reminder", IDI_REMINDER }, + { LPGEN("Bring All to Front"), "BringFront", IDI_BRINGFRONT }, + { LPGEN("Play Sound Icon"), "PlaySound", IDI_PLAYSOUND }, + { LPGEN("View Notes"), "ViewNotes", IDI_VIEWNOTES }, + { LPGEN("New Note"), "NewNote", IDI_NOTEICON }, + { LPGEN("New Reminder"), "NewReminder", IDI_ADDREMINDER } }; -HANDLE hIconLibItem[SIZEOF(iconList)]; - void InitIcons(void) { - char szSettingName[100]; - - TCHAR szFile[MAX_PATH]; - GetModuleFileName(hinstance, szFile, SIZEOF(szFile)); - - SKINICONDESC sid = { sizeof(sid) }; - sid.ptszDefaultFile = szFile; - sid.pszName = szSettingName; - sid.pszSection = MODULENAME; - sid.flags = SIDF_PATH_TCHAR; - - for (int i = 0; i < SIZEOF(iconList); i++) { - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULENAME, iconList[i].szName); - sid.pszDescription = iconList[i].szDescr; - sid.iDefaultIndex = -iconList[i].defIconID; - hIconLibItem[i] = Skin_AddIcon(&sid); - } + Icon_Register(hinstance, MODULENAME, iconList, SIZEOF(iconList), MODULENAME); } int OnOptInitialise(WPARAM w, LPARAM L) @@ -160,12 +136,12 @@ int OnTopToolBarInit(WPARAM w,LPARAM L) ttb.cbSize = sizeof(TTBButton); ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; - ttb.hIconHandleUp = hIconLibItem[14]; + ttb.hIconHandleUp = iconList[14].hIcolib; ttb.pszService = MODULENAME"/MenuCommandAddNew"; ttb.name = ttb.pszTooltipUp = LPGEN("Add New Note"); TopToolbar_AddButton(&ttb); - ttb.hIconHandleUp = hIconLibItem[15]; + ttb.hIconHandleUp = iconList[15].hIcolib; ttb.pszService = MODULENAME"/MenuCommandNewReminder"; ttb.name = ttb.pszTooltipUp = LPGEN("Add New Reminder"); TopToolbar_AddButton(&ttb); @@ -214,56 +190,56 @@ int OnModulesLoaded(WPARAM wparam,LPARAM lparam) mi.flags = CMIF_TCHAR | CMIF_ICONFROMICOLIB; mi.position = 1600000000; - mi.icolibItem = hIconLibItem[2]; + mi.icolibItem = iconList[2].hIcolib; mi.ptszName = LPGENT("New &Note"); mi.pszService = MODULENAME"/MenuCommandAddNew"; if (g_AddContListMI) Menu_AddContactMenuItem(&mi); Menu_AddMainMenuItem(&mi); mi.position = 1600000001; - mi.icolibItem = hIconLibItem[0]; + mi.icolibItem = iconList[0].hIcolib; mi.ptszName = LPGENT("New &Reminder"); mi.pszService = MODULENAME"/MenuCommandNewReminder"; if (g_AddContListMI) Menu_AddContactMenuItem(&mi); Menu_AddMainMenuItem(&mi); mi.position = 1600100000; - mi.icolibItem = hIconLibItem[3]; + mi.icolibItem = iconList[3].hIcolib; mi.ptszName = LPGENT("&Show / Hide Notes"); mi.pszService = MODULENAME"/MenuCommandShowHide"; if (g_AddContListMI) Menu_AddContactMenuItem(&mi); Menu_AddMainMenuItem(&mi); mi.position = 1600100001; - mi.icolibItem = hIconLibItem[13]; + mi.icolibItem = iconList[13].hIcolib; mi.ptszName = LPGENT("Vie&w Notes"); mi.pszService = MODULENAME"/MenuCommandViewNotes"; if (g_AddContListMI) Menu_AddContactMenuItem(&mi); Menu_AddMainMenuItem(&mi); mi.position = 1600100002; - mi.icolibItem = hIconLibItem[1]; + mi.icolibItem = iconList[1].hIcolib; mi.ptszName = LPGENT("&Delete All Notes"); mi.pszService = MODULENAME"/MenuCommandDeleteAll"; if (g_AddContListMI) Menu_AddContactMenuItem(&mi); Menu_AddMainMenuItem(&mi); mi.position = 1600100003; - mi.icolibItem = hIconLibItem[11]; + mi.icolibItem = iconList[11].hIcolib; mi.ptszName = LPGENT("&Bring All to Front"); mi.pszService = MODULENAME"/MenuCommandBringAllFront"; if (g_AddContListMI) Menu_AddContactMenuItem(&mi); Menu_AddMainMenuItem(&mi); mi.position = 1600200000; - mi.icolibItem = hIconLibItem[6]; + mi.icolibItem = iconList[6].hIcolib; mi.ptszName = LPGENT("&View Reminders"); mi.pszService = MODULENAME"/MenuCommandViewReminders"; if (g_AddContListMI) Menu_AddContactMenuItem(&mi); Menu_AddMainMenuItem(&mi); mi.position = 1600200001; - mi.icolibItem = hIconLibItem[5]; + mi.icolibItem = iconList[5].hIcolib; mi.ptszName = LPGENT("D&elete All Reminders"); mi.pszService = MODULENAME"/MenuCommandDeleteReminders"; if (g_AddContListMI) Menu_AddContactMenuItem(&mi); diff --git a/plugins/NotesAndReminders/src/notes.cpp b/plugins/NotesAndReminders/src/notes.cpp index 76f001cea1..25f372b1e7 100644 --- a/plugins/NotesAndReminders/src/notes.cpp +++ b/plugins/NotesAndReminders/src/notes.cpp @@ -1325,17 +1325,17 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l { HICON hcIcon; if (SN->OnTop) - hcIcon = Skin_GetIconByHandle(hIconLibItem[4]); + hcIcon = Skin_GetIconByHandle(iconList[4].hIcolib); else - hcIcon = Skin_GetIconByHandle(hIconLibItem[7]); + hcIcon = Skin_GetIconByHandle(iconList[7].hIcolib); DrawIcon(hdc, wr.right - wr.left - 16, 0 + 3, hcIcon); Skin_ReleaseIcon(hcIcon); - hcIcon = Skin_GetIconByHandle(hIconLibItem[9]); + hcIcon = Skin_GetIconByHandle(iconList[9].hIcolib); DrawIcon(hdc, wr.right - wr.left - 32, 1 + 3, hcIcon); Skin_ReleaseIcon(hcIcon); - hcIcon = Skin_GetIconByHandle(hIconLibItem[8]); + hcIcon = Skin_GetIconByHandle(iconList[8].hIcolib); DrawIcon(hdc, wr.right - wr.left - 48, 1 + 3, hcIcon); Skin_ReleaseIcon(hcIcon); } @@ -1960,9 +1960,9 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM { HWND H; - HICON hIcon = Skin_GetIconByHandle(hIconLibItem[13], ICON_SMALL); + HICON hIcon = Skin_GetIconByHandle(iconList[13].hIcolib, ICON_SMALL); SendMessage(Dialog, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); - hIcon = Skin_GetIconByHandle(hIconLibItem[13], ICON_BIG); + hIcon = Skin_GetIconByHandle(iconList[13].hIcolib, ICON_BIG); SendMessage(Dialog, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); SetWindowText(Dialog, _T("Notes")); diff --git a/plugins/NotesAndReminders/src/options.cpp b/plugins/NotesAndReminders/src/options.cpp index e64086f63c..62bad6bcd3 100644 --- a/plugins/NotesAndReminders/src/options.cpp +++ b/plugins/NotesAndReminders/src/options.cpp @@ -602,7 +602,7 @@ void InitSettings(void) InitFonts(); - g_hReminderIcon = Skin_GetIconByHandle(hIconLibItem[10]); + g_hReminderIcon = Skin_GetIconByHandle(iconList[10].hIcolib); if (g_Transparency < MIN_ALPHA) g_Transparency = MIN_ALPHA; diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp index 4183892d09..d991757090 100644 --- a/plugins/NotesAndReminders/src/reminders.cpp +++ b/plugins/NotesAndReminders/src/reminders.cpp @@ -2265,7 +2265,7 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA } } - hIcon = Skin_GetIconByHandle(hIconLibItem[12]); + hIcon = Skin_GetIconByHandle(iconList[12].hIcolib); SendDlgItemMessage(Dialog,IDC_BTN_PLAYSOUND,BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hIcon); if (NewReminderVisible == 2 && pEditReminder->SoundSel) @@ -2655,9 +2655,9 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA break; case WM_INITDIALOG: { - HICON hIcon = Skin_GetIconByHandle(hIconLibItem[6], ICON_SMALL); + HICON hIcon = Skin_GetIconByHandle(iconList[6].hIcolib, ICON_SMALL); SendMessage(Dialog, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); - hIcon = Skin_GetIconByHandle(hIconLibItem[6], ICON_BIG); + hIcon = Skin_GetIconByHandle(iconList[6].hIcolib, ICON_BIG); SendMessage(Dialog, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); TranslateDialogDefault(Dialog); -- cgit v1.2.3