From d53ca32424aa8c1cca9f0e0a8c81d15b2e7f123b Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sun, 28 Aug 2016 08:51:32 +0900 Subject: [PATCH 1/6] common: Remove old function declaration --- source/common/common.h | 1 - source/common/playfile.c | 1 - 2 files changed, 2 deletions(-) diff --git a/source/common/common.h b/source/common/common.h index c9c0449..ad3d0ee 100644 --- a/source/common/common.h +++ b/source/common/common.h @@ -331,7 +331,6 @@ DWORDLONG r_M32x32to64(DWORD a, DWORD b); BOOL PlayFile(HWND hwnd, const char *fname, int loops); BOOL PlayFileCmdLine(HWND hwnd, const char *str); -BOOL Player(HWND hwnd, const char *fname); void StopFile(void); void OnMCINotify(HWND hwnd, WPARAM wFlags, LONG lDevID); BOOL IsSoundFile(const char* fname); diff --git a/source/common/playfile.c b/source/common/playfile.c index fcee2b3..b63268c 100644 --- a/source/common/playfile.c +++ b/source/common/playfile.c @@ -12,7 +12,6 @@ BOOL PlayFile(HWND hwnd, const char *fname, int loops); BOOL PlayFileCmdLine(HWND hwnd, const char *str); -BOOL Player(HWND hwnd, const char *fname); void StopFile(void); void OnMCINotify(HWND hwnd, WPARAM wFlags, LONG lDevID); BOOL IsSoundFile(const char* fname); From 69dc83d937728e911dd37c618907719949cfe6be Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sun, 28 Aug 2016 11:00:22 +0900 Subject: [PATCH 2/6] common: Fix function declaration --- source/common/common.h | 4 ++-- source/common/nodeflib.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/common/common.h b/source/common/common.h index ad3d0ee..4c9be50 100644 --- a/source/common/common.h +++ b/source/common/common.h @@ -249,9 +249,9 @@ int r_strnicmp(const char* d, const char* s, size_t n); int r_atoi(const char *p); int r_atox(const char *p); int r__wtoi(const WCHAR *p); -int r_wcslen(const wchar_t *p); +size_t r_wcslen(const wchar_t *p); wchar_t *r_wcscpy(wchar_t *dp, const wchar_t *sp); -int r_wcsncmp(const wchar_t *p1, const wchar_t *p2, int count); +int r_wcsncmp(const wchar_t *p1, const wchar_t *p2, size_t count); wchar_t *r_wcscat(wchar_t *dp, const wchar_t *sp); wchar_t *r_wcsstr(const wchar_t *string, const wchar_t *strCharSet); diff --git a/source/common/nodeflib.c b/source/common/nodeflib.c index bd8ccda..fb302d6 100644 --- a/source/common/nodeflib.c +++ b/source/common/nodeflib.c @@ -124,9 +124,9 @@ int r__wtoi(const WCHAR *p) /*------------------------------------------- wcslen ---------------------------------------------*/ -int r_wcslen(const wchar_t *p) +size_t r_wcslen(const wchar_t *p) { - int n = 0; while(*p) { n++; p++; } return n; + size_t n = 0; while(*p) { n++; p++; } return n; } /*------------------------------------------- @@ -141,9 +141,9 @@ wchar_t *r_wcscpy(wchar_t *dp, const wchar_t *sp) /*------------------------------------------- wcsncmp ---------------------------------------------*/ -int r_wcsncmp(const wchar_t *p1, const wchar_t *p2, int count) +int r_wcsncmp(const wchar_t *p1, const wchar_t *p2, size_t count) { - int i; + size_t i; for(i = 0; i < count; i++) { if(*p1 == 0 && *p2 == 0) break; From 3935ea74bf901219073fd1e8993f8d8fbd2e836e Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sun, 28 Aug 2016 11:40:11 +0900 Subject: [PATCH 3/6] exe: Move g_uTaskbarRestart to wndproc.c No need to be a global variable. --- source/exe/main2.c | 5 ----- source/exe/tclock.h | 1 - source/exe/wndproc.c | 7 ++++++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/source/exe/main2.c b/source/exe/main2.c index 4bdb21f..5bc4876 100644 --- a/source/exe/main2.c +++ b/source/exe/main2.c @@ -16,7 +16,6 @@ char g_mydir[MAX_PATH]; // path to tclock.exe BOOL g_bIniSetting = FALSE; // save setting to ini file? char g_inifile[MAX_PATH]; // ini file name int g_winver; // windows version -UINT g_uTaskbarRestart; // taskbar recreating message /* Statics */ @@ -141,10 +140,6 @@ void InitTClockMain(void) g_winver = CheckWinVersion(); - // Message of the taskbar recreating - // Special thanks to Mr.Inuya - g_uTaskbarRestart = RegisterWindowMessage("TaskbarCreated"); - DelMyRegKey("OnContextMenu"); // temporarily InitTextColor(); diff --git a/source/exe/tclock.h b/source/exe/tclock.h index d5c3815..cfffddd 100644 --- a/source/exe/tclock.h +++ b/source/exe/tclock.h @@ -49,7 +49,6 @@ extern char g_mydir[MAX_PATH]; extern BOOL g_bIniSetting; extern char g_inifile[MAX_PATH]; extern int g_winver; -extern UINT g_uTaskbarRestart; /* ---------- wndproc.c ------------- */ LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); diff --git a/source/exe/wndproc.c b/source/exe/wndproc.c index 7619309..7bc0ff5 100644 --- a/source/exe/wndproc.c +++ b/source/exe/wndproc.c @@ -30,6 +30,7 @@ static void OnTaskbarRestart(HWND hwnd); static void OnCopyData(HWND hwnd, HWND hwndFrom, COPYDATASTRUCT* pcds); static void InitError(int n); +static UINT m_uTaskbarRestart; // taskbar recreating message static BOOL m_bHook = FALSE; static BOOL m_bStartTimer = FALSE; @@ -147,7 +148,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) return 0; } - if(message == g_uTaskbarRestart) + if(message == m_uTaskbarRestart) OnTaskbarRestart(hwnd); return DefWindowProc(hwnd, message, wParam, lParam); @@ -162,6 +163,10 @@ void OnCreate(HWND hwnd) { int nDelay; + // Message of the taskbar recreating + // Special thanks to Mr.Inuya + m_uTaskbarRestart = RegisterWindowMessage("TaskbarCreated"); + InitAlarm(); // alarm.c InitMouseFunction(hwnd); // mouse.c // InitSNTP(hwnd); // sntp.c From 24a3149ef3fcf4470379cbf8069baa1ed463138f Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sun, 28 Aug 2016 13:58:35 +0900 Subject: [PATCH 4/6] Import decoration and analog clock from tclocklight-050716 The build system is also updated. Now, "all" version cannot be compiled without libcmt because of analog clock. Makefiles cannot be shared with other versions. --- .gitignore | 2 + lang/tclang-ja.txt | 20 +- lang/tclang.txt | 24 ++- pack.bat | 2 +- prepare_custom.bat | 2 - source/common/combobox.c | 11 +- source/common/common.h | 5 +- source/config.h | 20 +- source/dll/draw.c | 353 ++++++++++++++++++++++++++++++-- source/dll/tooltip.c | 23 ++- source/property/main.c | 17 +- source/property/pageanalog.c | 268 ++++++++++++++++++++++++ source/property/pagecolor.c | 96 ++++++++- source/property/pagestartbtn.c | 9 +- source/property/pagestartmenu.c | 2 +- source/property/resource.h | 31 +++ source/property/tcprop.h | 4 + source/property/tcprop.mak | 3 +- source/property/tcprop.rc | 70 ++++++- source_all/Makefile | 65 ++++++ source_all/config.h | 20 +- source_custom/Makefile | 65 ++++++ source_custom/config.h | 20 +- 23 files changed, 1034 insertions(+), 98 deletions(-) create mode 100644 source/property/pageanalog.c create mode 100644 source_all/Makefile create mode 100644 source_custom/Makefile diff --git a/.gitignore b/.gitignore index 55408ab..92e7958 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ work64/ tags /source_all/* +!/source_all/Makefile !/source_all/config.h /source_custom/* +!/source_custom/Makefile !/source_custom/config.h diff --git a/lang/tclang-ja.txt b/lang/tclang-ja.txt index 021450e..8141c5e 100644 --- a/lang/tclang-ja.txt +++ b/lang/tclang-ja.txt @@ -1,6 +1,6 @@ [Main] DialogFont=MS Pゴシック,9 -Version=TClock Light kt160827 +Version=TClock Light kt160828 HelpURL=http://homepage1.nifty.com/kazubon/tclocklight/help/ja/ [Property] @@ -14,9 +14,11 @@ Line01=" [ Line02=" [ 背景色2][ ][...]" Line03=" [ グラデーション] [ 横] [ 縦]" Line04=" [ トレイの背景を塗りつぶす]" -Line05=" [文字色 ][ ][...]" -Line06=" [フォント][ ]" +Line05=" [ 文字色 ][ ][...]" +Line06=" [ フォント][ ]" Line07="[フォントサイズ][ ] [ 太字] [ 斜体]" +Line08=" [ 装飾][ なし] [ 影] [ 縁取り]" +Line09=" [ 色][ ][...][距離][ ][]" [Size] HelpURL=size.html @@ -48,6 +50,17 @@ Line02=" [ Line03=" [ 12時を0時と表示]" Line04=" [ OK ] [キャンセル ]" +[AnalogClock] +HelpURL=analog.html +Line01="[ アナログ時計を表示する]" +Line02=" [時針] [ ][...] [ 太線 ]" +Line03=" [分針] [ ][...] [ 太線 ]" +Line04=" [位置] [ テキストに重ねる ] [ 左 ] [ 右 ]" +Line05=" [位置調整 ]" +Line06=" [左右][ ][][上下][ ][]" +Line07=" [サイズ] [ ][]" +Line08="[ビットマップ][ ][...]" + [Alarm] HelpURL=alarm.html Line01=" [ 名前][ ] [ 追加 ] [ 削除 ]" @@ -190,6 +203,7 @@ Clock= Color=色とフォント SizePos=位置とサイズ Format=書式 +AnalogClock=アナログ時計 Alarm=アラーム Cuckoo=はと時計 Mouse=マウス操作 diff --git a/lang/tclang.txt b/lang/tclang.txt index 6c736a3..1d17501 100644 --- a/lang/tclang.txt +++ b/lang/tclang.txt @@ -1,6 +1,6 @@ [Main] DialogFont=MS Sans Serif, 9 -Version=TClock Light kt160827 +Version=TClock Light kt160828 HelpURL=http://homepage1.nifty.com/kazubon/tclocklight/help/en/ [Property] @@ -10,13 +10,15 @@ Line02=" [OK ] [Cancel ] [&Apply [Color] HelpURL=color.html -Line01=" [ Background1][ ][...]" -Line02=" [ Background2][ ][...]" +Line01=" [ Background1][ ][...]" +Line02=" [ Background2][ ][...]" Line03=" [Gradation ] [ Horizontal][ Vertical]" Line04=" [ Paint Tray background]" -Line05=" [Text ][ ][...]" -Line06=" [Font ][ ]" +Line05=" [Text ][ ][...]" +Line06=" [Font ][ ]" Line07=" [Size ][ ] [ Bold] [ Italic]" +Line08=" [ Decoration ][ None][ Shadow][ Border]" +Line09=" [ Color ][ ][...][ Range][ ][] " [Size] HelpURL=size.html @@ -48,6 +50,17 @@ Line02=" [PM symbol ][ ]" Line03=" [ Show 0:xx at 12:xx]" Line04=" [ OK ] [ Cancel ]" +[AnalogClock] +HelpURL=analog.html +Line01="[ Display analog clock]" +Line02=" [Hour hand] [ ][...] [ Bold ]" +Line03=" [Minute hand] [ ][...] [ Bold ]" +Line04=" [Position] [ Over the text ] [ Left ] [ Right ]" +Line05=" [Arrangement of position ]" +Line06=" [Horizontal][ ][][Vertical][ ][]" +Line07=" [Size] [ ][]" +Line08=" [ Background][ ][...]" + [Alarm] HelpURL=alarm.html Line01=" [ Name][ ] [ Add ] [Delete ]" @@ -190,6 +203,7 @@ Clock=Clock Color=Color and Font SizePos=Size and Position Format=Format +AnalogClock=Analog clock Alarm=Alarm Cuckoo=Cuckoo clock Mouse=Mouse diff --git a/pack.bat b/pack.bat index 58ece9a..a394b98 100755 --- a/pack.bat +++ b/pack.bat @@ -5,7 +5,7 @@ setlocal DISABLEDELAYEDEXPANSION :: Normal version set execfiles=tcdll.tclock tclock.exe tcplayer.exe tcprop.exe tcsntp.exe tctimer.exe set pkgfiles=readme-kt.txt config-kt.txt format-kt.txt readme.html -set srcfiles=source source_all\config.h source_custom\config.h pack.bat make_all.bat prepare_custom.bat +set srcfiles=source source_all\Makefile source_all\config.h source_custom\Makefile source_custom\config.h pack.bat make_all.bat prepare_custom.bat if not exist pkg mkdir pkg diff --git a/prepare_custom.bat b/prepare_custom.bat index ba211e0..ce5e4ad 100755 --- a/prepare_custom.bat +++ b/prepare_custom.bat @@ -14,7 +14,6 @@ goto :eof :createlink -if exist Makefile del Makefile if exist common rmdir common if exist dll rmdir dll if exist exe rmdir exe @@ -23,7 +22,6 @@ if exist property rmdir property if exist sntp rmdir sntp if exist timer rmdir timer -mklink Makefile ..\source\Makefile mklink /d common ..\source\common mklink /d dll ..\source\dll mklink /d exe ..\source\exe diff --git a/source/common/combobox.c b/source/common/combobox.c index 4c7225f..87c4363 100644 --- a/source/common/combobox.c +++ b/source/common/combobox.c @@ -16,8 +16,7 @@ void InitColorCombo(HWND hDlg, int idCombo, const COLORREF* pColAdd, int nAdd, COLORREF colDef); void OnMeasureItemColorCombo(LPMEASUREITEMSTRUCT pmis); void OnDrawItemColorCombo(LPDRAWITEMSTRUCT pdis, char (*pTexts)[80]); -void ChooseColorWithCombo(HINSTANCE hInst, HWND hDlg, - int idCombo); +BOOL ChooseColorWithCombo(HWND hDlg, int idCombo); /*------------------------------------------------ initialize @@ -131,8 +130,7 @@ void OnDrawItemColorCombo(LPDRAWITEMSTRUCT pdis, char (*pTexts)[80]) /*-------------------------------------------------------- open a choose color dialog and set color to combobox ----------------------------------------------------------*/ -void ChooseColorWithCombo(HINSTANCE hInst, HWND hDlg, - int idCombo) +BOOL ChooseColorWithCombo(HWND hDlg, int idCombo) { CHOOSECOLOR cc; COLORREF col, colarray[16]; @@ -146,12 +144,11 @@ void ChooseColorWithCombo(HINSTANCE hInst, HWND hDlg, memset(&cc, 0, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hDlg; - cc.hInstance = (HWND)hInst; cc.rgbResult = col; cc.lpCustColors = colarray; cc.Flags = CC_FULLOPEN | CC_RGBINIT; - if(!ChooseColor(&cc)) return; + if(!ChooseColor(&cc)) return FALSE; for(i = 0; i < CBGetCount(hDlg, idCombo); i++) { @@ -162,6 +159,8 @@ void ChooseColorWithCombo(HINSTANCE hInst, HWND hDlg, CBAddString(hDlg, idCombo, cc.rgbResult); CBSetCurSel(hDlg, idCombo, i); + + return TRUE; } /* ---------------------- Font combobox -------------------------------*/ diff --git a/source/common/common.h b/source/common/common.h index 4c9be50..1927aaf 100644 --- a/source/common/common.h +++ b/source/common/common.h @@ -15,7 +15,7 @@ #include #include "../config.h" -#define TCLOCKVERSION "TClock Light kt160827" +#define TCLOCKVERSION "TClock Light kt160828" #define CLASS_TCLOCKMAIN "TClockMainClass" #define CLASS_TCLOCKPROP "TClockPropertyClass" @@ -177,8 +177,7 @@ void InitColorCombo(HWND hDlg, int idCombo, const COLORREF *pColAdd, int nAdd, COLORREF colDef); void OnMeasureItemColorCombo(LPMEASUREITEMSTRUCT pmis); void OnDrawItemColorCombo(LPDRAWITEMSTRUCT pdis, char (*pTexts)[80]); -void ChooseColorWithCombo(HINSTANCE hInst, HWND hDlg, - int idCombo); +BOOL ChooseColorWithCombo(HWND hDlg, int idCombo); void InitFontNameCombo(HWND hDlg, int idCombo, const char* deffont); void InitFontSizeCombo(HWND hDlg, int idCombo, const char *fontname, int charset); diff --git a/source/config.h b/source/config.h index eb981e0..75121c3 100644 --- a/source/config.h +++ b/source/config.h @@ -14,15 +14,17 @@ //-------------------------------------------------------- // optional functions -#define TC_ENABLE_BATTERY 0 -#define TC_ENABLE_CPU 0 -#define TC_ENABLE_ETIME 0 -#define TC_ENABLE_HDD 0 -#define TC_ENABLE_MEMORY 0 -#define TC_ENABLE_NETWORK 0 -#define TC_ENABLE_VOLUME 0 -#define TC_ENABLE_WHEEL 0 -#define TC_ENABLE_DESKTOPICON 0 +#define TC_ENABLE_BATTERY 0 +#define TC_ENABLE_CPU 0 +#define TC_ENABLE_ETIME 0 +#define TC_ENABLE_HDD 0 +#define TC_ENABLE_MEMORY 0 +#define TC_ENABLE_NETWORK 0 +#define TC_ENABLE_VOLUME 0 +#define TC_ENABLE_WHEEL 0 +#define TC_ENABLE_DESKTOPICON 0 +#define TC_ENABLE_CLOCKDECORATION 0 +#define TC_ENABLE_ANALOGCLOCK 0 // Default interval for getting system information: default 4 [sec] #define TC_DEFAULT_INTERVALSYSINFO 4 diff --git a/source/dll/draw.c b/source/dll/draw.c index 113d851..c435ab7 100644 --- a/source/dll/draw.c +++ b/source/dll/draw.c @@ -8,6 +8,7 @@ #include "tcdll.h" #include "newapi.h" +#include /* Globals */ @@ -41,12 +42,44 @@ static BOOL m_fillbackcolor = TRUE; // fill background static COLORREF m_colback, m_colback2, m_colfore; // colors static ULONG m_grad = GRADIENT_FILL_RECT_H; // GradientFill direction static BOOL m_bFillTray; // Paint tray background +#if TC_ENABLE_CLOCKDECORATION +static int m_nClockDecoration; // decoration 0:none 1:shadow 2:border +static COLORREF m_colShadow; // color of shadow or border +static int m_nShadowRange; // +#endif static int m_dwidth = 0, m_dheight = 0; // to add pixels to width and height static int m_dvpos = 0; // to add pixels to vertical position static int m_dlineheight = 0; // to add pixels to line height static int m_nTextPos = 0; // alignment static int m_ClockWidth = -1; // to save clock width +// Analog Clock +#if TC_ENABLE_ANALOGCLOCK +static void LoadAnalogClockSetting(void); +static BOOL InitAnalogClock(HWND hwnd, HDC hdc); +static void ClearAnalogClock(void); +static void DrawAnalogClock(HWND hwnd, HDC hdcClock, const SYSTEMTIME *pt, + int wclock, int hclock); + +static HDC m_hdcAclk, m_hdcBack, m_hdcMask; +static HBITMAP m_hbmAclk, m_hbmBack, m_hbmMask; +static HPEN m_hpenHour, m_hpenMin; +static int m_lastHour = -1, m_lastMin = -1; +static BOOL m_useAnalogClock; +static COLORREF m_colHourHand, m_colMinHand; +static BOOL m_bHourHandBold, m_bMinHandBold; +static int m_nAClockPos; +static int m_nAClockHPos, m_nAClockVPos; +static int m_nAClockSize; +static char m_fname[MAX_PATH]; + +static const COLORREF MASK_COLOR = RGB(0xff, 0x00, 0xff); +static const int ACLOCK_DEFSIZE = 18; + +#define PI_30 0.10471975511965977462 +#define PI_360 0.0087266462599716478846 +#endif /* TC_ENABLE_ANALOGCLOCK */ + /*------------------------------------------------ read settings and initialize @@ -77,6 +110,12 @@ void LoadDrawingSetting(HWND hwnd) m_colfore = GetMyRegLong(NULL, "ForeColor", 0x80000000 | COLOR_BTNTEXT); +#if TC_ENABLE_CLOCKDECORATION + m_nClockDecoration = GetMyRegLong(NULL, "ClockDecoration", 0); + m_colShadow = GetMyRegLong(NULL, "ShadowColor", 0); + m_nShadowRange = GetMyRegLong(NULL, "ShadowRange", 1); +#endif + /* ------- font ------------- */ GetMyRegStr(NULL, "Font", fontname, LF_FACESIZE, ""); @@ -112,6 +151,10 @@ void LoadDrawingSetting(HWND hwnd) g_bFitClock = GetMyRegLong(NULL, "FitClock", TRUE); m_ClockWidth = -1; + +#if TC_ENABLE_ANALOGCLOCK + LoadAnalogClockSetting(); // Analog Clock +#endif } /*------------------------------------------------ @@ -141,6 +184,10 @@ void ClearClockDC(void) m_hdcClockBack = NULL; if(m_hbmpClockBack) DeleteObject(m_hbmpClockBack); m_hbmpClockBack = NULL; + +#if TC_ENABLE_ANALOGCLOCK + ClearAnalogClock(); // Analog Clock +#endif } /*------------------------------------------------ @@ -167,7 +214,7 @@ LRESULT CalcRect(HWND hwnd, int *textwidth, int *textheight) { TEXTMETRIC tm; HDC hdc; - HFONT hOldFont; + HFONT hOldFont = NULL; wchar_t s[BUFSIZE_FORMAT+BUFSIZE_DISP*2]; wchar_t *p; int wclock, hclock; @@ -175,10 +222,6 @@ LRESULT CalcRect(HWND hwnd, int *textwidth, int *textheight) if(!(GetWindowLong(hwnd, GWL_STYLE) & WS_VISIBLE)) return 0; - hdc = GetDC(hwnd); - if(m_hFont) hOldFont = SelectObject(hdc, m_hFont); - GetTextMetrics(hdc, &tm); - if(g_sdisp2[0]) wcscpy(s, g_sdisp2); else if(g_sdisp1[0]) wcscpy(s, g_sdisp1); else MakeFormat(s, NULL, NULL, BUFSIZE_FORMAT); @@ -196,12 +239,35 @@ LRESULT CalcRect(HWND hwnd, int *textwidth, int *textheight) ++p; } + hdc = GetDC(hwnd); + if(m_hFont) hOldFont = SelectObject(hdc, m_hFont); + GetTextMetrics(hdc, &tm); + GetClockTextSize(hdc, &tm, s, &wclock, &hclock); + + if(hOldFont) SelectObject(hdc, hOldFont); + ReleaseDC(hwnd, hdc); + if(textwidth != NULL) *textwidth = wclock; if(textheight != NULL) *textheight = hclock; wclock += tm.tmAveCharWidth * 2 + m_dwidth; hclock += (tm.tmHeight - tm.tmInternalLeading) / 2 + m_dheight; + +#if TC_ENABLE_CLOCKDECORATION + if (m_nClockDecoration == 1) + { + wclock += m_nShadowRange; + hclock += m_nShadowRange; + } +#endif +#if TC_ENABLE_ANALOGCLOCK + if (m_useAnalogClock && (m_nAClockPos == 1 || m_nAClockPos == 2)) + { + wclock += m_nAClockSize; + } +#endif + if(hclock < 4) hclock = 4; if(wclock > m_ClockWidth) m_ClockWidth = wclock; @@ -224,9 +290,6 @@ LRESULT CalcRect(HWND hwnd, int *textwidth, int *textheight) wclock = rcTray.right - rcTray.left; } - if(m_hFont) SelectObject(hdc, hOldFont); - ReleaseDC(hwnd, hdc); - return MAKELONG(wclock, hclock); } @@ -290,6 +353,10 @@ void CreateClockDC(HWND hwnd) } FillClock(hwnd, m_hdcClockBack, &rc); +#if TC_ENABLE_ANALOGCLOCK + InitAnalogClock(hwnd, hdc); // Analog Clock +#endif + ReleaseDC(NULL, hdc); } @@ -334,16 +401,22 @@ void DrawClock(HWND hwnd, HDC hdc, const SYSTEMTIME* pt) TEXTMETRIC tm; int x, y, wclock, hclock, wtext, htext; int len; + int sha = 0, ana = 0; wchar_t s[BUFSIZE_FORMAT+BUFSIZE_DISP*2], *p, *sp, *ep; DWORD dwRop = SRCCOPY; COLORREF textcolor = 0; BOOL aero = FALSE; +#if TC_ENABLE_CLOCKDECORATION + COLORREF colText, colShadow; +#endif DWORD size; - if(!m_hdcClock) CreateClockDC(hwnd); - - if(!m_hdcClock) return; + if(!m_hdcClock) + { + CreateClockDC(hwnd); + if(!m_hdcClock) return; + } GetClientRect(hwnd, &rcClock); wclock = rcClock.right; @@ -394,18 +467,40 @@ void DrawClock(HWND hwnd, HDC hdc, const SYSTEMTIME* pt) wcscat(s, g_scat2); } - GetTextMetrics(m_hdcClock, &tm); +#if TC_ENABLE_CLOCKDECORATION + switch(m_nClockDecoration) + { + case 1: // shadow + sha = m_nShadowRange; + // fall-through + case 2: // shadow, border + colShadow = (m_colShadow & 0x80000000) ? + GetSysColor(m_colShadow & 0x00ffffff) : m_colShadow; + colText = GetTextColor(m_hdcClock); + break; + } +#endif + +#if TC_ENABLE_ANALOGCLOCK + if(m_useAnalogClock) + { + if(m_nAClockPos == 1 && m_nTextPos != 2) + ana = m_nAClockSize; + else if(m_nAClockPos == 2 && m_nTextPos != 1) + ana = -m_nAClockSize; + } +#endif - //GetClockTextSize(m_hdcClock, &tm, s, &wtext, &htext); + GetTextMetrics(m_hdcClock, &tm); - y = (hclock - htext)/2 - tm.tmInternalLeading/2 + m_dvpos; + y = (hclock - htext - tm.tmInternalLeading - sha) / 2 + m_dvpos; if(m_nTextPos == 1) - x = (tm.tmAveCharWidth * 2) / 3; + x = ana + (tm.tmAveCharWidth * 2) / 3; else if(m_nTextPos == 2) - x = wclock - (tm.tmAveCharWidth * 2) / 3; + x = wclock - sha + ana - (tm.tmAveCharWidth * 2) / 3; else - x = wclock / 2; + x = (wclock - sha + ana) / 2; p = s; while(*p) @@ -414,12 +509,40 @@ void DrawClock(HWND hwnd, HDC hdc, const SYSTEMTIME* pt) while(*p && *p != 0x0d) p++; ep = p; if(*p == 0x0d) p += 2; + +#if TC_ENABLE_CLOCKDECORATION + switch(m_nClockDecoration) + { + case 1: // shadow + SetTextColor(m_hdcClock, colShadow); + TextOutW(m_hdcClock, + x + m_nShadowRange, y + m_nShadowRange, sp, (int)(ep - sp)); + SetTextColor(m_hdcClock, colText); + break; + case 2: // border + SetTextColor(m_hdcClock, colShadow); + TextOutW(m_hdcClock, x - 1, y - 1, sp, (int)(ep - sp)); + TextOutW(m_hdcClock, x , y - 1, sp, (int)(ep - sp)); + TextOutW(m_hdcClock, x + 1, y - 1, sp, (int)(ep - sp)); + TextOutW(m_hdcClock, x - 1, y , sp, (int)(ep - sp)); + TextOutW(m_hdcClock, x + 1, y , sp, (int)(ep - sp)); + TextOutW(m_hdcClock, x - 1, y + 1, sp, (int)(ep - sp)); + TextOutW(m_hdcClock, x , y + 1, sp, (int)(ep - sp)); + TextOutW(m_hdcClock, x + 1, y + 1, sp, (int)(ep - sp)); + SetTextColor(m_hdcClock, colText); + break; + } +#endif TextOutW(m_hdcClock, x, y, sp, (int)(ep - sp)); if(*p) y += tm.tmHeight - tm.tmInternalLeading + 2 + m_dlineheight; } +#if TC_ENABLE_ANALOGCLOCK + DrawAnalogClock(hwnd, m_hdcClock, pt, wclock, hclock); // ANALOGCLOCK +#endif + // if(g_nBlink > 0 && (g_nBlink % 2) == 0) dwRop = NOTSRCCOPY; if(!m_fillbackcolor && (dwRop == SRCCOPY) && aero) @@ -531,3 +654,199 @@ void GradientFillClock(HDC hdc, const RECT* prc, MyGradientFill(hdc, vert, 2, &gRect, 1, grad); } + +#if TC_ENABLE_ANALOGCLOCK +/*------------------------------------------------ + Analog Clock +--------------------------------------------------*/ +void LoadAnalogClockSetting(void) +{ + const char *section = "AnalogClock"; + + m_useAnalogClock = GetMyRegLong(section, "UseAnalogClock", FALSE); + + m_colHourHand = GetMyRegLong(section, "HourHandColor", 0); + m_colMinHand = GetMyRegLong(section, "MinHandColor", 0); + m_bHourHandBold = GetMyRegLong(section, "HourHandBold", 0); + m_bMinHandBold = GetMyRegLong(section, "MinHandBold", 0); + + m_nAClockPos = GetMyRegLong(section, "AnalogClockPos", 0); + m_nAClockHPos = GetMyRegLong(section, "HorizontalPos", 0); + m_nAClockVPos = GetMyRegLong(section, "VerticalPos", 0); + m_nAClockSize = GetMyRegLong(section, "Size", 0); + + GetMyRegStr(section, "Bitmap", m_fname, MAX_PATH, ""); +} + +BOOL InitAnalogClock(HWND hwnd, HDC hdc) +{ + if (!m_useAnalogClock) return FALSE; + + ClearAnalogClock(); + + // load background + if (m_fname[0]) { + char fname2[MAX_PATH]; + + RelToAbs(fname2, m_fname); + m_hbmAclk = (HBITMAP)LoadImage(NULL, fname2, IMAGE_BITMAP, + 0, 0, LR_LOADFROMFILE); + + if (m_hbmAclk) { + int x, y, size; + + if (GetBmpSize(m_hbmAclk, &x, &y)) // dllutl.c + size = (x < y) ? x : y; + else + size = -1; + if (m_nAClockSize == 0) + m_nAClockSize = (size > 0) ? size : ACLOCK_DEFSIZE; + + CreateOffScreenDC(hdc, &m_hdcBack, &m_hbmBack, + m_nAClockSize, m_nAClockSize); + m_hdcAclk = CreateCompatibleDC(hdc); + SelectObject(m_hdcAclk, m_hbmAclk); + + if (m_nAClockSize == size) { + BitBlt(m_hdcBack, 0, 0, m_nAClockSize, m_nAClockSize, + m_hdcAclk, 0, 0, SRCCOPY); + } else { + StretchBlt(m_hdcBack, 0, 0, m_nAClockSize, m_nAClockSize, + m_hdcAclk, 0, 0, size, size, SRCCOPY); + } + + DeleteDC(m_hdcAclk); + DeleteObject(m_hbmAclk); + } + } + + if (m_nAClockSize == 0) m_nAClockSize = ACLOCK_DEFSIZE; + + if (!m_hdcBack) { +// const int center = (m_nAClockSize - 1) / 2; + RECT rc; + HBRUSH hBrush; + + CreateOffScreenDC(hdc, &m_hdcBack, &m_hbmBack, + m_nAClockSize, m_nAClockSize); + rc.left = rc.top = 0; + rc.right = rc.bottom = m_nAClockSize; + hBrush = CreateSolidBrush(MASK_COLOR); + FillRect(m_hdcBack, &rc, hBrush); + DeleteObject(hBrush); +// SetPixel(m_hdcBack, center, center, 0); + } + + CreateOffScreenDC(hdc, &m_hdcAclk, &m_hbmAclk, + m_nAClockSize, m_nAClockSize); + + m_hdcMask = CreateCompatibleDC(hdc); + m_hbmMask = CreateBitmap(m_nAClockSize, m_nAClockSize, 1, 1, NULL); + SelectObject(m_hdcMask, m_hbmMask); + + m_hpenHour = CreatePen(PS_SOLID, m_bHourHandBold ? 2 : 1, m_colHourHand); + m_hpenMin = CreatePen(PS_SOLID, m_bMinHandBold ? 2 : 1, m_colMinHand); + + if (m_hdcAclk && m_hbmAclk && m_hdcBack && m_hbmBack + && m_hdcMask && m_hbmMask && m_hpenHour && m_hpenMin) { + return TRUE; + } else { + ClearAnalogClock(); + return FALSE; + } +} + +void ClearAnalogClock(void) +{ + if (m_hdcAclk) { DeleteDC(m_hdcAclk); m_hdcAclk = NULL; } + if (m_hbmAclk) { DeleteObject(m_hbmAclk); m_hbmAclk = NULL; } + + if (m_hdcBack) { DeleteDC(m_hdcBack); m_hdcBack = NULL; } + if (m_hbmBack) { DeleteObject(m_hbmBack); m_hbmBack = NULL; } + + if (m_hdcMask) { DeleteDC(m_hdcMask); m_hdcMask = NULL; } + if (m_hbmMask) { DeleteObject(m_hbmMask); m_hbmMask = NULL; } + + if (m_hpenHour) { DeleteObject(m_hpenHour); m_hpenHour = NULL; } + if (m_hpenMin) { DeleteObject(m_hpenMin); m_hpenMin = NULL; } + + m_lastHour = -1; + m_lastMin = -1; +} + +void DrawAnalogClock(HWND hwnd, HDC hdcClock, const SYSTEMTIME *pt, + int wclock, int hclock) +{ + static int x, y; + SYSTEMTIME st; + COLORREF col; + + if (!m_useAnalogClock) return; + + if (!m_hdcAclk && !InitAnalogClock(hwnd, hdcClock)) return; + + if (pt) memcpy(&st, pt, sizeof (SYSTEMTIME)); + else GetLocalTime(&st); + + if (st.wMinute != m_lastMin || st.wHour != m_lastHour) { + const int center = (m_nAClockSize - 1) / 2; + POINT ptHour, ptMin; + + m_lastHour = st.wHour; + m_lastMin = st.wMinute; + + // calculate hands' pos + ptHour.x = 0.5 + center + + sin((m_lastHour * 60 + m_lastMin) * PI_360) * center * 0.7; + ptHour.y = 0.5 + center + - cos((m_lastHour * 60 + m_lastMin) * PI_360) * center * 0.7; + ptMin.x = 0.5 + center + sin(m_lastMin * PI_30) * center; + ptMin.y = 0.5 + center - cos(m_lastMin * PI_30) * center; + + // draw hands + BitBlt(m_hdcAclk, 0, 0, m_nAClockSize, m_nAClockSize, + m_hdcBack, 0, 0, SRCCOPY); + + SelectObject(m_hdcAclk, m_hpenHour); + MoveToEx(m_hdcAclk, center, center, NULL); + LineTo(m_hdcAclk, ptHour.x, ptHour.y); +/* MoveToEx(m_hdcAclk, ptHour.x, ptHour.y, NULL); + LineTo(m_hdcAclk, center, center);*/ + SelectObject(m_hdcAclk, m_hpenMin); + MoveToEx(m_hdcAclk, center, center, NULL); + LineTo(m_hdcAclk, ptMin.x, ptMin.y); +/* MoveToEx(m_hdcAclk, ptMin.x, ptMin.y, NULL); + LineTo(m_hdcAclk, center, center);*/ + + // make mask + col = SetBkColor(m_hdcAclk, MASK_COLOR); + BitBlt(m_hdcMask, 0, 0, m_nAClockSize, m_nAClockSize, + m_hdcAclk, 0, 0, SRCCOPY); + SetBkColor(m_hdcAclk, col); + BitBlt(m_hdcAclk, 0, 0, m_nAClockSize, m_nAClockSize, + m_hdcMask, 0, 0, 0x220326); // dest = (NOT source) AND dest + +/* col = SetBkColor(m_hdcAclk, MASK_COLOR); + BitBlt(m_hdcMask, 0, 0, m_nAClockSize, m_nAClockSize, + m_hdcAclk, 0, 0, NOTSRCCOPY); + SetBkColor(m_hdcAclk, col); + BitBlt(m_hdcAclk, 0, 0, m_nAClockSize, m_nAClockSize, + m_hdcMask, 0, 0, SRCAND); + BitBlt(m_hdcMask, 0, 0, m_nAClockSize, m_nAClockSize, + m_hdcAclk, 0, 0, DSTINVERT); +*/ + if (m_nAClockPos == 2) + x = wclock - 1 - m_nAClockSize + m_nAClockHPos; + else + x = m_nAClockHPos; + y = (hclock - m_nAClockSize) / 2 + m_nAClockVPos; + } + + col = SetTextColor(hdcClock, 0); + BitBlt(hdcClock, x, y, m_nAClockSize, m_nAClockSize, + m_hdcMask, 0, 0, SRCAND); + BitBlt(hdcClock, x, y, m_nAClockSize, m_nAClockSize, + m_hdcAclk, 0, 0, SRCPAINT); + SetTextColor(hdcClock, col); +} +#endif /* TC_ENABLE_ANALOGCLOCK */ diff --git a/source/dll/tooltip.c b/source/dll/tooltip.c index c1ac855..8e64105 100644 --- a/source/dll/tooltip.c +++ b/source/dll/tooltip.c @@ -28,9 +28,9 @@ void PopupTooltip(HWND hwndClock, const wchar_t *p); /* Statics */ -void InitTooltipFormat(void); -void ReadTooltipFormatFromFile(const char *fname, BOOL bInit); -LRESULT CALLBACK WndProcTip(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +static void InitTooltipFormat(void); +static void ReadTooltipFormatFromFile(const char *fname, BOOL bInit); +static LRESULT CALLBACK WndProcTip(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static HWND m_hwndTip = NULL; static WNDPROC m_oldWndProc = NULL; @@ -188,10 +188,10 @@ void ReadTooltipFormatFromFile(const char *fname, BOOL bInit) size2 = MultiByteToWideChar(CP_ACP, 0, temp, -1, NULL, 0); - m_format = malloc(sizeof(wchar_t) * (size2 + 1)); + m_format = malloc(sizeof(wchar_t) * size2); MultiByteToWideChar(CP_ACP, 0, temp, -1, m_format, size2); - free(temp); + free(temp); } /*------------------------------------------------ @@ -199,15 +199,16 @@ void ReadTooltipFormatFromFile(const char *fname, BOOL bInit) --------------------------------------------------*/ void EndTooltip(HWND hwndClock) { - DestroyWindow(m_hwndTip); + if(m_hwndTip) { DestroyWindow(m_hwndTip); m_hwndTip = NULL; } - if(m_format) free(m_format); m_format = NULL; - if(m_format_temp) free(m_format_temp); m_format_temp = NULL; - if(m_textToolTip) free(m_textToolTip); m_textToolTip = NULL; + if(m_format) { free(m_format); m_format = NULL; } + if(m_format_temp) { free(m_format_temp); m_format_temp = NULL; } + if(m_textToolTip) { free(m_textToolTip); m_textToolTip = NULL; } m_textlen = 0; - if(m_hFont) DeleteObject(m_hFont); - m_hFont = NULL; + m_bTrackActive = FALSE; + + if(m_hFont) { DeleteObject(m_hFont); m_hFont = NULL; } } /*------------------------------------------------ diff --git a/source/property/main.c b/source/property/main.c index 0eaaebf..0151a83 100644 --- a/source/property/main.c +++ b/source/property/main.c @@ -48,6 +48,9 @@ static int m_lastTreeItem; enum { PAGE_COLOR, PAGE_SIZE, PAGE_FORMAT, +#if TC_ENABLE_ANALOGCLOCK + PAGE_ANALOGCLOCK, +#endif PAGE_ALARM, PAGE_CUCKOO, PAGE_MOUSE, #if TC_ENABLE_MOUSEDROP @@ -79,6 +82,9 @@ static struct { { NULL, IDD_PAGECOLOR, PageColorProc }, /* PAGE_COLOR */ { NULL, IDD_PAGESIZE, PageSizeProc }, /* PAGE_SIZE */ { NULL, IDD_PAGEFORMAT, PageFormatProc }, /* PAGE_FORMAT */ +#if TC_ENABLE_ANALOGCLOCK + { NULL, IDD_PAGEANALOGCLOCK, PageAnalogClockProc }, /* PAGE_ANALOGCLOCK */ +#endif { NULL, IDD_PAGEALARM, PageAlarmProc }, /* PAGE_ALARM */ { NULL, IDD_PAGECUCKOO, PageCuckooProc }, /* PAGE_CUCKOO */ { NULL, IDD_PAGEMOUSE, PageMouseProc }, /* PAGE_MOUSE */ @@ -105,6 +111,9 @@ static struct { enum { ITEM_PARENTCLOCK, ITEM_COLOR, ITEM_SIZE, ITEM_FORMAT, +#if TC_ENABLE_ANALOGCLOCK + ITEM_ANALOGCLOCK, +#endif ITEM_PARENTALARM, ITEM_ALARM, ITEM_CUCKOO, ITEM_PARENTMOUSE, ITEM_CLICK, #if TC_ENABLE_MOUSEDROP @@ -144,6 +153,10 @@ static struct { IDS_SIZEPOS, "SizePos", PAGE_SIZE }, { ITEM_PARENTCLOCK, /* ITEM_FORMAT */ IDS_FORMAT, "Format", PAGE_FORMAT }, +#if TC_ENABLE_ANALOGCLOCK + { ITEM_PARENTCLOCK, /* ITEM_ANALOGCLOCK */ + IDS_ANALOGCLOCK, "AnalogClock", PAGE_ANALOGCLOCK }, +#endif /* ITEM_PARENTALARM */ { -1, IDS_ALARM, "Alarm", PAGE_ALARM }, @@ -153,7 +166,7 @@ static struct { IDS_CUCKOO, "Cuckoo", PAGE_CUCKOO }, /* ITEM_PARENTMOUSE */ - { -1, IDS_MOUSE, "Mouse", PAGE_MOUSE }, + { -1, IDS_MOUSE, "Mouse", PAGE_MOUSE }, { ITEM_PARENTMOUSE, /* ITEM_CLICK */ IDS_CLICK, "Click", PAGE_MOUSE }, #if TC_ENABLE_MOUSEDROP @@ -302,7 +315,7 @@ INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, if(g_hfontDialog) DeleteObject(g_hfontDialog); SetMyRegLong(NULL, "LastTreeItem", m_lastTreeItem); - EndDialog(hDlg, LOWORD(wParam)); + EndDialog(hDlg, id); break; } return TRUE; diff --git a/source/property/pageanalog.c b/source/property/pageanalog.c new file mode 100644 index 0000000..8d33cc9 --- /dev/null +++ b/source/property/pageanalog.c @@ -0,0 +1,268 @@ +/*------------------------------------------------------------- + pageanalog.c : "Analog Clock" page of properties + (C) Kazuto Sato 1997-2003 + For the license, please read readme.txt. + + Written by Kazubon, Nanashi-san +---------------------------------------------------------------*/ + +#include "tcprop.h" + +#if TC_ENABLE_ANALOGCLOCK + +/* Globals */ + +INT_PTR CALLBACK PageAnalogClockProc(HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam); + +/* Statics */ + +static void SendPSChanged(HWND hDlg); +static void OnInit(HWND hDlg); +static void OnApply(HWND hDlg); +static void OnAnalogClock(HWND hDlg); +static void InitColor(HWND hDlg); +static void OnDrawItem(HWND hDlg, LPDRAWITEMSTRUCT pdis); +static void OnChooseColor(HWND hDlg, int id); +static void OnBrowse(HWND hDlg); + +static const char *m_section = "AnalogClock"; +static BOOL m_bInit = FALSE; +static BOOL m_bChanged = FALSE; + +/*------------------------------------------------ + dialog procedure of this page +--------------------------------------------------*/ +INT_PTR CALLBACK PageAnalogClockProc(HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_INITDIALOG: + OnInit(hDlg); + return TRUE; + case WM_COMMAND: + { + WORD id, code; + id = LOWORD(wParam); code = HIWORD(wParam); + switch(id) + { + case IDC_ANALOGCLOCK: + OnAnalogClock(hDlg); + SendPSChanged(hDlg); + break; + case IDC_COLHOUR: + case IDC_COLMIN: + if (code == CBN_SELCHANGE) + SendPSChanged(hDlg); + break; + case IDC_CHOOSECOLHOUR: + case IDC_CHOOSECOLMIN: + OnChooseColor(hDlg, id); + break; + case IDC_HOURHANDBOLD: + case IDC_MINHANDBOLD: + case IDC_ANALOGPOSLEFT: + case IDC_ANALOGPOSRIGHT: + case IDC_ANALOGPOSMIDDLE: + SendPSChanged(hDlg); + break; + case IDC_ANALOGHPOS: + case IDC_ANALOGVPOS: + case IDC_ANALOGSIZE: + case IDC_ANALOGBMP: + if (code == EN_CHANGE) + SendPSChanged(hDlg); + break; + case IDC_ANALOGBMPBROWSE: + OnBrowse(hDlg); + break; + } + return TRUE; + } + case WM_DRAWITEM: + OnDrawItem(hDlg, (LPDRAWITEMSTRUCT)lParam); + return TRUE; + case WM_MEASUREITEM: + // common/comobox.c + OnMeasureItemColorCombo((LPMEASUREITEMSTRUCT)lParam); + return TRUE; + case WM_NOTIFY: + switch(((NMHDR *)lParam)->code) + { + case PSN_APPLY: OnApply(hDlg); break; + case PSN_HELP: MyHelp(GetParent(hDlg), "AnalogClock"); break; + } + return TRUE; + } + return FALSE; +} + +/*------------------------------------------------ + notify parent window to enable "Apply" button +--------------------------------------------------*/ +void SendPSChanged(HWND hDlg) +{ + if(m_bInit) + { + g_bApplyClock = TRUE; + m_bChanged = TRUE; + SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)(hDlg), 0); + } +} + +/*------------------------------------------------ + initialize +--------------------------------------------------*/ +void OnInit(HWND hDlg) +{ + char s[MAX_PATH]; + + m_bInit = FALSE; + + // common/tclang.c + SetDialogLanguage(hDlg, "AnalogClock", g_hfontDialog); + + CheckDlgButton(hDlg, IDC_ANALOGCLOCK, + GetMyRegLong(m_section, "UseAnalogClock", FALSE)); + + OnAnalogClock(hDlg); + + InitColor(hDlg); + + CheckDlgButton(hDlg, IDC_HOURHANDBOLD, + GetMyRegLong(m_section, "HourHandBold", FALSE)); + CheckDlgButton(hDlg, IDC_MINHANDBOLD, + GetMyRegLong(m_section, "MinHandBold", FALSE)); + + CheckRadioButton(hDlg, IDC_ANALOGPOSMIDDLE, IDC_ANALOGPOSRIGHT, + GetMyRegLong(m_section, "AnalogClockPos", 0) + IDC_ANALOGPOSMIDDLE); + + UpDown_SetBuddy(hDlg, IDC_ANALOGHPOSSPIN, IDC_ANALOGHPOS); + UpDown_SetRange(hDlg, IDC_ANALOGHPOSSPIN, 999, -999); + UpDown_SetPos(hDlg, IDC_ANALOGHPOSSPIN, + GetMyRegLong(m_section, "HorizontalPos", 0)); + UpDown_SetBuddy(hDlg, IDC_ANALOGVPOSSPIN, IDC_ANALOGVPOS); + UpDown_SetRange(hDlg, IDC_ANALOGVPOSSPIN, 999, -999); + UpDown_SetPos(hDlg, IDC_ANALOGVPOSSPIN, + GetMyRegLong(m_section, "VerticalPos", 0)); + + UpDown_SetBuddy(hDlg, IDC_ANALOGSIZESPIN, IDC_ANALOGSIZE); + UpDown_SetRange(hDlg, IDC_ANALOGSIZESPIN, 99, 0); + UpDown_SetPos(hDlg, IDC_ANALOGSIZESPIN, + GetMyRegLong(m_section, "Size", 0)); + + GetMyRegStr(m_section, "Bitmap", s, MAX_PATH, ""); + SetDlgItemText(hDlg, IDC_ANALOGBMP, s); + + m_bInit = TRUE; +} + +/*------------------------------------------------ + Apply changes +--------------------------------------------------*/ +void OnApply(HWND hDlg) +{ + int i; + char s[MAX_PATH]; + + if(!m_bChanged) return; + m_bChanged = FALSE; + + SetMyRegLong(m_section, "UseAnalogClock", + IsDlgButtonChecked(hDlg, IDC_ANALOGCLOCK)); + + SetMyRegLong(m_section, "HourHandColor", + CBGetItemData(hDlg, IDC_COLHOUR, CBGetCurSel(hDlg, IDC_COLHOUR))); + SetMyRegLong(m_section, "MinHandColor", + CBGetItemData(hDlg, IDC_COLMIN, CBGetCurSel(hDlg, IDC_COLMIN))); + + SetMyRegLong(m_section, "HourHandBold", + IsDlgButtonChecked(hDlg, IDC_HOURHANDBOLD)); + SetMyRegLong(m_section, "MinHandBold", + IsDlgButtonChecked(hDlg, IDC_MINHANDBOLD)); + + if (IsDlgButtonChecked(hDlg, IDC_ANALOGPOSLEFT)) i = 1; + else if (IsDlgButtonChecked(hDlg, IDC_ANALOGPOSRIGHT)) i = 2; + else i = 0; + SetMyRegLong(m_section, "AnalogClockPos", i); + + SetMyRegLong(m_section, "HorizontalPos", + UpDown_GetPos(hDlg,IDC_ANALOGHPOSSPIN)); + SetMyRegLong(m_section, "VerticalPos", + UpDown_GetPos(hDlg,IDC_ANALOGVPOSSPIN)); + + SetMyRegLong(m_section, "Size", + UpDown_GetPos(hDlg,IDC_ANALOGSIZESPIN)); + + GetDlgItemText(hDlg, IDC_ANALOGBMP, s, MAX_PATH); + SetMyRegStr(m_section, "Bitmap", s); +} + +/*------------------------------------------------ + initizlize "Color" comoboxes +--------------------------------------------------*/ +void InitColor(HWND hDlg) +{ + InitColorCombo(hDlg, IDC_COLHOUR, NULL, 0, + GetMyRegLong(m_section, "HourHandColor", 0)); + + InitColorCombo(hDlg, IDC_COLMIN, NULL, 0, + GetMyRegLong(m_section, "MinHandColor", 0)); +} + +/*------------------------------------------------ + WM_DRAWITEM message +--------------------------------------------------*/ +void OnDrawItem(HWND hDlg, LPDRAWITEMSTRUCT pdis) +{ + // common/comobox.c + OnDrawItemColorCombo(pdis, NULL); +} + +/*------------------------------------------------ + "Display analog clock" is checked +--------------------------------------------------*/ +void OnAnalogClock(HWND hDlg) +{ + BOOL b = IsDlgButtonChecked(hDlg, IDC_ANALOGCLOCK); + HWND hwnd = GetDlgItem(hDlg, IDC_ANALOGCLOCK); + + while ((hwnd = GetWindow(hwnd, GW_HWNDNEXT)) != NULL) + EnableWindow(hwnd, b); +} + +/*------------------------------------------------ + "..." button : choose color +--------------------------------------------------*/ +void OnChooseColor(HWND hDlg, int id) +{ + int idCombo = id - 1; + + // common/combobox.c + if(ChooseColorWithCombo(hDlg, idCombo)) + { + PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); + SendPSChanged(hDlg); + } +} + +/*------------------------------------------------ + browse bitmap file +--------------------------------------------------*/ +void OnBrowse(HWND hDlg) +{ + char deffile[MAX_PATH], fname[MAX_PATH]; + char *filter = "Bitmap (*.bmp)\0*.bmp\0\0"; + + GetDlgItemText(hDlg, IDC_ANALOGBMP, deffile, MAX_PATH); + + // select file : common/selectfile.c + if(SelectMyFile(g_hInst, hDlg, filter, 0, deffile, fname)) + { + SetDlgItemText(hDlg, IDC_ANALOGBMP, fname); + PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); + SendPSChanged(hDlg); + } +} +#endif /* TC_ENABLE_ANALOGCLOCK */ diff --git a/source/property/pagecolor.c b/source/property/pagecolor.c index 4570fcc..adb7a8a 100644 --- a/source/property/pagecolor.c +++ b/source/property/pagecolor.c @@ -21,6 +21,9 @@ static void OnApply(HWND hDlg); static void InitColor(HWND hDlg); static void OnDrawItem(HWND hDlg, LPDRAWITEMSTRUCT pdis); static void OnChooseColor(HWND hDlg, int id); +#if TC_ENABLE_CLOCKDECORATION +static void OnSelectDecoration(HWND hDlg); +#endif static void OnCheckColor(HWND hDlg); static void InitFont(HWND hDlg); static void OnFont(HWND hDlg, int bInit); @@ -50,6 +53,9 @@ INT_PTR CALLBACK PageColorProc(HWND hDlg, UINT message, case IDC_COLBACK: case IDC_COLBACK2: case IDC_COLFORE: +#if TC_ENABLE_CLOCKDECORATION + case IDC_COLSHADOW: +#endif case IDC_FONT: case IDC_FONTSIZE: if(code == CBN_SELCHANGE || code == CBN_EDITCHANGE) @@ -66,8 +72,23 @@ INT_PTR CALLBACK PageColorProc(HWND hDlg, UINT message, case IDC_CHOOSECOLBACK: case IDC_CHOOSECOLBACK2: case IDC_CHOOSECOLFORE: +#if TC_ENABLE_CLOCKDECORATION + case IDC_CHOOSECOLSHADOW: +#endif OnChooseColor(hDlg, id); break; +#if TC_ENABLE_CLOCKDECORATION + case IDC_DECONONE: + case IDC_DECOSHADOW: + case IDC_DECOBORDER: + OnSelectDecoration(hDlg); + SendPSChanged(hDlg); + break; + case IDC_SHADOWRANGE: + if (code == EN_CHANGE) + SendPSChanged(hDlg); + break; +#endif case IDC_GRAD1: case IDC_GRAD2: case IDC_FILLTRAY: @@ -135,15 +156,26 @@ void OnInit(HWND hDlg) GetMyRegLong(NULL, "UseBackColor2", FALSE)); CheckRadioButton(hDlg, IDC_GRAD1, IDC_GRAD2, - (GetMyRegLong(NULL, "GradDir", FALSE) == 0) ? IDC_GRAD1 : IDC_GRAD2); - - OnCheckColor(hDlg); + (GetMyRegLong(NULL, "GradDir", 0) == 0) ? IDC_GRAD1 : IDC_GRAD2); CheckDlgButton(hDlg, IDC_FILLTRAY, GetMyRegLong(NULL, "FillTray", FALSE)); EnableDlgItem(hDlg, IDC_FILLTRAY, IsDlgButtonChecked(hDlg, IDC_CHKCOLOR)); + OnCheckColor(hDlg); + +#if TC_ENABLE_CLOCKDECORATION + // settings for decoration + CheckRadioButton(hDlg, IDC_DECONONE, IDC_DECOBORDER, + GetMyRegLong(NULL, "ClockDecoration", 0) + IDC_DECONONE); + OnSelectDecoration(hDlg); + UpDown_SetBuddy(hDlg, IDC_SHADOWRANGESPIN, IDC_SHADOWRANGE); + UpDown_SetRange(hDlg, IDC_SHADOWRANGESPIN, 10, 1); + UpDown_SetPos(hDlg, IDC_SHADOWRANGESPIN, + GetMyRegLong(NULL, "ShadowRange", 1)); +#endif + // settings of "font" and "font size" InitFont(hDlg); @@ -181,6 +213,9 @@ void OnInit(HWND hDlg) void OnApply(HWND hDlg) { char s[80]; +#if TC_ENABLE_CLOCKDECORATION + int i; +#endif // settings of "background" and "text" @@ -203,9 +238,21 @@ void OnApply(HWND hDlg) SetMyRegLong(NULL, "FillTray", IsDlgButtonChecked(hDlg, IDC_FILLTRAY)); - SetMyRegLong(NULL, "ForeColor", + SetMyRegLong(NULL, "ForeColor", CBGetItemData(hDlg, IDC_COLFORE, CBGetCurSel(hDlg, IDC_COLFORE))); +#if TC_ENABLE_CLOCKDECORATION + // settings of decoration + if (IsDlgButtonChecked(hDlg, IDC_DECOSHADOW)) i = 1; + else if (IsDlgButtonChecked(hDlg, IDC_DECOBORDER)) i = 2; + else i = 0; + SetMyRegLong(NULL, "ClockDecoration", i); + SetMyRegLong(NULL, "ShadowColor", + CBGetItemData(hDlg, IDC_COLSHADOW, CBGetCurSel(hDlg, IDC_COLSHADOW))); + SetMyRegLong(NULL, "ShadowRange", + UpDown_GetPos(hDlg,IDC_SHADOWRANGESPIN)); +#endif + // settings of "font" and "font size" CBGetLBText(hDlg, IDC_FONT, CBGetCurSel(hDlg, IDC_FONT), s); @@ -250,8 +297,35 @@ void OnCheckColor(HWND hDlg) EnableDlgItem(hDlg, IDC_FILLTRAY, b1); } +#if TC_ENABLE_CLOCKDECORATION +/*--------------------------------------------------- + enable/disable to use +-----------------------------------------------------*/ +void OnSelectDecoration(HWND hDlg) +{ + BOOL b; + HWND hwnd; + + b = !IsDlgButtonChecked(hDlg, IDC_DECONONE); + hwnd = GetDlgItem(hDlg, IDC_DECOBORDER); + while ((hwnd = GetWindow(hwnd, GW_HWNDNEXT)) != NULL) + { + EnableWindow(hwnd, b); + if (GetDlgCtrlID(hwnd) == IDC_CHOOSECOLSHADOW) break; + } + + b = IsDlgButtonChecked(hDlg, IDC_DECOSHADOW); + hwnd = GetDlgItem(hDlg, IDC_CHOOSECOLSHADOW); + while ((hwnd = GetWindow(hwnd, GW_HWNDNEXT)) != NULL) + { + EnableWindow(hwnd, b); + if (GetDlgCtrlID(hwnd) == IDC_SHADOWRANGESPIN) break; + } +} +#endif /* TC_ENABLE_CLOCKDECORATION */ + /*------------------------------------------------ - initizlize "Color" comoboxes + initialize "Color" comoboxes --------------------------------------------------*/ void InitColor(HWND hDlg) { @@ -272,6 +346,9 @@ void InitColor(HWND hDlg) colDef = GetMyRegLong("", "ForeColor", 0x80000000 | COLOR_BTNTEXT); InitColorCombo(hDlg, IDC_COLFORE, cols, 4, colDef); + + colDef = GetMyRegLong("", "ShadowColor", 0); + InitColorCombo(hDlg, IDC_COLSHADOW, cols, 4, colDef); } /*------------------------------------------------ @@ -297,10 +374,11 @@ void OnChooseColor(HWND hDlg, int id) int idCombo = id - 1; // common/combobox.c - ChooseColorWithCombo(g_hInst, hDlg, idCombo); - - PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); - SendPSChanged(hDlg); + if(ChooseColorWithCombo(hDlg, idCombo)) + { + PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); + SendPSChanged(hDlg); + } } /*------------------------------------------------ diff --git a/source/property/pagestartbtn.c b/source/property/pagestartbtn.c index e96b5f7..ef5b9fe 100644 --- a/source/property/pagestartbtn.c +++ b/source/property/pagestartbtn.c @@ -446,10 +446,11 @@ void OnSansho(HWND hDlg) void OnChooseColor(HWND hDlg) { // common/combobox.c - ChooseColorWithCombo(g_hInst, hDlg, IDC_STARTBTNCOL); - - PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); - SendPSChanged(hDlg); + if(ChooseColorWithCombo(hDlg, IDC_STARTBTNCOL)) + { + PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); + SendPSChanged(hDlg); + } } /*------------------------------------------------ diff --git a/source/property/pagestartmenu.c b/source/property/pagestartmenu.c index cd22692..05a6ddc 100644 --- a/source/property/pagestartmenu.c +++ b/source/property/pagestartmenu.c @@ -244,7 +244,7 @@ void OnBrowse(HWND hDlg) void OnChooseColor(HWND hDlg) { // common/combobox.c - ChooseColorWithCombo(g_hInst, hDlg, IDC_STARTMENUCOLOR); + ChooseColorWithCombo(hDlg, IDC_STARTMENUCOLOR); PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); SendPSChanged(hDlg); diff --git a/source/property/resource.h b/source/property/resource.h index a98eb5e..ecbc98e 100644 --- a/source/property/resource.h +++ b/source/property/resource.h @@ -22,6 +22,9 @@ #define IDD_PAGETASKBAR 115 #define IDD_PAGEMISC 116 #define IDD_SELECTICON 117 +#define IDD_PAGEANALOGCLOCK 118 +#define IDD_PAGEDESKTOP 119 +#define IDD_PAGECALENDAR 120 #define IDC_TREE 2801 #define IDC_APPLY 2802 @@ -45,6 +48,13 @@ #define IDC_FONTSIZE 1114 #define IDC_BOLD 1115 #define IDC_ITALIC 1116 +#define IDC_DECONONE 1117 +#define IDC_DECOSHADOW 1118 +#define IDC_DECOBORDER 1119 +#define IDC_COLSHADOW 1120 +#define IDC_CHOOSECOLSHADOW 1121 +#define IDC_SHADOWRANGE 1122 +#define IDC_SHADOWRANGESPIN 1123 // size and position #define IDC_ALIGNLEFT 1151 @@ -232,6 +242,26 @@ #define IDC_DESKTOPICON 1608 #define IDC_TRANSDESKTOPICONBK 1609 +// Analog Clock +#define IDC_ANALOGCLOCK 2401 +#define IDC_COLHOUR 2402 +#define IDC_CHOOSECOLHOUR 2403 +#define IDC_HOURHANDBOLD 2404 +#define IDC_COLMIN 2405 +#define IDC_CHOOSECOLMIN 2406 +#define IDC_MINHANDBOLD 2407 +#define IDC_ANALOGPOSMIDDLE 2408 +#define IDC_ANALOGPOSLEFT 2409 +#define IDC_ANALOGPOSRIGHT 2410 +#define IDC_ANALOGHPOS 2411 +#define IDC_ANALOGHPOSSPIN 2412 +#define IDC_ANALOGVPOS 2413 +#define IDC_ANALOGVPOSSPIN 2414 +#define IDC_ANALOGSIZE 2415 +#define IDC_ANALOGSIZESPIN 2416 +#define IDC_ANALOGBMP 2417 +#define IDC_ANALOGBMPBROWSE 2418 + // strings #define IDS_BTNFACE 1 #define IDS_BTNSHADOW 2 @@ -244,6 +274,7 @@ #define IDS_COLOR 8 #define IDS_SIZEPOS 9 #define IDS_FORMAT 10 +#define IDS_ANALOGCLOCK 52 #define IDS_ALARM 11 #define IDS_CUCKOO 12 #define IDS_MOUSE 13 diff --git a/source/property/tcprop.h b/source/property/tcprop.h index 9c23b4b..06b7fc4 100644 --- a/source/property/tcprop.h +++ b/source/property/tcprop.h @@ -36,6 +36,10 @@ INT_PTR CALLBACK PageSizeProc(HWND hDlg, UINT message, INT_PTR CALLBACK PageFormatProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); +/* ---------- pageanalog.c ---------- */ +INT_PTR CALLBACK PageAnalogClockProc(HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam); + /* ---------- pageformat2.c -------- */ INT_PTR CALLBACK DlgProcFormat2(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/source/property/tcprop.mak b/source/property/tcprop.mak index 104f988..b2f3ec2 100644 --- a/source/property/tcprop.mak +++ b/source/property/tcprop.mak @@ -22,7 +22,7 @@ TCPROPH=$(SRCDIR)\tcprop.h $(SRCDIR)\resource.h $(COMMONDIR)\common.h COMMONH=$(COMMONDIR)\common.h OBJS=pagecolor.obj pagesize.obj pageformat.obj pageformat2.obj\ - pagealarm.obj alarmday.obj pagecuckoo.obj\ + pageanalog.obj pagealarm.obj alarmday.obj pagecuckoo.obj\ pagemouse.obj pagemouse2.obj pagetooltip.obj\ pagestartbtn.obj selecticon.obj pagestartmenu.obj\ pagetaskbar.obj pagemisc.obj\ @@ -83,6 +83,7 @@ pagecolor.obj: $(SRCDIR)\pagecolor.c $(TCPROPH) pagesize.obj: $(SRCDIR)\pagesize.c $(TCPROPH) pageformat.obj: $(SRCDIR)\pageformat.c $(TCPROPH) ..\config.h pageformat2.obj: $(SRCDIR)\pageformat2.c $(TCPROPH) +pageanalog.obj: $(SRCDIR)\pageanalog.c $(TCPROPH) pagemouse.obj: $(SRCDIR)\pagemouse.c $(TCPROPH) $(COMMONDIR)\command.h ..\config.h pagemouse2.obj: $(SRCDIR)\pagemouse2.c $(TCPROPH) ..\config.h pagealarm.obj: $(SRCDIR)\pagealarm.c $(TCPROPH) diff --git a/source/property/tcprop.rc b/source/property/tcprop.rc index 9bf40a9..4771b80 100644 --- a/source/property/tcprop.rc +++ b/source/property/tcprop.rc @@ -49,16 +49,33 @@ BEGIN COMBOBOX IDC_COLFORE,62,82,84,120,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "...",IDC_CHOOSECOLFORE,151,82,14,13 - RTEXT "Font",IDC_STATIC,26,115,29,12 - COMBOBOX IDC_FONT,62,113,84,120,CBS_DROPDOWNLIST | CBS_SORT | + + RTEXT "Font",IDC_STATIC,26,103,29,12 + COMBOBOX IDC_FONT,62,101,84,120,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - RTEXT "Size",IDC_STATIC,26,138,29,12 - COMBOBOX IDC_FONTSIZE,62,136,38,66,CBS_DROPDOWN | WS_VSCROLL | + RTEXT "Size",IDC_STATIC,26,122,29,12 + COMBOBOX IDC_FONTSIZE,62,120,38,66,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + CONTROL "Bold",IDC_BOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - 114,135,36,12 + 114,119,36,12 CONTROL "Italic",IDC_ITALIC,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,154,135,40,12 + WS_TABSTOP,154,119,40,12 +#if TC_ENABLE_CLOCKDECORATION + RTEXT "Decoration",IDC_STATIC,15,139,40,10 + AUTORADIOBUTTON "None",IDC_DECONONE,62,137,32,12,WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "Shadow",IDC_DECOSHADOW,97,137,40,12 + AUTORADIOBUTTON "Border",IDC_DECOBORDER,140,137,35,12 + RTEXT "Color",IDC_STATIC,26,152,29,10 + COMBOBOX IDC_COLSHADOW,62,150,84,120,CBS_DROPDOWNLIST | + CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "...",IDC_CHOOSECOLSHADOW,151,150,14,13 + RTEXT "Range",IDC_STATIC,165,152,30,11 + EDITTEXT IDC_SHADOWRANGE,198,150,35,13,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SHADOWRANGESPIN,"msctls_updown32",UDS_WRAP | + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | + UDS_ARROWKEYS,220,150,9,13 +#endif END IDD_PAGESIZE DIALOG DISCARDABLE 0, 0, 198, 176 @@ -161,6 +178,47 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,85,85,50,14 END +IDD_PAGEANALOGCLOCK DIALOG DISCARDABLE 0, 0, 200, 100 +STYLE DS_CONTROL | WS_CHILD +FONT 9, "MS Sans Serif" +BEGIN + AUTOCHECKBOX "Display analog clock",IDC_ANALOGCLOCK,6,5,96,12,WS_GROUP + RTEXT "Hour hand",IDC_STATIC,15,25,40,11 + COMBOBOX IDC_COLHOUR,62,22,84,120,CBS_DROPDOWNLIST | + CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_GROUP | WS_TABSTOP + PUSHBUTTON "...",IDC_CHOOSECOLHOUR,151,22,14,13,WS_GROUP + AUTOCHECKBOX "Bold",IDC_HOURHANDBOLD,170,23,28,12,WS_GROUP + RTEXT "Minute hand",IDC_STATIC,15,43,40,11 + COMBOBOX IDC_COLMIN,62,40,84,120,CBS_DROPDOWNLIST | + CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_GROUP | WS_TABSTOP + PUSHBUTTON "...",IDC_CHOOSECOLMIN,151,40,14,13,WS_GROUP + AUTOCHECKBOX "Bold",IDC_MINHANDBOLD,170,41,28,12,WS_GROUP + RTEXT "Position",IDC_STATIC,15,68,40,12 + AUTORADIOBUTTON "Over the text",IDC_ANALOGPOSMIDDLE,62,66,55,12, + WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "Left",IDC_ANALOGPOSLEFT,124,66,27,12 + AUTORADIOBUTTON "Right",IDC_ANALOGPOSRIGHT,158,66,35,12 + GROUPBOX "Arrangement of position",IDC_STATIC,4,84,196,36,WS_GROUP + RTEXT "Horizontal",IDC_STATIC,14,100,40,11 + EDITTEXT IDC_ANALOGHPOS,60,98,40,13,ES_AUTOHSCROLL + CONTROL "",IDC_ANALOGHPOSSPIN,"msctls_updown32",UDS_WRAP | + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | + UDS_ARROWKEYS,90,98,9,13 + RTEXT "Vertical",IDC_STATIC,104,100,36,11 + EDITTEXT IDC_ANALOGVPOS,148,98,40,13,ES_AUTOHSCROLL + CONTROL "",IDC_ANALOGVPOSSPIN,"msctls_updown32",UDS_WRAP | + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | + UDS_ARROWKEYS,178,98,9,13 + RTEXT "Size",IDC_STATIC,35,130,20,11 + EDITTEXT IDC_ANALOGSIZE,62,128,40,13,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_ANALOGSIZESPIN,"msctls_updown32",UDS_WRAP | + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | + UDS_ARROWKEYS,92,128,9,13 + RTEXT "Background",IDC_STATIC,7,158,48,12 + EDITTEXT IDC_ANALOGBMP,62,156,118,13,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_ANALOGBMPBROWSE,182,156,15,13,WS_GROUP +END + IDD_PAGEALARM DIALOG DISCARDABLE 0, 0, 210, 186 STYLE DS_CONTROL | WS_CHILD FONT 9, "MS Sans Serif" diff --git a/source_all/Makefile b/source_all/Makefile new file mode 100644 index 0000000..e6ebc2a --- /dev/null +++ b/source_all/Makefile @@ -0,0 +1,65 @@ +# +# tclock.mak +# + +WORKDIR=work +OUTDIR=out + + +# Check target +!IF "$(CPU)"=="AMD64" || "$(TARGET_CPU)"=="x64" || "$(Platform)"=="x64" || "$(PLATFORM)"=="x64" || DEFINED(AMD64) +WIN64=1 +!ENDIF + +# Check VC++ version +!if [echo MSVCVER=_MSC_VER> msvcver.c && $(CC) /EP msvcver.c > msvcver.~ 2> nul] +!error Cannot run Visual C++ to determine its version. Make sure cl.exe is in your PATH. +!else +!include msvcver.~ +!if [del msvcver.c msvcver.~] +!endif +!endif + +!if $(MSVCVER) < 1900 +MSVC_MAJOR = ($(MSVCVER) / 100 - 6) +!else +MSVC_MAJOR = ($(MSVCVER) / 100 - 5) +!endif + +# Calculate MSVC_MAJOR. (Convert the expression to the actual value.) +!if [(set /a MSVC_MAJOR="$(MSVC_MAJOR)" > nul) && set MSVC_MAJOR > msvcmajor.~] == 0 +!include msvcmajor.~ +!if [del msvcmajor.~] +!endif +!endif + + +!IFDEF WIN64 + +WORKDIR=work64 +OUTDIR=out64 +#NODEFLIBOPT=NODEFAULTLIB=1 +MAKEOPT=OUTDIR=..\$(OUTDIR) $(NODEFLIBOPT) MSVC_MAJOR=$(MSVC_MAJOR) WIN64=1 -nologo + +!ELSE + +#NODEFLIBOPT=NODEFAULTLIB=1 +MAKEOPT=OUTDIR=..\$(OUTDIR) $(NODEFLIBOPT) MSVC_MAJOR=$(MSVC_MAJOR) -nologo + +!ENDIF + +all: + -if not exist $(OUTDIR) mkdir $(OUTDIR) + -if not exist $(WORKDIR) mkdir $(WORKDIR) + cd $(WORKDIR) + $(MAKE) -f ..\dll\tcdll.mak SRCDIR=..\dll $(MAKEOPT) + $(MAKE) -f ..\exe\tclock.mak SRCDIR=..\exe $(MAKEOPT) + $(MAKE) -f ..\property\tcprop.mak SRCDIR=..\property $(MAKEOPT) + $(MAKE) -f ..\timer\tctimer.mak SRCDIR=..\timer $(MAKEOPT) + $(MAKE) -f ..\player\tcplayer.mak SRCDIR=..\player $(MAKEOPT) + $(MAKE) -f ..\sntp\tcsntp.mak SRCDIR=..\sntp $(MAKEOPT) + cd .. + +clean: + -del $(OUTDIR)\*.exe $(OUTDIR)\tcdll.tclock $(OUTDIR)\*.map + -del /Q $(WORKDIR)\* diff --git a/source_all/config.h b/source_all/config.h index 26c5522..e4b7af8 100644 --- a/source_all/config.h +++ b/source_all/config.h @@ -14,15 +14,17 @@ //-------------------------------------------------------- // optional functions -#define TC_ENABLE_BATTERY 1 -#define TC_ENABLE_CPU 1 -#define TC_ENABLE_ETIME 1 -#define TC_ENABLE_HDD 1 -#define TC_ENABLE_MEMORY 1 -#define TC_ENABLE_NETWORK 1 -#define TC_ENABLE_VOLUME 1 -#define TC_ENABLE_WHEEL 1 -#define TC_ENABLE_DESKTOPICON 1 +#define TC_ENABLE_BATTERY 1 +#define TC_ENABLE_CPU 1 +#define TC_ENABLE_ETIME 1 +#define TC_ENABLE_HDD 1 +#define TC_ENABLE_MEMORY 1 +#define TC_ENABLE_NETWORK 1 +#define TC_ENABLE_VOLUME 1 +#define TC_ENABLE_WHEEL 1 +#define TC_ENABLE_DESKTOPICON 1 +#define TC_ENABLE_CLOCKDECORATION 1 +#define TC_ENABLE_ANALOGCLOCK 1 // Default interval for getting system information: default 4 [sec] #define TC_DEFAULT_INTERVALSYSINFO 4 diff --git a/source_custom/Makefile b/source_custom/Makefile new file mode 100644 index 0000000..620c628 --- /dev/null +++ b/source_custom/Makefile @@ -0,0 +1,65 @@ +# +# tclock.mak +# + +WORKDIR=work +OUTDIR=out + + +# Check target +!IF "$(CPU)"=="AMD64" || "$(TARGET_CPU)"=="x64" || "$(Platform)"=="x64" || "$(PLATFORM)"=="x64" || DEFINED(AMD64) +WIN64=1 +!ENDIF + +# Check VC++ version +!if [echo MSVCVER=_MSC_VER> msvcver.c && $(CC) /EP msvcver.c > msvcver.~ 2> nul] +!error Cannot run Visual C++ to determine its version. Make sure cl.exe is in your PATH. +!else +!include msvcver.~ +!if [del msvcver.c msvcver.~] +!endif +!endif + +!if $(MSVCVER) < 1900 +MSVC_MAJOR = ($(MSVCVER) / 100 - 6) +!else +MSVC_MAJOR = ($(MSVCVER) / 100 - 5) +!endif + +# Calculate MSVC_MAJOR. (Convert the expression to the actual value.) +!if [(set /a MSVC_MAJOR="$(MSVC_MAJOR)" > nul) && set MSVC_MAJOR > msvcmajor.~] == 0 +!include msvcmajor.~ +!if [del msvcmajor.~] +!endif +!endif + + +!IFDEF WIN64 + +WORKDIR=work64 +OUTDIR=out64 +NODEFLIBOPT=NODEFAULTLIB=1 +MAKEOPT=OUTDIR=..\$(OUTDIR) $(NODEFLIBOPT) MSVC_MAJOR=$(MSVC_MAJOR) WIN64=1 -nologo + +!ELSE + +NODEFLIBOPT=NODEFAULTLIB=1 +MAKEOPT=OUTDIR=..\$(OUTDIR) $(NODEFLIBOPT) MSVC_MAJOR=$(MSVC_MAJOR) -nologo + +!ENDIF + +all: + -if not exist $(OUTDIR) mkdir $(OUTDIR) + -if not exist $(WORKDIR) mkdir $(WORKDIR) + cd $(WORKDIR) + $(MAKE) -f ..\dll\tcdll.mak SRCDIR=..\dll $(MAKEOPT) + $(MAKE) -f ..\exe\tclock.mak SRCDIR=..\exe $(MAKEOPT) + $(MAKE) -f ..\property\tcprop.mak SRCDIR=..\property $(MAKEOPT) + $(MAKE) -f ..\timer\tctimer.mak SRCDIR=..\timer $(MAKEOPT) + $(MAKE) -f ..\player\tcplayer.mak SRCDIR=..\player $(MAKEOPT) + $(MAKE) -f ..\sntp\tcsntp.mak SRCDIR=..\sntp $(MAKEOPT) + cd .. + +clean: + -del $(OUTDIR)\*.exe $(OUTDIR)\tcdll.tclock $(OUTDIR)\*.map + -del /Q $(WORKDIR)\* diff --git a/source_custom/config.h b/source_custom/config.h index d2e9fea..4158d06 100644 --- a/source_custom/config.h +++ b/source_custom/config.h @@ -14,15 +14,17 @@ //-------------------------------------------------------- // optional functions -#define TC_ENABLE_BATTERY 0 -#define TC_ENABLE_CPU 0 -#define TC_ENABLE_ETIME 0 -#define TC_ENABLE_HDD 1 -#define TC_ENABLE_MEMORY 1 -#define TC_ENABLE_NETWORK 0 -#define TC_ENABLE_VOLUME 0 -#define TC_ENABLE_WHEEL 0 -#define TC_ENABLE_DESKTOPICON 0 +#define TC_ENABLE_BATTERY 0 +#define TC_ENABLE_CPU 0 +#define TC_ENABLE_ETIME 0 +#define TC_ENABLE_HDD 1 +#define TC_ENABLE_MEMORY 1 +#define TC_ENABLE_NETWORK 0 +#define TC_ENABLE_VOLUME 0 +#define TC_ENABLE_WHEEL 0 +#define TC_ENABLE_DESKTOPICON 0 +#define TC_ENABLE_CLOCKDECORATION 0 +#define TC_ENABLE_ANALOGCLOCK 0 // Default interval for getting system information: default 4 [sec] #define TC_DEFAULT_INTERVALSYSINFO 4 From e7674f8bd9dd792dcf5ac8773d9fd684357da2e6 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sun, 28 Aug 2016 14:08:30 +0900 Subject: [PATCH 5/6] Suppress warnings --- source/common/utl.c | 6 +++--- source/dll/draw.c | 16 ++++++++-------- source/dll/tooltip.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/common/utl.c b/source/common/utl.c index 98c8606..fe4af38 100644 --- a/source/common/utl.c +++ b/source/common/utl.c @@ -301,7 +301,7 @@ void SendStringToOtherW(HWND hwnd, HWND hwndFrom, COPYDATASTRUCT cds; cds.dwData = type; - cds.cbData = (wcslen(s) + 1) * sizeof(wchar_t); + cds.cbData = ((int)wcslen(s) + 1) * sizeof(wchar_t); cds.lpData = (LPVOID)s; if(hwnd && IsWindow(hwnd)) @@ -538,8 +538,8 @@ void WriteDebugW(const wchar_t* s) hf = _lcreat(fname, 0); if(hf == HFILE_ERROR) return; _llseek(hf, 0, 2); - _lwrite(hf, (LPCSTR)s, wcslen(s)*sizeof(wchar_t)); - _lwrite(hf, (LPCSTR)L"\x0d\x0a", wcslen(L"\x0d\x0a")*sizeof(wchar_t)); + _lwrite(hf, (LPCSTR)s, (int)wcslen(s)*sizeof(wchar_t)); + _lwrite(hf, (LPCSTR)L"\x0d\x0a", 2*sizeof(wchar_t)); _lclose(hf); } diff --git a/source/dll/draw.c b/source/dll/draw.c index c435ab7..3d84cde 100644 --- a/source/dll/draw.c +++ b/source/dll/draw.c @@ -454,14 +454,14 @@ void DrawClock(HWND hwnd, HDC hdc, const SYSTEMTIME* pt) if(g_scat1[0]) { - len = wcslen(s); + len = (int)wcslen(s); if(len > 0 && s[len - 1] != 0x0a && s[len - 1] != ' ') wcscat(s, L" "); wcscat(s, g_scat1); } if(g_scat2[0]) { - len = wcslen(s); + len = (int)wcslen(s); if(len > 0 && s[len - 1] != 0x0a && s[len - 1] != ' ') wcscat(s, L" "); wcscat(s, g_scat2); @@ -796,12 +796,12 @@ void DrawAnalogClock(HWND hwnd, HDC hdcClock, const SYSTEMTIME *pt, m_lastMin = st.wMinute; // calculate hands' pos - ptHour.x = 0.5 + center - + sin((m_lastHour * 60 + m_lastMin) * PI_360) * center * 0.7; - ptHour.y = 0.5 + center - - cos((m_lastHour * 60 + m_lastMin) * PI_360) * center * 0.7; - ptMin.x = 0.5 + center + sin(m_lastMin * PI_30) * center; - ptMin.y = 0.5 + center - cos(m_lastMin * PI_30) * center; + ptHour.x = (LONG)(0.5 + center + + sin((m_lastHour * 60 + m_lastMin) * PI_360) * center * 0.7); + ptHour.y = (LONG)(0.5 + center + - cos((m_lastHour * 60 + m_lastMin) * PI_360) * center * 0.7); + ptMin.x = (LONG)(0.5 + center + sin(m_lastMin * PI_30) * center); + ptMin.y = (LONG)(0.5 + center - cos(m_lastMin * PI_30) * center); // draw hands BitBlt(m_hdcAclk, 0, 0, m_nAClockSize, m_nAClockSize, diff --git a/source/dll/tooltip.c b/source/dll/tooltip.c index 8e64105..562cda2 100644 --- a/source/dll/tooltip.c +++ b/source/dll/tooltip.c @@ -338,7 +338,7 @@ BOOL OnTooltipNotify(HWND hwndClock, LRESULT *pres, const LPNMHDR pnmh) SendMessage(m_hwndTip, TTM_SETMAXTIPWIDTH, 0, 1024); - len = wcslen(pfmt) * 2; + len = (int)wcslen(pfmt) * 2; if(len > m_textlen || !m_textToolTip) { if(m_textToolTip) free(m_textToolTip); From 3c918a026fd133a6c7123e12584c245341ae95fe Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sun, 28 Aug 2016 14:17:56 +0900 Subject: [PATCH 6/6] Update document --- readme-kt.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme-kt.txt b/readme-kt.txt index 93da4e3..33c14b1 100644 --- a/readme-kt.txt +++ b/readme-kt.txt @@ -104,8 +104,6 @@ Privilege Isolation) ・TClock Light Unofficial 060502 ・tclocklight- 080409 - ツールチップの拡張や、アナログ時計、影、縁取りは取り込んでいません。 - 2.13. x64 への対応  x64 に正式対応しました。  x64 ディレクトリに入っているファイルが x64 用の実行ファイルです。使う際 @@ -399,6 +397,8 @@ UAC (User Account Control) - アラーム、マウス機能、タイマーの処理をリンクリストに変更。 - (memreduce は不採用) ・Explorerのクラッシュ後に改造し直す設定をデフォルトで有効化。 +・tclocklight-050716 の装飾とアナログ時計機能を取り込む。(all 版) + これに伴い、all 版はデフォルトライブラリとのリンクが必須となった。 5.ライセンス