76 lines
1.5 KiB
C
76 lines
1.5 KiB
C
/*
|
|
BUTTON.C
|
|
*/
|
|
|
|
#include <plib.h>
|
|
#include <wlib.h>
|
|
|
|
LOCAL_D WSERV_SPEC wSpec;
|
|
LOCAL_D UINT wMainWid;
|
|
LOCAL_D UINT FontID;
|
|
LOCAL_D UINT FontStyle;
|
|
LOCAL_D G_FONT_INFO FontInfo;
|
|
|
|
LOCAL_C VOID SetFont(INT fid,INT style)
|
|
{
|
|
gFontInfo(FontID=fid,FontStyle=style,&FontInfo);
|
|
}
|
|
|
|
LOCAL_C VOID SetGC(VOID)
|
|
{
|
|
G_GC gc;
|
|
|
|
gc.font=FontID;
|
|
gc.style=FontStyle;
|
|
gSetGC(0,G_GC_MASK_FONT|G_GC_MASK_STYLE,&gc);
|
|
}
|
|
|
|
LOCAL_C VOID DrawButton(INT state)
|
|
{
|
|
P_RECT rect;
|
|
|
|
rect.tl.x=20;
|
|
rect.tl.y=(40-2)-FontInfo.height;
|
|
rect.br.x=140;
|
|
rect.br.y=(40+2)+FontInfo.height;
|
|
wDrawButton(&rect,"Press any key",state);
|
|
}
|
|
|
|
LOCAL_C VOID MainEventLoop(VOID)
|
|
{
|
|
WS_EV event;
|
|
|
|
for (;;)
|
|
{
|
|
wGetEventWait(&event);
|
|
if (event.type==WM_REDRAW)
|
|
{
|
|
wBeginRedrawWinGC0(wMainWid);
|
|
gBorder(W_BORD_SHADOW_D|W_BORD_SHADOW_ON);
|
|
SetGC();
|
|
DrawButton(FALSE);
|
|
wEndRedraw();
|
|
continue;
|
|
}
|
|
if (event.type==WM_KEY)
|
|
{
|
|
gCreateTempGC0(wMainWid);
|
|
SetGC();
|
|
DrawButton(TRUE);
|
|
wFlush();
|
|
p_sleep(5l);
|
|
DrawButton(FALSE);
|
|
gFreeTempGC();
|
|
}
|
|
}
|
|
}
|
|
|
|
GLDEF_C VOID main(VOID)
|
|
{
|
|
wConnect(&wSpec,0,W_CONNECT_PRIORITY);
|
|
wMainWid=wCreateWindow(0,0,0,1);
|
|
wInitialiseWindowTree(wMainWid);
|
|
SetFont(WS_FONT_SYSTEM,G_STY_BOLD);
|
|
MainEventLoop();
|
|
}
|