ListBoxWithLabel Class Reference

#include <list_box_w_label.h>

Inheritance diagram for ListBoxWithLabel:

Inheritance graph
[legend]
Collaboration diagram for ListBoxWithLabel:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ListBoxWithLabel (const std::string &label, const Rectanglei &rect)
 ~ListBoxWithLabel ()
void Draw (const Point2i &mousePosition, Surface &surf) const
void SetSizePosition (const Rectanglei &rect)

Private Attributes

Texttxt_label

Detailed Description

Definition at line 28 of file list_box_w_label.h.


Constructor & Destructor Documentation

ListBoxWithLabel::ListBoxWithLabel ( const std::string &  label,
const Rectanglei rect 
)

Definition at line 32 of file list_box_w_label.cpp.

00032                                                                                   : ListBox(rect)
00033 {  
00034   txt_label = new Text(label, dark_gray_color, Font::GetInstance(Font::FONT_NORMAL, Font::BOLD), false);
00035   SetSizePosition(rect);
00036   txt_label->SetMaxWidth(GetSizeX());
00037 }

Here is the call graph for this function:

ListBoxWithLabel::~ListBoxWithLabel (  ) 

Definition at line 39 of file list_box_w_label.cpp.

00040 {
00041    delete txt_label;
00042 }


Member Function Documentation

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

Reimplemented from ListBox.

Definition at line 44 of file list_box_w_label.cpp.

00045 {
00046   int item = MouseIsOnWhichItem(mousePosition);
00047 
00048   Rectanglei rect (GetPositionX(),GetPositionY(),GetSizeX(),
00049                    GetSizeY()- 2 - txt_label->GetHeight());
00050 
00051   surf.BoxColor(rect, defaultListColor1);
00052   surf.RectangleColor(rect, white_color);
00053 
00054   for(uint i=0; i < nb_visible_items; i++){
00055     Rectanglei rect(GetPositionX() + 1, 
00056                     GetPositionY() + i * height_item + 1, 
00057                     GetSizeX() - 2, 
00058                     height_item - 2);
00059     
00060     if( int(i + first_visible_item) == selected_item) {
00061        surf.BoxColor(rect, defaultListColor2);
00062     }
00063     else if( i + first_visible_item == uint(item) ) {
00064       surf.BoxColor(rect, defaultListColor3);
00065     }
00066      
00067     (*Font::GetInstance(Font::FONT_SMALL)).WriteLeft( 
00068                                                      GetPosition() + Point2i(5, i*height_item),
00069                                                      m_items[i + first_visible_item]->GetLabel(),
00070                                                      white_color);
00071     if(!m_items[i]->IsEnabled())
00072       surf.BoxColor(rect, defaultDisabledColorBox);
00073   }  
00074 
00075   // Draw the label
00076   txt_label->DrawTopLeft( GetPositionX(), GetPositionY() + GetSizeY() - txt_label->GetHeight() );
00077 
00078   // buttons for listbox with more items than visible
00079   if (m_items.size() > nb_visible_items_max){
00080     m_up->Draw(mousePosition, surf);
00081     m_down->Draw(mousePosition, surf);
00082 #ifdef SCROLLBAR
00083     uint tmp_y, tmp_h;
00084     tmp_y = y+10+ first_visible_item* (h-20) / m_items.size();
00085     tmp_h = nb_visible_items_max * (h-20) / m_items.size();
00086     if (tmp_h < 5) tmp_h =5;
00087 
00088     boxRGBA(surf, 
00089             x+w-10, tmp_y,
00090             x+w-1,  tmp_y+tmp_h,
00091             white_color);
00092 #endif
00093   }
00094 }

Here is the call graph for this function:

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

Reimplemented from ListBox.

Definition at line 96 of file list_box_w_label.cpp.

00097 {
00098   StdSetSizePosition(rect);
00099   txt_label->SetMaxWidth(GetSizeX());
00100 
00101   m_up->SetSizePosition( Rectanglei(GetPositionX() + GetSizeX() - m_up->GetSizeX() - 2, 
00102                                     GetPositionY()+2, 
00103                                     m_up->GetSizeX(), m_up->GetSizeY()) );
00104 
00105   m_down->SetSizePosition( Rectanglei(GetPositionX() + GetSizeX() - m_down->GetSizeX() - 2, 
00106                                       GetPositionY() + GetSizeY() - m_down->GetSizeY() - 2 -
00107                                       txt_label->GetHeight() - 2,
00108                                       m_down->GetSizeX(), 
00109                                       m_down->GetSizeY()) );  
00110 
00111   nb_visible_items_max = GetSizeY()/height_item;
00112 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Text* ListBoxWithLabel::txt_label [private]

Definition at line 31 of file list_box_w_label.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 13:55:52 2007 for Wormux by  doxygen 1.4.7