[clock07] Implement remaining menu items

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unfortunately 'Always on Top', 'L button drag' & ''No titlebar' don't work except in desktop mode, but I checked that the code works fine on XP

Deleted language.c,h

Changelog
	+ Implement 'Choose font', 'No title', 'Always on Top'
	+ Paint to offscreen bitmap to eliminate flicker
	+ Put 'Always on top' on the main menu not the system menu
	+ Date format should be DATE_LONGDATE
	+ L button drag to move
	+ Cosmetic adjustments
	
diff -u -r programs/clock/clock_res.h programs/clock/clock_res.h
--- programs/clock/clock_res.h	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/clock_res.h	2003-12-08 11:25:47.000000000 +0000
@@ -31,4 +31,3 @@
 #define IDM_ONTOP                 0x113
 
 #define IDS_CLOCK                 0x10C
-#define IDS_ONTOP                 0x10D
diff -u -r programs/clock/Da.rc programs/clock/Da.rc
--- programs/clock/Da.rc	2003-12-03 15:35:26.000000000 +0000
+++ programs/clock/Da.rc	2003-12-08 11:34:11.000000000 +0000
@@ -31,6 +31,8 @@
   MENUITEM SEPARATOR
   MENUITEM "Se&kunder", IDM_SECONDS
   MENUITEM "Da&to", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Altid øverst", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Licens...", IDM_LICENSE
@@ -42,5 +44,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_DANISH, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Ur"
-IDS_ONTOP, "&Altid øverst"
 }
diff -u -r programs/clock/De.rc programs/clock/De.rc
--- programs/clock/De.rc	2003-12-03 15:35:26.000000000 +0000
+++ programs/clock/De.rc	2003-12-08 11:34:11.000000000 +0000
@@ -31,6 +31,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Sekunden", IDM_SECONDS
   MENUITEM "&Datum", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Immer im Vordergrund", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Lizenz...", IDM_LICENSE
@@ -42,5 +44,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Uhr"
-IDS_ONTOP, "&Immer im Vordergrund"
 }
diff -u -r programs/clock/En.rc programs/clock/En.rc
--- programs/clock/En.rc	2003-12-03 15:35:26.000000000 +0000
+++ programs/clock/En.rc	2003-12-08 11:34:11.000000000 +0000
@@ -33,6 +33,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Seconds", IDM_SECONDS
   MENUITEM "&Date", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Always on Top", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&License...", IDM_LICENSE
@@ -44,5 +46,4 @@
 STRINGTABLE DISCARDABLE
 {
 IDS_CLOCK, "Clock"
-IDS_ONTOP, "&Always on Top"
 }
diff -u -r programs/clock/Es.rc programs/clock/Es.rc
--- programs/clock/Es.rc	2003-12-03 15:35:26.000000000 +0000
+++ programs/clock/Es.rc	2003-12-08 11:34:11.000000000 +0000
@@ -33,6 +33,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Segundos", IDM_SECONDS
   MENUITEM "Fe&cha", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "Siempre &visible", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Licencia...", IDM_LICENSE
@@ -44,5 +46,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_SPANISH, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Reloj"
-IDS_ONTOP, "Siempre &visible"
 }
diff -u -r programs/clock/Fi.rc programs/clock/Fi.rc
--- programs/clock/Fi.rc	2003-12-03 15:35:26.000000000 +0000
+++ programs/clock/Fi.rc	2003-12-08 11:34:11.000000000 +0000
@@ -31,6 +31,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Sekunnit", IDM_SECONDS
   MENUITEM "&Päivämäärä", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Aina päällimmäisenä", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Lisenssi...", IDM_LICENSE
@@ -42,5 +44,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Kello"
-IDS_ONTOP, "&Aina päällimmäisenä"
 }
diff -u -r programs/clock/Fr.rc programs/clock/Fr.rc
--- programs/clock/Fr.rc	2003-12-03 15:35:26.000000000 +0000
+++ programs/clock/Fr.rc	2003-12-08 11:34:11.000000000 +0000
@@ -33,6 +33,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Secondes", IDM_SECONDS
   MENUITEM "&Date", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Toujours visible", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Licence...", IDM_LICENSE
@@ -44,5 +46,4 @@
 STRINGTABLE DISCARDABLE
 {
 IDS_CLOCK, "Horloge"
-IDS_ONTOP, "&Toujours visible"
 }
diff -u -r programs/clock/Hu.rc programs/clock/Hu.rc
--- programs/clock/Hu.rc	2003-12-03 15:35:26.000000000 +0000
+++ programs/clock/Hu.rc	2003-12-08 11:34:11.000000000 +0000
@@ -32,6 +32,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Másodperc", IDM_SECONDS
   MENUITEM "&Dátum", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Mindig legfelül", IDM_ONTOP
  }
  POPUP "Inf&ormáció" {
   MENUITEM "&Licenc...", IDM_LICENSE
@@ -43,5 +45,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Óra"
-IDS_ONTOP, "&Mindig legfelül"
 }
diff -u -r programs/clock/It.rc programs/clock/It.rc
--- programs/clock/It.rc	2003-12-03 15:35:26.000000000 +0000
+++ programs/clock/It.rc	2003-12-08 11:34:11.000000000 +0000
@@ -34,6 +34,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Secondi", IDM_SECONDS
   MENUITEM "&Data", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Sempre in primo piano", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Licenza...", IDM_LICENSE
@@ -45,5 +47,4 @@
 STRINGTABLE DISCARDABLE
 {
 IDS_CLOCK, "Orologio"
-IDS_ONTOP, "&Sempre in primo piano"
 }
Only in programs/clock/: language.c
Only in programs/clock/: language.h
diff -u -r programs/clock/main.c programs/clock/main.c
--- programs/clock/main.c	2003-12-03 15:35:28.000000000 +0000
+++ programs/clock/main.c	2003-12-08 11:45:03.000000000 +0000
@@ -23,8 +23,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "config.h"
-
 #include <stdio.h>
 
 #include "windows.h"
@@ -32,7 +30,6 @@
 
 #include "main.h"
 #include "license.h"
-#include "language.h"
 #include "winclock.h"
 
 #define INITIAL_WINDOW_SIZE 200
@@ -40,6 +37,54 @@
 
 CLOCK_GLOBALS Globals;
 
+static VOID CLOCK_UpdateMenuCheckmarks(VOID)
+{
+    HMENU hPropertiesMenu;
+    hPropertiesMenu = GetSubMenu(Globals.hMainMenu, 0);
+    if (!hPropertiesMenu)
+	return;
+
+    if(Globals.bAnalog) {
+
+        /* analog clock */
+        CheckMenuRadioItem(hPropertiesMenu, IDM_ANALOG, IDM_DIGITAL, IDM_ANALOG, MF_CHECKED);
+        EnableMenuItem(hPropertiesMenu, IDM_FONT, MF_GRAYED);
+    }
+    else
+    {
+        /* digital clock */
+        CheckMenuRadioItem(hPropertiesMenu, IDM_ANALOG, IDM_DIGITAL, IDM_DIGITAL, MF_CHECKED);
+        EnableMenuItem(hPropertiesMenu, IDM_FONT, 0);
+    }
+
+    CheckMenuItem(hPropertiesMenu, IDM_NOTITLE, (Globals.bWithoutTitle ? MF_CHECKED : MF_UNCHECKED));
+
+    CheckMenuItem(hPropertiesMenu, IDM_ONTOP, (Globals.bAlwaysOnTop ? MF_CHECKED : MF_UNCHECKED));
+    CheckMenuItem(hPropertiesMenu, IDM_SECONDS, (Globals.bSeconds ? MF_CHECKED : MF_UNCHECKED));
+    CheckMenuItem(hPropertiesMenu, IDM_DATE, (Globals.bDate ? MF_CHECKED : MF_UNCHECKED));
+}
+
+static VOID CLOCK_UpdateWindowCaption(VOID)
+{
+    CHAR szCaption[MAX_STRING_LEN];
+    int chars = 0;
+
+    /* Set frame caption */
+    if (Globals.bDate) {
+	chars = GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, NULL, NULL,
+			      szCaption, sizeof(szCaption));
+        if (chars) {
+	    --chars;
+	    szCaption[chars++] = ' ';
+	    szCaption[chars++] = '-';
+	    szCaption[chars++] = ' ';
+	    szCaption[chars] = '\0';
+	}
+    }
+    LoadString(0, IDS_CLOCK, szCaption + chars, sizeof(szCaption) - chars);
+    SetWindowText(Globals.hMainWnd, szCaption);
+}
+
 /***********************************************************************
  *
  *           CLOCK_ResetTimer
@@ -69,12 +114,90 @@
 
 /***********************************************************************
  *
+ *           CLOCK_ResetFont
+ */
+static VOID CLOCK_ResetFont(VOID)
+{
+    HFONT newfont;
+    HDC dc = GetDC(Globals.hMainWnd);
+    newfont = SizeFont(dc, Globals.MaxX, Globals.MaxY, Globals.bSeconds, &Globals.logfont);
+    if (newfont) {
+	DeleteObject(Globals.hFont);
+	Globals.hFont = newfont;
+    }
+	
+    ReleaseDC(Globals.hMainWnd, dc);
+}
+
+
+/***********************************************************************
+ *
+ *           CLOCK_ChooseFont
+ */
+static VOID CLOCK_ChooseFont(VOID)
+{
+    LOGFONT lf;
+    CHOOSEFONT cf;
+    memset(&cf, 0, sizeof(cf));
+    lf = Globals.logfont;
+    cf.lStructSize = sizeof(cf);
+    cf.hwndOwner = Globals.hMainWnd;
+    cf.lpLogFont = &lf;
+    cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
+    if (ChooseFont(&cf)) {
+	Globals.logfont = lf;
+	CLOCK_ResetFont();
+    }
+}
+
+/***********************************************************************
+ *
+ *           CLOCK_ToggleTitle
+ */
+static VOID CLOCK_ToggleTitle(VOID)
+{
+    /* Also shows/hides the menu */
+    LONG style = GetWindowLong(Globals.hMainWnd, GWL_STYLE);
+    if ((Globals.bWithoutTitle = !Globals.bWithoutTitle)) {
+	style = (style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP|WS_THICKFRAME;
+	SetMenu(Globals.hMainWnd, 0);
+    }
+    else {
+	style = (style & ~(WS_POPUP|WS_THICKFRAME)) | WS_OVERLAPPEDWINDOW;
+        SetMenu(Globals.hMainWnd, Globals.hMainMenu);
+    }
+    SetWindowLong(Globals.hMainWnd, GWL_STYLE, style);
+    SetWindowPos(Globals.hMainWnd, 0,0,0,0,0, 
+		 SWP_DRAWFRAME|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
+    
+    CLOCK_UpdateMenuCheckmarks();
+    CLOCK_UpdateWindowCaption();
+}
+
+/***********************************************************************
+ *
+ *           CLOCK_ToggleOnTop
+ */
+static VOID CLOCK_ToggleOnTop(VOID)
+{
+    if ((Globals.bAlwaysOnTop = !Globals.bAlwaysOnTop)) {
+	SetWindowPos(Globals.hMainWnd, HWND_TOPMOST, 0,0,0,0,
+		     SWP_NOMOVE|SWP_NOSIZE);
+    }
+    else {
+	SetWindowPos(Globals.hMainWnd, HWND_NOTOPMOST, 0,0,0,0,
+		     SWP_NOMOVE|SWP_NOSIZE);
+    }
+    CLOCK_UpdateMenuCheckmarks();
+}
+/***********************************************************************
+ *
  *           CLOCK_MenuCommand
  *
  *  All handling of main menu events
  */
 
-int CLOCK_MenuCommand (WPARAM wParam)
+static int CLOCK_MenuCommand (WPARAM wParam)
 {
     CHAR szApp[MAX_STRING_LEN];
     CHAR szAppRelease[MAX_STRING_LEN];
@@ -82,7 +205,7 @@
         /* switch to analog */
         case IDM_ANALOG: {
             Globals.bAnalog = TRUE;
-            LANGUAGE_UpdateMenuCheckmarks();
+            CLOCK_UpdateMenuCheckmarks();
 	    CLOCK_ResetTimer();
 	    InvalidateRect(Globals.hMainWnd, NULL, FALSE);
             break;
@@ -90,42 +213,42 @@
             /* switch to digital */
         case IDM_DIGITAL: {
             Globals.bAnalog = FALSE;
-            LANGUAGE_UpdateMenuCheckmarks();
+            CLOCK_UpdateMenuCheckmarks();
 	    CLOCK_ResetTimer();
+	    CLOCK_ResetFont();
 	    InvalidateRect(Globals.hMainWnd, NULL, FALSE);
             break;
         }
             /* change font */
         case IDM_FONT: {
-            MAIN_FileChooseFont();
+            CLOCK_ChooseFont();
             break;
         }
             /* hide title bar */
         case IDM_NOTITLE: {
-            Globals.bWithoutTitle = !Globals.bWithoutTitle;
-            LANGUAGE_UpdateWindowCaption();
-            LANGUAGE_UpdateMenuCheckmarks();
+	    CLOCK_ToggleTitle();
             break;
         }
             /* always on top */
         case IDM_ONTOP: {
-            Globals.bAlwaysOnTop = !Globals.bAlwaysOnTop;
-            LANGUAGE_UpdateMenuCheckmarks();
+	    CLOCK_ToggleOnTop();
             break;
         }
             /* show or hide seconds */
         case IDM_SECONDS: {
             Globals.bSeconds = !Globals.bSeconds;
-            LANGUAGE_UpdateMenuCheckmarks();
+            CLOCK_UpdateMenuCheckmarks();
 	    CLOCK_ResetTimer();
+	    if (!Globals.bAnalog)
+		CLOCK_ResetFont();
 	    InvalidateRect(Globals.hMainWnd, NULL, FALSE);
             break;
         }
             /* show or hide date */
         case IDM_DATE: {
             Globals.bDate = !Globals.bDate;
-            LANGUAGE_UpdateMenuCheckmarks();
-            LANGUAGE_UpdateWindowCaption();
+            CLOCK_UpdateMenuCheckmarks();
+            CLOCK_UpdateWindowCaption();
             break;
         }
             /* show license */
@@ -142,7 +265,6 @@
         case IDM_ABOUT: {
             LoadString(Globals.hInstance, IDS_CLOCK, szApp, sizeof(szApp));
             lstrcpy(szAppRelease,szApp);
-            lstrcat(szAppRelease,"\n" PACKAGE_STRING);
             ShellAbout(Globals.hMainWnd, szApp, szAppRelease, 0);
             break;
         }
@@ -150,30 +272,47 @@
     return 0;
 }
 
-VOID MAIN_FileChooseFont(VOID)
+/***********************************************************************
+ *
+ *           CLOCK_Paint
+ */
+static VOID CLOCK_Paint(HWND hWnd)
 {
-    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;
+    PAINTSTRUCT ps;
+    HDC dcMem, dc;
+    HBITMAP bmMem, bmOld;
+
+    dc = BeginPaint(hWnd, &ps);
+
+    /* Use an offscreen dc to avoid flicker */
+    dcMem = CreateCompatibleDC(dc);
+    bmMem = CreateCompatibleBitmap(dc, ps.rcPaint.right - ps.rcPaint.left,
+				    ps.rcPaint.bottom - ps.rcPaint.top);
+
+    bmOld = SelectObject(dcMem, bmMem);
+
+    SetViewportOrgEx(dcMem, -ps.rcPaint.left, -ps.rcPaint.top, NULL);
+    /* Erase the background */
+    FillRect(dcMem, &ps.rcPaint, GetStockObject(LTGRAY_BRUSH));
+
+    if(Globals.bAnalog)
+	AnalogClock(dcMem, Globals.MaxX, Globals.MaxY, Globals.bSeconds);
+    else
+	DigitalClock(dcMem, Globals.MaxX, Globals.MaxY, Globals.bSeconds, Globals.hFont);
+
+    /* Blit the changes to the screen */
+    BitBlt(dc, 
+	   ps.rcPaint.left, ps.rcPaint.top,
+	   ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top,
+           dcMem,
+	   ps.rcPaint.left, ps.rcPaint.top,
+           SRCCOPY);
+
+    SelectObject(dcMem, bmOld);
+    DeleteObject(bmMem);
+    DeleteDC(dcMem);
     
-    if (ChooseFont(&font)) {
-        /* do nothing yet */
-    }
+    EndPaint(hWnd, &ps);
 }
 
 /***********************************************************************
@@ -184,35 +323,30 @@
 LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     switch (msg) {
-      
-        case WM_CREATE: {
-            break;
-        }
-
-        case WM_RBUTTONUP: {
-            Globals.bWithoutTitle = !Globals.bWithoutTitle;
-            LANGUAGE_UpdateMenuCheckmarks();
-            LANGUAGE_UpdateWindowCaption();
-            UpdateWindow (Globals.hMainWnd);
+	/* L button drag moves the window */
+        case WM_NCHITTEST: {
+	    LRESULT ret = DefWindowProc (hWnd, msg, wParam, lParam);
+	    if (ret == HTCLIENT)
+		ret = HTCAPTION;
+            return ret;
+	}
+
+        case WM_NCLBUTTONDBLCLK:
+        case WM_LBUTTONDBLCLK: {
+	    CLOCK_ToggleTitle();
             break;
         }
 
         case WM_PAINT: {
-            PAINTSTRUCT ps;
-            HDC context;
-            
-            context = BeginPaint(hWnd, &ps);
-            if(Globals.bAnalog)
-                AnalogClock(context, Globals.MaxX, Globals.MaxY, Globals.bSeconds);
-            else
-                DigitalClock(context, Globals.MaxX, Globals.MaxY, Globals.bSeconds);
-            EndPaint(hWnd, &ps);
+	    CLOCK_Paint(hWnd);
             break;
+
         }
 
         case WM_SIZE: {
             Globals.MaxX = LOWORD(lParam);
             Globals.MaxY = HIWORD(lParam);
+	    CLOCK_ResetFont();
             break;
         }
 
@@ -255,27 +389,19 @@
     char szWinName[]   = "Clock";
     
     /* Setup Globals */
+    memset(&Globals.hFont, 0, sizeof (Globals.hFont));
     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 (!prev){
-        class.style         = CS_HREDRAW | CS_VREDRAW;
+        class.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
         class.lpfnWndProc   = CLOCK_WndProc;
         class.cbClsExtra    = 0;
         class.cbWndExtra    = 0;
-        class.hInstance     = Globals.hInstance;
+        class.hInstance     = hInstance;
         class.hIcon         = LoadIcon (0, IDI_APPLICATION);
         class.hCursor       = LoadCursor (0, IDC_ARROW);
-        class.hbrBackground = GetStockObject (GRAY_BRUSH);
+        class.hbrBackground = 0;
         class.lpszMenuName  = 0;
         class.lpszClassName = szClassName;
     }
@@ -286,15 +412,15 @@
     Globals.hMainWnd = CreateWindow (szClassName, szWinName, WS_OVERLAPPEDWINDOW,
                                      CW_USEDEFAULT, CW_USEDEFAULT,
                                      Globals.MaxX, Globals.MaxY, 0,
-                                     0, Globals.hInstance, 0);
+                                     0, hInstance, 0);
 
     if (!CLOCK_ResetTimer())
         return FALSE;
 
-    LANGUAGE_LoadMenus();
+    Globals.hMainMenu = LoadMenu(0, MAKEINTRESOURCE(MAIN_MENU));
     SetMenu(Globals.hMainWnd, Globals.hMainMenu);
-    
-    LANGUAGE_UpdateMenuCheckmarks();
+    CLOCK_UpdateMenuCheckmarks();
+    CLOCK_UpdateWindowCaption();
     
     ShowWindow (Globals.hMainWnd, show);
     UpdateWindow (Globals.hMainWnd);
@@ -305,6 +431,7 @@
     }
 
     KillTimer(Globals.hMainWnd, TIMER_ID);
+    DeleteObject(Globals.hFont);
 
     return 0;
 }
diff -u -r programs/clock/main.h programs/clock/main.h
--- programs/clock/main.h	2003-12-03 15:35:28.000000000 +0000
+++ programs/clock/main.h	2003-12-08 09:56:18.000000000 +0000
@@ -25,18 +25,11 @@
 
 typedef struct
 {
+  LOGFONT logfont;
+  HFONT   hFont;
   HANDLE  hInstance;
   HWND    hMainWnd;
-  HICON   hMainIcon;
-  HICON   hDefaultIcon;
   HMENU   hMainMenu;
-  HMENU   hPropertiesMenu;
-  HMENU   hLanguageMenu;
-  HMENU   hInfoMenu;
-  HMENU   hSystemMenu;
-  HMENU   hPopupMenu1;
-  LPCSTR  lpszIniFile;
-  LPCSTR  lpszIcoFile;
 
   BOOL    bAnalog;
   BOOL    bAlwaysOnTop;
@@ -49,6 +42,3 @@
 } CLOCK_GLOBALS;
 
 extern CLOCK_GLOBALS Globals;
-
-/* function prototypes */
-VOID MAIN_FileChooseFont(VOID);
diff -u -r programs/clock/Makefile.in programs/clock/Makefile.in
--- programs/clock/Makefile.in	2002-05-21 20:42:29.000000000 +0100
+++ programs/clock/Makefile.in	2003-12-08 10:13:32.000000000 +0000
@@ -9,7 +9,6 @@
 LICENSELANG = En
 
 C_SRCS = \
-	language.c \
 	license.c \
 	main.c \
 	winclock.c \
diff -u -r programs/clock/Nl.rc programs/clock/Nl.rc
--- programs/clock/Nl.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Nl.rc	2003-12-08 11:34:11.000000000 +0000
@@ -32,6 +32,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Seconden", IDM_SECONDS
   MENUITEM "Da&tum", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Altijd op de voorgrond", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Licentie...", IDM_LICENSE
@@ -43,5 +45,4 @@
 STRINGTABLE DISCARDABLE
 {
 IDS_CLOCK, "Klok"
-IDS_ONTOP, "&Altijd op de voorgrond"
 }
diff -u -r programs/clock/Pt.rc programs/clock/Pt.rc
--- programs/clock/Pt.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Pt.rc	2003-12-08 11:34:11.000000000 +0000
@@ -35,6 +35,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Segundos", IDM_SECONDS
   MENUITEM "&Data", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Sempre visível", IDM_ONTOP
  }
  POPUP "&Informações" {
   MENUITEM "&Licença...", IDM_LICENSE
@@ -46,5 +48,4 @@
 STRINGTABLE DISCARDABLE
 {
 IDS_CLOCK, "Relógio"
-IDS_ONTOP, "&Sempre visível"
 }
diff -u -r programs/clock/README programs/clock/README
--- programs/clock/README	2003-07-11 22:44:45.000000000 +0100
+++ programs/clock/README	2003-12-06 16:13:33.000000000 +0000
@@ -2,7 +2,4 @@
  Clock for Wine
  ==============
  
- This is a first attempt to realize a desktop clock for Wine as done in 
- Windows. It's an early release and some of the code is still broken.
-
  Originally contributed by <mbaur@xxxxxxxxxxx>
diff -u -r programs/clock/Ru.rc programs/clock/Ru.rc
--- programs/clock/Ru.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Ru.rc	2003-12-08 11:34:11.000000000 +0000
@@ -30,6 +30,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Ñåêóíäû", IDM_SECONDS
   MENUITEM "&Äàòà", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Ïîâåðõ âñåõ", IDM_ONTOP
  }
  POPUP "&Ñâåäåíèÿ" {
   MENUITEM "&Ëèöåíçèÿ...", IDM_LICENSE
@@ -41,5 +43,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "×àñû"
-IDS_ONTOP, "&Ïîâåðõ âñåõ"
 }
diff -u -r programs/clock/Si.rc programs/clock/Si.rc
--- programs/clock/Si.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Si.rc	2003-12-08 11:34:11.000000000 +0000
@@ -30,6 +30,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Sekunde", IDM_SECONDS
   MENUITEM "&Datum", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Vedno na vrhu", IDM_ONTOP
  }
  POPUP "Inf&ormacije " {
   MENUITEM "&Licenèna pogodba...", IDM_LICENSE
@@ -41,5 +43,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Ura"
-IDS_ONTOP, "&Vedno na vrhu"
 }
diff -u -r programs/clock/Sk.rc programs/clock/Sk.rc
--- programs/clock/Sk.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Sk.rc	2003-12-08 11:34:11.000000000 +0000
@@ -32,6 +32,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Sekundy", IDM_SECONDS
   MENUITEM "&Dátum", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&V?dy na vrchu", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Licencia...", IDM_LICENSE
@@ -43,5 +45,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Hodiny"
-IDS_ONTOP, "&V?dy na vrchu"
 }
diff -u -r programs/clock/Sw.rc programs/clock/Sw.rc
--- programs/clock/Sw.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Sw.rc	2003-12-08 11:34:11.000000000 +0000
@@ -32,6 +32,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Sekunder", IDM_SECONDS
   MENUITEM "&Datum", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "&Alltid överst", IDM_ONTOP
  }
  POPUP "Inf&o" {
   MENUITEM "&Licens...", IDM_LICENSE
@@ -43,5 +45,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Klockan"
-IDS_ONTOP, "&Alltid överst"
 }
diff -u -r programs/clock/Th.rc programs/clock/Th.rc
--- programs/clock/Th.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Th.rc	2003-12-08 11:34:11.000000000 +0000
@@ -32,6 +32,8 @@
   MENUITEM SEPARATOR
   MENUITEM "ÇÔ¹Ò·Õ", IDM_SECONDS
   MENUITEM "Çѹ·Õè", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "ÂÙº¹ÊØ´àÊÁÍ", IDM_ONTOP
  }
  POPUP "ÃÒÂÅÐàÍÕ´" {
   MENUITEM "ãºÍ¹Ø­Òµ...", IDM_LICENSE
@@ -43,5 +45,4 @@
 STRINGTABLE DISCARDABLE
 {
 IDS_CLOCK, "¹ÒÌÔ¡Ò"
-IDS_ONTOP, "ÂÙº¹ÊØ´àÊÁÍ"
 }
diff -u -r programs/clock/TODO programs/clock/TODO
--- programs/clock/TODO	2003-07-11 22:44:45.000000000 +0100
+++ programs/clock/TODO	2003-12-08 11:54:24.000000000 +0000
@@ -1,17 +1,4 @@
+'L button move', 'No title bar' & 'Always on top' don't work unless Wine is in
+desktop mode
 
-Some ideas for improvements:
-============================
-
-- Make "Without Titlebar", Double-clicking the clock should reveal the caption
-  again.
-
-- Font Handling of Digital Clock.
-  (Does not work probably due to Winelib)
-
-- Complete translation for the following languages : Pt,Sk
-
-- Add new .rc resources for all languages you know. That's in fact very easy. 
-  Just clone the file En.rc, change the strings and submit it. You can find
-  my email address in the README file.
-
-Please don't forget a ChangeLog entry.
+This is a problem in Wine, not in Clock
diff -u -r programs/clock/Wa.rc programs/clock/Wa.rc
--- programs/clock/Wa.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Wa.rc	2003-12-08 11:34:11.000000000 +0000
@@ -37,6 +37,8 @@
   MENUITEM SEPARATOR
   MENUITEM "&Segondes", IDM_SECONDS
   MENUITEM "&Date", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "Todi &Visibe", IDM_ONTOP
  }
  POPUP "&Informåcion" {
   MENUITEM "&Licinse...", IDM_LICENSE
@@ -48,7 +50,6 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_WALON, SUBLANG_DEFAULT
 {
 IDS_CLOCK, "Ôrlodje"
-IDS_ONTOP, "Todi &Visibe"
 }
 
 #endif  /* LANG_WALON */
diff -u -r programs/clock/winclock.c programs/clock/winclock.c
--- programs/clock/winclock.c	2003-12-03 15:35:28.000000000 +0000
+++ programs/clock/winclock.c	2003-12-08 12:10:00.000000000 +0000
@@ -23,7 +23,6 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
 #include "config.h"
 #include "wine/port.h"
 
@@ -33,11 +32,18 @@
 #include "windows.h"
 #include "winclock.h"
 
-static COLORREF FaceColor = RGB(192,192,192);
-static COLORREF HandColor = RGB(0,0,0);
-static COLORREF EtchColor = RGB(0,0,0);
-static COLORREF GRAY = RGB(128,128,128);
-static const int ETCH_DEPTH = 2;
+#define Black  RGB(0,0,0)
+#define Gray   RGB(128,128,128)
+#define LtGray RGB(192,192,192)
+#define White  RGB(255,255,255)
+
+static const COLORREF FaceColor = LtGray;
+static const COLORREF HandColor = White;
+static const COLORREF TickColor = White;
+static const COLORREF ShadowColor = Black;
+static const COLORREF BackgroundColor = LtGray;
+
+static const int SHADOW_DEPTH = 2;
  
 typedef struct
 {
@@ -47,17 +53,25 @@
 
 HandData HourHand, MinuteHand, SecondHand;
 
-static void DrawFace(HDC dc, const POINT* centre, int radius)
+static void DrawTicks(HDC dc, const POINT* centre, int radius)
 {
     int t;
 
-    SelectObject(dc,CreateSolidBrush(FaceColor));
-    SelectObject(dc,CreatePen(PS_SOLID,1,EtchColor));
-    Ellipse(dc,
-            centre->x - radius, centre->y - radius,
-            centre->x + radius, centre->y + radius);
+    /* Minute divisions */
+    if (radius>64)
+        for(t=0; t<60; t++) {
+            MoveToEx(dc,
+                     centre->x + sin(t*M_PI/30)*0.9*radius,
+                     centre->y - cos(t*M_PI/30)*0.9*radius,
+                     NULL);
+	    LineTo(dc,
+		   centre->x + sin(t*M_PI/30)*0.89*radius,
+		   centre->y - cos(t*M_PI/30)*0.89*radius);
+	}
 
+    /* Hour divisions */
     for(t=0; t<12; t++) {
+
         MoveToEx(dc,
                  centre->x + sin(t*M_PI/6)*0.9*radius,
                  centre->y - cos(t*M_PI/6)*0.9*radius,
@@ -66,14 +80,20 @@
                centre->x + sin(t*M_PI/6)*0.8*radius,
                centre->y - cos(t*M_PI/6)*0.8*radius);
     }
-    if (radius>64)
-        for(t=0; t<60; t++)
-            SetPixel(dc,
-                     centre->x + sin(t*M_PI/30)*0.9*radius,
-                     centre->y - cos(t*M_PI/30)*0.9*radius,
-                     EtchColor);
-    DeleteObject(SelectObject(dc,GetStockObject(NULL_BRUSH)));
-    DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
+}
+
+static void DrawFace(HDC dc, const POINT* centre, int radius)
+{
+    /* Ticks */
+    SelectObject(dc, CreatePen(PS_SOLID, 2, ShadowColor));
+    OffsetWindowOrgEx(dc, -SHADOW_DEPTH, -SHADOW_DEPTH, NULL);
+    DrawTicks(dc, centre, radius);
+    DeleteObject(SelectObject(dc, CreatePen(PS_SOLID, 2, TickColor)));
+    OffsetWindowOrgEx(dc, SHADOW_DEPTH, SHADOW_DEPTH, NULL);
+    DrawTicks(dc, centre, radius);
+
+    DeleteObject(SelectObject(dc, GetStockObject(NULL_BRUSH)));
+    DeleteObject(SelectObject(dc, GetStockObject(NULL_PEN)));
 }
 
 static void DrawHand(HDC dc,HandData* hand)
@@ -84,12 +104,32 @@
 
 static void DrawHands(HDC dc, BOOL bSeconds)
 {
-    SelectObject(dc,CreatePen(PS_SOLID,1,HandColor));
-    if (bSeconds)
+    if (bSeconds) {
+#if 0
+      	SelectObject(dc, CreatePen(PS_SOLID, 1, ShadowColor));
+	OffsetWindowOrgEx(dc, -SHADOW_DEPTH, -SHADOW_DEPTH, NULL);
+        DrawHand(dc, &SecondHand);
+	DeleteObject(SelectObject(dc, CreatePen(PS_SOLID, 1, HandColor)));
+	OffsetWindowOrgEx(dc, SHADOW_DEPTH, SHADOW_DEPTH, NULL);
+#else
+	SelectObject(dc, CreatePen(PS_SOLID, 1, HandColor));
+#endif
         DrawHand(dc, &SecondHand);
+	DeleteObject(SelectObject(dc, GetStockObject(NULL_PEN)));
+    }
+
+    SelectObject(dc, CreatePen(PS_SOLID, 4, ShadowColor));
+
+    OffsetWindowOrgEx(dc, -SHADOW_DEPTH, -SHADOW_DEPTH, NULL);
     DrawHand(dc, &MinuteHand);
     DrawHand(dc, &HourHand);
-    DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
+
+    DeleteObject(SelectObject(dc, CreatePen(PS_SOLID, 4, HandColor)));
+    OffsetWindowOrgEx(dc, SHADOW_DEPTH, SHADOW_DEPTH, NULL);
+    DrawHand(dc, &MinuteHand);
+    DrawHand(dc, &HourHand);
+
+    DeleteObject(SelectObject(dc, GetStockObject(NULL_PEN)));
 }
 
 static void PositionHand(const POINT* centre, double length, double angle, HandData* hand)
@@ -108,6 +148,7 @@
     /* Adding the millisecond count makes the second hand move more smoothly */
 
     GetLocalTime(&st);
+
     second = st.wSecond + st.wMilliseconds/1000.0;
     minute = st.wMinute + second/60.0;
     hour   = st.wHour % 12 + minute/60.0;
@@ -122,49 +163,79 @@
 {
     POINT centre;
     int radius;
-    radius = min(x, y)/2;
+    
+    radius = min(x, y)/2 - SHADOW_DEPTH;
+    if (radius < 0)
+	return;
 
     centre.x = x/2;
     centre.y = y/2;
 
     DrawFace(dc, &centre, radius);
+
     PositionHands(&centre, radius, bSeconds);
     DrawHands(dc, bSeconds);
 }
 
-void DigitalClock(HDC dc, int x, int y, BOOL bSeconds)
+
+HFONT SizeFont(HDC dc, int x, int y, BOOL bSeconds, const LOGFONT* font)
 {
-    CHAR szTime[255];
     SIZE extent;
     LOGFONT lf;
     double xscale, yscale;
-    HFONT oldFont;
+    HFONT oldFont, newFont;
+    CHAR szTime[255];
+    int chars;
 
-    GetTimeFormat(LOCALE_USER_DEFAULT, bSeconds ? 0 : TIME_NOSECONDS, NULL,
-		  NULL, szTime, sizeof (szTime));
+    chars = GetTimeFormat(LOCALE_USER_DEFAULT, bSeconds ? 0 : TIME_NOSECONDS, NULL,
+			  NULL, szTime, sizeof (szTime));
+    if (!chars)
+	return 0;
 
-    memset(&lf, 0, sizeof (lf));
+    --chars;
+
+    lf = *font;
     lf.lfHeight = -20;
 
-    x -= 2 * ETCH_DEPTH;
-    y -= 2 * ETCH_DEPTH;
+    x -= 2 * SHADOW_DEPTH;
+    y -= 2 * SHADOW_DEPTH;
 
     oldFont = SelectObject(dc, CreateFontIndirect(&lf));
-    GetTextExtentPoint(dc, szTime, strlen(szTime), &extent);
+    GetTextExtentPoint(dc, szTime, chars, &extent);
+    DeleteObject(SelectObject(dc, oldFont));
+
     xscale = (double)x/extent.cx;
     yscale = (double)y/extent.cy;
-    lf.lfHeight *= min(xscale, yscale);
+    lf.lfHeight *= min(xscale, yscale);    
+    newFont = CreateFontIndirect(&lf);
+
+    return newFont;
+}
 
-    DeleteObject(SelectObject(dc, CreateFontIndirect(&lf)));
-    GetTextExtentPoint(dc, szTime, strlen(szTime), &extent);
+void DigitalClock(HDC dc, int x, int y, BOOL bSeconds, HFONT font)
+{
+    SIZE extent;
+    HFONT oldFont;
+    CHAR szTime[255];
+    int chars;
 
-    SetBkColor(dc, GRAY); /* to match the background brush */
-    SetTextColor(dc, EtchColor);
-    TextOut(dc, (x - extent.cx)/2 + ETCH_DEPTH, (y - extent.cy)/2 + ETCH_DEPTH,
-	    szTime, strlen(szTime));
+    chars = GetTimeFormat(LOCALE_USER_DEFAULT, bSeconds ? 0 : TIME_NOSECONDS, NULL,
+		  NULL, szTime, sizeof (szTime));
+    if (!chars)
+	return;
+    --chars;
+
+    oldFont = SelectObject(dc, font);
+    GetTextExtentPoint(dc, szTime, chars, &extent);
+
+    SetBkColor(dc, BackgroundColor);
+    SetTextColor(dc, ShadowColor);
+    TextOut(dc, (x - extent.cx)/2 + SHADOW_DEPTH, (y - extent.cy)/2 + SHADOW_DEPTH,
+	    szTime, chars);
     SetBkMode(dc, TRANSPARENT);
 
-    SetTextColor(dc, FaceColor);
-    TextOut(dc, (x - extent.cx)/2, (y - extent.cy)/2, szTime, strlen(szTime));
-    DeleteObject(SelectObject(dc, oldFont));
+    SetTextColor(dc, HandColor);
+    TextOut(dc, (x - extent.cx)/2, (y - extent.cy)/2, szTime, chars);
+
+    SelectObject(dc, oldFont);
 }
diff -u -r programs/clock/winclock.h programs/clock/winclock.h
--- programs/clock/winclock.h	2003-12-03 15:35:28.000000000 +0000
+++ programs/clock/winclock.h	2003-12-05 13:20:44.000000000 +0000
@@ -22,4 +22,5 @@
  */
 
 void AnalogClock(HDC dc, int X, int Y, BOOL bSeconds);
-void DigitalClock(HDC dc, int X, int Y, BOOL bSeconds);
+HFONT SizeFont(HDC dc, int x, int y, BOOL bSeconds, const LOGFONT* font);
+void DigitalClock(HDC dc, int X, int Y, BOOL bSeconds, HFONT font);
diff -u -r programs/clock/Zh.rc programs/clock/Zh.rc
--- programs/clock/Zh.rc	2003-12-03 15:35:27.000000000 +0000
+++ programs/clock/Zh.rc	2003-12-08 11:34:11.000000000 +0000
@@ -30,6 +30,8 @@
   MENUITEM SEPARATOR
   MENUITEM "Ã루&£©", IDM_SECONDS
   MENUITEM "ÈÕÆÚ£¨&D£©", IDM_DATE
+  MENUITEM SEPARATOR
+  MENUITEM "×ÜÊÇÔÚ×îÇ°Ã棨&A£©", IDM_ONTOP
  }
  POPUP "×ÊÁÏÐÅÏ¢£¨&O£©" {
   MENUITEM "Óû§Ðí¿ÉЭÒ飨&L£©...", IDM_LICENSE
@@ -41,5 +43,4 @@
 STRINGTABLE DISCARDABLE LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
 {
 IDS_CLOCK, "ʱÖÓ"
-IDS_ONTOP, "×ÜÊÇÔÚ×îÇ°Ã棨&A£©"
 }

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux