PEG API Reference Manual
PEG API Reference Manual
Rev. 5
Feb. 2014
1
Copyright 2007–2008, 2011
Swell Software, LLC. All rights reserved.
2
Table of Contents
Forward ii
i
FORWARD
We at Swell Software thank you for choosing PEG!
PEG is by far the most used, best supported, and most adaptable graphical
interface software available. Our industry-leading real-time operating
system support, hardware integration, and development tool compatibility
allow complete flexibility as you and your team create next-generation
products.
The PEG library and development tools have today been used to create
several thousand unique products, and those products have shipped many
hundreds of millions of units. The applications utilizing PEG software cover
a broad spectrum including various consumer electronics, medical
instrumentation, video games, military communications, aeronautics, office
equipment, and even desktop applications.
ii
Forward
The Quickstart Guide is a short tutorial enabling you to easily begin working
with WindowBuilder and to create and run your own application in one of
our supported desktop environments.
This programming manual provides an ‘under the hood’ view of the PEG
software library internals and introduces basic concepts that are needed to
fully understand how PEG works. This is followed by descriptions of the
fundamental PEG classes.
Each of these manuals are provided in both printed and electronic (PDF)
formats. The PDF format manuals are always the most recent manual
updates, while for practical reason the printed manuals can sometimes be a
few months out of date.
Whenever the electronic manuals are updated, they are posted to the Swell
Software website. The online manuals can be found at the following
address:
http://www.swellsoftware.com/download/documentation.php.
What PEG IS
PEG is an acronym for Portable Embedded GUI. We chose this name
because we believe it accurately reflects the design and motivation that
went into the creation of our software.
PEG is Portable
We have designed our software to be portable to any target hardware that
is capable of graphical output. PEG does not expect or require any
underlying software components in order to do its job. If you have a C++
compiler and hardware capable of graphical output, you can run PEG.
PEG is GUI
The PEG class library provides the building blocks for a powerful and
extensible graphical user interface. Extensive thought and research have
gone into the design of our product to ensure that you are receiving a library
that is fully capable of supporting all of the advanced GUI features you
need today, while also accommodating future enhancements.
In addition to the class library, PEG provides tools for generating graphical
fonts, processing, optimizing, and compressing graphical images,
designing screens and child controls, creating custom colors, and
maintaining multi-lingual string data.
PEG is not an application program. The PEG library, by itself, will provide
an end user with absolutely zero in terms of useful interaction or information
display. It is your job to create the windows, dialogs, and other objects that
will be used to retrieve input from and display information to the end
user. Of course, the whole point of using PEG is that our library provides
the tools and components that make creating your application level
interface a manageable task.
PegMessageQueue
PegPresentationManager
PegResourceManager
PegScreen
PegTextThing
PegThing
PegTimerManager
1.1 PegMessageQueue
1.1.1 Overview
PegMessageQueue is a simple encapsulated FIFO message queue with
member functions for queue management. PegMessageQueue provides
functions for sending and receiving PegMessage formatted messages.
PegMessageQueue also performs timer maintenance and miscellaneous
housekeeping duties.
PEG messages can be divided into two types. PEG system messages,
Which are generated internally by PEG to control and manipulate PEG
objects, and USER messages, which are defined and used by your
application program. Whether a message is a system message or a user
message is determined by the value of the message Type field. This is a
16-bit unsigned value. PEG reserves message Type values 1-
FIRST_USER_MESSAGE - 1, which is currently equal to 0x4000. Message
Type values which are greater than FIRST_SIGNAL (0x8000) are used for
signals, which will be defined later. This leaves message types 16384
(0x4000) through 32767 (0x8000) available for user definition.
Message Description
PM_ADD This message can be issued to add an object to
another object. The message pTarget field should
contain a pointer to the parent object, and the
message pSource filed should contain a pointer to
the child object.
PM_ADDICON System message sent from a window to its parent
to add an icon for a minimized window.
Message Description
PM_BEGIN_MOVE System message sent from a title bar to its parent
window to begin moving the window. This message
can be sent by any child object to force the parent
window into ‘move mode.’
PM_CLOSE Recognized by PegWindow derived objects, and
causes the recipient to remove itself from its parent
and delete itself from memory.
PM_CLOSE_SIBLINGS
PM_COPY Sent by keyboard drivers to command a text copy
operation.
PM_CURRENT This message is sent to an object when it becomes
a member of the branch of the presentation tree
which has input focus.
PM_CUT Sent by keyboard drivers to command a text cut
operation.
PM_DESTROY This message is sent to PegPresentationManager
to destroy an object. The pSource member of the
message should point to the object to be destroyed.
PM_DIALOG_APPLY
PM_DIALOG_NOTIFY This message is sent to the owner of a PegDialog
when the dialog window is closed if the dialog
window is executed non-modally. The message
Param member will contain the ID of the button
used to close the dialog window.
PM_DRAW This message can be sent to an object to force that
object to redraw itself.
PM_EXIT This message is sent to PegPresentationManager
to cause termination of the application program.
PM_GAINED_KEYBOARD This message is sent to an object when it gains
keyboard input focus. This message is only defined
when PEG_KEYBOARD_SUPPORT is enabled.
PM_HIDE This message is sent to an object whenever it is
removed from a visible parent.
PM_HSCROLL This message is sent from a non-client scroll bar to
its parent window to effect scrolling of the window.
PM_KEY This message is sent to the current input object
when keyboard input is received. The message
Param member contains the corresponding ASCII
character code, if any, and the ExtParams[0]
member of the message contains the keyboard
scan code, if available.
PM_KEY_RELEASE This message is sent to the current input object
when keyboard input, indicating a key release, is
received. The message Param member contains
the corresponding ASCII character code, if any, and
the ExtParams[0] member of the message
contains the keyboard scan code, if available.
Message Description
PM_LANGUAGE_CHANGE This message is sent to all objects when the current
language changes. It informs the objects that they
need to update their text from the string table.
PM_LBUTTONDOWN This message is sent to an object when the user
generates mouse click input.
PegPresentationManager routes mouse input
directly to the lowest child object containing the
click position. If the child object does not process
mouse input, the message is passed up to the
parent object. This process continues until an
object in the active tree processes the message, or
the message ends up back at
PegPresentationManager. The position of the
mouse click is included in the message Point field.
PM_LBUTTONUP This message is sent to an object when the user
releases the left mouse button. The flow of this
message is identical to PM_LBUTTONDOWN.
PM_LOST_KEYBOARD This message is sent to an object when it loses
keyboard input focus. This message is only defined
when PEG_KEYBOARD_SUPPORT is enabled.
PM_MAXIMIZE This message can be sent to any PegWindow
derived object. If the target window is sizeable (as
determined by the PSF_SIZEABLE status flag), it
will resize itself to fill client rectangle of its parent.
PM_MINIMIZE Similar to PM_MAXIMIZE, this message can be sent
to any PegWindow derived object. If the window is
sizable, it will create a proxy PegIcon, add the icon
to the parent window, and remove itself from its
parent.
PM_MOVE_FOCUS This message is sent by PegPresentationManager
to itself when the top-level window which has input
focus is closed.
PM_MWCOMPLETE This message is sent to the owner of a
PegMessageWindow when the message window is
closed if the message window is executed non-
modally. The message Param member will contain
the ID of the button used to close the message
window.
PM_NONCURRENT This message is sent to an object when it loses
membership in the branch of the presentation tree
which has input focus.
PM_PARENTSIZED This message is sent to all children of a
PegWindow derived object if the window is resized.
This makes it very easy for child windows that want
to maintain a certain proportional spacing or
position within their parent to catch this message
and resize themselves whenever the parent window
is sized.
Message Description
PM_PASTE Sent by keyboard drivers to command a text paste
operation.
PM_POINTER_ENTER This message is sent to an object when the mouse
pointer (if any) passes over an object.
PM_POINTER_EXIT This message is sent to an object when the mouse
pointer (if any) leaves the object.
PM_POINTER_MOVE This message is sent to an object whenever the
mouse pointer moves over the object.
PM_SHOW This message is sent to an object when it is added
to a visible parent, before the object is first drawn.
This allows an object to perform any necessary
initialization prior to drawing itself on the screen.
PM_SIZE This message is sent to an object to resize it. This
is equivalent to calling the Resize() function. Note
that PEG does not differentiate between moving an
object and resizing an object. Both are
accomplished via the Resize operation. The new
size for the object is included in the message Rect
field.
PM_MOVE This is an obsolete message, replaced by
PM_SIZE.
PM_RESTORE This message can be sent to any sizable
PegWindow derived object to cause that window to
restore its size and position after it has been
maximized or minimized.
PM_RBUTTONDOWN This message is sent in systems that support right
mouse button input. PEG objects do not process
right mouse button messages.
PM_RBUTTONUP This message is sent in systems that support right
mouse button input. PEG objects do not process
right mouse button messages.
PM_REMOVETHING This message can be sent from one object to
another to remove the sending object from the
display. This is an indirect method of calling the
Remove() function, and can be useful if the target
object needs to know that the sender is being
removed.
PM_SLIDER_DRAG This message is sent from the slider button on a
PegSlider control to the PegSlider when the slider
button is operated by the user.
PM_VSCROLL This message is sent from a non-client scroll bar to
its parent window to effect scrolling of the window.
PM_TIMER This message is sent to an object that has started a
timer via the PegMessageQueue SetTimer
function when that timer expires. The ID of the timer
is included in the Param member of the message.
PegTimer
1.1.4 Derivation
PegMessageQueue is a PEG base class.
1.1.5 Constructors:
PegMessageQueue(void)
This is the only PegMessageQueue constructor. One instance of
PegMessageQueue is created during program startup, usually in PegTask.
This queue instance is referenced by all PEG objects.
PEGBOOL IsEmpty(void)
This returns TRUE if there are no messages waiting in the queue. If there
are messages in the queue it returns FALSE.
PEGBOOL Push(PegMessage *)
1.1.7 Examples:
The following example creates and sends a new PegMessage. The
message will cause the target object to resize.
The following example window creates a periodic timer when the window is
made visible, receives periodic timer messages, and destroys the timer
when the window is hidden:
case PM_HIDE:
KillTimer(TIMER_1
);
Swell Software, LLC Base Classes 7
Base Classes
PegWindow::Message(Mesg);
break;
default:
return PegWindow::Message(Mesg);
}
return 0;
1.2 PegPresentationManager
1.2.1 Overview
PegPresentationManager is a transparent background window that can be
thought of as the desktop window for all PEG applications.
PegPresentationManager keeps track of all of the windows and sub-objects
present on the display device. In addition, PegPresentationManager keeps
track of which object has the input focus (i.e. which object should receive
user input such as keyboard input), and which objects are on top of other
objects.
PegWindow
1.2.3 Derivation
PegPresentationManager derives from PegWindow.
1.2.4 Constructors:
PegPresentationManager(PegRect &Size)
This constructor determines the size in pixels of the PresentationManager
window. This determines the outer limits of all of your child windows and
controls. PegPresentationManager is normally sized to equal the pixel
dimensions of the display device.
void ClearScratchPad(void)
This function resets the PresentationManager scratchpad buffer, and frees
the associated memory.
PegThing *FindLowestThingContaining(PegThing
*pStart, PegPoint Where)
This function determines the lowest child object that contains the point
Where. The object must be enabled and selectable. A pointer to the child
object is returned.
PEG_QUEUE_TYPE GetCurrentMessageQueue(void)
This function returns the pointer to the current task’s PegMessageQueue.
PegThing *GetCurrentThing(void)
This function returns a pointer to the leaf object that has input focus. This
function will return NULL if no object has received focus.
PegThing *GetPointerOwner(void)
This function returns a pointer to the object that has currently captured the
pointer.
PegTaskInfo *GetTaskInfo(void)
This returns a pointer to the current PegTaskInfo.
PEG_QUEUE_TYPE GetThingMessageQueue(PegThing*
pTarget)
This returns the pointer to the PegMessageQueue used by pTarget.
PEGINT HScrollHeight(void)
This returns the height of the horizontal scrollbar.
PegThing *LastPointerOver(void)
Returns a pointer to the object the mouse pointer was last over.
PegThing *ScreenPop(void)
PegThing *ScreenPop(PegThing *pWho, PEGBOOL
Remove = TRUE, PEGBOOL Destroy = TRUE)
These functions remove an object from the screen stack and add it to the
Presentation. The parameter pWho should be a pointer to whatever object is
void PegTask(void)
{
...
...
while(1)
{
Presentation->Execute();
}
...
...
}
void SetUserMessageHandler(PEGINT
(*pHandler)(const PegMessage &Mesg))
This provides a way to catch user-defined messages in the default
PresentationManager without needing to override it. A callback function
pointer is passed so that it can be called whenever the
PresentationManager receives a user-defined message.
void SetVScrollDrawInfo(PegScrollDrawInfo
*pInfo)
This function assigns the vertical scrollbar drawing information.
PEGINT VScrollWidth(void)
This function returns the width of the vertical scrollbar.
void AllocateViewportBlock()
This function allocates a block of viewports which get added to the list of
free viewports.
void ConsolidateInvalidList()
This function reduces the number of entries in the list of invalid regions by
searching for any duplicate entries or overlapping child/parent entries. That
way PEG will try not to redraw the same portion of the screen multiple
times.
Viewport *GetFreeViewport()
This function returns a pointer to a viewport from the list of free viewports.
PegThing *mpInputThing
Pointer to the object which has input focus, or NULL.
PegThing *mpLastPointerOver
Pointer to the object the mouse pointer was last over, or NULL.
PEGCHAR * mpScratchPad
Pointer to the current contents of the scratchpad buffer, or NULL.
PEGUBYTE mPointerCaptures
Indicates the current pointer capture nesting level. If there are no
outstanding pointer captures, mPointerCaptures is 0.
1.3 PegResourceManager
1.3.1 Overview
PegResourceManager is a class responsible for maintaining all of the
applications resources, which include its fonts, bitmaps, strings, and colors.
All resources are given an ID used to reference those resources in the
tables that the PegResourceManager uses. Most of the PEG library source
code will use these IDs in the APIs rather than direct pointers to the
resources themselves.
The main advantage to using IDs for everything is that it allows the user to
switch which resources to use without needing to modify the application
code. This is sometimes referred to as “skinning.” For instance, the
application could be designed to allow user-selectable color schemes. To
do that, the application would need to create different color resource tables
for the different color schemes. Then it would simply need to call
InstallResourcesFromTable() to start using a particular skin.
All of the functions of this class are static, so there is no need to ever create
an instance of the PegResourceManager class.
PegFont
1.3.3 Derivation
None.
typedef struct {
PegBitmap *pBitmap;
PEGUSHORT BitmapId;
PEGUBYTE Flags;
} PegBitmapTableEntry;
typedef struct {
PEGCOLOR Color;
PEGUSHORT ColorId;
} PegColorTableEntry;
struct PegStringTablePage {
PEGUSHORT FirstSID;
PEGUSHORT LastSID;
PEGUSHORT NumLanguages;
const PEGCHAR ***pTable;
PegStringTablePage *pNext;
};
typedef struct {
const PegStringTablePage *pStringTable;
const PegFontTableEntry *pFontTable;
const PegBitmapTableEntry *pBitmapTable;
const PegColorTableEntry *pColorTable;
void *pSpare1;
void *pSpare2;
} PegResourceTable;
static PEGBOOL LoadResourceFile(char *pPathName,
PEGBOOL DeleteOld = FALSE)
This function loads a file from the file system at runtime that contains new
resource information. pPathName is the path and filename of the resource
file. This is only available if PEG_RUNTIME_RESOURCES is defined.
1.4 PegScreen
1.4.1 Overview
PegScreen is the PEG class that provides the drawing primitives used by
the individual PEG objects to draw themselves on the display device. PEG
windows and controls never directly manipulate video memory, but instead
use the PegScreen member functions to draw lines, text, bitmaps, etc. Most
importantly, PegScreen provides a layer of isolation between the video
hardware and the rest of the PEG library, which is required to ensure that
PEG is easily portable to any target environment.
Most often, the PegScreen member functions are used to draw directly to
the video frame buffer. However, it is also possible to draw into a private
PegBitmap, and then use the PegScreen::Bitmap() function to transfer
the private PegBitmap to the video frame buffer. This technique is
commonly used for displaying animation sequences, or for drawing on top
of an image before displaying the image. The general sequence required
for off-screen drawing is:
Class PegThing provides wrapper functions for the most commonly used
PegScreen Drawing operations.
1.4.3 Derivation
PegScreen is an abstract base class.
1.4.4 Constructors:
PegScreen(const PegRect &Size)
This constructor determines the size in pixels of the PegScreen frame
buffer. This does not have to be the same dimension as
PegPresentationManager, although this is the most typical case. One
instance of the target-specific PegScreen-derived interface class is created
during program startup. The PegScreen constructor is normally responsible
for configuring the target video controller and initializing other variables
used for improved drawing performance.
PEGUINT DrawNesting(void)
This function returns the current drawing nesting level.
This is the only text drawing function provided by the screen driver. Various
font formats, including anti-aliased fonts and outlined-fonts, are drawn by
the driver by testing the font type flags. The application program does not
differentiate between drawing a simple binary font or drawing an anti-
aliased font; this happens automatically within the screen driver itself. This
enables the application program to change font types and styles simply by
referencing new font pointers; no other change is required.
This function is used primarily for testing and/or capturing screen shots on
the embedded target for use in promotional literature. This function is NOT
normally used for production software since its output format is the
Microsoft Windows bitmap format, not the PegBitmap format.
The Ellipse function is not required internally by the PEG library, and is
therefore only provided if the #define PEG_ARC_GRAPHICS is turned on in the
header file \peg\include\pconfig.hpp.
PegBitmap *GetPointer(void)
This method returns a PegBitmap pointer to the current mouse pointer
bitmap.
PegPoint GetPointerPos(void)
This method returns a PegPoint with x/y coordinates for the location of the
pointer.
PEGUBYTE GetPointerType(void)
This function returns the current pointer type. The available pointer types
are enumerated at the top of the file \peg\include\pscreen.hpp. The types
provided with PEG include:
PPT_NORMAL
PPT_VSIZE
PPT_HSIZE
PPT_NWSE_SIZ
E
PegBitmap *GetSurfaceBitmapAndClose(PEGINT
Surface)
This function returns a pointer to the PegBitmap used by the surface with ID
Surface. It also then destroys every part of the surface except the bitmap.
The caller is then responsible for deleting the bitmap.
PEGINT GetXPointerOffset(void)
Returns the X offset of the currently used mouse pointer.
PEGINT GetXRes(void)
Returns the horizontal screen resolution, in pixels.
PEGINT GetYPointerOffset(void)
Returns the Y offset of the currently used mouse pointer.
PEGINT GetYRes(void)
Returns the vertical screen resolution, in pixels.
PEG color palettes are simple 8-8-8 RGB color values. There should be (3*
Num) PEGUBYTE values in the array pointed to by pPal.
PPT_NORMAL
PPT_VSIZE
PPT_HSIZE
PPT_NWSE_SIZ
E
PPT_NESW_SIZ
E PPT_IBEAM
PPT_HAND
PEGULONG mNumColors
Number of output colors. This is the number of colors supported by the
output device, rather than the number of colors in the current palette.
PEGINT mCurXOffset
Offset in x axis between upper-left corner of mouse pointer bitmap and
pointer hotspot.
PegBitmap *mpCurPointer
Address of current mouse pointer bitmap
PegPointer mpPointers[NUM_POINTER_TYPES]
Array of mouse pointer bitmap addresses. This array must be extended if
new pointer types are defined.
PEGUINT mDrawNesting
Nesting level within Draw functions
PEGINT mHRes
The horizontal screen resolution in pixels.
PEGINT mVRes
The vertical screen resolution in pixels.
PEGINT SqRoot(PEGINT x)
This function returns the integer square root of x. This is used for the
ellipse calculations. This function uses a simple lookup table, which makes
it quite fast. It does not use any floating point numbers.
1.4.7 Examples:
Draw() Function Example
case PM_HIDE:
Screen()->ResetPalette();
PegWindow::Message(Mesg);
break;
default:
return PegWindow::Message(Mesg);
}
return 0;
}
1.5 PegTextThing
1.5.1 Overview
PegTextThing serves as a base class for all PEG objects that display or
manipulate text. This provides a common set of API functions for all PEG
classes that display text, such as PegTitle, PegTextButton, PegPrompt,
PegEditField, and others.
For this reason, if you dynamically create a string that will be associated
with a PegTextThing derived class, you should use the TT_COPY style when
the class is constructed. For example, if you build up a string in an
automatic character array using a function like itoa or sprintf, the
storage for that character string is temporary storage, usually on the stack.
After the function returns, the storage is no longer valid. If you are using a
PegTextThing class in this way, the TT_COPY should be used.
If the string associated with an object is static, which is most often the case,
the TT_COPY flag should not be used. For example, when a PegTitle is
created like this:
the string is a string literal. The compile/linker will allocate storage space for
this string and the storage space will never be deleted. In this case, it is not
necessary for PegTextThing to copy the actual string data.
1.5.2 Derivation
PegTextThing is derived from PegThing. It is important to remember that all
public PegThing member functions are available to objects derived from
PegTextThing.
1.5.4 Constructors:
PegTextThing(const PegRect &Rect, PEGUINT
StringId = 0, PEGUSHORT Id = 0, PEGULONG
Style = FF_NONE, PEGUINT FontIndex = 0)
PEGUINT GetStringId(void)
Returns the current string ID
void SetCopyMode(void)
This method allows copy mode to be set to true after the object has been
constructed. Once set to true, it cannot be set back to false. This forces the
object to behave as if you had passed the TT_COPY flag in the constructor in
that it makes a copy of the text and stores it internally.
PEGINT TextLength(void)
This inline function returns the number of characters in the string currently
associated with any PegTextThing-derived object.
PEGINT GetYShadow(void)
This function returns the Y-axis offset of a text shadow.
PEGCOLOR GetShadowColor(void)
This function returns the color value of a text shadow.
PEGCOLOR GetShadowColorId(void)
This function returns the color Id of a text shadow.
PEGINT GetShadowBlur(void)
This function returns the blur value of a text shadow.
PEGSHORT GetShadowOpacity(void)
This function returns the opacity level of a text shadow.
PEGUSHORT GetShadowScale(void)
This function returns the scale of a text shadow.
PegShadowMode GetShadowMode(void)
This function returns the shadow mode of a text shadow.
PEGUSHORT GetTextOpacity(void)
This function returns the opacity of the text drawn with a text
shadow.
PEGCHAR *mpText
Pointer to the string associated with the object.
PEGUINT mFontIndex
ID of the PegFont associated with the object.
PEGINT mStrLen
Number of characters in the current assigned string.
PEGBOOL mCopy
TRUE/FALSE value indicating if the string copy mode is in effect.
1.5.7 Examples:
The following function creates a PegTextButton, which is a PegTextThing-
derived class, and assigns a custom font to the button. The font has the ID
labeled ‘CUSTOM_BTN_FONT.’ The button is then added to the parent
window.
The following function obtains the string associated with a prompt. The
string is converted to an integer, a range check is made, and the modified
value is then reassigned to the prompt. Note that in this case, the prompt
should be created with the TT_COPY flag enabled.
if (pString)
{
PEGINT Val = PegAtoI(pString);
1.6 PegThing
1.6.1 Overview
PegThing is the base class from which all viewable PEG objects are
derived. While you may never create an instance of an actual PegThing in
your application, it is very possible that you will derive your own custom
control types from PegThing. In any event, every window and control you
will use is based on PegThing, so you will be using the public functions of
PegThing often when programming with PEG.
Screen()->Line(.....)
Line(...)
The public member functions and wrapper functions are listed in the
Members section of this reference.
PegThing objects are NOT viewport objects. If you are constructing a large
container class, you may want to derive that class from PegWindow, rather
than from class PegThing. For small custom gadgets, PegThing works well
as a foundation upon which to build your custom class.
1.6.3 Derivation
PegThing is a PEG base class.
Public Functions
Add() Next()
AddToEnd() NextTabLink()
AddStatus() Parent()
Center() ParentShift()
Constructors Presentation()
CenterOf() Previous()
CheckDirectionalMove() PrevTabLink()
CheckSignal() Printer()
DefaultKeyHandler() Remove()
Destroy() RemoveStatus()
Distance() RemoveStyle()
Draw() Resize()
DrawChildren() Screen()
Find() SendSignal()
FindNearest() SetColor()
First() SetDefaultTabLinks()
FrameStyle() SetId()
GetId() SetMessageQueuePointer()
GetColor() SetPrintPtr()
GetSignals() SetScreenPtr()
GetStatus() SetSignals()
GetStyle() SetStyle()
Hide() SetTabLink()
InitClient() SetTabOrder()
Invalidate() SetTimer()
IsDescendentOf() SetTimeManager()
KillFocus() StandardBorder()
Message() StatusIs()
MessageChildren() Type()
MessageQueue() UpdateChildClipping()
MoveToFront() Version()
WrapperFunctions
BeginDraw() KillTimer()
Bitmap() Line()
Rectangle() RectMove()
BitmapFill() ReleasePointer()
Circle() SetPointerType()
CapturePointer() SetTimer()
DrawText() TextHeight()
EndDraw() TextWidth()
Invalidate()
Public Data
mReal mClip mClient
1.6.5 Constructors:
PegThing(const PegRect &Rect, PEGUSHORT Id = 0,
PEGULONG Style = FF_NONE)
This constructor is used when the desired initial position of the object on the
screen is known at the time of object creation. Rect contains the starting
screen coordinates, in pixels, for the object. The Style parameter indicates
the object's initial drawing style.
The easiest way to set an object's position is to call the member function
Resize(), which accepts a PegRect argument which should contain the
If the object pWho is already a member of the current object's child list, pWho
is not added again to the list. Instead, pWho is simply unlinked from the child
list and re-linked at the head of the child list. This action changes the order
of child objects, which may be the desired operation.
Objects are added to the parent according to the status of the object,
meaning that objects with PSF_VIEWPORT status or PSF_ALWAYS_ON_TOP
status are always maintained ahead of child objects which do not have this
status. These differences are maintained internally by PEG and are
necessary to ensure proper drawing; however, they are not normally the
concern of the application-level program.
If pWho is not visible at the time this function is called, and the object this is
visible, a PM_SHOW message will be sent to pWho to inform it that it has
become visible. If the calling object is not visible at the time pWho is added,
and the calling object later becomes visible (by addition to a visible object),
PM_SHOW messages will be sent at that time to the calling object and all of its
children.
When constructing complex windows and dialogs, it is best to first add all of
the child objects to the main window or dialog, and then to add the main
The AddToEnd function works very much like the Add() function, except
that the added object is added to the end of the linked list of child objects
rather than being added to the head of the linked list. This is sometimes
useful when adding objects to PegList containers in order to correct the
child display order.
void CapturePointer(void)
This function acts as a wrapper function, allowing access by a PegThing to
the PegPresentationManager member function of the same name. Use of
this function is equivalent to Presentation()->CapturePointer(this).
PegRect Rect;
Rect.Set(0, 0, 100, 100); // create 100x100 pixel window
PegWindow *MyWin = new PegWindow(Rect);
Presentation()->Center(MyWin); // center window on the screen
This function checks for keys that cause an input focus change, such as
TAB and ARROW keys. If the key is not one of these keys, the function
then checks to see if the object signals require that a PSF_KEY_RECEIVED
signal be sent to the object parent. Finally, if none of these operations are
performed, the key is passed up to the parent of the current object.
defalt:
return PegDialog::Message(Mesg);
}
return 0;
}
virtual PegThing *FindNearestNeighbor(PEGINT
Key, PegThing *pStart, PegPoint CenterThis)
FF_NONE No Frame
FF_THIN Thin Frame.
FF_RAISED Raised 3D Frame.
FF_RECESSED Recessed 3D Frame.
FF_THICK Thick 3D Frame.
PEGUSHORT FrameStyle(void)
This function returns the current frame style of an object.
PEGUSHORT GetId(void)
Returns the value of the object's mId member. The mId value is not used by
PEG directly, but it is useful to the application software for keeping track of
individual controls or other objects when a window such as a complex
dialog has several instances of a particular object type associated with it.
By assigning IDs to each object, the application can determine precisely the
source of a control notification by requesting the control's mId value. Object
IDs are also used to send and receive signals. The message number
associated with a particular signal is calculated based on the object ID and
the signal being sent.
PEGUSHORT GetSignals(void)
This function returns the signals of which the object is set to notify its
parent. The available signal masks and descriptions of each may be found
here.
Viewport *GetViewportList(void)
This function returns the object’s list of viewports. This is only available if
PEG_VIEWPORTS is defined.
static PegPresentationManager
*Presentation(void)
This function returns a pointer to the application's instance of
PegPresentationManager. This value is required in order to interact directly
with the top-level presentation. That is, in order to add a new window to the
screen, you would add the window to PegPresentationManager as shown:
PegThing *PrevTabLink(void)
Returns a pointer to the object that is previous in the tab order, if known;
otherwise returns NULL. This function is only provided if
PEG_KEYBOARD_SUPPORT and PEG_TAB_KEY_SUPPORT are defined. When
this configuration is defined, PEG objects that accept keyboard input focus
are linked together in a circular list when the parent window is displayed.
The order of this circular list is defined by functions SetDefaultTabLinks()
and SetTabOrder().
void ReleasePointer(void)
This function acts as a wrapper function allowing access by a PegThing to
the PegPresentationManager member function of the same name. Use of
this function is equivalent to Presentation()->ReleasePointer(this).
Remove() does not delete the object after it has been removed. In fact, the
purpose of Remove() is to allow you to remove objects from the screen
without deleting them, allowing you later to re-display the object simply by
re-adding it to a visible window. If you want to remove and delete an object,
the PegThing member function Destroy() is provided for that purpose.
MyButton-
>Resize(Rect);
Note: The Screen() function returns the static PegThing member variable
mpScreen. mpScreen does not have to be set in stone for the life of your
application. One possible reason to temporarily replace the mpScreen
pointer value is to perform screen printing operations. By defining a
PegScreen class that drives a printer, you can easily print any PEG window
by temporarily setting the mpScreen pointer to point to your print driver,
telling the PEG window to re-draw, and then setting the mpScreen member
back to its original value.
The default system color IDs are defined in the file presmgr.hpp. The
actual color values associated with these IDs will vary depending on the
color depth supported on the target system. A few PEG objects such as
PegSpreadsheet have additional color indices associated with them.
void SetDefaultTabLinks(void)
This is called automatically by PegWindow derived objects when they
receive the PM_SHOW message. This establishes the initial order of tabbing
through the list of child objects. Note that this function is only defined when
PEG_KEYBOARD_SUPPORT and PEG_TAB_KEY_SUPPORT are defined in the
pconfig.hpp header file. This function is also called when objects that can
receive keyboard focus are added to a visible window.
The default tab order is determined from the position of child objects with
PSF_ACCEPTS_FOCUS status. Child objects are placed in the tab list in a top-
to-bottom, left-to-right search order. By default, the child object that initially
receives input focus is always the top most, left most child object.
The application program can change the default initial focus by first finding
the child object with PSF_DEFAULT_FOCUS status and removing this status
by calling pChild->RemoveStatus(PSF_DEFAULT_FOCUS). The application
can then re-define the initial focus by calling pChild-
>SetStatus(PSF_DEFAULT_FOCUS) on the desired child object.
switch (Mesg.Type)
{
case PM_SHOW:
// This will set the default tab order.
PegWindow::Message(Mesg);
// This will set user-defined tab order.
SetTabOrder(Order);
break;
default:
return PegWindow::Message(Mesg);
}
return 0;
}
PEGUSHORT Type(void)
Returns the object's enumerated type, held in the private member variable
mType. This variable is used to determine the class of an object.
void UpdateChildClipping(void)
This function updates the mClip rectangle of all of the child (and
descendent) objects based on the current object’s mReal and mClip
rectangles.
PegRect mClip
This rectangle defines the clipping rectangle of the object. This may be
smaller than mReal if the object extends beyond the client area of its parent.
PegRect mReal
This rectangle defines the outer limits of an object, inclusive. Objects are
never allowed to draw themselves outside of this rectangle.
PEGINT mColorId[4]
This array defines the four basic colors that all PegThing objects use to
draw themselves. The colors are indexed as PCI_NORMAL, PCI_NTEXT,
PCI_SELECTED, and PCI_STEXT.
The first form of this function is used to draw into the default mSurface. The
second form is used to begin drawing into some other existing surface
defined in the application.
The first form is used when a direct bitmap pointer is available. The second
form is used when a bitmap’s ID is available. In that case, the ID is used to
find the bitmap pointer in the PegResourceManager.
PEGULONG mStatus
Object status flags.
PEGULONG mStyle
Object style flags.
1.7 PegTimerManager
1.7.1 Overview
PegTimerManager is where all timer functionality resides. This involves
starting and stopping PegTimers owned by PegThing objects as well as
keeping track of the underlying timer ticks that keep the PegTimers going.
Note that the PegThing class includes wrapper functions for SetTimer and
KillTimer that pass the PegThing’s this pointer as the target for the
timer. This is just a convenience, since this is typically the only way those
functions ever get called.
1.7.2 Derivation
PegTimerManager is a PEG base class.
1.7.4 Constructors:
PegTimerManager(void)
This constructs a PegTimerManager object. There only needs to be one
instance of this in an application. This instance is referenced by all PEG
objects.
void TimerTick(void)
This function is called by either the PegTask or by a separate timer task. It
will go through every PegTimer that has been created so far and decrement
their counters by one. If a counter reaches 0, that means it is time to send a
PM_TIMER message to whatever object the timer is targeted for. If its reset
value was non-zero, the counter will be reset to that value. Otherwise, the
PegTimer is deleted.
1.7.6 Example:
This example shows a PegPrompt that changes color twice per second.
Note that the PegThing wrapper functions are used here to simplify the
code.
#define MY_TIMER_ID 1
case PM_TIMER:
default:
return PegPrompt::Message(Mesg);
}
return 0;
}
PegTitle
PegToolBar
PegToolBarPanel
PegVPrompt
PegVScroll
2.1 PegAnimation
2.1.1 Overview
PegAnimation is an animated bitmap display class. It is designed to be
used for the simple display of animated GIF type images; however, any list
of images can be created and used with the PegAnimation class.
typedef struct {
PEGUINT BitmapId;
PEGINT Delay;
PEGINT xOffset;
PEGINT yOffset;
PEGINT Disposal;
} PegAnimationFrame;
2.1.4 Signals
PegAnimation class sends no signals.
2.1.5 Derivation
PegAnimation is derived from PegThing.
2.1.6 Constructors:
PegAnimation(const PegRect &Rect, PegAnimationFrame
*pFrameList, PEGUSHORT Id = 0, PEGULONG Style =
FF_NONE)
PegAnimation(const PegRect &Rect, PEGUSHORT Id = 0,
PEGULONG Style = FF_NONE)
The constructor creates a PegAnimation widget. Rect is the object size and
position. pFrameList is the address of an array of PegAnimationFrame
structures. The array is terminated with a structure having a -1 bitmap ID.
PEGINT GetCurrentFrame(void)
Returns the index of the current frame of animation.
This mode causes the animation to continuously wrap from the last frame to
the first. If this mode flag is not set, the animation will run once when
activated and terminate after displaying the last animation frame.
PEG_AF_SHOWIDLE
This mode flag causes the animation to display the current animation frame
even when the animation is idle (i.e. it is not cycling through the list of
animation frames). If this flag is not set, the animation widget displays no
image when it is not running.
PEG_AF_AUTOSTART
This mode flag causes the animation to automatically start running when it
is visible. If this mode flag is not set, the animation is started via program
control by calling the Start() function.
void Stop(void);
This function stops the animation. The animation will display the last active
frame if PEG_AF_SHOWIDLE mode is set; otherwise, it will display no graphic
when stopped.
2.2 PegBitmapButton
2.2.1 Overview
PegBitmapButton is a PegButton class that displays a PegBitmap with no
frame. There are actually three PegBitmaps associated with a
PegBitmapButton. There is one for the normal state, one for the pressed
state, and one for the focused state.
The button is NOT restricted to stay the same dimensions as the bitmaps,
so if the bitmap is smaller than the mReal rectangle of the button, then the
outer section of the button will essentially be transparent. Keep in mind,
however, that the user will still be able to click in the region outside the
bitmap if it is still within the button’s mReal. For some applications, this
might not be ideal, so it would be a good idea to keep the dimensions the
same.
Also, since there is no visible frame, if the bitmap has transparency in it,
then the button itself appears transparent. But it’s a good idea to make all of
the bitmaps that the button uses transparent in the same locations. For
example, if the normal bitmap is rectangular with the exception of a
rounded upper left corner, and the pressed bitmap is rectangular with the
exception of a rounded lower right corner, then there are going to be
artifacts left on the screen whenever the bitmap changes. The reason is
because the transparent region does not get redrawn. So if there was a
solid rectangle drawn there before, it won’t go away if a transparent bitmap
is drawn on top of it. To avoid this, the parent window can be redrawn to
clear out the background.
The PegBitmapButton uses four bitmaps, which can be indexed with the
following enumerations.
PegTextButton
PegRadioButton
PegCheckBox
2.2.4 Signals
PegBitmapButton sends the PSF_CLICKED signal when selected.
2.2.5 Derivation
PegBitmapButton is derived from PegButton.
2.2.6 Constructors:
PegBitmapButton(const PegRect &Rect, PEGUINT
NormalBmp, PEGUINT PressedBmp, PEGUINT
FocusedBmp = 0, PEGUSHORT Id = 0, PEGULONG Style
= AF_ENABLED|FF_NONE)
The constructor creates a PegBitmapButton with a user-defined size. The
NormalBmp and PressedBmp are required, but if FocusedBmp is 0, then the
button defaults to using the NormalBmp when it receives focus.
2.2.9 Examples:
...
...
PegRect Rect;
Rect.Set(20, 20, 99, 49);
Add(new PegBitmapButton(Rect, BID_RED_BTN, BID_GREEN_UP_BTN,
BID_GREEN_DOWN_BTN));
...
...
2.3 PegBitmapSlider
2.3.1 Overview
PegBitmapSlider is an analog adjustment control. The end user adjusts the
slider value by dragging the slider ‘handle.’ PegSlider can be either
horizontal or vertical. The orientation is determined by the style flags. This
class accepts bitmaps for the background and for the handle to allow a
much more customized appearance.
FF_NONE No Frame
FF_THIN Thin Frame.
FF_RAISED Raised 3D Frame.
FF_RECESSED Recessed 3D Frame.
SF_SNAP Snaps the slider handle to the exact tick
positions.
SS_ORIENTVERT Determines orientation. If this is used, the slider
is vertically oriented. Otherwise, it is horizontal.
2.3.4 Signals
PegBitmapSlider sends PSF_SLIDER_CHANGE signals to the slider parent
when adjusted by the end user. The message contains the following
values:
2.3.5 Derivation
PegBitmapSlider is derived from PegSlider.
2.3.6 Constructors:
PegBitmapSlider(const PegRect &Rect, PEGLONG Min,
PEGLONG Max, PEGINT BkgndBmp = 0, PEGINT
NeedleBmp = 0, PEGUINT Id = 0, PEGULONG Style =
FF_RAISED, PEGLONG Scale = -1)
The PegBitmapSlider constructor creates a slider control at the position and
size specified in Rect. The Min and Max values specify the initial limits of the
slider. The BkgndBmp parameter is the ID of the bitmap that will be drawn in
the background. The NeedleBmp parameter is the ID of the bitmap that will
be drawn for the needle or handle of the slider. If either bitmap IDs are -1,
the default PegSlider appearance will be used. The slider ID, if non- zero,
enables the PSF_SLIDER_CHANGE notification signal. The slider scale
determines the interval between slider tickmarks.
The bitmap progress bar control has three main styles. The default style is
PS_BITMAP. This style displays a background bitmap and an overlay bitmap.
As progress increases, more of the overlay bitmap is shown. Multiple overlay
bitmaps are can be used to create an animation effect. Another style,
PS_BUTTON, displays a gradient filled indicator, in which case the progress
bar internally draws a PegButton within the specified frame style. The
PS_LED style, on the other hand, does not use a client area button to
indicate progress; instead, it invokes a custom drawing style meant to
appear as a series of LEDs, with the lighted LEDs indicating the current
progress.
2.4.4 Signals
PegBmpProgressBar is a passive object, is not user selectable, and
sends no signals.
2.4.5 Derivation
PegBmpProgressBar is derived from PegProgressBar.
2.4.6 Constructors:
PegBmpProgressBar(const PegRect &Rect,
PEGULONG Style = FF_THIN|PS_SHOW_VAL|PS_PERCENT|
PS_BUTTON, PEGUINT BakbmpID = 0,
PEGUINT Ovlay1ID = 0, PEGUINT Ovlay2ID = 0,
PEGINT Min = 0, PEGINT Max = 100,
PEGINT Current = 0)
PEGINT GetAnimationRate(void)
Returns the animation rate.
void Start(void)
This function starts the overlay bitmap animation.
void Stop(void)
This function stops the overlay bitmap animation.
2.4 PegButton
2.4.1 Overview
PegButton serves as the base class for nearly all PEG button style objects.
PegButton provides the BF_REPEAT timer operation, default frame drawing,
and default selection PEG_SIGNALs. You would not normally create an
instance of PegButton in your system software; however, PegButton is very
useful as a base class for your own custom button styles.
PegIconButton
PegTextButton
PegRadioButton
PegCheckBox
2.4.4 Signals
PegButton sends the PSF_CLICKED signal when selected.
2.4.5 Derivation
PegButton is derived from PegTextThing.
2.4.6 Constructors:
PegButton(const PegRect &Rect, PEGUINT StringId = 0,
PEGUINT Id = 0, PEGULONG Style = AF_ENABLED|
FF_RAISED, PEGUINT FontIndex = 0))
PegButton(const PEGCHAR *pText, const PegRect &Rect,
PEGUINT Id = 0, PEGULONG Style = TT_COPY|
AF_ENABLED|FF_RAISED, PEGUINT FontIndex = 0)
PegButton(void)
The first and second constructors creates a PegButton with a defined size
and position. The third constructor creates a PegButton with an undefined
position. Note that PegButtons take text and a font as parameters, but by
default do not draw them on the button. To display text on a button, use
PegTextButton.
void Enable(void)
Enables the button, and allows it to be selected.
void UnselectSiblings(void)
This function is used to make sure all other buttons that are children of this
button’s parent object will become unselected.
2.5 PegCheckBox
2.5.1 Overview
PegCheckBox is a PegButton class that provides a toggle operation. Any
number of PegCheckBox objects with a common parent can be selected.
The PegCheckBox uses 4 bitmaps, which can be indexed with the following
enumerations.
PegTextButton
PegRadioButton
PegIconButton
PegBitmapButton
2.5.4 Signals
PegCheckBox sends the PSF_CHECK_ON signal when selected, and the
PSF_CHECK_OFF signal when de-selected.
2.5.5 Derivation
PegCheckBox is derived from PegButton.
2.5.6 Constructors:
PegCheckBox(const PegRect &Rect, PEGUINT StringId,
PEGUSHORT Id = 0, PEGULONG Style = AF_ENABLED|
FF_NONE|BF_TOGGLE)
PegCheckBox(const PEGCHAR *pText, const PegRect &Rect,
PEGUSHORT Id = 0, PEGULONG Style = TT_COPY|
AF_ENABLED|FF_NONE|BF_TOGGLE)
The first constructor creates a PegCheckBox by obtaining text from the
string table using a string ID. The second constructor takes a pointer to a
string directly.
2.5.8 Examples:
The following is an example of PegCheckBox:
...
...
PegRect Rect;
Rect.Set(20, 20, 99, 39);
Add(new PegCheckBox(“I like Coffee”, Rect));
...
...
2.6 PegDecoratedButton
2.6.1 Overview
PegDecoratedButton is a PegButton class that has the ability to display
both text and a PegBitmap. The location of the text relative to the bitmap
can be selected using a set of extended style flags. PegDecoratedButton
also supports a 'flyover' mode, where the button appears flat until the
pointer is over the button.
PegIconButton
PegBitmapButton
PegTextButton
PegRadioButton
PegCheckBox
2.6.4 Signals
PegDecoratedButton sends the PSF_CLICKED signal when selected.
2.6.5 Derivation
PegDecoratedButton is derived from PegButton.
2.6.6 Constructors:
PegDecoratedButton(const PegRect &Rect, PEGINT
StringId, PEGINT BitmapId, PEGUSHORT Id = 0,
PEGULONG Style = AF_ENABLED, PEGBOOL FlyOver =
FALSE)
PegDecoratedButton(const PEGCHAR *pText, const PegRect
&Rect, PEGINT BitmapId, PEGUSHORT Id = 0,
PEGULONG Style = AF_ENABLED, PEGBOOL FlyOver =
FALSE)
The constructors use the parameter Rect to determine the size of the
button, and can take in both a bitmap and text. Depending on which
constructor is used, either a string ID or a pointer to the text is passed in.
2.6.8 Examples:
The following are examples of PegDecoratedButton:
Rect.Shift(-150, 50);
pButton = new PegDecoratedButton(Rect, SID_TEXT_ON_RIGHT,
BID_GREEN_DOT, 0, AF_ENABLED, TRUE);
pWindow->Add(pButton);
Rect.Shift(150, 50);
pButton = new PegDecoratedButton(Rect, SID_TEXT_ON_TOP,
BID_GREEN_DOT, 0, AF_ENABLED | BF_ORIENT_BR, TRUE);
pWindow->Add(pButton);
Rect.Shift(150, -50);
pButton = new PegDecoratedButton(Rect, SID_TEXT_ON_LEFT,
BID_GREEN_DOT, 0, AF_ENABLED | BF_ORIENT_TR |
BF_ORIENT_BR,
TRUE);
pWindow->Add(pButton);
2.7 PegEditField
2.7.1 Overview
PegEditField is a user-editable graphical string object. PegEditField can be
displayed with any font or color and several different border styles. Only
one line of text can be displayed in a PegEditField.
PegEditField supports mark, cut, copy, and paste operations via keyboard
input when the definition #define PEG_KEYBOARD_INPUT is enabled in the file
\peg\include\pconfig.hpp. The length of the contained string can be
limited if desired. PegEditField shifts the string left or right as it is edited if it
cannot be completely displayed in the client area of the PegEditField
object.
PegTextBox
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
EF_EDIT When this style is applied, the user can edit the
PegEditField object. If this style is applied, the
PegEditField object automatically includes the
TT_COPY style.
TT_COPY Instructs the PegEditField to copy the text string
assigned. This flag should be used when the text
string assigned to the PegEditField is created
dynamically using temporary storage.
2.7.4 Signals
In addition to the common signals defined by PegThing, PegEditField
supports the following signals:
2.7.5 Derivation
PegEditField is derived from PegTextThing.
2.7.6 Constructors:
PegEditField(const PegRect &Rect, PEGUINT StringId =
0, PEGUSHORT Id = 0, PEGULONG Style =
FF_RECESSED|AF_ENABLED|EF_EDIT, PEGINT Len = -1)
PegEditField(const PEGCHAR *pText, const PegRect
&Rect, PEGUSHORT Id = 0, PEGULONG Style =
FF_RECESSED|AF_ENABLED|EF_EDIT, PEGINT Len = -1)
The first constructor takes a string ID as the initial text, while the second
constructor takes a pointer to a string.
void DeleteMarkedText(void)
This method deletes the marked text.
void PasteFromScratchPad(void)
This method pastes the text from the scratch pad and inserts it at the
current cursor position.
2.7.9 Examples:
The following are each different styles of PegEditField:
void MyWindow::AddCustomString(void)
{
PegRect ChildRect;
2.8 PegGroup
2.8.1 Overview
PegGroup is a container class that visually groups any number of children.
You can add any type of PEG object to a PegGroup, including window
objects, nested groups, etc.
PegThing
PegTextThing
2.8.4 Signals
PegGroup sends no signals. Signals sent by child objects of PegGroup are
passed up to the parent of the PegGroup object.
2.8.5 Derivation
PegGroup is derived from PegTextThing.
2.8.6 Constructors:
PegGroup(const PegRect &Rect, PEGINT StringId,
PEGULONG Style = AF_ENABLED)
PegGroup(const PEGCHAR *pText, const PegRect &Rect,
PEGULONG Style = AF_ENABLED)
The PegGroup constructor creates a PegGroup at the indicated position
with an initial text value indicated by either a string ID or a string pointer.
2.8.8 Examples:
The following are examples of PegGroup:
void MyWindow::AddGroup(void)
{
PegRect GroupRect;
GroupRect.Set(mClient.Left + 10, mClient.Top + 10,
mClient.Right - 10, mClient.Top + 100);
PegRect ChildRect;
ChildRect.Set(mClient.Left + 20, mClient.Top + 20,
mClient.iLeft + 79, mClient.Top + 39);
pGroup->Add(new PegRadioButton(ChildRect, "Button1"));
ChildRect.Shift(0, 20);
pGroup->Add(new PegRadioButton(ChildRect, "Button2"));
ChildRect.Shift(0, 20);
pGroup->Add(new PegRadioButton(ChildRect, "Button3"));
Add(pGroup);
}
2.9 PegHelpButton
2.9.1 Overview
PegHelpButton is a PegIconButton class that displays a text string when
the user moves the mouse over it.
PegTextButton
PegIconButton
2.9.4 Signals
PegHelpButton sends the PSF_CLICKED signal when selected.
2.9.5 Derivation
PegHelpButton is derived from PegIconButton.
2.9.6 Constructors:
PegHelpButton(const PegRect &Rect, PEGUINT BitmapId,
PEGUINT StringId, PEGUSHORT Id, PEGULONG Style =
AF_ENABLED)
PegHelpButton(const PEGCHAR *pText, const PegRect
&Rect, PEGUINT BitmapId, PEGUSHORT Id, PEGULONG
Style = AF_ENABLED)
The constructor creates a PegHelpButton with a user-defined size. The
PegBitmap associated with the button will be displayed in the center of the
button client area. The string that is passed will be displayed when the user
moves the mouse over the button.
2.10 PegHScroll
2.10.1 Overview
PegHScroll is a horizontal scroll bar class. The scroll bar elevator is
proportional to the visible area of the object being scrolled.
The second form is a client area scroll bar. This form does not have
PSF_NONCLIENT system status. This type of scroll bar is under system
software control, and does not attempt to automatically determine position
and limit information.
PegScroll
PegVScroll
PegSlider
PegThing
2.10.4 Signals
PegHScroll sends PSF_SCROLL_CHANGE signals when the position of the
scroll bar elevator is changed either by dragging the elevator or by selecting
the directional scroll buttons. The signal message contains the following
information:
2.10.5 Derivation
PegHScroll is derived from PegScroll.
2.10.6 Constructors:
PegHScroll(PegScrollDrawInfo *pDrawInfo = NULL)
PegHScroll(const PegRect &InRect, PegScrollInfo *pSi,
PEGUINT Id = 0, PegScrollDrawInfo *pDrawInfo =
NULL)
The first constructor creates a non-client area scroll bar. The scroll bar will
automatically determine its position and size itself to the width of the parent
window.
The second constructor creates a client area scroll bar. In this mode, a
pointer to a PegScrollInfo structure is passed to set up the initial scrolling
range. In this mode, the scroll bar position and size are passed to the
constructor, along with the scroll bar ID, if any.
2.10.9 Examples:
The following are examples of PegHScroll:
void MyWindow::AddHScroll(void)
{
si.Min = 0; si.Max
= 200; si.Current =
100; si.Step = 1;
si.Visible = 50;
PegRect ScrollRect;
ScrollRect.Set(10, 10, 120, PEG_SCROLL_WIDTH + 10);
2.11 PegIcon
2.11.1 Overview
PegIcon is a simple bitmap display object. PegIcon can also be used to
represent another object.
PegThing
2.11.4 Signals
None.
2.11.5 Derivation
PegIcon is derived from PegThing.
2.11.6 Constructors:
PegIcon(PegThing *pProxy, PEGINT BitmapId = 0, PEGUINT
Id = 0, PEGULONG Style = FF_NONE)
PegIcon(const PegRect &Where, PEGINT BitmapId = 0,
PEGUINT Id = 0, PEGULONG Style = FF_NONE)
PegIcon(PEGINT BitmapId = 0, PEGUINT Id = 0, PEGULONG
Style = FF_NONE)
The first constructor creates a PegIcon that represents or serves as a proxy
for another object. The second and third constructors create a PegIcon that
will simply display a bitmap. The second constructor allows the caller to
specify the icon size and position. The third constructor allows the icon to
self determine the overall icon size to match the bitmap size. When the third
constructor is used, the application software may immediately use the
Resize() function to position the icon.
2.12 PegIconButton
2.12.1 Overview
PegIconButton is a PegButton class that displays a PegBitmap centered in
the button client area.
PegTextButton
PegRadioButton
PegCheckBox
2.12.4 Signals
PegIconButton sends the PSF_CLICKED signal when selected.
2.12.5 Derivation
PegIconButton is derived from PegButton.
2.12.6 Constructors:
PegIconButton(const PegRect &Rect, PEGUINT BmpId,
PEGUINT Id = 0, PEGULONG Style = AF_ENABLED|
FF_RAISED)
The constructor creates a PegIconButton with a user defined size. The
PegBitmap associated with the button will be displayed in the center of the
button client area.
2.12.9 Examples:
The following example creates a PegIconButton. The button will display the
PegBitmap 'OnMap' in the button client area.
...
...
PegRect Rect;
Rect.Set(20, 20, 99, 49);
Add(new PegIconButton(Rect, BID_ON_MAP));
...
...
2.13 PegMenu
2.13.1 Overview
PegMenu is the background object used to display a list of menu items.
PegMenu may contain any number of PegMenuButton objects.
PegMenuButton
PegMenuDescription
2.13.4 Signals
None.
2.13.5 Derivation
PegMenu is derived from PegThing.
2.13.6 Constructors:
PegMenu(PegMenuDescription *pDesc, PEGBOOL Popup =
FALSE)
The PegMenu constructor creates a PegMenu object with PegMenuButton
children. The children are defined by the PegMenuDescription parameter.
PegRect GetMinSize(void)
This function examines all child objects of the PegMenu to determine the
minimum size required to display all children. The resulting rectangle is
returned. This result can be used to intelligently position the PegMenu.
2.13.9 Examples:
The following are examples of PegMenuBar, PegMenu, and
PegMenuButton:
void MyWindow::PopUpFileMenu(void)
{
PegMenu *pMenu = new PegMenu(FileMenu);
PegRect SizeRect = pMenu->GetMinSize();
SizeRect.MoveTo(mClient.Left, mClient.Top);
pMenu->Resize(SizeRect);
pMenu->SetOwner(this);
Presentation()-
>Add(pMenu);
}
2.14 PegMenuBar
2.14.1 Overview
PegMenuBar is a window decoration used to position and display a user
command menu. PegMenuBar is designed to work in conjunction with
PegDecoratedWindow objects. PegMenuBar may be added to any type of
object. However, the client area of objects other than
PegDecoratedWindow will not be reduced properly unless this is done in
the application software.
PegMenuButton
PegMenuDescription
2.14.4 Signals
None.
2.14.5 Derivation
PegMenuBar is derived from PegThing.
2.14.6 Constructors:
PegMenuBar(PegMenuDescription *pDesc)
The PegMenuBar constructor creates a PegMenuBar object with
PegMenuButton children. The children are defined by the
PegMenuDescription parameter. PegMenuBar automatically determines its
position and size.
2.14.9 Examples:
The following are examples of PegMenuBar, PegMenu, and
PegMenuButton:
The following example creates a PegMenuBar and adds the menu bar to
the parent window. In this example, ‘HelpMenu,’ ‘WindowsMenu,’
void MyWindow::AddMenuBar(void)
{
Add(new PegMenuBar(MainMenu));
}
2.15 PegMenuButton
2.15.1 Overview
PegMenuButton is a button class used to populate PegMenu and
PegMenuBar objects. PegMenuButton sends selection signals to the owner
of the PegMenu or PegMenuBar.
The styles for PegMenuButton descriptions are very important. They define
whether the item sends a simple command, or whether it defines additional
characteristics such as 'dotable' or 'checkable.'
PegMenu
PegMenuDescription
2.15.4 Signals
None.
2.15.5 Derivation
PegMenuButton is derived from class PegTextThing.
2.15.6 Constructors:
PegMenuButton(PegMenuDescription *pDesc)
The PegMenuButton constructor creates a PegMenuButton object. The
description should contain either a valid button ID or the address of an
additional PegMenuDescription array.
void Disable(void)
This function disables a menu button so that the user cannot select it. The
text also is drawn gray by default.
void Enable(void)
This function enables a menu button so that the user can select it.
PegThing *GetOwner(void)
Returns the owner object of the button.
PegMenu *GetSubMenu(void)
This function returns a pointer to the submenu associated with a menu
button, or NULL if the button has no submenu.
PEGBOOL IsPointerOver(void)
Returns a boolean stating whether the mouse pointer is over this menu
button.
PEGBOOL IsSubVisible(void)
Returns a boolean stating whether the submenu of this button is visible.
2.15.8 Examples:
The following are examples of PegMenuBar, PegMenu, and
PegMenuButton:
2.16 PegMLTextButton
2.16.1 Overview
PegMLTextButton provides a pushbutton object with visual feedback that
indicates button depress and release operation. PegMLTextButton differs
from PegTextButton in that the text displayed can span multiple lines in
the button client area, hence the class name PegMLTextButton.
The text strings displayed on the button face are vertically centered over
the button client area, and may be horizontally justified in different ways by
using the different text justification styles such as TJ_LEFT or TJ_CENTER.
The text breaks for a multi-line text button are defined by the caller when
the text string is passed to the button, either during object construction or
with the DataSet() function. The character to be used as a break character
is passed to the class constructor(s), and defaults to the value of the
following define:
This allows the application engineer to easily change the character used as
a line delimiter.
PegTextButton
PegBitmapButton
PegRadioButton
PegCheckBox
2.16.4 Signals
PegMLTextButton sends PSF_CLICKED signals when selected.
2.16.5 Derivation
PegMLTextButton is derived from PegButton.
2.16.6 Constructors:
PegMLTextButton(const PegRect &Size, PEGINT StringId,
PEGCHAR Marker = DEF_ML_MARKER, PEGUINT Id = 0,
PEGULONG Style = TJ_CENTER|AF_ENABLED)
PegMLTextButton(const PEGCHAR *pText, const PegRect
&Size, PEGCHAR Marker = DEF_ML_MARKER, PEGUINT
Id = 0, PEGULONG Style = TJ_CENTER|AF_ENABLED)
PegMLTextButton offers two constructors, depending on how you want to
specify the button text. The first constructor allows you to reference the
string table with a string ID. The second constructor allows you to specify
the text directly with a string pointer.
2.16.8 Examples:
The following is a default multi-line text button:
PegRect Rect;
Rect.Set(10, 10, 49, 49);
Add(new PegMLTextButton(Rect, "Multi-Line|Text|Button"));
The following is a multi-line text button with a blank line, modified color, and
modified font:
2.17 PegProgressBar
2.17.1 Overview
PegProgressBar is a simple progress bar control used to indicate to an end
user the completion status of a slow activity. PegProgressBar can assume
any scale value within the range of the PEGINT data type; however, it is
most common to display a value that is a percentage of the completion
status.
The style, range, and initial value of a PegProgressBar object are passed to
the object constructor. As the operation being monitored progresses, the
application software calls the Update() member function to change the
displayed completion value.
The progress bar control has two main styles. The most common style is a
solid indicator, in which case the progress bar internally draws a PegButton
within the specified frame style. The PS_LED style, on the other hand, does
not use a client area button to indicate progress; instead, it invokes a
custom drawing style meant to appear as a series of LEDs, with the lighted
LEDs indicating the current progress.
2.17.4 Signals
PegProgressBar is a passive object, is not user selectable, and sends no
signals.
2.17.5 Derivation
PegProgressBar is derived from PegThing.
2.17.6 Constructors:
PegProgressBar(const PegRect &Rect, PEGULONG Style =
FF_THIN|PS_SHOW_VAL|PS_PERCENT, PEGINT Min = 0,
PEGINT Max = 100, PEGINT Current = 0)
This constructor creates a PegProgressBar. The default values construct a
progress bar that displays both text and a graphical value. The graphical
indicator has a raised border. The progress bar has a range of 0 to 100,
and displays a ‘%’ sign after the output value.
PEGINT Value(void)
This function returns the current progress bar value.
2.17.8 Examples:
The following is a PegWindow containing several styles of
PegProgressBar:
The source code used to create the above example can be found in the file
\peg\examples\pegdemo\pegdemo.cpp. The window class is named
ProgBarWindow.
2.18 PegPrompt
2.18.1 Overview
PegPrompt is a text display object. PegPrompt can be drawn with several
different border styles, and can be updated dynamically for interactive
updates or real-time information display. PegPrompt does not support user
editing.
The font used by PegPrompt can be changed at any time by using the
SetFont() function, which is a PegTextThing member function. Likewise,
the color used by PegPrompt can be set at any time by calling the
SetColor() function.
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
TJ_RIGHT Right justified text
TJ_LEFT Left justified text
TJ_CENTER Centered text
2.18.4 Signals
In addition to the common signals defined by PegThing, PegPrompt
supports the PSF_CLICKED and PSF_FOCUS_RECEIVED signal notifications.
2.18.5 Derivation
PegPrompt is derived from PegTextThing.
2.18.6 Constructors:
PegPrompt(const PegRect &Rect, PEGUINT StringId = 0,
PEGUSHORT Id = 0, PEGULONG Style = FF_NONE|
TJ_LEFT|AF_TRANSPARENT)
PegPrompt(const PEGCHAR *pText, const PegRect &Rect,
PEGUSHORT Id = 0, PEGULONG Style = TT_COPY|
FF_NONE|TJ_LEFT|AF_TRANSPARENT)
PegPrompt(const PegPoint &Put, PEGUINT StringId = 0,
PEGUSHORT Id = 0, PEGULONG Style = FF_NONE|
TJ_LEFT|AF_TRANSPARENT, PEGUINT FontId = 0)
PegPrompt(const PEGCHAR *pText, const PegPoint &Put,
PEGUSHORT Id = 0, PEGULONG Style = TT_COPY|
FF_NONE|TJ_LEFT|AF_TRANSPARENT, PEGUINT FontId =
0)
There are four PegPrompt constructors. The first two allow you to fully
specify the PegPrompt position and size. The third and fourth automatically
determine the prompt height based on the font passed to the constructor or
the default font prompt if no font is passed. The first and third constructors
are used for string IDs. The second and fourth constructors are used with
string pointers, for when a dynamic string is created at run time.
2.18.8 Examples:
The following are each different styles of PegPrompt:
void MyWindow::AddCustomPrompt(void)
{
PegRect ChildRect;
ChildRect.Set(0, 0, 100, 40);
PegPrompt *pPrompt = new PegPrompt(ChildRect, "FooBar");
pPrompt->SetFont(FID_CUSTOM_FONT);
Add(pPrompt);
}
2.19 PegRadioButton
2.19.1 Overview
PegRadioButton provides a mutually exclusive selection indicator. When a
PegRadioButton is selected by the user, it finds all sibling radio buttons and
de-selects them.
The PegRadioButton uses four bitmaps, which can be indexed with the
following enumerations:
PegBitmapButton
PegTextButton
PegGroup
PegCheckBox
2.19.4 Signals
PegRadioButton sends PSF_DOT_ON and PSF_DOT_OFF signals.
2.19.5 Derivation
PegRadioButton is derived from PegTextThing.
2.19.6 Constructors:
PegRadioButton(const PegRect &Rect, PEGUINT StringId =
0, PEGUSHORT Id = 0, PEGULONG Style = AF_ENABLED|
FF_NONE|BF_EXCLUSIVE)
PegRadioButton(const PEGCHAR *pText, const PegRect
&Rect, PEGUSHORT Id = 0, PEGULONG Style =
TT_COPY|AF_ENABLED|FF_NONE|BF_EXCLUSIVE)
The first constructor is used when the string ID for the text is known. The
second constructor is used when the string is created at run time so that
only a pointer is available.
2.19.8 Examples:
The following are each different styles of PegRadioButton:
The following function creates a PegGroup and adds several radio button
children to the group. The radio button ‘Button1’ will initially be selected:
void MyWindow::AddSelectGroup(void)
{
PegRect ChildRect;
ChildRect.Set(20, 20, 120, 100);
PegGroup *pGroup = new PegGroup(ChildRect, "Select One");
ChildRect.Set(30, 30, 110, 48);
pGroup->Add(new PegRadioButton("Button1", ChildRect,
IDR_BUTTON1,
AF_ENABLED|FF_NONE|BF_EXCLUSIVE|BF_PUSHED))
;
ChildRect.Shift(0, 20);
pGroup->Add(new PegRadioButton("Button2", ChildRect,
IDR_BUTTON2));
ChildRect.Shift(0, 20);
pGroup->Add(new PegRadioButton("Button3", ChildRect,
IDR_BUTTON3));
Add(pGroup);
}
2.20 PegScroll
2.20.1 Overview
PegScroll is an abstract base scroll bar class. It is used as the base class
for both the default PegVScroll and PegHScroll scroll bar classes. Users
can implement their own scroll bar classes by deriving from the PegScroll
base.
This class is mainly responsible for setting and checking the PegScrollInfo
member. Any derived classes must decide what to do with that information
(i.e. how to draw the scroll buttons, etc.). PegVScroll and PegHScroll are
the default derivatives used in PEG.
Users may provide their own custom scroll bar appearance by deriving their
own scroll bar gadgets from the PegScroll base class. In order to use these
custom bars, the user must also override the parent window CreateVScroll
and/or CreateHScroll virtual member functions to instantiate instances of
the custom scroll bar class type.
The PegScroll class uses six bitmaps, which can be indexed with the
following enumerations:
PegHScroll
PegSlider
2.20.4 Signals
There are no signals associated with PegScroll Objects.
2.20.5 Derivation
PegScroll is derived from PegThing.
2.20.6 Constructors:
PegScroll(PegScrollDrawInfo *pDrawInfo = NULL, PEGBOOL
Vertical = TRUE)
PegScroll(const PegRect &InRect, PegScrollInfo *pSi,
PEGUINT Id = 0, PegScrollDrawInfo *pDrawInfo =
NULL, PEGBOOL Vertical = TRUE)
The first constructor creates a nonclient area scroll bar. The scroll bar will
automatically determine its position and size itself to the height of the
parent window.
The second constructor creates a client area scroll bar. In this mode, a
pointer to a PegScrollInfo structure is passed to set up the initial scrolling
range. In this mode, the scroll bar position and size are passed to the
constructor along with the scroll bar ID, if any.
PEGINT GetMaxOffset(void)
This inline function returns the maximum offset value. This is used to
determine the maximum location of the elevator button.
PegScrollInfo *GetScrollInfo()
This inline function can be called to retrieve the current scroll bar
information.
void Reset()
virtual void Reset(PegScrollInfo *pSi)
These functions are provided so that the scroll bar position can be
recalculated or reset at any time. The first form is used with nonclient scroll
bars, and the second form is used with client-area scroll bars that are under
program control.
2.21 PegScrollPrompt
2.21.1 Overview
PegScrollPrompt is a PegPrompt-derived object that supports scrolling the
text as well as assigning bitmaps to the left side, right side, and
background.
The font used by PegScrollPrompt can be changed at any time by using the
SetFont() function, which is a PegTextThing member function. Likewise,
the color used by PegScrollPrompt can be set at any time by calling the
SetColor() function.
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
TJ_RIGHT Right justified text
TJ_LEFT Left justified text
TJ_CENTER Centered text
2.21.4 Signals
In addition to the common signals defined by PegThing, PegScrollPrompt
supports the PSF_CLICKED, PSF_FOCUS_RECEIVED and
PSF_SCROLL_COMPLETE signal notifications.
2.21.5 Derivation
PegScrollPrompt is derived from PegPrompt.
2.21.6 Constructors:
PegScrollPrompt(const PegRect &Rect, PEGINT StringId =
0, PEGUSHORT Id = 0, PEGULONG Style = FF_NONE|
TJ_LEFT|AF_TRANSPARENT|SP_ALWAYS)
PegScrollPrompt(const PEGCHAR *pText, const PegRect
&Rect, PEGUSHORT Id = 0, PEGULONG Style =
FF_NONE|TJ_LEFT|AF_TRANSPARENT|SP_ALWAYS)
There are two PegScrollPrompt constructors. The first constructor is used
for string IDs. The second constructor is used with string pointers, for when
a dynamic string is created at run time.
2.22 PegSlider
2.22.1 Overview
PegSlider is an analog adjustment control. The end user adjusts the slider
value by dragging the slider ‘handle.’ PegSlider can be positioned
horizontally or vertically. The orientation is determined by the style flags.
PegVScroll
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
SF_SNAP Snaps the slider handle to the exact tick
positions.
SS_ORIENTVERT Determines orientation. If this is used, the slider
is vertically oriented. Otherwise, it is horizontal.
2.22.4 Signals
PegSlider sends PSF_SLIDER_CHANGE signals to the slider parent when
adjusted by the end user. The message contains the following values:
2.22.5 Derivation
PegSlider is derived from PegThing.
2.22.6 Constructors:
PegSlider(const PegRect &Rect, PEGLONG Min, PEGLONG
Max, PEGUINT Id = 0, PEGULONG Style = FF_RAISED,
PEGLONG Scale = -1)
The PegSlider constructor creates a PegSlider control at the position and
size specified in Rect. The Min and Max values specify the initial limits of
the slider. The slider ID, if non-zero, enables the PSF_SLIDER_CHANGE
notification signal. The slider scale determines the interval between slider
tickmarks.
PEGINT mMax
This is the maximum value for the slider.
PEGINT mMin
This is the minimum value for the slider.
PEGINT mScale
This is the slider tickmark interval.
2.22.9 Examples:
The following are each different styles of PegSlider:
The following function creates a PegSlider. The slider will be vertical, and
will have a minimum value of 0, a maximum value of 200, and a tick mark
interval of 20 (i.e. 10 tickmarks will be drawn). This initial slider value will be
50.
void MyWindow::AddSlider(void)
{
PegRect SliderRect;
SliderRect.Set(20, 20, 60, 120);
PegSlider *pSlider = new PegSlider(SliderRect, 0, 200,
ID_SLIDER, FF_RAISED|SS_ORIENTVERT, 20);
pSlider->SetCurrentValue(50);
Add(pSlider);
}
2.23 PegSpinButton
2.23.1 Overview
PegSpinButton is a thumbwheel style control that is normally used to adjust
a numeric value displayed in an adjacent object. PegSpinButton objects
can be horizontal or vertical in orientation.
There are two forms of PegSpinButton. The first form is created when the
spin button has a 'buddy' object. A buddy object is a PegTextThing-derived
object that is automatically updated as the spin button is manipulated by the
end user. The second form of PegSpinButton has no buddy object, and
therefore reports spin button selection to the parent window for application-
level processing.
When a spin button has a buddy object, that object should be designed to
display a numeric value. When the spin button is operated by the end user,
the spin button first converts the buddy object string to an integer, then
increments or decrements the integer value as required. It then converts
the integer value back to a string for assignment to the buddy object.
The buddy object, if any, is required to have TT_COPY style. This is required
because the string value assigned to the buddy object is dynamically
constructed. If the buddy object does not have TT_COPY style, this style is
added automatically by the spin button object.
PegTextThing
2.23.4 Signals
If a PegSpinButton has a non-zero ID value, it sends PSF_SPIN_MORE and
PSF_SPIN_LESS signals to the parent window as the spin button is selected
by the end user.
2.23.5 Derivation
PegSpinButton is derived from PegThing.
2.23.6 Constructors:
PegSpinButton(const PegRect &Rect, PEGUINT Id = 0,
PEGULONG Style = AF_ENABLED|SB_VERTICAL)
This constructor is used to create a PegSpinButton that has no buddy
object. This spin button will send notification signals to the parent object as
the spin button is operated.
PEGLONG mMax
This is the maximum value for the spinner.
PEGLONG mMin
This is the minimum value for the spinner.
PegTextThing *mpSlave
This is a pointer to the text object that will display the current value.
2.23.9 Examples:
The following illustrates a vertical PegSpinButton with a PegPrompt buddy
object:
ChildRect.Left = pPrompt->mReal.Right + 1;
ChildRect.Right = ChildRect.Left + PEG_SCROLL_WIDTH;
PegSpinButton *pSpin = new PegSpinButton(ChildRect,
pPrompt, 20, 80, 5, 0, SB_VERTICAL);
Add(pSpin);
}
2.24 PegStatusBar
2.24.1 Overview
PegStatusBar is a window decoration that automatically sizes and positions
itself at the bottom of the client area of its parent. PegStatusBar may have
any number of children. Since the PegPrompt object is the most common
type of child object added to a status bar, the PegStatusBar class includes
functions for easily displaying and accessing any number of PegPrompt
objects.
PegPrompt
2.24.4 Signals
PegStatusBar does not send signals. However, children of the status bar
will send the normal signals supported by the child object types.
PegStatusBar will pass any signal received on to the parent window.
2.24.5 Derivation
PegStatusBar is derived from PegThing.
2.24.6 Constructors:
PegStatusBar(void)
This constructor creates a PegStatusBar. The status bar is normally added
to a PegDecoratedWindow or PegDialog.
2.24.9 Examples:
The following is a PegStatusBar with several text fields, added to a
PegDecoratedWindow:
The following function creates a PegStatusBar with three text fields, and
adds the status bar to a parent window.
void MyWindow::AddStatusBar(void)
{
PegStatusBar *pStat = new PegStatusBar();
pStat->AddTextField(100, ID_FIELD1, "Fixed Field 1");
pStat->AddTextField(100, ID_FIELD2, "Fixed Field 2");
pStat->AddTextField(20, ID_FIELD3, "Variable Field 3");
Add(pStat);
}
Any field in the status bar created above can be updated using the following
code sequence:
2.25 PegTextButton
2.25.1 Overview
PegTextButton provides a pushbutton object with visual feedback indicating
to the user the button depress and release operation.
The text string displayed on the button face is vertically centered over the
button client area, and may be horizontally justified in different ways using
the text justification style flags.
PegIconButton
PegBitmapButton
PegRadioButton
PegCheckBox
2.25.4 Signals
PegTextButton sends PSF_CLICKED signals when selected.
2.25.5 Derivation
PegTextButton is derived from PegButton and PegTextThing.
2.25.6 Constructors:
PegTextButton(const PegRect &Rect, PEGUINT StringId =
0, PEGUSHORT Id = 0, PEGULONG Style = AF_ENABLED|
FF_RAISED)
PegTextButton(const PEGCHAR *pText, const PegRect
&Rect, PEGUSHORT Id = 0, PEGULONG Style =
TT_COPYAF_ENABLED|FF_RAISED)
The first constructor is used to specify the string ID for the text. The second
constructor is used when a string pointer is all that is available.
2.25.8 Examples:
The following are each different styles of PegTextButton:
Brush.Width = 3;
Brush.Width = 1;
PegPoint Put;
Put.x = (mClient.Left + mClient.Right) >> 1;
Put.x -= TextWidth(mpText, FID_SYSFONT) >> 1;
Put.y = mClient.Top + 1;
2.26 PegTitle
2.26.1 Overview
PegTitle is a window decoration that automatically sizes and positions itself
at the top of the client area of its parent. PegTitle automatically adds
various common control buttons to itself depending on the title style flags.
PegTitle also adds the functionality of dragging the parent window. PegTitle
checks the parent window PSF_MOVEABLE system flag in order to provide
this capability.
PegDialog
2.26.4 Signals
PegTitle does not send signals. However the system menu associated with
the title bar will send signals to the parent window.
2.26.5 Derivation
PegTitle is derived from PegTextThing.
2.26.6 Constructors:
PegTitle(PEGINT StringId, PEGULONG Style =
TF_SYSBUTTON|TF_MINMAXBUTTON|TF_CLOSEBUTTON)
PegTitle(const PEGCHAR *pText, PEGULONG Style =
TT_COPY|TF_SYSBUTTON|TF_MINMAXBUTTON|
TF_CLOSEBUTTON)
This constructor creates a PegTitle. The default style is to include all
available title buttons. The second constructor adds the style TT_COPY as
a default because if the text is created dynamically, it will typically need to
make its own copy of it.
2.26.9 Examples:
The following is a PegTitle added to a PegDialog window:
void MyWindow::AddTitle(void)
{
PegTitle *pTitle = new PegTitle("Hello World",
TF_SYSBUTTON|TF_CLOSEBUTTON);
pTitle->AssignMenu(SystemMenu);
Add(pTitle);
}
2.27 PegToolBar
2.27.1 Overview
PegToolBar is a window decoration used to position and display a group of
related user objects. These objects could be text or bitmap buttons, user
input fields, or any other objects that represent frequently used commands
or user data that does not lend itself well to a menu. PegToolBar is
designed to work in conjunction with PegDecoratedWindow objects.
PegToolBar may be added to any type of object. However, the client area
of objects other than PegDecoratedWindow will not properly be reduced
unless this is done in the application software.
Also, for example, say you have a PegMenuButton (on the window's menu)
and a PegIconButton (on the window's tool bar) that share a common ID.
Whichever is selected by the end user, the same code will be executed.
This makes it very easy to put frequently used commands on a tool bar, and
also have them on the menu.
2.27.4 Signals
None.
2.27.5 Derivation
PegToolBar is derived from PegThing.
2.27.6 Constructors:
PegToolBar(PEGUSHORT Id = 0)
The PegToolBar constructor creates a PegToolBar object. PegToolBar
automatically determines its position and size.
2.27.9 Examples:
The following is an example of two PegDecoratedWindows with
PegToolBars and PegToolBarPanels. Note that there are three
PegToolBarPanels on the top window and that there are two
PegToolBarPanels on the second window. Note also that the PegThing-
derived objects are added to the PegToolBarPanels, not to the PegToolBar
itself.
PegRect Rect;
PegToolBarPanel *pPanel = new PegToolBarPanel();
Rect.Set(0, 0, 70, 20);
pPanel->Add(new PegTextButton(Rect, "Remove It ->",
IDB_ALPHA_BUTTON));
Rect.Set(0, 0, 20, 20);
2.28 PegToolBarPanel
2.28.1 Overview
PegToolBarPanel is a container object that is used in conjunction with
PegToolBar. Any PegThing-derived object may be placed on a
PegToolBarPanel. As the objects are added, the panel positions the objects
from left to right. The panel also resizes itself to the tallest child that is
added to the panel. Objects that are smaller in height to the tallest object
are placed at the top of the panel's client area.
2.28.4 Signals
None.
2.28.5 Derivation
PegToolBarPanel is derived from PegThing.
2.28.6 Constructors:
PegToolBarPanel(PEGUSHORT Id = 0)
The PegToolBarPanel constructor creates a PegToolBarPanel object. The
size of the panel is determined by its child objects. Its position on the
PegToolBar is determined when it is added to the PegToolBar.
2.28.9 Examples:
The following is an example of two PegDecoratedWindows with
PegToolBars and PegToolBarPanels. Note that there are three
PegToolBarPanels on the top window and that there are two
PegToolBarPanels on the second window. Note also that the PegThing
derived objects are added to the PegToolBarPanels, not to the PegToolBar
itself.
PegRect Rect;
PegToolBarPanel *pPanel = new PegToolBarPanel();
Rect.Set(0, 0, 70, 20);
pPanel->Add(new PegTextButton(Rect, "Remove It ->",
IDB_ALPHA_BUTTON));
Rect.Set(0, 0, 20, 20);
2.30 PegTransIcon
2.30.1 Overview
PegIcon is a simple bitmap display object. PegIcon can also be used to
represent another object.
PegThing
2.11.4 Signals
None.
2.11.5 Derivation
PegIcon is derived from PegThing.
2.11.6 Constructors:
PegIcon(PegThing *pProxy, PEGINT BitmapId = 0, PEGUINT
Id = 0, PEGULONG Style = FF_NONE)
PegIcon(const PegRect &Where, PEGINT BitmapId = 0,
PEGUINT Id = 0, PEGULONG Style = FF_NONE)
PegIcon(PEGINT BitmapId = 0, PEGUINT Id = 0, PEGULONG
Style = FF_NONE)
The first constructor creates a PegIcon that represents or serves as a proxy
for another object. The second and third constructors create a PegIcon that
will simply display a bitmap. The second constructor allows the caller to
specify the icon size and position. The third constructor allows the icon to
self determine the overall icon size to match the bitmap size. When the third
constructor is used, the application software may immediately use the
Resize() function to position the icon.
2.29 PegVScroll
2.29.1 Overview
PegVScroll is a vertical scroll bar class. The scroll bar elevator is
proportional to the visible area of the object being scrolled.
PegVScroll takes two forms. The most common form is a NONCLIENT area
scroll bar. In this form, PegVScroll calls the parent window GetVScrollInfo
function to determine position, size, and limit information. An instance of
this form of PegVScroll has PSF_NONCLIENT system status.
The second form is a client area scroll bar. This form does not have
PSF_NONCLIENT system status. This type of scroll bar is under system
software control, and does not attempt to automatically determine position
and limit information.
PegHScroll
PegScroll
PegSlider
2.29.4 Signals
PegVScroll sends PSF_SCROLL_CHANGE signals when the position of the
scroll bar elevator is changed either by dragging the elevator or by selecting
the directional scroll buttons. The signal message contains the following
information:
2.29.5 Derivation
PegVScroll is derived from PegScroll.
2.29.6 Constructors:
PegVScroll(PegScrollDrawInfo *pDrawInfo = NULL)
PegVScroll(const PegRect &InRect, PegScrollInfo *pSi,
PEGUINT Id = 0, PegScrollDrawInfo *pDrawInfo =
NULL)
The first constructor creates a non-client area scroll bar. The scroll bar will
automatically determine its position and size itself to the height of the
parent window.
The second constructor creates a client area scroll bar. In this mode, a
pointer to a PegScrollInfo structure is passed to setup the initial scrolling
range. In this mode, the scroll bar position and size are passed to the
constructor along with the scroll bar ID, if any.
PegIconButton *mpDownButton
This is the down arrow button.
PeScrollButton *mpScrollButton
This is the elevator button that moves up and down inside the scroll bar.
PegIconButton *mpUpButton
This the up arrow button.
2.29.9 Examples:
The following are examples of PegVScroll:
void MyWindow::AddVScroll(void)
{
PegScrollInfo si;
si.Min = 0;
si.Max = 200;
si.Current = 100;
si.Step = 1;
si.Visible = 50;
PegRect ScrollRect;
ScrollRect.Set(10, 10, PEG_SCROLL_WIDTH + 10, 80);
2.30 PegVPrompt
2.30.1 Overview
PegVPrompt (Peg Vertical Prompt) is a text display object. PegVPrompt
can be drawn with several different border styles, and can be updated
dynamically for interactive updates or real-time information display.
PegVPrompt does not support user editing.
The PegVPrompt text is centered both horizontally and vertically within the
prompt client area.
The font used by PegVPrompt can be changed at any time by using the
SetFont() function, which is a PegTextThing member function. Likewise,
the color used by PegVPrompt can be set at any time by calling the
SetColor() function.
PegPrompt
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
TJ_RIGHT Right justified text
TJ_LEFT Left justified text
TJ_CENTER Centered text
2.30.4 Signals
In addition to the common signals defined by PegThing, PegVPrompt
supports the PSF_CLICKED signal notification.
2.30.5 Derivation
PegVPrompt is derived from PegPrompt.
2.30.6 Constructors:
PegVPrompt(const PegRect &Rect, PEGUINT StringId = 0,
PEGUSHORT Id = 0, PEGULONG Style = FF_NONE|
AF_TRANSPARENT)
PegVPrompt(const PEGCHAR *pText, const PegRect &Rect,
const PEGCHAR *pText, PEGUSHORT Id = 0, PEGULONG
Style = FF_NONE|AF_TRANSPARENT)
The PegVPrompt constructor accepts a rectangle describing the prompt
position and size, a pointer to or an ID for the initial text value, and optional
object ID and style flags.
2.30.8 Examples:
The following are examples of PegVPrompt:
3.1 PegBmpConvert
3.1.1 Overview
PegBmpConvert is a PegImageConvert-derived class for reading and
decompressing MS Windows or OS/2 BMP graphics files. Before using
PegBmpConvert, be sure to read fully the PegImageConvert base class
documentation.
PegImageConvert
PegJpgConvert
PegPngConvert
PegQuant
3.1.3 Derivation
PegBmpConvert is derived from PegImageConvert.
3.1.4 Constructors:
PegBmpConvert(PEGUINT Id = 0)
This constructor creates a bitmap conversion object.
typedef struct
{
PEGUSHORT id;
PEGULONG file_size;
PEGUSHORT reserved[2];
PEGULONG image_offset;
PEGUSHORT header_size;
PEGUSHORT not_used;
PEGULONG xres;
PEGULONG yres;
PEGUSHORT numplanes;
PEGUSHORT bits_per_pix;
PEGULONG compression;
PEGULONG bit_map_size;
PEGULONG hor_res;
PEGULONG vert_res;
PEGULONG number_of_colors;
PEGULONG num_sig_colors;
} BmpHeader;
virtual PEGBOOL GetImageInfo(PegFile *pSrc,
PegImageInfo *pInfo)
This reads the header of an image file and populates a PegImageInfo
structure with the height, width, and bits per pixel of the image.
struct PegImageInfo {
PEGINT Width;
PEGINT Height;
PEGINT BitsPerPix;
};
The caller is responsible for allocating the structure. When the function is
finished, it resets the file pointer to the beginning of the file. This function is
only available if PIC_FILE_MODE is turned on.
3.1.6 Examples:
A complete working example program using the run-time image conversion
classes is provided in your PEG distribution in the directory \peg\
examples\imgview.
3.2 PegGifConvert
3.2.1 Overview
PegGifConvert is a PegImageConvert-derived class for reading and
decompressing GIF input images. Before using PegGifConvert, be sure to
read fully the PegImageConvert base class documentation.
** WARNING **
At the time of this printing, LZW usage licenses are available from Unisys
for a royalty charge of 0.45% (forty five one-hundredths of one percent) or
PegImageConvert
PegJpgConvert
PegPngConvert
PegQuant
3.2.3 Derivation
PegGifConvert is derived from PegImageConvert.
3.2.4 Constructors:
PegGifConvert(PEGUINT Id = 0)
This constructor creates an image conversion object.
GIF_HEADER *GetGifHeader(void)
This function returns a pointer to the GIF file header information. This can
be used to determine additional information about the decoded GIF. There
is one GIF_HEADER structure produced for each GIF file converted. The
GIF_HEADER structure is deleted when the PegGifConvert object is
destroyed. The GIF header information structure is defined as:
typedef struct {
PEGUINT Width; // overall width
PEGUINT Height; // overall height
PEGUINT Colors;
GIF_IMAGE_INFO *GetGifInfo(void)
This function is used to retrieve a pointer to the array of GIF information
structures produced during image conversion. There will be one element in
the array for each image converted, i.e. one GIF file may contain any
number of images and the equivalent number of GIF_IMAGE_INFO
structures will be produced. The GIF_IMAGE_INFO structures define local
information for each embedded image such as size, relative offset, and
delay time. The GIF_IMAGE_INFO structure is defined as:
typedef struct {
PEGINT xOffset; // relative x offset
PEGINT yOffset; // relative y offset
PEGUINT Width; // width in pixels
PEGUINT Height; // height in pixels
PEGUINT Delay; // delay in hundredths of a second
PEGUBYTE HasTrans;
PEGUBYTE TransColor;
PEGUBYTE InputFlag; // wait for user input?
PEGUBYTE Disposal; // image overwrite method
} GIF_IMAGE_INFO;
After your application has completed using the image data produced by the
conversion object, you must delete the GIF_IMAGE_INFO structures with a
call to the DestroyImages() function to avoid a memory leak.
PEGBOOL ReadFrame(void)
GIF images can be animated by using multiple frames. This function reads
in one individual frame and converts it into a PegBitmap.
3.2.6 Examples:
A complete working example program using the run-time image conversion
classes is provided in your PEG distribution in the directory \peg\
examples\imgview.
3.3 PegImageConvert
3.3.1 Overview
PegImageConvert is the base class used to provide the image
decompression and other processing used by the PEG utility program of
the same name. PegImageConvert serves as the base class for
PegBmpConvert, PegGifConvert, PegJpgConvert, and PegPngConvert
classes. These classes provide the ability to read, color quantize, RLE
encode, and generate PegBitmap-formatted data structures at program run
time.
The image conversion classes are designed to run either standalone using
file input, or under separate low-priority execution threads. There are
definitions in the file \peg\include\pconfig.hpp that specify how the
image conversion classes are going to be used.
One of the jobs of the image conversion class is to map the input file colors
to the target system display capabilities. There are also two basic color
mapping modes that can be used by the conversion object. These mapping
modes are referred to as ‘inline’ mode and ‘post-read’ mode. In inline
remapping mode, the converter reads and decompresses one scanline of
input data to a temporary buffer and remaps this single row to the target
colors or grayscale. This process continues on a line-by-line basis until the
entire image has been remapped to the target system palette. The benefit
of this conversion mode is that only a single-line temporary buffer is
required in addition to the final output data array. As a result, this
conversion mode uses less dynamic memory than post-read conversion.
Please note, however, that inline conversion mode requires that the input
data is scan-line oriented and not interlaced. For this reason, inline
conversion mode cannot be used with interlaced PNG input files, which use
an interlace format that is not scan-line oriented.
Post-read conversion means that the entire input image is read into a
temporary buffer, and the image is then color mapped into the final output
buffer. This conversion mode can require much more memory than inline
conversion, especially for cases when high color depth (i.e. 24bpp) images
are being remapped to lower color depth target displays which may require
less than 8 bpp output in the final buffer. Post-read conversion has the
beneficial capability of producing an optimal color palette for 8 bpp paletted
systems. It is also able to handle interlaced PNG files.
** Important Note **
The PegBitmap structures created by the conversion object are not
deleted when the object is destroyed. Under normal operation, the caller
retrieves the bitmaps after conversion by calling the GetBitmapPointer()
function. The caller then owns the memory associated with the bitmaps,
and must free this memory after the bitmaps are no longer needed.
If the caller does not retrieve the PegBitmap structures, they should be
deleted with a call to DestroyImages() before deleting the conversion
object. This can be useful in an application where you do not actually want
to display the images, but you do need to obtain image size or other
attribute information. In this case, you can construct the conversion
object(s), tell them to read the image, retrieve whatever information is
required, and then call DestroyImages() to clean up the memory
associated with the conversion objects.
PegGifConvert
PegJpgConvert
PegPngConvert
PegQuant
3.3.3 Derivation
PegImageConvert is a PEG base class.
3.3.4 Constructors:
PegImageConvert(PEGUINT Id)
This constructor creates an image conversion object.
void DestroyImages(void)
This function can be called to destroy all PegBitmap images created by the
conversion object. This should only be done if the caller does not want to
keep and use the PegBitmaps produced.
PEGUINT GetBitmapCount(void)
This inline function can be called to learn the number of PegBitmap
structures produced during the image read operation. GIF files can contain
any number of individual images.
PEGCHAR *GetErrorString(void)
This function returns the error string associated with a conversion failure.
This value is only valid if the conversion object state variable indicates that
an error has occurred.
struct PegImageInfo {
PEGINT Width;
PEGINT Height;
PEGINT BitsPerPix;
};
The caller is responsible for allocating the structure. When the function is
finished, it resets the file pointer to the beginning of the file. This function is
only available if PIC_FILE_MODE is turned on.
When the function is finished, it resets the file pointer back to the beginning
of the file.
PEGUINT GetMode(void)
Returns the operating mode of the conversion object. The operating mode
is determined by the caller when configuring the conversion object. The
available modes are:
PEGUBYTE GetOutputBitsPerPix(void)
This function returns the output color depth determined by the system
palette assigned to the conversion object.
PEGUINT GetRowsConverted(void)
Returns the number of rows that have been converted so far.
PegPixel GetTransColor(void)
Returns the transparent color value.
PegPixel GetULCColor(void)
Returns the upper-left hand corner color of the first bitmap.
PEGUINT Id(void)
Returns the ID of the conversion object. This is a caller-defined value used
to identify a particular converter when many conversions are occurring
concurrently.
PEGUBYTE ImageType(void)
Returns the image type processed by the conversion object. The supported
image types are:
PIC_TYPE_BMP
PIC_TYPE_GIF
PIC_TYPE_JPG
PIC_TYPE_PNG
PEGBOOL RemapBitmap(void)
This function is called to do a best-color mapping of the bitmap to a fixed
system palette. The SetSystemPalette() function must be called before
RemapBitmap(). This function does no dithering; instead, it uses a closest-
match algorithm. This is useful when an optimal palette has been
generated.
The callback function should be structured such that it tests the conversion
object state variable to determine the reason for the callback. If the
conversion object needs data, the callback function should provide it by
calling the conversion object SendData() function. The state variable may
also indicate that conversion is complete or that an error has occurred.
The State value is a bitwise OR of the status flags defined above under the
GetState() function.
3.3.7 Examples:
A complete working example program using the run-time image conversion
classes is provided in your PEG distribution in the directory \peg\
examples\imgview.
3.4 PegJpgConvert
3.4.1 Overview
PegJpgConvert is a PegImageConvert-derived class for reading and
decompressing JPG input images. Before using PegJpgConvert, be sure to
read fully the PegImageConvert base class documentation.
PegGifConvert
PegImageConvert
PegPngConvert
PegQuant
3.4.3 Derivation
PegJpgConvert is derived from PegImageConvert.
3.4.4 Constructors:
PegJpgConvert(PEGUINT Id = 0)
This constructor creates an image conversion object.
The caller is responsible for allocating the structure. When the function is
finished, it resets the file pointer to the beginning of the file. This function is
only available if PIC_FILE_MODE is turned on.
3.4.6 Examples:
A complete working example program using the run-time image conversion
classes is provided in your PEG distribution in the directory \peg\
examples\imgview.
3.5 PegPngConvert
3.5.1 Overview
PegPngConvert is a PegImageConvert-derived class for reading and
decompressing PNG input images. Before using PegPngConvert, be sure
to read fully the PegImageConvert base class documentation.
PegGifConvert
PegImageConvert
PegJpgConvert
3.5.3 Derivation
PegPngConvert is derived from PegImageConvert.
3.5.4 Constructors:
PegPngConvert(PEGUINT Id = 0)
This constructor creates an image conversion object.
The caller is responsible for allocating the structure. When the function is
finished, it resets the file pointer to the beginning of the file. This function is
only available if PIC_FILE_MODE is turned on.
3.5.6 Examples:
A complete working example program using the run-time image conversion
classes is provided in your PEG distribution in the directory \peg\
examples\imgview.
3.6 PegQuant
3.6.1 Overview
PegQuant is a run-time histogram and optimal palette producer. PegQuant
implements a form of Heckbert's Median Cut color-reduction algorithm. This
class is only required for applications that must determine dynamic optimal
palettes. Most applications run with fixed palettes. PegQuant is passed to
PegImageConvert-derived classes to create a histogram of color usage.
After all included images have been added, the PeqQuant function
ReduceColors is called to create an optimal palette for use with the
scanned images.
PegBmpConvert
PegGifConvert
PegJpgConvert
3.6.3 Derivation
PegQuant is a PEG base class.
3.6.4 Constructors:
PegQuant(void)
Creates a PegQuant object.
PEGUBYTE *GetPalette(void)
Returns a pointer to the optimal color palette produced from the image color
sums.
3.6.6 Examples:
The following example reads several graphic files and creates an optimal
palette for use in displaying the files. The palette is then installed as the
new system palette. This example runs in PIC_FILE_MODE.
void MyWindow::CreatePalette(void)
{
PeqQuant *pQuant = new PegQuant();
delete pQuant;
}
pConvert->ReadImage(&Src);
pConvert-
>CountColors(pQuant);
pConvert->DestroyImages();
delete pConvert;
Src.Close();
}
4.1 PegAnimationWindow
4.1.1 Overview
PegAnimationWindow is a window class for displaying a series of
PegBitmap images. If these images are displayed in rapid sequence, the
effect of smooth motion animation is produced.
An x and y offset value may be specified for the animation window. This
value indicates the offset from the window origin to the display of the
animation frames. This allows the animation frames to be part of a larger
background bitmap. Note that each animation frame must be displayed in
the same relative position; i.e., there are no unique offset values for each
frame.
FF_NONE No Frame
4.1.4 Derivation
PegAnimationWindow derives from PegWindow.
4.1.5 Constructors:
PegAnimationWindow(const PegRect &Rect, PEGINT BkgBmp,
PEGINT *pFrameList, PEGUBYTE NumFrames, PEGINT
xPos, PEGINT yPos, PEGUBYTE *pPalette = NULL,
PEGULONG Style = FF_NONE)
Creates an animation window of the specified size at the specified position.
BkgBmp is the ID of the background bitmap for the animation. BkgBmp may
be -1 if no background is desired.
xPos and yPos indicate the upper-left corner position at which the
animation frames will be displayed. This allows the animation window to be
larger than, and offset relative to, the actual animation bitmaps.
Style is used to set the frame style for the animation window. The default
is to display no frame, allowing the animation window to be placed within a
larger parent window and provide a seamless animation appearance.
4.1.8 Examples:
An example of creating and using PegAnimationWindow can be found in
your PEG distribution. The directory \peg\examples\robot contains a
sample application that uses the PegAnimationWindow class.
4.2 PegComboBox
4.2.1 Overview
PegComboBox is similar to PegVertList. PegComboBox is a container that
can have any type of object added to it. PegComboBox adds the concept of
‘Opening and Closing,’ which can conserve space when a large number of
items are added to the combo box. A drop-down arrow is provided to open
the combo box. The box closes when an item is selected or the combo box
loses focus.
The LAST child added to the combo box will be displayed at the TOP of the
combo box if the Add() function is used to add children. The order of
display can be reversed by using the function AddToEnd() to add children
to the combo box.
If PegPrompt objects are added to a PegComboBox, the style flags for the
PegPrompt objects should include FF_NONE|AF_ENABLED for correct
display. Normally PegPrompt objects are not selectable (i.e. the
AF_ENABLED style is not used). However, when PegPrompt objects are
added to a PegComboBox, the style should be set as shown above so that
the prompt objects can be selected.
PegHorzList
PegWindow
FF_NONE No Frame
4.2.4 Signals
PegComboBox sends PSF_LIST_SELECT signals to the parent object. This
message contains:
4.2.5 Derivation
PegComboBox derives from PegThing.
4.2.6 Constructors:
PegComboBox(const PegRect &Rect, PEGUSHORT Id = 0,
PEGULONG Style = FF_THIN)
This constructor creates a PegComboBox object. The Rect parameter
determines the height of the combo box when open. The closed height is
determined by the height of the individual combo box children.
void CloseList(void)
This function closes the combo box list and displays the currently selected
item.
PEGINT GetCloseHeight(void)
This returns the height of the combo box when it is closed.
ComboList *GetListPointer(void)
This returns a pointer to the vertical list member.
PEGINT GetNumItems(void)
This returns the number of items in the list.
PEGINT GetOpenHeight(void)
This inline function returns the height of the combo box when open.
PEGBOOL IsOpen(void)
This inline function returns TRUE if the combo box is currently open,
otherwise FALSE.
void OpenList(void)
This function is used to open the combobox by adding the list to the
Presentation.
PegThing *PageDown(void)
If the list is open, this function scrolls down one page length.
PegThing *PageUp(void)
If the list is open, this function scrolls up one page length.
PegThing *SelectNext(void)
This function selects the next object in the list. If the currently-selected
object is already at the bottom, it does nothing.
PegThing *SelectPrevious(void)
This function selects the previous object in the list. If the currently-selected
object is already at the top, it does nothing.
PEGINT mOpenHeight
The height of the combo box when open.
PEGINT mCloseHeight
The height of the combo box when closed.
ComboList *mpList
This is the list that displays all the items in the combobox.
PegIconButton *mpOpenButton
This is the button on the combobox that opens the list.
4.2.9 Examples:
The following are examples of PegComboBox:
void MyWindow::AddComboBox(void)
{
PegRect ListRect;
ListRect.Set(10, 10, 90, 150);
PEGCHAR Temp[20];
PegStrCpy(Temp, "Select");
pList = new PegComboBox(ListRect);
pList->SetScrollMode(WSM_VSCROLL);
pList->SetSelected(5);
Add(pList);
}
4.3 PegDecoratedWindow
4.3.1 Overview
PegDecoratedWindow is a PegWindow-derived class that supports the
addition of common window decorations such as PegTitle, PegMenuBar,
and PegStatusBar. PegDecoratedWindow provides functions to facilitate
easy access to the decorations added to a window. PegDecoratedWindow
also maintains the actual client area available after the addition or removal
of any of these decorations.
Like all PEG objects, PegDecoratedWindow can also have any other type
of child objects added to it. The PegDecoratedWindow objects can even be
nested within themselves, creating complex and interesting window types.
PegDialog
PegMessageWindow
PegMLMessageWindow
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
4.3.4 Derivation
PegDecoratedWindow derives from PegWindow.
4.3.5 Constructors:
PegDecoratedWindow(const PegRect &Rect, PEGULONG Style
= FF_THICK)
PegDecoratedWindow(PEGULONG Style = FF_THICK)
There are two constructors available for PegDecoratedWindow. The first
defines the window size and position at the time the window is created. The
second requires that the window size and position be determined after the
window is constructed but before the window is displayed.
PegMenuBar *MenuBar(void)
This function returns a pointer to the PegMenuBar added to the window, or
NULL if no menu bar is present.
PegTitle *TitleObject(void)
This function returns a pointer to the decorated window title, or NULL if no
title is present.
PegToolBar *ToolBar(void)
This function returns a pointer to the PegToolBar added to the window, or
NULL if no toolbar is present.
4.3.7 Examples:
The following is a decorated window with a title bar, status bar, and menu
bar. The decorated window also contains a PegWindow child in the
decorated window client area. The full source code for this window can be
found in the file \peg\examples\pegdemo\pegdemo.cpp.
4.4 PegDialog
4.4.1 Overview
PegDialog is a PegDecoratedWindow class with added features to support
modal and nonmodal dialog window execution.
Dialog windows usually draw themselves with a different frame and client
color than other windows. Dialog windows may be executed as modal
windows by calling their member function Execute().
Dialog windows attach special significance to buttons with the following IDs:
IDB_CLOSE
IDB_OK
IDB_CANCE
L
IDB_ABORT
IDB_RETRY
IDB_YES
IDB_NO
IDB_APPLY
These button IDs are reserved by PEG and are found in the header file
pegtypes.hpp. When a button with one of the above ID values is selected,
the dialog will close. When defining a dialog window, you must ensure that
at least one button added to the dialog is constructed with one of the above
button ID values. Otherwise, the only way to close the dialog will be via
program intervention.
When any of the buttons listed above is selected, the dialog window will
send a PM_DIALOG_NOTIFY message to its parent window (or its ‘ReportTo’
window) to indicate that the dialog has been completed. The message
iData member will contain the ID of the button that caused the dialog to
close. In all cases except ID_APPLY, the dialog will close after the parent
window has received the PM_DIALOG_NOTIFY message.
In the case of a modal dialog, Execute() will return when any of these
messages are received, and the return value will be the ID of the button that
caused the dialog to close.
In the case that the user selects the IDB_APPLY button, the dialog will send
the PM_DIALOG_NOTIFY message to its parent without closing.
Swell Software, LLC Window Classes 231
Window Classes
PegDecoratedWindow
PegMessageWindow
PegMLMessageWindow
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
4.4.4 Derivation
PegDialog derives from PegDecoratedWindow.
4.4.5 Constructors:
PegDialog(const PegRect &Rect, PEGINT TitleStringId =
0, PegThing *pReportTo = NULL, PEGULONG Style =
FF_RAISED)
PegDialog(const PegRect &Rect, const PEGCHAR *pText,
PegThing *pReportTo = NULL, PEGULONG Style =
FF_RAISED)
PegDialog(PEGINT TitleStringId = 0, PegThing
*pReportTo = NULL, PEGULONG Style = FF_RAISED)
PegDialog(const PEGCHAR pText, PegThing *pReportTo =
NULL, PEGULONG Style = FF_RAISED)
There are four constructors available for PegDialog. The first two define the
window size and position at the time the window is created. The second two
4.4.7 Examples:
The following is a PegDialog window. The full source code for this window
can be found in the file \peg\examples\pegdemo\pegdemo.cpp.
4.5 PegEditBox
4.5.1 Overview
PegEditBox is a multi-line text display control that allows full user editing via
mouse and keyboard. PegEditBox is derived from PegTextBox and
therefore supports all of the functionality of this base class.
PegEditField
PegWindow
PegTextThing
PegTextBox
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
EF_EDIT When this style is applied, the user can edit the
PegTextBox object. If this style is applied the
PegTextBox object automatically includes the
TT_COPY style.
EF_WRAP When this style is applied, the text box will
wrap long lines to prevent them from being
clipped.
4.5.4 Signals
In addition to the common signals defined by PegThing, PegEditBox
supports the following signals:
4.5.5 Derivation
PegEditBox is derived from PegTextBox.
4.5.6 Constructors:
PegEditBox(const PegRect &Rect, PEGUINT StringId = 0,
PEGUSHORT Id = 0, PEGUSHORT Style = FF_RECESSED|
EF_EDIT|EF_WRAP, PEGUINT MaxChars = 1000)
PegEditBox(const PEGCHAR *pText, const PegRect &Rect,
PEGUSHORT Id = 0, PEGUSHORT Style = TT_COPY|
FF_RECESSED|EF_EDIT|EF_WRAP, PEGUINT MaxChars =
1000)
This constructor creates a PegEditBox. MaxChars is the maximum number
of characters that the text box will be required to support.
void CopyToScratchPad(void)
Copies the currently-selected text to the scratch pad.
void DeleteMarkedText(void)
Deletes the currently-selected text.
CURSOR_POS GetCursorRowCol(void)
This function returns a CURSOR_POS structure that contains the x and y
coordinates of the cursor. The y-coordinate represents the line number, and
the x-coordinate represents the number of characters from the beginning of
the line in which the cursor resides.
void HomeCursor(void)
This function moves the edit cursor to the column 0 position on the current
line.
PEGBOOL InEditMode(void)
Returns TRUE if the PegEditBox is in edit mode.
void PasteFromScratchPad(void)
Pastes the scratch pad text at the current cursor position.
PegPoint mCursorPos
The location of the cursor in (x, y) format.
4.5.9 Examples:
The following are each different styles of PegEditBox:
The complete source for the last example above can be found in the
example program \peg\examples\vecfont distributed with your PEG
release.
4.6 PegFileDialog
4.6.1 Overview
PegFileDialog is a utility class that supports the standard notion of browsing
a directory structure for a file name in the ‘File Open’ and ‘File Save As’
types of scenarios. Currently, the file system routines uses the generic
PegFile class (which gives it a degree of portability), as well as a few calls
that are specific to the Linux API (out of necessity).
The PegFileDialog was created out of a need for the PEG utility programs
(i.e. Window Builder, et al) to be able to run on the X Window System on
top of Linux. Since it has proven very useful to us, we have included it in the
PEG library to meet the needs of application developers who are creating
applications that require such functionality.
The class has all of the basics that make it useful, but it does not, at the
present time, have all of the luxuries that make it comparable to most
desktop implementations of the same types of dialogs.
It is important to note that the PegFileDialog does not actually change the
current working directory when the user navigates the file system. The file
routines simply keep track of the current directory and use this for finding
the files and directories within that directory. Therefore, you don't need to
worry about the dialog changing your application's present working
directory.
4.6.4 Signals
See PegDialog for a description of which signals are sent.
4.6.5 Derivation
PegFileDialog is derived from PegDialog.
4.6.6 Constructors:
PegFileDialog(const PEGSTRINGID TitleId, PEGINT Left =
-1, PEGINT Top = -1)
The constructor takes a constant PEGSTRINGID parameter that will be used
in the title of the dialog. It is usually a good idea to give the dialog box a title
that corresponds to the action that the user is performing (i.e. ‘File Open’).
The Left and Top parameters are needed if you would like to place the
dialog at a specific location on the screen. If you allow these parameters to
retain their default values, the dialog box will be centered on the screen.
Currently, it is not a good idea to assign the dialog box a size, since the
placement of the controls on the dialog expects the dialog to be a specific
size.
PEGINT GetOperation(void)const
This function returns the type of operation being performed. This method
will return PFD_FILEOPEN or PFD_FILESAVEAS.
PFD_FILEOPEN
PFD_FILESAVEA
S
At the present time, the dialog does not behave differently based on this
setting. But, for forward compatibility, it is best to specify the action you
intend.
The second parameter is the node in the directory structure where you
would like the dialog to start. In other words, the dialog will take this as its
present working directory. If running on Linux, you may want to start the
user out in his or her home directory. This can be accomplished like this:
pPasswd->pw_dir
Once you have set these parameters, you would then call the Execute
method and inspect the return value. If you receive a return value of
IDB_OK, then the full qualified name of the file (assuming the buffer did not
overrun) would be in pBuffer. If you receive a return value of IDB_CANCEL,
then the user canceled their selection and pBuffer is undefined.
4.6.8 Examples:
The following code snippet exemplifies how to create and use a
PegFileDialog object. Usage is very simple. All you need to do is create a
new instance of the dialog, allocate a buffer of sufficient size, set its
options, execute the dialog, and inspect the return value.
PEGCHAR Buffer[256];
PEGUINT BufSize = 256;
PEGINT RetVal;
if (pFD)
{
if (pPasswd)
{
pFD->SetOptions(PFD_FILEOPEN, pPasswd->pw_dir,
Buffer,
BufSize);
}
else
{
pFD->SetOptions(PFD_FILEOPEN, "/work", Buffer,
BufSize);
}
RetVal = pFD->Execute();
Starting with the toolbar, the button labeled ‘Up’ shifts the present working
directory up, if possible. The ‘Home’ button changes the present working
directory to the current user's home directory. The ‘Refresh’ button causes
the Directory and Files lists to be updated. And the ‘View’ button toggles the
The Directories and Files lists are fairly straightforward. The lists can be
independently sorted in ascending or descending order by the user clicking
on the Directories or Files label. You'll note the small triangles in the far
right of either label. These denote the sort order.
The ‘Selection’ label displays the current working directory. Once a file
name has been selected from the Files list, the file name is entered in the
edit field at the bottom. If the current working directory is changed, this file
name is cleared from the edit field control. It is important to note that the
PegFileDialog verifies that the file exists before it allows a file to be entered
here.
The OK button closes the dialog box with a return value of IDB_OK. The file
name is verified and put into the buffer that the application designer
provided in the SetOptions method. If the buffer is not large enough to hold
the entire file name, then PFD_ERROR is returned instead of IDB_OK. If the
Cancel button is pushed, then the dialog simply exits.
4.7 PegHorzList
4.7.1 Overview
PegHorzList is a container class for displaying a scrolling list of child
objects. PegHorzList automatically positions and sizes child objects. It is
therefore not necessary to manually position objects before adding them to
PegHorzList.
The LAST child added to the list will be displayed at the leftmost position in
the list if the Add() function is used to add children. The order of display
can be reversed by using the function AddToEnd() to add children to the
list.
Child objects are positioned when the list receives the PM_SHOW message,
which is a system message sent automatically when the list is first
displayed. PegHorzList sets the height of each child object to fit within the
horizontal list client area. The widths of child objects are not modified, and
should be set as desired when each child object is constructed.
PegList
PegWindow
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
The styles for PegHorzList are identical to the PegWindow styles. In
addition, scrolling is enabled in PegList in the same way as in PegWindow,
by using the SetScrollMode() function.
4.7.4 Signals
PegHorzList sends PSF_LIST_SELECT signals to the parent object. This
message contains:
4.7.5 Derivation
PegHorzList derives from PegList.
4.7.6 Constructors:
PegHorzList(const PegRect &Rect, PEGUINT Id = 0,
PEGULONG Style = FF_THIN)
This constructor creates a PegHorzList object. The Rect parameter
determines the position and size of the list. The list children are
automatically positioned by the list object.
4.7.9 Examples:
The following is a PegHorzList with PegTextButton children:
void MyWindow::AddHList(void)
{
PegRect Rect;
Rect.Set(10, 10, 180, 44);
pList->SetScrollMode(WSM_HSCROLL);
Add(pList);
}
4.8 PegList
4.8.1 Overview
PegList is a container class that serves as a base class for PegVertList and
PegHorzList. PegList positions child objects so that they are stacked left to
right or top to bottom. You would not normally create an instance of PegList
in your system software. However, several of the member functions are
important when working with derived PegHorzList and PegVertList classes.
The LAST child added to the list will be displayed at the leftmost or topmost
position in the list if the Add() function is used to add children. The order of
display can be reversed by using the function AddToEnd() to add children
to the list.
Child objects are positioned when the list receives the PM_SHOW message,
which is a system message sent automatically when the list is first
displayed. The position of children added to a list object may be any value,
including 0,0, as the list object will reposition objects to fit within the list
client area.
For vertical lists, child object's widths are also forced to match the list client
width. A child object's height is not modified, so this value is meaningful
when child objects are constructed.
Likewise for horizontal lists, child object's heights are forced to fit within the
list client area. Child object widths are not modified, and so this value
should be set as desired when list children are constructed.
PegHorzList
PegWindow
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
LS_WRAP_SELECT Wrap selection at top or bottom
The styles for PegList are identical to the PegWindow styles. In addition,
scrolling is enabled in PegList in the same way as in PegWindow, by using
the SetScrollMode() function.
4.8.4 Signals
PegList sends PSF_LIST_SELECT signals to the parent object. This
message contains:
4.8.5 Derivation
PegList derives from PegWindow.
4.8.6 Constructors:
PegList(const PegRect &Rect, PEGUINT Id = 0, PEGULONG
Style = FF_THIN)
This constructor creates a PegList object. The Rect parameter determines
the position and size of the list. The list children are automatically
positioned by the list object.
PEGINT GetNumItems(void)
This method returns the total number of child items in the list. The return
value is the total number of items, excluding scroll bars or other non-client
objects, if present.
PegThing *PageUp(void)
This function scrolls the PegList child items by one full page, meaning that
the first nonvisible item at the top or left of the list client area is scrolled into
view and selected. This function returns a pointer to the newly selected
item. This function is called by the PegList::Message function in response
to the PK_PGUP key message.
PegThing *SelectNext(void)
This function can be called to force the list to advance to the next child item.
The list will automatically scroll the newly selected child into view. If
LS_WRAP_SELECT is enabled, the list will wrap to the top item if
SelectNext() is called when the bottom item is selected.
PegThing *SelectPrevious(void)
This function can be called to force the list to back up to the previous child
item. The list will automatically scroll the newly selected child into view. If
LS_WRAP_SELECT is enabled, the list will wrap to the bottom item if
SelectPrevious() is called when the top item is selected.
4.9 PegMessageWindow
4.9.1 Overview
PegMessageWindow is a popup window class for display warning, error, or
other status information to the user.
PegDialog
PegMLMessageWindow
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
MW_OK This option displays an OK button on the
message window.
MW_YES This option displays a YES button on the
message window.
MW_NO This option displays a NO button on the
message window.
MW_ABORT This option displays an ABORT button on the
message window.
MW_RETRY This option displays a RETRY button on the
message window.
MW_CANCEL This option displays a CANCEL button on the
message window.
4.9.4 Derivation
PegMessageWindow derives from PegWindow.
4.9.5 Constructors:
PegMessageWindow(const PegRect &Rect, PEGINT
TitleStringId, PEGINT MessageId = 0, PEGULONG
Style = MW_OK|FF_RAISED, PEGINT IconId = 0,
PegThing *pOwner = NULL)
PegMessageWindow(PEGINT TitleStringId, PEGINT
MessageId = 0, PEGULONG Style = MW_OK|FF_RAISED,
PEGINT IconId = 0, PegThing *pOwner = NULL)
PegMessageWindow(const PEGCHAR *pTitle, const PEGCHAR
*pMessage, PEGULONG Style = TT_COPY|MW_OK|
FF_RAISED, PEGINT IconId = 0, PegThing *pOwner =
NULL)
There are three constructors available for PegMessageWindow. The first
constructor allows you to specify the overall message window size. This
constructor is used in cases where you would like to add additional
decorations to the message window.
The IconId parameter allows you to specify a bitmap that will be displayed
to the left of the text message.
The pOwner pointer allows you to specify a window that should receive a
PM_MWCOMPLETE message. This is only useful when the message window is
not executed modally. When the window is executed modally, the
Execute() function returns the ID of the button used to close the message
window.
4.9.7 Examples:
The following is a PegMessageWindow with OK, CANCEL, and RETRY
buttons.
The following function creates and modally executes the above message
window:
void MyWindow::ModalMessage(void)
{
PegMessageWindow *pWin = new PegMessageWindow(
"Example Message Window",
"This is a message window with a raised frame.",
MW_OK|MW_CANCEL|MW_RETRY|FF_RAISED);
Presentation()->Center(pWin);
Presentation()->Add(pWin);
pWin->Execute();
}
4.10 PegMLMessageWindow
4.10.1 Overview
PegMLMessageWindow is a popup window class for display warning, error,
or other status information to the user. The basic behavior of this class is
identical to the PegMessageWindow class, except that this class allows the
display of multiple lines of text in the message.
PegMessageWindow
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
MW_OK This option displays an OK button on the
message window.
MW_YES This option displays a YES button on the
message window.
MW_NO This option displays a NO button on the
message window.
MW_ABORT This option displays an ABORT button on the
message window.
MW_RETRY This option displays a RETRY button on the
message window.
MW_CANCEL This option displays a CANCEL button on the
message window.
4.10.4 Derivation
PegMLMessageWindow derives from PegWindow.
4.10.5 Constructors:
PegMLMessageWindow(const PegRect &Rect, PEGUINT
TitleStringId, PEGUINT MessageId = 0, PEGULONG
Style = MW_OK|FF_RAISED, PEGINT IconId = 0,
PegThing *pOwner = NULL)
PegMLMessageWindow(PEGUINT TitleStringId, PEGUINT
MessageId = 0, PEGULONG Style = MW_OK|FF_RAISED,
PEGINT IconId = 0, PegThing *pOwner = NULL)
PegMLMessageWindow(const PEGCHAR *pTitle, const
PEGCHAR *pMessage, PEGULONG Style = MW_OK|
FF_RAISED, PEGINT IconId = 0, PegThing *pOwner =
NULL)
There are three constructors available for PegMLMessageWindow. The
first constructor allows you to specify the overall message window size.
This constructor is used in cases where you would like to add additional
decorations to the message window.
If the size of the window is specified with a PegRect and the message text
is too large to fit in the available space, the sizing algorithm will grow the
height of the rectangle until all of the text fits properly. The left, top, and
right members of the specified rectangle will not change, only the bottom.
The IconId parameter allows you to specify a bitmap that will be displayed
to the left of the text message.
The pOwner pointer allows you to specify a window that should receive a
PM_MWCOMPLETE message. This is only useful when the message window is
not executed modally. When the window is executed modally, the
Execute() function returns the ID of the button used to close the message
window.
PegTextBox *GetTextBox(void)
Returns a pointer to the text box displaying the message. This is used to
edit any style parameters of the text box.
4.10.7 Examples:
For an example of using this class, please see the example in the
PegMessageWindow documentation.
4.11 PegNotebook
4.11.1 Overview
PegNotebook is a PegWindow-derived class for displaying and using a
tabbed notebook-style control. The notebook can have any number of tabs,
and each notebook tab is associated with a different notebook page. Each
notebook page displays any user defined group of objects.
Each notebook tab can contain either simple text or any user-defined object
type. Text tabs use slightly less memory, while user defined tab decorations
can give the notebook control a customized appearance.
Regardless of tab type, the tabs can be displayed at the top or bottom of
the notebook window.
4.11.4 Signals
In addition to the common signals defined by PegThing, PegNotebook
sends the PSF_PAGE_SELECT signal when a new notebook page is selected.
The message contains the following data:
4.11.5 Derivation
PegNotebook derives from PegWindow.
4.11.6 Constructors:
PegNotebook(const PegRect &Rect, PEGULONG Style,
PEGUBYTE NumTabs)
The PegNotebook constructor accepts a PegRect defining the notebook
position and size, a style value, and the number of tabs that the notebook
will initially display. The number of tabs can be modified at run time.
This function should be called once for each notebook page, setting the
page clients for page indexes 0 through (nTabs - 1).
This function should be called once for each notebook tab, setting the text
value for tab indexes 0 through (nTabs - 1).
4.11.9 Examples:
The following is an example of a PegNotebook window with text tabs, a
raised frame, and tabs on top:
4.12 PegProgressWindow
4.12.1 Overview
PegProgressWindow is an extension of PegMessageWindow. In this case,
a progress bar indicator is added to the message and optional buttons
displayed on the message window. This makes it very easy to create and
display a message and progress bar to the user during a long operation.
The progress bar that is a child of the progress window is directly updated
by the application software. The progress window member function Bar()
is called to retrieve a pointer to the progress bar when the application
determines that the progress bar should be updated.
The style of the progress bar displayed in the window client area is passed
to the PegProgressWindow constructor.
PegMessageWindow
4.12.4 Signals
PegProgressWindow signals are identical to PegMessageWindow signals.
4.12.5 Derivation
PegProgressWindow is derived from PegMessageWindow.
4.12.6 Constructors:
PegProgressWindow(const PegRect &Rect, PEGINT
TitleStringId, PEGINT MessageId, PEGUSHORT
MesgStyle, PEGUSHORT ProgStyle = FF_THIN|
PS_SHOW_VAL|PS_PERCENT, PEGINT IconId = 0,
PegThing *pOwner = NULL)
PegProgressWindow(const PegRect &Rect, const PEGCHAR
*pTitle, const PEGCHAR *pMessage, PEGUSHORT
MesgStyle, PEGUSHORT ProgStyle = FF_THIN|
PS_SHOW_VAL|PS_PERCENT, PEGINT IconId = 0,
PegThing *pOwner = NULL)
The PegProgressWindow constructors are identical to the
PegMessageWindow constructors, with the added style value ProgStyle.
This additional style value is applied to the child PegProgressBar object.
4.12.8 Examples:
The following code fragment creates and displays a PegProgressWindow:
void MyWin::DisplayProgress(void)
{
PegRect Rect;
Rect.Set(10, 10, 190, 140);
PegProgressWindow *pWin = new PegProgressWindow(Rect,
"Working....", "Copying Information...", MW_OK|
FF_RAISED);
Presentation()->Center(pWin);
Presentation()->Add(pWin);
}
4.13 PegRichTextBox
4.13.1 Overview
The PegRichTextBox is responsible for Rich Text support in PegPro library.
The PegRichTextBox with additional APIs for Rich Text Support is
responsible for displaying formatted text like bold, italic, underline, etc. that
are in Rich Text Format. It is responsible for displaying the RTF file.
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
4.13.4 Derivation
PegRichTextBox derives from PegWindow.
4.13.5 Constructors:
PegRichTextBox(const PegRect &Rect, PEGUSHORT Id = 0,
PEGULONG Style = FF_RECESSED|EF_WRAP|TJ_LEFT)
This constructor creates a PegRichTextBox. This constructor initializes all
member variables.
char *mpFileName
Holds the pointer to the file name.
RichTextNode *mpDrawHome
Pointer to RichTextNode link list.
RtfColorTable *mpColorHome
Pointer to color table.
PEGINT *mpRichFontTable
Pointer to font ID array.
4.13.9 Examples:
The following is an example of a PegRichTextBox display RTF file.
4.14 PegSpreadSheet
4.14.1 Overview
PegSpreadSheet is a row,column matrix for displaying text or bitmaps.
PegSpreadSheet is a higher-level construct than the basic PEG window
and control types; therefore, there are a large number of functions available
for controlling PegSpreadSheet appearance and operation.
Each column of the spreadsheet has its own set of style flags. These flags
control the appearance of each column of cells. These flags are modified
through the SetColStyle() member function. Likewise, each row of the
Optional column headers, row headers, and column footers are drawn if
desired.
PegTable
4.14.4 Signals
In addition to the common signals defined by PegThing, PegSpreadSheet
supports the following signals:
4.14.5 Derivation
PegSpreadSheet derives from PegWindow.
4.14.6 Constructors:
PegSpreadSheet(const PegRect &Rect, PEGINT Rows,
PEGINT Cols, PEGUINT Id = 0, PEGULONG Style =
FF_RAISED|SS_CELL_SELECT|SS_PARTIAL_COL,
PegThing *pOwner = NULL)
The PegSpreadSheet constructor accepts a PegRect defining the
spreadsheet position and size. The total number of spreadsheet rows is
specified by Rows, and the total number of columns is specified in Cols. The
spreadsheet must have a non-zero ID to send signals, and the ID can be
specified in Id. Style indicates the global spreadsheet style, as each row
and column style must be set individually.
The pOwner parameter specifies which window, if any, should receive the
spreadsheet selection signals. This is required since PegSpreadSheet is
often added to PegPresentationManager, rather than to the owner window.
void DrawFooters(void)
This function draws all visible footers in the spreadsheet.
void DrawRowHeaders(void)
This function draws all visible row headers in the spreadsheet.
PEGINT GetDispCols(void)
This inline function returns the number of columns that are actually visible
in the spreadsheet client area.
PEGINT GetDispRows(void)
This inline function returns the number of rows that are actually visible in
the spreadsheet client area.
PEGINT GetOptimumHeight(void)
This function returns the best height for the spreadsheet after all cells have
been initialized. This height will allow the display of the entire spreadsheet
without scrolling.
PEGINT GetOptimumWidth(void)
Returns the best width for the spreadsheet after all cells have been
initialized. This width will allow the display of the entire spreadsheet without
scrolling.
PEGBOOL UnselectCells(void)
This function unselects cells. It returns TRUE if a selected cell was found,
else FALSE.
PEGBOOL UnselectColumns(void)
This function unselects all columns. It returns TRUE if a selected column
was found, else FALSE.
PEGBOOL UnselectRows(void)
This function unselects all rows. It returns TRUE if a selected row was
found, else FALSE.
PEGINT UpdateColLayout(void)
This function forces the spreadsheet to recalculate the visible/non-visible
column parameters and scroll bar settings. This function should be called if
the SS_PARTIAL_COL style flag is changed after the spreadsheet is visible.
4.14.9 Examples:
The following is an example of a PegSpreadSheet, centered in the client
area of a PegDecoratedWindow:
4.15 PegTable
4.15.1 Overview
PegTable is a container object for displaying a matrix of PegThing-derived
objects.
The number of table rows and columns must be passed to the PegTable
constructor. The row heights and columns widths are determined
dynamically as objects are added to the table.
PegTable will display a cell grid if the table grid line width is non-zero. The
default grid line width is PEG_FRAME_WIDTH. This can be modified by calling
the member function SetGridWidth().
Each cell can add padding space around each child object if desired. The
default padding amount is zero pixels. This can be modified by calling the
table member function SetCellPadding(). Cell padding applies to all cells
in the table.
Child objects are added to the table using the table SetCellClient()
member function. Any PegThing-derived class may become a table cell
client. As objects are added to the table, they can be set to span multiple
rows and/or columns. This allows a great deal of flexibility in the final
appearance of the table. When objects that span multiple rows or columns
are added to the table and the TCF_FORCEFIT style flag is passed to the
SetCellClient() function, the spanned rows and/or columns may be
expanded to ensure that the object is fully displayed in the indicated table
cells.
After the table has been fully initialized, the Layout() member function
should be called before the table is displayed. The Layout function
calculates the correct overall table size, and positions each child object to fit
correctly within the desired table cells.
The Layout() function resizes row heights and column widths if required to
accommodate all children with TCF_FORCEFIT style. The layout algorithm
works by checking the following rules in the following order:
• For each single-cell child object with a TCF_FORCEFIT style, ensure that
the height and width of the cell occupied by the object are the object
height and width.
• For each multicell child object with a TCF_FORCEFIT, add the total height
and width of the spanned cells.
— If the total width of spanned cells is the object width, continue to
height check.
— Otherwise, search for a zero-width column spanned by the
object.
— If a zero-width column is found, increase the column width the
necessary amount to display the child object.
— If no zero-width columns are found, increase all spanned cell
widths by an equal amount to fully display the child object.
— If the total height of spanned cells is the object height, continue.
— Otherwise, search for a zero-height row spanned by the object.
— If a zero-height row is found, increase the row height the
necessary amount to display the child object.
— If no zero-height rows are found, increase all spanned cell
heights by an equal amount to fully display the child object.
• Position each child object to the center of the each cell.
Each table column has a fixed width. Initially, each column has a default
width of zero. The true width of each column can either be set manually by
calling the SetColWidth() function, or can be determined automatically by
Each table row also has a fixed height, which can either be set using the
SetRowHeight() function or determined automatically by the table.
PegTable will automatically size itself to display all children when the
Layout() function is called. For displaying very large tables, PegTable may
be added to the client area of a parent window which has scrolling enabled
This will allow the table to be panned up-down and left-right.
Notifications sent from table cell clients are passed unchanged to the table
parent. This allows any window containing a PegTable to receive events
from the table cell client objects as if the objects were direct children of the
parent window.
PegTable also supports the following styles with regard to the cell clients.
These flags are only applicable when calling the SetCellClient method.
4.15.4 Derivation
PegTable derives from PegWindow.
4.15.5 Constructors:
PegTable(PegRect &Rect, PEGINT Rows, PEGINT Cols)
This constructs a PegTable object, specifying the position and the number
of table rows and columns.
PEGINT GetCellPadding(void)
This inline function returns the cell padding of the table.
PEGINT GetColumns(void)
This inline function returns the number of columns in the table.
PEGINT GetGridWidth(void)
This inline function returns the table's grid width.
The default Style flag will center the object vertically and horizontally within
the bounding cell. To enable force-fitting the cell on the table, specify the
TCF_FORCEFIT style.
See this table for a list of supported style flags for the cell objects. It is
important to note that the justification styles operate only on the placement
of the object within its bounding cell or cells. The style flags do not operate
on the object itself. For example, a PegPrompt object has a series of styles
that allow for left, center, and right justification of its text. These text
4.15.7 Examples:
The following is a PegTable populated with different types of cell client
objects.
The full source code for this example can be found in the \peg\examples\
table directory.
4.16 PegTextBox
4.16.1 Overview
PegTextBox is a multiline text display control. PegTextBox is derived from
PegWindow.
The font, color, size, scrolling mode, and other parameters can be modified,
giving PegTextbox a wide variety of appearances.
Lines of text that are too long to fit in the client width of the text box are also
wrapped by default to use two or more lines. This is controlled by the
EF_WRAP style flag. The wrapping algorithm searches for white space,
comma, or hyphen characters as logical points to break long lines. If a
suitable breaking point is not found, PegTextBox simply breaks a line at the
last character that fits within the client width area.
PegTextBox does not allow user editing. The text data displayed in the text
box can only be modified via program control using the DataSet() or
Append() member functions. For a full edit-style control, refer to
PegEditBox.
PegEditField
PegWindow
PegTextThing
PegEditBox
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
EF_EDIT When this style is applied, the user can edit the
PegTextBox object. If this style is applied, the
PegTextBox object automatically includes the
TT_COPY style.
EF_WRAP When this style is applied, the text box will
wrap long lines to prevent them from being
clipped.
TT_COPY Instructs the PegEditBox to copy the text string
assigned. This flag should be used when the
text string assigned to the PegEditBox is
created dynamically using temporary storage.
4.16.4 Signals
PegTextBox supports no extended signals.
4.16.5 Derivation
PegTextBox is derived from PegWindow.
4.16.6 Constructors:
PegTextBox(const PegRect &Rect, PEGUINT StringId = 0,
PEGUSHORT Id = 0, PEGULONG Style = FF_RECESSED|
EF_WRAP|TJ_LEFT, PEGUINT MaxChars = 1000)
PegTextBox(const PEGCHAR *pText, const PegRect &Rect,
PEGUSHORT Id = 0, PEGULONG Style = TT_COPY|
FF_RECESSED|EF_WRAP|TJ_LEFT, PEGUINT MaxChars =
1000)
This constructor creates a PegTextBox. MaxChars is the maximum number
of characters that the text box will be required to support. If more than this
number of characters is assigned using the DataSet() function, the extra
characters fall off the end. If more than this number of total characters is
assigned using the Append() function, the oldest characters fall off the top.
PEGUINT GetMaxChars(void)
This inline function returns the maximum number of characters the text box
will contain.
PEGUINT GetTopLine(void)
This inline function returns the index of the top line currently displayed in
the text box.
PEGINT GetWidestLine(void)
This inline function returns the width (in pixels) of the widest line of
currently-displayed text in the text box. The widest line may not be visible in
the client area.
PEGINT LineCount(void)
This inline function returns the total number of lines contained in the text
box. This is the total number of lines available, as opposed to the number of
lines actually visible.
PEGBOOL LineUp(void)
This function can be called to scroll the text box up one line under program
control.
void SetTopLineToEnd(void)
This function will scroll the text box down such that its last line is visible.
PEGINT mWidestLine
Holds the width of the widest text box line, in pixels.
PEGINT mLeftOffset
This value indicates how far the text box has scrolled from the leftmost
anchor point.
4.16.9 Examples:
The following are each different styles of PegTextBox:
II
rr.
' 1 ...
[!Jr 1
The camplete source for the Iast example shown above can be found in the
example program \peg\examples\vecfont distributed with your PEG
release.
4.17 PegTreeNode
4.17.1 Overview
PegTreeNode, derived from PegTextThing, is used to populate a
PegTreeView container window.
Each PegTreeNode must have an associated text string. Each node may
also have a bitmap or thumbnail associated with it. If a bitmap is specified,
the bitmap is displayed to the left of the text for that node. The same bitmap
can be used for any number of nodes.
The bitmaps associated with each node do not all have to be the same size.
The bitmaps associated with each node are displayed such that they are
horizontally centered. Also, the bitmaps can be of any height and width. A
pleasing display is usually created using bitmaps of between 12 x 12 and
20 x 20 pixels.
PegTreeNode objects are displayed in the order they are added to the
parent node.
PegTreeView
4.17.3 Derivation
PegTreeNode derives from PegTextThing.
4.17.4 Constructors:
PegTreeNode(PEGINT StringId = 0, PEGINT BmpId = 0)
PegTreeNode(const PEGCHAR *Text, PEGINT BmpId = 0)
Creates a PegTreeNode object. The text string must be valid, while the
bitmap is optional.
PEGINT BranchHeight(void)
Returns the height of the current branch, factoring in all child node heights if
the current branch is open.
void Close(void)
Closes the current node. If the node has children, they are not displayed.
PEGINT Count(void)
Returns the number of children owned by the current node.
PegTreeNode *FirstNode(void)
Returns the first child node of the current node, or NULL if the current node
has no children.
void ForceOpen(void)
This function forces the node to be open.
PEGINT GetMap(void)
Returns the bitmap associated with the node, or -1.
PEGBOOL IsSelected(void)
Returns TRUE if the current node is selected, else FALSE.
PegTreeNode *NextNode(void)
Returns the following sibling of the current node, or NULL.
PegTreeNode *NodeAbove(void)
This function returns the nearest visible PegTreeNode above the current
node.
PegTreeNode *NodeBelow(void)
This function returns the nearest visible PegTreeNode below the current
node.
PegTreeNode *NodeBottom(void)
This function returns the bottom-most PegTreeNode on the node's subtree.
PEGINT NodeHeight(void)
Returns the height of the current node, in pixels. This function does not
include the height of any child nodes.
PEGINT NodeWidth(void)
Returns the width, in pixels, of the current node. This includes the bitmap
width (if any) and the text string width.
void Open(void)
Forces the node to open and display any children.
PegTreeNode *ParentNode(void)
Returns the parent of the current node, or NULL if the current node is the
tree view top node.
4.17.6 Examples:
Refer to PegTreeView for instance and programming examples.
4.18 PegTreeView
4.18.1 Overview
PegTreeView, derived from PegWindow, displays a hierarchical
presentation of PegTreeNode objects. PegTreeView always uses
automatic vertical and horizontal scrolling, so that whenever more nodes
than can be displayed in the PegTreeView client area are present, scroll
bars are provided for panning the node display area.
PegTreeNode
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
4.18.4 Signals
PegTreeView sends the following signals based on user selections:
For each of the above signals, the message contains the following data:
4.18.5 Derivation
PegTreeView derives from PegWindow.
4.18.6 Constructors:
PegTreeView(const PegRect &Rect, PEGINT StringId,
PEGULONG Style, PEGINT BitmapId = 0)
PegTreeView(const PegRect &Rect, const PEGCHAR *pText,
PEGULONG Style, PEGINT BitmapId = 0)
The PegTreeView constructor accepts the initial tree view position, frame
style, and top node text. An optional bitmap or thumbnail to be associated
with the top level node may also be defined.
DestroyNode(FindNode(1, "Temp"));
Node nesting levels start at 0. The only level 0 node is the top tree node.
The first level of nodes under the top node are level 1 nodes, the next level
of indented nodes are level 2 nodes, etc.
PEGINT GetIndent(void)
This function returns the current indent level, in pixels.
PegTreeNode *GetSelected(void)
This function returns a pointer to the selected node.
RemoveNode(FindNode(1, "Temp"));
void Reset(PEGINT TopStringId)
void Reset(const PEGCHAR *pText)
This method resets the entire tree by removing and deleting all of the tree's
nodes. The text for the top node is then set to the specified text.
PegTreeNode *TopNode(void)
This function returns a pointer to the top tree node. Using this pointer, the
application-level software can traverse the entire tree.
4.18.8 Examples:
The following is an example of a PegTreeView window populated with
PegTreeNodes. In this case, the PegTreeView window is used as the client
for a PegNotebook page. This example is taken from PegWindowBuilder:
void MyWindow::CreateTreeView(void)
{
PegTreeView *pTree;
pTree = new PegTreeView(mClient, “Hockey Teams”,
FF_RECESSED,
BID_HOCKEY);
pTree->Id(IDW_HOCKEY_TREE);
pNode = pNode->FirstNode();
pNode = pNode->NextNode();
Add(pTree);
}
4.19 PegVirtualVList
4.19.1 Overview
PegVirtualVList is very similar to a PegVertList class in that it arranges data
vertically and allows the user to scroll through each element. The main
difference between them is that the PegVirtualVList class does not require
a PegThing object for each item in the list. It automatically makes just
enough objects to fill in the visible area, and then if the user scrolls the list,
only the data is shifted up and down, not the objects themselves.
By default, the PegVirtualVList class will only work with text, and it will use
standard PegPrompts to display that text. However, the class is designed to
be flexible to allow applications to create derived versions that could
potentially display any kind of data.
Rather than creating PegPrompts and adding them to the list in the manner
of a PegVertList class, the PegVirtualVList class takes an array of data as
input in the AssignVirtualList function. The default implementation
assumes the data is text, but the function’s parameter is actually a void*,
so derived versions can override this function to use other types of data.
The PegVirtualVList will create just enough PegPrompts to fit in its mClient
area, and then it will call DataSet() to assign text to the prompts from the
list data. When the user scrolls, it is just a matter of calling DataSet() on
each prompt again.
The main advantage here is speed. For lists of large sizes, the
PegVirtualVList is much faster at scrolling then a PegVertList. The reason
is that when a PegVertList scrolls its child objects, even though only a
select few of them might be visible, ALL of the child objects still need to be
repositioned. That means that the more objects are added to the list, the
slower scrolling will become. And with lists of hundreds or thousands of
items that can add up. The PegVirtualVList performs exactly the same
operations no matter how much data is in the list, so it doesn’t slow down.
PegList
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
The styles for PegVirtualVList are identical to the PegWindow styles. In
addition, scrolling is enabled in PegVirtualVList in the same way as in
PegWindow, by using the SetScrollMode() function.
4.19.4 Signals
PegVirtualVList sends PSF_LIST_SELECT signals to the parent object. This
message contains:
4.19.5 Derivation
PegVirtualVList derives from PegWindow.
4.19.6 Constructors:
PegVirtualVList(const PegRect &Rect, PEGUSHORT Id = 0,
PEGULONG Style = FF_THIN|TJ_CENTER)
This constructor creates a PegVirtualVList object. The Rect parameter
determines the position and size of the list. The list children are
automatically positioned by the list object.
void PageDown(void)
This function scrolls the data down by one full page, meaning that the first
non-visible data item at the bottom of the list client area is scrolled into view
and selected. This function is called by the Message function in response to
the PK_PGDN key message.
void PageUp(void)
This function scrolls the data up by one full page, meaning that the first non-
visible data item at the top of the list client area is scrolled into view and
selected. This function is called by the Message function in response to the
PK_PGUP key message.
void SelectPrevious(void)
This function selects the data item that comes before (above) the currently-
selected item. If the previous item is not currently visible, then the list will be
scrolled.
4.19.9 Examples:
The following is a PegVirtualVList:
PEGCHAR *gpListData[] = {
“Prompt0”,
“Prompt1”,
“Prompt2”,
“Prompt3”,
“Prompt4”,
“Prompt5”,
“Prompt6”,
“Prompt7”,
“Prompt8”,
“Prompt9”,
};
void MyWindow::AddVList(void)
{
PegRect Rect;
Rect.Set(10, 10, 80, 180);
4.20 PegVertList
4.20.1 Overview
PegVertList is a container class for displaying a scrolling list of child
objects. PegVertList automatically positions and sizes child objects. It is
therefore not necessary to manually position objects before adding them to
PegVertList.
The LAST child added to the list will be displayed at the topmost position in
the list if the Add() function is used to add children. The order of display
can be reversed by using the function AddToEnd() to add children to the
list.
Child objects are positioned when the list receives the PM_SHOW message,
which is a system message sent automatically when the list is first
displayed. PegVertList forces the width of child objects to match the width
of the list client area. Because the height of each child object is not
modified, you should use the correct object height when constructing child
objects.
PegList
PegWindow
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
4.20.4 Signals
PegVertList sends PSF_LIST_SELECT signals to the parent object. This
message contains:
4.20.5 Derivation
PegVertList derives from PegList.
4.20.6 Constructors:
PegVertList(const PegRect &Rect, PEGUINT Id = 0,
PEGULONG Style = FF_THIN)
This constructor creates a PegVertList object. The Rect parameter
determines the position and size of the list. The list children are
automatically positioned by the list object.
4.20.9 Examples:
The following is a PegVertList with PegPrompt children:
void MyWindow::AddHList(void)
{
PegRect Rect;
Rect.Set(10, 10, 80, 180);
Rect.Set(0, 0, 0, 34);
pList->Add(new PegIconButton(Rect, BID_THUNDER));
pList->Add(new PegIconButton(Rect, BID_LIGHT));
pList->Add(new PegIconButton(Rect, BID_SATELLITE));
pList->Add(new PegIconButton(Rect, BID_DYNAMITE));
pList->Add(new PegIconButton(Rect, BID_APPLE));
pList->SetScrollMode(WSM_VSCROLL);
Add(pList);
4.21 PegWindow
4.21.1 Overview
PegWindow defines a basic rectangular area on the screen. Important
functionality added by PegWindow includes the concept of scrolling a
virtual client area.
PegWindow objects may be used as-is, but more commonly they serve as
the base class for the more refined window classes such as
PegDecoratedWindow and PegDialog. PegWindow can be resized by the
user, has a virtual client area, has one of several frame styles, and controls
nonclient-area scroll bars.
A simple way to create a window with a virtual scrolling client area is to nest
a large window within the client area of a parent window. An example of this
is included in the examples section for PegWindow.
Viewports
PegDecoratedWindow
PegDialog
PegMessageWindow
PegMLMessageWindow
FF_NONE No Frame
FF_THIN Thin Frame
FF_RAISED Raised 3D Frame
FF_RECESSED Recessed 3D Frame
FF_THICK Thick 3D Frame
4.21.4 Signals
None.
4.21.5 Derivation
PegWindow derives from PegTextThing.
4.21.6 Constructors:
PegWindow(const PegRect &Rect, PEGULONG Style =
FF_THICK)
This constructor is used when the initial size and position of the window are
known at the time the window is created. Rect defines the mReal position of
the window.
PEGUBYTE BlendMode(void)
Returns the window’s current blend mode. This function is only available if
PEG_LAYERED_WINDOWS is turned on.
PEGUBYTE BlendRatio(void)
Returns the window’s current blend ratio. This function is only available if
PEG_LAYERED_WINDOWS is turned on.
PEGBOOL CheckAutoScroll(void)
If either WSM_AUTOVSCROLL or WSM_AUTOHSCROLL scroll modes are set, this
function is called when the window is resized to determine if scroll bars
need to be updated. Derived classes also call this function at times when
the scroll bars may need to be added or removed.
PEGUBYTE CurrentMoveMode(void)
Returns the current move mode of the window.
PEGINT GlobalModalExecute(void)
Normally a call to Execute() will make a window modal within its own task,
while windows in other tasks can still get focus and read mouse/keyboard
input. This function makes a window modal over all tasks. It is only provided
if #define PEG_MULTITHREAD is enabled in the configuration file
pconfig.hpp.
PEGBOOL IsMaximized(void)
Returns TRUE if the window is maximized, else FALSE.
PEGBOOL IsModal(void)
Returns TRUE if the window is modal, else FALSE.
The WSM_CONTINUOUS mode can be included with any other modes. This
flag causes the scroll bars to send scroll messages continuously as they
are dragged by the user, rather than the default operation, which is to send
a scroll message only when the scroll button is released.
void BeginExitTransition(void)
This function begins a transition when a window is removed from the
display.
PEGUBYTE mScrollMode
The current window scroll mode.
PEGUBYTE mModal
TRUE if the window is executing modally.
PEGUBYTE mMoveMode
The current move or resize mode of the window.
PegScroll *mpHScroll
Pointer to non-client horizontal scroll bar if present, else NULL.
PegScroll *mpVScroll
Pointer to non-client vertical scroll bar if present, else NULL.
4.21.9 Examples:
Default PegWindow:
void SomeObject::CreateWindow(void)
{
PegRect WinSize;
WinSize.Set(10, 10, 200, 120);
PegWindow *pWin = new PegWindow(WinSize);
Presentation()->Center(pWin);
Presentation()->Add(pWin);
}
The following example will create a PegWindow with a recessed frame and
add the window to the current object. The window will fill the client area of
the current object.
void SomeObject::AddClientWindow(void)
{
PegWindow *pWin = new PegWindow(mClient, FF_RECESSED);
Add(pWin);
}
void SomeObject::CreateScrollingWindow(void)
{
PegRect ParentRect, ChildRect;
Presentation()->Center(pOuter);
Presentation()->Add(pOuter);
}
5.1 PegChart
5.1.1 Overview
PegChart is the base class for all of the charts in the PEG library. PegChart
is a virtual base class; therefore, it is not possible to instantiate an object of
this type directly at run time. The main job of PegChart is to provide a basic
framework for its derived children. It does this by keeping track of an extra
style variable, over and above the one retained by PegThing. It also
provides the algorithms for calculating the layout of the chart based on
whether or not the chart will be drawing labels and tick marks. And, lastly, it
provides drawing methods for the common elements of a chart (i.e., x and y
tick marks, labels, and grid lines).
5.1.3 Signals
PegChart does not send any signals.
5.1.4 Derivation
PegChart is derived from PegThing.
5.1.5 Constructor:
PegChart(const PegRect &Rect, PEGLONG MinX, PEGLONG
MaxX, PEGLONG MinY, PEGLONG MaxY, PEGUINT
MajorXScale = 0, PEGUINT MajorYScale = 0)
The constructor is fairly straightforward. Like most PegThing-derived
objects, you pass it the rectangle you wish for it to occupy. If you have
CS_AUTOSIZE turned on, you may simply want to pass it the parent's
mClient rectangle.
The next four PEGLONG values specify the minimum and maximum values
for x and y. The last two parameters are for setting the major tick mark
frequency for the x and y axis, respectively. For instance, if your minimum y
value is -100 and your maximum y value is 900, and you specify a y scale
of 100, if the CS_DRAWYTICS bit is set in the extended style flag, you will see
tick marks on the y axis starting at -100 and incrementing 100 all the way to
5.1.8 Examples:
PegChart is not directly instantiable. See PegLineChart, PegMultiLineChart
or PegStripChart for an example of appropriate usage.
5.2 PegLineChart
5.2.1 Overview
PegLineChart is a simple abstract down from PegChart and supports the
displaying of a single line on a given scale.
5.2.4 Signals
PegLineChart does not send any signals.
5.2.5 Derivation
PegLineChart is derived from PegChart.
5.2.6 Constructor:
PegLineChart(const PegRect &Rect, PEGLONG MinX,
PEGLONG MaxX, PEGLONG MinY, PEGLONG MaxY,
PEGUINT MajorXScale = 0, PEGUINT MajorYScale =
0)
The constructor is fairly straightforward. Like most PegThing-derived
objects, you pass it the rectangle you wish for it to occupy. If you have
CS_AUTOSIZE turned on, you may simply want to pass it the parent's
mClient rectangle.
The next four PEGLONG values specify the minimum and maximum values
for x and y. The last two parameters are for setting the major tick mark
frequency for the x and y axis, respectively. For instance, if your minimum y
value is -100 and your maximum y value is 900, and you specify a y scale
of 100, if the CS_DRAWYTICS bit is set in the extended style flag, you will see
tick marks on the y axis starting at -100 and incrementing 100 all the way to
900. Therefore, there will be 11 tick marks drawn on the y axis. If you were
void RecalcLine(void)
This method forces a recalculation of the screen coordinates for every point
on the line.
void ResetLine(void)
This method removes all of the points associated with the line.
5.2.8 Examples:
The following code snippet produces the PegLineChart pictured below.
5.3 PegMultiLineChart
5.3.1 Overview
PegMultiLineChart supports the drawing of discrete lines that use the same
x and y scaling.
5.3.4 Signals
PegMultiLineChart does not send any signals.
5.3.5 Derivation
PegMultiLineChart is derived from PegChart.
5.3.6 Constructor:
PegMultiLineChart(const PegRect &Rect, PEGLONG MinX,
PEGLONG MaxX, PEGLONG MinY, PEGLONG MaxY,
PEGUINT MajorXScale = 0, PEGUINT MajorYScale =
0)
The constructor is fairly straightforward. Like most PegThing-derived
objects, you pass it the rectangle you wish for it to occupy. If you have
CS_AUTOSIZE turned on, you may just want to pass it the parent's mClient
rectangle.
The next four PEGLONG values specify the minimum and maximum values
for x and y. The last two parameters are for setting the major tick mark
frequency for the x and y axis, respectively. For instance, if your minimum y
value is -100 and your maximum Y value is 900, and you specify a y scale
of 100, if the CS_DRAWYTICS bit is set in the extended style flag, you will see
tick marks on the y axis starting at -100 and incrementing 100 all the way to
5.3.8 Examples:
The following code snippet produces the PegMultiLineChart pictured below.
5.4 PegStripChart
5.4.1 Overview
PegStripChart supports the drawing of discrete lines plotted against the y
axis, with new data samples added in series along the x axis.
5.4.4 Signals
PegStripChart does not send any signals.
5.4.5 Derivation
PegStripChart is derived from PegChart.
5.4.6 Constructor:
PegStripChart(const PegRect &Rect, PEGUINT Samples,
PEGLONG MinY, PEGLONG MaxY, PEGUINT XScale = 0,
PEGUINT YScale = 0)
The constructor is fairly straightforward. Like most PegThing-derived
objects, you pass it the rectangle you wish for it to occupy. If you have
CS_AUTOSIZE turned on, you may simply want to pass it the parent's
mClient rectangle.
The Samples parameter specifies how many samples will fit into the chart
region. If you would like to see 100 samples of data at one time, then you
would set this parameter to 100.
The last two parameters are for setting the major tick mark frequency for
the x and y axis, respectively. For instance, if your minimum y value is -100
and your maximum y value is 900, and you specify a y scale of 100, if the
CS_DRAWYTICS bit is set in the extended style flag, you will see tick marks
on the y axis starting at -100 and incrementing 100 all the way to 900.
Therefore, there will be 11 tick marks drawn on the y axis. If you were to
also turn on the CS_DRAWYGRID bit, you would see a grid line at the same
interval as the tick marks. Label scaling, or interval, is independent of the
tick mark/grid line scaling. Therefore, it is possible to specify tick marks to
appear at intervals of 100, while specifying labels to be drawn every 200.
If adding the line fails, a value of 0 will be returned. This chart supports up
to 255 lines simultaneously.
5.4.9 Examples:
The following code snippet produces the PegStripChart pictured below.
This strip chart is using the CS_PAGED method of drawing.
PegRect Rect;
Rect.Set(40, 40, 590, 240);
PegStripChart *pChart = new PegStripChart(Rect, 240, -
100,
120, 0, 20);
6.1 PegDial
6.1.1 Overview
PegDial is an abstract base class from which PegFiniteDial and
PegFiniteBitmapDial are derived. PegDial provides the base functionality
common to all the derived dial objects in the PEG library.
The various quadrants are denoted by I, II, III, and IV called the first,
second, third, and fourth quadrants, respectively. In Figure 1, for example,
angle A is in the second quadrant while in Figure 2, angle A is in the third
quadrant.
When working with angles with any PegDial derived class, 0 degrees is
always on line OX with greater angle values going counterclockwise.
Therefore, line OY is at 90 degrees, line OX' is at 180 degrees and line OY'
is at 270 degrees.
PegFiniteDial
PegFiniteBitmapDial
PegCircularDial
PegCircularBitmapDial
DS_CLOCKWISE Sets the direction that the data will move the
needle. Having this flag set causes the needle
to move in a clockwise direction as the current
value gets larger. Clearing this flag will cause
the needle to move in a counterclockwise
direction.
DS_TICMARKS If this flag is set, the dial will draw tick marks at
the defined intervals.
DS_THINNEEDLE Will draw the needle as a thin single line.
DS_THICKNEEDLE Will draw the needle as a thick single line.
DS_POLYNEEDLE Will draw the needle using a filled polygon.
DS_RECTCOR Rectangle Center of Rotation. Will use the
center of the bounding rectangle (mReal) as
the center for the anchor of the needle.
DS_USERCOR User Center of Rotation. Allows the user to
specify where the center anchor will be for the
needle. This allows off-center bitmaps to be
used for backgrounds on the dial.
DS_STANDARDSTYLE A combination of DS_THINNEEDLE |
DS_CLOCKWISE | DS_TICMARKS | DS_RECTCOR.
AF_TRANSPARENT Enables the background to be drawn using the
background color of the parent.
6.1.4 Signals
PegDial does not send any signals.
6.1.5 Derivation
PegDial is derived from PegThing.
6.1.6 Constructors:
PegDial(const PegRect &Rect, PEGULONG Style)
This constructor simply takes a reference to a PegRect and a PEGULONG for
the style flags.
6.1.9 Examples:
See PegFiniteDial or PegFiniteBitmapDial for examples of PegDial-derived
objects.
6.2 PegFiniteDial
6.2.1 Overview
PegFiniteDial is an HMI output gadget that provides an analog equivalent to
a digital readout. It can be fed any integral data from any source.
The dial is categorized as finite because it takes a specific start angle and a
specific end angle that map to a minimum and maximum value,
respectively. So, in action, the needle on the dial moves between the start
and end angles based on the current value that is between the minimum
and maximum values assigned to the dial. The travel of the needle may be
the entire 360 degrees of a circle, say from 0 to 359 in a counter clockwise
direction, but it may not wrap.
PegFiniteBitmapDial
6.2.4 Signals
PegFiniteDial does not send any signals.
6.2.5 Derivation
PegFiniteDial is derived from PegDial.
6.2.6 Constructors:
PegFiniteDial(const PegRect &Rect, PEGINT MinAngle,
PEGINT MaxAngle, PEGLONG MinValue, PEGLONG
MaxValue, PEGULONG Style = DS_STANDARDSTYLE)
This constructor takes a reference to a PegRect to determine its size, a
style, a minimum and maximum angle, and a minimum and maximum
value.
The dial will map the minimum angle to the minimum value, and the
maximum angle to the maximum value. So, the dial will behave as
expected. If you set the minimum angle to be 0 and the maximum angle to
be 180, and the minimum value to 0 and the maximum value to 100, then
setting the value on the dial to 50 will set the needle to 90 degrees, straight
up.
6.2.9 Examples:
The following is an example of three PegFiniteDials on a
PegDecoratedWindow.
WinRect.Shift(160, 0);
mpDial2 = new PegFiniteDial(WinRect, 225, 315, 0, 300,
FF_RAISED | DS_THICKNEEDLE | DS_TICMARKS | DS_RECTCOR);
mpDial2->SetColor(PCI_NORMAL, CID_DARKGRAY);
mpDial2->SetNeedleColor(CID_BLUE);
mpDial2->SetTicFreq(50);
mpDial2->SetTicLen(20);
WinRect.Shift(160, 0);
mpDial3 = new PegFiniteDial(WinRect, 225, 315, 0, 300
FF_RECESSED | DS_POLYNEEDLE | DS_TICMARKS | DS_RECTCOR);
mpDial3->SetColor(PCI_NORMAL, CID_LIGHTGRAY);
Add(mpDial1);
WinRect.Set(105, 160, 144, 179);
PegPrompt *pPrompt = new PegPrompt(WinRect, "0", 101,
FF_RECESSED | TJ_CENTER | TT_COPY);
pPrompt->SetColor(PCI_NTEXT, CID_RED);
mpDial1->Add(pPrompt);
Add(mpDial2);
WinRect.Set(265, 160, 304, 179);
pPrompt = new PegPrompt(WinRect, "0", 102, FF_RECESSED |
TJ_CENTER | TT_COPY);
pPrompt->SetColor(PCI_NTEXT, CID_BLUE);
mpDial2->Add(pPrompt);
Add(mpDial3);
mpDial2->Add(pPrompt);
Add(mpDial3);
6.3 PegFiniteBitmapDial
6.3.1 Overview
PegFiniteBitmapDial behaves exactly the same as PegFiniteDial, from
which it derives. The differences are that the user may specify a
background bitmap over which the dial needle will be drawn as well as a
bitmap that will be used to draw the needle anchor at the center of rotation.
This allows for very customizable finite dials.
PegFiniteDial
6.3.4 Signals
PegFiniteBitmapDial does not send any signals.
6.3.5 Derivation
PegFiniteBitmapDial is derived from PegFiniteDial.
6.3.6 Constructors:
PegFiniteBitmapDial(const PegRect &Rect, PEGINT
MinAngle, PEGINT MaxAngle, PEGLONG MinValue,
PEGLONG MaxValue, PEGINT BkgBmp, PEGINT
AnchorBmp = 0, PEGULONG Style =
DS_STANDARDSTYLE)
This constructor takes a reference to a PegRect to determine its size, a
minimum and maximum angle, a minimum and maximum value, a bitmap
ID that will be used for drawing the background, a bitmap ID that will be
used to draw the needle anchor, and style flags.
The dial will map the minimum angle to the minimum value, and the
maximum angle to the maximum value. So, the dial will behave as
expected. If you set the minimum angle to be 0 and the maximum angle to
be 180, and the minimum value to 0 and the maximum value to 100, then
setting the value on the dial to 50 will set the needle to 90 degrees, straight
up.
6.3.9 Examples:
The following is an example of three PegFiniteBitmapDials on a
PegDecoratedWindow. Notice that the third dial, on the right, has a center
of rotation that is in the bottom right corner of the bounding rectangle of the
dial.
WinRect.Shift(160, 0);
pDial2 = new PegFiniteBitmapDial(WinRect, 225, 315, -25, 125,
BID_DIAL_BKGRND2, BID_ANCHOR1);
pDial2->SetStyle((pDial2->GetStyle() | DS_POLYNEEDLE) &
~DS_THINNEEDLE);
pDial2->SetNeedleColor(CID_BLUE);
WinRect.Shift(160, 0);
pDial3 = new PegFiniteBitmapDial(WinRect, 180, 90, 0, 100,
BID_DIAL_BKGRND3);
pDial3->SetStyle(DS_THICKNEEDLE | DS_USERCOR);
pDial3->SetCOR(123, 123);
pDial3->SetNeedleLength(65);
Add(pDial1);
Add(pDial2);
Add(pDial3);
6.4 PegCircularDial
6.4.1 Overview
PegCircularDial is an HMI output gadget that provides an analog equivalent
to a digital readout. It can be fed any integral data from any source.
As an example, if the minimum value of the dial were 0 and the maximum
were 900, and the value per revolution were 300 and the reference angle
were 90, then setting the current value of the dial to 0 would force the
needle to draw at 90 degrees. Incrementing the value up to 300 would
make the needle do one complete revolution around the dial. When the
current value reached 900, the needle would be at 90 degrees, having
traveled around the circumference of the dial three times.
PegCircularBitmapDials6_PegFiniteDial
6.4.4 Signals
PegCircularDial does not send any signals.
6.4.5 Derivation
PegCircularDial is derived from PegDial.
6.4.6 Constructors:
PegCircularDial(const PegRect &Rect, PEGINT RefAngle,
PEGLONG ValuePerRev, PEGLONG MinValue, PEGLONG
MaxValue, PEGULONG Style = DS_STANDARDSTYLE)
This constructor takes a reference to a PegRect to determine its size. It
then takes a PEGINT value to denote the reference angle. The reference
angle is the point on the dial at which the minimum value that the dial
supports will be mapped, as well as where a complete revolution is
counted. ValuePerRev tells the dial how much to increment its internal
current value for each revolution of the needle around the circumference of
the dial. It then takes PEGLONGs for the minimum and maximum value, and a
style PEGUSHORT.
6.4.9 Examples:
The following is an example of three PegCircularDials on a
PegDecoratedWindow.
WinRect.Shift(160, 0);
pDial2 = new PegCircularDial(WinRect, 270, 180, 0, 1800,
FF_RAISED);
pDial2->SetStyle(pDial2->GetStyle() | DS_THICKNEEDLE |
DS_TICMARKS | DS_RECTCOR);
pDial2->SetColor(PCI_NORMAL, CID_DARKGRAY);
pDial2->SetNeedleColor(CID_BLUE);
pDial2->SetTicFreq(10);
WinRect.Shift(160, 0);
pDial3 = new PegCircularDial(WinRect, 180, 360, 0, 720,
FF_RECESSED);
pDial3->SetStyle(mpDial3->GetStyle() | DS_POLYNEEDLE |
DS_TICMARKS | DS_RECTCOR);
pDial3->SetColor(PCI_NORMAL, CID_LIGHTGRAY);
pDial3->SetDialColor(CID_GREEN);
pDial3->SetNeedleColor(CID_YELLOW);
pDial3->SetTicFreq(10);
pDial3->SetTicLen(20);
Add(pDial1);
WinRect.Set(105, 210, 144, 229);
PegPrompt* pPrompt = new PegPrompt(WinRect, "0", 101,
FF_RECESSED | TJ_CENTER | TT_COPY);
pPrompt->SetColor(PCI_NTEXT, CID_RED);
Add(pPrompt);
Add(pDial2);
WinRect.Set(265, 210, 304, 229);
pPrompt = new PegPrompt(WinRect, "0", 102, FF_RECESSED |
TJ_CENTER | TT_COPY);
pPrompt->SetColor(PCI_NTEXT, CID_BLUE);
Add(pPrompt);
6.5 PegCircularBitmapDial
6.5.1 Overview
PegCircularBitmapDial behaves exactly the same as PegCircularDial, from
which it derives. The differences are that the user may specify a
background bitmap over which the dial needle will be drawn as well as a
bitmap that will be used to draw the needle anchor at the center of rotation.
This allows for very customizable circular dials.
PegCircularDial
6.5.4 Signals
PegCircularBitmapDial does not send any signals.
6.5.5 Derivation
PegCircularBitmapDial is derived from PegCircularDial.
6.5.6 Constructors:
PegCircularBitmapDial(const PegRect &Rect, PEGINT
RefAngle, PEGLONG ValPerRev, PEGLONG MinValue,
PEGLONG MaxValue, PEGINT BkgBmp, PEGINT
AnchorBmp = 0, PEGULONG Style =
DS_STANDARDSTYLE)
This constructor takes a reference to a PegRect to determine its size, a
PEGINT value for the reference angle, a PEGLONG value for the value per
revolution, a minimum and maximum value, a bitmap ID that will be used
for drawing the background, a bitmap ID that will be used to draw the
needle anchor, and a style PEGULONG.
7.1 Peg2DPolygon
7.1.1 Overview
Peg2DPolygon is an advanced drawing class that extends and
encapsulates the functionality implemented in the PegScreen's Polygon
method into a true sprite-oriented, two-dimensional polygon.
Another great feature is the ability to rotate the polygon to any given angle
without have to translate the points yourself. The following is a discussion
of how the current angle value is used in determining the translation of the
points of the polygon.
The various quadrants are denoted by I, II, III, and IV called the first,
second, third, and fourth quadrants, respectively. In Figure 1, for example,
It is also important to note that the polygon is rotated relative to its bounding
rectangle. In other words, if you were to have a polygon that was bounded
by a rectangle 48 pixels high and 48 pixels wide, the center of rotation for
the polygon would be at relative 23 x and 23 y (24 pixels from the top left
corner of the bounding rectangle). This can provide some very interesting
rotational effects. The one aspect that does require some care in rotating
the polygon is the point’s distance from the center of the bounding
rectangle. If a point lies outside of the radius of the largest concentric circle
that would fit within the perimeter of the bounding rectangle, then the point
may become clipped as the polygon is rotated.
Peg2DPolygon also supports the TT_COPY style flag. If set, this causes
Peg2DPolygon to copy the array of PegPoints sent over in the constructor's
parameter list. If you have allocated the points on the heap and would not
like the data copied, do not set this flag. By default, this flag is not set.
7.1.4 Signals
Peg2DPolygon does not send any signals.
7.1.5 Derivation
Peg2DPolygon is derived from PegThing.
7.1.6 Constructors:
Peg2DPolygon(const PegRect &Rect, PegPoint *pPoints,
PEGUINT NumPoints, PEGUINT Id = 0, PEGULONG
Style = FF_NONE)
The constructor takes a reference to a PegRect that describes the
bounding rectangle for the polygon, a pointer to a PegPoint structure, the
number of points that describe the polygon, a PEGUINT for the ID of the
object, and a PEGULONG for the style flags.
7.1.8 Examples:
The following is a code snippet that creates the Peg2DPolygon displayed
below. You'll notice that since we globally allocated the PegPoints that
described the polygon, we don't set the TT_COPY flag in the constructor to
the Peg2DPolygon object.
PolygonWindow::PolygonWindow() : PegDecoratedWindow()
{
mReal.Set(0, 0, 400, 300);
InitClient();
SetColor(PCI_NORMAL, CID_BLUE);
PegRect Rect;
Rect.Set(mClient.Left + 10, mClient.Top + 10,
mClient.Left + 57, mClient.Top + 57);
mpPolygon = new Peg2DPolygon(Rect, >PolyPoints[0], 8,
101, FF_NONE);
mpPolygon->SetColor(PCI_NORMAL, CID_BLUE);
mpPolygon->SetColor(PCI_NTEXT, CID_WHITE);
Add(mpPolygon);
}
7.2 PegBitmap
The PegBitmap structure contains format and data address information for
PEG-compatible bitmaps.
struct PegBitmap
{
PEGUBYTE Flags; // combination of flags above
PEGUBYTE BitsPix; // 1, 2, 4, 8, 16, or 24
PEGUSHORT Width; // in pixels
PEGUSHORT Height; // in pixels
PEGULONG TransColor; // transparent color for > 8bpp
// bitmaps
PEGUBYTE PEGFAR *pStart; // bitmap data pointer
};
7.3 PegBitmapRotator
7.3.1 Overview
The PegBitmapRotator class is a utility class that takes a PegBitmap as
input and returns a rotated version of that PegBitmap. It uses all fixed-point
math to do the calculations.
The various quadrants are denoted by I, II, III, and IV called the first,
second, third and fourth quadrants, respectively. In Figure 1, for example,
angle A is in the second quadrant while, in Figure 2, angle A is in the third
quadrant.
7.4 PegBrush
The PegBrush class is used to pass information to the PegScreen drawing
functions. PegBrush contains foreground and background colors, pattern,
width, and style flag information.
public:
PegBrush()
;
PegBrush(PEGCOLOR LColor, PEGCOLOR FColor,
PEGINT BStyle = PBS_NO_ALIAS, PEGINT LWidth = 1);
~PegBrush();
PEGCOLOR LineColor;
PEGCOLOR FillColor;
PEGULONG Pattern;
PEGUINT Alpha;
PEGINT Width;
PEGINT Style;
PegBitmap *pBitmap;
private:
PegBitmap *pSysmap;
};
PBS_SIMPLE_ALIAS: This flag is used to draw lines or text with ‘simple anti-
aliasing.’ This means that, at the edges of the line, the Brush.LineColor
will get blended with Brush.FillColor to produce a smoother looking line.
For lines drawn on top of solid-colored surfaces, this is often sufficient.
PBS_TRUE_ALIAS: This flag is used to draw lines or text with ‘true anti-
aliasing.’ This means that, at the edges of the line, the Brush.LineColor
will get blended with whatever pixels are already found on the screen. This
results in a smooth looking line even on multicolored backgrounds.
Performance-wise, this takes more processing time than
PBS_SIMPLE_ALIAS.
PBS_ROUNDED: This flag is used to draw rounded endpoints for wide lines.
This can be useful when drawing a series of connected wide lines because
the intersections will look smooth and round, rather than having sharp
corners sticking out.
7.5 PegCapture
PegCapture is a utility class used to capture and restore regions of the
screen.
class PegCapture
{
public:
PegCapture(voi
d)
{
mRect.Set(0, 0, 0, 0);
mBitmap.pStart = 0
mValid = FALSE;
mDataSize = 0;
}
~PegCapture()
{
if (mBitmap.pStart)
{
delete mBitmap.pStart;
}
}
7.6 PegFont
The PegFont structure contains format and data address information for
PEG compatible fonts.
struct PegFont
{
PEGUBYTE Type; PEGUBYTE
Ascent; PEGUBYTE
Descent; PEGUBYTE
CharHeight; PEGUBYTE
PreSpace; PEGUBYTE
PostSpace; PEGUBYTE
LineHeight; PEGUSHORT
BytesPerLine; PEGUSHORT
FirstChar; PEGUSHORT
LastChar; PEGUSHORT
*pOffsets; PegFont
*pNext;
PEGUBYTE *pData;
};
7.7 PegGradient
The PegGradient class is used to draw a progression from one color to
another. It can draw that progression in a number of different directions,
and it can include any number of specified colors at any point along that
progression, not just two colors at the ends.
Once the colors have been set, the application can create a gradient in any
style or direction. The PegGradient APIs can be used to draw a gradient
directly to the screen, or it can draw it into a PegBitmap so that the gradient
doesn’t need to be recalculated every time the application wants to redraw
it. Drawing into a bitmap can greatly improve performance, though it does
so at the cost of requiring more memory.
7.7.1 Constructors:
PegGradient(void)
This creates an instance of the PegGradient class. The gradient is empty at
this point so it would be unable to draw anything.
7.7.3 Examples
This example demonstrates how to make a gradient-filled button. The
gradient will start with dark gray, then move to light gray, and then end with
black. When the user presses on the button a different gradient will be
used.
grad.ClearColors();
grad.AddColor(CLR_LIGHTGRAY, 0);
grad.AddColor(CLR_DARKGRAY, 0x7f);
grad.AddColor(CLR_WHITE, 0xff);
mpSelectedBitmap = grad.GetVertGradient(this,
mClient.Width(), mClient.Height(), FALSE);
}
PegPoint p;
p.Set(mClient.Left, mClient.Top);
EndDraw();
}
7.8 PegMenuDescription
PegMenuDescption is a structure used to define PegMenuButton objects.
Arrays of PegMenuDescriptions are used to define any number of nested
menus and submenus. PegMenuDescription arrays are terminated with an
entry filled with 0 or NULL values.
struct PegMenuDescription
{
const PEGCHAR *pText;
PEGUSHORT Id;
PEGULONG Style;
PegMenuDescription *pSubMenu;
};
PegMenuButton
PegMenuBar
7.9 PegMessage
PegMessage is a data structure used to send and receive messages.
PegMessageQueue is the coordinator of message transports in your PEG
application.
struct PegMessage
{
public:
PegMessage(
)
{
pNext = NULL;
pTarget = NULL;
pSource = NULL;
}
PegMessage(PEGUSHORT Val)
{
pNext = NULL;
pTarget = NULL;
pSource = NULL;
Type = Val;
}
PegThing *pSource;
PegThing *pTarget;
PEGUSHORT Type;
PEGUSHORT Param;
union
{
private:
PegMessage *pNext;
};
For system messages, the message data fields are predefined. For user
defined messages, all fields except Type and pTarget are available for
user definition and can be used to send application-defined data values.
7.10 PegPoint
The PegPoint structure contains a single pixel address.
struct PegPoint
{
PEGSHORT x;
PEGSHORT y;
PEGBOOL operator != (const PegPoint &InPoint)const
PEGBOOL operator == (const PegPoint &InPoint)const
PegPoint operator +(const PegPoint &Point)const
void Set(PEGINT InX, PEGINT InY);
};
7.11 PegRect
The PegRect structure contains a rectangular screen dimension along with
a large number of operators, making it convenient to manipulate
rectangular areas of the display screen.
PEGSHORT Left;
PEGSHORT Top;
PEGSHORT Right;
PEGSHORT Bottom;
};
7.12 PegScrollInfo
The PegScrollInfo structure is used to pass scrolling data to and from
PegHScroll and PegVScroll scroll bar classes.
struct PegScrollInfo
{
PEGINT Min;
PEGINT Max;
PEGINT Current;
PEGINT Step;
PEGINT Visible;
};
7.13 PegTimer
The PegTimer structure contains information about an active PegTimer.
The PegTimer structure is private to PegTimerManager and is never
referenced directly by external software, however we document this
structure here for completeness.
struct PegTimer
{
PegTimer() {pNext = NULL; pTarget = NULL;}
PegTimer(PEGLONG Cnt, PEGLONG Res)
{
mpNext = NULL;
mpTarget = NULL;
Count = Cnt;
Reset = Reset;
}
PegTimer *mpNext;
PegThing *mpTarget;
PEGLONG Count;
PEGLONG Reset;
PEGUSHORT TimerId;
};
The PegUnzip function can operate in two modes. The most efficient mode
requires that the application program has preknowledge of the
uncompressed data size. In this case, the application program allocates a
buffer for storing the uncompressed data and passes this buffer address
and size to the PegUnzip function. In this mode, the PegUnzip function is
completed in one step, returning the uncompressed data.
A second, less efficient mode allows the caller to pass a NULL buffer
pointer and zero (0) buffer size. In this mode, the PegUnzip function unzips
the compressed data but discards the output, returning only the
The SourceLen parameter is the size of the buffer to compress. This must
be passed by your application to the PegZip function.
The pDestLen parameter is the address of a variable holding the size of the
output buffer allocated by the caller. If this value is 0, the PegUnzip function
discards the uncompressed data but returns the size of the required output
buffer in this variable. This can be useful if the uncompressed data size is
not known by the application.
PEG Signals
Viewports
8.1 PegPrinter
8.1.1 Overview
PegPrinter is a virtual base class that supports printing in PEG.
Much like the screen drivers, the PegPrinter provides the framework
necessary for objects to draw themselves to a printer instead of to the
output display.
For example, if your target system is running in monochrome and you are
printing to letter-sized paper at 100 dots per inch, the size of the bitmap
needed to hold an entire page would be 109,438 bytes, or just under
107 KB. On the other hand, if your target system is running in 16 bit per
pixel color and on the same size paper you are printing at 300 dots per
inch, the bitmap would be 1.581e+07 bytes, or 15.439 MB. So, it is
important to take these factors into consideration when designing printer
output.
See the Examples section below for a code listing on the steps necessary
to properly print.
PegScreen
8.1.4 Signals
None.
8.1.5 Derivation
None.
8.1.7 Constructors:
PegPrinter(void)
The PegPrinter constructor creates the PegPrinter object and sets the
object's internal members to reasonable defaults.
See the explanation for the Setup method for details on using the
PegPrintSetup structure.
• PPRINT_PS_LETTER
• PPRINT_PS_LEGAL_LIST_1
• PPRINT_PS_LEDGER
• PPRINT_PS_EXECUTIVE
• PPRINT_PS_A4
• PPRINT_PS_A3
• PPRINT_PS_COM_10
• PPRINT_PS_MONARCH
• PPRINT_PS_C5
• PPRINT_PS_B5
• PPRINT_PS_DL
By default, the printer driver will use the paper size that is in the default tray
of the printer. Internally, the paper size is used to calculate the printable
area of the page.
It is important to note that not all printers support all of these resolutions.
Some types of printers—thermal bar code printers, for example—only
support one resolution that is hard wired in the device. But most types of
desktop-type printers support a resolution of 300 dots per inch.
struct PegPrintSetup
{
PEGINT ColorMode;
PEGINT Orient;
PEGINT Res;
PEGINT PaperSize;
PEGINT Width;
PEGINT Height;
PegPrintSetup(void)
{
ColorMode = PPRINT_MODE_MONOCHROME;
Orient = PPRINT_ORIENT_PORTRAIT;
Res = PPRINT_RES_75;
PaperSize = PPRINT_PS_LETTER;
Width = PPRINT_DEF_WIDTH;
Height = PPRINT_DEF_HEIGHT;
}
The structure has a default constructor that sets the structure members to
reasonable defaults that would typically be supported by any printer.
The remaining members may be set to any value as described above for
their respective indicators.
A useful example of this method is updating a status bar that shows the
current print job progress. Using this method, the first page may be printed
and printing then suspended. While printing is suspended, the screen may
then be updated, informing the user that page one has completed and page
two is being readied. At that point, the Resume may be called to resume
printing.
8.1.10 Examples:
The following is a code listing that details the steps necessary to properly
direct drawing output to a printer. It is analogous to drawing into an off-
screen bitmap, so the interface should be familiar.
The example below shows the printing of two separate documents, each
having any number of pages. Note that the first document is printed in
monochrome and the second in simple color.
void MyThing::PrintReport(void)
{
PEGINT ret;
PegPrintSetup setup;
// end the page. This will also eject the paper from the
// printer.
ret = Printer()->EndPage();
ret = Printer()->BeginPage();
PrintBitmapChart();
ret = Printer()->EndPage();
Invalidate(mReal);
Draw();
ret = Printer()->EndPage();
ret = Printer()->EndDoc();
The printer object is very flexible in what type of output can be produced.
Basically, any type of drawing that you could normally do into a bitmap, you
can do into a printer. This allows you to create any type of output.
8.2 PCLPrinter
8.2.1 Overview
The PCLPrinter class is a printer driver for printers that support the Hewlett-
Packard (HP) Printer Control Language (PCL) level 3 or above. Most
modern HP LaserJet and InkJet printers, including HP Photo printers,
support this language. If you are in doubt regarding a specific printer, please
consult the printer specifications that came with your printer or on HP's
website.
This class is a straight derivation of the PegPrinter class and does not
implement any new public functions.
8.2.4 Signals
None.
8.2.5 Derivation
PegPrinter
8.2.6 Constructors:
PCLPrinter(void)
The constructor creates an instance of a PCLPrinter object. This function
should not be called directly by the application code. Application code
should always call the PegScreen::BeginPrint method to begin printing.
DS_CLOCKWISE
DS_TICMARKS
DS_THINNEEDLE
DS_THICKNEEDL
DS_POLYNEEDLE
DS_RECTCOR
DS_USERCOR
CS_DRAWXGRID
CS_DRAWYGRID
CS_DRAWXTICS
CS_DRAWYTICS
CS_AUTOSIZE
CS_SCROLLED
CS_PAGED
CS_DRAWXAXIS
CS_DRAWAGED
CS_DRAWLEADER
CS_DUALYTICS
CS_DUALYLABELS
CS_XAXISONZEROY
CS_DRAWLINEFILL
CS_DRAWXLABELS
CS_DRAWYLABELS
PSF_ACCEPTS_FOCUS This flag indicates that the object will become the
receiver of input events when selected. The
application level software can modify this flag, but
normally this is not advised. If this flag is modified
for a particular object, it is important for correct
operation that ‘breaks’ in the tree of objects
accepting focus are avoided. In other words, if a
parent window cannot accept focus, then neither
should any of the window’s child objects be
allowed to accept focus.
PSF_ALWAYS_ON_TOP This flag ensures that the object is always on top
of its siblings. The application level software can
modify this flag.
PSF_BUTTON_DERIVED This flag indicates that the object is either a
PegButton or derived from a PegButton. It is
added to objects in the PegButton constructor and
should not need to be modified by application
code.
PSF_CONTINUOUS_SCROLL This flag is used on objects that use a scroll bar. If
it is turned on, the user will be able to watch the
contents of the window scroll up or down as he or
she drags the scroll bar’s elevator button. If it is
turned off, then the user only sees the window
move when the elevator button is released. The
application level software can modify this flag.
PSF_CURRENT This flag indicates that the object is in the current
branch of the display tree. If the object is a leaf
object (i.e. it has no children) and it is current, then
it is the object that will receive keyboard input
messages.
PSF_KEEPS_CHILD_FOCUS This flag indicates that when the object gets focus,
it does not attempt to give focus to any of its child
objects. This is for objects like the PegList that
internally maintain which child object should be
focused.
PSF_DEFAULT_FOCUS This flag is given to objects when they receive the
PM_CURRENT message indicating that they have
focus. They only lose this flag when a different
sibling object receives focus. This is used to
maintain which object had focus last, even if the
parent object loses focus.
8.6 Viewports
PEG uses the concept of viewports to improve drawing efficiency and to
allow background drawing operations to occur without overwriting
foreground graphics.
In the diagram above, a typical run-time screen is shown. The black area is
the screen background, covered by PegPresentationManager. The two
white areas are PEG windows, named WindowA and WindowB. WindowB
is on top and partially covering WindowA. In this diagram, the black
rectangles with solid green outlines depict the viewports owned by
PegPresentationManager. In this case, PresentationManager owns
viewports V1-V6. WindowA is divided into two viewports, V7 and V8.
Finally, WindowB is on top and has one viewport, V9.
PEG maintains the screen viewports, and you do not ordinarily have to
concern yourself with how they work. There is one exception, however, that
you may need to be aware of. Normally, only PegWindow-derived objects
have viewport status. That means that other smaller objects like PegButton
AddStatus(PSF_VIEWPORT);
Now your container class will work correctly, and both PegWindow-derived
children and simple children will be displayed when the parent container
class is displayed.
The scroll bars added to the window make use of two virtual PegWindow
functions: GetHScrollInfo and GetVScrollInfo. When a scroll bar needs
to update itself, it calls these parent window member functions to learn the
scroll bar limit, current setting, and percentage visible data.
GetHScrollInfo() and GetVScrollInfo() receive a pointer to a
The default implementation works well in most cases, and makes it very
easy to create scrolling client areas. All you need to do is add a child
window to a scrolling parent that is much larger than the parent client area.
The default implementation will adjust the scroll bars such that the entire
child window can be viewed by moving the horizontal and/or vertical scroll
bars.
In some cases, the default operation does not provide the required function.
In these cases, you can override the GetHScrollInfo and
GetVScrollInfo functions to return custom scrolling information. For
example, suppose you want to create a continuous time plot of data values
with a horizontal scroll bar to move back and forth in the time period
displayed. In this case, you would create a derived PegWindow class in
order to draw the chart data in the window client area. You would also
provide a overridden version of the GetHScrollInfo function to make the
horizontal scrollbar reflect the accumulated time values. In this case, the
PegScrollInfo minimum value might be the starting time of data recording,
the maximum value would be the current time, and the visible amount
would be the time period visible in the window client area.