home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / c / ZINC.ZIP / D_GRAPH.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-23  |  2.3 KB  |  87 lines

  1. //    Program name..    Zinc Interface Library
  2. //    Filename......    D_.CPP
  3. //    
  4. //    COPYRIGHT (C) 1990.  All Rights Reserved.
  5. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  6.  
  7. #include <graphics.h>
  8. #include <ui_win.hpp>
  9. #include "d_demo.hpp"
  10. #include "d_help.hlh"
  11.  
  12. // Icon bitmap.
  13. static USHORT note[] = {
  14.     8,            //          16th note
  15.     12,            //           ┌────────┐
  16.     0x0800,        //           │    ■   │
  17.     0x0C00,        //           │    ■■  │
  18.     0x0B00,        //           │    ■ ■■│
  19.     0x0800,        //           │    ■   │
  20.     0x0C00,        //           │    ■■  │
  21.     0x0B00,        //           │    ■ ■■│
  22.     0x0800,        //           │    ■   │
  23.     0x7800,        //           │ ■■■■   │
  24.     0xF800,        //           │■■■■■   │
  25.     0xF800,        //           │■■■■■   │
  26.     0xF800,        //           │■■■■■   │
  27.     0x7000        //           │ ■■■    │
  28.                 //           └────────┘
  29. };
  30.  
  31. USHORT *notes[] = { note, 0 };
  32.  
  33. UI_PALETTE notePalettes[] =
  34. {
  35.     {
  36.         '\260', attrib(RED, RED), attrib(MONO_BLACK, MONO_BLACK),
  37.             SOLID_FILL, attrib(RED, WHITE), attrib(BW_BLACK, BW_WHITE),
  38.             attrib(GS_BLACK, GS_WHITE)
  39.     }
  40. };
  41.  
  42.  
  43. #pragma argsused
  44. void Graph(void *item, UI_EVENT &event)
  45. {
  46.     extern void ExitButton(void *object, UI_EVENT &event);
  47.  
  48.     int left = _display->columns / _display->cellWidth / 2 - 15;
  49.     int top = _display->lines / _display->cellHeight / 2 - 8;
  50.     if (top < 0)
  51.         top = 0;
  52.  
  53.     // Create the window.
  54.     UIW_WINDOW *window = UIW_WINDOW::GENERIC(left, top, 31, 17, WOF_NO_FLAGS,
  55.         WOAF_MODAL, INFO_GRAPH, " Icon graph ");
  56.     *window
  57.         + &(*new UIW_PULL_DOWN_MENU(0, WOF_NO_FLAGS, WOAF_NO_FLAGS)
  58.             + new HELP_PULL_DOWN_ITEM(" ~About icons ", MNF_NO_FLAGS, INFO_GRAPH));
  59.  
  60.     // Draw the graph with icons if in graphics mode, otherwise use Xs.
  61.     int i, j;
  62.     int height[] = { 8, 7, 7, 7, 5, 6, 4, 1, 1};
  63.     for (i = 2; i <= 28; i += 3)
  64.         for (j = height[i / 3]; j < 9; j++)
  65.         {
  66.             if (_display->isText)
  67.                 *window + new UIW_PROMPT(i, j, "X", WOF_NO_FLAGS);
  68.             else
  69.                 *window + new UIW_ICON(i, j, notes , notePalettes,
  70.                     ICF_NO_FLAGS, WOF_NO_FLAGS);
  71.         }
  72.  
  73.     // Add the prompt line (no border needed in text mode).
  74.     if (_display->isText)
  75.         *window + new UIW_PROMPT(1, 10, " 1  2  3  4  5  6  7  8  9 ", WOF_NO_FLAGS);
  76.     else
  77.         *window + new UIW_PROMPT(1, 10, " 1  2  3  4  5  6  7  8  9 ", WOF_BORDER);
  78.  
  79.     // Add the Exit button.
  80.     *window
  81.         + new UIW_BUTTON(9, 12, 10, "Esc=Exit", BTF_NO_FLAGS, WOF_JUSTIFY_CENTER, ExitButton);
  82.  
  83.     // Add the graph to the window manager.
  84.     *_windowManager + window;
  85. }
  86.  
  87.