home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / ZINC_2.ZIP / EXAMPLES.LIF / WINMGR.CPP next >
Encoding:
C/C++ Source or Header  |  1991-05-13  |  3.5 KB  |  118 lines

  1. //    WINMGR.CPP - Example of multiple window management and help system.
  2. //    COPYRIGHT (C) 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #include <ui_win.hpp>
  6. #include "winmgr.hlh"
  7.  
  8. #ifndef ZIL_MSWINDOWS // ---------------------------------------------------------
  9.  
  10. main()
  11. {
  12.     // Initialize the display, trying for graphics first.
  13.     UI_DISPLAY *display = new UI_DOS_BGI_DISPLAY;
  14.     if (!display->installed)
  15.     {
  16.         delete display;
  17.         display = new UI_DOS_TEXT_DISPLAY;
  18.     }
  19.  
  20.     // Initialize the event manager.
  21.     UI_EVENT_MANAGER *eventManager = new UI_EVENT_MANAGER(100, display);
  22.     *eventManager + new UI_BIOS_KEYBOARD + new UI_MS_MOUSE + new UI_CURSOR;
  23.  
  24. #else // ZIL_MSWINDOWS -----------------------------------------------------------
  25.  
  26. #pragma argsused
  27. int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow )
  28. {
  29.     // Initialize the display.
  30.     UI_DISPLAY *display = new UI_MSWINDOWS_DISPLAY(hInstance, hPrevInstance, nCmdShow);
  31.     if (!display->installed)
  32.     {
  33.         delete display;
  34.         return 1;
  35.     }
  36.  
  37.     // Initialize the event manager and add three devices to it.
  38.     UI_EVENT_MANAGER *eventManager = new UI_EVENT_MANAGER(100, display);
  39.     *eventManager + new UI_MSWINDOWS_MESSAGE;
  40.  
  41. #endif // ZIL_MSWINDOWS -----------------------------------------------------------
  42.  
  43.     // Initialize the window manager.
  44.     UI_WINDOW_MANAGER *windowManager =
  45.         new UI_WINDOW_MANAGER(display, eventManager);
  46.  
  47.     // Initialize the help window system.
  48.     _helpSystem = new UI_HELP_WINDOW_SYSTEM("winmgr",
  49.         windowManager, HELP_GENERAL);
  50.  
  51.     // Initialize the error window system.
  52.     _errorSystem = new UI_ERROR_WINDOW_SYSTEM;
  53.  
  54.     // Create both notepads.
  55.     UIW_WINDOW *notepad1 = new UIW_WINDOW(4, 5, 66, 12,
  56.         WOF_NO_FLAGS, WOAF_NO_FLAGS, HELP_NOTEPAD);
  57.  
  58.     UIW_WINDOW *notepad2 = new UIW_WINDOW(9, 10, 65, 12,
  59.         WOF_NO_FLAGS, WOAF_NO_FLAGS, HELP_NOTEPAD);
  60.  
  61.     // Add window objects to notepad1.
  62.     *notepad1
  63.         + new UIW_BORDER
  64.         + new UIW_MAXIMIZE_BUTTON
  65.         + new UIW_MINIMIZE_BUTTON
  66.         + new UIW_SYSTEM_BUTTON
  67.         + new UIW_TITLE("Notepad 1", WOF_JUSTIFY_CENTER)
  68.  
  69.         + new UIW_PROMPT(2, 1, "To:", WOF_NO_FLAGS)
  70.         + new UIW_STRING(6, 1, 15, "Everyone", 40, STF_NO_FLAGS,
  71.             WOF_BORDER)
  72.  
  73.         + new UIW_PROMPT(28, 1, "Date:", WOF_NO_FLAGS)
  74.         + new UIW_DATE(35, 1, 20, &UI_DATE(), "",
  75.             DTF_SYSTEM | DTF_ALPHA_MONTH, WOF_BORDER)
  76.  
  77.         + new UIW_PROMPT(2, 2, "Message:", WOF_NO_FLAGS)
  78.         + new UIW_TEXT(2, 3, 60, 4, "", 1028, TXF_NO_FLAGS, WOF_BORDER);
  79.  
  80.     // Add window objects to notepad2.
  81.     *notepad2
  82.         + new UIW_BORDER
  83.         + new UIW_MAXIMIZE_BUTTON
  84.         + new UIW_MINIMIZE_BUTTON
  85.         + new UIW_SYSTEM_BUTTON
  86.         + new UIW_TITLE("Notepad 2", WOF_JUSTIFY_CENTER)
  87.  
  88.         + new UIW_PROMPT(2, 1, "To:", WOF_NO_FLAGS)
  89.         + new UIW_STRING(6, 1, 15, "Everyone", 40, STF_NO_FLAGS,
  90.             WOF_BORDER)
  91.  
  92.         + new UIW_PROMPT(28, 1, "Date:", WOF_NO_FLAGS)
  93.         + new UIW_DATE(35, 1, 20, &UI_DATE(), "",
  94.             DTF_SYSTEM | DTF_ALPHA_MONTH, WOF_BORDER)
  95.  
  96.         + new UIW_PROMPT(2, 2, "Message:", WOF_NO_FLAGS)
  97.         + new UIW_TEXT(2, 3, 60, 4, "", 1028, TXF_NO_FLAGS, WOF_BORDER);
  98.  
  99.     // Add notepads to the window manager.
  100.     *windowManager + notepad1 + notepad2;
  101.  
  102.     // Wait for user response.
  103.     int ccode;
  104.     UI_EVENT event;
  105.     do
  106.     {
  107.         eventManager->Get(event, Q_NORMAL);
  108.         ccode = windowManager->Event(event);
  109.     } while (ccode != L_EXIT && ccode != S_NO_OBJECT);
  110.  
  111.     // Clean up.
  112.     delete _helpSystem;
  113.     delete _errorSystem;
  114.      delete windowManager;
  115.     delete eventManager;
  116.     delete display;
  117. }
  118.