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

CPen

Methods Index

Heritage
Description
Usage
Protected Data Members
CPen Attributes
Public Methods
Constructor, Destructor, and Initializer Methods
Helper Operators
State Methods

CPen


Heritage

Superclass: None

Subclasses: None


Description

The CPen class encapsulates XVT pens. Objects of this type describe a color pen for drawing lines, but not for filling in shapes with an interior (use a CBrush for that). Each window has its own current CPen. The CPen object describes the color, the pattern, the style, and the width of the pen.

The color is indicated by RGB values. XVT uses a 24-bit number to specify a color. The 24 bits are divided into three 8-bit values for the red, green, and blue components.

For your convenience, XVT provides symbols for the colors in Table 11. You can use other colors if you wish. However, if your target platform doesn't flexibly support color, XVT recommends that you use one of the predefined colors.

The pattern indicates the pen pattern, which has the allowable values shown in Table 12. The style indicates the style used by the pen, which has the predefined values shown in Table 13. The width is the width of the pen stroke in pixels.

Table 11. 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 12. Predefined XVT Portability Toolkit Pen Patterns
Pattern Symbol Description
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 a user to stretch a rectangle or other shape by moving the mouse. Drawing is always done with a mode of M_XOR.

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

See Also: For information on filling closed shapes, see CBrush. For information on drawing modes and other "environmental" attributes, see CEnvironment.


Usage

CPen aPen(COLOR_RED, PAT_SOLID, P_SOLID, 1);

CPEN anXVTPen = aPen;
xvt_dwin_set_cpen(itsXVTWindow, &anXVTPen);

xvt_dwin_set_back_color(itsXVTWindow, aPen.GetColor());

Protected Data Members

CPen Attributes

CPEN itsPen; The pen


Public Methods

Constructor, Destructor, and Initializer Methods

CPen();
CPen(COLOR theColor,
PAT_STYLE thePattern,
PEN_STYLE theStyle = P_SOLID,
short theWidth = 1);
CPen(CPEN thePen);
CPen(const CPen &theImage);
CPen & operator= (const CPen &thePen);
~CPen();

Helper Operators

operator CPEN () const;
CPen & operator= (CPEN thePen);

State Methods

void IPen(COLOR theColor,
PAT_STYLE thePattern,
PEN_STYLE theStyle = P_SOLID,
short theWidth = 1);
void SetColor(COLOR theColor);
void SetPattern(PAT_STYLE thePattern);
void SetStyle(PEN_STYLE theStyle);
void SetWidth(short theWidth);
COLOR GetColor(void) const;
PAT_STYLE GetPattern(void) const;
PEN_STYLE GetStyle(void) const;
short GetWidth(void) const;


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

support@xvt.com


Visit our online help desk for tech support

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