home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
ISTATTXT.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
17KB
|
330 lines
#ifndef _ISTATTXT_
#define _ISTATTXT_
/*******************************************************************************
* FILE NAME: istattxt.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IStaticText - This class creates and manages the static text control *
* window. *
* *
* COPYRIGHT: *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1992, 1993 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
*******************************************************************************/
#ifndef _ITEXTCTL_
#include <itextctl.hpp>
#endif
#ifndef _IBITFLAG_
#include <ibitflag.hpp>
#endif
#ifndef _ICOLOR_
#include <icolor.hpp>
#endif
#ifndef _IRECT_
#include <irect.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
// Forward declarations for other classes:
class ISize;
class IStaticTextHandler;
class IStaticText : public ITextControl {
typedef ITextControl
Inherited;
/*******************************************************************************
* The IStaticText class creates and manages the static text control window. *
* Static text controls are simple text fields, bit maps, and icons. Static *
* text controls do not accept user input. *
* *
* Example: *
* IStaticText sttxtText(ID_TEXT, this, this, IRectangle(10,10,70,24)); *
* sttxtText.setText("It is a wonderful day"); *
* *
* To change the style of the static text control after it has been created, *
* use functions such as: *
* setAlignment(IStaticText::centerCenter); *
*******************************************************************************/
public:
/*------------------------- Style ---------------------------------------------
The following functions provide a means to set and query static text styles:
Style - Nested class that provides static members that define the set of
valid static text styles. These styles can be used in conjunction
with the styles defined by the nested classes IWindow::Style and
IControl::Style. For example, you could define an instance of the
IStaticText::Style class and initialize it like:
IStaticText::Style
style = IStaticText::left | IControl::group;
An object of this type is provided when the static text is
created. A customizable default is used if no styles are
specified. Once the object is constructed, IStaticText,
IWindow, and IControl member functions can be used to set or
query the object's style.
The declaration of the IStaticText::Style nested class is
generated by the INESTEDBITFLAGCLASSDEF2 macro.
The valid static text styles are:
classDefaultStyle - Original default style for this class, which is
left | top | fillBackground | IWindow::visible.
left - Used to make the text left-justified.
center - Used to make the text centered.
right - Used to make the text right-justified.
top - Used to align the text to the top of the window.
vertCenter - Used to align the text vertically in the center of
the window.
bottom - Used to align the text to the bottom of the window.
mnemonic - If a mnemonic prefix character is encountered, the
next character is drawn with mnemonic emphasis.
halftone - The text will be drawn in halftone color.
underscore - The text will be drawn underscored.
strikeout - The text will be drawn overstriked.
wordBreak - Can only be used when the left and top styles are
also specified. This causes word-wrapping at ends of
lines for text that has multiple lines.
fillBackground - Erases the background using the currently set fill
color before drawing the text.
The following functions provide a means of getting and setting the default
style for this class:
defaultStyle - Returns the current default style. This is the same as
classDefaultStyle unless setDefaultStyle has been
called.
setDefaultStyle - Sets the default style for all subsequent static text
controls.
-----------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF2(Style, IStaticText, IWindow, IControl);
static const Style
classDefaultStyle,
left,
center,
right,
top,
vertCenter,
bottom,
mnemonic,
halftone,
underscore,
strikeout,
wordBreak,
fillBackground;
static Style
defaultStyle ( );
static void
setDefaultStyle ( Style style );
/*------------------------- Constructors/Destructor ----------------------------
| You can construct instances of this class in the following ways: |
| - From a control ID, parent and owner windows, rectangle, and style. |
| This creates the specified static text control and an object for it. |
| - From the ID of an existing static text control on a dialog window. |
| This creates the object for the specified static text control. |
| - From the window handle of an existing static text control. This |
| creates the object for the specified static text control. |
------------------------------------------------------------------------------*/
IStaticText ( unsigned long id,
IWindow* parent,
IWindow* owner,
const IRectangle& initial= IRectangle(),
const Style& style = defaultStyle() );
IStaticText ( unsigned long id,
IWindow* parent );
IStaticText ( const IWindowHandle& handle );
virtual
~IStaticText ( );
/*------------------------------- Enumerations ---------------------------------
| Alignment - Enumeration used to replace the alignment style. Values are: |
| topLeft - Text is aligned to the top of the window |
| and is left-justified. |
| topLeftWrapped - Text is aligned to the top of the window, |
| is left-justified and is multiple-line with |
| word-wrapping at ends of lines. |
| topCenter - Text is aligned to the top of the window |
| and is centered. |
| topRight - Text is aligned to the top of the window |
| and is right-justified. |
| centerLeft - Text is aligned vertically in the center of |
| the window and is left-justified. |
| centerCenter - Text is aligned vertically in the center of |
| the window and is centered. |
| centerRight - Text is aligned vertically in the center of |
| the window and is right-justified. |
| bottomLeft - Text is aligned to the bottom of the window |
| and is left-justified. |
| bottomCenter - Text is aligned to the bottom of the window |
| and is centered. |
| bottomRight - Text is aligned to the bottom of the window |
| and is right-justified. |
| |
| ColorArea - Enumeration used to replace the color for a particular region. |
| Values are: |
| foreground - Sets the color in which the text is drawn. |
| background - Sets the color of the character fields. A |
| character field is the small rectangle of space |
| that contains a character. |
| fill - Sets the color for the area of the static text |
| control window that is not occupied by text. |
------------------------------------------------------------------------------*/
enum Alignment {
topLeft,
topLeftWrapped,
topCenter,
topRight,
centerLeft,
centerCenter,
centerRight,
bottomLeft,
bottomCenter,
bottomRight
};
enum ColorArea {
foreground,
background,
fill
};
/*--------------------------- Alignment Operation ------------------------------
| setAlignment - Sets the alignment of the static text. |
| alignment - Returns the current alignment for the static text. |
------------------------------------------------------------------------------*/
IStaticText
&setAlignment ( Alignment alignment );
Alignment
alignment ( ) const;
/*-------------------------------- Attributes ------------------------------------
| These operations can be used to query and change the style of the text. |
| enableFillBackground - Either erases the background before the text is |
| drawn, or does not change the background. |
| disableFillBackground - Draws text over what is currently in the background. |
| enableStrikeout - Draws a line through the text. |
| disableStrikeout - Removes the line that has been drawn through the |
| text. |
| enableUnderscore - Draws a line beneath the text. |
| disableUnderscore - Removes the line beneath the text. |
| enableHalftone - Draws the text in the halftone style. |
| disableHalftone - Removes halftone style from the text. |
| hasFillBackground - Returns true if the background is erased before any |
| text is drawn. |
| isStrikeout - Queries whether the text has the strikeout style. |
| isUnderscore - Queries whether the text has the underscore style. |
| isHalftone - Queries whether the text has the halftone style. |
--------------------------------------------------------------------------------*/
IStaticText
&enableFillBackground ( Boolean enable = true ),
&disableFillBackground ( ),
&enableStrikeout ( Boolean enable = true ),
&disableStrikeout ( ),
&enableUnderscore ( Boolean enable = true ),
&disableUnderscore ( ),
&enableHalftone ( Boolean enable = true ),
&disableHalftone ( );
Boolean
hasFillBackground ( ) const,
isStrikeout ( ) const,
isUnderscore ( ) const,
isHalftone ( ) const;
/*----------------------------- Color Functions --------------------------------
| These functions are used to change or set the colors used by the control: |
| setColor - Changes the color of the given color region. |
| color - Returns the color of the given color region. |
------------------------------------------------------------------------------*/
IStaticText
&setColor ( ColorArea value, const IColor& color );
IColor
color ( ColorArea value ) const;
/*-------------------------- Minimum Size Adjustment ---------------------------
| The following operations set and query the number of characters that the |
| minimum size can be based on. |
| setLimit - Sets the maximum number of characters that the static text |
| control is likely to display. This function should be used by |
| static text controls that will be changing the text they |
| display while on an ISetCanvas or IMultiCellCanvas. |
| A non-zero value is used to calculate a minimum size for this |
| window that can be larger than that needed to hold the |
| currently-displayed text. The larger of the actual size |
| needed by the text or the size based on the limit specified to |
| this function is used as the minimum size. A limit of 0 |
| specifies that the minimum size should only be what is needed |
| to display the current text, which is the default if this |
| function is not called. |
| limit - Returns the maximum number of characters that the static text |
| control is likely to display. |
------------------------------------------------------------------------------*/
IStaticText
&setLimit ( unsigned long limit = 0 );
unsigned long
limit ( ) const;
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited functions: |
| setText - Sets the text for the control and notifies a parent |
| canvas to update how it lays out its child windows, |
| if appropriate. |
------------------------------------------------------------------------------*/
virtual IStaticText
&setText ( const char* text ),
&setText ( const IResourceId& text );
protected:
/*------------------------------- Layout Size ----------------------------------
| calcMinimumSize - Returns the recommended minimum size of this static text |
| control. The size is based on the text string length |
| and the current font, and the value returned by |
| calcLimitSize. |
| calcLimitSize - Returns a size based on the text limit value and the |
| current font. |
------------------------------------------------------------------------------*/
virtual ISize
calcMinimumSize ( ) const,
calcLimitSize ( ) const;
private:
/*--------------------------------- Private ----------------------------------*/
IStaticText ( const IStaticText& );
IStaticText
&operator= ( const IStaticText& );
static Style
currentDefaultStyle;
IColor
clrfill,
clrback;
Boolean
clrset;
unsigned long
ulClLimit;
friend class IStaticTextHandler;
}; // class IStaticText
INESTEDBITFLAGCLASSFUNCS(Style, IStaticText);
// global style functions
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif // _ISTATTXT_