MsgBox Class Reference

#include <msg_box.h>

Inheritance diagram for MsgBox:

Inheritance graph
[legend]
Collaboration diagram for MsgBox:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MsgBox (const Rectanglei &rect, Font *_font)
void NewMessage (const std::string &msg)
void Draw (const Point2i &mousePosition, Surface &surf) const
void SetSizePosition (const Rectanglei &rect)

Private Member Functions

void Flush ()

Private Attributes

Fontfont
std::list< Text * > messages

Detailed Description

Definition at line 31 of file msg_box.h.


Constructor & Destructor Documentation

MsgBox::MsgBox ( const Rectanglei rect,
Font _font 
)

Definition at line 26 of file msg_box.cpp.

00026                                                   :
00027    Widget(rect)
00028 {
00029   font = _font;
00030 }


Member Function Documentation

void MsgBox::Draw ( const Point2i mousePosition,
Surface surf 
) const [virtual]

Implements Widget.

Definition at line 61 of file msg_box.cpp.

00062 {
00063   // Draw the border
00064   surf.BoxColor(*this, defaultOptionColorBox);
00065   surf.RectangleColor(*this, defaultOptionColorRect,2);
00066 
00067   // Draw the messages
00068   std::list<Text*>::const_iterator it;
00069   int x = GetPositionX()+5;
00070   int y = GetPositionY()+5;
00071   for (it = messages.begin(); it != messages.end(); it++) {
00072     (*it)->DrawTopLeft(Point2i(x,y));
00073     y += (*it)->GetHeight() + 5;
00074   }
00075 }

Here is the call graph for this function:

void MsgBox::Flush (  )  [private]

Definition at line 32 of file msg_box.cpp.

00033 {
00034   std::list<Text *>::iterator it ;
00035 
00036   uint y = 5;
00037   for (it = messages.begin(); it != messages.end(); it++) 
00038     {
00039       y += (*it)->GetHeight() + 5;
00040 
00041       while (int(y) > GetSizeY() && !messages.empty()) {
00042         Text* tmp = messages.front();
00043         y -= tmp->GetHeight() - 5; 
00044         delete tmp;
00045         messages.pop_front();
00046       }
00047     }
00048 }

Here is the call graph for this function:

Here is the caller graph for this function:

void MsgBox::NewMessage ( const std::string &  msg  ) 

Definition at line 50 of file msg_box.cpp.

00051 {
00052   messages.push_back(new Text(msg));
00053   messages.back()->SetMaxWidth(GetSizeX());
00054 
00055   // Remove old messages if needed
00056   Flush();
00057 
00058   ForceRedraw();
00059 }

Here is the call graph for this function:

Here is the caller graph for this function:

void MsgBox::SetSizePosition ( const Rectanglei rect  )  [virtual]

Implements Widget.

Definition at line 77 of file msg_box.cpp.

00078 {
00079   StdSetSizePosition(rect);
00080 
00081   // render the messages with the correct width
00082   std::list<Text*>::iterator it;
00083   for (it = messages.begin(); it != messages.end(); it++) {
00084     (*it)->SetMaxWidth(GetSizeX());
00085   }
00086   
00087   // Remove old messages if needed
00088   Flush();
00089 }

Here is the call graph for this function:


Member Data Documentation

Font* MsgBox::font [private]

Definition at line 33 of file msg_box.h.

std::list<Text*> MsgBox::messages [private]

Definition at line 34 of file msg_box.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:00:53 2007 for Wormux by  doxygen 1.4.7