- 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.
This commit is contained in:
parent
7499242fd3
commit
cc8c205adb
|
@ -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 "&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 @@ MAIN_MENU MENU LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
|
|||
STRINGTABLE DISCARDABLE LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
|
||||
{
|
||||
IDS_CLOCK, "Kello"
|
||||
IDS_ONTOP, "&Aina päällimmäisenä"
|
||||
}
|
||||
|
|
|
@ -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 "&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 @@ MAIN_MENU MENU LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
|
|||
STRINGTABLE DISCARDABLE LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
|
||||
{
|
||||
IDS_CLOCK, "Óra"
|
||||
IDS_ONTOP, "&Mindig legfelül"
|
||||
}
|
||||
|
|
|
@ -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 visível", IDM_ONTOP
|
||||
}
|
||||
POPUP "&Informações" {
|
||||
MENUITEM "&Licença...", IDM_LICENSE
|
||||
|
@ -46,5 +48,4 @@ MAIN_MENU MENU
|
|||
STRINGTABLE DISCARDABLE
|
||||
{
|
||||
IDS_CLOCK, "Relógio"
|
||||
IDS_ONTOP, "&Sempre visível"
|
||||
}
|
||||
|
|
|
@ -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 "&Licenèna 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 "&Dátum", IDM_DATE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Vždy 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, "&Vždy 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"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "&Informåcion" {
|
||||
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
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#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: */
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* 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: */
|
|
@ -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
|
||||
|
@ -67,6 +112,84 @@ static BOOL CLOCK_ResetTimer(void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* 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
|
||||
|
@ -74,7 +197,7 @@ static BOOL CLOCK_ResetTimer(void)
|
|||
* 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 @@ int CLOCK_MenuCommand (WPARAM wParam)
|
|||
/* 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 @@ int CLOCK_MenuCommand (WPARAM wParam)
|
|||
/* 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 @@ int CLOCK_MenuCommand (WPARAM wParam)
|
|||
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 @@ int CLOCK_MenuCommand (WPARAM wParam)
|
|||
return 0;
|
||||
}
|
||||
|
||||
VOID MAIN_FileChooseFont(VOID)
|
||||
/***********************************************************************
|
||||
*
|
||||
* CLOCK_Paint
|
||||
*/
|
||||
static VOID CLOCK_Paint(HWND hWnd)
|
||||
{
|
||||
CHOOSEFONT font;
|
||||
LOGFONT lf;
|
||||
PAINTSTRUCT ps;
|
||||
HDC dcMem, dc;
|
||||
HBITMAP bmMem, bmOld;
|
||||
|
||||
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;
|
||||
dc = BeginPaint(hWnd, &ps);
|
||||
|
||||
if (ChooseFont(&font)) {
|
||||
/* do nothing yet */
|
||||
}
|
||||
/* 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);
|
||||
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -184,35 +323,30 @@ VOID MAIN_FileChooseFont(VOID)
|
|||
LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg) {
|
||||
/* 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_CREATE: {
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_RBUTTONUP: {
|
||||
Globals.bWithoutTitle = !Globals.bWithoutTitle;
|
||||
LANGUAGE_UpdateMenuCheckmarks();
|
||||
LANGUAGE_UpdateWindowCaption();
|
||||
UpdateWindow (Globals.hMainWnd);
|
||||
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 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
|
|||
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 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
|
|||
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 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
|
|||
}
|
||||
|
||||
KillTimer(Globals.hMainWnd, TIMER_ID);
|
||||
DeleteObject(Globals.hFont);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -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,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 @@ 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, ¢re, radius);
|
||||
|
||||
PositionHands(¢re, 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);
|
||||
newFont = CreateFontIndirect(&lf);
|
||||
|
||||
DeleteObject(SelectObject(dc, CreateFontIndirect(&lf)));
|
||||
GetTextExtentPoint(dc, szTime, strlen(szTime), &extent);
|
||||
return newFont;
|
||||
}
|
||||
|
||||
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));
|
||||
void DigitalClock(HDC dc, int x, int y, BOOL bSeconds, HFONT font)
|
||||
{
|
||||
SIZE extent;
|
||||
HFONT oldFont;
|
||||
CHAR szTime[255];
|
||||
int chars;
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue