Category : C Source Code
Archive   : PUBWIW_C.ZIP
Filename : UITEST.C
Output of file : UITEST.C contained in archive : PUBWIW_C.ZIP
#include
#include
#include "GRconst.h"
#include "GRports.h" /* MetaWINDOW header files */
#include "GRextrn.h"
#include "menu.h"
#include "window.h"
#include "control.h"
#define GRwait 0 /* disable GRquery wait */
extern void GrQuery(), ExitToShell();
extern COUNT GrafixCard, CommPort, fntHeight;
char menuTitle[] = "Menu Title";
int x, y, xold, yold, level, button, quit, XHair;
extern void DrawCursor();
MenuItem ddItems[4] =
{
{ M_ITEM, "Query Entry", 0, True, M_NULL, NULL},
{ M_ITEM, "Add Entry", 0, True, M_NULL, NULL},
{ M_ITEM, "Delete Entry", 0, True, M_NULL, NULL},
{ M_LAST, "", 0, True, M_NULL, NULL}
};
MenuItem sysItems[5] =
{
{ M_ITEM, "About MWDemo", 0, True, M_NULL, NULL},
{ M_ITEM, "DOS Command", 0, 0, M_NULL, NULL},
{ M_ITEM, "DOS Shell", 0, 0, M_NULL, NULL},
{ M_ITEM, "Exit", 0, True, M_NULL, ExitToShell},
{ M_LAST, "", 0, True, M_NULL, NULL}
};
MenuItem windowItems[5] =
{
{ M_ITEM, "Close Document", 0, True, M_NULL, NULL},
{ M_ITEM, "Create Document", 0, True, M_NULL, NULL},
{ M_ITEM, "UnHiLite Document", 0, True, M_NULL, NULL},
{ M_ITEM, "Test Polygon Draw", 0, True, M_NULL, NULL},
{ M_LAST, "", 0, True, M_NULL, NULL}
};
MenuItem fileItems[9] =
{
{ M_ITEM, "New", 0, True, M_NULL, NULL},
{ M_ITEM, "Open", 0, True, M_NULL, NULL},
{ M_ITEM, "Close", 0, 0, M_NULL, NULL},
{ M_ITEM, "Save", 0, 0, M_NULL, NULL},
{ M_ITEM, "Save As",0, 0, M_NULL, NULL},
{ M_ITEM, "Print", 0, 0, M_NULL, NULL},
{ M_LAST, "", 0, True, M_NULL, NULL}
};
MenuItem mainItems[7] =
{
{ M_ITEM, "Call SubMenu", 0, True, ddItems, NULL},
{ M_ITEM, "Close Document", 0, True, M_NULL, NULL},
{ M_ITEM, "Create Document", 0, True, M_NULL, NULL},
{ M_ITEM, "UnHiLite Document", 0, True, M_NULL, NULL},
{ M_ITEM, "CrossHair Cursor", 0, True, M_NULL, NULL},
{ M_ITEM, "Exit To DOS", 0, True, M_NULL, NULL},
{ M_LAST, "", 0, True, M_NULL, NULL}
};
void start_XHair()
{
QueryCursor(&x,&y,&level,&button);
HideCursor();
DrawCursor(x,y); /* Put the cursor on the screen */
xold = x;
yold = y;
}
void stop_XHair()
{
DrawCursor(xold,yold); /* Remove cursor from the screen */
ShowCursor();
}
void DrawCursor (CX,CY)
int CX,CY;
{
RasterOp(zXORz);
MoveTo (scrnRect.Xmin,CY);
LineTo (scrnRect.Xmax,CY);
MoveTo (CX,scrnRect.Ymin);
LineTo (CX,scrnRect.Ymax);
}
COUNT docFlag;
KillWindow(wnp)
WindowPtr wnp;
{
metaPort *savePort;
if (docFlag == True)
{
GetPort(&savePort);
SetPort(&(wnp->port));
HideCursor();
FillRect(&(wnp->bounds),_sysBack);
CloseWindow(wnp);
ShowCursor();
SetPort(savePort);
docFlag = False;
}
}
WindowPtr docWn, aboutWn;
HideAbout()
{
HideCursor();
RemoveWindow(aboutWn);
ShowCursor();
}
/* ----------------------------------------------------------------------- */
main(argc,argv)
int argc;
char *argv[];
{
event thisEvent;
rect docRect, cpRect, aboutRect, buttonRect;
ControlPtr cp, cb, OKbutton;
metaPort *savePort;
COUNT cState;
GrQuery(argc,argv);
_init();
InitWindows();
InitMenus();
AppendMenu("System",0,sysItems);
DrawMenuBar();
docFlag = False;
ScaleMouse(24,16);
TrackCursor(True);
x = y = xold = yold = level = 0;
button = 0;
quit = False;
XHair = False;
button = -1;
SetRect(&aboutRect,100,100,540,240);
SetRect(&buttonRect,200,90,290,135);
aboutWn = NewWindow
(
W_DIALOG,
(TEXT *)0,
&aboutRect,
True,
False
);
OKbutton = NewButton(aboutWn,&buttonRect," O K ",HideAbout,NULL,True);
ColorWindow(aboutWn,0,15, 1,-1);
DrawWindow(aboutWn);
GetPort(&savePort);
SetPort(&(aboutWn->port));
MoveTo(25,50);
DrawString("Welcome to a Simple Example of Window Management");
SetPort(savePort);
DupRect(&scrnRect,&docRect);
InsetRect(&docRect,100,50);
DupRect(&docRect, &cpRect);
InsetRect(&cpRect,80,20);
cpRect.Ymax = cpRect.Ymin + fntHeight;
cpRect.Xmax = cpRect.Xmin + 120;
EventQueue(True);
while (1)
{
do
ReadMouse(&x,&y,&button);
while (button < 0);
if (XHair == True)
{
DrawCursor(xold,yold); /* erase the old cursor */
DrawCursor(x,y); /* draw cursor in new position */
xold=x; yold=y;
}
if (KeyEvent(False,&thisEvent))
{
if (thisEvent.State & 0x0100)
{
if (XHair == False)
{
HideCursor();
}
switch (PopUpMenu(mainItems,x+10,y+10))
{
case 2:
KillWindow(docWn);
break;
case 3:
docWn = NewWindow
(
W_DOCUMENT,
"User Interface Test",
&docRect,
False,
False
);
ColorWindow(docWn,0,15,-1,-1);
DupRect(&docRect, &cpRect);
InsetRect(&cpRect,2,20);
cpRect.Xmin = cpRect.Xmax - 18;
GetPort(&savePort);
SetPort(&(docWn->port));
Gbl2LclRect(&cpRect);
SetPort(savePort);
cState = False;
cp = (ControlPtr)NewVScroll(docWn,
&cpRect, NULL, NULL, 0, 0 ,100);
DrawWindow(docWn);
docFlag = True;
break;
case 4:
if (docFlag == True)
{
HiliteWindow(docWn,cState);
if (cState == False)
cState = True;
else
cState = False;
}
break;
case 5:
if (XHair == True)
{
stop_XHair();
XHair = False;
}
else
{
start_XHair();
XHair = True;
}
break;
case 6:
ExitToShell();
break;
}
if (XHair == False)
{
ShowCursor();
}
}
else if (thisEvent.State & 0x0400)
{
MenuEvent(thisEvent.CursorX, thisEvent.CursorY);
WindowEvent(thisEvent.CursorX, thisEvent.CursorY,aboutWn);
if (docFlag == True)
switch(WindowEvent(thisEvent.CursorX,
thisEvent.CursorY,docWn))
{
case IN_DRAG:
DragWindow(docWn);
break;
case IN_GOAWAY:
HideCursor();
GetPort(&savePort);
SetPort(&(docWn->port));
InvertRect(docWn->goAway);
wait();
FillRect(&(docWn->bounds),_sysBack);
ShowCursor();
wait();
CloseWindow(docWn);
docFlag = False;
SetPort(savePort);
break;
case IN_SHRINK:
ShrinkWindow(docWn);
break;
case IN_GROW:
GrowWindow(docWn);
break;
}
}
}
}
} /* end MAIN */
#include "GRquery.c"
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/