Make indentation consistent (4 chars).
This commit is contained in:
parent
9d59fb72b1
commit
64852f4b0e
|
@ -27,8 +27,8 @@
|
|||
|
||||
CHAR STRING_MENU_Xx[] = "MENU_Xx";
|
||||
|
||||
VOID LANGUAGE_UpdateMenuCheckmarks(VOID) {
|
||||
|
||||
VOID LANGUAGE_UpdateMenuCheckmarks(VOID)
|
||||
{
|
||||
if(Globals.bAnalog == TRUE) {
|
||||
|
||||
/* analog clock */
|
||||
|
@ -40,9 +40,8 @@ VOID LANGUAGE_UpdateMenuCheckmarks(VOID) {
|
|||
EnableMenuItem(Globals.hPropertiesMenu, 0x103,
|
||||
MF_BYCOMMAND | MF_GRAYED);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
|
||||
/* digital clock */
|
||||
|
||||
CheckMenuItem(Globals.hPropertiesMenu, 0x100,
|
||||
|
@ -51,7 +50,6 @@ VOID LANGUAGE_UpdateMenuCheckmarks(VOID) {
|
|||
MF_BYCOMMAND | MF_CHECKED);
|
||||
EnableMenuItem(Globals.hPropertiesMenu, 0x103,
|
||||
MF_BYCOMMAND);
|
||||
|
||||
}
|
||||
|
||||
CheckMenuItem(Globals.hPropertiesMenu, 0x105, MF_BYCOMMAND |
|
||||
|
@ -64,68 +62,66 @@ VOID LANGUAGE_UpdateMenuCheckmarks(VOID) {
|
|||
(Globals.bDate ? MF_CHECKED : MF_UNCHECKED));
|
||||
}
|
||||
|
||||
VOID LANGUAGE_UpdateWindowCaption(VOID) {
|
||||
VOID LANGUAGE_UpdateWindowCaption(VOID)
|
||||
{
|
||||
CHAR szCaption[MAX_STRING_LEN];
|
||||
CHAR szDate[MAX_STRING_LEN];
|
||||
|
||||
CHAR szCaption[MAX_STRING_LEN];
|
||||
CHAR szDate[MAX_STRING_LEN];
|
||||
LPSTR date = szDate;
|
||||
|
||||
LPSTR date = szDate;
|
||||
SYSTEMTIME st;
|
||||
LPSYSTEMTIME lpst = &st;
|
||||
|
||||
SYSTEMTIME st;
|
||||
LPSYSTEMTIME lpst = &st;
|
||||
|
||||
GetLocalTime(&st);
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, lpst, NULL, date,
|
||||
MAX_STRING_LEN);
|
||||
|
||||
/* Set frame caption */
|
||||
LoadString(Globals.hInstance, 0x10C, szCaption, sizeof(szCaption));
|
||||
if (Globals.bDate) {
|
||||
lstrcat(szCaption, " - ");
|
||||
lstrcat(szCaption, szDate);
|
||||
}
|
||||
SetWindowText(Globals.hMainWnd, szCaption);
|
||||
GetLocalTime(&st);
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, lpst, NULL, date,
|
||||
MAX_STRING_LEN);
|
||||
|
||||
/* Set frame caption */
|
||||
LoadString(Globals.hInstance, 0x10C, szCaption, sizeof(szCaption));
|
||||
if (Globals.bDate) {
|
||||
lstrcat(szCaption, " - ");
|
||||
lstrcat(szCaption, szDate);
|
||||
}
|
||||
SetWindowText(Globals.hMainWnd, szCaption);
|
||||
}
|
||||
|
||||
VOID LANGUAGE_LoadMenus(VOID)
|
||||
{
|
||||
CHAR szItem[MAX_STRING_LEN];
|
||||
HMENU hMainMenu;
|
||||
|
||||
CHAR szItem[MAX_STRING_LEN];
|
||||
HMENU hMainMenu;
|
||||
|
||||
|
||||
/* Create menu */
|
||||
hMainMenu = LoadMenu(Globals.hInstance, MAKEINTRESOURCE(MAIN_MENU));
|
||||
/* Create menu */
|
||||
hMainMenu = LoadMenu(Globals.hInstance, MAKEINTRESOURCE(MAIN_MENU));
|
||||
Globals.hPropertiesMenu = GetSubMenu(hMainMenu, 0);
|
||||
Globals.hLanguageMenu = GetSubMenu(hMainMenu, 1);
|
||||
Globals.hInfoMenu = GetSubMenu(hMainMenu, 2);
|
||||
|
||||
SetMenu(Globals.hMainWnd, hMainMenu);
|
||||
|
||||
SetMenu(Globals.hMainWnd, hMainMenu);
|
||||
/* Destroy old menu */
|
||||
if (Globals.hMainMenu) DestroyMenu(Globals.hMainMenu);
|
||||
Globals.hMainMenu = hMainMenu;
|
||||
|
||||
/* Destroy old menu */
|
||||
if (Globals.hMainMenu) DestroyMenu(Globals.hMainMenu);
|
||||
Globals.hMainMenu = hMainMenu;
|
||||
/* specific for Clock: */
|
||||
|
||||
/* specific for Clock: */
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
LANGUAGE_UpdateWindowCaption();
|
||||
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
LANGUAGE_UpdateWindowCaption();
|
||||
Globals.hSystemMenu = GetSystemMenu(Globals.hMainWnd, TRUE);
|
||||
|
||||
/* FIXME: Append a SEPARATOR to Globals.hSystemMenu here */
|
||||
|
||||
Globals.hSystemMenu = GetSystemMenu(Globals.hMainWnd, TRUE);
|
||||
|
||||
/* FIXME: Append a SEPARATOR to Globals.hSystemMenu here */
|
||||
|
||||
LoadString(Globals.hInstance, 0x10D, szItem, sizeof(szItem));
|
||||
AppendMenu(Globals.hSystemMenu, MF_STRING | MF_BYCOMMAND, 1000, szItem);
|
||||
LoadString(Globals.hInstance, 0x10D, szItem, sizeof(szItem));
|
||||
AppendMenu(Globals.hSystemMenu, MF_STRING | MF_BYCOMMAND, 1000, szItem);
|
||||
}
|
||||
|
||||
/*
|
||||
VOID LANGUAGE_DefaultHandle(WPARAM wParam)
|
||||
{
|
||||
if ((wParam >=CL_FIRST_LANGUAGE) && (wParam<=CL_LAST_LANGUAGE))
|
||||
LANGUAGE_SelectByNumber(wParam - CL_FIRST_LANGUAGE);
|
||||
else printf("Unimplemented menu command %i\n", wParam);
|
||||
if ((wParam >=CL_FIRST_LANGUAGE) && (wParam<=CL_LAST_LANGUAGE))
|
||||
LANGUAGE_SelectByNumber(wParam - CL_FIRST_LANGUAGE);
|
||||
else
|
||||
printf("Unimplemented menu command %i\n", wParam);
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -48,106 +48,106 @@ CLOCK_GLOBALS Globals;
|
|||
|
||||
int CLOCK_MenuCommand (WPARAM wParam)
|
||||
{
|
||||
CHAR szApp[MAX_STRING_LEN];
|
||||
CHAR szAppRelease[MAX_STRING_LEN];
|
||||
switch (wParam) {
|
||||
/* switch to analog */
|
||||
case 0x100: {
|
||||
Globals.bAnalog = TRUE;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
|
||||
break;
|
||||
}
|
||||
/* switch to digital */
|
||||
case 0x101: {
|
||||
Globals.bAnalog = FALSE;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
|
||||
break;
|
||||
}
|
||||
/* change font */
|
||||
case 0x103: {
|
||||
MAIN_FileChooseFont();
|
||||
break;
|
||||
}
|
||||
/* hide title bar */
|
||||
case 0x105: {
|
||||
Globals.bWithoutTitle = !Globals.bWithoutTitle;
|
||||
LANGUAGE_UpdateWindowCaption();
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
break;
|
||||
}
|
||||
/* always on top */
|
||||
case 0x10D: {
|
||||
Globals.bAlwaysOnTop = !Globals.bAlwaysOnTop;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
break;
|
||||
}
|
||||
/* show or hide seconds */
|
||||
case 0x107: {
|
||||
Globals.bSeconds = !Globals.bSeconds;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
|
||||
break;
|
||||
}
|
||||
/* show or hide date */
|
||||
case 0x108: {
|
||||
Globals.bDate = !Globals.bDate;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
LANGUAGE_UpdateWindowCaption();
|
||||
break;
|
||||
}
|
||||
/* show license */
|
||||
case 0x109: {
|
||||
WineLicense(Globals.hMainWnd);
|
||||
break;
|
||||
}
|
||||
/* show warranties */
|
||||
case 0x10A: {
|
||||
WineWarranty(Globals.hMainWnd);
|
||||
break;
|
||||
}
|
||||
/* show "about" box */
|
||||
case 0x10B: {
|
||||
LoadString(Globals.hInstance, 0x10C, szApp, sizeof(szApp));
|
||||
lstrcpy(szAppRelease,szApp);
|
||||
lstrcat(szAppRelease,"\n" PACKAGE_STRING);
|
||||
ShellAbout(Globals.hMainWnd, szApp, szAppRelease, 0);
|
||||
break;
|
||||
}
|
||||
/* Handle languages */
|
||||
/* default:
|
||||
LANGUAGE_DefaultHandle(wParam);
|
||||
*/
|
||||
}
|
||||
return 0;
|
||||
CHAR szApp[MAX_STRING_LEN];
|
||||
CHAR szAppRelease[MAX_STRING_LEN];
|
||||
switch (wParam) {
|
||||
/* switch to analog */
|
||||
case 0x100: {
|
||||
Globals.bAnalog = TRUE;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
|
||||
break;
|
||||
}
|
||||
/* switch to digital */
|
||||
case 0x101: {
|
||||
Globals.bAnalog = FALSE;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
|
||||
break;
|
||||
}
|
||||
/* change font */
|
||||
case 0x103: {
|
||||
MAIN_FileChooseFont();
|
||||
break;
|
||||
}
|
||||
/* hide title bar */
|
||||
case 0x105: {
|
||||
Globals.bWithoutTitle = !Globals.bWithoutTitle;
|
||||
LANGUAGE_UpdateWindowCaption();
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
break;
|
||||
}
|
||||
/* always on top */
|
||||
case 0x10D: {
|
||||
Globals.bAlwaysOnTop = !Globals.bAlwaysOnTop;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
break;
|
||||
}
|
||||
/* show or hide seconds */
|
||||
case 0x107: {
|
||||
Globals.bSeconds = !Globals.bSeconds;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
|
||||
break;
|
||||
}
|
||||
/* show or hide date */
|
||||
case 0x108: {
|
||||
Globals.bDate = !Globals.bDate;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
LANGUAGE_UpdateWindowCaption();
|
||||
break;
|
||||
}
|
||||
/* show license */
|
||||
case 0x109: {
|
||||
WineLicense(Globals.hMainWnd);
|
||||
break;
|
||||
}
|
||||
/* show warranties */
|
||||
case 0x10A: {
|
||||
WineWarranty(Globals.hMainWnd);
|
||||
break;
|
||||
}
|
||||
/* show "about" box */
|
||||
case 0x10B: {
|
||||
LoadString(Globals.hInstance, 0x10C, szApp, sizeof(szApp));
|
||||
lstrcpy(szAppRelease,szApp);
|
||||
lstrcat(szAppRelease,"\n" PACKAGE_STRING);
|
||||
ShellAbout(Globals.hMainWnd, szApp, szAppRelease, 0);
|
||||
break;
|
||||
}
|
||||
/* Handle languages */
|
||||
/*
|
||||
default:
|
||||
LANGUAGE_DefaultHandle(wParam);
|
||||
*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID MAIN_FileChooseFont(VOID) {
|
||||
|
||||
CHOOSEFONT font;
|
||||
LOGFONT lf;
|
||||
|
||||
font.lStructSize = sizeof(font);
|
||||
font.hwndOwner = Globals.hMainWnd;
|
||||
font.hDC = NULL;
|
||||
font.lpLogFont = &lf;
|
||||
font.iPointSize = 0;
|
||||
font.Flags = 0;
|
||||
font.rgbColors = 0;
|
||||
font.lCustData = 0;
|
||||
font.lpfnHook = 0;
|
||||
font.lpTemplateName = 0;
|
||||
font.hInstance = Globals.hInstance;
|
||||
/* font.lpszStyle = LF_FACESIZE; */
|
||||
font.nFontType = 0;
|
||||
font.nSizeMin = 0;
|
||||
font.nSizeMax = 144;
|
||||
|
||||
if (ChooseFont(&font)) {
|
||||
/* do nothing yet */
|
||||
}
|
||||
|
||||
VOID MAIN_FileChooseFont(VOID)
|
||||
{
|
||||
CHOOSEFONT font;
|
||||
LOGFONT lf;
|
||||
|
||||
font.lStructSize = sizeof(font);
|
||||
font.hwndOwner = Globals.hMainWnd;
|
||||
font.hDC = NULL;
|
||||
font.lpLogFont = &lf;
|
||||
font.iPointSize = 0;
|
||||
font.Flags = 0;
|
||||
font.rgbColors = 0;
|
||||
font.lCustData = 0;
|
||||
font.lpfnHook = 0;
|
||||
font.lpTemplateName = 0;
|
||||
font.hInstance = Globals.hInstance;
|
||||
/* font.lpszStyle = LF_FACESIZE; */
|
||||
font.nFontType = 0;
|
||||
font.nSizeMin = 0;
|
||||
font.nSizeMax = 144;
|
||||
|
||||
if (ChooseFont(&font)) {
|
||||
/* do nothing yet */
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -158,9 +158,9 @@ VOID MAIN_FileChooseFont(VOID) {
|
|||
LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg) {
|
||||
|
||||
|
||||
case WM_CREATE: {
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_RBUTTONUP: {
|
||||
|
@ -171,41 +171,41 @@ LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
}
|
||||
|
||||
case WM_PAINT: {
|
||||
case WM_PAINT: {
|
||||
PAINTSTRUCT ps;
|
||||
HDC context;
|
||||
|
||||
|
||||
context = BeginPaint(hWnd, &ps);
|
||||
if(Globals.bAnalog) {
|
||||
DrawFace(context);
|
||||
Idle(context);
|
||||
}
|
||||
else
|
||||
if(Globals.bAnalog) {
|
||||
DrawFace(context);
|
||||
Idle(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* do nothing */
|
||||
/* do nothing */
|
||||
}
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SIZE: {
|
||||
Globals.MaxX = LOWORD(lParam);
|
||||
Globals.MaxY = HIWORD(lParam);
|
||||
Globals.MaxX = LOWORD(lParam);
|
||||
Globals.MaxY = HIWORD(lParam);
|
||||
OldHour.DontRedraw = TRUE;
|
||||
OldMinute.DontRedraw = TRUE;
|
||||
OldSecond.DontRedraw = TRUE;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_COMMAND: {
|
||||
CLOCK_MenuCommand(wParam);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case WM_TIMER: {
|
||||
Idle(0);
|
||||
break;
|
||||
}
|
||||
Idle(0);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY: {
|
||||
PostQuitMessage (0);
|
||||
|
@ -213,7 +213,7 @@ LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
|
||||
default:
|
||||
return DefWindowProc (hWnd, msg, wParam, lParam);
|
||||
return DefWindowProc (hWnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -229,43 +229,43 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
|
|||
{
|
||||
MSG msg;
|
||||
WNDCLASS class;
|
||||
|
||||
|
||||
char szClassName[] = "CLClass"; /* To make sure className >= 0x10000 */
|
||||
char szWinName[] = "Clock";
|
||||
|
||||
|
||||
/* Setup Globals */
|
||||
Globals.bAnalog = TRUE;
|
||||
Globals.bAnalog = TRUE;
|
||||
Globals.bSeconds = TRUE;
|
||||
Globals.lpszIniFile = "clock.ini";
|
||||
Globals.lpszIcoFile = "clock.ico";
|
||||
|
||||
|
||||
Globals.hInstance = hInstance;
|
||||
Globals.hMainIcon = ExtractIcon(Globals.hInstance,
|
||||
Globals.lpszIcoFile, 0);
|
||||
|
||||
if (!Globals.hMainIcon) Globals.hMainIcon =
|
||||
LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
|
||||
|
||||
|
||||
if (!Globals.hMainIcon)
|
||||
Globals.hMainIcon = LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
|
||||
|
||||
if (!prev){
|
||||
class.style = CS_HREDRAW | CS_VREDRAW;
|
||||
class.lpfnWndProc = CLOCK_WndProc;
|
||||
class.cbClsExtra = 0;
|
||||
class.cbWndExtra = 0;
|
||||
class.hInstance = Globals.hInstance;
|
||||
class.hIcon = LoadIcon (0, IDI_APPLICATION);
|
||||
class.hCursor = LoadCursor (0, IDC_ARROW);
|
||||
class.hbrBackground = GetStockObject (GRAY_BRUSH);
|
||||
class.lpszMenuName = 0;
|
||||
class.lpszClassName = szClassName;
|
||||
class.style = CS_HREDRAW | CS_VREDRAW;
|
||||
class.lpfnWndProc = CLOCK_WndProc;
|
||||
class.cbClsExtra = 0;
|
||||
class.cbWndExtra = 0;
|
||||
class.hInstance = Globals.hInstance;
|
||||
class.hIcon = LoadIcon (0, IDI_APPLICATION);
|
||||
class.hCursor = LoadCursor (0, IDC_ARROW);
|
||||
class.hbrBackground = GetStockObject (GRAY_BRUSH);
|
||||
class.lpszMenuName = 0;
|
||||
class.lpszClassName = szClassName;
|
||||
}
|
||||
|
||||
|
||||
if (!RegisterClass (&class)) return FALSE;
|
||||
|
||||
|
||||
Globals.MaxX = Globals.MaxY = INITIAL_WINDOW_SIZE;
|
||||
Globals.hMainWnd = CreateWindow (szClassName, szWinName, WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
Globals.MaxX, Globals.MaxY, 0,
|
||||
0, Globals.hInstance, 0);
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
Globals.MaxX, Globals.MaxY, 0,
|
||||
0, Globals.hInstance, 0);
|
||||
|
||||
if (!SetTimer (Globals.hMainWnd, TIMER_ID, TIMER_PERIOD, NULL)) {
|
||||
MessageBox(0, "No available timers", szWinName, MB_ICONEXCLAMATION | MB_OK);
|
||||
|
@ -274,12 +274,12 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
|
|||
|
||||
LANGUAGE_LoadMenus();
|
||||
SetMenu(Globals.hMainWnd, Globals.hMainMenu);
|
||||
|
||||
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
|
||||
|
||||
ShowWindow (Globals.hMainWnd, show);
|
||||
UpdateWindow (Globals.hMainWnd);
|
||||
|
||||
|
||||
while (GetMessage(&msg, 0, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
|
|
|
@ -42,65 +42,67 @@ int nLastSecond = 60;
|
|||
|
||||
HandData OldSecond,OldHour,OldMinute;
|
||||
|
||||
int MiddleX(void) {
|
||||
int X, diff;
|
||||
int MiddleX(void)
|
||||
{
|
||||
int X, diff;
|
||||
|
||||
X = (Globals.MaxX/2);
|
||||
diff = (Globals.MaxX-Globals.MaxY);
|
||||
if (diff>0) { X = (X-(diff/2)); }
|
||||
return X;
|
||||
X = (Globals.MaxX/2);
|
||||
diff = (Globals.MaxX-Globals.MaxY);
|
||||
if (diff>0) { X = (X-(diff/2)); }
|
||||
return X;
|
||||
}
|
||||
|
||||
int MiddleY(void) {
|
||||
int Y, diff;
|
||||
|
||||
Y = (Globals.MaxY/2);
|
||||
diff = (Globals.MaxX-Globals.MaxY);
|
||||
if (diff<0) { Y = Y+(diff/2); }
|
||||
return Y;
|
||||
int MiddleY(void)
|
||||
{
|
||||
int Y, diff;
|
||||
|
||||
Y = (Globals.MaxY/2);
|
||||
diff = (Globals.MaxX-Globals.MaxY);
|
||||
if (diff<0) { Y = Y+(diff/2); }
|
||||
return Y;
|
||||
}
|
||||
|
||||
void DrawFace(HDC dc)
|
||||
{
|
||||
int MidX, MidY, t, DiffX, DiffY;
|
||||
int MidX, MidY, t, DiffX, DiffY;
|
||||
|
||||
MidX = MiddleX();
|
||||
MidY = MiddleY();
|
||||
DiffX = (Globals.MaxX-MidX*2)/2;
|
||||
DiffY = (Globals.MaxY-MidY*2)/2;
|
||||
MidX = MiddleX();
|
||||
MidY = MiddleY();
|
||||
DiffX = (Globals.MaxX-MidX*2)/2;
|
||||
DiffY = (Globals.MaxY-MidY*2)/2;
|
||||
|
||||
SelectObject(dc,CreateSolidBrush(FaceColor));
|
||||
SelectObject(dc,CreatePen(PS_SOLID,1,EtchColor));
|
||||
Ellipse(dc,DiffX,DiffY,2*MidX+DiffX,2*MidY+DiffY);
|
||||
SelectObject(dc,CreateSolidBrush(FaceColor));
|
||||
SelectObject(dc,CreatePen(PS_SOLID,1,EtchColor));
|
||||
Ellipse(dc,DiffX,DiffY,2*MidX+DiffX,2*MidY+DiffY);
|
||||
|
||||
for(t=0; t<12; t++)
|
||||
{
|
||||
MoveToEx(dc,(MidX+DiffX)+sin(t*Pi/6)*0.9*MidX,(MidY+DiffY)-cos(t*Pi/6)*0.9*MidY,NULL);
|
||||
LineTo(dc,(MidY+DiffX)+sin(t*Pi/6)*0.8*MidX,(MidY+DiffY)-cos(t*Pi/6)*0.8*MidY);
|
||||
}
|
||||
if(Globals.MaxX>64 && Globals.MaxY>64)
|
||||
for(t=0; t<60; t++)
|
||||
SetPixel(dc,(MidX+DiffX)+sin(t*Pi/30)*0.9*MidX,(MidY+DiffY)-cos(t*Pi/30)*0.9*MidY
|
||||
,EtchColor);
|
||||
DeleteObject(SelectObject(dc,GetStockObject(NULL_BRUSH)));
|
||||
DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
|
||||
memset(&OldSecond,0,sizeof(OldSecond));
|
||||
memset(&OldMinute,0,sizeof(OldMinute));
|
||||
memset(&OldHour,0,sizeof(OldHour));
|
||||
for(t=0; t<12; t++)
|
||||
{
|
||||
MoveToEx(dc,(MidX+DiffX)+sin(t*Pi/6)*0.9*MidX,(MidY+DiffY)-cos(t*Pi/6)*0.9*MidY,NULL);
|
||||
LineTo(dc,(MidY+DiffX)+sin(t*Pi/6)*0.8*MidX,(MidY+DiffY)-cos(t*Pi/6)*0.8*MidY);
|
||||
}
|
||||
if(Globals.MaxX>64 && Globals.MaxY>64)
|
||||
for(t=0; t<60; t++)
|
||||
SetPixel(dc,(MidX+DiffX)+sin(t*Pi/30)*0.9*MidX,(MidY+DiffY)-cos(t*Pi/30)*0.9*MidY
|
||||
,EtchColor);
|
||||
DeleteObject(SelectObject(dc,GetStockObject(NULL_BRUSH)));
|
||||
DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
|
||||
memset(&OldSecond,0,sizeof(OldSecond));
|
||||
memset(&OldMinute,0,sizeof(OldMinute));
|
||||
memset(&OldHour,0,sizeof(OldHour));
|
||||
}
|
||||
|
||||
void DrawHourHand(HDC dc)
|
||||
{
|
||||
if (OldHour.DontRedraw) return;
|
||||
MoveToEx(dc, OldHour.StartX, OldHour.StartY, NULL);
|
||||
LineTo(dc, OldHour.EndX, OldHour.EndY);
|
||||
if (OldHour.DontRedraw) return;
|
||||
MoveToEx(dc, OldHour.StartX, OldHour.StartY, NULL);
|
||||
LineTo(dc, OldHour.EndX, OldHour.EndY);
|
||||
}
|
||||
|
||||
void DrawMinuteHand(HDC dc)
|
||||
{
|
||||
if (OldMinute.DontRedraw) return;
|
||||
MoveToEx(dc, OldMinute.StartX, OldMinute.StartY, NULL);
|
||||
LineTo(dc, OldMinute.EndX, OldMinute.EndY);
|
||||
if (OldMinute.DontRedraw) return;
|
||||
MoveToEx(dc, OldMinute.StartX, OldMinute.StartY, NULL);
|
||||
LineTo(dc, OldMinute.EndX, OldMinute.EndY);
|
||||
}
|
||||
|
||||
void DrawSecondHand(HDC dc)
|
||||
|
@ -112,146 +114,144 @@ void DrawSecondHand(HDC dc)
|
|||
|
||||
BOOL UpdateHourHand(HDC dc,int MidX,int MidY,int XExt,int YExt,WORD Pos)
|
||||
{
|
||||
int Sx, Sy, Ex, Ey;
|
||||
BOOL rv;
|
||||
|
||||
rv = FALSE;
|
||||
Sx = MidX; Sy = MidY;
|
||||
Ex = MidX+sin(Pos*Pi/6000)*XExt;
|
||||
Ey = MidY-cos(Pos*Pi/6000)*YExt;
|
||||
rv = ( Sx!=OldHour.StartX || Ex!=OldHour.EndX ||
|
||||
Sy!=OldHour.StartY || Ey!=OldHour.EndY );
|
||||
if (Globals.bAnalog && rv)DrawHourHand(dc);
|
||||
OldHour.StartX = Sx; OldHour.EndX = Ex;
|
||||
OldHour.StartY = Sy; OldHour.EndY = Ey;
|
||||
OldHour.DontRedraw=FALSE;
|
||||
return rv;
|
||||
int Sx, Sy, Ex, Ey;
|
||||
BOOL rv;
|
||||
|
||||
rv = FALSE;
|
||||
Sx = MidX; Sy = MidY;
|
||||
Ex = MidX+sin(Pos*Pi/6000)*XExt;
|
||||
Ey = MidY-cos(Pos*Pi/6000)*YExt;
|
||||
rv = ( Sx!=OldHour.StartX || Ex!=OldHour.EndX ||
|
||||
Sy!=OldHour.StartY || Ey!=OldHour.EndY );
|
||||
if (Globals.bAnalog && rv)DrawHourHand(dc);
|
||||
OldHour.StartX = Sx; OldHour.EndX = Ex;
|
||||
OldHour.StartY = Sy; OldHour.EndY = Ey;
|
||||
OldHour.DontRedraw=FALSE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
BOOL UpdateMinuteHand(HDC dc,int MidX,int MidY,int XExt,int YExt,WORD Pos)
|
||||
{
|
||||
int Sx, Sy, Ex, Ey;
|
||||
BOOL rv;
|
||||
|
||||
rv = FALSE;
|
||||
Sx = MidX; Sy = MidY;
|
||||
Ex = MidX+sin(Pos*Pi/30000)*XExt;
|
||||
Ey = MidY-cos(Pos*Pi/30000)*YExt;
|
||||
rv = ( Sx!=OldMinute.StartX || Ex!=OldMinute.EndX ||
|
||||
Sy!=OldMinute.StartY || Ey!=OldMinute.EndY );
|
||||
if (Globals.bAnalog && rv)DrawMinuteHand(dc);
|
||||
OldMinute.StartX = Sx; OldMinute.EndX = Ex;
|
||||
OldMinute.StartY = Sy; OldMinute.EndY = Ey;
|
||||
OldMinute.DontRedraw=FALSE;
|
||||
return rv;
|
||||
int Sx, Sy, Ex, Ey;
|
||||
BOOL rv;
|
||||
|
||||
rv = FALSE;
|
||||
Sx = MidX; Sy = MidY;
|
||||
Ex = MidX+sin(Pos*Pi/30000)*XExt;
|
||||
Ey = MidY-cos(Pos*Pi/30000)*YExt;
|
||||
rv = ( Sx!=OldMinute.StartX || Ex!=OldMinute.EndX ||
|
||||
Sy!=OldMinute.StartY || Ey!=OldMinute.EndY );
|
||||
if (Globals.bAnalog && rv)DrawMinuteHand(dc);
|
||||
OldMinute.StartX = Sx; OldMinute.EndX = Ex;
|
||||
OldMinute.StartY = Sy; OldMinute.EndY = Ey;
|
||||
OldMinute.DontRedraw=FALSE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
BOOL UpdateSecondHand(HDC dc,int MidX,int MidY,int XExt,int YExt,WORD Pos)
|
||||
{
|
||||
int Sx, Sy, Ex, Ey;
|
||||
BOOL rv;
|
||||
int Sx, Sy, Ex, Ey;
|
||||
BOOL rv;
|
||||
|
||||
rv = FALSE;
|
||||
rv = FALSE;
|
||||
|
||||
if (Globals.bSeconds) {
|
||||
Sx = MidX; Sy = MidY;
|
||||
Ex = MidX+sin(Pos*Pi/3000)*XExt;
|
||||
Ey = MidY-cos(Pos*Pi/3000)*YExt;
|
||||
rv = ( Sx!=OldSecond.StartX || Ex!=OldSecond.EndX ||
|
||||
Sy!=OldSecond.StartY || Ey!=OldSecond.EndY );
|
||||
if (Globals.bAnalog && rv) DrawSecondHand(dc);
|
||||
OldSecond.StartX = Sx; OldSecond.EndX = Ex;
|
||||
OldSecond.StartY = Sy; OldSecond.EndY = Ey;
|
||||
OldSecond.DontRedraw=FALSE;
|
||||
}
|
||||
if (Globals.bSeconds) {
|
||||
Sx = MidX; Sy = MidY;
|
||||
Ex = MidX+sin(Pos*Pi/3000)*XExt;
|
||||
Ey = MidY-cos(Pos*Pi/3000)*YExt;
|
||||
rv = ( Sx!=OldSecond.StartX || Ex!=OldSecond.EndX ||
|
||||
Sy!=OldSecond.StartY || Ey!=OldSecond.EndY );
|
||||
if (Globals.bAnalog && rv) DrawSecondHand(dc);
|
||||
OldSecond.StartX = Sx; OldSecond.EndX = Ex;
|
||||
OldSecond.StartY = Sy; OldSecond.EndY = Ey;
|
||||
OldSecond.DontRedraw=FALSE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
void DigitalClock(HDC dc) {
|
||||
void DigitalClock(HDC dc)
|
||||
{
|
||||
CHAR szTime[MAX_STRING_LEN];
|
||||
LPSTR time = szTime;
|
||||
static short xChar, yChar;
|
||||
TEXTMETRIC tm;
|
||||
|
||||
CHAR szTime[MAX_STRING_LEN];
|
||||
LPSTR time = szTime;
|
||||
static short xChar, yChar;
|
||||
TEXTMETRIC tm;
|
||||
|
||||
SYSTEMTIME st;
|
||||
LPSYSTEMTIME lpst = &st;
|
||||
|
||||
GetLocalTime(&st);
|
||||
GetTimeFormat(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, lpst, NULL, time,
|
||||
MAX_STRING_LEN);
|
||||
|
||||
SelectObject(dc,CreatePen(PS_SOLID,1,FaceColor));
|
||||
xChar = tm.tmAveCharWidth;
|
||||
yChar = tm.tmHeight;
|
||||
|
||||
xChar = 100;
|
||||
yChar = 100;
|
||||
TextOut (dc, xChar, yChar, szTime, strlen (szTime));
|
||||
DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
|
||||
SYSTEMTIME st;
|
||||
LPSYSTEMTIME lpst = &st;
|
||||
|
||||
GetLocalTime(&st);
|
||||
GetTimeFormat(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, lpst, NULL, time,
|
||||
MAX_STRING_LEN);
|
||||
|
||||
SelectObject(dc,CreatePen(PS_SOLID,1,FaceColor));
|
||||
xChar = tm.tmAveCharWidth;
|
||||
yChar = tm.tmHeight;
|
||||
|
||||
xChar = 100;
|
||||
yChar = 100;
|
||||
TextOut (dc, xChar, yChar, szTime, strlen (szTime));
|
||||
DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AnalogClock(HDC dc) {
|
||||
void AnalogClock(HDC dc)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
WORD H, M, S, F;
|
||||
int MidX, MidY, DiffX, DiffY;
|
||||
BOOL Redraw;
|
||||
|
||||
SYSTEMTIME st;
|
||||
WORD H, M, S, F;
|
||||
int MidX, MidY, DiffX, DiffY;
|
||||
BOOL Redraw;
|
||||
GetLocalTime(&st);
|
||||
|
||||
S = st.wSecond;
|
||||
nLastSecond = S;
|
||||
H = st.wHour;
|
||||
M = st.wMinute;
|
||||
F = st.wMilliseconds / 10;
|
||||
F = F + S*100;
|
||||
M = M*1000+F/6;
|
||||
H = H*1000+M/60;
|
||||
MidX = MiddleX();
|
||||
MidY = MiddleY();
|
||||
DiffX = (Globals.MaxX-MidX*2)/2;
|
||||
DiffY = (Globals.MaxY-MidY*2)/2;
|
||||
|
||||
GetLocalTime(&st);
|
||||
SelectObject(dc,CreatePen(PS_SOLID,1,FaceColor));
|
||||
Redraw = FALSE;
|
||||
if(UpdateHourHand(dc,MidX+DiffX,MidY+DiffY,MidX*0.5,MidY*0.5,H)) Redraw = TRUE;
|
||||
if(UpdateMinuteHand(dc,MidX+DiffX,MidY+DiffY,MidX*0.65,MidY*0.65,M)) Redraw = TRUE;
|
||||
if(UpdateSecondHand(dc,MidX+DiffX,MidY+DiffY,MidX*0.79,MidY*0.79,F)) Redraw = TRUE;
|
||||
|
||||
S = st.wSecond;
|
||||
nLastSecond = S;
|
||||
H = st.wHour;
|
||||
M = st.wMinute;
|
||||
F = st.wMilliseconds / 10;
|
||||
F = F + S*100;
|
||||
M = M*1000+F/6;
|
||||
H = H*1000+M/60;
|
||||
MidX = MiddleX();
|
||||
MidY = MiddleY();
|
||||
DiffX = (Globals.MaxX-MidX*2)/2;
|
||||
DiffY = (Globals.MaxY-MidY*2)/2;
|
||||
|
||||
SelectObject(dc,CreatePen(PS_SOLID,1,FaceColor));
|
||||
Redraw = FALSE;
|
||||
if(UpdateHourHand(dc,MidX+DiffX,MidY+DiffY,MidX*0.5,MidY*0.5,H)) Redraw = TRUE;
|
||||
if(UpdateMinuteHand(dc,MidX+DiffX,MidY+DiffY,MidX*0.65,MidY*0.65,M)) Redraw = TRUE;
|
||||
if(UpdateSecondHand(dc,MidX+DiffX,MidY+DiffY,MidX*0.79,MidY*0.79,F)) Redraw = TRUE;
|
||||
|
||||
DeleteObject(SelectObject(dc,CreatePen(PS_SOLID,1,HandColor)));
|
||||
DeleteObject(SelectObject(dc,CreatePen(PS_SOLID,1,HandColor)));
|
||||
if(Redraw)
|
||||
{
|
||||
{
|
||||
DrawSecondHand(dc);
|
||||
DrawMinuteHand(dc);
|
||||
DrawHourHand(dc);
|
||||
}
|
||||
DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
|
||||
|
||||
}
|
||||
DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
|
||||
}
|
||||
|
||||
void Idle(HDC idc)
|
||||
{
|
||||
HDC context;
|
||||
|
||||
if(idc)
|
||||
HDC context;
|
||||
|
||||
if(idc)
|
||||
context=idc;
|
||||
else
|
||||
else
|
||||
context=GetDC(Globals.hMainWnd);
|
||||
|
||||
if (!context) return;
|
||||
|
||||
if (Globals.bAnalog)
|
||||
{
|
||||
AnalogClock(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
DigitalClock(context);
|
||||
}
|
||||
if(!idc) ReleaseDC(Globals.hMainWnd, context);
|
||||
if (!context) return;
|
||||
|
||||
if (Globals.bAnalog)
|
||||
{
|
||||
AnalogClock(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
DigitalClock(context);
|
||||
}
|
||||
if(!idc) ReleaseDC(Globals.hMainWnd, context);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue