From 0233716a1aeab439b0195408a76285fd2ecbbe93 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Feb 2013 14:49:25 +0000 Subject: slightly optimized color creation git-svn-id: http://svn.miranda-ng.org/main/trunk@3439 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MyDetails/src/frame.cpp | 30 ++-- plugins/MyDetails/src/mydetails.cpp | 282 ++++++++++++++++-------------------- 2 files changed, 137 insertions(+), 175 deletions(-) (limited to 'plugins/MyDetails') diff --git a/plugins/MyDetails/src/frame.cpp b/plugins/MyDetails/src/frame.cpp index c9c26968d0..476c286e5f 100644 --- a/plugins/MyDetails/src/frame.cpp +++ b/plugins/MyDetails/src/frame.cpp @@ -73,7 +73,10 @@ char font_sizes[] = { 13, 8, 8, 8, 8 }; BYTE font_styles[] = { DBFONTF_BOLD, 0, 0, DBFONTF_ITALIC, DBFONTF_ITALIC }; COLORREF font_colors[] = { RGB(0,0,0), RGB(0,0,0), RGB(0,0,0), RGB(150,150,150), RGB(150,150,150) }; -ColourIDT bg_colour, av_colour; +static ColourID + bg_colour = { sizeof(bg_colour), LPGEN("My Details"), LPGEN("Background"), MODULE_NAME, "BackgroundColor", 0, GetSysColor(COLOR_BTNFACE) }, + av_colour = { sizeof(av_colour), LPGEN("My Details"), LPGEN("Avatar Border"), MODULE_NAME, "AvatarBorderColor", 0, RGB(0,0,0) }; + int CreateFrame(); void FixMainMenu(); void RefreshFrame(); @@ -207,8 +210,8 @@ int ReloadFont(WPARAM wParam, LPARAM lParam) int ReloadColour(WPARAM,LPARAM) { - opts.bkg_color = (COLORREF) CallService(MS_COLOUR_GETT,(WPARAM)&bg_colour,0); - opts.draw_avatar_border_color = (COLORREF) CallService(MS_COLOUR_GETT,(WPARAM)&av_colour,0); + opts.bkg_color = (COLORREF)CallService(MS_COLOUR_GET,(WPARAM)&bg_colour,0); + opts.draw_avatar_border_color = (COLORREF)CallService(MS_COLOUR_GET,(WPARAM)&av_colour,0); RefreshFrame(); return 0; @@ -224,25 +227,10 @@ int CreateFrame() { HDC hdc = GetDC(NULL); - ZeroMemory(&bg_colour, sizeof(bg_colour)); - bg_colour.cbSize = sizeof(ColourIDT); - _tcsncpy(bg_colour.name,LPGENT("Background"),SIZEOF(bg_colour.name)); - _tcsncpy(bg_colour.group,LPGENT("My Details"),SIZEOF(bg_colour.group)); - strncpy(bg_colour.dbSettingsGroup,MODULE_NAME,sizeof(bg_colour.dbSettingsGroup)); - strncpy(bg_colour.setting,"BackgroundColor",sizeof(bg_colour.setting)); - bg_colour.defcolour = GetSysColor(COLOR_BTNFACE); - ColourRegisterT(&bg_colour); - - ZeroMemory(&av_colour, sizeof(av_colour)); - av_colour.cbSize = sizeof(ColourIDT); - _tcsncpy(av_colour.name,LPGENT("Avatar Border"),SIZEOF(av_colour.name)); - _tcsncpy(av_colour.group,LPGENT("My Details"),SIZEOF(av_colour.group)); - strncpy(av_colour.dbSettingsGroup,MODULE_NAME,sizeof(av_colour.dbSettingsGroup)); - strncpy(av_colour.setting,"AvatarBorderColor",sizeof(av_colour.setting)); - av_colour.defcolour = RGB(0,0,0); - ColourRegisterT(&av_colour); + ColourRegister(&bg_colour); + ColourRegister(&av_colour); ReloadColour(0,0); - HookEvent(ME_COLOUR_RELOAD,ReloadColour); + HookEvent(ME_COLOUR_RELOAD, ReloadColour); for (int i = 0 ; i < NUM_FONTS ; i++) { ZeroMemory(&font_id[i], sizeof(font_id[i])); diff --git a/plugins/MyDetails/src/mydetails.cpp b/plugins/MyDetails/src/mydetails.cpp index ddd65b54ad..3956494c9c 100644 --- a/plugins/MyDetails/src/mydetails.cpp +++ b/plugins/MyDetails/src/mydetails.cpp @@ -17,14 +17,14 @@ not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "commons.h" -// Prototypes ///////////////////////////////////////////////////////////////////////////////////// - HINSTANCE hInst; int hLangpack = 0; + +// Prototypes /////////////////////////////////////////////////////////////////////////// + PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), "My Details", @@ -35,7 +35,8 @@ PLUGININFOEX pluginInfo={ "© 2005-2008 Ricardo Pescuma Domenecci, Drugwash", "http://miranda-ng.org/", UNICODE_AWARE, - { 0xa82baeb3, 0xa33c, 0x4036, { 0xb8, 0x37, 0x78, 0x3, 0xa5, 0xb6, 0xc2, 0xab } } // {A82BAEB3-A33C-4036-B837-7803A5B6C2AB} + // {A82BAEB3-A33C-4036-B837-7803A5B6C2AB} + { 0xa82baeb3, 0xa33c, 0x4036, { 0xb8, 0x37, 0x78, 0x3, 0xa5, 0xb6, 0xc2, 0xab } } }; static IconItem iconList[] = @@ -55,24 +56,8 @@ HWND hwndSetNickname; long status_msg_dialog_open; HWND hwndSetStatusMsg; -// Hook called after init -static int MainInit(WPARAM wparam,LPARAM lparam); -static int MainUninit(WPARAM wParam, LPARAM lParam); - -// Services -static INT_PTR PluginCommand_SetMyNicknameUI(WPARAM wParam,LPARAM lParam); -static INT_PTR PluginCommand_SetMyNickname(WPARAM wParam,LPARAM lParam); -static INT_PTR PluginCommand_GetMyNickname(WPARAM wParam,LPARAM lParam); -static INT_PTR PluginCommand_SetMyAvatarUI(WPARAM wParam,LPARAM lParam); -static INT_PTR PluginCommand_SetMyAvatar(WPARAM wParam,LPARAM lParam); -static INT_PTR PluginCommand_GetMyAvatar(WPARAM wParam,LPARAM lParam); -static INT_PTR PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam); -static INT_PTR PluginCommand_CycleThroughtProtocols(WPARAM wParam,LPARAM lParam); - - // Functions ////////////////////////////////////////////////////////////////////////////////////// - BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) { hInst = hinstDLL; @@ -86,139 +71,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) const MUUID interfaces[] = { MIID_MDETAILS, MIID_LAST }; -extern "C" __declspec(dllexport) int Load() -{ - mir_getLP(&pluginInfo); - - // Hook event to load messages and show first one - HookEvent(ME_SYSTEM_MODULESLOADED, MainInit); - HookEvent(ME_SYSTEM_PRESHUTDOWN, MainUninit); - - nickname_dialog_open = 0; - status_msg_dialog_open = 0; - - // Options - InitOptions(); - - // Register services - CreateServiceFunction(MS_MYDETAILS_SETMYNICKNAME, PluginCommand_SetMyNickname); - CreateServiceFunction(MS_MYDETAILS_SETMYNICKNAMEUI, PluginCommand_SetMyNicknameUI); - CreateServiceFunction(MS_MYDETAILS_SETMYAVATAR, PluginCommand_SetMyAvatar); - CreateServiceFunction(MS_MYDETAILS_SETMYAVATARUI, PluginCommand_SetMyAvatarUI); - CreateServiceFunction(MS_MYDETAILS_GETMYNICKNAME, PluginCommand_GetMyNickname); - CreateServiceFunction(MS_MYDETAILS_GETMYAVATAR, PluginCommand_GetMyAvatar); - CreateServiceFunction(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, PluginCommand_SetMyStatusMessageUI); - CreateServiceFunction(MS_MYDETAILS_SHOWNEXTPROTOCOL, PluginCommand_ShowNextProtocol); - CreateServiceFunction(MS_MYDETAILS_SHOWPREVIOUSPROTOCOL, PluginCommand_ShowPreviousProtocol); - CreateServiceFunction(MS_MYDETAILS_SHOWPROTOCOL, PluginCommand_ShowProtocol); - CreateServiceFunction(MS_MYDETAILS_CYCLE_THROUGH_PROTOCOLS, PluginCommand_CycleThroughtProtocols); - - return 0; -} - -extern "C" __declspec(dllexport) int Unload(void) -{ - DestroyServiceFunction(MS_MYDETAILS_SETMYNICKNAME); - DestroyServiceFunction(MS_MYDETAILS_SETMYNICKNAMEUI); - DestroyServiceFunction(MS_MYDETAILS_SETMYAVATAR); - DestroyServiceFunction(MS_MYDETAILS_SETMYAVATARUI); - DestroyServiceFunction(MS_MYDETAILS_GETMYNICKNAME); - DestroyServiceFunction(MS_MYDETAILS_GETMYAVATAR); - DestroyServiceFunction(MS_MYDETAILS_SETMYSTATUSMESSAGEUI); - DestroyServiceFunction(MS_MYDETAILS_SHOWNEXTPROTOCOL); - DestroyServiceFunction(MS_MYDETAILS_SHOWPREVIOUSPROTOCOL); - DestroyServiceFunction(MS_MYDETAILS_SHOWPROTOCOL); - DestroyServiceFunction(MS_MYDETAILS_CYCLE_THROUGH_PROTOCOLS); - - DeInitProtocolData(); - return 0; -} - - -static INT_PTR Menu_SetMyAvatarUI(WPARAM wParam,LPARAM lParam) -{ - return PluginCommand_SetMyAvatarUI(0, 0); -} - -static INT_PTR Menu_SetMyNicknameUI(WPARAM wParam,LPARAM lParam) -{ - return PluginCommand_SetMyNicknameUI(0, 0); -} - -static INT_PTR Menu_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) -{ - return PluginCommand_SetMyStatusMessageUI(0, 0); -} - - -// Hook called after init -static int MainInit(WPARAM wparam,LPARAM lparam) -{ - InitProtocolData(); - - // Add options to menu - // !!!!!!!! check it later - CLISTMENUITEM mi = { sizeof(mi) }; - - if (protocols->CanSetAvatars()) { - mi.flags = CMIF_TCHAR; - mi.popupPosition = 500050000; - mi.ptszPopupName = LPGENT("My Details"); - mi.position = 100001; - mi.ptszName = LPGENT("Set My Avatar..."); - CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYAVATARUI, Menu_SetMyAvatarUI); - mi.pszService = "MENU_" MS_MYDETAILS_SETMYAVATARUI; - Menu_AddMainMenuItem(&mi); - } - - ZeroMemory(&mi,sizeof(mi)); - mi.cbSize = sizeof(mi); - mi.flags = CMIF_TCHAR; - mi.popupPosition = 500050000; - mi.ptszPopupName = LPGENT("My Details"); - mi.position = 100002; - mi.ptszName = LPGENT("Set My Nickname..."); - CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYNICKNAMEUI, Menu_SetMyNicknameUI); - mi.pszService = "MENU_" MS_MYDETAILS_SETMYNICKNAMEUI; - Menu_AddMainMenuItem(&mi); - - ZeroMemory(&mi,sizeof(mi)); - mi.cbSize = sizeof(mi); - mi.flags = CMIF_TCHAR; - mi.popupPosition = 500050000; - mi.ptszPopupName = LPGENT("My Details"); - mi.position = 100003; - mi.ptszName = LPGENT("Set My Status Message..."); - CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYSTATUSMESSAGEUI, Menu_SetMyStatusMessageUI); - mi.pszService = "MENU_" MS_MYDETAILS_SETMYSTATUSMESSAGEUI; - Menu_AddMainMenuItem(&mi); - - // Set protocols to show frame - ZeroMemory(&mi,sizeof(mi)); - mi.cbSize = sizeof(mi); - mi.flags = CMIF_TCHAR; - mi.popupPosition = 500050000; - mi.ptszPopupName = LPGENT("My Details"); - mi.position = 200001; - mi.ptszName = LPGENT("Show next protocol"); - mi.pszService = MS_MYDETAILS_SHOWNEXTPROTOCOL; - Menu_AddMainMenuItem(&mi); - - InitFrames(); - - if ( Skin_GetIcon("LISTENING_TO_ICON") == NULL) - Icon_Register(hInst, LPGEN("Contact List"), iconList, 1); - - Icon_Register(hInst, LPGEN("My Details"), iconList+1, SIZEOF(iconList)-1); - return 0; -} - -static int MainUninit(WPARAM wParam, LPARAM lParam) -{ - DeInitFrames(); - return 0; -} - // Set nickname /////////////////////////////////////////////////////////////////////////////////// #define WMU_SETDATA (WM_USER+1) @@ -712,4 +564,126 @@ static INT_PTR PluginCommand_CycleThroughtProtocols(WPARAM wParam,LPARAM lParam) LoadOptions(); return 0; -} \ No newline at end of file +} + +// Services /////////////////////////////////////////////////////////////////////////////////////// + +static INT_PTR Menu_SetMyAvatarUI(WPARAM wParam,LPARAM lParam) +{ + return PluginCommand_SetMyAvatarUI(0, 0); +} + +static INT_PTR Menu_SetMyNicknameUI(WPARAM wParam,LPARAM lParam) +{ + return PluginCommand_SetMyNicknameUI(0, 0); +} + +static INT_PTR Menu_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) +{ + return PluginCommand_SetMyStatusMessageUI(0, 0); +} + +// Hook called after init +static int MainInit(WPARAM wparam,LPARAM lparam) +{ + InitProtocolData(); + + // Add options to menu + CLISTMENUITEM mi = { sizeof(mi) }; + mi.cbSize = sizeof(mi); + mi.popupPosition = 500050000; + + if (protocols->CanSetAvatars()) { + mi.pszPopupName = LPGEN("My Details"); + mi.position = 100001; + mi.pszName = LPGEN("Set My Avatar..."); + CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYAVATARUI, Menu_SetMyAvatarUI); + mi.pszService = "MENU_" MS_MYDETAILS_SETMYAVATARUI; + Menu_AddMainMenuItem(&mi); + } + + mi.pszPopupName = LPGEN("My Details"); + mi.position = 100002; + mi.pszName = LPGEN("Set My Nickname..."); + CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYNICKNAMEUI, Menu_SetMyNicknameUI); + mi.pszService = "MENU_" MS_MYDETAILS_SETMYNICKNAMEUI; + Menu_AddMainMenuItem(&mi); + + mi.position = 100003; + mi.pszName = LPGEN("Set My Status Message..."); + CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYSTATUSMESSAGEUI, Menu_SetMyStatusMessageUI); + mi.pszService = "MENU_" MS_MYDETAILS_SETMYSTATUSMESSAGEUI; + Menu_AddMainMenuItem(&mi); + + // Set protocols to show frame + mi.position = 200001; + mi.pszName = LPGEN("Show next protocol"); + mi.pszService = MS_MYDETAILS_SHOWNEXTPROTOCOL; + Menu_AddMainMenuItem(&mi); + + InitFrames(); + + if ( Skin_GetIcon("LISTENING_TO_ICON") == NULL) + Icon_Register(hInst, LPGEN("Contact List"), iconList, 1); + + Icon_Register(hInst, LPGEN("My Details"), iconList+1, SIZEOF(iconList)-1); + return 0; +} + +static int MainUninit(WPARAM wParam, LPARAM lParam) +{ + DeInitFrames(); + return 0; +} + +// Load /////////////////////////////////////////////////////////////////////////////////////////// + +extern "C" __declspec(dllexport) int Load() +{ + mir_getLP(&pluginInfo); + + // Hook event to load messages and show first one + HookEvent(ME_SYSTEM_MODULESLOADED, MainInit); + HookEvent(ME_SYSTEM_PRESHUTDOWN, MainUninit); + + nickname_dialog_open = 0; + status_msg_dialog_open = 0; + + // Options + InitOptions(); + + // Register services + CreateServiceFunction(MS_MYDETAILS_SETMYNICKNAME, PluginCommand_SetMyNickname); + CreateServiceFunction(MS_MYDETAILS_SETMYNICKNAMEUI, PluginCommand_SetMyNicknameUI); + CreateServiceFunction(MS_MYDETAILS_SETMYAVATAR, PluginCommand_SetMyAvatar); + CreateServiceFunction(MS_MYDETAILS_SETMYAVATARUI, PluginCommand_SetMyAvatarUI); + CreateServiceFunction(MS_MYDETAILS_GETMYNICKNAME, PluginCommand_GetMyNickname); + CreateServiceFunction(MS_MYDETAILS_GETMYAVATAR, PluginCommand_GetMyAvatar); + CreateServiceFunction(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, PluginCommand_SetMyStatusMessageUI); + CreateServiceFunction(MS_MYDETAILS_SHOWNEXTPROTOCOL, PluginCommand_ShowNextProtocol); + CreateServiceFunction(MS_MYDETAILS_SHOWPREVIOUSPROTOCOL, PluginCommand_ShowPreviousProtocol); + CreateServiceFunction(MS_MYDETAILS_SHOWPROTOCOL, PluginCommand_ShowProtocol); + CreateServiceFunction(MS_MYDETAILS_CYCLE_THROUGH_PROTOCOLS, PluginCommand_CycleThroughtProtocols); + + return 0; +} + +// Unload ///////////////////////////////////////////////////////////////////////////////////////// + +extern "C" __declspec(dllexport) int Unload(void) +{ + DestroyServiceFunction(MS_MYDETAILS_SETMYNICKNAME); + DestroyServiceFunction(MS_MYDETAILS_SETMYNICKNAMEUI); + DestroyServiceFunction(MS_MYDETAILS_SETMYAVATAR); + DestroyServiceFunction(MS_MYDETAILS_SETMYAVATARUI); + DestroyServiceFunction(MS_MYDETAILS_GETMYNICKNAME); + DestroyServiceFunction(MS_MYDETAILS_GETMYAVATAR); + DestroyServiceFunction(MS_MYDETAILS_SETMYSTATUSMESSAGEUI); + DestroyServiceFunction(MS_MYDETAILS_SHOWNEXTPROTOCOL); + DestroyServiceFunction(MS_MYDETAILS_SHOWPREVIOUSPROTOCOL); + DestroyServiceFunction(MS_MYDETAILS_SHOWPROTOCOL); + DestroyServiceFunction(MS_MYDETAILS_CYCLE_THROUGH_PROTOCOLS); + + DeInitProtocolData(); + return 0; +} -- cgit v1.2.3