#include <msg_box.h>
Inheritance diagram for MsgBox:
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 | |
Font * | font |
std::list< Text * > | messages |
Definition at line 31 of file msg_box.h.
MsgBox::MsgBox | ( | const Rectanglei & | rect, | |
Font * | _font | |||
) |
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:
Font* MsgBox::font [private] |
std::list<Text*> MsgBox::messages [private] |