[Classes] [Prev] [Next] [Methods]

CEnvironment

Methods Index

Heritage
Description
Usage
Protected Data Members
Attributes
Monochrome Attributes
Statics
Public Methods
Constructor, Destructor, and Initializer Methods
Helper Operators
State Methods
Color Utility Methods
Methods For Colors in Controls
Font Methods
Pen Methods
Brush Methods
Miscellaneous Utilities
Color/Monochrome Methods
Other Utilities

CEnvironment


Heritage

Superclass: CNotifier

Subclasses: None


Description

CEnvironment is a utility class that contains environment information for objects in the XVT-Power++ class hierarchy, such as:

By default, a global environment object is shared by every displayable object in an XVT-Power++ application. An environment object can be attached at any level in XVT-Power++, all the way from the application object to the deepest subview. Because an environment propagates downward, many objects can share the same environment.

As shown in Tables 3 through 7, many of the environment settings take the XVT Portability Toolkit values. You are not limited to the colors listed in the color table. However, if your target platform doesn't flexibly support color, XVT recommends that you use one of the colors listed in Table 4.

Note: For more information on setting the background color for windows, see CWindow::SetBackgroundDrawing.

See Also: For more information on possible brushes, pens and fonts, see CBrush, CPen, and CFont in this manual. For more details on XVT Portability Toolkit predefined values, see the XVT Portability Toolkit Guide and XVT Portability Toolkit Reference.

Table 3. Common XVT Portability Toolkit Drawing Modes
Mode Description
M_COPY
Ignores what is on the screen and copies drawn pixels. All XVT Portability Toolkit implementations obey this rule at all times. Use only this mode when printing because some print drivers cannot handle any other method of transferring pixels to paper.
M_XOR
Temporarily shows something on the screen so that the screen can be restored by drawing the same shape again, rather than by updating the screen with what was there before. What was previously on the screen is probably irrelevant.

Table 4. Predefined XVT Portability Toolkit Color Variables
Color Symbol Color
#define COLOR_INVALID
Error return
#define COLOR_RED
Red
#define COLOR_GREEN
Green
#define COLOR_BLUE
Blue
#define COLOR_CYAN
Cyan
#define COLOR_MAGENTA
Magenta
#define COLOR_YELLOW
Yellow
#define COLOR_BLACK
Black
#define COLOR_DKGRAY
Dark Gray
#define COLOR_GRAY
Gray
#define COLOR_LTGRAY
Light Gray
#define COLOR_WHITE
White

Table 5. Predefined XVT Portability Toolkit Brush Patterns
Pattern Symbol Brush Pattern
PAT_SOLID
Solid fill
PAT_HOLLOW
Hollow
PAT_HORZ
Horizontal
PAT_VERT
Vertical
PAT_FDIAG
Forward diagonal
PAT_BDIAG
Backward diagonal
PAT_CROSS
Crisscross
PAT_DIAGCROSS
Diagonal crisscross

Table 6. Predefined XVT Portability Toolkit Pen Patterns
Pattern Symbol Pen Pattern
PAT_SOLID
A normal pen that draws a solid line in the specified width with the specified color.
PAT_HOLLOW
No pen at all; shapes with a brush do not have a border around them, and shapes with only a pen are not seen.
PAT_RUBBER
Used for rubberbanding; a grayish or dotted line that allows the user to stretch a rectangle or other shape by moving the mouse. Drawing is always done with a mode of M_XOR.

Table 7. Predefined XVT Portability Toolkit Pen Styles
Style Symbol Pen Style
P_SOLID
Solid line
P_DOT
Dotted line
P_DASH
Dashed line


Usage

A global environment object is automatically created as part of the G global variables of the CBoss class. In addition, you can create CEnvironment objects for other individual objects that should have different "environmental" attributes. The separate sections on each of the view classes in this manual demonstrate how each class uses environments.


Protected Data Members

Attributes

CFont itsFont; The font
CBrush itsBrush; The brush
CPen itsPen; The pen
DRAW_MODE itsDrawingMode; The drawing mode (see Table 3)
COLOR itsBackgroundColor; Color background
COLOR itsForegroundColor; Color foreground
short isTextOpaque Flag for drawing text with opaque background
static short itIsColor Flag to determine if in color or monochrome mode
COLOR itsBlendColor Native view blend color
COLOR itsBorderColor Border color
COLOR itsMonoBackgroundColor Background color used on monochrome execution
COLOR itsMonoBrushColor Brush color used on monochrome execution
COLOR itsMonoForegroundColor Foreground color used on monochrome execution
COLOR itsMonoPenColor Pen color used on monochrome execution
COLOR itsSelectColor Native view select color
COLOR itsTroughColor Native view trough color

Monochrome Attributes

COLOR itsMonoBackgroundColor; Background
COLOR itsMonoForegroundColor; Foreground
COLOR itsMonoBrushColor; The brush
COLOR itsMonoPenColor; The pen

Statics

static BOOLEAN itIsColor; Whether the display is color


Public Methods

Constructor, Destructor, and Initializer Methods

CEnvironment(
COLOR theBackground = COLOR_INVALID,
COLOR theForeground = COLOR_INVALID,
COLOR theBrushColor = COLOR_WHITE,
PAT_STYLEtheBrushPattern = PAT_SOLID,
COLOR thePenColor = COLOR_BLACK,
PAT_STYLE thePenPattern = PAT_SOLID,
short thePenWidth = 1,
const CFont& theFont = STDFont,
DRAW_MODE theDrawingMode = M_COPY
PEN_STYLE thePenStyle = P_SOLID
BOOLEAN theTextIsOpaque = FALSE,
COLOR theMonoBackground = COLOR_WHITE,
COLOR theMonoForeground = COLOR_BLACK,
COLOR theMonoBrushColor = COLOR_WHITE,
COLOR theMonoPenColor = COLOR_BLACK);
CEnvironment(const CFont &theFont,
const CBrush &theBrush,
const CPen &thePen,
DRAW_MODE theDrawingMode = M_COPY,
COLOR theBackground = COLOR_INVALID,
COLOR theForeground = COLOR_INVALID,
BOOLEAN theTextIsOpaque = FALSE,
COLOR theMonoBackground = COLOR_WHITE,
COLOR theMonoForeground = COLOR_BLACK,
COLOR theMonoBrushColor = COLOR_WHITE,
COLOR theMonoPenColor = COLOR_BLACK);
CEnvironment(DRAW_CTOOLS theTools);
CEnvironment(const CEnvironment &theEnv);
CEnvironment & operator= (const CEnvironment &theEnv);
virtual ~Environment(void);

Helper Operators

operator DRAW_CTOOLS () const;
int operator==(const CEnvironment &theEnv) const;
int operator!=(const CEnvironment &theEnv) const;

State Methods

BOOLEAN IEnvironment(
COLOR theBackground = COLOR_INVALID,
COLOR theForeground = COLOR_INVALID,
COLOR theBrushColor = COLOR_WHITE,
PAT_STYLE theBrushPattern = PAT_SOLID,
COLOR thePenColor = COLOR_BLACK,
PAT_STYLE thePenPattern = PAT_SOLID,
short thePenWidth = 1,
const CFont& theFont = STDFont,
DRAW_MODE theDrawingMode = M_COPY
PEN_STYLE thePenStyle = P_SOLID
BOOLEAN theTextIsOpaque = FALSE,
COLOR theMonoBackground = COLOR_WHITE,
COLOR theMonoForeground = COLOR_BLACK,
COLOR theMonoBrushColor = COLOR_WHITE,
COLOR theMonoPenColor = COLOR_BLACK);
BOOLEAN IEnvironment(
const CFont &theFont,
const CBrush &theBrush,
const CPen &thePen,
DRAW_MODE theDrawingMode = M_COPY,
COLOR theBackground = COLOR_INVALID,
COLOR theForeground = COLOR_INVALID,
BOOLEAN theTextIsOpaque = FALSE,
COLOR theMonoBackground = COLOR_WHITE,
COLOR theMonoForeground = COLOR_BLACK,
COLOR theMonoBrushColor = COLOR_WHITE,
COLOR theMonoPenColor = COLOR_BLACK);

Color Utility Methods

virtual void SetColor(
COLOR theBackground = COLOR_INVALID,
COLOR theForeground = COLOR_INVALID,
COLOR theBrushColor = COLOR_WHITE,
COLOR thePenColor = COLOR_BLACK,
COLOR theMonoBackground = COLOR_WHITE,
COLOR theMonoForeground = COLOR_BLACK,
COLOR theMonoBrushColor = COLOR_WHITE,
COLOR theMonoPenColor = COLOR_BLACK);
virtual void SetBackgroundColor(COLOR theColor,
COLOR theMonoColor = COLOR_WHITE);
void SetForegroundColor(COLOR theColor,
COLOR theMonoColor = COLOR_BLACK);

Methods For Colors in Controls

The following methods support the use of fonts and colors in controls. For additional information, see the "Controls" chapter of the XVT Portability Toolkit Guide.

virtual void SetBlendColor(COLOR theColor);
virtual void SetBorderColor(COLOR theColor);
virtual void SetHighlightColor(COLOR theColor);
virtual void SetSelectColor(COLOR theColor);
virtual void SetTroughColor(COLOR theColor);
COLOR GetBlendColor(void) const;
COLOR GetBorderColor(void) const;
COLOR GetHighlightColor(void) const;
COLOR GetSelectColor(void) const;
COLOR GetTroughColor(void) const;
COLOR GetForegroundColor(void) const;
COLOR GetBackgroundColor(void) const;
virtual void SetNativeViewEnv(const CNativeView& theNativeView) const;
virtual void INativeViewColors(WIN_TYPE theType);
virtual void SetFont(const CFont &theFont);
const CFont & GetFont(void) const;
For more information on XVT fonts, see CFont.

Pen Methods

A pen is used to draw lines. The following methods allow you to set and get the pen properties of an object. For more information on XVT pens, see CPen.

virtual void SetPen(const CPen &thePen);
virtual void SetPen(COLOR theColor,
short thePenWidth,
PAT_STYLE thePenPattern
PEN_STYLE thePenStyle = P_SOLID);
virtual void SetPenPattern(PAT_STYLE thePenPattern);
virtual void SetPenStyle(PEN_STYLE thePenStyle);
virtual void SetPenWidth(short thePenWidth);
virtual void SetPenColor(COLOR theColor, 
COLOR theMonoColor = COLOR_BLACK);
const CPen & GetPen(void) const;
PAT_STYLE GetPenPattern(void) const;
PEN_STYLE GetPenStyle(void) const;
short GetPenWidth(void) const;
COLOR GetPenColor(void) const;

Brush Methods

The "brush" is the interior fill of closed shapes. The possible brush patterns are shown in Table 5. The open spaces of a pattern are drawn in the object's background color. For more information on XVT brushes, see CBrush.

virtual void SetBrush(const CBrush &theBrush);
virtual void SetBrush(COLOR theColor, 
PAT_STYLE theBrushPattern);
virtual void SetBrushPattern(
PAT_STYLE theBrushPattern);
virtual void SetBrushColor(COLOR theColor, 
COLOR theMonoColor = COLOR_WHITE);
const CBrush & GetBrush(void) const;
PAT_STYLE GetBrushPattern(void) const;
COLOR GetBrushColor(void) const;

Miscellaneous Utilities

virtual void SetDrawingMode(DRAW_MODE theDrawMode);
virtual void SetTextOpaque(BOOLEAN theTextIsOpaque);
DRAW_MODE GetDrawingMode(void) const;
BOOLEAN IsTextOpaque(void) const;

Color/Monochrome Methods

The environment class provides a coding facility that will allow you to map colors correctly between monochrome and color monitors. The following methods return the current mode (color or monochrome) and change the mode. Notice that these are static methods, and thus they affect all environment objects. You cannot combine monochrome and color environments within one application.

virtual void SetColorOn(BOOLEAN isColorOn);
BOOLEAN IsColorOn(void) const;

Other Utilities

void SetDrawingEnv(const CWindow& theWindow) const;
void InvertColors(void);


[Classes] [Prev] [Next] [Methods]

support@xvt.com


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.