Commit cc8c205a authored by Richard Cohen's avatar Richard Cohen Committed by Alexandre Julliard

- 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.
parent 7499242f
......@@ -31,6 +31,8 @@ MAIN_MENU MENU LANGUAGE LANG_DANISH, SUBLANG_DEFAULT
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 @@ MAIN_MENU MENU LANGUAGE LANG_DANISH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_DANISH, SUBLANG_DEFAULT
{
IDS_CLOCK, "Ur"
IDS_ONTOP, "&Altid verst"
}
......@@ -31,6 +31,8 @@ MAIN_MENU MENU LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
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 @@ MAIN_MENU MENU LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
{
IDS_CLOCK, "Uhr"
IDS_ONTOP, "&Immer im Vordergrund"
}
......@@ -33,6 +33,8 @@ MAIN_MENU MENU
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 @@ MAIN_MENU MENU
STRINGTABLE DISCARDABLE
{
IDS_CLOCK, "Clock"
IDS_ONTOP, "&Always on Top"
}
......@@ -33,6 +33,8 @@ MAIN_MENU MENU LANGUAGE LANG_SPANISH, SUBLANG_DEFAULT
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 @@ MAIN_MENU MENU LANGUAGE LANG_SPANISH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_SPANISH, SUBLANG_DEFAULT
{
IDS_CLOCK, "Reloj"
IDS_ONTOP, "Siempre &visible"
}
......@@ -31,6 +31,8 @@ MAIN_MENU MENU LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
MENUITEM SEPARATOR
MENUITEM "&Sekunnit", IDM_SECONDS
MENUITEM "&Pivmr", IDM_DATE
MENUITEM SEPARATOR
MENUITEM "&Aina pllimmisen", IDM_ONTOP
}
POPUP "Inf&o" {
MENUITEM "&Lisenssi...", IDM_LICENSE
......@@ -42,5 +44,4 @@ MAIN_MENU MENU LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
{
IDS_CLOCK, "Kello"
IDS_ONTOP, "&Aina pllimmisen"
}
......@@ -33,6 +33,8 @@ MAIN_MENU MENU
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 @@ MAIN_MENU MENU
STRINGTABLE DISCARDABLE
{
IDS_CLOCK, "Horloge"
IDS_ONTOP, "&Toujours visible"
}
......@@ -32,6 +32,8 @@ MAIN_MENU MENU LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
MENUITEM SEPARATOR
MENUITEM "&Msodperc", IDM_SECONDS
MENUITEM "&Dtum", IDM_DATE
MENUITEM SEPARATOR
MENUITEM "&Mindig legfell", IDM_ONTOP
}
POPUP "Inf&ormci" {
MENUITEM "&Licenc...", IDM_LICENSE
......@@ -43,5 +45,4 @@ MAIN_MENU MENU LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
{
IDS_CLOCK, "ra"
IDS_ONTOP, "&Mindig legfell"
}
......@@ -34,6 +34,8 @@ MAIN_MENU MENU
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 @@ MAIN_MENU MENU
STRINGTABLE DISCARDABLE
{
IDS_CLOCK, "Orologio"
IDS_ONTOP, "&Sempre in primo piano"
}
......@@ -9,7 +9,6 @@ IMPORTS = comdlg32 shell32 user32 gdi32 kernel32
LICENSELANG = En
C_SRCS = \
language.c \
license.c \
main.c \
winclock.c \
......
......@@ -32,6 +32,8 @@ MAIN_MENU MENU
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 @@ MAIN_MENU MENU
STRINGTABLE DISCARDABLE
{
IDS_CLOCK, "Klok"
IDS_ONTOP, "&Altijd op de voorgrond"
}
......@@ -35,6 +35,8 @@ MAIN_MENU MENU
MENUITEM SEPARATOR
MENUITEM "&Segundos", IDM_SECONDS
MENUITEM "&Data", IDM_DATE
MENUITEM SEPARATOR
MENUITEM "&Sempre visvel", IDM_ONTOP
}
POPUP "&Informaes" {
MENUITEM "&Licena...", IDM_LICENSE
......@@ -46,5 +48,4 @@ MAIN_MENU MENU
STRINGTABLE DISCARDABLE
{
IDS_CLOCK, "Relgio"
IDS_ONTOP, "&Sempre visvel"
}
......@@ -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@g26.ethz.ch>
......@@ -30,6 +30,8 @@ MAIN_MENU MENU LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
MENUITEM SEPARATOR
MENUITEM "&", IDM_SECONDS
MENUITEM "&", IDM_DATE
MENUITEM SEPARATOR
MENUITEM "& ", IDM_ONTOP
}
POPUP "&" {
MENUITEM "&...", IDM_LICENSE
......@@ -41,5 +43,4 @@ MAIN_MENU MENU LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
{
IDS_CLOCK, ""
IDS_ONTOP, "& "
}
......@@ -30,6 +30,8 @@ MAIN_MENU MENU LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT
MENUITEM SEPARATOR
MENUITEM "&Sekunde", IDM_SECONDS
MENUITEM "&Datum", IDM_DATE
MENUITEM SEPARATOR
MENUITEM "&Vedno na vrhu", IDM_ONTOP
}
POPUP "Inf&ormacije " {
MENUITEM "&Licenna pogodba...", IDM_LICENSE
......@@ -41,5 +43,4 @@ MAIN_MENU MENU LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT
{
IDS_CLOCK, "Ura"
IDS_ONTOP, "&Vedno na vrhu"
}
......@@ -32,6 +32,8 @@ MAIN_MENU MENU LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
MENUITEM SEPARATOR
MENUITEM "&Sekundy", IDM_SECONDS
MENUITEM "&Dtum", IDM_DATE
MENUITEM SEPARATOR
MENUITEM "&Vdy na vrchu", IDM_ONTOP
}
POPUP "Inf&o" {
MENUITEM "&Licencia...", IDM_LICENSE
......@@ -43,5 +45,4 @@ MAIN_MENU MENU LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
{
IDS_CLOCK, "Hodiny"
IDS_ONTOP, "&Vdy na vrchu"
}
......@@ -32,6 +32,8 @@ MAIN_MENU MENU LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT
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 @@ MAIN_MENU MENU LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT
{
IDS_CLOCK, "Klockan"
IDS_ONTOP, "&Alltid verst"
}
'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
......@@ -32,6 +32,8 @@ MAIN_MENU MENU
MENUITEM SEPARATOR
MENUITEM "Թҷ", IDM_SECONDS
MENUITEM "ѹ", IDM_DATE
MENUITEM SEPARATOR
MENUITEM "ٺش", IDM_ONTOP
}
POPUP "´" {
MENUITEM "͹حҵ...", IDM_LICENSE
......@@ -43,5 +45,4 @@ MAIN_MENU MENU
STRINGTABLE DISCARDABLE
{
IDS_CLOCK, "ԡ"
IDS_ONTOP, "ٺش"
}
......@@ -37,6 +37,8 @@ MAIN_MENU MENU LANGUAGE LANG_WALON, SUBLANG_DEFAULT
MENUITEM SEPARATOR
MENUITEM "&Segondes", IDM_SECONDS
MENUITEM "&Date", IDM_DATE
MENUITEM SEPARATOR
MENUITEM "Todi &Visibe", IDM_ONTOP
}
POPUP "&Informcion" {
MENUITEM "&Licinse...", IDM_LICENSE
......@@ -48,7 +50,6 @@ MAIN_MENU MENU LANGUAGE LANG_WALON, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE LANGUAGE LANG_WALON, SUBLANG_DEFAULT
{
IDS_CLOCK, "rlodje"
IDS_ONTOP, "Todi &Visibe"
}
#endif /* LANG_WALON */
......@@ -30,6 +30,8 @@ MAIN_MENU MENU LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
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 @@ MAIN_MENU MENU LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
STRINGTABLE DISCARDABLE LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
{
IDS_CLOCK, "时钟"
IDS_ONTOP, "总是在最前面(&A)"
}
......@@ -31,4 +31,3 @@
#define IDM_ONTOP 0x113
#define IDS_CLOCK 0x10C
#define IDS_ONTOP 0x10D
/*
* Clock
*
* Copyright 1998 Marcel Baur <mbaur@g26.ethz.ch>
* Copyright 1998 Karl Backstrm <karl_b@geocities.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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 <stdio.h>
#include "windows.h"
#include "main.h"
#include "language.h"
#include "winnls.h"
VOID LANGUAGE_UpdateMenuCheckmarks(VOID)
{
if(Globals.bAnalog == TRUE) {
/* analog clock */
CheckMenuItem(Globals.hPropertiesMenu, IDM_ANALOG, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(Globals.hPropertiesMenu, IDM_DIGITAL, MF_BYCOMMAND | MF_UNCHECKED);
EnableMenuItem(Globals.hPropertiesMenu, IDM_FONT, MF_BYCOMMAND | MF_GRAYED);
}
else
{
/* digital clock */
CheckMenuItem(Globals.hPropertiesMenu, IDM_ANALOG, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(Globals.hPropertiesMenu, IDM_DIGITAL, MF_BYCOMMAND | MF_CHECKED);
EnableMenuItem(Globals.hPropertiesMenu, IDM_FONT, MF_BYCOMMAND);
}
CheckMenuItem(Globals.hPropertiesMenu, IDM_NOTITLE, MF_BYCOMMAND |
(Globals.bWithoutTitle ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(Globals.hSystemMenu, IDM_ONTOP, MF_BYCOMMAND |
(Globals.bAlwaysOnTop ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(Globals.hPropertiesMenu, IDM_SECONDS, MF_BYCOMMAND |
(Globals.bSeconds ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(Globals.hPropertiesMenu, IDM_DATE, MF_BYCOMMAND |
(Globals.bDate ? MF_CHECKED : MF_UNCHECKED));
}
VOID LANGUAGE_UpdateWindowCaption(VOID)
{
CHAR szCaption[MAX_STRING_LEN];
CHAR szDate[MAX_STRING_LEN];
SYSTEMTIME st;
GetLocalTime(&st);
GetDateFormat(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, &st, NULL, szDate, sizeof(szDate));
/* Set frame caption */
LoadString(Globals.hInstance, IDS_CLOCK, 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;
/* 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);
/* Destroy old menu */
if (Globals.hMainMenu) DestroyMenu(Globals.hMainMenu);
Globals.hMainMenu = hMainMenu;
/* specific for Clock: */
LANGUAGE_UpdateMenuCheckmarks();
LANGUAGE_UpdateWindowCaption();
Globals.hSystemMenu = GetSystemMenu(Globals.hMainWnd, TRUE);
/* FIXME: Append a SEPARATOR to Globals.hSystemMenu here */
LoadString(Globals.hInstance, IDS_ONTOP, szItem, sizeof(szItem));
AppendMenu(Globals.hSystemMenu, MF_STRING | MF_BYCOMMAND, IDM_ONTOP, szItem);
}
/* Local Variables: */
/* c-file-style: "GNU" */
/* End: */
/*
* Clock
*
* Copyright 1998 Marcel Baur <mbaur@g26.ethz.ch>
* Copyright 1998 Karl Backström <karl_b@geocities.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
VOID LANGUAGE_UpdateWindowCaption(VOID);
VOID LANGUAGE_UpdateMenuCheckmarks(VOID);
VOID LANGUAGE_LoadMenus(VOID);
/* Local Variables: */
/* c-file-style: "GNU" */
/* End: */
......@@ -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 @@ typedef struct
} CLOCK_GLOBALS;
extern CLOCK_GLOBALS Globals;
/* function prototypes */
VOID MAIN_FileChooseFont(VOID);
......@@ -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 @@ typedef struct
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 @@ static void DrawFace(HDC dc, const POINT* centre, int radius)
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 DrawHand(HDC dc,HandData* hand)
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, CreatePen(PS_SOLID, 4, HandColor)));
OffsetWindowOrgEx(dc, SHADOW_DEPTH, SHADOW_DEPTH, NULL);
DrawHand(dc, &MinuteHand);
DrawHand(dc, &HourHand);
DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
DeleteObject(SelectObject(dc, GetStockObject(NULL_PEN)));
}
static void PositionHand(const POINT* centre, double length, double angle, HandData* hand)
......@@ -108,6 +148,7 @@ static void PositionHands(const POINT* centre, int radius, BOOL bSeconds)
/* 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 @@ void AnalogClock(HDC dc, int x, int y, BOOL bSeconds)
{
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;
--chars;
memset(&lf, 0, sizeof (lf));
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);
DeleteObject(SelectObject(dc, CreateFontIndirect(&lf)));
GetTextExtentPoint(dc, szTime, strlen(szTime), &extent);
return newFont;
}
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);
}
......@@ -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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment