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

  1. //    Zinc Interface Library - TITLE.CPP
  2. //    COPYRIGHT (C) 1990, 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #include "ui_win.hpp"
  6. #include <string.h>
  7.  
  8. UIW_TITLE::UIW_TITLE(char *title, USHORT _woFlags) :
  9.     UIW_BUTTON(0, 0, 0, title, BTF_DOWN_CLICK | BTF_NO_TOGGLE | BTF_NO_3D,
  10.     _woFlags | WOF_BORDER | WOF_NON_FIELD_REGION, UIW_TITLE::TitleUserFunction)
  11. {
  12.     // Initialize the title information.
  13.     windowID[0] = ID_TITLE;
  14.     windowID[1] = ID_BUTTON;
  15.     search.type = ID_TITLE;
  16.     search.numberID = NUMID_TITLE;
  17.     strcpy(search.stringID, "NUMID_TITLE");
  18.  
  19.     woAdvancedFlags |= WOAF_NON_CURRENT;
  20.     MSWindowsStyle |= WS_CAPTION;
  21. }
  22.  
  23. void UIW_TITLE::DataSet(char *_string)
  24. {
  25.     // Reset the button's string information.
  26.     if (_string)
  27.     {
  28.         if (string && !FlagSet(woFlags, WOF_NO_ALLOCATE_DATA))
  29.             delete string;
  30.         string = FlagSet(woFlags, WOF_NO_ALLOCATE_DATA) ? _string : ui_strdup(_string);
  31.         if (parent && parent->hWnd)
  32.             SetWindowText(parent->hWnd, string);
  33.     }
  34.     if (display && display->isText)
  35.         UI_WINDOW_OBJECT::Redisplay(TRUE);
  36.     else
  37.         UI_WINDOW_OBJECT::Redisplay(FALSE);
  38. }
  39.  
  40. int UIW_TITLE::Event(const UI_EVENT &event)
  41. {
  42.     // Switch on the event type.
  43.     int ccode = event.type;
  44.     switch (ccode)
  45.     {
  46.     case S_INITIALIZE:
  47.         if (parent)
  48.             parent->MSWindowsStyle |= MSWindowsStyle;
  49.         break;
  50.  
  51.     case S_CREATE:
  52.     case S_SIZE:
  53.         if (parent->hWnd)
  54.             SetWindowText(parent->hWnd, string);
  55.  
  56.         int height;
  57.         height = GetSystemMetrics(SM_CYCAPTION) - 1;
  58.         UI_WINDOW_OBJECT::RegionMax(TRUE);
  59.         true.top -= 1;
  60.         true.bottom = true.top + height - 1;
  61.         break;
  62.  
  63.     default:
  64.         // Default to the base class object.
  65.         ccode = UI_WINDOW_OBJECT::Event(event);
  66.         break;
  67.     }
  68.  
  69.     // Return the control code.
  70.     return (ccode);
  71. }
  72.  
  73.  
  74. #ifdef ZIL_LOAD
  75. UIW_TITLE::UIW_TITLE(const char *name, UI_STORAGE *file, USHORT loadFlags) :
  76.     UIW_BUTTON(name, file, loadFlags | L_SUB_LEVEL)
  77. {
  78.     windowID[0] = ID_TITLE;
  79.     windowID[1] = ID_BUTTON;
  80.     userFunction = UIW_TITLE::TitleUserFunction;
  81.  
  82.     if (!file)
  83.         file = _storage;
  84.     if (!FlagSet(loadFlags, L_SUB_LEVEL) && FlagSet(file->stStatus, STS_TEMPORARY))
  85.         delete file;
  86. }
  87. #endif
  88.  
  89. #ifdef ZIL_STORE
  90. void UIW_TITLE::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
  91. {
  92.     UIW_BUTTON::Store(name, file, storeFlags | S_SUB_LEVEL);
  93.     if (!FlagSet(storeFlags, S_SUB_LEVEL))
  94.         file->ObjectSize(name, search);
  95. }
  96. #endif
  97.  
  98.  
  99.