wine/libtest/rolex.c

242 lines
5.4 KiB
C
Raw Normal View History

Release 951226 Sat Dec 23 18:15:59 1995 Alexandre Julliard <julliard@sunsite.unc.edu> * [configure.in] [Makefile.in] [tools/install-sh] New 'install' target installs Wine binary, library and man page. Library is now more logically named libwine.a. Split toolkit/ directory into library (for library code) and libtest (for test programs). * [controls/edit.c] Quick hack to partially support EM_PASSWORD style (avoids displaying your passwords on the screen when testing programs...) * [configure.in] [controls/menu.c] [include/resource.h] [misc/commdlg.c] [misc/ole2nls.c] [misc/shell.c] [windows/msgbox.c] Language is now a run-time option (wine -language xx). * [debugger/dbg.y] Dump some more debugging info on crash. * [misc/profile.c] Only consider ';' as a comment if it's the first non-blank character on the line. * [miscemu/dpmi.c] More debugging info for real-mode callback. * [objects/gdiobj.c] Rewrote EnumObjects() to do the Right Thing. * [resources/sysres*] New directory containing system resources. Fri Dec 22 11:24:39 GMT 1995 John Harvey <john@division.co.uk> * [win32/file.c] [win32/memory.c] Unixware doesn't have MAP_ANON ifdefed out for now. * [misc/dos_fs.c] DOS_GetDosFileName didn't truncate paths starting ./ properly. * [tools/build.c] Produces assembly code that works with the unixware assembler. Wed Dec 20 22:22:29 +0100 1995 Morten Welinder <terra@diku.dk> * [miscemu/instr.c] INSTR_GetOperandAddr: 16-bit addresses should be masked to 16 bits. * [misc/dos_fs.c] DOS_readdir should always return directories, even if they don't match the file name mask. Tue Dec 19 18:00:00 1995 Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de> * [misc/exec.c] Give arguments to winhelp. * [miscemu/int21.c] Implemented Interrupt 21 AX=6C00 EXTENDED OPEN/CREATE. Created function ExtendedOpenCreateFile. Give for some Windows95 interrupts the return value 'not implemented'. Sun Dec 17 16:51:56 EST 1995 Jim Peterson <jspeter@birch.ee.vt.edu> * [include/kernel32.h] [include/windows.h] Moved the typedefs for SYSTEMTIME and LPSYSTEMTIME from include/kernel32.h to include/windows.h and declared the new Win32 API functions Sleep(), GetLocalTime(), and GetSystemTime(). Redefined INFINITE as 0xFFFFFFFF if WINELIB32. * [rc/rc (new file)] Created the shell script 'rc', which should simplify resource compilation. * [win32/environment.c] Kludged around an undefined reference to wine_files. This change should be fixed some time. * [win32/time.c] [if1632/kernel32.spec] Added the functions GetSystemTime(), and Sleep(). * [miscemu/int21.c] Renamed static function GetSystemTime to INT21_GetSystemTime to avoid conflicts with the API function of the same name. * [include/wintypes.h] Added the SPFMT definition for printf statements. * [misc/shell.c] [include/shell.h] Changed ERROR_* defines to SHELL_ERROR_*, as they were conflicting with the ones in include/winerror.h. They should probably use the versions in winerror.h, but I'm not certain, and that can be done later. * [windows/mdi.c] Translated WM_MDIACTIVATE(?,(LOhwnd,HIhwnd)) messages to WM_MDIACTIVATE(HIhwnd,LOhwnd) for WINELIB32. The ? parameter (boolean) was discarded with this translation. Translated handler of WM_MDISETMENU(ref,(loHMENU,hiHMENU)) to handle WM_MDISETMENU(loHMENU, hiHMENU) messages in WINELIB32 (ref assumed false, call DrawMenuBar() if desired). * [*/*] General explicit casts and more rigid typing to remove warnings. * [include/winpos.h] [windows/winpos.c] Changed return type of WINPOS_ChangeActiveWindow to BOOL. * [include/commdlg.h] [misc/commdlg.c] Added prototypes for ChooseColor(), CommDlgExtendedError(), FindText() GetFileTitle(), GetOpenFileName(), GetSaveFileName(), PrintDlg, and ReplaceText(). Renamed the CommDlgExtendError() function to CommDlgExtendedError(). Made GetFileTitle return a short, as per the API definition. * [Makefile.in] Added line to clean and distclean that removes temporaries from the include directory. Sat Dec 16 19:39:14 MET 1995 Steffen Moeller <smoe0024@rz.uni-hildesheim.de> * [controls/edit.c] Almost rewrote EDIT_GetLineMsg. Sat Dec 16 13:51:48 MST 1995 Andrew Taylor <andrew@riscan.com> * [windows/mdi.c] Fixed MDITile() bug that occurs when 0 windows are present or all windows are minimized. Wed Dec 12 23:30:00 1995 Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de> * [misc/profile.c] Try harder to find files, especially in the working directory. Look in $HOME/.wine too and create it there if it isn't found.
1995-12-26 15:05:24 +00:00
#include <math.h>
#include <string.h>
#include "windows.h"
char* AppName = "Rolex";
char* WindowName = "Rolex";
int WindowWidth = 100;
int WindowHeight = 121;
COLORREF FaceColor = RGB(192,192,192);
COLORREF HandColor = RGB(0,0,0);
COLORREF EtchColor = RGB(0,0,0);
float Pi=3.1415926;
typedef struct
{
int StartX,StartY,EndX,EndY;
} HandData;
int MaxX,MaxY;
HandData OldSecond,OldHour,OldMinute;
HWND HWindow;
void DrawFace(HDC dc)
{
int MidX, MidY, t;
MidX=MaxX/2;
MidY=MaxY/2;
SelectObject(dc,CreateSolidBrush(FaceColor));
SelectObject(dc,CreatePen(PS_SOLID,1,EtchColor));
Ellipse(dc,0,0,MaxX,MaxY);
for(t=0; t<12; t++)
{
MoveToEx(dc,MidX+sin(t*Pi/6)*0.9*MidX,MidY-cos(t*Pi/6)*0.9*MidY,NULL);
LineTo(dc,MidX+sin(t*Pi/6)*0.8*MidX,MidY-cos(t*Pi/6)*0.8*MidY);
}
if(MaxX>64 && MaxY>64)
for(t=0; t<60; t++)
SetPixel(dc,MidX+sin(t*Pi/30)*0.9*MidX,MidY-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)
{
MoveToEx(dc, OldHour.StartX, OldHour.StartY, NULL);
LineTo(dc, OldHour.EndX, OldHour.EndY);
}
void DrawMinuteHand(HDC dc)
{
MoveToEx(dc, OldMinute.StartX, OldMinute.StartY, NULL);
LineTo(dc, OldMinute.EndX, OldMinute.EndY);
}
void DrawSecondHand(HDC dc)
{
MoveToEx(dc, OldSecond.StartX, OldSecond.StartY, NULL);
LineTo(dc, OldSecond.EndX, OldSecond.EndY);
}
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(rv)DrawHourHand(dc);
OldHour.StartX = Sx; OldHour.EndX = Ex;
OldHour.StartY = Sy; OldHour.EndY = Ey;
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(rv)DrawMinuteHand(dc);
OldMinute.StartX = Sx; OldMinute.EndX = Ex;
OldMinute.StartY = Sy; OldMinute.EndY = Ey;
return rv;
}
BOOL UpdateSecondHand(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/3000)*XExt;
Ey = MidY-cos(Pos*Pi/3000)*YExt;
rv = ( Sx!=OldSecond.StartX || Ex!=OldSecond.EndX ||
Sy!=OldSecond.StartY || Ey!=OldSecond.EndY );
if(rv)DrawSecondHand(dc);
OldSecond.StartX = Sx; OldSecond.EndX = Ex;
OldSecond.StartY = Sy; OldSecond.EndY = Ey;
return rv;
}
void Idle(HDC idc)
{
SYSTEMTIME st;
WORD H, M, S, F;
int MidX, MidY;
HDC dc;
BOOL Redraw;
if(idc)
dc=idc;
else
dc=GetDC(HWindow);
if(!dc)return;
GetLocalTime(&st);
H = st.wHour;
M = st.wMinute;
S = st.wSecond;
F = st.wMilliseconds / 10;
F = F + S*100;
M = M*1000+F/6;
H = H*1000+M/60;
MidX = MaxX/2;
MidY = MaxY/2;
SelectObject(dc,CreatePen(PS_SOLID,1,FaceColor));
Redraw = FALSE;
if(UpdateHourHand(dc,MidX,MidY,MidX*0.5,MidY*0.5,H)) Redraw = TRUE;
if(UpdateMinuteHand(dc,MidX,MidY,MidX*0.65,MidY*0.65,M)) Redraw = TRUE;
if(UpdateSecondHand(dc,MidX,MidY,MidX*0.79,MidY*0.79,F)) Redraw = TRUE;
DeleteObject(SelectObject(dc,CreatePen(PS_SOLID,1,HandColor)));
if(Redraw)
{
DrawSecondHand(dc);
DrawMinuteHand(dc);
DrawHourHand(dc);
}
DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
if(!idc) ReleaseDC(HWindow,dc);
}
LRESULT ProcessAppMsg(HWND wnd,UINT msg,WPARAM w,LPARAM l)
{
PAINTSTRUCT PaintInfo;
HDC dc;
switch(msg)
{
case WM_PAINT:
if(GetUpdateRect(wnd,NULL,FALSE))
{
dc=BeginPaint(wnd,&PaintInfo);
DrawFace(dc);
Idle(dc);
EndPaint(wnd,&PaintInfo);
}
break;
case WM_SIZE:
MaxX = LOWORD(l);
MaxY = HIWORD(l);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (wnd, msg, w, l);
}
return 0l;
}
WPARAM MessageLoop()
{
MSG msg;
while(1)
{
Sleep(1); /* sleep 1 millisecond */
if(PeekMessage(&msg,0,0,0,PM_REMOVE))
{
if(msg.message == WM_QUIT) return msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
Idle(NULL);
}
}
int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
{
WNDCLASS class;
if(!prev)
{
class.style = CS_HREDRAW | CS_VREDRAW;
class.lpfnWndProc = ProcessAppMsg;
class.cbClsExtra = 0;
class.cbWndExtra = 0;
class.hInstance = inst;
class.hIcon = 0; /* Draw my own icon */
class.hCursor = LoadCursor (0, IDC_ARROW);
class.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
class.lpszMenuName = 0;
class.lpszClassName = AppName;
}
if (!RegisterClass (&class)) return -1;
HWindow=CreateWindowEx(WS_EX_TOPMOST,AppName,WindowName,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,WindowWidth,WindowHeight,
0,0,inst,0);
memset(&OldSecond,0,sizeof(OldSecond));
memset(&OldMinute,0,sizeof(OldMinute));
memset(&OldHour,0,sizeof(OldHour));
MaxX = WindowWidth;
MaxY = WindowHeight;
ShowWindow (HWindow, show);
UpdateWindow (HWindow);
return MessageLoop();
}