home *** CD-ROM | disk | FTP | other *** search
- // Zinc Interface Library - UI_DSP.HPP
- // COPYRIGHT (C) 1990, 1991. All Rights Reserved.
- // Zinc Software Incorporated. Pleasant Grove, Utah USA
-
- #ifndef UI_DSP_HPP
- #define UI_DSP_HPP
- #ifndef UI_GEN_HPP
- #include <ui_gen.hpp>
- #endif
-
- #ifdef ZIL_MSWINDOWS // ---------------------------------------------------
-
- // ----- MS Windows specific definitions ----------------------------------
-
- // ----- UI_PALETTE -------------------------------------------------------
-
- // --- hatchStyle (defined in windows.h). ---
- const int HS_NONE = -1;
- // HS_CROSS +++++
- // HS_DIAGCROSS xxxxx
- // HS_HORIZONTAL -----
- // HS_VERTICAL |||||
- // HS_FDIAGONAL \\\\\
- // HS_BDIAGONAL /////
-
- // --- foregroundColor, backgroundColor (Use system color or RGB form) ---
- // System colors (defined in windows.h).
- // COLOR_ACTIVEBORDER
- // COLOR_ACTIVECAPTION
- // COLOR_APPWORKSPACE
- // COLOR_BACKGROUND
- // COLOR_BTNFACE
- // COLOR_BTNSHADOW
- // COLOR_BTNTEXT
- // COLOR_CAPTIONTEXT
- // COLOR_GRAYTEXT
- // COLOR_HIGHLIGHT
- // COLOR_HIGHLIGHTTEXT
- // COLOR_INACTIVEBORDER
- // COLOR_INACTIVECAPTION
- // COLOR_MENU
- // COLOR_MENUTEXT
- // COLOR_SCROLLBAR
- // COLOR_WINDOW
- // COLOR_WINDOWFRAME
- // COLOR_WINDOWTEXT
-
- // Definitions of basic 16 colors for MS Windows.
- // This is in the RGB form 0x80bbggrr where bb is a value 0-255 with 255 (FFh)
- // being pure dark blue. The gg and rr represent green and red.
- const DWORD BLACK = 0x80000000L; // Dark colors.
- const DWORD BLUE = 0x80800000L;
- const DWORD GREEN = 0x80008000L;
- const DWORD CYAN = 0x80808000L;
- const DWORD RED = 0x80000080L;
- const DWORD MAGENTA = 0x80800080L;
- const DWORD BROWN = 0x80008080L;
- const DWORD LIGHTGRAY = 0x80C0C0C0L;
- const DWORD DARKGRAY = 0x80808080L; // Light colors.
- const DWORD LIGHTBLUE = 0x80FF0000L;
- const DWORD LIGHTGREEN = 0x8000FF00L;
- const DWORD LIGHTCYAN = 0x80FFFF00L;
- const DWORD LIGHTRED = 0x800000FFL;
- const DWORD LIGHTMAGENTA = 0x80FF00FFL;
- const DWORD YELLOW = 0x8000FFFFL;
- const DWORD WHITE = 0x80FFFFFFL;
-
- struct EXPORT UI_PALETTE
- {
- int hatchStyle; // Hatch style (HS_NONE for no hatch).
- DWORD colorForeground; // Foreground EGA/VGA colors.
- DWORD colorBackground; // Background EGA/VGA colors.
- };
-
- typedef HWND SCREENID;
-
- #else // Not MS Windows ----------------------------------------------------
-
- // ----- DOS text and graphics specific definitions ------------------------
-
- // ----- UI_PALETTE ---------------------------------------------------------
-
- // --- palette macro ---
- #define attrib(foreground, background) (((background) << 4) + (foreground))
-
- // --- monoAttribute ---
- #define MONO_BLACK 0x00
- #define MONO_DIM 0x08
- #define MONO_NORMAL 0x07
- #define MONO_HIGH 0x0F
-
- // --- bwColor ---
- #define BW_BLACK 0x00
- #define BW_WHITE 0x01
-
- // --- grayScaleColor ---
- #define GS_BLACK 0x00
- #define GS_GRAY 0x01
- #define GS_BLINKING 0x02
- #define GS_WHITE 0x03
-
- struct UI_PALETTE
- {
- // Fields described in UI_PALETTE reference chapter.
- // --- Text mode ---
- UCHAR fillCharacter; // Fill character.
- UCHAR colorAttribute; // Color attribute.
- UCHAR monoAttribute; // Mono attribute.
-
- // --- Graphics mode ---
- UCHAR fillPattern; // Fill pattern.
- UCHAR colorForeground; // EGA/VGA colors.
- UCHAR colorBackground;
- UCHAR bwForeground; // Black & White colors (2 color).
- UCHAR bwBackground;
- UCHAR grayScaleForeground; // Monochrome colors (3+ color).
- UCHAR grayScaleBackground;
- };
-
- typedef int SCREENID;
-
- #endif // ZIL_MSWINDOWS --------------------------------------------------------
-
- extern UI_PALETTE *_backgroundPalette;
- extern UI_PALETTE *_xorPalette;
-
- // ----- UI_REGION_ELEMENT & UI_REGION_LIST ---------------------------------
- // ----- member functions found in DISPLAY.CPP ------------------------------
-
- class EXPORT UI_REGION_ELEMENT : public UI_ELEMENT
- {
- public:
- // Members described in UI_REGION_ELEMENT reference chapter.
- SCREENID screenID;
- UI_REGION region;
-
- UI_REGION_ELEMENT(SCREENID _screenID, const UI_REGION *_region) :
- screenID(_screenID), region(*_region) { }
- UI_REGION_ELEMENT(SCREENID _screenID, int left, int top, int right,
- int bottom) : screenID(_screenID) { region.left = left,
- region.top = top, region.right = right, region.bottom = bottom; }
- int Encompassed(const UI_REGION &sRegion)
- { return(region.left >= sRegion.left && region.top >= sRegion.top &&
- region.right <= sRegion.right && region.bottom <= sRegion.bottom); }
- int Overlap(const UI_POSITION &position)
- { return(position.column >= region.left &&
- position.column <= region.right && position.line >= region.top &&
- position.line <= region.bottom); }
- int Overlap(const UI_REGION &a_region);
- int Overlap(const UI_REGION &s_region, UI_REGION &t_region);
-
- // Members described in UI_LIST reference chapter.
- UI_REGION_ELEMENT *Next(void) { return((UI_REGION_ELEMENT *)next); }
- UI_REGION_ELEMENT *Previous(void) { return((UI_REGION_ELEMENT *)previous); }
- };
-
- class EXPORT UI_REGION_LIST : public UI_LIST
- {
- public:
- // Members described in UI_REGION_LIST reference chapter.
- void Split(SCREENID screenID, const UI_REGION ®ion);
-
- // Members described in UI_LIST reference chapter.
- UI_REGION_ELEMENT *First(void) { return((UI_REGION_ELEMENT *)first); }
- UI_REGION_ELEMENT *Last(void) { return((UI_REGION_ELEMENT *)last); }
- };
-
- // ----- UI_DISPLAY ---------------------------------------------------------
- // ----- member functions found in DISPLAY.CPP ------------------------------
-
- // --- Definition of screen identification ---
- const int ID_SCREEN = 0; // special value-see ui_map.hpp
-
- enum DISPLAY_CODE
- {
- DC_NO_DISPLAY = 0x00,
- DC_MONOCHROME = 0x01,
- DC_CGA = 0x02,
- DC_EGA_COLOR = 0x04,
- DC_EGA_MONO = 0x05,
- DC_PGA_COLOR = 0x06,
- DC_PS2_ANALOG_MONO = 0x07,
- DC_PS2_ANALOG_COLOR = 0x08,
- DC_M30_ANALOG_MONO = 0x0B,
- DC_M30_ANALOG_COLOR = 0x0C,
- DC_UNKNOWN = -1
- };
-
- extern class EXPORT UI_EVENT_MANAGER;
- class EXPORT UI_DISPLAY : public UI_REGION_LIST
- {
- public:
- // Members described in UI_DISPLAY reference chapter.
- int installed;
- const int isText;
- const int cellWidth;
- const int cellHeight;
- int columns;
- int lines;
- USHORT onCursorValue;
- USHORT offCursorValue;
- UI_EVENT_MANAGER *eventManager;
-
- virtual ~UI_DISPLAY(void);
- virtual void Bitmap(SCREENID screenID, int column, int line,
- int bitmapWidth, int bitmapHeight, const UCHAR *bitmapArray,
- const UI_PALETTE *palette = NULL, const UI_REGION *clipRegion = NULL) = 0;
- virtual void Ellipse(SCREENID screenID, int column, int line,
- int startAngle, int endAngle, int xRadius, int yRadius,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL) = 0;
- virtual void Line(SCREENID screenID, int column1, int line1, int column2,
- int line2, const UI_PALETTE *palette, int width = 1, int xor = FALSE,
- const UI_REGION *clipRegion = NULL) = 0;
- virtual void Polygon(SCREENID screenID, int numPoints, const int *polygonPoints,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL) = 0;
- virtual void Rectangle(SCREENID screenID, const UI_REGION ®ion,
- const UI_PALETTE *palette, int width = 1, int fill = FALSE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL)
- { Rectangle(screenID, region.left, region.top, region.right,
- region.bottom, palette, width, fill, xor, clipRegion); }
- virtual void Rectangle(SCREENID screenID, int left, int top, int right,
- int bottom, const UI_PALETTE *palette, int width = 1, int fill = FALSE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL) = 0;
- virtual void RectangleXORDiff(const UI_REGION &oldRegion, const UI_REGION &newRegion) = 0;
- virtual void RegionConvert(UI_REGION ®ion, USHORT *oldFlags, USHORT newFlags) = 0;
- virtual void RegionDefine(SCREENID screenID, const UI_REGION ®ion)
- { RegionDefine(screenID, region.left, region.top, region.right, region.bottom); }
- virtual void RegionDefine(SCREENID screenID, int left, int top, int right, int bottom);
- virtual void RegionMove(const UI_REGION &oldRegion, int newColumn, int newLine,
- SCREENID oldScreenID = ID_SCREEN, SCREENID newScreenID = ID_SCREEN) = 0;
- virtual void Text(SCREENID screenID, int left, int top, const char *text,
- const UI_PALETTE *palette, int length = -1, int fill = TRUE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL) = 0;
- virtual int TextHeight(const char *string, SCREENID screenID = ID_SCREEN) = 0;
- virtual int TextWidth(const char *string, SCREENID screenID = ID_SCREEN) = 0;
-
- protected:
- // Members described in UI_DISPLAY reference chapter.
- UI_DISPLAY(int isText, int cellWidth, int cellHeight);
- };
-
- #ifdef ZIL_MSWINDOWS // ---------------------------------------------------
-
- // ----- UI_MSWINDOWS_DISPLAY ---------------------------------------------
- // ----- member functions found in WINDSP.CPP -----------------------------
-
- class EXPORT UI_MSWINDOWS_DISPLAY : public UI_DISPLAY
- {
- public:
- // Members described in UI_MSWINDOWS_DISPLAY reference chapter.
- HANDLE hInstance;
- HANDLE hPrevInstance;
- int nCmdShow;
-
- UI_MSWINDOWS_DISPLAY(HANDLE hInstance, HANDLE hPrevInstance, int nCmdShow);
- virtual ~UI_MSWINDOWS_DISPLAY(void);
-
- virtual void Bitmap(SCREENID screenID, int column, int line,
- int bitmapWidth, int bitmapHeight, const UCHAR *bitmapArray,
- const UI_PALETTE *palette = NULL, const UI_REGION *clipRegion = NULL);
- virtual void Ellipse(SCREENID screenID, int column, int line,
- int startAngle, int endAngle, int xRadius, int yRadius,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Line(SCREENID screenID, int column1, int line1, int column2,
- int line2, const UI_PALETTE *palette, int width = 1, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Polygon(SCREENID screenID, int numPoints, const int *polygonPoints,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Rectangle(SCREENID screenID, int left, int top, int right,
- int bottom, const UI_PALETTE *palette, int width = 1, int fill = FALSE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL);
- virtual void RectangleXORDiff(const UI_REGION &oldRegion, const UI_REGION &newRegion);
- virtual void RegionConvert(UI_REGION ®ion, USHORT *oldFlags, USHORT newFlags);
- virtual void RegionMove(const UI_REGION &oldRegion, int newColumn, int newLine,
- SCREENID oldScreenID = ID_SCREEN, SCREENID newScreenID = ID_SCREEN);
- virtual void Text(SCREENID screenID, int left, int top, const char *text,
- const UI_PALETTE *palette, int length = -1, int fill = TRUE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL);
- virtual int TextHeight(const char *string, SCREENID screenID = 0);
- virtual int TextWidth(const char *string, SCREENID screenID = 0);
- };
-
- #else // Not MS Windows ----------------------------------------------------
-
- // ----- UI_DOS_BGI_DISPLAY -------------------------------------------------
- // ----- member functions found in BGIDSP.CPP -------------------------------
-
- class UI_DOS_BGI_DISPLAY : public UI_DISPLAY
- {
- public:
- // Members described in UI_DOS_BGI_DISPLAY reference chapter.
- UI_DOS_BGI_DISPLAY(int driver = 0, int mode = 0);
- virtual ~UI_DOS_BGI_DISPLAY(void);
- virtual void Bitmap(SCREENID screenID, int column, int line,
- int bitmapWidth, int bitmapHeight, const UCHAR *bitmapArray,
- const UI_PALETTE *palette = NULL, const UI_REGION *clipRegion = NULL);
- virtual void Ellipse(SCREENID screenID, int column, int line,
- int startAngle, int endAngle, int xRadius, int yRadius,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Line(SCREENID screenID, int column1, int line1, int column2,
- int line2, const UI_PALETTE *palette, int width = 1, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Polygon(SCREENID screenID, int numPoints, const int *polygonPoints,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Rectangle(SCREENID screenID, int left, int top, int right,
- int bottom, const UI_PALETTE *palette, int width = 1, int fill = FALSE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL);
- virtual void RectangleXORDiff(const UI_REGION &oldRegion, const UI_REGION &newRegion);
- virtual void RegionConvert(UI_REGION ®ion, USHORT *oldFlags, USHORT newFlags);
- virtual void RegionMove(const UI_REGION &oldRegion, int newColumn, int newLine,
- SCREENID oldScreenID = ID_SCREEN, SCREENID newScreenID = ID_SCREEN);
- virtual void Text(SCREENID screenID, int left, int top, const char *text,
- const UI_PALETTE *palette, int length = -1, int fill = TRUE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL);
- virtual int TextHeight(const char *string, SCREENID screenID = 0);
- virtual int TextWidth(const char *string, SCREENID screenID = 0);
-
- protected:
- // Members described in UI_DOS_BGI_DISPLAY reference chapter.
- int maxColor;
-
- int MapColor(const UI_PALETTE *palette, int isForeground);
- };
-
- // ----- UI_DOS_FLASH_DISPLAY -----------------------------------------------
- // ----- member functions found in FLSHDSP.CPP ------------------------------
-
- class UI_DOS_FLASH_DISPLAY : public UI_DISPLAY
- {
- public:
- // Members described in UI_DOS_FLASH_DISPLAY reference chapter.
- UI_DOS_FLASH_DISPLAY(void);
- virtual ~UI_DOS_FLASH_DISPLAY(void);
- virtual void Bitmap(SCREENID screenID, int column, int line,
- int bitmapWidth, int bitmapHeight, const UCHAR *bitmapArray,
- const UI_PALETTE *palette = NULL, const UI_REGION *clipRegion = NULL);
- virtual void Ellipse(SCREENID screenID, int column, int line,
- int startAngle, int endAngle, int xRadius, int yRadius,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Line(SCREENID screenID, int column1, int line1, int column2,
- int line2, const UI_PALETTE *palette, int width = 1, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Polygon(SCREENID screenID, int numPoints, const int *polygonPoints,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Rectangle(SCREENID screenID, int left, int top, int right,
- int bottom, const UI_PALETTE *palette, int width = 1, int fill = FALSE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL);
- virtual void RectangleXORDiff(const UI_REGION &oldRegion, const UI_REGION &newRegion);
- virtual void RegionConvert(UI_REGION ®ion, USHORT *oldFlags, USHORT newFlags);
- virtual void RegionMove(const UI_REGION &oldRegion, int newColumn, int newLine,
- SCREENID oldScreenID = ID_SCREEN, SCREENID newScreenID = ID_SCREEN);
- virtual void Text(SCREENID screenID, int left, int top, const char *text,
- const UI_PALETTE *palette, int length = -1, int fill = TRUE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL);
- virtual int TextHeight(const char *string, SCREENID screenID = 0);
- virtual int TextWidth(const char *string, SCREENID screenID = 0);
-
- protected:
- // Members described in UI_DOS_FLASH_DISPLAY reference chapter.
- int maxColor;
-
- int MapColor(const UI_PALETTE *palette, int isForeground);
- };
-
- // ----- UI_DOS_TEXT_DISPLAY ------------------------------------------------
- // ----- member functions found in TEXTDSP.CPP ------------------------------
-
- #define TDM_AUTO -1
- #define TDM_25x40 1
- #define TDM_25x80 3
- #define TDM_43x80 64
- #define TDM_MONO_25x80 7
- #define TDM_NONE 0xFFFF
-
- class UI_DOS_TEXT_DISPLAY : public UI_DISPLAY
- {
- public:
- // Members described in UI_DOS_TEXT_DISPLAY reference chapter.
- static int forceMono;
- int isMono;
-
- UI_DOS_TEXT_DISPLAY(int mode = TDM_AUTO);
- virtual ~UI_DOS_TEXT_DISPLAY(void);
- virtual void Bitmap(SCREENID screenID, int column, int line,
- int bitmapWidth, int bitmapHeight, const UCHAR *bitmapArray,
- const UI_PALETTE *palette = NULL, const UI_REGION *clipRegion = NULL);
- virtual void Ellipse(SCREENID screenID, int column, int line,
- int startAngle, int endAngle, int xRadius, int yRadius,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Line(SCREENID screenID, int column1, int line1, int column2,
- int line2, const UI_PALETTE *palette, int width = 1, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Polygon(SCREENID screenID, int numPoints, const int *polygonPoints,
- const UI_PALETTE *palette, int fill = FALSE, int xor = FALSE,
- const UI_REGION *clipRegion = NULL);
- virtual void Rectangle(SCREENID screenID, int left, int top, int right,
- int bottom, const UI_PALETTE *palette, int width = 1, int fill = FALSE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL);
- virtual void RectangleXORDiff(const UI_REGION &oldRegion, const UI_REGION &newRegion);
- virtual void RegionConvert(UI_REGION ®ion, USHORT *oldFlags, USHORT newFlags);
- virtual void RegionMove(const UI_REGION &oldRegion, int newColumn, int newLine,
- SCREENID oldScreenID = ID_SCREEN, SCREENID newScreenID = ID_SCREEN);
- virtual void Text(SCREENID screenID, int left, int top, const char *text,
- const UI_PALETTE *palette, int length = -1, int fill = TRUE,
- int xor = FALSE, const UI_REGION *clipRegion = NULL);
- virtual int TextHeight(const char *string, SCREENID screenID = 0);
- virtual int TextWidth(const char *string, SCREENID screenID = 0);
-
- private:
- // Private UI_DISPLAY members are not described.
- USHORT originalCursorValue;
- UCHAR originalCursorEmulationBit;
- UCHAR videoMode;
- UCHAR retraceWait;
- UCHAR desqview;
- UCHAR topview;
- USHORT segment;
- USHORT offset;
- UCHAR blinkState;
- static UCHAR displayCode;
- static UCHAR oldVideoMode;
- void DrawText(const UI_PALETTE *palette, int column, int line,
- const char *text, int length);
- void Fill(SCREENID screenID, const UI_REGION ®ion,
- const UI_PALETTE *palette);
- void FillLine(int column, int line, int noOfCharacters,
- const UI_PALETTE *palette);
- void FillXOR(const UI_REGION ®ion);
- void RectangleOnly(SCREENID screenID, const UI_REGION ®ion,
- const UI_PALETTE *palette, int width);
- void RectangleXOR(const UI_REGION ®ion);
- void SetBlink(int enableBlink);
- void TextXOR(int left, int top, int length);
- void XorAttribute(int column, int line, int swapNibbles = FALSE);
- };
-
- #endif // ZIL_MSWINDOWS
-
- #ifndef UI_EVT_HPP
- #include <ui_evt.hpp>
- #endif
- #endif // UI_DSP_HPP
-