home *** CD-ROM | disk | FTP | other *** search
- // Zinc Interface Library - BORDER.CPP
- // COPYRIGHT (C) 1990, 1991. All Rights Reserved.
- // Zinc Software Incorporated. Pleasant Grove, Utah USA
-
- #include "ui_win.hpp"
- #include <string.h>
-
- int UIW_BORDER::width = 6;
-
- UIW_BORDER::UIW_BORDER() :
- UI_WINDOW_OBJECT(0, 0, 0, 0, WOF_NON_FIELD_REGION, WOAF_OUTSIDE_REGION | WOAF_NON_CURRENT)
- {
- // Initialize the border information.
- windowID[0] = ID_BORDER;
- search.type = ID_BORDER;
- search.numberID = NUMID_BORDER;
- strcpy(search.stringID, "NUMID_BORDER");
- }
-
- void UIW_BORDER::DataSet(int _width)
- {
- width = (_width > 0) ? _width : 1;
- if (eventManager)
- {
- UI_EVENT event;
- event.type = S_REDISPLAY;
- eventManager->Put(event, Q_END);
- }
- }
-
- int UIW_BORDER::Event(const UI_EVENT &event)
- {
- // Switch on the event type.
- int tSize;
- UI_WINDOW_OBJECT::Information(GET_DEFAULT_HEIGHT, &tSize);
- tSize /= 2;
- UI_REGION region;
- int ccode = UI_WINDOW_OBJECT::LogicalEvent(event, ID_BORDER);
- switch (ccode)
- {
- case S_CREATE:
- case S_SIZE:
- UI_WINDOW_OBJECT::RegionMax(TRUE);
- if (!display->isText)
- {
- true.left += width;
- true.top += width;
- true.right -= width;
- true.bottom -= width;
- }
- break;
-
- case S_DISPLAY_INACTIVE:
- case S_DISPLAY_ACTIVE:
- // Draw the borders around the object.
- if (!display->isText && !UI_WINDOW_OBJECT::NeedsUpdate(event, ccode))
- break;
- UI_PALETTE *palette = UI_WINDOW_OBJECT::LogicalPalette(ccode);
- lastPalette = palette;
- if (display->isText)
- display->Rectangle(screenID, true, palette, (ccode == S_DISPLAY_ACTIVE) ? 2 : 1);
- else
- {
- region = parent->true;
- eventManager->DevicesHide(parent->true);
- UI_PALETTE *outlinePalette = MapPalette(paletteMapTable,
- PM_ACTIVE, ID_BLACK_SHADOW);
- display->Rectangle(screenID, true, outlinePalette);
- display->Rectangle(screenID, region, outlinePalette);
- UI_WINDOW_OBJECT::Shadow(region, 1);
-
- // Display the top and bottom lines.
- int temp = region.bottom;
- region.bottom = true.top - 1;
- display->Rectangle(screenID, region, palette, 0, TRUE);
- region.bottom = temp;
-
- temp = region.top;
- region.top = true.bottom + 1;
- display->Rectangle(screenID, region, palette, 0, TRUE);
- region.top = temp;
-
- // Display the left and right columns.
- temp = region.right;
- region.right = true.left - 1;
- display->Rectangle(screenID, region, palette, 0, TRUE);
- region.right = temp;
-
- temp = region.left;
- region.left = true.right + 1;
- display->Rectangle(screenID, region, palette, 0, TRUE);
-
- // Draw the corner identifiers.
- if (FlagSet(parent->woAdvancedFlags, WOAF_NO_SIZE))
- {
- eventManager->DevicesShow(parent->true);
- break;
- }
- region = parent->true;
- region.left = true.left + tSize;
- region.right = true.right - tSize;
- if (region.left > region.right)
- region.left = region.right = (true.left + true.right) / 2;
- region.bottom = true.top;
- display->Rectangle(screenID, region, outlinePalette);
- region.top = true.bottom;
- region.bottom = parent->true.bottom;
- display->Rectangle(screenID, region, outlinePalette);
-
- region = parent->true;
- region.top = true.top + tSize;
- region.bottom = true.bottom - tSize;
- if (region.top > region.bottom)
- region.top = region.bottom = (true.top + true.bottom) / 2;
- region.right = true.left;
- display->Rectangle(screenID, region, outlinePalette);
- region.left = true.right;
- region.right = parent->true.right;
- display->Rectangle(screenID, region, outlinePalette);
- eventManager->DevicesShow(parent->true);
- }
- break;
-
- case L_VIEW:
- case L_BEGIN_SELECT:
- UI_EVENT tEvent = event;
- tEvent.rawCode = DM_VIEW;
- if (FlagSet(parent->woAdvancedFlags, WOAF_NO_SIZE))
- {
- eventManager->Event(tEvent);
- break;
- }
- region = true;
- region.left += tSize;
- region.right -= tSize;
- if (region.left > region.right)
- region.left = region.right = (true.left + true.right) / 2;
- region.top += tSize;
- region.bottom -= tSize;
- if (region.top > region.bottom)
- region.top = region.bottom = (true.top + true.bottom) / 2;
-
- int sizeFlags = 0;
- if (event.position.column <= region.left)
- sizeFlags |= M_LEFT_CHANGE;
- else if (event.position.column >= region.right)
- sizeFlags |= M_RIGHT_CHANGE;
- if (event.position.line <= region.top)
- sizeFlags |= M_TOP_CHANGE;
- else if (event.position.line >= region.bottom)
- sizeFlags |= M_BOTTOM_CHANGE;
-
- if (FlagsSet(sizeFlags, M_LEFT_CHANGE | M_TOP_CHANGE) ||
- FlagsSet(sizeFlags, M_RIGHT_CHANGE | M_BOTTOM_CHANGE))
- tEvent.rawCode = DM_DIAGONAL_ULLR;
- else if (FlagsSet(sizeFlags, M_LEFT_CHANGE | M_BOTTOM_CHANGE) ||
- FlagsSet(sizeFlags, M_RIGHT_CHANGE | M_TOP_CHANGE))
- tEvent.rawCode = DM_DIAGONAL_LLUR;
- else if (FlagSet(sizeFlags, M_LEFT_CHANGE | M_RIGHT_CHANGE))
- tEvent.rawCode = DM_HORIZONTAL;
- else if (FlagSet(sizeFlags, M_TOP_CHANGE | M_BOTTOM_CHANGE))
- tEvent.rawCode = DM_VERTICAL;
- eventManager->Event(tEvent);
-
- if (ccode == L_BEGIN_SELECT && sizeFlags)
- {
- UI_EVENT tEvent = event;
- tEvent.type = S_SIZE;
- tEvent.rawCode = sizeFlags;
- eventManager->Put(tEvent, Q_BEGIN);
- }
- break;
-
- default:
- ccode = UI_WINDOW_OBJECT::Event(event);
- break;
- }
-
- // Return the control code.
- return (ccode);
- }
-
- #ifdef ZIL_STORE
- #pragma argsused
- void UIW_BORDER::Store(const char *name, UI_STORAGE *file, USHORT storeFlags)
- {
- file->Store(search.type);
- if (!FlagSet(storeFlags, S_SUB_LEVEL))
- file->ObjectSize(name, search);
- }
- #endif
-
-