home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / CHRGUI10 / DEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1993-10-31  |  31KB  |  900 lines

  1. PROGRAM DEMO;
  2.  
  3. {
  4.   Chrome Interface Demo V1.0
  5.   This program demonstrates some of the aspects of
  6.   the Chrome Interface Library, V1.0.
  7.  
  8.   Created 10/9/93
  9. }
  10.  
  11. { Use Chrome Interface Library, and the Graph unit }
  12.  
  13. USES Chrome,Graph;
  14.  
  15. { These constants are defined to simplify Menu ID's into a readable
  16.   form }
  17.  
  18. CONST
  19.      BUTTONDEMO=1;
  20.      CHECKDEMO=2;
  21.      PROPDEMO=3;
  22.      LISTDEMO=4;
  23.      STRINGDEMO=5;
  24.      LINKDEMO=6;
  25.      WINDOWDEMO=7;
  26.      EVENTDEMO=8;
  27.      ABOUT=9;
  28.      REQDEMO=10;
  29.  
  30.      QUIT=100;
  31.  
  32. VAR
  33.    WM:WinManager;   {The Window Manager Object}
  34.  
  35.    {Menu List Pointers}
  36.  
  37.    MainMenu:PMenuList;
  38.    GadgetDemos:PMenuList;
  39.    MenuDemos,MenuDemosLevel2,QuickKeyExample:PMenuList;
  40.    IODemos:PMenuList;
  41.  
  42.    aw:PWindow;  {Pointer to the active window}
  43.  
  44.    Port,MenuID:integer;  {Information exchage variables}
  45.  
  46.    terminated:BOOLEAN; {Quit flag}
  47.  
  48.    {About Demo Section Variables}
  49.  
  50.    AboutWin:PWindow;
  51.    AboutView:PGadget;
  52.    AboutList:PListHeader;
  53.  
  54.    {Window Demo Section Variables}
  55.  
  56.    WindowWin:PWindow;
  57.    WindowView:PGadget;
  58.    WindowList:PListHeader;
  59.  
  60.    {Button Demo Section Variables}
  61.  
  62.    ButtonWin:PWindow;
  63.    ButtonView:PGadget;
  64.    ButtonList:PListHeader;
  65.  
  66.    {Check Box Demo Section Variables}
  67.  
  68.    CheckWin:PWindow;
  69.    CheckView:PGadget;
  70.    CheckList:PListHeader;
  71.  
  72.    {Proportional Demo Section Variables}
  73.  
  74.    PropWin:PWindow;
  75.    PropView,p1,p2:PGadget;
  76.    PropList:PListHeader;
  77.  
  78.    {List Demo Section Variables}
  79.  
  80.    ListWin:PWindow;
  81.    ListView,ListSelect:PGadget;
  82.    ListList,ListList2:PListHeader;
  83.  
  84.    {String Demo Section Variables}
  85.  
  86.    StringWin:PWindow;
  87.    StringView,sgad:PGadget;
  88.    StringList:PListHeader;
  89.  
  90.    {Link Demo Section Variables}
  91.  
  92.    LinkWin:PWindow;
  93.  
  94.    LinkView,viewprop:PGadget;
  95.    LinkList:PListHeader;
  96.    viewgroup:PLinkGadList;
  97.  
  98.    st,prop:PGadget;
  99.    stpropgroup:PLinkGadList;
  100.  
  101.    st1,st2,st3:PGadget;
  102.    st2stgroup:PLinkGadList;
  103.  
  104.    ck1,ck2,ck3:PGadget;
  105.    ckexgroup:PLinkGadList;
  106.  
  107.    {Event Demo Section Variables}
  108.  
  109.    EventWin:PWindow;
  110.    EventView:PGadget;
  111.    EventList:PListHeader;
  112.  
  113.  
  114. {Include some predefined Links into the program.}
  115.  
  116. {$I LINKS.PAS}
  117.  
  118.  
  119. PROCEDURE InitDemo;
  120. {This procedure Initializes the menus, and sets some pointers to nil }
  121.  
  122. BEGIN
  123.      {Gadget Demo Menus}
  124.  
  125.      GadgetDemos:=WM.NewMenuHeader('Gadget Demos');
  126.      WM.NewMenuNode(GadgetDemos,'Button Gadgets...      ',BUTTONDEMO,#0,NIL);
  127.      WM.NewMenuNode(GadgetDemos,'CheckBox Gadgets...    ',CHECKDEMO ,#0,NIL);
  128.      WM.NewMenuNode(GadgetDemos,'Proportional Gadgets...',PROPDEMO  ,#0,NIL);
  129.      WM.NewMenuNode(GadgetDemos,'List Gadgets...        ',LISTDEMO  ,#0,NIL);
  130.      WM.NewMenuNode(GadgetDemos,'String Gadgets...      ',STRINGDEMO,#0,NIL);
  131.      WM.NewMenuNode(GadgetDemos,''                       ,0         ,#0,NIL);
  132.      WM.NewMenuNode(GadgetDemos,'Gadget Links...        ',LINKDEMO  ,#0,NIL);
  133.  
  134.      {Menu Demo Menus}
  135.  
  136.      QuickKeyExample:=WM.NewMenuHeader('Quick Key');
  137.      WM.NewMenuNode(QuickKeyExample,'  Menu Demo Done  ',0,#0,NIL);
  138.  
  139.      MenuDemosLevel2:=WM.NewMenuHeader('More Info');
  140.      WM.NewMenuNode(MenuDemosLevel2,'Menus stay open until the user',0,#0,NIL);
  141.      WM.NewMenuNode(MenuDemosLevel2,'is ready to close them.  Items',0,#0,NIL);
  142.      WM.NewMenuNode(MenuDemosLevel2,'can have alt-codes for quick  ',0,#0,NIL);
  143.      WM.NewMenuNode(MenuDemosLevel2,'access.  Press Alt-M or click ',0,#0,NIL);
  144.      WM.NewMenuNode(MenuDemosLevel2,'below to demonstrate this.    ',0,#0,NIL);
  145.      WM.NewMenuNode(MenuDemosLevel2,''                              ,0,#0,NIL);
  146.      WM.NewMenuNode(MenuDemosLevel2,'Quick Key Example      Alt-M  ',0,#50,QuickKeyExample);
  147.  
  148.      MenuDemos:=WM.NewMenuHeader('Menu Demos');
  149.      WM.NewMenuNode(MenuDemos,'Menus allow easy selection  ',0,#0,NIL);
  150.      WM.NewMenuNode(MenuDemos,'from lists to get around    ',0,#0,NIL);
  151.      WM.NewMenuNode(MenuDemos,'any program.  Menus can have',0,#0,NIL);
  152.      WM.NewMenuNode(MenuDemos,'infinite levels of submenus.',0,#0,NIL);
  153.      WM.NewMenuNode(MenuDemos,''                            ,0,#0,NIL);
  154.      WM.NewMenuNode(MenuDemos,'Click For More On Menus     ',0,#0,MenuDemosLevel2);
  155.  
  156.      MainMenu:=WM.NewMenuHeader('Chrome Interface');
  157.      WM.NewMenuNode(MainMenu,'About...         ',ABOUT     ,#0 ,nil);
  158.      WM.NewMenuNode(MainMenu,''                 ,0         ,#0 ,nil);
  159.      WM.NewMenuNode(MainMenu,'Window Demo...   ',WINDOWDEMO,#0 ,nil);
  160.      WM.NewMenuNode(MainMenu,'Requester Demo...',REQDEMO   ,#0 ,nil);
  161.      WM.NewMenuNode(MainMenu,'Menu Demo        ',0         ,#0 ,MenuDemos);
  162.      WM.NewMenuNode(MainMenu,'Gadget Demos     ',0         ,#0 ,GadgetDemos);
  163.      WM.NewMenuNode(MainMenu,'Event Demo...    ',EVENTDEMO ,#0 ,nil);
  164.      WM.NewMenuNode(MainMenu,''                 ,0         ,#0 ,nil);
  165.      WM.NewMenuNode(MainMenu,'Quit        Alt-Q',QUIT      ,#16,nil);
  166.  
  167.      WM.SetGlobalMenu(MainMenu);
  168.  
  169.      AboutWin:=nil;
  170.      WindowWin:=nil;
  171.      ButtonWin:=nil;
  172.      CheckWin:=nil;
  173.      PropWin:=nil;
  174.      ListWin:=nil;
  175.      StringWin:=nil;
  176.      LinkWin:=nil;
  177.      EventWin:=nil;
  178. END;
  179.  
  180. PROCEDURE DoneDemo;
  181. {This procedure Cleans up the demo, including reseting the global menu and
  182.  disposing the menus that were allocated}
  183.  
  184. BEGIN
  185.      WM.SetGlobalMenu(nil);
  186.  
  187.      WM.DisposeMenu(MainMenu);
  188.      WM.DisposeMenu(GadgetDemos);
  189.      WM.DisposeMenu(MenuDemos);
  190.      WM.DisposeMenu(MenuDemosLevel2);
  191.      WM.DisposeMenu(QuickKeyExample);
  192. END;
  193.  
  194. {For the following procedures, the ones ending in Proc initialize the
  195.  specific demo, the ones ending in Handler handle events that are sent
  196.  to that part of the demos window.}
  197.  
  198. Procedure AboutDemoProc;
  199. BEGIN
  200.      AboutWin:=WM.NewWindow('About',200,95,240,290,WFLAG_CLOSEGADGET);
  201.  
  202.      AboutView:=WM.NewGadget(GTYPE_VIEWLIST,'',10,14,210,231,GFLAG_NOTHING);
  203.  
  204.      AboutList:=WM.NewListHeader;
  205.      WM.NewListNode(AboutList,'Chrome Interface Demo V1.0');
  206.      WM.NewListNode(AboutList,'Chrome Interface Library V1.0');
  207.      WM.NewListNode(AboutList,'');
  208.      WM.NewListNode(AboutList,'The Chrome Interface library is');
  209.      WM.NewListNode(AboutList,'a unit which gives Turbo Pascal');
  210.      WM.NewListNode(AboutList,'7.0 users the ability to');
  211.      WM.NewListNode(AboutList,'add a graphical user interface');
  212.      WM.NewListNode(AboutList,'to their dos programs with maximum');
  213.      WM.NewListNode(AboutList,'ease.  This program demonstrates');
  214.      WM.NewListNode(AboutList,'some of the aspects of the library.');
  215.      WM.NewListNode(AboutList,'');
  216.      WM.NewListNode(AboutList,'Please read the readme file which');
  217.      WM.NewListNode(AboutList,'came with this program.  For more');
  218.      WM.NewListNode(AboutList,'information, contact:');
  219.      WM.NewListNode(AboutList,'');
  220.      WM.NewListNode(AboutList,'High Velocity Systems');
  221.      WM.NewListNode(AboutList,'6521 S 41st Street');
  222.      WM.NewListNode(AboutList,'Lincoln, NE  68516');
  223.      WM.NewListNode(AboutList,'');
  224.      WM.NewListNode(AboutList,'Internet: jvanabra@nyx.cs.du.edu');
  225.  
  226.      WM.SetGadgetList(AboutView,AboutList);
  227. END;
  228.  
  229. Procedure AboutDemoHandler(port:integer);
  230. BEGIN
  231.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  232.      BEGIN
  233.           WM.DisposeWindow(AboutWin);
  234.           WM.DisposeList(AboutList);
  235.  
  236.           AboutWin:=nil;
  237.      END;
  238. END;
  239.  
  240. Procedure WindowDemoProc;
  241. BEGIN
  242.      WindowWin:=WM.NewWindow('Windows',190,60,260,350,WFLAG_STANDARD);
  243.  
  244.      WindowView:=WM.NewGadget(GTYPE_VIEWLIST,'',10,14,235,291,GFLAG_NOTHING);
  245.  
  246.      WindowList:=WM.NewListHeader;
  247.      WM.NewListNode(WindowList,'Windows');
  248.      WM.NewListNode(WindowList,'');
  249.      WM.NewListNode(WindowList,'A window is a graphical area of the');
  250.      WM.NewListNode(WindowList,'screen which functions as the');
  251.      WM.NewListNode(WindowList,'primary unit of interaction.');
  252.      WM.NewListNode(WindowList,'');
  253.      WM.NewListNode(WindowList,'All windows are similar.  They all');
  254.      WM.NewListNode(WindowList,'consist of a border.  In the border');
  255.      WM.NewListNode(WindowList,'there are gadgets, or active areas');
  256.      WM.NewListNode(WindowList,'of the window which respond to mouse');
  257.      WM.NewListNode(WindowList,'clicks.  One may click on the title');
  258.      WM.NewListNode(WindowList,'bar to move the window,');
  259.      WM.NewListNode(WindowList,'click on the zoom button (the one');
  260.      WM.NewListNode(WindowList,'with the double arrows) to change');
  261.      WM.NewListNode(WindowList,'the window to its alternate size');
  262.      WM.NewListNode(WindowList,'and position, click on the');
  263.      WM.NewListNode(WindowList,'Close (X) gadget to close the window,');
  264.      WM.NewListNode(WindowList,'or click on the lower right hand corner');
  265.      WM.NewListNode(WindowList,'of the window to change the window''s');
  266.      WM.NewListNode(WindowList,'size.');
  267.      WM.NewListNode(WindowList,'');
  268.      WM.NewListNode(WindowList,'Everything the programmer manipulates');
  269.      WM.NewListNode(WindowList,'is done between the window borders.');
  270.      WM.NewListNode(WindowList,'There, manipulation may be done using');
  271.      WM.NewListNode(WindowList,'the Library''s built in procedures,');
  272.      WM.NewListNode(WindowList,'or the programmer may use BGI routines');
  273.      WM.NewListNode(WindowList,'to draw directly into the window');
  274.      WM.NewListNode(WindowList,'themselves.');
  275.  
  276.      WM.SetGadgetList(WindowView,WindowList);
  277. END;
  278.  
  279. Procedure WindowDemoHandler(port:integer);
  280. BEGIN
  281.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  282.      BEGIN
  283.           WM.DisposeWindow(WindowWin);
  284.           WM.DisposeList(WindowList);
  285.  
  286.           WindowWin:=nil;
  287.      END;
  288. END;
  289.  
  290. Procedure ReqDemoProc;
  291. { The requester demo is quite simple, since each request takes over the
  292.   system until it is finished, no Handler is required}
  293.  
  294. var
  295.    result:integer;
  296. BEGIN
  297.      WM.Request('Requester Example','Requesters can be created using only one command.',
  298.                 'They allow an easy way to provide information,','Continue','','');
  299.  
  300.      Repeat
  301.            result:=WM.Request('Requester Example, cont.','...or an easy way to ask a pressing question',
  302.                               'Isn''t this a great demo?','Yes','No','');
  303.  
  304.            If result<>1 then
  305.               WM.Request('Information','I''m sorry, you pressed the wrong button.','','Continue','','');
  306.      Until result=1;
  307. END;
  308.  
  309. Procedure ButtonDemoProc;
  310. var
  311.    tst:string;
  312.    x:integer;
  313.  
  314. BEGIN
  315.      ButtonWin:=WM.NewWindow('Button Demo',200,100,300,240,WFLAG_CLOSEGADGET);
  316.  
  317.      for x:=1 to 10 do
  318.      BEGIN
  319.           Str(x,tst);
  320.           WM.NewGadget(GTYPE_BUTTON,'Gad #'+tst,10,11+12*x,60,11,GFLAG_NOTHING);
  321.      END;
  322.  
  323.      ButtonView:=WM.NewGadget(GTYPE_VIEWLIST,'',100,10,180,201,GFLAG_NOTHING);
  324.  
  325.      ButtonList:=WM.NewListHeader;
  326.      WM.NewListNode(ButtonList,'Button Gadgets');
  327.      WM.NewListNode(ButtonList,'');
  328.      WM.NewListNode(ButtonList,'Button Gadgets allow the');
  329.      WM.NewListNode(ButtonList,'programmer to instantly');
  330.      WM.NewListNode(ButtonList,'respond to a press of the');
  331.      WM.NewListNode(ButtonList,'mouse button within a defined');
  332.      WM.NewListNode(ButtonList,'area.');
  333.      WM.NewListNode(ButtonList,'');
  334.      WM.NewListNode(ButtonList,'Button Gadgets are used by');
  335.      WM.NewListNode(ButtonList,'the Chrome Interface Library');
  336.      WM.NewListNode(ButtonList,'to make the menuing system.');
  337.  
  338.      WM.SetGadgetList(ButtonView,ButtonList);
  339. END;
  340.  
  341. Procedure ButtonDemoHandler(port:integer);
  342. BEGIN
  343.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  344.      BEGIN
  345.           WM.DisposeWindow(ButtonWin);
  346.           WM.DisposeList(ButtonList);
  347.  
  348.           ButtonWin:=nil;
  349.      END;
  350. END;
  351.  
  352. Procedure CheckDemoProc;
  353. var
  354.    x:integer;
  355.    tst:string;
  356.  
  357. BEGIN
  358.      CheckWin:=WM.NewWindow('CheckBox Demo',200,100,300,240,WFLAG_CLOSEGADGET);
  359.  
  360.      for x:=1 to 10 do
  361.      BEGIN
  362.           Str(x,tst);
  363.           WM.NewGadget(GTYPE_CHECKBOX,'Gad #'+tst,10,11+12*x,11,11,GFLAG_NOTHING);
  364.      END;
  365.  
  366.      CheckView:=WM.NewGadget(GTYPE_VIEWLIST,'',100,10,180,201,GFLAG_NOTHING);
  367.  
  368.      CheckList:=WM.NewListHeader;
  369.      WM.NewListNode(CheckList,'Checkbox Gadgets');
  370.      WM.NewListNode(CheckList,'');
  371.      WM.NewListNode(CheckList,'Checkbox gadgets allow the');
  372.      WM.NewListNode(CheckList,'programmer to get on/off');
  373.      WM.NewListNode(CheckList,'states from the user.');
  374.      WM.NewListNode(CheckList,'');
  375.      WM.NewListNode(CheckList,'Checkbox gadgets are usually');
  376.      WM.NewListNode(CheckList,'used in the configuration part');
  377.      WM.NewListNode(CheckList,'of a program to allow the');
  378.      WM.NewListNode(CheckList,'user to select certain');
  379.      WM.NewListNode(CheckList,'features.');
  380.  
  381.      WM.SetGadgetList(CheckView,CheckList);
  382. END;
  383.  
  384. Procedure CheckDemoHandler(port:integer);
  385. BEGIN
  386.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  387.      BEGIN
  388.           WM.DisposeWindow(CheckWin);
  389.           WM.DisposeList(CheckList);
  390.  
  391.           CheckWin:=nil;
  392.      END;
  393. END;
  394.  
  395. Procedure PropDemoProc;
  396. var
  397.    x:integer;
  398.  
  399. BEGIN
  400.      PropWin:=WM.NewWindow('Proportional Demo',200,100,350,240,WFLAG_CLOSEGADGET);
  401.  
  402.      p1:=WM.NewGadget(GTYPE_HPROPORTIONAL,'A',14,11,76,11,GFLAG_NOTHING);
  403.      p2:=WM.NewGadget(GTYPE_VPROPORTIONAL,'B',45,45,11,140,GFLAG_NOTHING);
  404.  
  405.      WM.SetProportionalFraction(p1,1,10);
  406.      WM.SetProportionalFraction(p2,6,15);
  407.  
  408.      PropView:=WM.NewGadget(GTYPE_VIEWLIST,'',100,10,230,201,GFLAG_NOTHING);
  409.  
  410.      PropList:=WM.NewListHeader;
  411.      WM.NewListNode(PropList,'Proportional Gadgets');
  412.      WM.NewListNode(PropList,'');
  413.      WM.NewListNode(PropList,'Proportional Gadgets are used');
  414.      WM.NewListNode(PropList,'to represent a range of integer');
  415.      WM.NewListNode(PropList,'values, and/or a percentage');
  416.      WM.NewListNode(PropList,'of something that can be viewed.');
  417.      WM.NewListNode(PropList,'');
  418.      WM.NewListNode(PropList,'For example, VGA palette entries');
  419.      WM.NewListNode(PropList,'for one componet of a color are');
  420.      WM.NewListNode(PropList,'valid for the numbers 0-63.');
  421.      WM.NewListNode(PropList,'Proportional gadgets could be used');
  422.      WM.NewListNode(PropList,'to allow the user to select a value.');
  423.      WM.NewListNode(PropList,'');
  424.      WM.NewListNode(PropList,'In a list of strings, proportional');
  425.      WM.NewListNode(PropList,'gadgets can represent the percentage');
  426.      WM.NewListNode(PropList,'of the list that is viewable, and');
  427.      WM.NewListNode(PropList,'how much more there is in the list');
  428.      WM.NewListNode(PropList,'that can not be seen.');
  429.  
  430.      WM.SetGadgetList(PropView,PropList);
  431. END;
  432.  
  433. Procedure PropDemoHandler(port:integer);
  434. BEGIN
  435.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  436.      BEGIN
  437.           WM.DisposeWindow(PropWin);
  438.           WM.DisposeList(PropList);
  439.  
  440.           PropWin:=nil;
  441.      END;
  442. END;
  443.  
  444. Procedure ListDemoProc;
  445. var
  446.    x:integer;
  447.    tst:string;
  448.  
  449. BEGIN
  450.      ListWin:=WM.NewWindow('List Demo',200,100,350,240,WFLAG_CLOSEGADGET);
  451.  
  452.      ListSelect:=WM.NewGadget(GTYPE_SELECTLIST,'Select List',10,14,100,180,GFLAG_NOTHING);
  453.      ListView:=WM.NewGadget(GTYPE_VIEWLIST,'View List',130,14,200,201,GFLAG_NOTHING);
  454.  
  455.      ListList:=WM.NewListHeader;
  456.      WM.NewListNode(ListList,'List Gadgets');
  457.      WM.NewListNode(ListList,'');
  458.      WM.NewListNode(ListList,'Information is given to users');
  459.      WM.NewListNode(ListList,'through the use of a view list');
  460.      WM.NewListNode(ListList,'gadget like this one.');
  461.      WM.NewListNode(ListList,'');
  462.      WM.NewListNode(ListList,'Users can be allowed to select');
  463.      WM.NewListNode(ListList,'from a list of text by the use');
  464.      WM.NewListNode(ListList,'of a select list gadget.');
  465.      WM.NewListNode(ListList,'');
  466.      WM.NewListNode(ListList,'Both types are easily linked to');
  467.      WM.NewListNode(ListList,'a proportional gadget to allow');
  468.      WM.NewListNode(ListList,'for navigation of lists larger');
  469.      WM.NewListNode(ListList,'than the height of the gadget.');
  470.  
  471.  
  472.      ListList2:=WM.NewListHeader;
  473.  
  474.      For x:=1 to 18 do
  475.      BEGIN
  476.           Str(x,tst);
  477.           WM.NewListNode(ListList2,'Selection '+tst);
  478.      END;
  479.  
  480.      WM.SetGadgetList(ListView,ListList);
  481.      WM.SetGadgetList(ListSelect,ListList2);
  482. END;
  483.  
  484. Procedure ListDemoHandler(port:integer);
  485. BEGIN
  486.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  487.      BEGIN
  488.           WM.DisposeWindow(ListWin);
  489.           WM.DisposeList(ListList2);
  490.           WM.DisposeList(ListList);
  491.  
  492.           ListWin:=nil;
  493.      END;
  494. END;
  495.  
  496. Procedure StringDemoProc;
  497. BEGIN
  498.      StringWin:=WM.NewWindow('String Demo',200,100,350,240,WFLAG_CLOSEGADGET);
  499.  
  500.      sgad:=WM.NewGadget(GTYPE_STRING,'String Gad',10,14,100,15,GFLAG_NOTHING);
  501.      WM.SetString(sgad,'Edit Me');
  502.  
  503.      StringView:=WM.NewGadget(GTYPE_VIEWLIST,'',130,14,200,201,GFLAG_NOTHING);
  504.  
  505.      StringList:=WM.NewListHeader;
  506.      WM.NewListNode(StringList,'String Gadgets');
  507.      WM.NewListNode(StringList,'');
  508.      WM.NewListNode(StringList,'String gadgets allow the');
  509.      WM.NewListNode(StringList,'programmer to get strings of');
  510.      WM.NewListNode(StringList,'text from the user.  These');
  511.      WM.NewListNode(StringList,'strings can be converted to');
  512.      WM.NewListNode(StringList,'numbers by the use of standard');
  513.      WM.NewListNode(StringList,'Pascal routines.');
  514.      WM.NewListNode(StringList,'');
  515.      WM.NewListNode(StringList,'To accept the editing done in');
  516.      WM.NewListNode(StringList,'the string gadget, the user');
  517.      WM.NewListNode(StringList,'presses return.  To abort, the');
  518.      WM.NewListNode(StringList,'user clicks the mouse outside');
  519.      WM.NewListNode(StringList,'of the string gadget.');
  520.  
  521.      WM.SetGadgetList(StringView,StringList);
  522. END;
  523.  
  524. Procedure StringDemoHandler(port:integer);
  525. BEGIN
  526.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  527.      BEGIN
  528.           WM.DisposeWindow(StringWin);
  529.           WM.DisposeList(StringList);
  530.  
  531.           StringWin:=nil;
  532.      END;
  533. END;
  534.  
  535. Procedure LinkDemoProc;
  536. BEGIN
  537.      LinkWin:=WM.NewWindow('Link Demo',200,100,430,240,WFLAG_CLOSEGADGET);
  538.  
  539.      LinkList:=WM.NewListHeader;
  540.      WM.NewListNode(LinkList,'Gadget Links');
  541.      WM.NewListNode(LinkList,'');
  542.      WM.NewListNode(LinkList,'Gadgets can be grouped together');
  543.      WM.NewListNode(LinkList,'by the use of gadget links.');
  544.      WM.NewListNode(LinkList,'The actual gadget linking code');
  545.      WM.NewListNode(LinkList,'is a procedure which is called');
  546.      WM.NewListNode(LinkList,'automatically whenever a gadget');
  547.      WM.NewListNode(LinkList,'in a defined group is changed.');
  548.      WM.NewListNode(LinkList,'That procedure is passed the');
  549.      WM.NewListNode(LinkList,'list of gadgets within its');
  550.      WM.NewListNode(LinkList,'group.');
  551.      WM.NewListNode(LinkList,'');
  552.      WM.NewListNode(LinkList,'The links shown here come with');
  553.      WM.NewListNode(LinkList,'the Chrome Interface Library.');
  554.      WM.NewListNode(LinkList,'This view list gadget is linked');
  555.      WM.NewListNode(LinkList,'to a proportional gadget. The');
  556.      WM.NewListNode(LinkList,'other proportional gadget in the');
  557.      WM.NewListNode(LinkList,'window is linked to the string');
  558.      WM.NewListNode(LinkList,'gadget directly below it.  The');
  559.      WM.NewListNode(LinkList,'other three string gadgets are');
  560.      WM.NewListNode(LinkList,'linked to each other so that');
  561.      WM.NewListNode(LinkList,'pressing the return key moves');
  562.      WM.NewListNode(LinkList,'to the next string gadget.');
  563.      WM.NewListNode(LinkList,'The three checkbox gadgets are');
  564.      WM.NewListNode(LinkList,'linked so that one and only one');
  565.      WM.NewListNode(LinkList,'of the checkboxes are on at');
  566.      WM.NewListNode(LinkList,'once.');
  567.  
  568.      LinkView:=WM.NewGadget(GTYPE_VIEWLIST,'',200,14,200,WM.ConvertListLinesToHeight(15),GFLAG_NOTHING);
  569.      WM.SetGadgetList(LinkView,LinkList);
  570.  
  571.      viewprop:=WM.NewGadget(GTYPE_VPROPORTIONAL,'',400,14,11,WM.ConvertListLinesToHeight(15),GFLAG_NOTHING);
  572.      WM.SetProportionalFraction(viewprop,15,27);
  573.  
  574.      viewgroup:=WM.NewLinkGadgetHeader(@LinkProportionalToList);
  575.      WM.NewLinkGadgetNode(viewgroup,LinkView);
  576.      WM.NewLinkGadgetNode(viewgroup,viewprop);
  577.  
  578.      prop:=WM.NewGadget(GTYPE_HPROPORTIONAL,'',10,10,100,11,GFLAG_NOTHING);
  579.      st:=WM.NewGadget(GTYPE_STRING,'',40,25,40,15,GFLAG_NOTHING);
  580.      WM.SetProportionalFraction(prop,1,101);
  581.      WM.SetProportionalOffsetScale(prop,-51,2);
  582.      WM.SetGadgetState(prop,0);
  583.      WM.SetString(st,'0');
  584.  
  585.      stpropgroup:=WM.NewLinkGadgetHeader(@LinkProportionalToString);
  586.      WM.NewLinkGadgetNode(stpropgroup,st);
  587.      WM.NewLinkGadgetNode(stpropgroup,prop);
  588.  
  589.      st1:=WM.NewGadget(GTYPE_STRING,'',10,60,100,15,GFLAG_NOTHING);
  590.      st2:=WM.NewGadget(GTYPE_STRING,'',10,77,100,15,GFLAG_NOTHING);
  591.      st3:=WM.NewGadget(GTYPE_STRING,'',10,94,100,15,GFLAG_NOTHING);
  592.  
  593.      WM.SetString(st1,'These Gadgets');
  594.      WM.SetString(st2,'Are');
  595.      WM.SetString(st3,'Linked.');
  596.  
  597.      st2stgroup:=WM.NewLinkGadgetHeader(@LinkStringToString);
  598.      WM.NewLinkGadgetNode(st2stgroup,st3);
  599.      WM.NewLinkGadgetNode(st2stgroup,st2);
  600.      WM.NewLinkGadgetNode(st2stgroup,st1);
  601.  
  602.      ck1:=WM.NewGadget(GTYPE_CHECKBOX,'Exclusive',10,130,11,11,GFLAG_NOTHING);
  603.      ck2:=WM.NewGadget(GTYPE_CHECKBOX,'Checkbox',10,145,11,11,GFLAG_NOTHING);
  604.      ck3:=WM.NewGadget(GTYPE_CHECKBOX,'Selection',10,160,11,11,GFLAG_NOTHING);
  605.  
  606.      WM.SetGadgetState(ck1,ON);
  607.  
  608.      ckexgroup:=WM.NewLinkGadgetHeader(@LINKCheckBoxExclusive);
  609.      WM.NewLinkGadgetNode(ckexgroup,ck3);
  610.      WM.NewLinkGadgetNode(ckexgroup,ck2);
  611.      WM.NewLinkGadgetNode(ckexgroup,ck1);
  612. END;
  613.  
  614. Procedure LinkDemoHandler(port:integer);
  615. BEGIN
  616.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  617.      BEGIN
  618.           WM.DisposeWindow(LinkWin);
  619.           WM.DisposeList(LinkList);
  620.  
  621.           LinkWin:=nil;
  622.      END;
  623. END;
  624.  
  625. Procedure EventDemoProc;
  626. BEGIN
  627.      EventWin:=WM.NewWindow('Events',200,95,240,290,WFLAG_STANDARD);
  628.  
  629.      EventView:=WM.NewGadget(GTYPE_VIEWLIST,'',10,14,210,200,GFLAG_NOTHING);
  630.  
  631.      EventList:=WM.NewListHeader;
  632.      WM.NewListNode(EventList,'Events');
  633.      WM.NewListNode(EventList,'');
  634.      WM.NewListNode(EventList,'All important operations done by');
  635.      WM.NewListNode(EventList,'the user are reported to the');
  636.      WM.NewListNode(EventList,'programmer as an event.  When');
  637.      WM.NewListNode(EventList,'an event is received, the');
  638.      WM.NewListNode(EventList,'programmer can use procedures to');
  639.      WM.NewListNode(EventList,'get more information on the event,');
  640.      WM.NewListNode(EventList,'and then he/she may respond to the');
  641.      WM.NewListNode(EventList,'event.');
  642.      WM.NewListNode(EventList,'');
  643.      WM.NewListNode(EventList,'Try clicking in different areas');
  644.      WM.NewListNode(EventList,'and pushing keys on the keyboard');
  645.      WM.NewListNode(EventList,'now.  The events are displayed');
  646.      WM.NewListNode(EventList,'as they happen below this gadget.');
  647.  
  648.      WM.SetGadgetList(EventView,EventList);
  649. END;
  650.  
  651. Procedure EventDemoHandler(port:integer);
  652. { Since this is the most complex handler, it will be further explained}
  653.  
  654. var
  655.    information:string;
  656.    temp:string;
  657.  
  658.    procedure OutputInformation;
  659.    {This procedure outputs the variable information in a nice fasion in the
  660.     window}
  661.  
  662.    BEGIN
  663.         { The PrepareUserOuput/DoneUserOutput pairing is required whenever
  664.          we draw directly into the windows on our own. }
  665.  
  666.         WM.PrepareUserOutput;
  667.  
  668.         WM.FillBox(Gray,10,215,221,230);
  669.         WM.DrawBevelBoxInv(10,215,221,230);
  670.  
  671.         SetColor(Black);
  672.         OutTextXY(20,217,information);
  673.  
  674.         WM.DoneUserOutput;
  675.    END;
  676.  
  677. BEGIN
  678.      information:='';
  679.  
  680.      {We check for all of the possible events that could happen and
  681.       set information equal to the name of the event constant.}
  682.  
  683.      {A gadget has been pressed, its PGadget ID is available in
  684.       QueryGadgetPressed}
  685.  
  686.      if WM.EventInPort(EVENT_GADGETPRESSED,port) then
  687.      BEGIN
  688.           information:='GADGETPRESSED ID:';
  689.  
  690.           str(abs(LongInt(WM.QueryGadgetPressed)),temp);
  691.           information:=information+temp;
  692.      END;
  693.  
  694.      {Someone has pushed on a close gadget, and this window is asking
  695.       to be closed.  Use Dispose Window to close then window, and
  696.       then perform any other clean up that is needed}
  697.  
  698.      if WM.EventInPort(EVENT_ASKCLOSEWINDOW,port) then
  699.      BEGIN
  700.           information:='ASKCLOSEWINDOW';
  701.  
  702.           WM.DisposeWindow(EventWin);
  703.           WM.DisposeList(EventList);
  704.  
  705.           EventWin:=nil;
  706.  
  707.           exit;
  708.      END;
  709.  
  710.      {A Window has been sized, Use QueryWindowWidth/QueryWindowInnerWidth,
  711.       QueryWindowHeight,QueryWindowInnerHeight to get the new sizing
  712.       information.  Since gadgets are automatically updated, we dont
  713.       have to worry about redrawing them.  However, any thing else,
  714.       the user must redraw}
  715.  
  716.      if WM.EventInPort(EVENT_SIZEWINDOW,port) then
  717.      BEGIN
  718.           information:='SIZEWINDOW w';
  719.           Str(WM.QueryWindowWidth,temp);
  720.           information:=information+temp+' h';
  721.           Str(WM.QueryWindowHeight,temp);
  722.           information:=information+temp;
  723.      END;
  724.  
  725.      {A New Window has been activated and is now the front most window.
  726.       We need not do any updating, all of the window imagery is stored
  727.       and updated for us.}
  728.  
  729.      if WM.EventInPort(EVENT_ACTIVATEWINDOW,port) then
  730.      BEGIN
  731.           information:='ACTIVATEWINDOW ID:';
  732.  
  733.           str(abs(LongInt(WM.QueryWindowActive)),temp);
  734.                 information:=information+temp;
  735.      END;
  736.  
  737.      {The left mouse button has been pressed.  One can use QueryMouseX and
  738.       QueryMouseY to get the positional information of the mouse relative
  739.       to the current window at any time.}
  740.  
  741.      if WM.EventInPort(EVENT_LMBPRESSED,port) then
  742.      BEGIN
  743.           information:='LBMPRESSED x';
  744.  
  745.           str(WM.QueryMouseX,temp);
  746.           information:=information+temp+' y';
  747.           str(WM.QueryMouseY,temp);
  748.           information:=information+temp;
  749.      END;
  750.  
  751.      {The right mouse button has been pressed}
  752.  
  753.      if WM.EventInPort(EVENT_RMBPRESSED,port) then
  754.      BEGIN
  755.           information:='RMBPRESSED x';
  756.  
  757.           str(WM.QueryMouseX,temp);
  758.           information:=information+temp+' y';
  759.           str(WM.QueryMouseY,temp);
  760.           information:=information+temp;
  761.      END;
  762.  
  763.      {The left mouse button has been released}
  764.  
  765.      if WM.EventInPort(EVENT_LMBRELEASED,port) then
  766.      BEGIN
  767.           information:='LMBRELEASED';
  768.      END;
  769.  
  770.      {The right mouse button has been released}
  771.  
  772.      if WM.EventInPort(EVENT_RMBRELEASED,port) then
  773.      BEGIN
  774.           information:='RMBRELEASED';
  775.      END;
  776.  
  777.      {A key has been pressed, it is available in QueryKeyPressed.}
  778.  
  779.      if WM.EventInPort(EVENT_KEYPRESSED,port) then
  780.      BEGIN
  781.           information:='KEYPRESSED '+WM.QueryKeyPressed;
  782.      END;
  783.  
  784.      {An extended key has been pressed, it's code is availale in
  785.       QueryExtKeyPressed. }
  786.  
  787.      if WM.EventInPort(EVENT_EXTKEYPRESSED,port) then
  788.      BEGIN
  789.           information:='EXTKEYPRESSED X';
  790.      END;
  791.  
  792.      {A Menu has been pressed, its ID is available in QueryMenuPressed}
  793.  
  794.      if WM.EventInPort(EVENT_MENUPRESSED,port) then
  795.      BEGIN
  796.           information:='MENUPRESSED ID:';
  797.           Str(WM.QueryMenuPressed,temp);
  798.           information:=information+temp;
  799.      END;
  800.  
  801.      OutputInformation;  {Output the new information}
  802. END;
  803.  
  804. BEGIN
  805.      {Init the Window Manager Object, pass the title of the program
  806.       and the name of the programmer. }
  807.  
  808.      WM.Init('Chrome Interface Demo','High Velocity Systems');
  809.  
  810.      {Do our initialization}
  811.  
  812.      InitDemo;
  813.  
  814.      {Start the loop, continue until terminated}
  815.  
  816.      Repeat
  817.            {Wait for there to been an event in the port}
  818.  
  819.            Repeat
  820.                  WM.WinEventManager;
  821.  
  822.                  Port:=WM.QueryEventPort;
  823.            Until Port<>0;
  824.  
  825.            {If its a menu event, then we need to init that demo section
  826.             if it is not already open}
  827.  
  828.            if WM.EventInPort(EVENT_MENUPRESSED,Port) then
  829.            BEGIN
  830.               MenuID:=WM.QueryMenuPressed;
  831.  
  832.               case MenuID of
  833.                    BUTTONDEMO:
  834.                     If ButtonWin=nil then
  835.                      ButtonDemoProc;
  836.                    CHECKDEMO:
  837.                     If CheckWin=nil then
  838.                      CheckDemoProc;
  839.                    PROPDEMO:
  840.                     If PropWin=nil then
  841.                      PropDemoProc;
  842.                    LISTDEMO:
  843.                     If ListWin=nil then
  844.                      ListDemoProc;
  845.                    STRINGDEMO:
  846.                     If StringWin=nil then
  847.                      StringDemoProc;
  848.                    LINKDEMO:
  849.                     If LinkWin=nil then
  850.                      LinkDemoProc;
  851.                    WINDOWDEMO:
  852.                     If WindowWin=nil then
  853.                      WindowDemoProc;
  854.                    EVENTDEMO:
  855.                     If EventWin=nil then
  856.                      EventDemoProc;
  857.                    ABOUT:
  858.                     If AboutWin=nil then
  859.                      AboutDemoProc;
  860.                    REQDEMO:
  861.                      ReqDemoProc;
  862.                    QUIT:
  863.                      terminated:=TRUE;
  864.               end;
  865.            END
  866.            else
  867.            {Otherwize we need to handle the event according to each
  868.             individual window's handler}
  869.            BEGIN
  870.                 aw:=WM.QueryWindowActive;
  871.  
  872.                 If aw=ButtonWin then
  873.                    ButtonDemoHandler(Port)
  874.                 else if aw=CheckWin then
  875.                    CheckDemoHandler(Port)
  876.                 else if aw=PropWin then
  877.                    PropDemoHandler(Port)
  878.                 else if aw=ListWin then
  879.                    ListDemoHandler(Port)
  880.                 else if aw=StringWin then
  881.                    StringDemoHandler(Port)
  882.                 else if aw=LinkWin then
  883.                    LinkDemoHandler(Port)
  884.                 else if aw=WindowWin then
  885.                    WindowDemoHandler(Port)
  886.                 else if aw=EventWin then
  887.                    EventDemoHandler(Port)
  888.                 else if aw=AboutWin then
  889.                    AboutDemoHandler(Port);
  890.            END;
  891.      Until terminated;
  892.  
  893.      {Clean up some stuff}
  894.  
  895.      DoneDemo;
  896.  
  897.      {Tell the Window Manager that we are done with it.}
  898.  
  899.      WM.Done;
  900. END.