home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / ZINC_6.ZIP / DOSSRC.ZIP / D_ICON.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-01  |  4.3 KB  |  127 lines

  1. //    Zinc Interface Library - D_ICON.CPP
  2. //    COPYRIGHT (C) 1990, 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #include "ui_dsn.hpp"
  6. #include "d_help.hlh"
  7. #include <mem.h>
  8. #include <graphics.h>
  9.  
  10. const int STRING_FIELD        = 0x0001;
  11. const int WIDTH_FIELD        = 0x0002;
  12. const int HEIGHT_FIELD        = 0x0003;
  13. const int ICON_FIELD        = 0x0004;
  14. const int STRINGID_FIELD    = 0x0005;
  15.  
  16. static UCHAR _colorMap[] =
  17. {
  18.     BLACK, DARKGRAY,
  19.     BLUE, LIGHTBLUE,
  20.     GREEN, LIGHTGREEN,
  21.     CYAN, LIGHTCYAN,
  22.     RED, LIGHTRED,
  23.     MAGENTA, LIGHTMAGENTA,
  24.     BROWN, YELLOW,
  25.     LIGHTGRAY, WHITE
  26. };
  27. int UIW_ICON::Editor(const UI_EVENT &event)
  28. {
  29.     char *windowName = "Icon";
  30.  
  31.     int ccode = event.type;
  32.     switch (ccode)
  33.     {
  34.     case S_EDIT_OBJECT:
  35.         {
  36.         UIW_BUTTON *save, *cancel, *help;
  37.         UIW_ICON *iconField;
  38.         UIW_STRING *stringField, *stringIDField;
  39.         UIW_NUMBER *widthField, *heightField;
  40.  
  41.         // Create the icon editor window.
  42.         UIW_WINDOW *window = new UIW_WINDOW(_centerColumn - 34, _centerLine - 13,
  43.             68, 26, WOF_NO_FLAGS, WOAF_MODAL | WOAF_NO_SIZE);
  44.         *window
  45.             + new UIW_BORDER
  46.             + &(*new UIW_SYSTEM_BUTTON
  47.                 + new UIW_POP_UP_ITEM("~Move", MNIF_MOVE, BTF_NO_TOGGLE, WOF_NO_FLAGS)
  48.                 + new UIW_POP_UP_ITEM("~Close", MNIF_CLOSE, BTF_NO_TOGGLE, WOF_NO_FLAGS))
  49.             + new UIW_TITLE(windowName)
  50.  
  51.             + new UIW_PROMPT(2, 1, "Text:", WOF_NO_FLAGS)
  52.             + (stringField = new UIW_STRING(10, 1, 20, string, 100,
  53.                 STF_NO_FLAGS, WOF_BORDER | WOF_AUTO_CLEAR, 0))
  54.             + new UIW_PROMPT(2, 2, "Width:", WOF_NO_FLAGS)
  55.             + (widthField = new UIW_NUMBER(10, 2, 10, &bitmapWidth, "1..64",
  56.                 NMF_NO_FLAGS, WOF_BORDER | WOF_NON_SELECTABLE | WOF_AUTO_CLEAR, 0))
  57.             + new UIW_PROMPT(2, 3, "Height:", WOF_NO_FLAGS)
  58.             + (heightField = new UIW_NUMBER(10, 3, 10, &bitmapHeight, "1..64",
  59.                 NMF_NO_FLAGS, WOF_BORDER | WOF_NON_SELECTABLE | WOF_AUTO_CLEAR, 0))
  60.  
  61.             + new UIW_PROMPT(32, 1, "StringID:", WOF_NO_FLAGS)
  62.             + (stringIDField = new UIW_STRING(42, 1, 22, search.stringID, 100, STF_VARIABLE_NAME, WOF_BORDER | WOF_AUTO_CLEAR, 0))
  63.  
  64.             + new UIW_PROMPT(4, 5, "color", WOF_NO_FLAGS)
  65.             + new UIW_PROMPT(12, 9, "left", WOF_NO_FLAGS)
  66.             + new UIW_PROMPT(12, 13, "right", WOF_NO_FLAGS)
  67.             + new UIW_PROMPT(20, 5, "bitmap", WOF_NO_FLAGS)
  68.             + new UIW_PROMPT(48, 5, "icon", WOF_NO_FLAGS)
  69.  
  70.             + new UIW_ICON(4, 6, 1, 16, _colorMap, NULL, ICF_WRITE, WOF_BORDER, NULL, 32, 11)
  71.             + new UIW_ICON(12, 10, 1, 1, NULL, NULL, ICF_AUTO_SELECT, WOF_BORDER | WOF_NON_SELECTABLE, NULL, 32, 11)
  72.             + new UIW_ICON(12, 14, 1, 1, NULL, NULL, ICF_AUTO_ESCAPE, WOF_BORDER | WOF_NON_SELECTABLE, NULL, 32, 11)
  73.             + new UIW_ICON(20, 6, bitmapWidth, bitmapHeight, bitmapArray, NULL, ICF_READ, WOF_BORDER, NULL, 5, 5)
  74.             + (iconField = new UIW_ICON(48, 6, bitmapWidth, bitmapHeight, bitmapArray,
  75.                 NULL, ICF_READ | ICF_END, WOF_NON_SELECTABLE, NULL, 1, 1))
  76.  
  77.             + (save = new UIW_BUTTON(13, 22, 10, "~Save",
  78.                 BTF_NO_TOGGLE | BTF_AUTO_SIZE,
  79.                 WOF_BORDER | WOF_JUSTIFY_CENTER, UI_DESIGN_MANAGER::Save))
  80.             + (cancel = new UIW_BUTTON(28, 22, 10, "~Cancel",
  81.                 BTF_NO_TOGGLE | BTF_AUTO_SIZE,
  82.                 WOF_BORDER | WOF_JUSTIFY_CENTER, UI_DESIGN_MANAGER::Cancel))
  83.             + (help = new UIW_BUTTON(43, 22, 10, "~Help",
  84.                 BTF_NO_TOGGLE | BTF_AUTO_SIZE,
  85.                 WOF_BORDER | WOF_JUSTIFY_CENTER, UI_DESIGN_MANAGER::Help));
  86.  
  87.         // Identify key fields.
  88.         window->StringID(windowName);
  89.         stringField->NumberID(STRING_FIELD);
  90.         widthField->NumberID(WIDTH_FIELD);
  91.         heightField->NumberID(HEIGHT_FIELD);
  92.         stringIDField->NumberID(STRINGID_FIELD);
  93.         iconField->NumberID(ICON_FIELD);
  94.         save->userObject = cancel->userObject = help->userObject = this;
  95.         help->value = HELP_ICON;
  96.  
  97.         // Add the window to the window manager.
  98.         *windowManager + window;
  99.         break;
  100.         }
  101.  
  102.     case S_SAVE_OBJECT:
  103.         {
  104.         UIW_WINDOW *window = (UIW_WINDOW *)windowManager->Get(windowName);
  105.  
  106.         UIW_STRING *stringIDField = (UIW_STRING *)window->Get(STRINGID_FIELD);
  107.         StringID(stringIDField->DataGet());
  108.  
  109.         UIW_STRING *stringField = (UIW_STRING *)window->Get(STRING_FIELD);
  110.         if (string) delete string;
  111.         string = ui_strdup(stringField->DataGet());
  112.  
  113.         UIW_ICON *iconField = (UIW_ICON *)window->Get(ICON_FIELD);
  114.         memcpy(bitmapArray, iconField->DataGet(), bitmapWidth * bitmapHeight);
  115.         UI_WINDOW_OBJECT::Redisplay(TRUE);
  116.         break;
  117.         }
  118.  
  119.     default:
  120.         ccode = UI_WINDOW_OBJECT::Editor(event);
  121.         break;
  122.     }
  123.  
  124.     // Return the control code.
  125.     return (ccode);
  126. }
  127.