Planeshift
Classes | Public Member Functions | Protected Member Functions | Protected Attributes

pawsMessageTextBox Class Reference

This is a special type of text box that is used for messages. More...

#include <pawstextbox.h>

List of all members.

Classes

struct  MessageLine
struct  MessageSegment

Public Member Functions

void AddMessage (const char *data, int colour=-1)
 Add a new message to this box.
void AppendLastMessage (const char *data)
void Clear ()
virtual void Draw ()
 Draws the widget and all of it's children.
void FullScroll ()
 Sets the scrollbar to 100% (offset=max)
virtual int GetBorderStyle ()
 This returns the BORDER_BUMP style.
bool OnKeyDown (utf32_char code, utf32_char key, int modifiers)
 Process keydown messages.
virtual bool OnMouseDown (int button, int modifiers, int x, int y)
 Manage mouse down event to test for and apply window changes.
virtual void OnResize ()
 Sets the new position of the close button.
virtual bool OnScroll (int direction, pawsScrollBar *widget)
 Called whenever a window is scrolled.
virtual void OnUpdateData (const char *dataname, PAWSData &data)
 pawsMessageTextBox (const pawsMessageTextBox &origin)
 pawsMessageTextBox ()
virtual bool PostSetup ()
 This is called after the widget and all of it's children have been created.
void ReplaceLastMessage (const char *data)
void ResetScroll ()
 Resets scrollbar to starting position (offset=0)
virtual void Resize ()
 Resize a widget based on it's parent's size.
bool SelfPopulate (iDocumentNode *node)
 This function allows a widget to fill in its own contents from an xml node supplied.
virtual bool Setup (iDocumentNode *node)
 Setup this widget.
virtual bool Setup (void)
virtual ~pawsMessageTextBox ()

Protected Member Functions

void CalcLineHeight ()
 Calculates value of the lineHeight attribute.
pawsScrollBarGetScrollBar ()
 checks for a child of type pawsScrollBar.
int RenderMessage (const char *data, int lineStart, int colour)
 Renders an entire message and returns the total lines it took.
void SplitMessage (const char *newText, int colour, int size, MessageLine *&msgLine, int &startPosition)

Protected Attributes

csPDelArray< MessageLineadjusted
int lineHeight
size_t maxLines
csPDelArray< MessageLinemessages
 List of messages this box has.
pawsScrollBarscrollBar
int scrollBarWidth
int topLine

Detailed Description

This is a special type of text box that is used for messages.

This text box allows each 'message' to be stored as it's own line with it's own colours.

Definition at line 285 of file pawstextbox.h.


Constructor & Destructor Documentation

pawsMessageTextBox::pawsMessageTextBox ( )
pawsMessageTextBox::pawsMessageTextBox ( const pawsMessageTextBox origin)
virtual pawsMessageTextBox::~pawsMessageTextBox ( ) [virtual]

Member Function Documentation

void pawsMessageTextBox::AddMessage ( const char *  data,
int  colour = -1 
)

Add a new message to this box.

Parameters:
dataThe new message to add.
colourThe colour this message should be. -1 means use the default colour that is available.
void pawsMessageTextBox::AppendLastMessage ( const char *  data)
void pawsMessageTextBox::CalcLineHeight ( ) [protected]

Calculates value of the lineHeight attribute.

void pawsMessageTextBox::Clear ( )
virtual void pawsMessageTextBox::Draw ( ) [virtual]

Draws the widget and all of it's children.

Remarks:
Uses clipping rect of it's parent to define drawing area. If the drawing area defined is empty it returns.

Reimplemented from pawsWidget.

void pawsMessageTextBox::FullScroll ( )

Sets the scrollbar to 100% (offset=max)

virtual int pawsMessageTextBox::GetBorderStyle ( ) [inline, virtual]

This returns the BORDER_BUMP style.

Remarks:
Other styles available include: BORDER_RAISED, BORDER_SUNKEN and BORDER_ETCHED.

Reimplemented from pawsWidget.

Definition at line 350 of file pawstextbox.h.

pawsScrollBar* pawsMessageTextBox::GetScrollBar ( ) [protected]

checks for a child of type pawsScrollBar.

Returns:
pawsScrollBar* pointer to child or NULL
bool pawsMessageTextBox::OnKeyDown ( utf32_char  keyCode,
utf32_char  keyChar,
int  modifiers 
) [virtual]

Process keydown messages.

Parameters:
keyCodeThe code for the pressed key.
keyCharThe key pressed.
modifiersUsed to modify tab behavior.
Returns:
bool TRUE for success FALSE if no action.
Remarks:
If you override this, be sure to also override GetFocusOverridesControls() as returning true

Reimplemented from pawsWidget.

virtual bool pawsMessageTextBox::OnMouseDown ( int  button,
int  modifiers,
int  x,
int  y 
) [virtual]

Manage mouse down event to test for and apply window changes.

Parameters:
buttonType of button: 1 resizable or movable, 2 context menu or config window.
modifiersUsed with PAWS_CONSTRUCTION.
xUsed to test for resize.
yUsed to test for resize.
Returns:
bool TRUE if movable or resizable.
Remarks:
calls OnMouseDown on it's parent.

Reimplemented from pawsWidget.

virtual void pawsMessageTextBox::OnResize ( ) [virtual]

Sets the new position of the close button.

Reimplemented from pawsWidget.

virtual bool pawsMessageTextBox::OnScroll ( int  scrollDirection,
pawsScrollBar widget 
) [virtual]

Called whenever a window is scrolled.

Parameters:
scrollDirectionThe direction to move.
widgetThe scrollbar widget being manipulated.
Returns:
bool Parent's result or FALSE if no parent.

Reimplemented from pawsWidget.

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

Reimplemented from pawsWidget.

virtual bool pawsMessageTextBox::PostSetup ( ) [virtual]

This is called after the widget and all of it's children have been created.

Remarks:
This can be useful for widgets that want to get pointers to some of it's children for quick access.

Reimplemented from pawsWidget.

int pawsMessageTextBox::RenderMessage ( const char *  data,
int  lineStart,
int  colour 
) [protected]

Renders an entire message and returns the total lines it took.

void pawsMessageTextBox::ReplaceLastMessage ( const char *  data)
void pawsMessageTextBox::ResetScroll ( )

Resets scrollbar to starting position (offset=0)

virtual void pawsMessageTextBox::Resize ( ) [virtual]

Resize a widget based on it's parent's size.

Reimplemented from pawsWidget.

bool pawsMessageTextBox::SelfPopulate ( iDocumentNode *  node) [virtual]

This function allows a widget to fill in its own contents from an xml node supplied.

This is NOT the same as Setup, which is defining height, width, styles, etc. This is data.

Reimplemented from pawsWidget.

virtual bool pawsMessageTextBox::Setup ( iDocumentNode *  ) [virtual]

Setup this widget.

Reimplemented from pawsWidget.

virtual bool pawsMessageTextBox::Setup ( void  ) [virtual]
void pawsMessageTextBox::SplitMessage ( const char *  newText,
int  colour,
int  size,
MessageLine *&  msgLine,
int startPosition 
) [protected]

Member Data Documentation

csPDelArray<MessageLine> pawsMessageTextBox::adjusted [protected]

Definition at line 386 of file pawstextbox.h.

Definition at line 388 of file pawstextbox.h.

size_t pawsMessageTextBox::maxLines [protected]

Definition at line 389 of file pawstextbox.h.

csPDelArray<MessageLine> pawsMessageTextBox::messages [protected]

List of messages this box has.

Definition at line 371 of file pawstextbox.h.

Definition at line 393 of file pawstextbox.h.

Definition at line 394 of file pawstextbox.h.

Definition at line 391 of file pawstextbox.h.


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