Planeshift
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

pawsTextBox Class Reference

A basic text box widget. More...

#include <pawstextbox.h>

List of all members.

Public Types

enum  pawsHorizAdjust { horizLEFT, horizRIGHT, horizCENTRE }
 

Various positions to center the text on horizontally.

More...
enum  pawsVertAdjust { vertTOP, vertBOTTOM, vertCENTRE }
 

Various positions to center the text on vertically.

More...

Public Member Functions

void Adjust (pawsHorizAdjust horiz, pawsVertAdjust vert)
 Alters how the text box is laid out in its container.
void Draw ()
 Draws the text box.
void FormatText (const char *fmt,...)
 Sets the text to display using formatting.
virtual int GetBorderStyle ()
 Gets the border style for the text box.
virtual int GetFontColour ()
 Gets the font color based on the set colour and if grayed is set.
const char * GetText () const
 Gets the text that is displayed by this text box.
void Grayed (bool g)
 Sets if the text box is having its text grayed.
void HorizAdjust (pawsHorizAdjust horiz)
 Alters how the text box is laid out horizontally in its container.
virtual bool OnGainFocus (bool)
 Normal text boxes should not be focused.
virtual void OnUpdateData (const char *dataname, PAWSData &data)
 Called whenever subscribed data gets updated Sets the text to either the data's string value or a properly formatted float representation.
 pawsTextBox (const pawsTextBox &origin)
 Copy constructor.
 pawsTextBox ()
 Basic constructor.
bool SelfPopulate (iDocumentNode *node)
 Sets the text from the node using either the text attribute or the node's content.
void SetSizeByText (int padX, int padY)
 Sets the size of the widget to fit the text that it displays.
void SetText (const char *text)
 Sets the text to display.
bool Setup (iDocumentNode *node)
 Sets up the text box from a document node
Possible attributes in the node:
void SetVertical (bool vertical)
 Sets if this text box should be rendered vertically (top to bottom)
void VertAdjust (pawsVertAdjust vert)
 Alters how the text box is laid out vertically in its container.
virtual ~pawsTextBox ()
 Basic deconstructor.

Static Public Member Functions

static int CountCodePoints (const char *text, int start=0, int len=-1)
 Utility function to calculate number of code points in a substring.
static int RewindCodePoints (const char *text, int start, int count)
 Utility function to rewind a UTF-8 string by a certain number of codepoints.
static int SkipCodePoints (const char *text, int start, int count)
 Utility function to skip a UTF-8 string by a certain number of codepoints.

Protected Member Functions

void CalcLetterSizes ()
 Fills 'letterSizes' array.
void CalcTextPos ()
 Calculates textX and textY attributes.
void CalcTextSize (int &width, int &height)
 Calculates size of text.

Protected Attributes

int colour
 The colour of the text.
bool grayed
 Whether the text is currently being grayed out.
pawsHorizAdjust horizAdjust
 The current horizontal alignment for the text box.
psPointletterSizes
 Array containing the size of each letter in text (only used when vertical is true)
csString text
 The text for this box.
int textWidth
 Width of vertical column of letters (only used when vertical is true)
int textX
 X-Position of text inside the widget (relative to adjustment)
int textY
 X-Position of text inside the widget (relative to adjustment)
pawsVertAdjust vertAdjust
 The current vertical alignment for the text box.
bool vertical
 Whether the text box is rendering vertically (up-down rather than left-right)

Detailed Description

A basic text box widget.

Useful for simply displaying text.

Definition at line 42 of file pawstextbox.h.


Member Enumeration Documentation

Various positions to center the text on horizontally.

Enumerator:
horizLEFT 

Adjusted to left.

horizRIGHT 

Adjusted to right.

horizCENTRE 

Adjusted to centre.

Definition at line 58 of file pawstextbox.h.

Various positions to center the text on vertically.

Enumerator:
vertTOP 

Adjusted to top.

vertBOTTOM 

Adjusted to bottom.

vertCENTRE 

Adjusted to centre.

Definition at line 48 of file pawstextbox.h.


Constructor & Destructor Documentation

pawsTextBox::pawsTextBox ( )

Basic constructor.

virtual pawsTextBox::~pawsTextBox ( ) [virtual]

Basic deconstructor.

pawsTextBox::pawsTextBox ( const pawsTextBox origin)

Copy constructor.


Member Function Documentation

void pawsTextBox::Adjust ( pawsHorizAdjust  horiz,
pawsVertAdjust  vert 
)

Alters how the text box is laid out in its container.

Parameters:
horizSets the horizontal alignment for the text
vertSets the vertical alignment for the text
void pawsTextBox::CalcLetterSizes ( ) [protected]

Fills 'letterSizes' array.

Can be called only when vertical==true

void pawsTextBox::CalcTextPos ( ) [protected]

Calculates textX and textY attributes.

void pawsTextBox::CalcTextSize ( int width,
int height 
) [protected]

Calculates size of text.

Parameters:
widthTarget to store width of text into
heightTarget to store height of text into
static int pawsTextBox::CountCodePoints ( const char *  text,
int  start = 0,
int  len = -1 
) [static]

Utility function to calculate number of code points in a substring.

Parameters:
textText to calculate on
startIndex to start on
lenLength to perform calculation on or -1 for start to end
Returns:
Number of code points
void pawsTextBox::Draw ( ) [virtual]

Draws the text box.

Reimplemented from pawsWidget.

void pawsTextBox::FormatText ( const char *  fmt,
  ... 
)

Sets the text to display using formatting.

Parameters:
fmtThe format to use to format the string to display
virtual int pawsTextBox::GetBorderStyle ( ) [inline, virtual]

Gets the border style for the text box.

Returns:
Always BORDER_SUNKEN

Reimplemented from pawsWidget.

Definition at line 167 of file pawstextbox.h.

virtual int pawsTextBox::GetFontColour ( ) [virtual]

Gets the font color based on the set colour and if grayed is set.

Returns:
Gray if grayed is true, colour otherwise

Reimplemented from pawsWidget.

const char* pawsTextBox::GetText ( ) const [inline]

Gets the text that is displayed by this text box.

Returns:
text

Definition at line 119 of file pawstextbox.h.

void pawsTextBox::Grayed ( bool  g) [inline]

Sets if the text box is having its text grayed.

Parameters:
gOverwrites grayed

Definition at line 176 of file pawstextbox.h.

void pawsTextBox::HorizAdjust ( pawsHorizAdjust  horiz)

Alters how the text box is laid out horizontally in its container.

Parameters:
horizSets the horizontal alignment for the text
virtual bool pawsTextBox::OnGainFocus ( bool  ) [inline, virtual]

Normal text boxes should not be focused.

Does nothing

Returns:
false

Reimplemented from pawsWidget.

Definition at line 158 of file pawstextbox.h.

virtual void pawsTextBox::OnUpdateData ( const char *  dataname,
PAWSData data 
) [virtual]

Called whenever subscribed data gets updated Sets the text to either the data's string value or a properly formatted float representation.

Parameters:
datanameUnused
dataThe data to update the text with

Reimplemented from pawsWidget.

static int pawsTextBox::RewindCodePoints ( const char *  text,
int  start,
int  count 
) [static]

Utility function to rewind a UTF-8 string by a certain number of codepoints.

Parameters:
textText to calculate on
startIndex to begin rewinding at
countNumber of code points to rewind by
Returns:
Resulting index
bool pawsTextBox::SelfPopulate ( iDocumentNode *  node) [virtual]

Sets the text from the node using either the text attribute or the node's content.

Parameters:
nodeThe node to pull the text from
Returns:
True if data is pulled, false if the node is empty

Reimplemented from pawsWidget.

void pawsTextBox::SetSizeByText ( int  padX,
int  padY 
)

Sets the size of the widget to fit the text that it displays.

Parameters:
padXHorizontal padding
padYVertical padding
void pawsTextBox::SetText ( const char *  text)

Sets the text to display.

Parameters:
textThe string
bool pawsTextBox::Setup ( iDocumentNode *  node) [virtual]

Sets up the text box from a document node
Possible attributes in the node:

  • vertical - yes/no
  • text
    • horizAdjust - CENTRE/RIGHT/LEFT
    • vertAdjust - CENTRE/BOTTOM/TOP
    • string - text
Parameters:
nodeThe node to pull the attributes from
Returns:
True

Reimplemented from pawsWidget.

void pawsTextBox::SetVertical ( bool  vertical)

Sets if this text box should be rendered vertically (top to bottom)

Parameters:
verticalWhether it should be rendered vertically
static int pawsTextBox::SkipCodePoints ( const char *  text,
int  start,
int  count 
) [static]

Utility function to skip a UTF-8 string by a certain number of codepoints.

Parameters:
textText to calculate on
startIndex to begin rewinding at
countNumber of code points to rewind by
Returns:
Resulting index
void pawsTextBox::VertAdjust ( pawsVertAdjust  vert)

Alters how the text box is laid out vertically in its container.

Parameters:
vertSets the vertical alignment for the text

Member Data Documentation

int pawsTextBox::colour [protected]

The colour of the text.

Definition at line 245 of file pawstextbox.h.

bool pawsTextBox::grayed [protected]

Whether the text is currently being grayed out.

Definition at line 248 of file pawstextbox.h.

The current horizontal alignment for the text box.

Definition at line 251 of file pawstextbox.h.

Array containing the size of each letter in text (only used when vertical is true)

Definition at line 269 of file pawstextbox.h.

csString pawsTextBox::text [protected]

The text for this box.

Definition at line 242 of file pawstextbox.h.

Width of vertical column of letters (only used when vertical is true)

Definition at line 266 of file pawstextbox.h.

int pawsTextBox::textX [protected]

X-Position of text inside the widget (relative to adjustment)

Definition at line 260 of file pawstextbox.h.

int pawsTextBox::textY [protected]

X-Position of text inside the widget (relative to adjustment)

Definition at line 263 of file pawstextbox.h.

The current vertical alignment for the text box.

Definition at line 254 of file pawstextbox.h.

bool pawsTextBox::vertical [protected]

Whether the text box is rendering vertically (up-down rather than left-right)

Definition at line 257 of file pawstextbox.h.


The documentation for this class was generated from the following file: