From e5868034a9b3cefc7b3d785e97b40b5382108fc8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 3 Aug 2016 09:55:35 +0000 Subject: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@17158 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_fontservice.h | 191 +++++++++++++++++++++---------------------- plugins/Alarms/src/frame.cpp | 66 ++++++--------- 2 files changed, 121 insertions(+), 136 deletions(-) diff --git a/include/m_fontservice.h b/include/m_fontservice.h index 10fb006760..ad89aeab34 100644 --- a/include/m_fontservice.h +++ b/include/m_fontservice.h @@ -17,18 +17,18 @@ #define DBFONTF_STRIKEOUT 8 // flags for compatibility -#define FIDF_APPENDNAME 1 // append 'Name' to the setting used to store font face (as CLC settings require) -#define FIDF_NOAS 2 // disable the As setting to prevent 'same as' behaviour -#define FIDF_SAVEACTUALHEIGHT 4 // write the actual height of a test string to the db -#define FIDF_SAVEPOINTSIZE 8 // write the font point size to the db +#define FIDF_APPENDNAME 0x0001 // append 'Name' to the setting used to store font face (as CLC settings require) +#define FIDF_NOAS 0x0002 // disable the As setting to prevent 'same as' behaviour +#define FIDF_SAVEACTUALHEIGHT 0x0004 // write the actual height of a test string to the db +#define FIDF_SAVEPOINTSIZE 0x0008 // write the font point size to the db // additional flags -#define FIDF_DEFAULTVALID 32 // the default font settings are valid - else, just use generic default -#define FIDF_NEEDRESTART 64 // setting changes will not take effect until miranda is restarted -#define FIDF_ALLOWREREGISTER 128 // allow plugins to register this font again (i.e. override already registered settings such as flags) -#define FIDF_ALLOWEFFECTS 256 // allow setting of font effects (i.e. underline and strikeout) -#define FIDF_DISABLESTYLES 512 // don't allow to select font attributes (bold/underline/italics) - // FIDF_ALLOWEFFECTS has priority and will override this flag! +#define FIDF_DEFAULTVALID 0x0020 // the default font settings are valid - else, just use generic default +#define FIDF_NEEDRESTART 0x0040 // setting changes will not take effect until miranda is restarted +#define FIDF_ALLOWREREGISTER 0x0080 // allow plugins to register this font again (i.e. override already registered settings such as flags) +#define FIDF_ALLOWEFFECTS 0x0100 // allow setting of font effects (i.e. underline and strikeout) +#define FIDF_DISABLESTYLES 0x0200 // don't allow to select font attributes (bold/underline/italics) + // FIDF_ALLOWEFFECTS has priority and will override this flag! // font class #define FIDF_CLASSMASK 0x70000000 @@ -37,62 +37,60 @@ #define FIDF_CLASSSMALL 0x30000000 // settings to be used for the value of 'deffontsettings' in the FontID structure below - i.e. defaults -typedef struct FontSettings_tag + +struct FontSettings { COLORREF colour; - char size; - BYTE style; // see the DBFONTF_* flags above - BYTE charset; - char szFace[LF_FACESIZE]; -} - FontSettings; + char size; + BYTE style; // see the DBFONTF_* flags above + BYTE charset; + char szFace[LF_FACESIZE]; +}; -typedef struct FontSettingsW_tag +struct FontSettingsW { COLORREF colour; - char size; - BYTE style; // see the DBFONTF_* flags above - BYTE charset; - wchar_t szFace[LF_FACESIZE]; -} - FontSettingsW; + char size; + BYTE style; // see the DBFONTF_* flags above + BYTE charset; + wchar_t szFace[LF_FACESIZE]; +}; // a font identifier structure - used for registering a font, and getting one out again // WARNING: do not use Translate(TS) for name or group as they // are translated by the core, which may lead to double translation. // Use LPGEN instead which are just dummy wrappers/markers for "lpgen.pl". -typedef struct FontID_tag + +struct FontID { int cbSize; - char group[64]; // [TRANSLATED-BY-CORE] group the font belongs to - this is the 'Font Group' list in the options page - char name[64]; // [TRANSLATED-BY-CORE] this is the name of the font setting - e.g. 'contacts' in the 'contact list' group - char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored - char prefix[32]; // this is prepended to the settings used to store this font's data in the db - DWORD flags; // bitwise OR of the FIDF_* flags above - FontSettings deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID - int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal, - // they will be ordered alphabetically by name) - char backgroundGroup[64]; - char backgroundName[64]; -} - FontID; - -typedef struct FontIDW_tag + char group[64]; // [TRANSLATED-BY-CORE] group the font belongs to - this is the 'Font Group' list in the options page + char name[64]; // [TRANSLATED-BY-CORE] this is the name of the font setting - e.g. 'contacts' in the 'contact list' group + char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored + char prefix[32]; // this is prepended to the settings used to store this font's data in the db + DWORD flags; // bitwise OR of the FIDF_* flags above + FontSettings deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID + int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal, + // they will be ordered alphabetically by name) + char backgroundGroup[64]; + char backgroundName[64]; +}; + +struct FontIDW { - int cbSize; - wchar_t group[64]; // [TRANSLATED-BY-CORE] group the font belongs to - this is the 'Font Group' list in the options page - wchar_t name[64]; // [TRANSLATED-BY-CORE] this is the name of the font setting - e.g. 'contacts' in the 'contact list' group - char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored - char prefix[32]; // this is prepended to the settings used to store this font's data in the db - DWORD flags; // bitwise OR of the FIDF_* flags above + int cbSize; + wchar_t group[64]; // [TRANSLATED-BY-CORE] group the font belongs to - this is the 'Font Group' list in the options page + wchar_t name[64]; // [TRANSLATED-BY-CORE] this is the name of the font setting - e.g. 'contacts' in the 'contact list' group + char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored + char prefix[32]; // this is prepended to the settings used to store this font's data in the db + DWORD flags; // bitwise OR of the FIDF_* flags above FontSettingsW deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID - int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal, - // they will be ordered alphabetically by name) + int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal, + // they will be ordered alphabetically by name) wchar_t backgroundGroup[64]; wchar_t backgroundName[64]; -} - FontIDW; +}; // register a font // wparam = (FontID *)&font_id @@ -100,12 +98,14 @@ typedef struct FontIDW_tag extern int hLangpack; -__forceinline void FontRegister( FontID* pFontID ) -{ CallService("Font/Register", (WPARAM)pFontID, hLangpack); +__forceinline void FontRegister(FontID* pFontID) +{ + CallService("Font/Register", (WPARAM)pFontID, hLangpack); } -__forceinline void FontRegisterW( FontIDW* pFontID ) -{ CallService("Font/RegisterW", (WPARAM)pFontID, hLangpack); +__forceinline void FontRegisterW(FontIDW* pFontID) +{ + CallService("Font/RegisterW", (WPARAM)pFontID, hLangpack); } // get a font @@ -133,7 +133,8 @@ __forceinline void FontRegisterW( FontIDW* pFontID ) // WARNING: do not use Translate(TS) for name or group as they // are translated by the core, which may lead to double translation. // Use LPGEN instead which are just dummy wrappers/markers for "lpgen.pl". -typedef struct ColourID_tag + +struct ColourID { int cbSize; char group[64]; // [TRANSLATED-BY-CORE] @@ -143,22 +144,20 @@ typedef struct ColourID_tag DWORD flags; // not used COLORREF defcolour; // default value int order; -} - ColourID; +}; // a font identifier structure - used for registering a font, and getting one out again -typedef struct ColourIDW_tag +struct ColourIDW { - int cbSize; - wchar_t group[64]; // [TRANSLATED-BY-CORE] - wchar_t name[64]; // [TRANSLATED-BY-CORE] - char dbSettingsGroup[32]; - char setting[32]; - DWORD flags; // not used - COLORREF defcolour; // default value - int order; -} - ColourIDW; + int cbSize; + wchar_t group[64]; // [TRANSLATED-BY-CORE] + wchar_t name[64]; // [TRANSLATED-BY-CORE] + char dbSettingsGroup[32]; + char setting[32]; + DWORD flags; // not used + COLORREF defcolour; // default value + int order; +}; // register a colour (this should be used for everything except actual text colour for registered fonts) // [note - a colour with name 'Background' [translated!] has special meaning and will be used as the background colour of @@ -167,11 +166,13 @@ typedef struct ColourIDW_tag // lparam = hLangpack __forceinline void ColourRegister(ColourID* pColorID) -{ CallService("Colour/Register", (WPARAM)pColorID, hLangpack); +{ + CallService("Colour/Register", (WPARAM)pColorID, hLangpack); } __forceinline void ColourRegisterW(ColourIDW* pColorID) -{ CallService("Colour/RegisterW", (WPARAM)pColorID, hLangpack); +{ + CallService("Colour/RegisterW", (WPARAM)pColorID, hLangpack); } // get a colour @@ -191,54 +192,52 @@ __forceinline void ColourRegisterW(ColourIDW* pColorID) // // EFFECTS // -typedef struct FONTEFFECT_tag + +struct FONTEFFECT { BYTE effectIndex; DWORD baseColour; // ARGB DWORD secondaryColour; // ARGB -} - FONTEFFECT; +}; -typedef struct EffectID_tag +struct EffectID { - int cbSize; - char group[64]; - char name[64]; - char dbSettingsGroup[32]; - char setting[32]; - DWORD flags; + int cbSize; + char group[64]; + char name[64]; + char dbSettingsGroup[32]; + char setting[32]; + DWORD flags; FONTEFFECT defeffect; - int order; - + int order; FONTEFFECT value; -} - EffectID; +}; -typedef struct EffectIDW_tag +struct EffectIDW { - int cbSize; - wchar_t group[64]; - wchar_t name[64]; - char dbSettingsGroup[32]; - char setting[32]; - DWORD flags; + int cbSize; + wchar_t group[64]; + wchar_t name[64]; + char dbSettingsGroup[32]; + char setting[32]; + DWORD flags; FONTEFFECT defeffect; - int order; - + int order; FONTEFFECT value; -} - EffectIDW; +}; // register an effect // wparam = (EffectID *)&effect_id // lparam = 0 __forceinline void EffectRegister(EffectID* pEffectID) -{ CallService("Effect/Register", (WPARAM)pEffectID, hLangpack); +{ + CallService("Effect/Register", (WPARAM)pEffectID, hLangpack); } __forceinline void EffectRegisterW(EffectIDW* pEffectID) -{ CallService("Effect/RegisterW", (WPARAM)pEffectID, hLangpack); +{ + CallService("Effect/RegisterW", (WPARAM)pEffectID, hLangpack); } // get a effect diff --git a/plugins/Alarms/src/frame.cpp b/plugins/Alarms/src/frame.cpp index 9fd38fb638..da831a8fb6 100644 --- a/plugins/Alarms/src/frame.cpp +++ b/plugins/Alarms/src/frame.cpp @@ -342,11 +342,10 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return TRUE; case WM_CONTEXTMENU: + POINT pt; + GetCursorPos(&pt); + ScreenToClient(hwnd_list, &pt); { - POINT pt; - GetCursorPos(&pt); - ScreenToClient(hwnd_list, &pt); - mir_cslock lck(list_cs); DWORD item = SendMessage(hwnd_list, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y)); @@ -376,22 +375,22 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL); DestroyMenu(menu); - if (ret) PostMessage(hwnd, WM_COMMAND, ret, 0); + if (ret) + PostMessage(hwnd, WM_COMMAND, ret, 0); } return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case ID_REMINDERFRAMECONTEXT_OPTIONS: - { - OPENOPTIONSDIALOG oop; - oop.cbSize = sizeof(oop); - oop.pszGroup = "Events"; - oop.pszPage = "Alarms"; - oop.pszTab = 0; - Options_Open(&oop); - } + OPENOPTIONSDIALOG oop; + oop.cbSize = sizeof(oop); + oop.pszGroup = "Events"; + oop.pszPage = "Alarms"; + oop.pszTab = 0; + Options_Open(&oop); break; + case ID_REMINDERFRAMECONTEXT_SUSPEND: if (context_menu_alarm.occurrence != OC_ONCE) { suspend(context_menu_alarm.id); @@ -402,16 +401,16 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } } break; + case ID_REMINDERFRAMECONTEXT_EDIT: EditNonModal(context_menu_alarm); break; + case ID_REMINDERFRAMECONTEXT_DELETE: remove(context_menu_alarm.id); PostMessage(hwnd, WMU_FILL_LIST, 0, 0); - if (hwndOptionsDialog) { - // refresh options list + if (hwndOptionsDialog) // refresh options list PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0); - } break; case ID_REMINDERFRAMECONTEXT_NEWALARM: @@ -486,16 +485,10 @@ INT_PTR ShowHideMenuFunc(WPARAM, LPARAM) int CreateFrame() { - WNDCLASS wndclass; - wndclass.style = 0; - wndclass.lpfnWndProc = FrameWindowProc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = hInst; - wndclass.hIcon = NULL; - wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); - wndclass.hbrBackground = 0; - wndclass.lpszMenuName = NULL; + WNDCLASS wndclass = {}; + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hInstance = hInst; + wndclass.lpfnWndProc = FrameWindowProc; wndclass.lpszClassName = L"AlarmsFrame"; RegisterClass(&wndclass); @@ -514,15 +507,9 @@ int CreateFrame() frame_id = CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,0); } else { - wndclass.style = 0;//CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = FrameContainerWindowProc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = hInst; - wndclass.hIcon = NULL; - wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); - wndclass.hbrBackground = 0; //(HBRUSH)(COLOR_3DFACE+1); - wndclass.lpszMenuName = NULL; + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hInstance = hInst; + wndclass.lpfnWndProc = FrameContainerWindowProc; wndclass.lpszClassName = L"AlarmsFrameContainer"; RegisterClass(&wndclass); @@ -608,14 +595,14 @@ int CreateFrame() return 0; } -void RefreshReminderFrame() { +void RefreshReminderFrame() +{ SendMessage(hwnd_plugin, WMU_FILL_LIST, 0, 0); - if (frame_id == -1) { + if (frame_id == -1) InvalidateRect(hwnd_frame, 0, TRUE); - } else + else InvalidateRect(hwnd_plugin, 0, TRUE); - } void InitFrames() @@ -633,4 +620,3 @@ void DeinitFrames() DeleteObject(bk_brush); } - -- cgit v1.2.3