home *** CD-ROM | disk | FTP | other *** search
- // Zinc Interface Library - TITLE.CPP
- // COPYRIGHT (C) 1990, 1991. All Rights Reserved.
- // Zinc Software Incorporated. Pleasant Grove, Utah USA
-
- #include "ui_win.hpp"
- #include <string.h>
-
- UIW_TITLE::UIW_TITLE(char *title, USHORT _woFlags) :
- UIW_BUTTON(0, 0, 0, title, BTF_DOWN_CLICK | BTF_NO_TOGGLE | BTF_NO_3D,
- _woFlags | WOF_BORDER | WOF_NON_FIELD_REGION, UIW_TITLE::TitleUserFunction)
- {
- // Initialize the title information.
- windowID[0] = ID_TITLE;
- windowID[1] = ID_BUTTON;
- search.type = ID_TITLE;
- search.numberID = NUMID_TITLE;
- strcpy(search.stringID, "NUMID_TITLE");
-
- woAdvancedFlags |= WOAF_NON_CURRENT;
- }
-
- void UIW_TITLE::DataSet(char *_string)
- {
- // Reset the button's string information.
- if (_string)
- {
- if (string && !FlagSet(woFlags, WOF_NO_ALLOCATE_DATA))
- delete string;
- string = FlagSet(woFlags, WOF_NO_ALLOCATE_DATA) ? _string : ui_strdup(_string);
- }
- if (display && display->isText)
- UI_WINDOW_OBJECT::Redisplay(TRUE);
- else
- UI_WINDOW_OBJECT::Redisplay(FALSE);
- }
-
- int UIW_TITLE::Event(const UI_EVENT &event)
- {
- // Switch on the event type.
- int ccode = UI_WINDOW_OBJECT::LogicalEvent(event, ID_TITLE);
- switch (ccode)
- {
- case S_CREATE:
- UIW_BUTTON::Event(event);
- // Continue to S_SIZE.
-
- case S_SIZE:
- if (display->isText)
- {
- int width = (parent && parent->hotKey) ?
- strlen(string) - 1 : strlen(string);
- if (FlagSet(woFlags, WOF_BORDER))
- width += 2;
- true.top = true.bottom = parent->true.top;
- int count = 0;
- for (UI_WINDOW_OBJECT *object = Previous(); object;
- object = object->Previous())
- if (object->true.top == parent->true.top)
- count++;
- if (count > 1)
- {
- true.left = parent->true.left + 5;
- true.right = parent->true.right - 8;
- }
- else
- {
- true.left = parent->true.left + 1;
- true.right = parent->true.right - 1;
- }
- if (width < true.right - true.left)
- {
- if (FlagSet(woFlags, WOF_JUSTIFY_CENTER))
- true.left += (true.right - true.left - width + 1) / 2;
- else if (FlagSet(woFlags, WOF_JUSTIFY_RIGHT))
- true.left = true.right - width + 1;
- true.right = true.left + width - 1;
- }
- }
- else
- {
- int height;
- UI_WINDOW_OBJECT::Information(GET_DEFAULT_HEIGHT, &height);
- UI_WINDOW_OBJECT::RegionMax(TRUE);
- if (true.top > parent->true.top)
- true.top -= 1;
- if (true.right < parent->true.right)
- true.right += 1;
- if (true.left > parent->true.left)
- true.left -= 1;
- true.bottom = true.top + height - 1;
- }
- break;
-
- case L_VIEW:
- if (!FlagSet(parent->woAdvancedFlags, WOAF_NO_MOVE) &&
- UI_WINDOW_OBJECT::Overlap(event.position))
- {
- UI_EVENT tEvent = event;
- tEvent.rawCode = DM_MOVE;
- eventManager->Event(tEvent);
- break;
- }
- // Continue to default.
-
- case S_DISPLAY_ACTIVE:
- case S_DISPLAY_INACTIVE:
- if (display->isText)
- lastPalette = NULL;
- // Continue to default.
-
- default:
- ccode = UIW_BUTTON::Event(event);
- break;
- }
-
- // Return the control code.
- return (ccode);
- }
-
-
- #ifdef ZIL_LOAD
- UIW_TITLE::UIW_TITLE(const char *name, UI_STORAGE *file, USHORT loadFlags) :
- UIW_BUTTON(name, file, loadFlags | L_SUB_LEVEL)
- {
- windowID[0] = ID_TITLE;
- windowID[1] = ID_BUTTON;
- userFunction = UIW_TITLE::TitleUserFunction;
-
- if (!file)
- file = _storage;
- if (!FlagSet(loadFlags, L_SUB_LEVEL) && FlagSet(file->stStatus, STS_TEMPORARY))
- delete file;
- }
- #endif
-
- #ifdef ZIL_STORE
- void UIW_TITLE::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
- {
- UIW_BUTTON::Store(name, file, storeFlags | S_SUB_LEVEL);
- if (!FlagSet(storeFlags, S_SUB_LEVEL))
- file->ObjectSize(name, search);
- }
- #endif
-