home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / global.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  8.4 KB  |  253 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.02
  4. // Copyright (C) 1990, 1991
  5. // Software Dimensions
  6. //
  7. // Dialog Development System
  8. //
  9.  
  10. #include "fliwin.h"
  11. #include "colors.h"
  12. #include "dds.h"
  13.  
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17.  
  18. #include "open.h"
  19. #include "yesno.h"
  20.  
  21. int ZPositioning=0;
  22.  
  23. //-------------------------------------------------------------------------
  24. //
  25. // This is the GLOBAL event handler for the DDS workspace
  26. // The LOCAL (or window) event handler is in DIAWIN.CPP
  27. //
  28. //-------------------------------------------------------------------------
  29.  
  30. int DesignerWindow::EventHandler(int Event)
  31. {
  32.   switch(Event)
  33.   {
  34.     case winChDir:
  35.       ChDirDialog &ChDir=*new ChDirDialog();
  36.       ChDir.UseDialog();
  37.       delete &ChDir;
  38.       return CompleteEvent;
  39.  
  40.     case winDOSShell:
  41.       BlazeClass Blaze;
  42.       char *Screen = new char[Blaze.ComputeNeededBytes(Blaze.WhatWidth(),Blaze.WhatHeight())];
  43.       MouseShutDown();
  44.       Blaze.Window(0,0,Blaze.WhatWidth(),Blaze.WhatHeight());
  45.       Blaze.GetArea(0,0,Blaze.WhatWidth(),Blaze.WhatHeight(),Screen);
  46.       Blaze.EraseArea(0,0,Blaze.WhatWidth(),Blaze.WhatHeight(),7);
  47.       Blaze.GotoXY(0,0);
  48.       Blaze.VisibleCursor();
  49.       puts("Type EXIT to return to the FLI Dialog Designer");
  50.       system("");
  51.       Blaze.InvisibleCursor();
  52.       Blaze.PutArea(0,0,Screen);
  53.       MouseReStart();
  54.       MouseShow();
  55.       delete Screen;
  56.       return CompleteEvent;
  57.  
  58.     case winOpen:
  59.       if (NumberOfWindows)
  60.         return Event;
  61.  
  62.       OpenDialog &Open=*new OpenDialog("*.DDS");
  63.       char *File=Open.OpenFile();
  64.  
  65.       if (!File || !*File)
  66.       {
  67.         delete &Open;
  68.         return CompleteEvent;
  69.       }
  70.  
  71.       char Filer[100];
  72.       strcpy(Filer,File);
  73.       delete &Open;
  74.  
  75.       if (File && *File)
  76.       {
  77.         RemoveAllMenus();
  78.  
  79.               if (!NewWindow(new DialogWindow(Filer),0))
  80.                   return CompleteEvent;
  81.  
  82.         goto Menus;
  83.       }
  84.  
  85.       return CompleteEvent;
  86.  
  87.     case winAbout:
  88.       Welcome->Title("About");
  89.       Welcome->UseInfoBox();
  90.       return CompleteEvent;
  91.  
  92.     case winExit:
  93.       {
  94.         YesNo &Query=*new YesNo();
  95.         Query + "Are you sure that you want to exit?";
  96.         Query.Title("Please Confirm");
  97.         int Response=Query.UseYesNo();
  98.         delete &Query;
  99.         if (!Response)
  100.           return CompleteEvent;
  101.       }
  102.       return StopEvent;
  103.  
  104.     case layoutMove:
  105.       MoveWindow();
  106.       return CompleteEvent;
  107.  
  108.     case layoutSize:
  109.       SizeWindow();
  110.       return CompleteEvent;
  111.  
  112.     case winNew:
  113.  
  114.             if (NumberOfWindows)
  115.                 return Event;
  116.  
  117.             if (!NewWindow(new DialogWindow(),0))
  118.                 return CompleteEvent;
  119.  
  120. Menus:
  121.  
  122.             NewMenu("~Layout","Dialog layout characteristics",kbAltL);
  123.                 Option("~Specifiers ...","Specify the specifiers of this dialog",layoutSpecs);
  124.                 Option("~Test Dialog ...","Test the dialog and see how it performs",layoutTest);
  125.                 HotKey("Alt-T",kbAltT);
  126.         BlankLine();
  127.                 Option("~Edit Mode","Select the Edit Mode",layoutEditMode);
  128.                 Selectable(ZPositioning,"Normal Edit","Z Positioning",(char*)0);
  129.                 HotKey("Alt-Z",kbAltZ);
  130.         BlankLine();
  131.         Option("~Move Dialog","Move the dialog (for non-mousers)",layoutMove);
  132.         Option("~Size Dialog","Size the dialog (for non-mousers)",layoutSize);
  133.  
  134.             NewMenu("~Element","Place an element on the dialog",kbAltE);
  135.                 Option("~Character","Drop a character or scrolling character element (Quick Masks too!)",elementChar);
  136.                 HotKey("Ctrl-C",kbCtrlC);
  137.                 Option("~Integer","Drop an integer element",elementInt);
  138.                 HotKey("Ctrl-I",kbCtrlI);
  139.                 Option("~Long","Drop a long integer element",elementLong);
  140.                 HotKey("Ctrl-L",kbCtrlL);
  141.                 Option("~Float","Drop a floating point element",elementFloat);
  142.                 HotKey("Ctrl-F",kbCtrlF);
  143.                 Option("~Double","Drop a double floating point element",elementDouble);
  144.                 HotKey("Ctrl-D",kbCtrlD);
  145.                 Option("~Bcd","Drop a BCD element",elementBcd);
  146.                 HotKey("Ctrl-B",kbCtrlB);
  147.         BlankLine();
  148.                 Option("~Vertical Radio Buttons","Drop a radio button element",elementVRadio);
  149.               HotKey("Ctrl-V",kbCtrlV);
  150.         Option("~Horizontal Radio Buttons","Drop a radio button element",elementHRadio);
  151.               HotKey("Ctrl-Z",kbCtrlZ);
  152.                 Option("Chec~k Box","Drop a check box element",elementCheck);
  153.                 HotKey("Ctrl-K",kbCtrlK);
  154.                 Option("P~ush Button","Drop a push button element",elementPush);
  155.                 HotKey("Ctrl-U",kbCtrlU);
  156.                 Option("~Generic Pick List","Drop a generic pick list element",elementPickGeneric);
  157.         HotKey("Ctrl-P",kbCtrlP);
  158.         BlankLine();
  159.                 Option("~Group Heading","Drop a group heading",elementHeading);
  160.         HotKey("Ctrl-G",kbCtrlG);
  161.  
  162.             NewMenu("~Draw","Draw a Blaze elements in the dialog box",kbAltD);
  163.                 Option("~Box","Draw a hollow box",drawBox);
  164.                 HotKey("Alt-B",kbAltB);
  165.                 Option("F~illed Box","Draw a filled box",drawFillBox);
  166.                 HotKey("Alt-I",kbAltI);
  167.                 Option("~Horizontal Line","Draw a horizontal line",drawHLine);
  168.                 HotKey("Alt-H",kbAltH);
  169.                 Option("~Vertical Line","Draw a vertical line",drawVLine);
  170.                 HotKey("Alt-V",kbAltV);
  171.                 Option("~Shadow","Draw a shadow",drawShadow);
  172.                 HotKey("Alt-S",kbAltS);
  173.                 Option("E~rase Area","Erase or blank an area",drawErase);
  174.                 HotKey("Alt-R",kbAltR);
  175.                 Option("~Transparent Box","Draw a transparent box",drawTrans);
  176.                 HotKey("Alt-N",kbAltN);
  177.                 Option("~Plop Character","Drop a character",drawPlop);
  178.                 HotKey("Alt-P",kbAltP);
  179.                 BlankLine();
  180.                 Option("Change ~Drawing Color","Change the current color",drawColor);
  181.                 HotKey("F4",kbF4);
  182.  
  183.             NewMenu("~Manipulate","Manipulate the way the dialog appears",kbAltM);
  184.                 Option("Throw ~Back","Throw a drawing object to the rear of the dialog",manipBack);
  185.                 HotKey("F5",kbF5);
  186.                 Option("Pull ~Forward","Pull a drawing object to the top of the dialog",manipForward);
  187.                 HotKey("F6",kbF6);
  188.                 Option("Element ~Rearrange","Rearrange the order of the elements on the dialog",manipReArrange);
  189.                     SubMenu();
  190.                     Option("Move to ~Start","Make an element the starting point for the dialog",manipToStart);
  191.           HotKey("Ctrl-Home",kbCtrlHome);
  192.                     Option("Move to ~End","Make an element the last on the dialog",manipToEnd);
  193.           HotKey("Ctrl-End",kbCtrlEnd);
  194.                     Option("Slide One E~arlier","Move element one step closer to the start of the dialog",manipEarlier);
  195.           HotKey("Ctrl-PgUp",kbCtrlPgUp);
  196.           Option("Slide One ~Later","Move element one step closer to the end of the dialog",manipLater);
  197.           HotKey("Ctrl-PgDn",kbCtrlPgDn);
  198.                     EndSubMenu();
  199.                 BlankLine();
  200.                 Option("~Size or Edit","Size a drawn object or edit an element",manipSize);
  201.                 HotKey("F7",kbF7);
  202.                 Option("~Move","Move an object, element, or prompter",manipMove);
  203.                 HotKey("F8",kbF8);
  204.                 Option("Move ~Text","Move a block of text",manipMoveText);
  205.                 Option("~Copy","Copy an object or element",manipCopy);
  206.                 HotKey("F9",kbF9);
  207.                 Option("C~opy Text","Copy a block of text",manipCopyText);
  208.                 Option("~Delete a Piece","Delete an element or drawn object",manipDeletePiece);
  209.         HotKey("F3",kbF3);
  210.         BlankLine();
  211.                 Option("T~ext Color","Change the color of some text to the current color",manipTextColor);
  212.                 Option("Ob~ject Color","Change the color of a drawn object to the current color",manipObjectColor);
  213.  
  214.             SetMenus();
  215.  
  216.             return RefreshEvent;
  217.  
  218.         case CloseEvent:
  219.             DeleteLastMenu();
  220.             DeleteLastMenu();
  221.             DeleteLastMenu();
  222.             DeleteLastMenu();
  223.             SetMenus();
  224.             return CompleteEvent;
  225.  
  226.         case winControlPanel:
  227.             if (ControlPanel())
  228.                 RefreshWorkSpace();
  229.       if (BlazeClass::WhatWidth()>80 || BlazeClass::WhatHeight()>25)
  230.       {
  231.         InfoBox &NotAvailable = *new InfoBox;
  232.         NotAvailable
  233.               + "It isn't advisable to create a dialog box"
  234.               + "that is larger than the default 80x25"
  235.               + "display mode, because the end user may"
  236.               + "not have video support for this mode."
  237.               + ""
  238.               + "If you know that your end users have"
  239.               + "support for this video mode, then enjoy"
  240.               + "yourself and start designing!";
  241.         NotAvailable.Title("Recommendation");
  242.         NotAvailable.UseInfoBox();
  243.         delete &NotAvailable;
  244.       }
  245.       return CompleteEvent;
  246.  
  247.     case winCallMenu:
  248.       CallMenu();
  249.       return CompleteEvent;
  250.   }
  251.   return Event;
  252. }
  253.