diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/NotesAndReminders/src/globals.h | 4 | ||||
-rw-r--r-- | plugins/NotesAndReminders/src/hotkeys.cpp | 67 | ||||
-rw-r--r-- | plugins/NotesAndReminders/src/main.cpp | 28 | ||||
-rw-r--r-- | plugins/NotesAndReminders/src/miscutils.cpp | 24 | ||||
-rw-r--r-- | plugins/NotesAndReminders/src/notes.cpp | 1015 | ||||
-rw-r--r-- | plugins/NotesAndReminders/src/options.cpp | 85 | ||||
-rw-r--r-- | plugins/NotesAndReminders/src/reminders.cpp | 973 | ||||
-rw-r--r-- | plugins/NotesAndReminders/src/version.h | 14 |
8 files changed, 913 insertions, 1297 deletions
diff --git a/plugins/NotesAndReminders/src/globals.h b/plugins/NotesAndReminders/src/globals.h index b918255061..42dc243638 100644 --- a/plugins/NotesAndReminders/src/globals.h +++ b/plugins/NotesAndReminders/src/globals.h @@ -48,7 +48,7 @@ typedef struct { typedef struct {
HWND SNHwnd,REHwnd;
- BOOL Visible,OnTop;
+ BOOL bVisible, bOnTop;
char *data;
ULARGE_INTEGER ID; // FILETIME in UTC
char *title;
@@ -75,7 +75,7 @@ extern void CreateMsgWindow(void); extern void DestroyMsgWindow(void);
extern STICKYNOTE* NewNote(int Ax,int Ay,int Aw,int Ah,char *Data,
- ULARGE_INTEGER *ID,BOOL Visible,BOOL OnTop,int scrollV);
+ ULARGE_INTEGER *ID,BOOL Visible,BOOL bOnTop,int scrollV);
extern void LoadNotes(BOOL bIsStartup);
extern void SaveNotes(void);
extern void DeleteNotes(void);
diff --git a/plugins/NotesAndReminders/src/hotkeys.cpp b/plugins/NotesAndReminders/src/hotkeys.cpp index 4084e6752b..566129094d 100644 --- a/plugins/NotesAndReminders/src/hotkeys.cpp +++ b/plugins/NotesAndReminders/src/hotkeys.cpp @@ -2,18 +2,13 @@ #define MSG_WND_CLASS "MIM_SNMsgWindow"
-
HWND HKHwnd;
-
enum KB_ACTIONS {KB_NEW_NOTE = 1, KB_TOGGLE_NOTES, KB_NEW_REMINDER};
-
void RegisterKeyBindings()
{
- HOTKEYDESC desc;
-
- memset(&desc, 0, sizeof(desc));
+ HOTKEYDESC desc = {};
desc.cbSize = sizeof(desc);
desc.pwszSection = _A2W(SECTIONNAME);
desc.dwFlags = HKD_UNICODE;
@@ -47,66 +42,26 @@ void RegisterKeyBindings() Hotkey_Register(&desc);
}
-
-/*int HandleNRShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK NotifyHotKeyWndProc(HWND AHwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
- STICKYNOTE* PSN;
-
- BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000;
- BOOL isAlt = GetKeyState(VK_MENU) & 0x8000;
- BOOL isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) && !isAlt;
-
- int action;
- MSG amsg;
- amsg.hwnd = hwnd;
- amsg.message = msg;
- amsg.wParam = wParam;
- amsg.lParam = lParam;
-
- switch ( (action = CallService(MS_HOTKEY_CHECK, (WPARAM)&amsg, (LPARAM)SECTIONNAME)) )
- {
- case KB_NEW_NOTE:
- PSN = NewNote(0,0,0,0,NULL,NULL,TRUE,TRUE,0);
- SetFocus(PSN->REHwnd);
- return FALSE;
- case KB_TOGGLE_NOTES:
- ShowHideNotes();
- return FALSE;
- case KB_NEW_REMINDER:
- NewReminder();
- return FALSE;
- }
-
- return -1;
-}*/
-
-
-LRESULT CALLBACK NotifyHotKeyWndProc(HWND AHwnd,UINT Message,WPARAM wParam,LPARAM lParam)
-{
- BOOL b;
-
- switch (Message)
- {
+ switch (Message) {
case WM_TIMER:
- {
- KillTimer(HKHwnd,1026);
- b = CheckRemindersAndStart();
- SetTimer(HKHwnd,1026,b ? REMINDER_UPDATE_INTERVAL_SHORT : REMINDER_UPDATE_INTERVAL,0);
+ KillTimer(HKHwnd, 1026);
+ BOOL b = CheckRemindersAndStart();
+ SetTimer(HKHwnd, 1026, b ? REMINDER_UPDATE_INTERVAL_SHORT : REMINDER_UPDATE_INTERVAL, 0);
- return FALSE;
- }
+ return FALSE;
}
- return DefWindowProc(AHwnd,Message,wParam,lParam);
+ return DefWindowProc(AHwnd, Message, wParam, lParam);
}
void CreateMsgWindow(void)
{
HWND hParent = NULL;
- WNDCLASSEX TWC = {0};
+ WNDCLASSEX TWC = { 0 };
- if (!GetClassInfoEx(hmiranda, MSG_WND_CLASS, &TWC))
- {
+ if (!GetClassInfoEx(hmiranda, MSG_WND_CLASS, &TWC)) {
TWC.style = 0;
TWC.cbClsExtra = 0;
TWC.cbWndExtra = 0;
@@ -129,6 +84,6 @@ void CreateMsgWindow(void) void DestroyMsgWindow(void)
{
- KillTimer(HKHwnd,1026);
+ KillTimer(HKHwnd, 1026);
DestroyWindow(HKHwnd);
}
diff --git a/plugins/NotesAndReminders/src/main.cpp b/plugins/NotesAndReminders/src/main.cpp index c4985c1b84..8af86244e6 100644 --- a/plugins/NotesAndReminders/src/main.cpp +++ b/plugins/NotesAndReminders/src/main.cpp @@ -127,7 +127,7 @@ static int OnOptInitialise(WPARAM w, LPARAM) return 0;
}
-int OnTopToolBarInit(WPARAM, LPARAM)
+int OnTopToolBarInit(WPARAM, LPARAM)
{
TTBButton ttb = { 0 };
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
@@ -156,21 +156,21 @@ static void InitServices() // register menu command services
- CreateServiceFunction(MODULENAME"/MenuCommandAddNew",PluginMenuCommandAddNew);
- CreateServiceFunction(MODULENAME"/MenuCommandShowHide",PluginMenuCommandShowHide);
- CreateServiceFunction(MODULENAME"/MenuCommandViewNotes",PluginMenuCommandViewNotes);
- CreateServiceFunction(MODULENAME"/MenuCommandDeleteAll",PluginMenuCommandDeleteAll);
- CreateServiceFunction(MODULENAME"/MenuCommandBringAllFront",PluginMenuCommandAllBringFront);
+ CreateServiceFunction(MODULENAME"/MenuCommandAddNew", PluginMenuCommandAddNew);
+ CreateServiceFunction(MODULENAME"/MenuCommandShowHide", PluginMenuCommandShowHide);
+ CreateServiceFunction(MODULENAME"/MenuCommandViewNotes", PluginMenuCommandViewNotes);
+ CreateServiceFunction(MODULENAME"/MenuCommandDeleteAll", PluginMenuCommandDeleteAll);
+ CreateServiceFunction(MODULENAME"/MenuCommandBringAllFront", PluginMenuCommandAllBringFront);
//
- CreateServiceFunction(MODULENAME"/MenuCommandNewReminder",PluginMenuCommandNewReminder);
- CreateServiceFunction(MODULENAME"/MenuCommandViewReminders",PluginMenuCommandViewReminders);
- CreateServiceFunction(MODULENAME"/MenuCommandDeleteReminders",PluginMenuCommandDeleteReminders);
+ CreateServiceFunction(MODULENAME"/MenuCommandNewReminder", PluginMenuCommandNewReminder);
+ CreateServiceFunction(MODULENAME"/MenuCommandViewReminders", PluginMenuCommandViewReminders);
+ CreateServiceFunction(MODULENAME"/MenuCommandDeleteReminders", PluginMenuCommandDeleteReminders);
// register misc
- CreateServiceFunction(MODULENAME"/OpenTriggeredReminder",OpenTriggeredReminder);
+ CreateServiceFunction(MODULENAME"/OpenTriggeredReminder", OpenTriggeredReminder);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -191,8 +191,8 @@ int OnModulesLoaded(WPARAM, LPARAM) RegisterFontServiceFonts();
RegisterKeyBindings();
- g_AddContListMI = (BOOL)db_get_dw(0,MODULENAME,"AddContactMenuItems",1);
-
+ g_AddContListMI = (BOOL)db_get_dw(0, MODULENAME, "AddContactMenuItems", 1);
+
// register menus
CMenuItem mi;
mi.root = Menu_CreateRoot(MO_MAIN, LPGENW("Notes && Reminders"), 1600000000);
@@ -249,7 +249,7 @@ int OnModulesLoaded(WPARAM, LPARAM) // register misc
hkOptInit = HookEvent(ME_OPT_INITIALISE, OnOptInitialise);
- hkTopToolbarInit = HookEvent("TopToolBar/ModuleLoaded", OnTopToolBarInit);
+ hkTopToolbarInit = HookEvent("TopToolBar/ModuleLoaded", OnTopToolBarInit);
UnhookEvent(hkModulesLoaded);
// init vars and load all data
@@ -302,7 +302,7 @@ extern "C" __declspec(dllexport) int Load(void) mir_getCLI();
hmiranda = GetModuleHandle(NULL);
- INITCOMMONCONTROLSEX ctrls = {0};
+ INITCOMMONCONTROLSEX ctrls = { 0 };
ctrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
ctrls.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&ctrls);
diff --git a/plugins/NotesAndReminders/src/miscutils.cpp b/plugins/NotesAndReminders/src/miscutils.cpp index 1ebc3fab85..5add0c6e07 100644 --- a/plugins/NotesAndReminders/src/miscutils.cpp +++ b/plugins/NotesAndReminders/src/miscutils.cpp @@ -18,9 +18,9 @@ WORD ConvertControlToHotKey(WORD HK) return R;
}
-void FreeSettingBlob(WORD pSize,void *pbBlob)
+void FreeSettingBlob(WORD pSize, void *pbBlob)
{
- DBVARIANT dbv = {0};
+ DBVARIANT dbv = { 0 };
dbv.type = DBVT_BLOB;
dbv.cpbVal = pSize;
dbv.pbVal = (BYTE*)pbBlob;
@@ -29,9 +29,9 @@ void FreeSettingBlob(WORD pSize,void *pbBlob) void ReadSettingBlob(MCONTACT hContact, char *ModuleName, char *SettingName, WORD *pSize, void **pbBlob)
{
- DBVARIANT dbv = {0};
+ DBVARIANT dbv = { 0 };
dbv.type = DBVT_BLOB;
- if ( db_get(hContact, ModuleName, SettingName, &dbv)) {
+ if (db_get(hContact, ModuleName, SettingName, &dbv)) {
*pSize = 0;
*pbBlob = NULL;
}
@@ -41,12 +41,12 @@ void ReadSettingBlob(MCONTACT hContact, char *ModuleName, char *SettingName, WOR }
}
-void WriteSettingIntArray(MCONTACT hContact,char *ModuleName,char *SettingName,const int *Value, int Size)
+void WriteSettingIntArray(MCONTACT hContact, char *ModuleName, char *SettingName, const int *Value, int Size)
{
db_set_blob(hContact, ModuleName, SettingName, (void*)Value, sizeof(int)*Size);
}
-bool ReadSettingIntArray(MCONTACT hContact,char *ModuleName,char *SettingName,int *Value, int Size)
+bool ReadSettingIntArray(MCONTACT hContact, char *ModuleName, char *SettingName, int *Value, int Size)
{
WORD sz = 4096;
int *pData;
@@ -61,7 +61,7 @@ bool ReadSettingIntArray(MCONTACT hContact,char *ModuleName,char *SettingName,in bResult = true;
}
- FreeSettingBlob(sz,pData);
+ FreeSettingBlob(sz, pData);
return bResult;
}
@@ -75,11 +75,11 @@ void TreeAdd(TREEELEMENT **root, void *Data) }
}
-void TreeAddSorted(TREEELEMENT **root,void *Data,int (*CompareCb)(TREEELEMENT*,TREEELEMENT*))
+void TreeAddSorted(TREEELEMENT **root, void *Data, int(*CompareCb)(TREEELEMENT*, TREEELEMENT*))
{
if (!*root) {
// list empty, just add normally
- TreeAdd(root,Data);
+ TreeAdd(root, Data);
return;
}
@@ -117,7 +117,7 @@ void TreeAddSorted(TREEELEMENT **root,void *Data,int (*CompareCb)(TREEELEMENT*,T Prev->next = NTE;
}
-void TreeDelete(TREEELEMENT **root,void *iItem)
+void TreeDelete(TREEELEMENT **root, void *iItem)
{
TREEELEMENT *TTE = *root, *Prev = NULL;
if (!TTE)
@@ -130,7 +130,7 @@ void TreeDelete(TREEELEMENT **root,void *iItem) if (TTE) {
if (Prev)
Prev->next = TTE->next;
- else
+ else
*root = (TREEELEMENT*)TTE->next;
SAFE_FREE((void**)&TTE);
}
@@ -154,7 +154,7 @@ int TreeGetCount(TREEELEMENT *root) {
if (!root)
return 0;
-
+
int i = 0;
TREEELEMENT *TTE = root;
while (TTE) {
diff --git a/plugins/NotesAndReminders/src/notes.cpp b/plugins/NotesAndReminders/src/notes.cpp index f7ef6474c5..373e4c05a7 100644 --- a/plugins/NotesAndReminders/src/notes.cpp +++ b/plugins/NotesAndReminders/src/notes.cpp @@ -6,13 +6,12 @@ // NotesData DB data params -#define DATATAG_TEXT 1 // %s -#define DATATAG_SCROLLPOS 2 // %u (specifies rich edit controls scroll post as first visible line) -#define DATATAG_BGCOL 3 // %x (custom background color) -#define DATATAG_FGCOL 4 // %x (custom text/fg colors) -#define DATATAG_TITLE 5 // %s (custom note title) -#define DATATAG_FONT 6 // %d:%u:%u:%s (custom font) - +#define DATATAG_TEXT 1 // %s +#define DATATAG_SCROLLPOS 2 // %u (specifies rich edit controls scroll post as first visible line) +#define DATATAG_BGCOL 3 // %x (custom background color) +#define DATATAG_FGCOL 4 // %x (custom text/fg colors) +#define DATATAG_TITLE 5 // %s (custom note title) +#define DATATAG_FONT 6 // %d:%u:%u:%s (custom font) #define MAX_TITLE_LEN 63 #define MAX_NOTE_LEN 16384 @@ -20,7 +19,6 @@ // delay before saving note changes (ms) #define NOTE_CHANGE_COMMIT_DELAY 1000 - #ifndef WS_EX_NOACTIVATE #define WS_EX_NOACTIVATE 0x08000000 #endif @@ -84,27 +82,24 @@ static struct ColorPreset clrPresets[] = { LPGEN("White"), RGB(255,255,255) } }; - TREEELEMENT *g_Stickies = NULL; +LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message, WPARAM wParam,LPARAM lParam); - -INT_PTR PluginMenuCommandAddNew(WPARAM w,LPARAM l); -INT_PTR PluginMenuCommandDeleteAll(WPARAM w,LPARAM l); +INT_PTR PluginMenuCommandAddNew(WPARAM w, LPARAM l); +INT_PTR PluginMenuCommandDeleteAll(WPARAM w, LPARAM l); void GetTriggerTimeString(const ULARGE_INTEGER *When, char *s, UINT strSize, BOOL bUtc); void OnListResize(HWND Dialog); void UpdateGeomFromWnd(HWND Dialog, int *geom, int *colgeom, int nCols); void FileTimeToTzLocalST(const FILETIME *lpUtc, SYSTEMTIME *tmLocal); - COLORREF GetCaptionColor(COLORREF bodyClr) { const DWORD r = ((bodyClr & 0xff) * 4) / 5; const DWORD g = (((bodyClr & 0xff00) * 4) / 5) & 0xff00; const DWORD b = (((bodyClr & 0xff0000) * 4) / 5) & 0xff0000; - return (COLORREF)(r|g|b); + return (COLORREF)(r | g | b); } @@ -116,10 +111,8 @@ static void EnsureUniqueID(STICKYNOTE *TSN) try_next: // check existing notes if id is in use - for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) - { - if (((STICKYNOTE*)TTE->ptrdata)->ID.QuadPart == TSN->ID.QuadPart) - { + for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) { + if (((STICKYNOTE*)TTE->ptrdata)->ID.QuadPart == TSN->ID.QuadPart) { // id in use, try new (increases the ID/time stamp by 100 nanosecond steps until an unused time is found, // allthough it's very unlikely that there will be duplicated id's it's better to make 100% sure) TSN->ID.QuadPart++; @@ -128,11 +121,9 @@ try_next: } } - static void InitNoteTitle(STICKYNOTE *TSN) { - if (g_NoteTitleDate) - { + if (g_NoteTitleDate) { char TempStr[MAX_PATH]; SYSTEMTIME tm; LCID lc = GetUserDefaultLCID(); @@ -142,16 +133,14 @@ static void InitNoteTitle(STICKYNOTE *TSN) memset(&tm, 0, sizeof(tm)); FileTimeToTzLocalST((FILETIME*)&TSN->ID, &tm); - if ( GetDateFormat(lc, 0, &tm, GetDateFormatStr(), TempStr, MAX_PATH) ) - { + if (GetDateFormat(lc, 0, &tm, GetDateFormatStr(), TempStr, MAX_PATH)) { // append time if requested - if (g_NoteTitleTime) - { + if (g_NoteTitleTime) { int n = (int)mir_strlen(TempStr); TempStr[n++] = ' '; TempStr[n] = 0; - GetTimeFormat(MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),0), 0, &tm, GetTimeFormatStr(), TempStr+n, MAX_PATH-n); + GetTimeFormat(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), 0), 0, &tm, GetTimeFormatStr(), TempStr + n, MAX_PATH - n); } TSN->title = _strdup(TempStr); @@ -161,19 +150,16 @@ static void InitNoteTitle(STICKYNOTE *TSN) TSN->CustomTitle = FALSE; } - static void InitStickyNoteLogFont(STICKYNOTEFONT *pCustomFont, LOGFONT *lf) { - if (!pCustomFont->size) - { + if (!pCustomFont->size) { SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE); lf->lfHeight = 10; HDC hdc = GetDC(0); - lf->lfHeight = -MulDiv(lf->lfHeight,GetDeviceCaps(hdc, LOGPIXELSY), 72); + lf->lfHeight = -MulDiv(lf->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72); ReleaseDC(0, hdc); } - else - { + else { lf->lfHeight = pCustomFont->size; } @@ -193,10 +179,9 @@ static void InitStickyNoteLogFont(STICKYNOTEFONT *pCustomFont, LOGFONT *lf) static BOOL CreateStickyNoteFont(STICKYNOTEFONT *pCustomFont, LOGFONT *plf) { - LOGFONT lf = {0}; + LOGFONT lf = { 0 }; - if (!plf) - { + if (!plf) { InitStickyNoteLogFont(pCustomFont, &lf); plf = &lf; } @@ -210,28 +195,25 @@ static BOOL CreateStickyNoteFont(STICKYNOTEFONT *pCustomFont, LOGFONT *plf) } -STICKYNOTE* NewNoteEx(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID,BOOL Visible,BOOL OnTop,int scrollV,COLORREF bgClr,COLORREF fgClr,char *Title,STICKYNOTEFONT *pCustomFont,BOOL bLoading) +STICKYNOTE* NewNoteEx(int Ax, int Ay, int Aw, int Ah, char *Data, ULARGE_INTEGER *ID, BOOL bVisible, BOOL bOnTop, int scrollV, COLORREF bgClr, COLORREF fgClr, char *Title, STICKYNOTEFONT *pCustomFont, BOOL bLoading) { - WNDCLASSEX TWC = {0}; + WNDCLASSEX TWC = { 0 }; WINDOWPLACEMENT TWP; - DWORD L1,L2; + DWORD L1, L2; SYSTEMTIME tm; - char TempStr[MAX_PATH] = {0}; - char *TData; - const BOOL bIsStartup = Visible & 0x10000; - Visible &= ~0x10000; + const BOOL bIsStartup = bVisible & 0x10000; + bVisible &= ~0x10000; - if (Data) TData = Data; else TData = NULL; + char *TData = Data; - if (!GetClassInfoEx(hmiranda, NOTE_WND_CLASS, &TWC)) - { + if (!GetClassInfoEx(hmiranda, NOTE_WND_CLASS, &TWC)) { TWC.style = CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE; TWC.cbClsExtra = 0; TWC.cbWndExtra = 0; TWC.hInstance = hmiranda; - TWC.hIcon = LoadIcon(0,IDI_APPLICATION); - TWC.hCursor = LoadCursor(0,IDC_ARROW); + TWC.hIcon = LoadIcon(0, IDI_APPLICATION); + TWC.hCursor = LoadCursor(0, IDC_ARROW); TWC.hbrBackground = 0; TWC.lpszMenuName = 0; TWC.lpszClassName = NOTE_WND_CLASS; @@ -240,10 +222,9 @@ STICKYNOTE* NewNoteEx(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID, if (!RegisterClassEx(&TWC)) return NULL; } - if (!TData || Aw < 0 || Ah < 0) - { + if (!TData || Aw < 0 || Ah < 0) { TWP.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(GetDesktopWindow(),&TWP); + GetWindowPlacement(GetDesktopWindow(), &TWP); Aw = g_NoteWidth; Ah = g_NoteHeight; Ax = ((TWP.rcNormalPosition.right - TWP.rcNormalPosition.left) / 2) - (Aw / 2); Ay = ((TWP.rcNormalPosition.bottom - TWP.rcNormalPosition.top) / 2) - (Ah / 2); @@ -251,22 +232,19 @@ STICKYNOTE* NewNoteEx(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID, STICKYNOTE *TSN = (STICKYNOTE*)malloc(sizeof(STICKYNOTE)); - if (ID) - { + if (ID) { TSN->ID = *ID; } - else - { + else { GetSystemTime(&tm); SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&TSN->ID); } EnsureUniqueID(TSN); - TreeAdd(&g_Stickies,TSN); + TreeAdd(&g_Stickies, TSN); - if (!TData) - { + if (!TData) { TData = _strdup(""); TSN->data = TData; } @@ -274,19 +252,17 @@ STICKYNOTE* NewNoteEx(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID, TSN->data = TData; // init note title (time-stamp) - if (Title) - { + if (Title) { TSN->title = Title; TSN->CustomTitle = TRUE; } - else - { + else { TSN->title = NULL; InitNoteTitle(TSN); } - TSN->Visible = Visible; - TSN->OnTop = OnTop; + TSN->bVisible = bVisible; + TSN->bOnTop = bOnTop; TSN->BgColor = bgClr; TSN->FgColor = fgClr; @@ -295,65 +271,59 @@ STICKYNOTE* NewNoteEx(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID, L1 = WS_EX_TOOLWINDOW; if (g_Transparency < 255) L1 |= WS_EX_LAYERED; - if (OnTop) L1 |= WS_EX_TOPMOST; + if (bOnTop) L1 |= WS_EX_TOPMOST; L2 = WS_POPUP | WS_THICKFRAME | WS_CAPTION; // NOTE: loaded note positions stem from GetWindowPlacement, which normally have a different coord space than // CreateWindow/SetWindowPos, BUT since we now use WS_EX_TOOLWINDOW they use the same coord space so // we don't have to worry about notes "drifting" between sessions - TSN->SNHwnd = CreateWindowEx(L1, NOTE_WND_CLASS, "StickyNote", L2, Ax,Ay,Aw,Ah, NULL, 0, hmiranda, TSN); + TSN->SNHwnd = CreateWindowEx(L1, NOTE_WND_CLASS, "StickyNote", L2, Ax, Ay, Aw, Ah, NULL, 0, hmiranda, TSN); if (g_Transparency < 255) - SetLayeredWindowAttributes(TSN->SNHwnd,0,(BYTE)g_Transparency,LWA_ALPHA); + SetLayeredWindowAttributes(TSN->SNHwnd, 0, (BYTE)g_Transparency, LWA_ALPHA); // ensure that window is not placed off-screen (if previous session had different monitor count or resolution) // NOTE: SetWindowPlacement should do this, but it's extremly flakey - if (Data) - { - if (!MonitorFromWindow(TSN->SNHwnd, MONITOR_DEFAULTTONULL) ) - { + if (Data) { + if (!MonitorFromWindow(TSN->SNHwnd, MONITOR_DEFAULTTONULL)) { TWP.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(GetDesktopWindow(), &TWP); if (Aw > 500) Aw = 500; - if (Ay < TWP.rcNormalPosition.left+10 || Ax > TWP.rcNormalPosition.right-120) + if (Ay < TWP.rcNormalPosition.left + 10 || Ax > TWP.rcNormalPosition.right - 120) Ax = ((TWP.rcNormalPosition.right - TWP.rcNormalPosition.left) / 2) - (Aw / 2) + (rand() & 0x3f); - if (Ay < TWP.rcNormalPosition.top+50 || Ay > TWP.rcNormalPosition.bottom-50) + if (Ay < TWP.rcNormalPosition.top + 50 || Ay > TWP.rcNormalPosition.bottom - 50) Ay = ((TWP.rcNormalPosition.bottom - TWP.rcNormalPosition.top) / 4) + (rand() & 0x1f); - SetWindowPos(TSN->SNHwnd, NULL, Ax, Ay, Aw, Ah, SWP_NOZORDER|SWP_NOACTIVATE); + SetWindowPos(TSN->SNHwnd, NULL, Ax, Ay, Aw, Ah, SWP_NOZORDER | SWP_NOACTIVATE); } } - if (Visible) - { + if (bVisible) { ShowWindow(TSN->SNHwnd, SW_SHOWNA); // when loading notes (only at startup), place all non-top notes at the bottom so they don't cover other windows - if (Data && !OnTop && bIsStartup) - SetWindowPos(TSN->SNHwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_ASYNCWINDOWPOS); + if (Data && !bOnTop && bIsStartup) + SetWindowPos(TSN->SNHwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS); } if (scrollV) - { SendMessage(TSN->REHwnd, EM_LINESCROLL, 0, scrollV); - } // make sure that any event triggered by init doesn't cause a meaningless save KillTimer(TSN->SNHwnd, 1025); - if (!bLoading) - { + if (!bLoading) { NOTIFY_LIST(); } return TSN; } -STICKYNOTE* NewNote(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID,BOOL Visible,BOOL OnTop,int scrollV) +STICKYNOTE* NewNote(int Ax, int Ay, int Aw, int Ah, char *Data, ULARGE_INTEGER *ID, BOOL bVisible, BOOL bOnTop, int scrollV) { - return NewNoteEx(Ax,Ay,Aw,Ah,Data,ID,Visible,OnTop,scrollV,0,0,NULL,NULL,FALSE); + return NewNoteEx(Ax, Ay, Aw, Ah, Data, ID, bVisible, bOnTop, scrollV, 0, 0, NULL, NULL, FALSE); } void LoadNotes(BOOL bIsStartup) @@ -364,16 +334,14 @@ void LoadNotes(BOOL bIsStartup) g_Stickies = NULL; - int NotesCount = db_get_dw(0,MODULENAME,"NotesData",0); + int NotesCount = db_get_dw(0, MODULENAME, "NotesData", 0); - for (int I = 0; I < NotesCount; I++) - { + for (int I = 0; I < NotesCount; I++) { char *DelPos; mir_snprintf(ValueName, "NotesData%d", I); - if (Value) - { + if (Value) { FreeSettingBlob(Size, Value); Value = NULL; } @@ -385,31 +353,29 @@ void LoadNotes(BOOL bIsStartup) if (!Size || !Value) continue; // the setting could not be read from DB -> skip - if (Value[0] == 'X') - { + if (Value[0] == 'X') { // new eXtended/fleXible data format - STICKYNOTE note = {0}; + STICKYNOTE note = { 0 }; int i, rect[4]; int scrollV = 0; STICKYNOTEFONT *pCustomFont = NULL; DWORD flags; - DelPos = strchr(Value+1,0x1B); + DelPos = strchr(Value + 1, 0x1B); if (DelPos) *DelPos = 0; // id:x:y:w:h:flags - TVal = strchr(Value+1, ':'); + TVal = strchr(Value + 1, ':'); if (!TVal || (DelPos && TVal > DelPos)) continue; *TVal++ = 0; - note.ID.QuadPart = _strtoui64(Value+1, NULL, 16); + note.ID.QuadPart = _strtoui64(Value + 1, NULL, 16); - for (i=0; i<4; i++) - { + for (i = 0; i<4; i++) { char *sep = strchr(TVal, ':'); if (!sep || (DelPos && sep > DelPos)) goto skip; @@ -423,13 +389,12 @@ void LoadNotes(BOOL bIsStartup) flags = strtoul(TVal, NULL, 16); if (flags & 1) - note.Visible = TRUE; + note.bVisible = TRUE; if (flags & 2) - note.OnTop = TRUE; + note.bOnTop = TRUE; // optional \033 separated params - while (DelPos) - { + while (DelPos) { char *sep; UINT tag; @@ -448,8 +413,7 @@ void LoadNotes(BOOL bIsStartup) tag = strtoul(TVal, NULL, 10); TVal = sep + 1; - switch (tag) - { + switch (tag) { case DATATAG_TEXT: note.data = _strdup(TVal); break; @@ -510,8 +474,7 @@ void LoadNotes(BOOL bIsStartup) mir_strcpy(pCustomFont->szFace, TVal2); pCustomFont->hFont = NULL; - if ( !CreateStickyNoteFont(pCustomFont, NULL) ) - { + if (!CreateStickyNoteFont(pCustomFont, NULL)) { free(pCustomFont); pCustomFont = NULL; } @@ -523,19 +486,18 @@ void LoadNotes(BOOL bIsStartup) if (!note.data) note.data = _strdup(""); - note.Visible = note.Visible && (!bIsStartup || g_ShowNotesAtStart); + note.bVisible = note.bVisible && (!bIsStartup || g_ShowNotesAtStart); if (bIsStartup) - note.Visible |= 0x10000; + note.bVisible |= 0x10000; - NewNoteEx(rect[0],rect[1],rect[2],rect[3],note.data,¬e.ID,note.Visible,note.OnTop,scrollV,note.BgColor,note.FgColor,note.title,pCustomFont,TRUE); + NewNoteEx(rect[0], rect[1], rect[2], rect[3], note.data, ¬e.ID, note.bVisible, note.bOnTop, scrollV, note.BgColor, note.FgColor, note.title, pCustomFont, TRUE); } - else - { + else { // old format (for DB backward compatibility) - int Tx,Ty,Tw,Th,TV,OT; + int Tx, Ty, Tw, Th, TV, OT; BOOL V; - char *Data,*ID; + char *Data, *ID; ULARGE_INTEGER newid; OT = 1; TV = 1; @@ -543,9 +505,8 @@ void LoadNotes(BOOL bIsStartup) Tw = 179; Th = 35; Data = NULL; ID = NULL; - if (DelPos = strchr(Value,0x1B)) - { // get first delimiter -// int PartLen = DelPos - TVal; + if (DelPos = strchr(Value, 0x1B)) { // get first delimiter + // int PartLen = DelPos - TVal; Data = NULL; ID = NULL; @@ -598,36 +559,32 @@ void LoadNotes(BOOL bIsStartup) V |= 0x10000; // convert old ID format to new - if ( strchr(ID, '-') ) - { + if (strchr(ID, '-')) { // validate format (otherwise create new) - if (mir_strlen(ID) < 19 || ID[2] != '-' || ID[5] != '-' || ID[10] != ' ' || ID[13] != ':' || ID[16] != ':') - { + if (mir_strlen(ID) < 19 || ID[2] != '-' || ID[5] != '-' || ID[10] != ' ' || ID[13] != ':' || ID[16] != ':') { ID = NULL; } - else - { + else { SYSTEMTIME tm; ID[2] = ID[5] = ID[10] = ID[13] = ID[16] = 0; memset(&tm, 0, sizeof(tm)); tm.wDay = (WORD)strtoul(ID, NULL, 10); - tm.wMonth = (WORD)strtoul(ID+3, NULL, 10); - tm.wYear = (WORD)strtoul(ID+6, NULL, 10); - tm.wHour = (WORD)strtoul(ID+11, NULL, 10); - tm.wMinute = (WORD)strtoul(ID+14, NULL, 10); - tm.wSecond = (WORD)strtoul(ID+17, NULL, 10); + tm.wMonth = (WORD)strtoul(ID + 3, NULL, 10); + tm.wYear = (WORD)strtoul(ID + 6, NULL, 10); + tm.wHour = (WORD)strtoul(ID + 11, NULL, 10); + tm.wMinute = (WORD)strtoul(ID + 14, NULL, 10); + tm.wSecond = (WORD)strtoul(ID + 17, NULL, 10); SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&newid); } } - else - { + else { ID = NULL; } - NewNoteEx(Tx,Ty,Tw,Th,Data,ID?&newid:NULL,V,(BOOL)OT,0,0,0,NULL,NULL,TRUE); + NewNoteEx(Tx, Ty, Tw, Th, Data, ID ? &newid : NULL, V, (BOOL)OT, 0, 0, 0, NULL, NULL, TRUE); } } skip:; @@ -641,8 +598,7 @@ skip:; void CloseNotesList() { - if (ListNotesVisible) - { + if (ListNotesVisible) { DestroyWindow(LV); ListNotesVisible = FALSE; } @@ -650,18 +606,16 @@ void CloseNotesList() static void PurgeNotesTree() { - while (g_Stickies) // empty whole tree - { + while (g_Stickies) { // empty whole tree STICKYNOTE *pt = (STICKYNOTE*)g_Stickies->ptrdata; if (pt->SNHwnd) DestroyWindow(pt->SNHwnd); SAFE_FREE((void**)&pt->title); SAFE_FREE((void**)&pt->data); - if (pt->pCustomFont) - { + if (pt->pCustomFont) { DeleteObject(pt->pCustomFont->hFont); free(pt->pCustomFont); } - TreeDelete(&g_Stickies,pt); + TreeDelete(&g_Stickies, pt); SAFE_FREE((void**)&pt); } g_Stickies = NULL; @@ -671,11 +625,10 @@ void PurgeNotes(void) { char ValueName[16]; - int NotesCount = db_get_dw(0,MODULENAME,"NotesData",0); - for(int I = 0; I < NotesCount; I++) - { + int NotesCount = db_get_dw(0, MODULENAME, "NotesData", 0); + for (int I = 0; I < NotesCount; I++) { mir_snprintf(ValueName, "NotesData%d", I); - db_unset(0,MODULENAME,ValueName); + db_unset(0, MODULENAME, ValueName); } } @@ -696,23 +649,20 @@ void BringAllNotesToFront(STICKYNOTE *pActive) // is active, it refuses to move notes to top like it should with HWND_TOP. as a workaround still doesn't // work 100% of the time, but at least more often, we first move not to top-most then for non-always-on-top // notes we demote them back as a non top-most window - for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) - { + for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) { STICKYNOTE *SN = (STICKYNOTE*)TTE->ptrdata; - if (SN->Visible && pActive != SN) - { - SetWindowPos(SN->SNHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); - if (!SN->OnTop) - SetWindowPos(SN->SNHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + if (SN->bVisible && pActive != SN) { + SetWindowPos(SN->SNHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + if (!SN->bOnTop) + SetWindowPos(SN->SNHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } } - if (pActive) - { - SetWindowPos(pActive->SNHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); - if (!pActive->OnTop) - SetWindowPos(pActive->SNHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + if (pActive) { + SetWindowPos(pActive->SNHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + if (!pActive->bOnTop) + SetWindowPos(pActive->SNHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } } @@ -723,18 +673,17 @@ static void JustSaveNotesEx(STICKYNOTE *pModified = NULL) int n, l; char ValueName[32]; WINDOWPLACEMENT wp; - int TX,TY,TW,TH; + int TX, TY, TW, TH; DWORD flags; int SzT; int scrollV; - char *tData, *Value; + char *tData; const int OldNotesCount = db_get_dw(0, MODULENAME, "NotesData", 0); db_set_dw(0, MODULENAME, "NotesData", NotesCount); - for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next, I++) - { + for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next, I++) { STICKYNOTE *pNote = (STICKYNOTE*)TTE->ptrdata; BOOL bDeleteTData = TRUE; scrollV = 0; @@ -750,21 +699,20 @@ static void JustSaveNotesEx(STICKYNOTE *pModified = NULL) // set flags flags = 0; - if (pNote->Visible) flags |= 1; - if (pNote->OnTop) flags |= 2; + if (pNote->bVisible) flags |= 1; + if (pNote->bOnTop) flags |= 2; // get note text SzT = GetWindowTextLength(pNote->REHwnd); - if (SzT) // TODO: change to support unicode and rtf, use EM_STREAMOUT - { - if (SzT > MAX_NOTE_LEN) SzT = MAX_NOTE_LEN; // we want to be far below the 64k limit + if (SzT) { // TODO: change to support unicode and rtf, use EM_STREAMOUT + if (SzT > MAX_NOTE_LEN) + SzT = MAX_NOTE_LEN; // we want to be far below the 64k limit tData = (char*)malloc(SzT + 1); if (tData) GetWindowText(pNote->REHwnd, tData, SzT + 1); } - if (pNote == pModified) - { + if (pNote == pModified) { // update the data of the modified note if (pNote->data) free(pNote->data); @@ -772,16 +720,12 @@ static void JustSaveNotesEx(STICKYNOTE *pModified = NULL) bDeleteTData = FALSE; } - if (!tData) - // empty note + if (!tData) // empty note SzT = 0; - else - // get current scroll position + else // get current scroll position scrollV = SendMessage(pNote->REHwnd, EM_GETFIRSTVISIBLELINE, 0, 0); - // - - Value = (char*)malloc(SzT + 512); + char *Value = (char*)malloc(SzT + 512); if (!Value) { if (bDeleteTData) SAFE_FREE((void**)&tData); @@ -795,51 +739,44 @@ static void JustSaveNotesEx(STICKYNOTE *pModified = NULL) if (l > 0) n += l; // scroll pos - if (scrollV > 0) - { - l = sprintf(Value+n, "\033""%u:%u", DATATAG_SCROLLPOS, (UINT)scrollV); //!!!!!!!!!! + if (scrollV > 0) { + l = sprintf(Value + n, "\033""%u:%u", DATATAG_SCROLLPOS, (UINT)scrollV); //!!!!!!!!!! if (l > 0) n += l; } // custom bg color - if (pNote->BgColor) - { - l = sprintf(Value+n, "\033""%u:%x", DATATAG_BGCOL, (UINT)(pNote->BgColor&0xffffff)); //!!!!!!!!!!!!! + if (pNote->BgColor) { + l = sprintf(Value + n, "\033""%u:%x", DATATAG_BGCOL, (UINT)(pNote->BgColor & 0xffffff)); //!!!!!!!!!!!!! if (l > 0) n += l; } // custom fg color - if (pNote->FgColor) - { - l = sprintf(Value+n, "\033""%u:%x", DATATAG_FGCOL, (UINT)(pNote->FgColor&0xffffff)); //!!!!!!!!!!!!! + if (pNote->FgColor) { + l = sprintf(Value + n, "\033""%u:%x", DATATAG_FGCOL, (UINT)(pNote->FgColor & 0xffffff)); //!!!!!!!!!!!!! if (l > 0) n += l; } - if (pNote->pCustomFont) - { - l = sprintf(Value+n, "\033""%u:%d:%u:%u:%s", DATATAG_FONT, + if (pNote->pCustomFont) { + l = sprintf(Value + n, "\033""%u:%d:%u:%u:%s", DATATAG_FONT, (int)pNote->pCustomFont->size, (UINT)pNote->pCustomFont->style, (UINT)pNote->pCustomFont->charset, pNote->pCustomFont->szFace); //!!!!!!!!!!!!!!! if (l > 0) n += l; } // custom title - if (pNote->CustomTitle && pNote->title) - { - l = sprintf(Value+n, "\033""%u:%s", DATATAG_TITLE, pNote->title); //!!!!!!!!!!!!! + if (pNote->CustomTitle && pNote->title) { + l = sprintf(Value + n, "\033""%u:%s", DATATAG_TITLE, pNote->title); //!!!!!!!!!!!!! if (l > 0) n += l; } // note text (ALWAYS PUT THIS PARAM LAST) - if (tData) - { - l = sprintf(Value+n, "\033""%u:%s", DATATAG_TEXT, tData); //!!!!!!!!!!!! + if (tData) { + l = sprintf(Value + n, "\033""%u:%s", DATATAG_TEXT, tData); //!!!!!!!!!!!! if (l > 0) n += l; } // clamp data size to WORD (including null terminator) - if (n >= 0xffff) - { + if (n >= 0xffff) { // huston, we have a problem, strip some reminder text n = 0xfffe; Value[0xffff] = 0; @@ -847,7 +784,7 @@ static void JustSaveNotesEx(STICKYNOTE *pModified = NULL) mir_snprintf(ValueName, "NotesData%d", NotesCount - I - 1); // we do not reverse notes in DB - db_set_blob(0, MODULENAME, ValueName, Value, n+1); + db_set_blob(0, MODULENAME, ValueName, Value, n + 1); SAFE_FREE((void**)&Value); if (bDeleteTData) @@ -859,10 +796,9 @@ static void JustSaveNotesEx(STICKYNOTE *pModified = NULL) } // delete any left over DB note entries - for(; I < OldNotesCount; I++) - { + for (; I < OldNotesCount; I++) { mir_snprintf(ValueName, "NotesData%d", I); - db_unset(0,MODULENAME,ValueName); + db_unset(0, MODULENAME, ValueName); } NOTIFY_LIST(); @@ -870,14 +806,12 @@ static void JustSaveNotesEx(STICKYNOTE *pModified = NULL) void OnDeleteNote(HWND hdlg, STICKYNOTE *SN) { - if (MessageBoxW(hdlg, TranslateT("Are you sure you want to delete this note?"), TranslateT(SECTIONNAME), MB_OKCANCEL) == IDOK) - { + if (MessageBoxW(hdlg, TranslateT("Are you sure you want to delete this note?"), TranslateT(SECTIONNAME), MB_OKCANCEL) == IDOK) { if (SN->SNHwnd) DestroyWindow(SN->SNHwnd); TreeDelete(&g_Stickies, SN); SAFE_FREE((void**)&SN->data); - if (SN->pCustomFont) - { + if (SN->pCustomFont) { DeleteObject(SN->pCustomFont->hFont); free(SN->pCustomFont); } @@ -889,8 +823,6 @@ void OnDeleteNote(HWND hdlg, STICKYNOTE *SN) void ShowHideNotes(void) { - BOOL Visible; - if (!g_Stickies) return; @@ -898,33 +830,31 @@ void ShowHideNotes(void) // only toggle vis state if all are hidden or all are visible UINT nHideCount = 0, nVisCount = 0; - - for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) - { - if (((STICKYNOTE*)TTE->ptrdata)->Visible) + + for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) { + if (((STICKYNOTE*)TTE->ptrdata)->bVisible) nVisCount++; else nHideCount++; } + BOOL bVisible; if (!nVisCount) - Visible = TRUE; + bVisible = TRUE; else if (!nHideCount) - Visible = FALSE; + bVisible = FALSE; else - Visible = TRUE; + bVisible = TRUE; - int bShow = Visible ? SW_SHOWNA : SW_HIDE; + int bShow = bVisible ? SW_SHOWNA : SW_HIDE; - - for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) - { + + for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) { STICKYNOTE *SN = (STICKYNOTE*)TTE->ptrdata; - if ((!Visible) != (!SN->Visible)) - { + if ((!bVisible) != (!SN->bVisible)) { ShowWindow(SN->SNHwnd, bShow); - SN->Visible = Visible; + SN->bVisible = bVisible; } } @@ -945,20 +875,16 @@ static int FindMenuItem(HMENU h, LPTSTR lpszName) { int n = GetMenuItemCount(h); - if (n <= 0) - { + if (n <= 0) { return -1; } // searches for a menu item based on name (used to avoid hardcoding item indices for sub-menus) - for (UINT i=0; i<(UINT)n; i++) - { + for (UINT i = 0; i < (UINT)n; i++) { char s[128]; - if ( GetMenuString(h, i, s, 128, MF_BYPOSITION) ) - { - if ( !mir_strcmp(s, lpszName) ) - { + if (GetMenuString(h, i, s, 128, MF_BYPOSITION)) { + if (!mir_strcmp(s, lpszName)) { return (int)i; } } @@ -967,16 +893,16 @@ static int FindMenuItem(HMENU h, LPTSTR lpszName) return -1; } -static BOOL DoContextMenu(HWND AhWnd,WPARAM,LPARAM lParam) +static BOOL DoContextMenu(HWND AhWnd, WPARAM, LPARAM lParam) { STICKYNOTE *SN = (STICKYNOTE*)GetProp(AhWnd, "ctrldata"); HMENU hMenuLoad, FhMenu, hSub; hMenuLoad = LoadMenu(hinstance, "MNU_NOTEPOPUP"); - FhMenu = GetSubMenu(hMenuLoad,0); + FhMenu = GetSubMenu(hMenuLoad, 0); - if (SN->OnTop) - CheckMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_CHECKED|MF_BYCOMMAND); + if (SN->bOnTop) + CheckMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_CHECKED | MF_BYCOMMAND); EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTEPOPUP_PASTETITLE, MF_BYCOMMAND | (IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED)); @@ -986,20 +912,19 @@ static BOOL DoContextMenu(HWND AhWnd,WPARAM,LPARAM lParam) // NOTE: names used for FindMenuItem would need to include & chars if such shortcuts are added to the menus int n = FindMenuItem(FhMenu, "Appearance"); - if (n >= 0 && (hSub = GetSubMenu(FhMenu, n))) - { + if (n >= 0 && (hSub = GetSubMenu(FhMenu, n))) { HMENU hBg = GetSubMenu(hSub, FindMenuItem(hSub, "Background Color")); HMENU hFg = GetSubMenu(hSub, FindMenuItem(hSub, "Text Color")); - for (int i=0; i<_countof(clrPresets); i++) - InsertMenu(hBg, i, MF_BYPOSITION|MF_OWNERDRAW, IDM_COLORPRESET_BG+i, Translate(clrPresets[i].szName)); + for (int i = 0; i < _countof(clrPresets); i++) + InsertMenu(hBg, i, MF_BYPOSITION | MF_OWNERDRAW, IDM_COLORPRESET_BG + i, Translate(clrPresets[i].szName)); - for (int i=0; i<_countof(clrPresets); i++) - InsertMenu(hFg, i, MF_BYPOSITION|MF_OWNERDRAW, IDM_COLORPRESET_FG+i, Translate(clrPresets[i].szName)); + for (int i = 0; i < _countof(clrPresets); i++) + InsertMenu(hFg, i, MF_BYPOSITION | MF_OWNERDRAW, IDM_COLORPRESET_FG + i, Translate(clrPresets[i].szName)); } TranslateMenu(FhMenu); - TrackPopupMenu(FhMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,LOWORD(lParam),HIWORD(lParam),0,AhWnd,0); + TrackPopupMenu(FhMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, LOWORD(lParam), HIWORD(lParam), 0, AhWnd, 0); DestroyMenu(hMenuLoad); return TRUE; } @@ -1013,12 +938,12 @@ static void MeasureColorPresetMenuItem(HWND hdlg, LPMEASUREITEMSTRUCT lpMeasureI ReleaseDC(hdlg, hdc); lpMeasureItem->itemWidth = 50 + sz.cx; - lpMeasureItem->itemHeight = (sz.cy+2)>18 ? sz.cy+2 : 18; + lpMeasureItem->itemHeight = (sz.cy + 2)>18 ? sz.cy + 2 : 18; } static void PaintColorPresetMenuItem(LPDRAWITEMSTRUCT lpDrawItem, struct ColorPreset *clrPresets2) { -// UINT n = lpDrawItem->itemID - IDM_COLORPRESET_BG; + // UINT n = lpDrawItem->itemID - IDM_COLORPRESET_BG; RECT rect; rect.left = lpDrawItem->rcItem.left + 50; rect.top = lpDrawItem->rcItem.top; @@ -1043,7 +968,7 @@ static void PaintColorPresetMenuItem(LPDRAWITEMSTRUCT lpDrawItem, struct ColorPr int h = lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top; rect.left = lpDrawItem->rcItem.left + 5; - rect.top = lpDrawItem->rcItem.top + ((h-14)>>1); + rect.top = lpDrawItem->rcItem.top + ((h - 14) >> 1); rect.right = rect.left + 40; rect.bottom = rect.top + 14; @@ -1058,35 +983,30 @@ static BOOL GetClipboardText_Title(char *pOut, int size) { BOOL bResult = FALSE; - if ( OpenClipboard(NULL) ) - { + if (OpenClipboard(NULL)) { HANDLE hData = GetClipboardData(CF_TEXT); LPCSTR buffer; - if (hData && (buffer = (LPCSTR)GlobalLock(hData))) - { + if (hData && (buffer = (LPCSTR)GlobalLock(hData))) { // trim initial white spaces while (*buffer && isspace(*buffer)) buffer++; size_t n = mir_strlen(buffer); if (n >= size) - n = size-1; + n = size - 1; memcpy(pOut, buffer, n); pOut[n] = 0; // end string on line break and convert tabs to spaces char *p = pOut; - while (*p) - { - if (*p == '\r' || *p == '\n') - { + while (*p) { + if (*p == '\r' || *p == '\n') { *p = 0; n = mir_strlen(pOut); break; } - else if (*p == '\t') - { + else if (*p == '\t') { *p = ' '; } p++; @@ -1108,10 +1028,10 @@ static BOOL GetClipboardText_Title(char *pOut, int size) static void SetNoteTextControl(STICKYNOTE *SN) { - CHARFORMAT CF = {0}; + CHARFORMAT CF = { 0 }; CF.cbSize = sizeof(CHARFORMAT); CF.dwMask = CFM_COLOR; - CF.crTextColor = SN->FgColor ? (SN->FgColor&0xffffff) : BodyFontColor; + CF.crTextColor = SN->FgColor ? (SN->FgColor & 0xffffff) : BodyFontColor; SendMessage(SN->REHwnd, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF); if (SN->data) // TODO: use EM_STREAMIN @@ -1121,11 +1041,10 @@ static void SetNoteTextControl(STICKYNOTE *SN) static UINT_PTR CALLBACK CFHookProc(HWND hdlg, UINT msg, WPARAM, LPARAM) { - if (msg == WM_INITDIALOG) - { + if (msg == WM_INITDIALOG) { // hide color selector - ShowWindow(GetDlgItem(hdlg,0x443), SW_HIDE); - ShowWindow(GetDlgItem(hdlg,0x473), SW_HIDE); + ShowWindow(GetDlgItem(hdlg, 0x443), SW_HIDE); + ShowWindow(GetDlgItem(hdlg, 0x473), SW_HIDE); TranslateDialogDefault(hdlg); } @@ -1133,10 +1052,9 @@ static UINT_PTR CALLBACK CFHookProc(HWND hdlg, UINT msg, WPARAM, LPARAM) } -LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam) +LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) - { + switch (message) { case WM_CLOSE: return TRUE; @@ -1144,9 +1062,9 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l { RECT SZ; - GetClientRect(hdlg,&SZ); - HWND H = GetDlgItem(hdlg,1); - MoveWindow(H, 0, 0, SZ.right,SZ.bottom, TRUE); + GetClientRect(hdlg, &SZ); + HWND H = GetDlgItem(hdlg, 1); + MoveWindow(H, 0, 0, SZ.right, SZ.bottom, TRUE); KillTimer(hdlg, 1025); SetTimer(hdlg, 1025, NOTE_CHANGE_COMMIT_DELAY, 0); @@ -1154,9 +1072,8 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l return TRUE; } - case WM_TIMER: - if (wParam == 1025) - { + case WM_TIMER: + if (wParam == 1025) { STICKYNOTE *SN = (STICKYNOTE*)GetProp(hdlg, "ctrldata"); KillTimer(hdlg, 1025); @@ -1164,12 +1081,12 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l } break; - case WM_MOVE: + case WM_MOVE: KillTimer(hdlg, 1025); SetTimer(hdlg, 1025, NOTE_CHANGE_COMMIT_DELAY, 0); return TRUE; - case WM_CREATE: + case WM_CREATE: { STICKYNOTE *SN = (STICKYNOTE*)GetProp(hdlg, "ctrldata"); @@ -1181,13 +1098,13 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l BringWindowToTop(hdlg); mystyle = WS_CHILD | WS_VISIBLE | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN; if (g_ShowScrollbar) mystyle |= WS_VSCROLL; - HWND H = CreateWindow(RICHEDIT_CLASS, 0, mystyle, 0, 0, CS->cx-3-3, CS->cy-3-(3+14), hdlg, (HMENU)1, hmiranda, 0); + HWND H = CreateWindowW(MSFTEDIT_CLASS, 0, mystyle, 0, 0, CS->cx - 3 - 3, CS->cy - 3 - (3 + 14), hdlg, (HMENU)1, hmiranda, 0); SN->REHwnd = H; SendMessage(H, EM_SETTEXTMODE, TM_PLAINTEXT, 0); SendMessage(H, EM_LIMITTEXT, MAX_NOTE_LEN, 0); SendMessage(H, WM_SETFONT, (WPARAM)(SN->pCustomFont ? SN->pCustomFont->hFont : hBodyFont), 1); SendMessage(H, EM_SETEVENTMASK, 0, ENM_CHANGE | ENM_LINK); - SendMessage(H, EM_SETBKGNDCOLOR, 0, SN->BgColor ? (SN->BgColor&0xffffff) : BodyColor); + SendMessage(H, EM_SETBKGNDCOLOR, 0, SN->BgColor ? (SN->BgColor & 0xffffff) : BodyColor); SendMessage(H, EM_AUTOURLDETECT, 1, 0); SetNoteTextControl(SN); } @@ -1197,9 +1114,9 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l { MINMAXINFO *mm = (MINMAXINFO*)lParam; // min width accomodates frame, buttons and some extra space for sanity - mm->ptMinTrackSize.x = 48+3+3+8 + 40; + mm->ptMinTrackSize.x = 48 + 3 + 3 + 8 + 40; // min height allows collapsing entire client area, only leaving frame and caption - mm->ptMinTrackSize.y = 3+3+14; + mm->ptMinTrackSize.y = 3 + 3 + 14; } return 0; @@ -1210,15 +1127,14 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l case WM_NCPAINT: // make window borders have the same color as caption { - STICKYNOTE *SN = (STICKYNOTE*)GetProp(hdlg,"ctrldata"); + STICKYNOTE *SN = (STICKYNOTE*)GetProp(hdlg, "ctrldata"); RECT rect, wr, r; //HDC hdc = GetDCEx(hdlg, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN); HDC hdc = GetWindowDC(hdlg); GetWindowRect(hdlg, &wr); - if (wParam && wParam != 1) - { + if (wParam && wParam != 1) { SelectClipRgn(hdc, (HRGN)wParam); OffsetClipRgn(hdc, -wr.left, -wr.top); } @@ -1231,39 +1147,39 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l // draw all frame sides separately to avoid filling client area (which flickers) { - // top - r.left = rect.left; r.right = rect.right; - r.top = rect.top; r.bottom = r.top + 3+14; - FillRect(hdc, &r, hBkBrush); - // bottom - r.top = rect.bottom - 3; r.bottom = rect.bottom; - FillRect(hdc, &r, hBkBrush); - // left - r.left = rect.left; r.right = r.left + 3; - r.top = rect.top + 3+14; r.bottom = rect.bottom - 3; - FillRect(hdc, &r, hBkBrush); - // right - r.left = rect.right - 3; r.right = rect.right; - FillRect(hdc, &r, hBkBrush); + // top + r.left = rect.left; r.right = rect.right; + r.top = rect.top; r.bottom = r.top + 3 + 14; + FillRect(hdc, &r, hBkBrush); + // bottom + r.top = rect.bottom - 3; r.bottom = rect.bottom; + FillRect(hdc, &r, hBkBrush); + // left + r.left = rect.left; r.right = r.left + 3; + r.top = rect.top + 3 + 14; r.bottom = rect.bottom - 3; + FillRect(hdc, &r, hBkBrush); + // right + r.left = rect.right - 3; r.right = rect.right; + FillRect(hdc, &r, hBkBrush); } // paint title bar contents (time stamp and buttons) if (SN && SN->title) { RECT R; - SelectObject(hdc,hCaptionFont); - R.top = 3+1; R.bottom = 3+11; R.left = 3+2; R.right = rect.right-3-1; + SelectObject(hdc, hCaptionFont); + R.top = 3 + 1; R.bottom = 3 + 11; R.left = 3 + 2; R.right = rect.right - 3 - 1; if (g_ShowNoteButtons) R.right -= 48; - SetTextColor(hdc,SN->FgColor ? (SN->FgColor&0xffffff) : CaptionFontColor); + SetTextColor(hdc, SN->FgColor ? (SN->FgColor & 0xffffff) : CaptionFontColor); SetBkMode(hdc, TRANSPARENT); DrawText(hdc, SN->title, -1, &R, DT_LEFT | DT_SINGLELINE | DT_END_ELLIPSIS | DT_VCENTER); } if (g_ShowNoteButtons) { HICON hcIcon; - if (SN->OnTop) + if (SN->bOnTop) hcIcon = IcoLib_GetIconByHandle(iconList[4].hIcolib); else hcIcon = IcoLib_GetIconByHandle(iconList[7].hIcolib); @@ -1292,7 +1208,7 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l pRect->bottom -= 3; pRect->right -= 3; pRect->left += 3; - pRect->top += 3+14; + pRect->top += 3 + 14; } return WVR_REDRAW; @@ -1301,49 +1217,45 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l RedrawWindow(hdlg, NULL, NULL, RDW_UPDATENOW); return TRUE; - case WM_NOTIFY: - if (LOWORD(wParam) == 1) - { - char *Buff; + case WM_NOTIFY: + if (LOWORD(wParam) == 1) { + char *Buff; PENLINK PEnLnk = (PENLINK)lParam; - if (PEnLnk->msg == WM_LBUTTONDOWN) - { - SendDlgItemMessage(hdlg,1,EM_EXSETSEL,0,(LPARAM)&(PEnLnk->chrg)); + if (PEnLnk->msg == WM_LBUTTONDOWN) { + SendDlgItemMessage(hdlg, 1, EM_EXSETSEL, 0, (LPARAM)&(PEnLnk->chrg)); Buff = (char*)malloc(PEnLnk->chrg.cpMax - PEnLnk->chrg.cpMin + 1); - SendDlgItemMessage(hdlg,1,EM_GETSELTEXT,0,(LPARAM)Buff); + SendDlgItemMessage(hdlg, 1, EM_GETSELTEXT, 0, (LPARAM)Buff); if ((GetAsyncKeyState(VK_CONTROL) >> 15) != 0) - ShellExecute(hdlg, "open", "iexplore", Buff, "" ,SW_SHOWNORMAL); + ShellExecute(hdlg, "open", "iexplore", Buff, "", SW_SHOWNORMAL); else if (g_lpszAltBrowser && *g_lpszAltBrowser) - ShellExecute(hdlg, "open", g_lpszAltBrowser, Buff, "" ,SW_SHOWNORMAL); + ShellExecute(hdlg, "open", g_lpszAltBrowser, Buff, "", SW_SHOWNORMAL); else ShellExecute(hdlg, "open", Buff, "", "", SW_SHOWNORMAL); SAFE_FREE((void**)&Buff); return TRUE; } return FALSE; - } + } break; case WM_NCHITTEST: { - int r = DefWindowProc(hdlg,message,wParam,lParam); - // filter out potential hits on windows default title bar buttons - switch (r) - { - case HTSYSMENU: - case HTCLOSE: - case HTMINBUTTON: - case HTMAXBUTTON: - return HTCAPTION; - } - return r; + int r = DefWindowProc(hdlg, message, wParam, lParam); + // filter out potential hits on windows default title bar buttons + switch (r) { + case HTSYSMENU: + case HTCLOSE: + case HTMINBUTTON: + case HTMAXBUTTON: + return HTCAPTION; + } + return r; } case WM_NCLBUTTONDOWN: - if (wParam == HTCAPTION && g_ShowNoteButtons) - { - long X,Y; + if (wParam == HTCAPTION && g_ShowNoteButtons) { + long X, Y; RECT rect; int Tw; @@ -1353,23 +1265,20 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l X = LOWORD(lParam) - rect.left; Y = HIWORD(lParam) - rect.top; - if (X > Tw - 16) - { - SendMessage(hdlg,WM_COMMAND,IDM_TOGGLEONTOP,0); + if (X > Tw - 16) { + SendMessage(hdlg, WM_COMMAND, IDM_TOGGLEONTOP, 0); return TRUE; } - else if (X > Tw - 31 && X < Tw - 16) - { - SendMessage(hdlg,WM_COMMAND,IDM_REMOVENOTE,0); + else if (X > Tw - 31 && X < Tw - 16) { + SendMessage(hdlg, WM_COMMAND, IDM_REMOVENOTE, 0); return TRUE; } - else if (X > Tw - 48 && X < Tw - 32) - { - SendMessage(hdlg,WM_COMMAND,IDM_HIDENOTE,0); + else if (X > Tw - 48 && X < Tw - 32) { + SendMessage(hdlg, WM_COMMAND, IDM_HIDENOTE, 0); return TRUE; } } - return DefWindowProc(hdlg,message,wParam,lParam); + return DefWindowProc(hdlg, message, wParam, lParam); case WM_MEASUREITEM: { @@ -1378,13 +1287,11 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l if (lpMeasureItem->CtlType != ODT_MENU) break; - if (lpMeasureItem->itemID >= IDM_COLORPRESET_BG && lpMeasureItem->itemID <= IDM_COLORPRESET_BG+_countof(clrPresets)) - { + if (lpMeasureItem->itemID >= IDM_COLORPRESET_BG && lpMeasureItem->itemID <= IDM_COLORPRESET_BG + _countof(clrPresets)) { MeasureColorPresetMenuItem(hdlg, lpMeasureItem, clrPresets + (lpMeasureItem->itemID - IDM_COLORPRESET_BG)); return TRUE; } - else if (lpMeasureItem->itemID >= IDM_COLORPRESET_FG && lpMeasureItem->itemID <= IDM_COLORPRESET_FG+_countof(clrPresets)) - { + else if (lpMeasureItem->itemID >= IDM_COLORPRESET_FG && lpMeasureItem->itemID <= IDM_COLORPRESET_FG + _countof(clrPresets)) { MeasureColorPresetMenuItem(hdlg, lpMeasureItem, clrPresets + (lpMeasureItem->itemID - IDM_COLORPRESET_FG)); return TRUE; } @@ -1392,20 +1299,17 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l break; case WM_DRAWITEM: - if (!wParam) - { + if (!wParam) { LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT)lParam; if (lpDrawItem->CtlType != ODT_MENU) break; - if (lpDrawItem->itemID >= IDM_COLORPRESET_BG && lpDrawItem->itemID <= IDM_COLORPRESET_BG+_countof(clrPresets)) - { + if (lpDrawItem->itemID >= IDM_COLORPRESET_BG && lpDrawItem->itemID <= IDM_COLORPRESET_BG + _countof(clrPresets)) { PaintColorPresetMenuItem(lpDrawItem, clrPresets + (lpDrawItem->itemID - IDM_COLORPRESET_BG)); return TRUE; } - else if (lpDrawItem->itemID >= IDM_COLORPRESET_FG && lpDrawItem->itemID <= IDM_COLORPRESET_FG+_countof(clrPresets)) - { + else if (lpDrawItem->itemID >= IDM_COLORPRESET_FG && lpDrawItem->itemID <= IDM_COLORPRESET_FG + _countof(clrPresets)) { PaintColorPresetMenuItem(lpDrawItem, clrPresets + (lpDrawItem->itemID - IDM_COLORPRESET_FG)); return TRUE; } @@ -1416,95 +1320,90 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l { STICKYNOTE *SN = (STICKYNOTE*)GetProp(hdlg, "ctrldata"); - switch ( HIWORD(wParam) ) - { + switch (HIWORD(wParam)) { case EN_CHANGE: case EN_VSCROLL: case EN_HSCROLL: - KillTimer(hdlg,1025); + KillTimer(hdlg, 1025); SetTimer(hdlg, 1025, NOTE_CHANGE_COMMIT_DELAY, 0); break; } - UINT id = (UINT) LOWORD(wParam); + UINT id = (UINT)LOWORD(wParam); HWND H = SN->REHwnd; - if (id >= IDM_COLORPRESET_BG && id <= IDM_COLORPRESET_BG+_countof(clrPresets)) - { - SN->BgColor = clrPresets[id-IDM_COLORPRESET_BG].color | 0xff000000; + if (id >= IDM_COLORPRESET_BG && id <= IDM_COLORPRESET_BG + _countof(clrPresets)) { + SN->BgColor = clrPresets[id - IDM_COLORPRESET_BG].color | 0xff000000; SendMessage(H, EM_SETBKGNDCOLOR, 0, SN->BgColor & 0xffffff); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); return FALSE; } - else if (id >= IDM_COLORPRESET_FG && id <= IDM_COLORPRESET_FG+_countof(clrPresets)) - { - CHARFORMAT CF = {0}; - SN->FgColor = clrPresets[id-IDM_COLORPRESET_FG].color | 0xff000000; + else if (id >= IDM_COLORPRESET_FG && id <= IDM_COLORPRESET_FG + _countof(clrPresets)) { + CHARFORMAT CF = { 0 }; + SN->FgColor = clrPresets[id - IDM_COLORPRESET_FG].color | 0xff000000; CF.cbSize = sizeof(CHARFORMAT); CF.dwMask = CFM_COLOR; CF.crTextColor = SN->FgColor & 0xffffff; SendMessage(H, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); return FALSE; } - switch (id) - { + switch (id) { case ID_CONTEXTMENUNOTEPOPUP_NEWNOTE: - PluginMenuCommandAddNew(0,0); + PluginMenuCommandAddNew(0, 0); break; case ID_APPEARANCE_CUSTOMBG: { - COLORREF custclr[16] = {0}; - CHOOSECOLOR cc = {0}; - COLORREF orgclr = SN->BgColor ? (COLORREF)(SN->BgColor&0xffffff) : (COLORREF)(BodyColor&0xffffff); + COLORREF custclr[16] = { 0 }; + CHOOSECOLOR cc = { 0 }; + COLORREF orgclr = SN->BgColor ? (COLORREF)(SN->BgColor & 0xffffff) : (COLORREF)(BodyColor & 0xffffff); cc.lStructSize = sizeof(cc); cc.hwndOwner = SN->SNHwnd; cc.rgbResult = orgclr; cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT | CC_SOLIDCOLOR; cc.lpCustColors = custclr; - if (ChooseColor(&cc) && cc.rgbResult != orgclr) - { + if (ChooseColor(&cc) && cc.rgbResult != orgclr) { SN->BgColor = cc.rgbResult | 0xff000000; - SendMessage(H, EM_SETBKGNDCOLOR, 0, SN->BgColor&0xffffff); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + SendMessage(H, EM_SETBKGNDCOLOR, 0, SN->BgColor & 0xffffff); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); } } break; case ID_APPEARANCE_CUSTOMTEXT: { - COLORREF custclr[16] = {0}; - CHOOSECOLOR cc = {0}; - COLORREF orgclr = SN->FgColor ? (COLORREF)(SN->FgColor&0xffffff) : (COLORREF)(BodyFontColor&0xffffff); + COLORREF custclr[16] = { 0 }; + CHOOSECOLOR cc = { 0 }; + COLORREF orgclr = SN->FgColor ? (COLORREF)(SN->FgColor & 0xffffff) : (COLORREF)(BodyFontColor & 0xffffff); cc.lStructSize = sizeof(cc); cc.hwndOwner = SN->SNHwnd; cc.rgbResult = orgclr; cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT | CC_SOLIDCOLOR; cc.lpCustColors = custclr; - if (ChooseColor(&cc) && cc.rgbResult != orgclr) - { - CHARFORMAT CF = {0}; + if (ChooseColor(&cc) && cc.rgbResult != orgclr) { + CHARFORMAT CF = { 0 }; SN->FgColor = cc.rgbResult | 0xff000000; CF.cbSize = sizeof(CHARFORMAT); CF.dwMask = CFM_COLOR; CF.crTextColor = SN->FgColor & 0xffffff; SendMessage(H, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); } } break; + case ID_APPEARANCE_CUSTOMFONT: { - CHOOSEFONT cf = {0}; - LOGFONT lf = {0}; + CHOOSEFONT cf = { 0 }; + LOGFONT lf = { 0 }; if (SN->pCustomFont) InitStickyNoteLogFont(SN->pCustomFont, &lf); @@ -1517,10 +1416,8 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l cf.Flags = CF_EFFECTS | CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_ENABLEHOOK; cf.lpfnHook = CFHookProc; - if ( ChooseFont(&cf) ) - { - if (!SN->pCustomFont) - { + if (ChooseFont(&cf)) { + if (!SN->pCustomFont) { SN->pCustomFont = (STICKYNOTEFONT*)malloc(sizeof(STICKYNOTEFONT)); SN->pCustomFont->hFont = NULL; } @@ -1530,8 +1427,7 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l SN->pCustomFont->charset = lf.lfCharSet; mir_strcpy(SN->pCustomFont->szFace, lf.lfFaceName); - if ( !CreateStickyNoteFont(SN->pCustomFont, &lf) ) - { + if (!CreateStickyNoteFont(SN->pCustomFont, &lf)) { // failed free(SN->pCustomFont); SN->pCustomFont = NULL; @@ -1541,7 +1437,7 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l SetWindowText(H, ""); SendMessage(H, WM_SETFONT, (WPARAM)(SN->pCustomFont ? SN->pCustomFont->hFont : hBodyFont), FALSE); SetNoteTextControl(SN); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); } } @@ -1550,26 +1446,25 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l case ID_BACKGROUNDCOLOR_RESET: SN->BgColor = 0; SendMessage(H, EM_SETBKGNDCOLOR, 0, (LPARAM)BodyColor); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); break; case ID_TEXTCOLOR_RESET: { - CHARFORMAT CF = {0}; + CHARFORMAT CF = { 0 }; SN->FgColor = 0; CF.cbSize = sizeof(CHARFORMAT); CF.dwMask = CFM_COLOR; CF.crTextColor = BodyFontColor; SendMessage(H, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); } JustSaveNotesEx(); break; case ID_FONT_RESET: - if (SN->pCustomFont) - { + if (SN->pCustomFont) { DeleteObject(SN->pCustomFont->hFont); free(SN->pCustomFont); SN->pCustomFont = NULL; @@ -1578,36 +1473,33 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l SetWindowText(H, ""); SendMessage(H, WM_SETFONT, (WPARAM)hBodyFont, FALSE); SetNoteTextControl(SN); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); } break; case ID_CONTEXTMENUNOTEPOPUP_PASTETITLE: { - char s[MAX_TITLE_LEN+1]; - if ( GetClipboardText_Title(s, sizeof(s)) ) - { + char s[MAX_TITLE_LEN + 1]; + if (GetClipboardText_Title(s, sizeof(s))) { if (SN->title) free(SN->title); SN->title = _strdup(s); SN->CustomTitle = TRUE; - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); } } break; case ID_CONTEXTMENUNOTEPOPUP_RESETTITLE: - if (SN->CustomTitle) - { - if (SN->title) - { + if (SN->CustomTitle) { + if (SN->title) { free(SN->title); SN->title = NULL; } InitNoteTitle(SN); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW); JustSaveNotesEx(); } break; @@ -1617,35 +1509,35 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l break; case IDM_HIDENOTE: - SN->Visible = FALSE; - ShowWindow(hdlg,SW_HIDE); + SN->bVisible = FALSE; + ShowWindow(hdlg, SW_HIDE); JustSaveNotesEx(); break; case IDM_COPY: - SendMessage(H,WM_COPY,0,0); + SendMessage(H, WM_COPY, 0, 0); break; case IDM_PASTE: - SendMessage(H,WM_PASTE,0,0); + SendMessage(H, WM_PASTE, 0, 0); break; case IDM_CUT: - SendMessage(H,WM_CUT,0,0); + SendMessage(H, WM_CUT, 0, 0); break; case IDM_CLEAR: - SendMessage(H,WM_CLEAR,0,0); + SendMessage(H, WM_CLEAR, 0, 0); break; case IDM_UNDO: - SendMessage(H,WM_UNDO,0,0); + SendMessage(H, WM_UNDO, 0, 0); break; case IDM_TOGGLEONTOP: - SN->OnTop = !SN->OnTop; - SetWindowPos(hdlg, SN->OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE); - RedrawWindow(hdlg, NULL, NULL, RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW); + SN->bOnTop = !SN->bOnTop; + SetWindowPos(hdlg, SN->bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); + RedrawWindow(hdlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); JustSaveNotesEx(); break; @@ -1665,11 +1557,11 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l break; case WM_CONTEXTMENU: - if (DoContextMenu(hdlg,wParam,lParam)) + if (DoContextMenu(hdlg, wParam, lParam)) return FALSE; default: - return DefWindowProc(hdlg,message,wParam,lParam); + return DefWindowProc(hdlg, message, wParam, lParam); } return FALSE; } @@ -1679,15 +1571,14 @@ static void EditNote(STICKYNOTE *SN) if (!SN) return; - if (!SN->Visible) - { - SN->Visible = TRUE; + if (!SN->bVisible) { + SN->bVisible = TRUE; JustSaveNotesEx(); } - SetWindowPos(SN->SNHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); - if (!SN->OnTop) - SetWindowPos(SN->SNHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + SetWindowPos(SN->SNHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + if (!SN->bOnTop) + SetWindowPos(SN->SNHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetFocus(SN->REHwnd); } @@ -1697,13 +1588,13 @@ char* GetPreviewString(const char *lpsz) int l; char *p; const int MaxLen = 80; - static char s[80+8]; + static char s[80 + 8]; if (!lpsz) return ""; // trim leading spaces - while ( iswspace(*lpsz) ) + while (iswspace(*lpsz)) lpsz++; l = (int)mir_strlen(lpsz); @@ -1711,17 +1602,15 @@ char* GetPreviewString(const char *lpsz) if (!l) return ""; - if (l <= MaxLen) - { + if (l <= MaxLen) { mir_strcpy(s, lpsz); } - else - { + else { memcpy(s, lpsz, MaxLen); s[MaxLen] = '.'; - s[MaxLen+1] = '.'; - s[MaxLen+2] = '.'; - s[MaxLen+3] = 0; + s[MaxLen + 1] = '.'; + s[MaxLen + 2] = '.'; + s[MaxLen + 3] = 0; } if (!s) @@ -1731,9 +1620,8 @@ char* GetPreviewString(const char *lpsz) p = s; - while (*p) - { - if ( iswspace(*p) ) + while (*p) { + if (iswspace(*p)) *p = ' '; p++; } @@ -1744,18 +1632,17 @@ char* GetPreviewString(const char *lpsz) static void InitListView(HWND AHLV) { int I = 0; - char *S; + char *S; char S1[128]; - char *V = Translate("Visible"); + char *V = Translate("bVisible"); char *T = Translate("Top"); - ListView_SetHoverTime(AHLV,700); - ListView_SetExtendedListViewStyle(AHLV,LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT); + ListView_SetHoverTime(AHLV, 700); + ListView_SetExtendedListViewStyle(AHLV, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT); ListView_DeleteAllItems(AHLV); - - for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) - { + + for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next) { STICKYNOTE *pNote = (STICKYNOTE*)TTE->ptrdata; LV_ITEM lvTIt; @@ -1767,44 +1654,42 @@ static void InitListView(HWND AHLV) lvTIt.iItem = I; lvTIt.iSubItem = 0; lvTIt.pszText = (pNote->CustomTitle && pNote->title) ? pNote->title : S1; - ListView_InsertItem(AHLV,&lvTIt); + ListView_InsertItem(AHLV, &lvTIt); - if (pNote->Visible) - { + if (pNote->bVisible) { lvTIt.iItem = I; lvTIt.iSubItem = 1; lvTIt.pszText = V; - ListView_SetItem(AHLV,&lvTIt); + ListView_SetItem(AHLV, &lvTIt); } - if (pNote->OnTop) - { + if (pNote->bOnTop) { lvTIt.iItem = I; lvTIt.iSubItem = 2; lvTIt.pszText = T; - ListView_SetItem(AHLV,&lvTIt); + ListView_SetItem(AHLV, &lvTIt); } S = GetPreviewString(pNote->data); lvTIt.iItem = I; lvTIt.iSubItem = 3; lvTIt.pszText = S; - ListView_SetItem(AHLV,&lvTIt); + ListView_SetItem(AHLV, &lvTIt); I++; } - ListView_SetItemState(AHLV,0,LVIS_SELECTED,LVIS_SELECTED); + ListView_SetItemState(AHLV, 0, LVIS_SELECTED, LVIS_SELECTED); } -static BOOL DoListContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam,STICKYNOTE *pNote) +static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam, STICKYNOTE *pNote) { HWND hwndListView = (HWND)wParam; - if (hwndListView != GetDlgItem(AhWnd,IDC_LISTREMINDERS)) + if (hwndListView != GetDlgItem(AhWnd, IDC_LISTREMINDERS)) return FALSE; - - HMENU hMenuLoad = LoadMenu(hinstance,"MNU_NOTELISTPOPUP"); - HMENU FhMenu = GetSubMenu(hMenuLoad,0); + + HMENU hMenuLoad = LoadMenu(hinstance, "MNU_NOTELISTPOPUP"); + HMENU FhMenu = GetSubMenu(hMenuLoad, 0); MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(mii); @@ -1814,31 +1699,28 @@ static BOOL DoListContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam,STICKYNOTE mii.fState |= MFS_GRAYED; SetMenuItemInfo(FhMenu, ID_CONTEXTMENUNOTELISTVIEW_EDITNOTE, FALSE, &mii); - if (!pNote) - { - EnableMenuItem(FhMenu, IDM_REMOVENOTE, MF_GRAYED|MF_BYCOMMAND); - EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY, MF_GRAYED|MF_BYCOMMAND); - EnableMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_GRAYED|MF_BYCOMMAND); + if (!pNote) { + EnableMenuItem(FhMenu, IDM_REMOVENOTE, MF_GRAYED | MF_BYCOMMAND); + EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY, MF_GRAYED | MF_BYCOMMAND); + EnableMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_GRAYED | MF_BYCOMMAND); } - else - { - if (pNote->Visible) - CheckMenuItem(FhMenu, ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY, MF_CHECKED|MF_BYCOMMAND); - if (pNote->OnTop) - CheckMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_CHECKED|MF_BYCOMMAND); + else { + if (pNote->bVisible) + CheckMenuItem(FhMenu, ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY, MF_CHECKED | MF_BYCOMMAND); + if (pNote->bOnTop) + CheckMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_CHECKED | MF_BYCOMMAND); } TranslateMenu(FhMenu); - TrackPopupMenu(FhMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,LOWORD(lParam),HIWORD(lParam),0,AhWnd,0); + TrackPopupMenu(FhMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, LOWORD(lParam), HIWORD(lParam), 0, AhWnd, 0); DestroyMenu(hMenuLoad); return TRUE; } -static INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam) +static INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam) { - switch (Message) - { + switch (Message) { case WM_SIZE: OnListResize(Dialog); UpdateGeomFromWnd(Dialog, g_notesListGeom, NULL, 0); @@ -1857,20 +1739,18 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam, return 0; case WM_RELOAD: - SetDlgItemText(Dialog,IDC_REMINDERDATA,""); - InitListView(GetDlgItem(Dialog,IDC_LISTREMINDERS)); + SetDlgItemText(Dialog, IDC_REMINDERDATA, ""); + InitListView(GetDlgItem(Dialog, IDC_LISTREMINDERS)); return TRUE; case WM_CONTEXTMENU: { STICKYNOTE *pNote = NULL; - HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS); - if ( ListView_GetSelectedCount(H) ) - { + HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS); + if (ListView_GetSelectedCount(H)) { int I = ListView_GetSelectionMark(H); - if (I != -1) - { + if (I != -1) { pNote = (STICKYNOTE*)TreeGetAt(g_Stickies, I); } } @@ -1889,8 +1769,7 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam, SetDlgItemText(Dialog, IDC_REMINDERDATA, ""); { - - HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS); + HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS); LV_COLUMN lvCol; lvCol.mask = LVCF_TEXT | LVCF_WIDTH; @@ -1898,32 +1777,31 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam, char *S = Translate("Note text"); lvCol.pszText = S; lvCol.cx = g_notesListColGeom[3]; - ListView_InsertColumn(H,0,&lvCol); + ListView_InsertColumn(H, 0, &lvCol); lvCol.mask = LVCF_TEXT | LVCF_WIDTH; S = Translate("Top"); lvCol.pszText = S; lvCol.cx = g_notesListColGeom[2]; - ListView_InsertColumn(H,0,&lvCol); + ListView_InsertColumn(H, 0, &lvCol); lvCol.mask = LVCF_TEXT | LVCF_WIDTH; - S = Translate("Visible"); + S = Translate("bVisible"); lvCol.pszText = S; lvCol.cx = g_notesListColGeom[1]; - ListView_InsertColumn(H,0,&lvCol); + ListView_InsertColumn(H, 0, &lvCol); lvCol.mask = LVCF_TEXT | LVCF_WIDTH; S = Translate("Date/Title"); lvCol.pszText = S; lvCol.cx = g_notesListColGeom[0]; - ListView_InsertColumn(H,0,&lvCol); + ListView_InsertColumn(H, 0, &lvCol); InitListView(H); SetWindowLongPtr(GetDlgItem(H, 0), GWL_ID, IDC_LISTREMINDERS_HEADER); LV = Dialog; - if (g_notesListGeom[1] && g_notesListGeom[2]) - { + if (g_notesListGeom[1] && g_notesListGeom[2]) { WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(Dialog, &wp); @@ -1947,133 +1825,116 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam, return TRUE; case WM_NOTIFY: - { - if (wParam == IDC_LISTREMINDERS) - { - LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam; - switch (NM->hdr.code) + if (wParam == IDC_LISTREMINDERS) { + LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam; + switch (NM->hdr.code) { + case LVN_ITEMCHANGED: { - case LVN_ITEMCHANGED: - { - char *S = ((STICKYNOTE*)TreeGetAt(g_Stickies,NM->iItem))->data; - SetDlgItemText(Dialog,IDC_REMINDERDATA,S); - } - break; - case NM_DBLCLK: - { - HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS); - if ( ListView_GetSelectedCount(H) ) - { - int I = ListView_GetSelectionMark(H); - if (I != -1) - { - EditNote((STICKYNOTE *)TreeGetAt(g_Stickies, I)); - } + char *S = ((STICKYNOTE*)TreeGetAt(g_Stickies, NM->iItem))->data; + SetDlgItemText(Dialog, IDC_REMINDERDATA, S); + } + break; + case NM_DBLCLK: + { + HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS); + if (ListView_GetSelectedCount(H)) { + int I = ListView_GetSelectionMark(H); + if (I != -1) { + EditNote((STICKYNOTE *)TreeGetAt(g_Stickies, I)); } } - break; } + break; } - else if (wParam == IDC_LISTREMINDERS_HEADER) - { - LPNMHEADER NM = (LPNMHEADER)lParam; - switch (NM->hdr.code) - { - case HDN_ENDTRACK: - UpdateGeomFromWnd(Dialog, NULL, g_notesListColGeom, _countof(g_notesListColGeom)); - break; - } + } + else if (wParam == IDC_LISTREMINDERS_HEADER) { + LPNMHEADER NM = (LPNMHEADER)lParam; + switch (NM->hdr.code) { + case HDN_ENDTRACK: + UpdateGeomFromWnd(Dialog, NULL, g_notesListColGeom, _countof(g_notesListColGeom)); + break; } } break; case WM_COMMAND: - { - switch(LOWORD(wParam)) + switch (LOWORD(wParam)) { + case ID_CONTEXTMENUNOTELISTVIEW_EDITNOTE: { - case ID_CONTEXTMENUNOTELISTVIEW_EDITNOTE: - { - HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS); - if ( ListView_GetSelectedCount(H) ) - { - int I = ListView_GetSelectionMark(H); - if (I != -1) - { - EditNote((STICKYNOTE*)TreeGetAt(g_Stickies, I)); - } + HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS); + if (ListView_GetSelectedCount(H)) { + int I = ListView_GetSelectionMark(H); + if (I != -1) { + EditNote((STICKYNOTE*)TreeGetAt(g_Stickies, I)); } } - return TRUE; - case ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY: - { - HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS); - if ( ListView_GetSelectedCount(H) ) - { - int I = ListView_GetSelectionMark(H); - if (I != -1) - { - STICKYNOTE *SN = (STICKYNOTE*)TreeGetAt(g_Stickies, I); - SN->Visible = !SN->Visible; - ShowWindow(SN->SNHwnd,SN->Visible?SW_SHOWNA:SW_HIDE); - JustSaveNotesEx(); - } + } + return TRUE; + + case ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY: + { + HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS); + if (ListView_GetSelectedCount(H)) { + int I = ListView_GetSelectionMark(H); + if (I != -1) { + STICKYNOTE *SN = (STICKYNOTE*)TreeGetAt(g_Stickies, I); + SN->bVisible = !SN->bVisible; + ShowWindow(SN->SNHwnd, SN->bVisible ? SW_SHOWNA : SW_HIDE); + JustSaveNotesEx(); } } - return TRUE; - case IDM_TOGGLEONTOP: - { - HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS); - if ( ListView_GetSelectedCount(H) ) - { - int I = ListView_GetSelectionMark(H); - if (I != -1) - { - STICKYNOTE *SN = (STICKYNOTE*)TreeGetAt(g_Stickies,I); - SN->OnTop = !SN->OnTop; - SetWindowPos(SN->SNHwnd, SN->OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE); - RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW); - JustSaveNotesEx(); - } + } + return TRUE; + + case IDM_TOGGLEONTOP: + { + HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS); + if (ListView_GetSelectedCount(H)) { + int I = ListView_GetSelectionMark(H); + if (I != -1) { + STICKYNOTE *SN = (STICKYNOTE*)TreeGetAt(g_Stickies, I); + SN->bOnTop = !SN->bOnTop; + SetWindowPos(SN->SNHwnd, SN->bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); + RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); + JustSaveNotesEx(); } } - return TRUE; + } + return TRUE; - case IDC_CLOSE: - DestroyWindow(Dialog); - ListNotesVisible = FALSE; - return TRUE; + case IDC_CLOSE: + DestroyWindow(Dialog); + ListNotesVisible = FALSE; + return TRUE; - case ID_CONTEXTMENUNOTEPOPUP_NEWNOTE: - case IDC_ADDNEWREMINDER: - PluginMenuCommandAddNew(0,0); - return TRUE; + case ID_CONTEXTMENUNOTEPOPUP_NEWNOTE: + case IDC_ADDNEWREMINDER: + PluginMenuCommandAddNew(0, 0); + return TRUE; - case ID_CONTEXTMENUNOTELISTVIEW_DELETEALLNOTES: - PluginMenuCommandDeleteAll(0,0); - return TRUE; + case ID_CONTEXTMENUNOTELISTVIEW_DELETEALLNOTES: + PluginMenuCommandDeleteAll(0, 0); + return TRUE; - case IDM_REMOVENOTE: - { - HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS); - if ( ListView_GetSelectedCount(H) ) - { - int I = ListView_GetSelectionMark(H); - if (I != -1) - { - OnDeleteNote(Dialog, (STICKYNOTE*)TreeGetAt(g_Stickies, I)); - } + case IDM_REMOVENOTE: + { + HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS); + if (ListView_GetSelectedCount(H)) { + int I = ListView_GetSelectionMark(H); + if (I != -1) { + OnDeleteNote(Dialog, (STICKYNOTE*)TreeGetAt(g_Stickies, I)); } } - return TRUE; - case ID_CONTEXTMENUNOTELISTVIEW_SHOW: - ShowHideNotes(); - return TRUE; + } + return TRUE; - case ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP: - BringAllNotesToFront(NULL); - return TRUE; + case ID_CONTEXTMENUNOTELISTVIEW_SHOW: + ShowHideNotes(); + return TRUE; - } + case ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP: + BringAllNotesToFront(NULL); + return TRUE; } } return FALSE; @@ -2085,13 +1946,9 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam, void ListNotes(void) { - if (!ListNotesVisible) - { + if (!ListNotesVisible) { CreateDialog(hinstance, MAKEINTRESOURCE(IDD_LISTREMINDERS), 0, DlgProcViewNotes); ListNotesVisible = TRUE; } - else - { - BringWindowToTop(LV); - } + else BringWindowToTop(LV); } diff --git a/plugins/NotesAndReminders/src/options.cpp b/plugins/NotesAndReminders/src/options.cpp index 560cf9e2bf..f59c2e3d1d 100644 --- a/plugins/NotesAndReminders/src/options.cpp +++ b/plugins/NotesAndReminders/src/options.cpp @@ -29,7 +29,6 @@ int g_notesListColGeom[4] = { 150, 20, 20, 165 }; #define NRCDEFAULT_BODYCLR RGB(255,255,0)
-
struct DateFormat
{
LPCSTR lpszUI;
@@ -81,11 +80,11 @@ struct FontOptionsList }
static fontOptionsList[] =
{
- { LPGEN("Sticky Note Caption"), RGB(0,0,0), "Small Fonts", 0, 7, LPGEN("Sticky Note Background Color")},
-// { LPGEN("Sticky Note Caption"), RGB(0,0,0), L"Terminal", 0, 6, LPGEN("Sticky Note Background Color")},
-// { LPGEN("Sticky Note Caption"), RGB(0,0,0), L"MS Serif", 0, 7, LPGEN("Sticky Note Background Color")},
-// { LPGEN("Sticky Note Body"), RGB(0,0,0), L"Tahoma", 0, 8, LPGEN("Sticky Note Background Color")},
- { LPGEN("Sticky Note Body"), RGB(0,0,0), "System", DBFONTF_BOLD, 10, LPGEN("Sticky Note Background Color")},
+ { LPGEN("Sticky Note Caption"), RGB(0, 0, 0), "Small Fonts", 0, 7, LPGEN("Sticky Note Background Color") },
+ // { LPGEN("Sticky Note Caption"), RGB(0,0,0), L"Terminal", 0, 6, LPGEN("Sticky Note Background Color")},
+ // { LPGEN("Sticky Note Caption"), RGB(0,0,0), L"MS Serif", 0, 7, LPGEN("Sticky Note Background Color")},
+ // { LPGEN("Sticky Note Body"), RGB(0,0,0), L"Tahoma", 0, 8, LPGEN("Sticky Note Background Color")},
+ { LPGEN("Sticky Note Body"), RGB(0, 0, 0), "System", DBFONTF_BOLD, 10, LPGEN("Sticky Note Background Color") },
};
@@ -97,60 +96,60 @@ struct ColourOptionsList }
static colourOptionsList[] =
{
- { LPGEN("Sticky Note Background Color"), "BodyColor", NRCDEFAULT_BODYCLR}
+ { LPGEN("Sticky Note Background Color"), "BodyColor", NRCDEFAULT_BODYCLR }
};
LPCSTR GetDateFormatStr()
{
- return dateFormats[g_NoteTitleDate ? g_NoteTitleDate-1 : 0].lpszFmt;
+ return dateFormats[g_NoteTitleDate ? g_NoteTitleDate - 1 : 0].lpszFmt;
}
LPCSTR GetTimeFormatStr()
{
- return timeFormats[g_NoteTitleTime ? g_NoteTitleTime-1 : 0].lpszFmt;
+ return timeFormats[g_NoteTitleTime ? g_NoteTitleTime - 1 : 0].lpszFmt;
}
#if defined( _UNICODE )
static BYTE MsgDlgGetFontDefaultCharset(const wchar_t* szFont)
{
- return DEFAULT_CHARSET;
+ return DEFAULT_CHARSET;
}
#else
// get font charset according to current CP
static BYTE MsgDlgGetCPDefaultCharset()
{
switch (GetACP()) {
- case 1250:
- return EASTEUROPE_CHARSET;
- case 1251:
- return RUSSIAN_CHARSET;
- case 1252:
- return ANSI_CHARSET;
- case 1253:
- return GREEK_CHARSET;
- case 1254:
- return TURKISH_CHARSET;
- case 1255:
- return HEBREW_CHARSET;
- case 1256:
- return ARABIC_CHARSET;
- case 1257:
- return BALTIC_CHARSET;
- case 1361:
- return JOHAB_CHARSET;
- case 874:
- return THAI_CHARSET;
- case 932:
- return SHIFTJIS_CHARSET;
- case 936:
- return GB2312_CHARSET;
- case 949:
- return HANGEUL_CHARSET;
- case 950:
- return CHINESEBIG5_CHARSET;
- default:
- return DEFAULT_CHARSET;
+ case 1250:
+ return EASTEUROPE_CHARSET;
+ case 1251:
+ return RUSSIAN_CHARSET;
+ case 1252:
+ return ANSI_CHARSET;
+ case 1253:
+ return GREEK_CHARSET;
+ case 1254:
+ return TURKISH_CHARSET;
+ case 1255:
+ return HEBREW_CHARSET;
+ case 1256:
+ return ARABIC_CHARSET;
+ case 1257:
+ return BALTIC_CHARSET;
+ case 1361:
+ return JOHAB_CHARSET;
+ case 874:
+ return THAI_CHARSET;
+ case 932:
+ return SHIFTJIS_CHARSET;
+ case 936:
+ return GB2312_CHARSET;
+ case 949:
+ return HANGEUL_CHARSET;
+ case 950:
+ return CHINESEBIG5_CHARSET;
+ default:
+ return DEFAULT_CHARSET;
}
}
@@ -163,7 +162,7 @@ static int CALLBACK EnumFontFamExProc(const LOGFONT *, const TEXTMETRIC *, DWORD // get font charset according to current CP, if available for specified font
static BYTE MsgDlgGetFontDefaultCharset(const char *szFont)
{
- LOGFONT lf = {0};
+ LOGFONT lf = { 0 };
int found = 0;
mir_strcpy(lf.lfFaceName, szFont);
@@ -191,9 +190,9 @@ static void InitFonts() LoadNRFont(NR_FONTID_BODY, &lfBody, (COLORREF*)&BodyFontColor);
if (hBodyFont)
- DeleteObject(hBodyFont);
+ DeleteObject(hBodyFont);
if (hCaptionFont)
- DeleteObject(hCaptionFont);
+ DeleteObject(hCaptionFont);
hBodyFont = CreateFontIndirect(&lfBody);
hCaptionFont = CreateFontIndirect(&lfCaption);
diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp index 5b43d7c7d9..0db6a9384e 100644 --- a/plugins/NotesAndReminders/src/reminders.cpp +++ b/plugins/NotesAndReminders/src/reminders.cpp @@ -49,8 +49,8 @@ static REMINDERDATA *pEditReminder = NULL; static HWND LV;
static SOCKET S;
-int WS_Send(SOCKET s,char *data,int datalen);
-unsigned long WS_ResolveName(char *name,WORD *port,int defaultPort);
+int WS_Send(SOCKET s, char *data, int datalen);
+unsigned long WS_ResolveName(char *name, WORD *port, int defaultPort);
void Send(char *user, char *host, char *Msg, char* server);
char* GetPreviewString(const char *lpsz);
@@ -94,29 +94,6 @@ void TzLocalSTToFileTime(const SYSTEMTIME *tmLocal, FILETIME *lpUtc) SYSTEMTIMEtoFILETIME(&tm, lpUtc);
}
-/*void AddToTzLocalFT(FILETIME *lpLocal, UINT nSeconds)
-{
- ULARGE_INTEGER utc;
- TzLocalToUtcFT(lpLocal, (FILETIME*)&utc);
- utc.QuadPart += (ULONGLONG)nSeconds * FILETIME_TICKS_PER_SEC;
- UtcToTzLocalFT((FILETIME*)&utc, lpLocal);
-}*/
-
-/*static void AddToSystemTime(SYSTEMTIME *tm, UINT nSeconds)
-{
- ULARGE_INTEGER li;
- FILETIME ft;
-
- SYSTEMTIMEtoFILETIME(tm, &ft);
-
- li.HighPart = ft.dwHighDateTime;
- li.LowPart = ft.dwLowDateTime;
- li.QuadPart += (ULONGLONG)nSeconds * FILETIME_TICKS_PER_SEC;
-
- FILETIMEtoSYSTEMTIME((FILETIME*)&li, tm);
-}*/
-
-
static DWORD CreateUid()
{
DWORD uid;
@@ -125,12 +102,10 @@ static DWORD CreateUid() if (!RemindersList)
return 1;
- for (uid = 1; ; uid++)
- {
+ for (uid = 1;; uid++) {
// check existing reminders if uid is in use
TTE = RemindersList;
- while (TTE)
- {
+ while (TTE) {
if (((REMINDERDATA*)TTE->ptrdata)->uid == uid)
// uid in use
goto try_next;
@@ -142,9 +117,6 @@ static DWORD CreateUid() try_next:;
}
-
- // should never get here (unless someone has 4294967295 reminders)
- return 0;
}
static REMINDERDATA* FindReminder(DWORD uid)
@@ -152,12 +124,10 @@ static REMINDERDATA* FindReminder(DWORD uid) if (!RemindersList)
return NULL;
- for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT *) TTE->next)
- {
+ for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT *)TTE->next) {
REMINDERDATA *pReminder = (REMINDERDATA*)TTE->ptrdata;
- if (pReminder->uid == uid)
- {
+ if (pReminder->uid == uid) {
return pReminder;
}
}
@@ -169,7 +139,7 @@ static REMINDERDATA* FindReminder(DWORD uid) static void RemoveReminderSystemEvent(REMINDERDATA *p)
{
if (p->SystemEventQueued) {
- for (int i = 0; ; i++) {
+ for (int i = 0;; i++) {
CLISTEVENT *pev = pcli->pfnGetEvent(-1, i);
if (!pev)
break;
@@ -190,9 +160,8 @@ void PurgeReminders(void) {
char ValueName[32];
- int ReminderCount = db_get_dw(0,MODULENAME,"RemindersData",0);
- for(int I = 0;I < ReminderCount;I++)
- {
+ int ReminderCount = db_get_dw(0, MODULENAME, "RemindersData", 0);
+ for (int I = 0; I < ReminderCount; I++) {
mir_snprintf(ValueName, "RemindersData%d", I);
db_unset(0, MODULENAME, ValueName);
}
@@ -201,7 +170,7 @@ void PurgeReminders(void) void JustSaveReminders(void)
{
int I = 0, n, l;
- char *tmpReminder = NULL,*Value;
+ char *tmpReminder = NULL, *Value;
char ValueName[32];
int ReminderCount;
@@ -209,11 +178,10 @@ void JustSaveReminders(void) ReminderCount = TreeGetCount(RemindersList);
- db_set_dw(0,MODULENAME, "RemindersData", ReminderCount);
+ db_set_dw(0, MODULENAME, "RemindersData", ReminderCount);
- for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT *) TTE->next, I++)
- {
- REMINDERDATA *pReminder = (REMINDERDATA *) TTE->ptrdata;
+ for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT *)TTE->next, I++) {
+ REMINDERDATA *pReminder = (REMINDERDATA *)TTE->ptrdata;
if (pReminder->Reminder && mir_strlen(pReminder->Reminder))
tmpReminder = pReminder->Reminder;
else
@@ -231,33 +199,29 @@ void JustSaveReminders(void) // data header (save 'When' with 1-second resolution, it's just a waste to have 100-nanosecond resolution
// which results in larger DB strings with no use)
- l = sprintf(Value, "X%u:%I64x", pReminder->uid, pReminder->When.QuadPart/FILETIME_TICKS_PER_SEC); //!!!!!!!!!
+ l = sprintf(Value, "X%u:%I64x", pReminder->uid, pReminder->When.QuadPart / FILETIME_TICKS_PER_SEC); //!!!!!!!!!
if (l > 0) n += l;
// sound repeat
- if (pReminder->RepeatSound)
- {
- l = sprintf(Value+n, "\033""%u:%u", DATATAG_SNDREPEAT, pReminder->RepeatSound); //!!!!!!!!!!
+ if (pReminder->RepeatSound) {
+ l = sprintf(Value + n, "\033""%u:%u", DATATAG_SNDREPEAT, pReminder->RepeatSound); //!!!!!!!!!!
if (l > 0) n += l;
}
// sound
- if (pReminder->SoundSel)
- {
- l = sprintf(Value+n, "\033""%u:%d", DATATAG_SNDSEL, pReminder->SoundSel); //!!!!!!!!!
+ if (pReminder->SoundSel) {
+ l = sprintf(Value + n, "\033""%u:%d", DATATAG_SNDSEL, pReminder->SoundSel); //!!!!!!!!!
if (l > 0) n += l;
}
// reminder text/note (ALWAYS PUT THIS PARAM LAST)
- if (tmpReminder && *tmpReminder)
- {
- l = sprintf(Value+n, "\033""%u:%s", DATATAG_TEXT, tmpReminder); //!!!!!!!!!!!
+ if (tmpReminder && *tmpReminder) {
+ l = sprintf(Value + n, "\033""%u:%s", DATATAG_TEXT, tmpReminder); //!!!!!!!!!!!
if (l > 0) n += l;
}
// clamp data size to WORD (including null terminator)
- if (n >= 0xffff)
- {
+ if (n >= 0xffff) {
// huston, we have a problem, strip some reminder text
n = 0xfffe;
Value[0xffff] = 0;
@@ -265,14 +229,13 @@ void JustSaveReminders(void) mir_snprintf(ValueName, "RemindersData%d", ReminderCount - I - 1); // do not want to reverse in DB
- db_set_blob(0, MODULENAME, ValueName, Value, n+1);
+ db_set_blob(0, MODULENAME, ValueName, Value, n + 1);
SAFE_FREE((void**)&Value);
}
// delete any left over DB reminder entries
- for(; I < OldReminderCount; I++)
- {
+ for (; I < OldReminderCount; I++) {
mir_snprintf(ValueName, "RemindersData%d", I);
db_unset(0, MODULENAME, ValueName);
}
@@ -288,8 +251,7 @@ void LoadReminders(void) RemindersList = NULL;
int RemindersCount = db_get_dw(0, MODULENAME, "RemindersData", 0);
- for (int I = 0; I < RemindersCount; I++)
- {
+ for (int I = 0; I < RemindersCount; I++) {
Size = 65535;
Value = NULL;
mir_snprintf(ValueName, "RemindersData%d", I);
@@ -298,16 +260,15 @@ void LoadReminders(void) if (Size && Value) // was the blob found
{
- REMINDERDATA rem = {0};
+ REMINDERDATA rem = { 0 };
char *TVal;
REMINDERDATA *TempRem;
char *DelPos = strchr(Value, 0x1B);
// ensure that read data is null-terminated
- Value[(UINT)Size-1] = 0;
+ Value[(UINT)Size - 1] = 0;
- if (Value[0] == 'X')
- {
+ if (Value[0] == 'X') {
// new eXtended/fleXible data format
if (DelPos)
@@ -315,17 +276,16 @@ void LoadReminders(void) // uid:when
- TVal = strchr(Value+1, ':');
+ TVal = strchr(Value + 1, ':');
if (!TVal || (DelPos && TVal > DelPos))
continue;
*TVal++ = 0;
- rem.uid = strtoul(Value+1, NULL, 10);
+ rem.uid = strtoul(Value + 1, NULL, 10);
rem.When.QuadPart = _strtoui64(TVal, NULL, 16) * FILETIME_TICKS_PER_SEC;
// optional \033 separated params
- while (DelPos)
- {
+ while (DelPos) {
char *sep;
UINT tag;
@@ -344,8 +304,7 @@ void LoadReminders(void) tag = strtoul(TVal, NULL, 10);
TVal = sep + 1;
- switch (tag)
- {
+ switch (tag) {
case DATATAG_TEXT:
rem.Reminder = _strdup(TVal);
break;
@@ -366,8 +325,7 @@ void LoadReminders(void) if (!rem.Reminder)
rem.Reminder = _strdup("");
}
- else
- {
+ else {
// old format (for DB backward compatibility)
if (!DelPos)
@@ -376,22 +334,22 @@ void LoadReminders(void) DelPos[0] = 0;
// convert time_t to (local) FILETIME
{
- SYSTEMTIME tm;
- struct tm *stm;
- time_t tt;
-
- tt = (time_t)strtoul(Value, NULL, 10);
- stm = localtime(&tt);
- tm.wDayOfWeek = 0;
- tm.wSecond = 0;
- tm.wMilliseconds = 0;
- tm.wHour = stm->tm_hour;
- tm.wMinute = stm->tm_min;
- tm.wSecond = stm->tm_sec;
- tm.wYear = stm->tm_year + 1900;
- tm.wMonth = stm->tm_mon + 1;
- tm.wDay = stm->tm_mday;
- SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&rem.When);
+ SYSTEMTIME tm;
+ struct tm *stm;
+ time_t tt;
+
+ tt = (time_t)strtoul(Value, NULL, 10);
+ stm = localtime(&tt);
+ tm.wDayOfWeek = 0;
+ tm.wSecond = 0;
+ tm.wMilliseconds = 0;
+ tm.wHour = stm->tm_hour;
+ tm.wMinute = stm->tm_min;
+ tm.wSecond = stm->tm_sec;
+ tm.wYear = stm->tm_year + 1900;
+ tm.wMonth = stm->tm_mon + 1;
+ tm.wDay = stm->tm_mday;
+ SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&rem.When);
}
TVal = DelPos + 1;
rem.Reminder = _strdup(TVal);
@@ -402,13 +360,11 @@ void LoadReminders(void) GenerateUids = TRUE;
TempRem = (REMINDERDATA*)malloc(sizeof(REMINDERDATA));
- if (TempRem)
- {
+ if (TempRem) {
*TempRem = rem;
TreeAddSorted(&RemindersList, TempRem, ReminderSortCb);
}
- else if (rem.Reminder)
- {
+ else if (rem.Reminder) {
free(rem.Reminder);
}
skip:;
@@ -418,10 +374,8 @@ skip:; }
// generate UIDs if there are any items with an invalid UID
- if (GenerateUids && RemindersList)
- {
- for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT*)TTE->next)
- {
+ if (GenerateUids && RemindersList) {
+ for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT*)TTE->next) {
REMINDERDATA *pReminder = (REMINDERDATA*)TTE->ptrdata;
if (!pReminder->uid)
@@ -437,8 +391,7 @@ static void DeleteReminder(REMINDERDATA *p) if (!p)
return;
- if (p->SystemEventQueued)
- {
+ if (p->SystemEventQueued) {
// remove pending system event
RemoveReminderSystemEvent(p);
}
@@ -450,8 +403,7 @@ static void DeleteReminder(REMINDERDATA *p) void CloseReminderList()
{
- if (ListReminderVisible)
- {
+ if (ListReminderVisible) {
DestroyWindow(LV);
ListReminderVisible = FALSE;
}
@@ -477,7 +429,7 @@ void SaveReminders(void) void DeleteReminders(void)
{
PurgeReminders();
- db_set_dw(0,MODULENAME,"RemindersData",0);
+ db_set_dw(0, MODULENAME, "RemindersData", 0);
PurgeReminderTree();
}
@@ -494,30 +446,29 @@ void GetTriggerTimeString(const ULARGE_INTEGER *When, char *s, UINT strSize, BOO else
FILETIMEtoSYSTEMTIME((FILETIME*)When, &tm);
- if ( GetDateFormat(lc, DATE_LONGDATE, &tm, NULL, s, strSize)) {
+ if (GetDateFormat(lc, DATE_LONGDATE, &tm, NULL, s, strSize)) {
// append time
int n = (int)mir_strlen(s);
s[n++] = ' ';
s[n] = 0;
- if ( !GetTimeFormat(lc, LOCALE_NOUSEROVERRIDE|TIME_NOSECONDS, &tm, NULL, s+n, strSize-n) )
- mir_snprintf(s+n, strSize-n, "%02d:%02d", tm.wHour, tm.wMinute);
+ if (!GetTimeFormat(lc, LOCALE_NOUSEROVERRIDE | TIME_NOSECONDS, &tm, NULL, s + n, strSize - n))
+ mir_snprintf(s + n, strSize - n, "%02d:%02d", tm.wHour, tm.wMinute);
}
else mir_snprintf(s, strSize, "%d-%02d-%02d %02d:%02d", tm.wYear, tm.wMonth, tm.wDay, tm.wHour, tm.wMinute);
}
static void SkinPlaySoundPoly(LPCSTR pszSoundName)
{
- if (g_UseDefaultPlaySound)
- {
+ if (g_UseDefaultPlaySound) {
SkinPlaySound(pszSoundName);
return;
}
- if (db_get_b(NULL, "SkinSoundsOff", pszSoundName, 0)==0) {
+ if (db_get_b(NULL, "SkinSoundsOff", pszSoundName, 0) == 0) {
DBVARIANT dbv;
- if (db_get_s(NULL, "SkinSounds", pszSoundName, &dbv)==0) {
+ if (db_get_s(NULL, "SkinSounds", pszSoundName, &dbv) == 0) {
char szFull[MAX_PATH];
PathToAbsolute(dbv.pszVal, szFull);
@@ -542,18 +493,14 @@ static void UpdateReminderEvent(REMINDERDATA *pReminder, UINT nElapsedSeconds, B {
DWORD dwSoundMask;
- if (pReminder->RepeatSound)
- {
- if (nElapsedSeconds >= pReminder->RepeatSoundTTL)
- {
+ if (pReminder->RepeatSound) {
+ if (nElapsedSeconds >= pReminder->RepeatSoundTTL) {
pReminder->RepeatSoundTTL = pReminder->RepeatSound;
dwSoundMask = 1 << pReminder->SoundSel;
- if ( !(*pHasPlayedSound & dwSoundMask) )
- {
- switch (pReminder->SoundSel)
- {
+ if (!(*pHasPlayedSound & dwSoundMask)) {
+ switch (pReminder->SoundSel) {
case 1: SkinPlaySoundPoly("AlertReminder2"); break;
case 2: SkinPlaySoundPoly("AlertReminder3"); break;
default:
@@ -563,8 +510,7 @@ static void UpdateReminderEvent(REMINDERDATA *pReminder, UINT nElapsedSeconds, B *pHasPlayedSound |= dwSoundMask;
}
}
- else
- {
+ else {
pReminder->RepeatSoundTTL -= nElapsedSeconds;
}
}
@@ -589,8 +535,7 @@ static void FireReminder(REMINDERDATA *pReminder, BOOL *pHasPlayedSound) pReminder->SystemEventQueued = TRUE;
QueuedReminderCount++;
- if (pReminder->SoundSel < 0)
- {
+ if (pReminder->SoundSel < 0) {
// sound disabled
return;
}
@@ -599,10 +544,8 @@ static void FireReminder(REMINDERDATA *pReminder, BOOL *pHasPlayedSound) pReminder->RepeatSoundTTL = pReminder->RepeatSound;
- if ( !(*pHasPlayedSound & dwSoundMask) )
- {
- switch (pReminder->SoundSel)
- {
+ if (!(*pHasPlayedSound & dwSoundMask)) {
+ switch (pReminder->SoundSel) {
case 1: SkinPlaySoundPoly("AlertReminder2"); break;
case 2: SkinPlaySoundPoly("AlertReminder3"); break;
default:
@@ -626,17 +569,16 @@ BOOL CheckRemindersAndStart(void) return FALSE;
{
- SYSTEMTIME tm;
- GetSystemTime(&tm);
- SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&curT);
+ SYSTEMTIME tm;
+ GetSystemTime(&tm);
+ SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&curT);
}
// NOTE: reminder list is sorted by trigger time, so we can early out on the first reminder > cur time
// quick check for normal case with no reminder ready to be triggered and no queued triggered reminders
// (happens 99.99999999999% of the time)
- if (curT.QuadPart < ((REMINDERDATA*)RemindersList->ptrdata)->When.QuadPart && !QueuedReminderCount)
- {
+ if (curT.QuadPart < ((REMINDERDATA*)RemindersList->ptrdata)->When.QuadPart && !QueuedReminderCount) {
return FALSE;
}
@@ -652,36 +594,30 @@ BOOL CheckRemindersAndStart(void) // allthough count should always be correct, it's fool proof to just count them again in the loop below
QueuedReminderCount = 0;
-
- for(TREEELEMENT *TTE = RemindersList;TTE && (bHasQueuedReminders || ((REMINDERDATA*)TTE->ptrdata)->When.QuadPart <= curT.QuadPart); TTE = (TREEELEMENT *)TTE->next)
- {
+
+ for (TREEELEMENT *TTE = RemindersList; TTE && (bHasQueuedReminders || ((REMINDERDATA*)TTE->ptrdata)->When.QuadPart <= curT.QuadPart); TTE = (TREEELEMENT *)TTE->next) {
REMINDERDATA *pReminder = (REMINDERDATA*)TTE->ptrdata;
- if (!pReminder->RemVisible)
- {
- if (pReminder->SystemEventQueued)
- {
- UpdateReminderEvent(pReminder, REMINDER_UPDATE_INTERVAL_SHORT/1000, &bHasPlayedSound);
+ if (!pReminder->RemVisible) {
+ if (pReminder->SystemEventQueued) {
+ UpdateReminderEvent(pReminder, REMINDER_UPDATE_INTERVAL_SHORT / 1000, &bHasPlayedSound);
QueuedReminderCount++;
bResult = TRUE;
}
- else if (((REMINDERDATA*)TTE->ptrdata)->When.QuadPart <= curT.QuadPart)
- {
- if (!g_RemindSMS)
- {
+ else if (((REMINDERDATA*)TTE->ptrdata)->When.QuadPart <= curT.QuadPart) {
+ if (!g_RemindSMS) {
FireReminder(pReminder, &bHasPlayedSound);
if (pReminder->SystemEventQueued)
bResult = TRUE;
}
- else
- {
+ else {
char* S2 = strchr(g_RemindSMS, '@');
char* S1 = (char*)malloc(S2 - g_RemindSMS);
strncpy(S1, g_RemindSMS, S2 - g_RemindSMS);
- S1[S2 - g_RemindSMS]= 0x0;
+ S1[S2 - g_RemindSMS] = 0x0;
S2++;
Send(S1, S2, pReminder->Reminder ? pReminder->Reminder : "", NULL);
SAFE_FREE((void**)&S1);
@@ -699,15 +635,14 @@ BOOL CheckRemindersAndStart(void) static LRESULT CALLBACK DatePickerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch (message)
- {
+ switch (message) {
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_CHAR:
- case WM_INITMENUPOPUP:
+ case WM_INITMENUPOPUP:
case WM_PASTE:
return TRUE;
case WM_SYSKEYUP:
@@ -725,11 +660,10 @@ static void InitDatePicker(HWND Dialog, UINT nIDDate) HWND hCtrl = GetDlgItem(Dialog, nIDDate);
// tweak style of picker
- if ( IsWinVerVistaPlus() )
- {
- DWORD dw = SendDlgItemMessage(Dialog,nIDDate,DTM_GETMCSTYLE,0,0);
+ if (IsWinVerVistaPlus()) {
+ DWORD dw = SendDlgItemMessage(Dialog, nIDDate, DTM_GETMCSTYLE, 0, 0);
dw |= MCS_WEEKNUMBERS | MCS_NOSELCHANGEONNAV;
- SendDlgItemMessage(Dialog,nIDDate,DTM_SETMCSTYLE,0,dw);
+ SendDlgItemMessage(Dialog, nIDDate, DTM_SETMCSTYLE, 0, dw);
}
mir_subclassWindow(hCtrl, DatePickerWndProc);
@@ -749,12 +683,10 @@ static BOOL ParseTime(LPCSTR s, int *hout, int *mout, BOOL bTimeOffset, BOOL bAl // read hour
- while ( iswspace(*s) ) s++;
+ while (iswspace(*s)) s++;
- if (*s == '+')
- {
- if (!bTimeOffset)
- {
+ if (*s == '+') {
+ if (!bTimeOffset) {
if (!bAllowOffsetOverride)
return FALSE;
@@ -763,96 +695,83 @@ static BOOL ParseTime(LPCSTR s, int *hout, int *mout, BOOL bTimeOffset, BOOL bAl }
s++;
- while ( iswspace(*s) ) s++;
+ while (iswspace(*s)) s++;
}
- if ( !isdigit(*s) )
+ if (!isdigit(*s))
return FALSE;
- h = (int)(*s-'0');
+ h = (int)(*s - '0');
s++;
- if (!bOffset)
- {
- if ( isdigit(*s) )
- {
- h = h * 10 + (int)(*s-'0');
+ if (!bOffset) {
+ if (isdigit(*s)) {
+ h = h * 10 + (int)(*s - '0');
s++;
}
- if ( isdigit(*s) )
+ if (isdigit(*s))
return FALSE;
}
- else
- {
+ else {
// allow more than 2-digit numbers for offset
- while ( isdigit(*s) )
- {
- h = h * 10 + (int)(*s-'0');
+ while (isdigit(*s)) {
+ h = h * 10 + (int)(*s - '0');
s++;
}
}
// find : separator
- while ( iswspace(*s) ) s++;
+ while (iswspace(*s)) s++;
- if (*s == ':')
- {
+ if (*s == ':') {
s++;
// read minutes
- while ( iswspace(*s) ) s++;
+ while (iswspace(*s)) s++;
- if ( !isdigit(*s) )
+ if (!isdigit(*s))
return FALSE;
- m = (int)(*s-'0');
+ m = (int)(*s - '0');
s++;
- if ( isdigit(*s) )
- {
- m = m * 10 + (int)(*s-'0');
+ if (isdigit(*s)) {
+ m = m * 10 + (int)(*s - '0');
s++;
}
}
- else
- {
- if (bOffset)
- {
+ else {
+ if (bOffset) {
// no : separator found, interpret the entered number as minutes and allow > 60
if (h < 0)
return FALSE;
- if (bTimeOffset)
- {
+ if (bTimeOffset) {
*hout = h / 60;
*mout = h % 60;
}
- else
- {
+ else {
*mout = h;
*hout = -1;
}
return TRUE;
}
- else
- {
+ else {
m = 0;
}
}
// validate time
- if (bOffset)
- {
+ if (bOffset) {
if (h < 0)
return FALSE;
if (m < 0 || m > 59)
return FALSE;
}
- else
- {
+ else {
if (h == 24)
h = 0;
else if (h < 0 || h > 23)
@@ -861,22 +780,19 @@ static BOOL ParseTime(LPCSTR s, int *hout, int *mout, BOOL bTimeOffset, BOOL bAl return FALSE;
}
- if (!bOffset)
- {
+ if (!bOffset) {
// check for PM indicator (not strict, only checks for P char)
- while ( iswspace(*s) ) s++;
+ while (iswspace(*s)) s++;
- if (*s == 'p' || *s == 'P')
- {
+ if (*s == 'p' || *s == 'P') {
if (h < 13)
h += 12;
else if (h == 12)
h = 0;
}
}
- else if (!bTimeOffset)
- {
+ else if (!bTimeOffset) {
// entered time is an offset
*mout = h * 60 + m;
@@ -894,7 +810,7 @@ static BOOL ParseTime(LPCSTR s, int *hout, int *mout, BOOL bTimeOffset, BOOL bAl // returns TRUE if combo box list displays time offsets ("23:34 (5 Minutes)" etc.)
__inline static BOOL IsRelativeCombo(HWND Dialog, UINT nIDTime)
{
- return (((int)SendDlgItemMessage(Dialog,nIDTime,CB_GETITEMDATA,0,0)) >= 0);
+ return (((int)SendDlgItemMessage(Dialog, nIDTime, CB_GETITEMDATA, 0, 0)) >= 0);
}
static void PopulateTimeCombo(HWND Dialog, UINT nIDTime, BOOL bRelative, const SYSTEMTIME *tmUtc)
@@ -912,9 +828,8 @@ static void PopulateTimeCombo(HWND Dialog, UINT nIDTime, BOOL bRelative, const S LPCSTR lpszHours;
WORD wCurHour, wCurMinute;
- if (!bRelative)
- {
- SendDlgItemMessage(Dialog,nIDTime,CB_RESETCONTENT,0,0);
+ if (!bRelative) {
+ SendDlgItemMessage(Dialog, nIDTime, CB_RESETCONTENT, 0, 0);
// ensure that we start on midnight local time
SystemTimeToTzSpecificLocalTime(NULL, (SYSTEMTIME*)tmUtc, &tm2);
@@ -926,17 +841,16 @@ static void PopulateTimeCombo(HWND Dialog, UINT nIDTime, BOOL bRelative, const S SYSTEMTIMEtoFILETIME(&tm2, (FILETIME*)&li);
// from 00:00 to 23:30 in 30 minute steps
- for (i=0; i<50; i++)
- {
- const int h = i>>1;
- const int m = (i&1) ? 30 : 0;
+ for (i = 0; i < 50; i++) {
+ const int h = i >> 1;
+ const int m = (i & 1) ? 30 : 0;
FileTimeToTzLocalST((FILETIME*)&li, &tm2);
mir_snprintf(s, "%02d:%02d", (UINT)tm2.wHour, (UINT)tm2.wMinute);
- n = SendDlgItemMessage(Dialog,nIDTime,CB_ADDSTRING,0,(LPARAM)s);
+ n = SendDlgItemMessage(Dialog, nIDTime, CB_ADDSTRING, 0, (LPARAM)s);
// item data contains time offset from midnight in seconds (bit 31 is set to flag that
// combo box items are absolute times and not relative times like below
- SendDlgItemMessage(Dialog,nIDTime,CB_SETITEMDATA,n, (LPARAM)((ULONG)((h*60+m)*60) | 0x80000000));
+ SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((ULONG)((h * 60 + m) * 60) | 0x80000000));
li.QuadPart += (ULONGLONG)30 * MinutesToFileTime;
@@ -964,55 +878,53 @@ static void PopulateTimeCombo(HWND Dialog, UINT nIDTime, BOOL bRelative, const S wCurHour = tm2.wHour;
wCurMinute = tm2.wMinute;
mir_snprintf(s, "%02d:%02d", (UINT)tm2.wHour, (UINT)tm2.wMinute);
- n = SendDlgItemMessage(Dialog,nIDTime,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart-ref)/FILETIME_TICKS_PER_SEC));
+ n = SendDlgItemMessage(Dialog, nIDTime, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart - ref) / FILETIME_TICKS_PER_SEC));
// 5 minutes
li.QuadPart += (ULONGLONG)5 * MinutesToFileTime;
FileTimeToTzLocalST((FILETIME*)&li, &tm2);
mir_snprintf(s, "%02d:%02d (5 %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, lpszMinutes);
- n = SendDlgItemMessage(Dialog,nIDTime,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart-ref)/FILETIME_TICKS_PER_SEC));
+ n = SendDlgItemMessage(Dialog, nIDTime, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart - ref) / FILETIME_TICKS_PER_SEC));
// 10 minutes
li.QuadPart += (ULONGLONG)5 * MinutesToFileTime;
FileTimeToTzLocalST((FILETIME*)&li, &tm2);
mir_snprintf(s, "%02d:%02d (10 %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, lpszMinutes);
- n = SendDlgItemMessage(Dialog,nIDTime,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart-ref)/FILETIME_TICKS_PER_SEC));
+ n = SendDlgItemMessage(Dialog, nIDTime, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart - ref) / FILETIME_TICKS_PER_SEC));
// 15 minutes
li.QuadPart += (ULONGLONG)5 * MinutesToFileTime;
FileTimeToTzLocalST((FILETIME*)&li, &tm2);
mir_snprintf(s, "%02d:%02d (15 %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, lpszMinutes);
- n = SendDlgItemMessage(Dialog,nIDTime,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart-ref)/FILETIME_TICKS_PER_SEC));
+ n = SendDlgItemMessage(Dialog, nIDTime, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart - ref) / FILETIME_TICKS_PER_SEC));
// 30 minutes
li.QuadPart += (ULONGLONG)15 * MinutesToFileTime;
FileTimeToTzLocalST((FILETIME*)&li, &tm2);
mir_snprintf(s, "%02d:%02d (30 %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, lpszMinutes);
- n = SendDlgItemMessage(Dialog,nIDTime,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart-ref)/FILETIME_TICKS_PER_SEC));
+ n = SendDlgItemMessage(Dialog, nIDTime, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, (LPARAM)((li.QuadPart - ref) / FILETIME_TICKS_PER_SEC));
// round +1h time to nearest even or half hour
li.QuadPart += (ULONGLONG)30 * MinutesToFileTime;
li.QuadPart = (li.QuadPart / (30 * MinutesToFileTime)) * (30 * MinutesToFileTime);
// add from +1 to +23.5 (in half hour steps) if crossing daylight saving boundary it may be 22.5 or 24.5 hours
- for (i=0; i<50; i++)
- {
+ for (i = 0; i < 50; i++) {
UINT dt;
FileTimeToTzLocalST((FILETIME*)&li, &tm2);
- if (i > 40)
- {
+ if (i > 40) {
UINT nLastEntry = ((UINT)wCurHour * 60 + (UINT)wCurMinute) / 30;
if (nLastEntry)
nLastEntry *= 30;
else
- nLastEntry = 23*60 + 30;
+ nLastEntry = 23 * 60 + 30;
if (((UINT)tm2.wHour * 60 + (UINT)tm2.wMinute) == nLastEntry)
break;
@@ -1021,13 +933,13 @@ static void PopulateTimeCombo(HWND Dialog, UINT nIDTime, BOOL bRelative, const S // icq-style display 1.0, 1.5 etc. hours even though that isn't accurate due to rounding
//mir_snprintf(s, "%02d:%02d (%d.%d %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, 1+(i>>1), (i&1) ? 5 : 0, lpszHours);
// display delta time more accurately to match reformatting (that icq doesn't do)
- dt = (UINT)((li.QuadPart/MinutesToFileTime) - (ref/MinutesToFileTime));
+ dt = (UINT)((li.QuadPart / MinutesToFileTime) - (ref / MinutesToFileTime));
if (dt < 60)
mir_snprintf(s, "%02d:%02d (%d %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, dt, lpszMinutes);
else
- mir_snprintf(s, "%02d:%02d (%d.%d %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, dt/60, ((dt%60)*10)/60, lpszHours);
- n = SendDlgItemMessage(Dialog,nIDTime,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog,nIDTime,CB_SETITEMDATA,n, dt*60);
+ mir_snprintf(s, "%02d:%02d (%d.%d %s)", (UINT)tm2.wHour, (UINT)tm2.wMinute, dt / 60, ((dt % 60) * 10) / 60, lpszHours);
+ n = SendDlgItemMessage(Dialog, nIDTime, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDTime, CB_SETITEMDATA, n, dt * 60);
li.QuadPart += (ULONGLONG)30 * MinutesToFileTime;
}
@@ -1038,7 +950,7 @@ static void PopulateTimeOffsetCombo(HWND Dialog, UINT nIDCombo) int n;
char s[MAX_PATH];
- SendDlgItemMessage(Dialog,nIDCombo,CB_RESETCONTENT,0,0);
+ SendDlgItemMessage(Dialog, nIDCombo, CB_RESETCONTENT, 0, 0);
LPCSTR lpszMinutes = Translate("Minutes");
LPCSTR lpszHour = Translate("Hour");
@@ -1048,43 +960,40 @@ static void PopulateTimeOffsetCombo(HWND Dialog, UINT nIDCombo) LPCSTR lpszWeek = Translate("Week");
// 5 - 55 minutes (in 5 minute steps)
- for (int i = 1; i < 12; i++)
- {
- mir_snprintf(s, "%d %s", i*5, lpszMinutes);
- n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog,nIDCombo,CB_SETITEMDATA,n, i*5);
+ for (int i = 1; i < 12; i++) {
+ mir_snprintf(s, "%d %s", i * 5, lpszMinutes);
+ n = SendDlgItemMessage(Dialog, nIDCombo, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDCombo, CB_SETITEMDATA, n, i * 5);
}
// 1 hour
mir_snprintf(s, "1 %s", lpszHour);
- n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog,nIDCombo,CB_SETITEMDATA, n, 60);
+ n = SendDlgItemMessage(Dialog, nIDCombo, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDCombo, CB_SETITEMDATA, n, 60);
// 2, 4, 8 hours
- for (int i = 2; i <= 8; i+=2)
- {
+ for (int i = 2; i <= 8; i += 2) {
mir_snprintf(s, "%d %s", i, lpszHours);
- n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog,nIDCombo,CB_SETITEMDATA, n, i*60);
+ n = SendDlgItemMessage(Dialog, nIDCombo, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDCombo, CB_SETITEMDATA, n, i * 60);
}
// 1 day
mir_snprintf(s, "1 %s", lpszDay);
- n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog,nIDCombo,CB_SETITEMDATA, n, 24*60);
+ n = SendDlgItemMessage(Dialog, nIDCombo, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDCombo, CB_SETITEMDATA, n, 24 * 60);
// 2-4 days
- for (int i = 2; i <= 4; i++)
- {
+ for (int i = 2; i <= 4; i++) {
mir_snprintf(s, "%d %s", i, lpszDays);
- n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog,nIDCombo,CB_SETITEMDATA, n, i*24*60);
+ n = SendDlgItemMessage(Dialog, nIDCombo, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDCombo, CB_SETITEMDATA, n, i * 24 * 60);
}
// 1 week
mir_snprintf(s, "1 %s", lpszWeek);
- n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
- SendDlgItemMessage(Dialog,nIDCombo,CB_SETITEMDATA, n, 7*24*60);
+ n = SendDlgItemMessage(Dialog, nIDCombo, CB_ADDSTRING, 0, (LPARAM)s);
+ SendDlgItemMessage(Dialog, nIDCombo, CB_SETITEMDATA, n, 7 * 24 * 60);
}
// returns non-zero if specified time was inside "missing" hour of daylight saving
@@ -1096,12 +1005,10 @@ static int ReformatTimeInputEx(HWND Dialog, UINT nIDTime, UINT nIDRefTime, int h char buf[64];
const ULONGLONG MinutesToFileTime = (ULONGLONG)60 * FILETIME_TICKS_PER_SEC;
- if (h < 0)
- {
+ if (h < 0) {
// time value is an offset ('m' holds the offset in minutes)
- if ( IsRelativeCombo(Dialog, nIDTime) )
- {
+ if (IsRelativeCombo(Dialog, nIDTime)) {
ULONGLONG ref;
ULARGE_INTEGER li;
SYSTEMTIME tm;
@@ -1113,8 +1020,8 @@ static int ReformatTimeInputEx(HWND Dialog, UINT nIDTime, UINT nIDRefTime, int h }
// clamp delta time to 23.5 hours (coule be issues otherwise as relative combo only handles <24)
- if (m > (23*60+30))
- m = 23*60+30;
+ if (m > (23 * 60 + 30))
+ m = 23 * 60 + 30;
li.QuadPart += (ULONGLONG)(m * 60) * FILETIME_TICKS_PER_SEC;
@@ -1125,25 +1032,23 @@ static int ReformatTimeInputEx(HWND Dialog, UINT nIDTime, UINT nIDRefTime, int h if (triggerRelUtcOut)
*triggerRelUtcOut = li;
- dt = (UINT)((li.QuadPart/MinutesToFileTime) - (ref/MinutesToFileTime));
+ dt = (UINT)((li.QuadPart / MinutesToFileTime) - (ref / MinutesToFileTime));
if (dt < 60)
mir_snprintf(buf, "%02d:%02d (%d %s)", h, m, dt, Translate("Minutes"));
else
- mir_snprintf(buf, "%02d:%02d (%d.%d %s)", h, m, dt/60, ((dt%60)*10)/60, Translate("Hours"));
+ mir_snprintf(buf, "%02d:%02d (%d.%d %s)", h, m, dt / 60, ((dt % 60) * 10) / 60, Translate("Hours"));
// search for preset
n = SendDlgItemMessage(Dialog, nIDTime, CB_FINDSTRING, (WPARAM)-1, (LPARAM)buf);
- if (n != CB_ERR)
- {
+ if (n != CB_ERR) {
SendDlgItemMessage(Dialog, nIDTime, CB_SETCURSEL, n, 0);
return 0;
}
SetDlgItemText(Dialog, nIDTime, buf);
}
- else
- {
+ else {
// should never happen
SendDlgItemMessage(Dialog, nIDTime, CB_SETCURSEL, 0, 0);
}
@@ -1157,14 +1062,12 @@ static int ReformatTimeInputEx(HWND Dialog, UINT nIDTime, UINT nIDRefTime, int h // search for preset first
n = SendDlgItemMessage(Dialog, nIDTime, CB_FINDSTRING, (WPARAM)-1, (LPARAM)buf);
- if (n != CB_ERR)
- {
+ if (n != CB_ERR) {
SendDlgItemMessage(Dialog, nIDTime, CB_SETCURSEL, n, 0);
return 0;
}
- if ( IsRelativeCombo(Dialog, nIDTime) )
- {
+ if (IsRelativeCombo(Dialog, nIDTime)) {
// date format is a time offset ("24:43 (5 Minutes)" etc.)
ULONGLONG ref;
@@ -1190,23 +1093,21 @@ static int ReformatTimeInputEx(HWND Dialog, UINT nIDTime, UINT nIDRefTime, int h tmTriggerLocal.wSecond = 0;
tmTriggerLocal.wMilliseconds = 0;
- if (nT < nRefT)
- {
+ if (nT < nRefT) {
// (this special case only works correctly if time can be returned in triggerRelUtcOut)
- if (tmRefLocal.wHour == tmTriggerLocal.wHour && triggerRelUtcOut)
- {
+ if (tmRefLocal.wHour == tmTriggerLocal.wHour && triggerRelUtcOut) {
// check for special case if daylight saving ends in this hour, then interpret as within the next hour
TzLocalSTToFileTime(&tmTriggerLocal, (FILETIME*)&li);
- li.QuadPart += (ULONGLONG)3600*FILETIME_TICKS_PER_SEC;
+ li.QuadPart += (ULONGLONG)3600 * FILETIME_TICKS_PER_SEC;
FileTimeToTzLocalST((FILETIME*)&li, &tmTriggerLocal2);
- if ((tmTriggerLocal2.wHour*60+tmTriggerLocal2.wMinute) == (tmTriggerLocal.wHour*60+tmTriggerLocal.wMinute))
+ if ((tmTriggerLocal2.wHour * 60 + tmTriggerLocal2.wMinute) == (tmTriggerLocal.wHour * 60 + tmTriggerLocal.wMinute))
// special case detected
goto output_result;
}
// tomorrow (add 24h to local time)
SYSTEMTIMEtoFILETIME(&tmTriggerLocal, (FILETIME*)&li);
- li.QuadPart += (ULONGLONG)(24*3600)*FILETIME_TICKS_PER_SEC;
+ li.QuadPart += (ULONGLONG)(24 * 3600)*FILETIME_TICKS_PER_SEC;
FILETIMEtoSYSTEMTIME((FILETIME*)&li, &tmTriggerLocal);
}
@@ -1222,13 +1123,12 @@ static int ReformatTimeInputEx(HWND Dialog, UINT nIDTime, UINT nIDRefTime, int h // check for special case when the current time and requested time is inside the "missing" hour
// standard->daylight switch, so that the cleaned up time ends up being earlier than the current
// time even though it originally wasn't (see note above)
- if ((tmTriggerLocal2.wHour*60+tmTriggerLocal2.wMinute) < (tmTriggerLocal.wHour*60+tmTriggerLocal.wMinute))
- {
+ if ((tmTriggerLocal2.wHour * 60 + tmTriggerLocal2.wMinute) < (tmTriggerLocal.wHour * 60 + tmTriggerLocal.wMinute)) {
// special case detected, fall back to current time so at least the reminder won't be missed
// due to ending up at an undesired time (this way the user immediately notices something was wrong)
SendDlgItemMessage(Dialog, nIDTime, CB_SETCURSEL, 0, 0);
invalid_dst:
- MessageBox(Dialog, Translate("The specified time is invalid due to begin of daylight saving (summer time)."), SECTIONNAME, MB_OK|MB_ICONWARNING);
+ MessageBox(Dialog, Translate("The specified time is invalid due to begin of daylight saving (summer time)."), SECTIONNAME, MB_OK | MB_ICONWARNING);
return 1;
}
@@ -1236,16 +1136,15 @@ output_result: if (triggerRelUtcOut)
*triggerRelUtcOut = li;
- dt = (UINT)((li.QuadPart/MinutesToFileTime) - (ref/MinutesToFileTime));
+ dt = (UINT)((li.QuadPart / MinutesToFileTime) - (ref / MinutesToFileTime));
if (dt < 60)
mir_snprintf(buf, "%02d:%02d (%d %s)", h, m, dt, Translate("Minutes"));
else
- mir_snprintf(buf, "%02d:%02d (%d.%d %s)", h, m, dt/60, ((dt%60)*10)/60, Translate("Hours"));
+ mir_snprintf(buf, "%02d:%02d (%d.%d %s)", h, m, dt / 60, ((dt % 60) * 10) / 60, Translate("Hours"));
}
}
- else
- {
+ else {
// absolute time (00:00 to 23:59), clean up time to make sure it's not inside "missing" hour (will be rounded downard)
FILETIME ft;
@@ -1258,14 +1157,12 @@ output_result: TzLocalSTToFileTime(&Date, &ft);
FileTimeToTzLocalST(&ft, &Date);
- if ((int)Date.wHour != h || (int)Date.wMinute != m)
- {
+ if ((int)Date.wHour != h || (int)Date.wMinute != m) {
mir_snprintf(buf, "%02d:%02d", (UINT)Date.wHour, (UINT)Date.wMinute);
// search for preset again
n = SendDlgItemMessage(Dialog, nIDTime, CB_FINDSTRING, (WPARAM)-1, (LPARAM)buf);
- if (n != CB_ERR)
- {
+ if (n != CB_ERR) {
SendDlgItemMessage(Dialog, nIDTime, CB_SETCURSEL, n, 0);
goto invalid_dst;
}
@@ -1301,12 +1198,10 @@ static BOOL GetTriggerTime(HWND Dialog, UINT nIDTime, UINT nIDRefTime, SYSTEMTIM }
int n = SendDlgItemMessage(Dialog, nIDTime, CB_GETCURSEL, 0, 0);
- if (n != CB_ERR)
- {
+ if (n != CB_ERR) {
// use preset value
preset_value:;
- if ( IsRelativeCombo(Dialog, nIDTime) )
- {
+ if (IsRelativeCombo(Dialog, nIDTime)) {
// time offset from ref time ("24:43 (5 Minutes)" etc.)
UINT nDeltaSeconds = (UINT)SendDlgItemMessage(Dialog, nIDTime, CB_GETITEMDATA, n, 0);
@@ -1316,14 +1211,12 @@ preset_value:; // if specified time is a small offset (< 10 Minutes) then retain current second count for better accuracy
// otherwise try to match specified time (which never contains seconds only even minutes) as close as possible
- if (nDeltaSeconds >= 10*60)
- {
+ if (nDeltaSeconds >= 10 * 60) {
pDate->wSecond = 0;
pDate->wMilliseconds = 0;
}
}
- else
- {
+ else {
// absolute time (offset from midnight on pDate)
UINT nDeltaSeconds = (UINT)((ULONG)SendDlgItemMessage(Dialog, nIDTime, CB_GETITEMDATA, n, 0) & ~0x80000000);
@@ -1344,19 +1237,17 @@ preset_value:; GetDlgItemText(Dialog, nIDTime, buf, 30);
- if ( !ParseTime(buf, &h, &m, FALSE, IsRelativeCombo(Dialog, nIDTime)) )
- {
- MessageBox(Dialog, Translate("The specified time is invalid."), SECTIONNAME, MB_OK|MB_ICONWARNING);
+ if (!ParseTime(buf, &h, &m, FALSE, IsRelativeCombo(Dialog, nIDTime))) {
+ MessageBox(Dialog, Translate("The specified time is invalid."), SECTIONNAME, MB_OK | MB_ICONWARNING);
return FALSE;
}
- if ( IsRelativeCombo(Dialog, nIDTime) )
- {
+ if (IsRelativeCombo(Dialog, nIDTime)) {
// date has not been changed, the specified time is a time between reftime and reftime+24h
ULARGE_INTEGER li2;
- if ( ReformatTimeInputEx(Dialog, nIDTime, nIDRefTime, h, m, pDate, &li2) )
+ if (ReformatTimeInputEx(Dialog, nIDTime, nIDRefTime, h, m, pDate, &li2))
return FALSE;
// check if reformatted value is a preset
@@ -1367,9 +1258,8 @@ preset_value:; return TRUE;
}
- else
- {
- if ( ReformatTimeInputEx(Dialog, nIDTime, nIDRefTime, h, m, pDate, NULL) )
+ else {
+ if (ReformatTimeInputEx(Dialog, nIDTime, nIDRefTime, h, m, pDate, NULL))
return FALSE;
// check if reformatted value is a preset
@@ -1407,8 +1297,7 @@ static void OnDateChanged(HWND Dialog, UINT nDateID, UINT nTimeID, UINT nRefTime TzSpecificLocalTimeToSystemTime(NULL, &Date, &DateUtc);
PopulateTimeCombo(Dialog, nTimeID, FALSE, &DateUtc);
- if (h < 0)
- {
+ if (h < 0) {
// parsing failed, default to current time
SYSTEMTIME tm;
GetLocalTime(&tm);
@@ -1420,10 +1309,9 @@ static void OnDateChanged(HWND Dialog, UINT nDateID, UINT nTimeID, UINT nRefTime }
-static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
{
- switch (Message)
- {
+ switch (Message) {
case WM_INITDIALOG:
{
SYSTEMTIME tm;
@@ -1447,14 +1335,14 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP PopulateTimeOffsetCombo(Dialog, IDC_REMINDAGAININ);
- ShowWindow(GetDlgItem(Dialog,IDC_REMINDAGAININ),SW_SHOW);
- ShowWindow(GetDlgItem(Dialog,IDC_DATEAGAIN),SW_HIDE);
- ShowWindow(GetDlgItem(Dialog,IDC_TIMEAGAIN),SW_HIDE);
- ShowWindow(GetDlgItem(Dialog,IDC_STATIC_DATE),SW_HIDE);
- ShowWindow(GetDlgItem(Dialog,IDC_STATIC_TIME),SW_HIDE);
+ ShowWindow(GetDlgItem(Dialog, IDC_REMINDAGAININ), SW_SHOW);
+ ShowWindow(GetDlgItem(Dialog, IDC_DATEAGAIN), SW_HIDE);
+ ShowWindow(GetDlgItem(Dialog, IDC_TIMEAGAIN), SW_HIDE);
+ ShowWindow(GetDlgItem(Dialog, IDC_STATIC_DATE), SW_HIDE);
+ ShowWindow(GetDlgItem(Dialog, IDC_STATIC_TIME), SW_HIDE);
CheckDlgButton(Dialog, IDC_AFTER, BST_CHECKED);
CheckDlgButton(Dialog, IDC_ONDATE, BST_UNCHECKED);
- SendDlgItemMessage(Dialog,IDC_REMINDAGAININ,CB_SETCURSEL,0,0);
+ SendDlgItemMessage(Dialog, IDC_REMINDAGAININ, CB_SETCURSEL, 0, 0);
SendDlgItemMessage(Dialog, IDC_REMDATA, EM_LIMITTEXT, MAX_REMINDER_LEN, 0);
@@ -1463,10 +1351,10 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP FileTimeToTzLocalST((FILETIME*)&li, &tm);
// make sure date picker uses reference time
- SendDlgItemMessage(Dialog,IDC_DATEAGAIN,DTM_SETSYSTEMTIME,0,(LPARAM)&tm);
+ SendDlgItemMessage(Dialog, IDC_DATEAGAIN, DTM_SETSYSTEMTIME, 0, (LPARAM)&tm);
InitDatePicker(Dialog, IDC_DATEAGAIN);
- SendDlgItemMessage(Dialog,IDC_TIMEAGAIN,CB_SETCURSEL,0,0);
+ SendDlgItemMessage(Dialog, IDC_TIMEAGAIN, CB_SETCURSEL, 0, 0);
return TRUE;
}
@@ -1475,12 +1363,10 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP return TRUE;
case WM_NOTIFY:
- if (wParam == IDC_DATEAGAIN)
- {
+ if (wParam == IDC_DATEAGAIN) {
LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
- switch (NM->hdr.code)
- {
+ switch (NM->hdr.code) {
case DTN_DATETIMECHANGE:
OnDateChanged(Dialog, IDC_DATEAGAIN, IDC_TIMEAGAIN, IDC_REFTIME);
break;
@@ -1491,12 +1377,10 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP case WM_CLOSE:
{
int ReminderCount = TreeGetCount(RemindersList);
- for (int I = 0; I < ReminderCount; I++)
- {
+ for (int I = 0; I < ReminderCount; I++) {
REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
- if (pReminder->handle == Dialog)
- {
+ if (pReminder->handle == Dialog) {
DeleteReminder(pReminder);
JustSaveReminders();
break;
@@ -1509,28 +1393,23 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP case WM_COMMAND:
{
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDC_TIMEAGAIN:
- switch (HIWORD(wParam))
- {
+ switch (HIWORD(wParam)) {
case CBN_KILLFOCUS:
// reformat displayed value
- if (SendDlgItemMessage(Dialog, IDC_TIMEAGAIN, CB_GETCURSEL, 0, 0) == CB_ERR)
- {
+ if (SendDlgItemMessage(Dialog, IDC_TIMEAGAIN, CB_GETCURSEL, 0, 0) == CB_ERR) {
char buf[64];
int h, m;
GetDlgItemText(Dialog, IDC_TIMEAGAIN, buf, 30);
- if ( ParseTime(buf, &h, &m, FALSE, IsRelativeCombo(Dialog, IDC_TIMEAGAIN)) )
- {
+ if (ParseTime(buf, &h, &m, FALSE, IsRelativeCombo(Dialog, IDC_TIMEAGAIN))) {
SYSTEMTIME Date;
- SendDlgItemMessage(Dialog,IDC_DATEAGAIN,DTM_GETSYSTEMTIME,0,(LPARAM)&Date);
+ SendDlgItemMessage(Dialog, IDC_DATEAGAIN, DTM_GETSYSTEMTIME, 0, (LPARAM)&Date);
ReformatTimeInput(Dialog, IDC_TIMEAGAIN, IDC_REFTIME, h, m, &Date);
}
- else
- {
+ else {
SendDlgItemMessage(Dialog, IDC_TIMEAGAIN, CB_SETCURSEL, 0, 0);
}
}
@@ -1539,33 +1418,27 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP break;
case IDC_REMINDAGAININ:
- switch (HIWORD(wParam))
- {
+ switch (HIWORD(wParam)) {
case CBN_KILLFOCUS:
// reformat displayed value if it has been edited
- if (SendDlgItemMessage(Dialog,IDC_REMINDAGAININ,CB_GETCURSEL,0,0) == CB_ERR)
- {
+ if (SendDlgItemMessage(Dialog, IDC_REMINDAGAININ, CB_GETCURSEL, 0, 0) == CB_ERR) {
char buf[64];
int h, m;
GetDlgItemText(Dialog, IDC_REMINDAGAININ, buf, 30);
- if (ParseTime(buf, &h, &m, TRUE, TRUE) && h+m)
- {
- if (h)
- {
+ if (ParseTime(buf, &h, &m, TRUE, TRUE) && h + m) {
+ if (h) {
LPCSTR lpszHours = Translate("Hours");
mir_snprintf(buf, "%d:%02d %s", h, m, lpszHours);
}
- else
- {
+ else {
LPCSTR lpszMinutes = Translate("Minutes");
mir_snprintf(buf, "%d %s", m, lpszMinutes);
}
SetDlgItemText(Dialog, IDC_REMINDAGAININ, buf);
}
- else
- {
- SendDlgItemMessage(Dialog,IDC_REMINDAGAININ,CB_SETCURSEL,0,0);
+ else {
+ SendDlgItemMessage(Dialog, IDC_REMINDAGAININ, CB_SETCURSEL, 0, 0);
}
}
break;
@@ -1591,12 +1464,10 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP case IDC_DISMISS:
{
int ReminderCount = TreeGetCount(RemindersList);
- for (int I = 0; I < ReminderCount; I++)
- {
+ for (int I = 0; I < ReminderCount; I++) {
REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
- if (pReminder->handle == Dialog)
- {
+ if (pReminder->handle == Dialog) {
DeleteReminder(pReminder);
JustSaveReminders();
break;
@@ -1610,14 +1481,11 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP case IDC_REMINDAGAIN:
{
int ReminderCount = TreeGetCount(RemindersList);
- for (int I = 0; I < ReminderCount; I++)
- {
+ for (int I = 0; I < ReminderCount; I++) {
REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
- if (pReminder->handle == Dialog)
- {
- if (IsDlgButtonChecked(Dialog, IDC_AFTER) == BST_CHECKED)
- {
+ if (pReminder->handle == Dialog) {
+ if (IsDlgButtonChecked(Dialog, IDC_AFTER) == BST_CHECKED) {
// delta time
ULONGLONG TT;
@@ -1628,12 +1496,10 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&li);
int n = SendDlgItemMessage(Dialog, IDC_REMINDAGAININ, CB_GETCURSEL, 0, 0);
- if (n != CB_ERR)
- {
+ if (n != CB_ERR) {
TT = SendDlgItemMessage(Dialog, IDC_REMINDAGAININ, CB_GETITEMDATA, n, 0) * 60;
- if (TT >= 24*3600)
- {
+ if (TT >= 24 * 3600) {
// selection is 1 day or more, take daylight saving boundaries into consideration
// (ie. 24 hour might actually be 23 or 25, in order for reminder to pop up at the
// same time tomorrow)
@@ -1642,13 +1508,11 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP FileTimeToTzLocalST((FILETIME*)&li2, &tm2);
li2.QuadPart += (TT * FILETIME_TICKS_PER_SEC);
FileTimeToTzLocalST((FILETIME*)&li2, &tm3);
- if (tm2.wHour != tm3.wHour || tm2.wMinute != tm3.wMinute)
- {
+ if (tm2.wHour != tm3.wHour || tm2.wMinute != tm3.wMinute) {
// boundary crossed
// do a quick and dirty sanity check that times not more than 2 hours apart
- if (abs((int)(tm3.wHour*60+tm3.wMinute)-(int)(tm2.wHour*60+tm2.wMinute)) <= 120)
- {
+ if (abs((int)(tm3.wHour * 60 + tm3.wMinute) - (int)(tm2.wHour * 60 + tm2.wMinute)) <= 120) {
// adjust TT so that same HH:MM is set
tm3.wHour = tm2.wHour;
tm3.wMinute = tm2.wMinute;
@@ -1658,16 +1522,14 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP }
}
}
- else
- {
+ else {
// parse user input
char s[32];
int h = 0, m = 0;
GetDlgItemText(Dialog, IDC_REMINDAGAININ, s, 30);
ParseTime(s, &h, &m, TRUE, TRUE);
m += h * 60;
- if (!m)
- {
+ if (!m) {
MessageBox(Dialog, Translate("The specified time offset is invalid."), SECTIONNAME, MB_OK | MB_ICONWARNING);
return TRUE;
}
@@ -1678,13 +1540,12 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP pReminder->When = li;
pReminder->When.QuadPart += (TT * FILETIME_TICKS_PER_SEC);
}
- else if (IsDlgButtonChecked(Dialog, IDC_ONDATE) == BST_CHECKED)
- {
+ else if (IsDlgButtonChecked(Dialog, IDC_ONDATE) == BST_CHECKED) {
SYSTEMTIME Date;
SendDlgItemMessage(Dialog, IDC_DATEAGAIN, DTM_GETSYSTEMTIME, 0, (LPARAM)&Date);
- if ( !GetTriggerTime(Dialog, IDC_TIMEAGAIN, IDC_REFTIME, &Date) )
+ if (!GetTriggerTime(Dialog, IDC_TIMEAGAIN, IDC_REFTIME, &Date))
break;
SYSTEMTIMEtoFILETIME(&Date, (FILETIME*)&pReminder->When);
@@ -1692,24 +1553,23 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP // update reminder text
{
- char *ReminderText = NULL;
- int SzT = SendDlgItemMessage(Dialog, IDC_REMDATA, WM_GETTEXTLENGTH, 0, 0);
- if (SzT)
- {
- if (SzT > MAX_REMINDER_LEN) SzT = MAX_REMINDER_LEN;
- ReminderText = (char*)malloc(SzT + 1);
- GetDlgItemText(Dialog, IDC_REMDATA, ReminderText, SzT + 1);
- }
- if (pReminder->Reminder)
- free(pReminder->Reminder);
- pReminder->Reminder = ReminderText;
+ char *ReminderText = NULL;
+ int SzT = SendDlgItemMessage(Dialog, IDC_REMDATA, WM_GETTEXTLENGTH, 0, 0);
+ if (SzT) {
+ if (SzT > MAX_REMINDER_LEN) SzT = MAX_REMINDER_LEN;
+ ReminderText = (char*)malloc(SzT + 1);
+ GetDlgItemText(Dialog, IDC_REMDATA, ReminderText, SzT + 1);
+ }
+ if (pReminder->Reminder)
+ free(pReminder->Reminder);
+ pReminder->Reminder = ReminderText;
}
pReminder->RemVisible = FALSE;
pReminder->handle = NULL;
// re-insert tree item sorted
- TreeDelete(&RemindersList,pReminder);
+ TreeDelete(&RemindersList, pReminder);
TreeAddSorted(&RemindersList, pReminder, ReminderSortCb);
JustSaveReminders();
break;
@@ -1722,21 +1582,18 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP case IDC_NONE:
{
- // create note from remainder
+ // create note from remainder
int ReminderCount = TreeGetCount(RemindersList);
- for (int I = 0; I < ReminderCount; I++)
- {
+ for (int I = 0; I < ReminderCount; I++) {
REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
- if (pReminder->handle == Dialog)
- {
+ if (pReminder->handle == Dialog) {
// get up-to-date reminder text
char *ReminderText = NULL;
int SzT = SendDlgItemMessage(Dialog, IDC_REMDATA, WM_GETTEXTLENGTH, 0, 0);
- if (SzT)
- {
+ if (SzT) {
if (SzT > MAX_REMINDER_LEN) SzT = MAX_REMINDER_LEN;
- ReminderText = (char*)malloc(SzT+1);
+ ReminderText = (char*)malloc(SzT + 1);
GetDlgItemText(Dialog, IDC_REMDATA, ReminderText, SzT + 1);
}
@@ -1752,18 +1609,16 @@ static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wP return FALSE;
}
-static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
{
HICON hIcon = NULL;
- switch (Message)
- {
- case WM_INITDIALOG:
+ switch (Message) {
+ case WM_INITDIALOG:
{
ULARGE_INTEGER li;
SYSTEMTIME tm;
- if (NewReminderVisible == 2)
- {
+ if (NewReminderVisible == 2) {
// opening the edit reminder dialog (uses same dialog resource as add reminder)
SetWindowText(Dialog, Translate("Reminder"));
SetDlgItemText(Dialog, IDC_ADDREMINDER, Translate("&Update Reminder"));
@@ -1772,8 +1627,7 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara li = pEditReminder->When;
FILETIMEtoSYSTEMTIME((FILETIME*)&li, &tm);
}
- else
- {
+ else {
GetSystemTime(&tm);
SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&li);
}
@@ -1804,8 +1658,7 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara SendDlgItemMessage(Dialog, IDC_REMINDER, EM_LIMITTEXT, MAX_REMINDER_LEN, 0);
- if (NewReminderVisible == 2)
- {
+ if (NewReminderVisible == 2) {
char s[32];
mir_snprintf(s, "%02d:%02d", (UINT)tm.wHour, (UINT)tm.wMinute);
@@ -1818,9 +1671,8 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara SetDlgItemText(Dialog, IDC_REMINDER, pEditReminder->Reminder);
}
- else
- {
- SendDlgItemMessage(Dialog,IDC_TIME,CB_SETCURSEL,0,0);
+ else {
+ SendDlgItemMessage(Dialog, IDC_TIME, CB_SETCURSEL, 0, 0);
}
// populate sound repeat combo
@@ -1832,41 +1684,39 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara // NOTE: use multiples of REMINDER_UPDATE_INTERVAL_SHORT (currently 5 seconds)
int n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)Translate("Never"));
- SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_SETITEMDATA, n, 0);
+ SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETITEMDATA, n, 0);
mir_snprintf(s, "%s 5 %s", lpszEvery, lpszSeconds);
- n = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)s);
+ n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)s);
SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETITEMDATA, n, (LPARAM)5);
mir_snprintf(s, "%s 10 %s", lpszEvery, lpszSeconds);
- n = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_ADDSTRING, 0, (LPARAM)s);
+ n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)s);
SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETITEMDATA, n, (LPARAM)10);
mir_snprintf(s, "%s 15 %s", lpszEvery, lpszSeconds);
- n = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_ADDSTRING, 0, (LPARAM)s);
+ n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)s);
SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETITEMDATA, n, (LPARAM)15);
mir_snprintf(s, "%s 20 %s", lpszEvery, lpszSeconds);
- n = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_ADDSTRING, 0, (LPARAM)s);
+ n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)s);
SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETITEMDATA, n, (LPARAM)20);
mir_snprintf(s, "%s 30 %s", lpszEvery, lpszSeconds);
- n = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_ADDSTRING, 0, (LPARAM)s);
+ n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)s);
SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETITEMDATA, n, (LPARAM)30);
mir_snprintf(s, "%s 60 %s", lpszEvery, lpszSeconds);
n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)s);
SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETITEMDATA, n, (LPARAM)60);
- if (NewReminderVisible == 2 && pEditReminder->RepeatSound)
- {
+ if (NewReminderVisible == 2 && pEditReminder->RepeatSound) {
mir_snprintf(s, "%s %d %s", lpszEvery, pEditReminder->RepeatSound, lpszSeconds);
SetDlgItemText(Dialog, IDC_COMBO_REPEATSND, s);
SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETCURSEL, SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)s), 0);
}
- else
- {
- SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_SETCURSEL,0,0);
+ else {
+ SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_SETCURSEL, 0, 0);
}
}
@@ -1881,30 +1731,27 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara n = SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_ADDSTRING, 0, (LPARAM)Translate("None"));
SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_SETITEMDATA, n, (LPARAM)-1);
- if (NewReminderVisible == 2 && pEditReminder->SoundSel)
- {
- const UINT n2 = pEditReminder->SoundSel<0 ? 3 : pEditReminder->SoundSel;
- SendDlgItemMessage(Dialog,IDC_COMBO_SOUND,CB_SETCURSEL,n2,0);
+ if (NewReminderVisible == 2 && pEditReminder->SoundSel) {
+ const UINT n2 = pEditReminder->SoundSel < 0 ? 3 : pEditReminder->SoundSel;
+ SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_SETCURSEL, n2, 0);
}
- else
- {
- SendDlgItemMessage(Dialog,IDC_COMBO_SOUND,CB_SETCURSEL,0,0);
+ else {
+ SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_SETCURSEL, 0, 0);
}
}
hIcon = IcoLib_GetIconByHandle(iconList[12].hIcolib);
- SendDlgItemMessage(Dialog,IDC_BTN_PLAYSOUND,BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hIcon);
+ SendDlgItemMessage(Dialog, IDC_BTN_PLAYSOUND, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon);
- if (NewReminderVisible == 2 && pEditReminder->SoundSel)
- {
- EnableWindow(GetDlgItem(Dialog, IDC_BTN_PLAYSOUND), pEditReminder->SoundSel>=0);
- EnableWindow(GetDlgItem(Dialog, IDC_COMBO_REPEATSND), pEditReminder->SoundSel>=0);
+ if (NewReminderVisible == 2 && pEditReminder->SoundSel) {
+ EnableWindow(GetDlgItem(Dialog, IDC_BTN_PLAYSOUND), pEditReminder->SoundSel >= 0);
+ EnableWindow(GetDlgItem(Dialog, IDC_COMBO_REPEATSND), pEditReminder->SoundSel >= 0);
}
if (NewReminderVisible == 2)
- SetFocus( GetDlgItem(Dialog, IDC_ADDREMINDER) );
+ SetFocus(GetDlgItem(Dialog, IDC_ADDREMINDER));
else
- SetFocus( GetDlgItem(Dialog, IDC_REMINDER) );
+ SetFocus(GetDlgItem(Dialog, IDC_REMINDER));
return FALSE;
}
@@ -1914,8 +1761,7 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara return TRUE;
case WM_CLOSE:
- if (NewReminderVisible == 2)
- {
+ if (NewReminderVisible == 2) {
pEditReminder->RemVisible = FALSE;
}
DestroyWindow(Dialog);
@@ -1924,12 +1770,10 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara return TRUE;
case WM_NOTIFY:
- if (wParam == IDC_DATE)
- {
+ if (wParam == IDC_DATE) {
LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
- switch (NM->hdr.code)
- {
+ switch (NM->hdr.code) {
case DTN_DATETIMECHANGE:
OnDateChanged(Dialog, IDC_DATE, IDC_TIME, IDC_REFTIME);
break;
@@ -1939,27 +1783,22 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara case WM_COMMAND:
{
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDC_TIME:
- switch (HIWORD(wParam))
- {
+ switch (HIWORD(wParam)) {
case CBN_KILLFOCUS:
// reformat displayed value
- if (SendDlgItemMessage(Dialog, IDC_TIME, CB_GETCURSEL, 0, 0) == CB_ERR)
- {
+ if (SendDlgItemMessage(Dialog, IDC_TIME, CB_GETCURSEL, 0, 0) == CB_ERR) {
char buf[64];
int h, m;
GetDlgItemText(Dialog, IDC_TIME, buf, 30);
- if ( ParseTime(buf, &h, &m, FALSE, IsRelativeCombo(Dialog, IDC_TIME)) )
- {
+ if (ParseTime(buf, &h, &m, FALSE, IsRelativeCombo(Dialog, IDC_TIME))) {
SYSTEMTIME Date;
- SendDlgItemMessage(Dialog,IDC_DATE,DTM_GETSYSTEMTIME,0,(LPARAM)&Date);
+ SendDlgItemMessage(Dialog, IDC_DATE, DTM_GETSYSTEMTIME, 0, (LPARAM)&Date);
ReformatTimeInput(Dialog, IDC_TIME, IDC_REFTIME, h, m, &Date);
}
- else
- {
+ else {
SendDlgItemMessage(Dialog, IDC_TIME, CB_SETCURSEL, 0, 0);
}
}
@@ -1968,15 +1807,14 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara break;
case IDC_COMBO_SOUND:
- switch (HIWORD(wParam))
- {
+ switch (HIWORD(wParam)) {
case CBN_SELENDOK:
{
int n = SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_GETCURSEL, 0, 0);
n = (int)SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_GETITEMDATA, n, 0);
- EnableWindow(GetDlgItem(Dialog, IDC_BTN_PLAYSOUND), n>=0);
- EnableWindow(GetDlgItem(Dialog, IDC_COMBO_REPEATSND), n>=0);
+ EnableWindow(GetDlgItem(Dialog, IDC_BTN_PLAYSOUND), n >= 0);
+ EnableWindow(GetDlgItem(Dialog, IDC_COMBO_REPEATSND), n >= 0);
}
break;
}
@@ -1986,8 +1824,7 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara {
int n = SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_GETCURSEL, 0, 0);
n = (int)SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_GETITEMDATA, n, 0);
- switch (n)
- {
+ switch (n) {
case 0: SkinPlaySound("AlertReminder"); break;
case 1: SkinPlaySound("AlertReminder2"); break;
case 2: SkinPlaySound("AlertReminder3"); break;
@@ -1996,8 +1833,7 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara return TRUE;
case IDC_CLOSE:
- if (NewReminderVisible == 2)
- {
+ if (NewReminderVisible == 2) {
pEditReminder->RemVisible = FALSE;
}
DestroyWindow(Dialog);
@@ -2013,28 +1849,26 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara {
SYSTEMTIME Date;
- SendDlgItemMessage(Dialog,IDC_DATE,DTM_GETSYSTEMTIME,0,(LPARAM)&Date);
+ SendDlgItemMessage(Dialog, IDC_DATE, DTM_GETSYSTEMTIME, 0, (LPARAM)&Date);
- if ( !GetTriggerTime(Dialog, IDC_TIME, IDC_REFTIME, &Date) )
+ if (!GetTriggerTime(Dialog, IDC_TIME, IDC_REFTIME, &Date))
break;
- int RepeatSound = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_GETCURSEL,0,0);
+ int RepeatSound = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_GETCURSEL, 0, 0);
if (RepeatSound != CB_ERR)
- RepeatSound = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_GETITEMDATA,(WPARAM)RepeatSound,0);
+ RepeatSound = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_GETITEMDATA, (WPARAM)RepeatSound, 0);
else
RepeatSound = 0;
- int SzT = SendDlgItemMessage(Dialog,IDC_REMINDER,WM_GETTEXTLENGTH,0,0);
+ int SzT = SendDlgItemMessage(Dialog, IDC_REMINDER, WM_GETTEXTLENGTH, 0, 0);
char *ReminderText = NULL;
- if (SzT)
- {
+ if (SzT) {
if (SzT > MAX_REMINDER_LEN) SzT = MAX_REMINDER_LEN;
ReminderText = (char*)malloc(SzT + 1);
GetDlgItemText(Dialog, IDC_REMINDER, ReminderText, SzT + 1);
}
- if (NewReminderVisible != 2)
- {
+ if (NewReminderVisible != 2) {
// new reminder
REMINDERDATA *TempRem = (REMINDERDATA*)malloc(sizeof(REMINDERDATA));
TempRem->uid = CreateUid();
@@ -2044,11 +1878,10 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara TempRem->SystemEventQueued = 0;
TempRem->RepeatSoundTTL = 0;
TempRem->SoundSel = (int)SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_GETCURSEL, 0, 0), 0);
- TempRem->RepeatSound = TempRem->SoundSel<0 ? 0 : (UINT)RepeatSound;
- TreeAddSorted(&RemindersList,TempRem,ReminderSortCb);
+ TempRem->RepeatSound = TempRem->SoundSel < 0 ? 0 : (UINT)RepeatSound;
+ TreeAddSorted(&RemindersList, TempRem, ReminderSortCb);
}
- else
- {
+ else {
// update existing reminder
SYSTEMTIMEtoFILETIME(&Date, (FILETIME*)&pEditReminder->When);
@@ -2056,20 +1889,19 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara free(pEditReminder->Reminder);
pEditReminder->Reminder = ReminderText;
pEditReminder->SoundSel = (int)SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(Dialog, IDC_COMBO_SOUND, CB_GETCURSEL, 0, 0), 0);
- pEditReminder->RepeatSound = pEditReminder->SoundSel<0 ? 0 : (UINT)RepeatSound;
+ pEditReminder->RepeatSound = pEditReminder->SoundSel < 0 ? 0 : (UINT)RepeatSound;
// re-insert tree item sorted
- TreeDelete(&RemindersList,pEditReminder);
- TreeAddSorted(&RemindersList,pEditReminder,ReminderSortCb);
+ TreeDelete(&RemindersList, pEditReminder);
+ TreeAddSorted(&RemindersList, pEditReminder, ReminderSortCb);
pEditReminder->RemVisible = FALSE;
}
- SetDlgItemText(Dialog,IDC_REMINDER,"");
+ SetDlgItemText(Dialog, IDC_REMINDER, "");
JustSaveReminders();
NOTIFY_LIST();
- if (g_CloseAfterAddReminder || NewReminderVisible == 2)
- {
+ if (g_CloseAfterAddReminder || NewReminderVisible == 2) {
DestroyWindow(Dialog);
NewReminderVisible = FALSE;
pEditReminder = NULL;
@@ -2081,7 +1913,7 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wPara IcoLib_ReleaseIcon(hIcon);
break;
}
- return FALSE;
+ return FALSE;
}
@@ -2123,8 +1955,7 @@ INT_PTR OpenTriggeredReminder(WPARAM, LPARAM l) void NewReminder(void)
{
- if (!NewReminderVisible)
- {
+ if (!NewReminderVisible) {
NewReminderVisible = TRUE;
CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDREMINDER), 0, DlgProcNewReminder);
}
@@ -2135,17 +1966,14 @@ void EditReminder(REMINDERDATA *p) if (!p)
return;
- if (!NewReminderVisible && !p->SystemEventQueued)
- {
- if (!p->RemVisible)
- {
+ if (!NewReminderVisible && !p->SystemEventQueued) {
+ if (!p->RemVisible) {
p->RemVisible = TRUE;
NewReminderVisible = 2;
pEditReminder = p;
CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDREMINDER), 0, DlgProcNewReminder);
}
- else
- {
+ else {
BringWindowToTop(p->handle);
}
}
@@ -2156,12 +1984,11 @@ static void InitListView(HWND AHLV) int I = 0;
char S1[128];
- ListView_SetHoverTime(AHLV,700);
- ListView_SetExtendedListViewStyle(AHLV,LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT);
+ ListView_SetHoverTime(AHLV, 700);
+ ListView_SetExtendedListViewStyle(AHLV, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT);
ListView_DeleteAllItems(AHLV);
-
- for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT*)TTE->next)
- {
+
+ for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT*)TTE->next) {
REMINDERDATA *pReminder = (REMINDERDATA*)TTE->ptrdata;
LV_ITEM lvTIt;
@@ -2172,18 +1999,18 @@ static void InitListView(HWND AHLV) lvTIt.iItem = I;
lvTIt.iSubItem = 0;
lvTIt.pszText = S1;
- ListView_InsertItem(AHLV,&lvTIt);
+ ListView_InsertItem(AHLV, &lvTIt);
lvTIt.mask = LVIF_TEXT;
char *S2 = GetPreviewString(pReminder->Reminder);
lvTIt.iItem = I;
lvTIt.iSubItem = 1;
lvTIt.pszText = S2;
- ListView_SetItem(AHLV,&lvTIt);
+ ListView_SetItem(AHLV, &lvTIt);
I++;
}
- ListView_SetItemState(AHLV,0,LVIS_SELECTED,LVIS_SELECTED);
+ ListView_SetItemState(AHLV, 0, LVIS_SELECTED, LVIS_SELECTED);
}
void OnListResize(HWND Dialog)
@@ -2191,7 +2018,7 @@ void OnListResize(HWND Dialog) HWND hList, hText, hBtnNew, hBtnClose;
RECT lr, cr, tr, clsr;
int th, btnh, btnw, MARGIN;
- POINT org = {0};
+ POINT org = { 0 };
hList = GetDlgItem(Dialog, IDC_LISTREMINDERS);
hText = GetDlgItem(Dialog, IDC_REMINDERDATA);
@@ -2222,8 +2049,8 @@ void OnListResize(HWND Dialog) lr.right = cr.right - MARGIN;
lr.bottom = tr.top - 5;
- MoveWindow(hList, lr.left, lr.top, lr.right-lr.left, lr.bottom-lr.top, FALSE);
- MoveWindow(hText, tr.left, tr.top, tr.right-tr.left, tr.bottom-tr.top, FALSE);
+ MoveWindow(hList, lr.left, lr.top, lr.right - lr.left, lr.bottom - lr.top, FALSE);
+ MoveWindow(hText, tr.left, tr.top, tr.right - tr.left, tr.bottom - tr.top, FALSE);
MoveWindow(hBtnClose, clsr.left, clsr.top, btnw, btnh, FALSE);
clsr.left -= btnw + 2;
@@ -2235,8 +2062,7 @@ void OnListResize(HWND Dialog) void UpdateGeomFromWnd(HWND Dialog, int *geom, int *colgeom, int nCols)
{
- if (geom)
- {
+ if (geom) {
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
@@ -2248,18 +2074,16 @@ void UpdateGeomFromWnd(HWND Dialog, int *geom, int *colgeom, int nCols) geom[3] = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
}
- if (colgeom)
- {
+ if (colgeom) {
HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS);
- for (int i=0; i<nCols; i++)
- {
+ for (int i = 0; i < nCols; i++) {
colgeom[i] = ListView_GetColumnWidth(H, i);
}
}
}
-static BOOL DoListContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam,REMINDERDATA *pReminder)
+static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam, REMINDERDATA *pReminder)
{
HWND hwndListView = (HWND)wParam;
if (hwndListView != GetDlgItem(AhWnd, IDC_LISTREMINDERS)) return FALSE;
@@ -2275,20 +2099,19 @@ static BOOL DoListContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam,REMINDERDAT SetMenuItemInfo(FhMenu, ID_CONTEXTMENUREMINDERLISTVIEW_EDIT, FALSE, &mii);
if (!pReminder)
- EnableMenuItem(FhMenu, IDM_DELETEREMINDER, MF_GRAYED|MF_BYCOMMAND);
+ EnableMenuItem(FhMenu, IDM_DELETEREMINDER, MF_GRAYED | MF_BYCOMMAND);
TranslateMenu(FhMenu);
- TrackPopupMenu(FhMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,LOWORD(lParam),HIWORD(lParam),0,AhWnd,0);
+ TrackPopupMenu(FhMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, LOWORD(lParam), HIWORD(lParam), 0, AhWnd, 0);
DestroyMenu(hMenuLoad);
return TRUE;
}
-static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
{
- LV_COLUMN lvCol;
+ LV_COLUMN lvCol;
- switch (Message)
- {
+ switch (Message) {
case WM_SIZE:
OnListResize(Dialog);
UpdateGeomFromWnd(Dialog, g_reminderListGeom, NULL, 0);
@@ -2315,17 +2138,15 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wPa {
REMINDERDATA *pReminder = NULL;
- HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
- if ( ListView_GetSelectedCount(H) )
- {
+ HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS);
+ if (ListView_GetSelectedCount(H)) {
int I = ListView_GetSelectionMark(H);
- if (I != -1)
- {
- pReminder = (REMINDERDATA*)TreeGetAt(RemindersList,I);
+ if (I != -1) {
+ pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
}
}
- if ( DoListContextMenu(Dialog, wParam, lParam, pReminder) )
+ if (DoListContextMenu(Dialog, wParam, lParam, pReminder))
return TRUE;
}
break;
@@ -2334,25 +2155,24 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wPa Window_SetIcon_IcoLib(Dialog, iconList[6].hIcolib);
TranslateDialogDefault(Dialog);
- SetDlgItemText(Dialog,IDC_REMINDERDATA, "");
+ SetDlgItemText(Dialog, IDC_REMINDERDATA, "");
{
- HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS);
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
char *S2 = Translate("Reminder text");
lvCol.pszText = S2;
lvCol.cx = g_reminderListColGeom[1];
- ListView_InsertColumn(H,0,&lvCol);
+ ListView_InsertColumn(H, 0, &lvCol);
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
S2 = Translate("Date of activation");
lvCol.pszText = S2;
lvCol.cx = g_reminderListColGeom[0];
- ListView_InsertColumn(H,0,&lvCol);
+ ListView_InsertColumn(H, 0, &lvCol);
InitListView(H);
SetWindowLongPtr(GetDlgItem(H, 0), GWL_ID, IDC_LISTREMINDERS_HEADER);
LV = Dialog;
- if (g_reminderListGeom[1] && g_reminderListGeom[2])
- {
+ if (g_reminderListGeom[1] && g_reminderListGeom[2]) {
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(Dialog, &wp);
@@ -2372,25 +2192,21 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wPa case WM_NOTIFY:
{
- if (wParam == IDC_LISTREMINDERS)
- {
+ if (wParam == IDC_LISTREMINDERS) {
LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
- switch (NM->hdr.code)
- {
+ switch (NM->hdr.code) {
case LVN_ITEMCHANGED:
{
- char *S2 = ((REMINDERDATA*)TreeGetAt(RemindersList,NM->iItem))->Reminder;
- SetDlgItemText(Dialog,IDC_REMINDERDATA,S2);
+ char *S2 = ((REMINDERDATA*)TreeGetAt(RemindersList, NM->iItem))->Reminder;
+ SetDlgItemText(Dialog, IDC_REMINDERDATA, S2);
}
break;
case NM_DBLCLK:
{
- HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
- if ( ListView_GetSelectedCount(H) )
- {
+ HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS);
+ if (ListView_GetSelectedCount(H)) {
int I = ListView_GetSelectionMark(H);
- if (I != -1)
- {
+ if (I != -1) {
EditReminder((REMINDERDATA*)TreeGetAt(RemindersList, I));
}
}
@@ -2398,11 +2214,9 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wPa break;
}
}
- else if (wParam == IDC_LISTREMINDERS_HEADER)
- {
+ else if (wParam == IDC_LISTREMINDERS_HEADER) {
LPNMHEADER NM = (LPNMHEADER)lParam;
- switch (NM->hdr.code)
- {
+ switch (NM->hdr.code) {
case HDN_ENDTRACK:
UpdateGeomFromWnd(Dialog, NULL, g_reminderListColGeom, _countof(g_reminderListColGeom));
break;
@@ -2412,16 +2226,13 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wPa break;
case WM_COMMAND:
{
- switch(LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case ID_CONTEXTMENUREMINDERLISTVIEW_EDIT:
{
- HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
- if ( ListView_GetSelectedCount(H) )
- {
+ HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS);
+ if (ListView_GetSelectedCount(H)) {
int I = ListView_GetSelectionMark(H);
- if (I != -1)
- {
+ if (I != -1) {
EditReminder((REMINDERDATA*)TreeGetAt(RemindersList, I));
}
}
@@ -2439,23 +2250,20 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wPa return TRUE;
case IDM_DELETEALLREMINDERS:
- if (RemindersList && MessageBox(Dialog, Translate("Are you sure you want to delete all reminders?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK)
- {
+ if (RemindersList && MessageBox(Dialog, Translate("Are you sure you want to delete all reminders?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK) {
SetDlgItemText(Dialog, IDC_REMINDERDATA, "");
DeleteReminders();
- InitListView(GetDlgItem(Dialog,IDC_LISTREMINDERS));
+ InitListView(GetDlgItem(Dialog, IDC_LISTREMINDERS));
}
return TRUE;
case IDM_DELETEREMINDER:
{
- HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
- if ( ListView_GetSelectedCount(H) )
- {
+ HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS);
+ if (ListView_GetSelectedCount(H)) {
int I = ListView_GetSelectionMark(H);
if (I != -1
- && MessageBox(Dialog, Translate("Are you sure you want to delete this reminder?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK)
- {
+ && MessageBox(Dialog, Translate("Are you sure you want to delete this reminder?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK) {
SetDlgItemText(Dialog, IDC_REMINDERDATA, "");
DeleteReminder((REMINDERDATA*)TreeGetAt(RemindersList, I));
JustSaveReminders();
@@ -2475,13 +2283,11 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wPa void ListReminders(void)
{
- if (!ListReminderVisible)
- {
+ if (!ListReminderVisible) {
CreateDialog(hinstance, MAKEINTRESOURCE(IDD_LISTREMINDERS), 0, DlgProcViewReminders);
ListReminderVisible = TRUE;
}
- else
- {
+ else {
BringWindowToTop(LV);
}
}
@@ -2493,7 +2299,7 @@ void ListReminders(void) BOOL WS_Init()
{
WSADATA wsd;
- if (WSAStartup(MAKEWORD(2,2),&wsd)!=0) return FALSE;
+ if (WSAStartup(MAKEWORD(2, 2), &wsd) != 0) return FALSE;
return TRUE;
}
@@ -2502,33 +2308,32 @@ void WS_CleanUp() WSACleanup();
}
-int WS_Send(SOCKET s,char *data,int datalen)
+int WS_Send(SOCKET s, char *data, int datalen)
{
int rlen;
- if ((rlen = send(s,data,datalen,0)) == SOCKET_ERROR) return FALSE;
+ if ((rlen = send(s, data, datalen, 0)) == SOCKET_ERROR) return FALSE;
return TRUE;
}
-unsigned long WS_ResolveName(char *name,WORD *port,int defaultPort)
+unsigned long WS_ResolveName(char *name, WORD *port, int defaultPort)
{
- HOSTENT *lk;
- char *pcolon,*nameCopy;
- DWORD ret;
- nameCopy=_strdup(name);
- if(port != NULL) *port = defaultPort;
- pcolon = strchr(nameCopy,':');
- if(pcolon != NULL)
- {
- if(port != NULL) *port = atoi(pcolon+1);
+ char *nameCopy = _strdup(name);
+ if (port != NULL)
+ *port = defaultPort;
+ char *pcolon = strchr(nameCopy, ':');
+ if (pcolon != NULL) {
+ if (port != NULL) *port = atoi(pcolon + 1);
*pcolon = 0;
}
- if (inet_addr(nameCopy) == INADDR_NONE)
- {
- lk = gethostbyname(nameCopy);
- if(lk == 0) return SOCKET_ERROR;
- else {free(nameCopy); return *(u_long*)lk->h_addr_list[0];}
+ if (inet_addr(nameCopy) == INADDR_NONE) {
+ HOSTENT *lk = gethostbyname(nameCopy);
+ if (lk == 0)
+ return SOCKET_ERROR;
+
+ free(nameCopy);
+ return *(u_long*)lk->h_addr_list[0];
}
- ret=inet_addr(nameCopy);
+ DWORD ret = inet_addr(nameCopy);
free(nameCopy);
return ret;
}
@@ -2538,22 +2343,22 @@ void Send(char *user, char *host, char *Msg, char *server) SOCKADDR_IN sockaddr;
WORD port;
char *ch = NULL;
- S = socket(AF_INET,SOCK_STREAM,0);
+ S = socket(AF_INET, SOCK_STREAM, 0);
if (!server) server = host;
if ((sockaddr.sin_addr.S_un.S_addr = WS_ResolveName(server,
- &port,25))==SOCKET_ERROR) return;
+ &port, 25)) == SOCKET_ERROR) return;
sockaddr.sin_port = htons(port);
sockaddr.sin_family = AF_INET;
- if(connect(S,(SOCKADDR*)&sockaddr,sizeof(sockaddr)) == SOCKET_ERROR) return;
+ if (connect(S, (SOCKADDR*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR) return;
ch = (char*)malloc(mir_strlen(user) + mir_strlen(host) + 16);
- ch = (char*)realloc(ch,sprintf(ch,"rcpt to:%s@%s\r\n",user,host)); //!!!!!!!!!!
- WS_Send(S,"mail from: \r\n",13);
- WS_Send(S,ch,(int)mir_strlen(ch));
- WS_Send(S,"data\r\n",6);
- WS_Send(S,"From:<REM>\r\n\r\n",14);
- WS_Send(S,Msg,(int)mir_strlen(Msg));
- WS_Send(S,"\r\n.\r\n",5);
- WS_Send(S,"quit\r\n",6);
+ ch = (char*)realloc(ch, sprintf(ch, "rcpt to:%s@%s\r\n", user, host)); //!!!!!!!!!!
+ WS_Send(S, "mail from: \r\n", 13);
+ WS_Send(S, ch, (int)mir_strlen(ch));
+ WS_Send(S, "data\r\n", 6);
+ WS_Send(S, "From:<REM>\r\n\r\n", 14);
+ WS_Send(S, Msg, (int)mir_strlen(Msg));
+ WS_Send(S, "\r\n.\r\n", 5);
+ WS_Send(S, "quit\r\n", 6);
SAFE_FREE((void**)&ch);
closesocket(S);
}
diff --git a/plugins/NotesAndReminders/src/version.h b/plugins/NotesAndReminders/src/version.h index 3d6456de56..f0ca245e17 100644 --- a/plugins/NotesAndReminders/src/version.h +++ b/plugins/NotesAndReminders/src/version.h @@ -1,14 +1,14 @@ #define __MAJOR_VERSION 0 -#define __MINOR_VERSION 0 -#define __RELEASE_NUM 5 -#define __BUILD_NUM 1 +#define __MINOR_VERSION 1 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 1 #include <stdver.h> -#define __PLUGIN_NAME "Sticky Notes & Reminders" -#define __FILENAME "NotesReminders.dll" +#define __PLUGIN_NAME "Sticky Notes & Reminders" +#define __FILENAME "NotesReminders.dll" #define __DESCRIPTION "Sticky Notes & Reminders Implementation for Miranda NG." -#define __AUTHOR "Joe Kucera, Lubomir Kolev Ivanov, Georg Fischer" -#define __AUTHOREMAIL "jokusoftware@users.sourceforge.net; d00mEr@dir.bg" +#define __AUTHOR "Joe Kucera, Lubomir Kolev Ivanov, Georg Fischer" +#define __AUTHOREMAIL "jokusoftware@users.sourceforge.net; d00mEr@dir.bg" #define __AUTHORWEB "http://miranda-ng.org/p/NotesAndReminders/" #define __COPYRIGHT "© 2003-2005 Joe Kucera, Lubomir Ivanov" |