#include <wg_listbox.h>
Inheritance diagram for wGui::CListBox:
The button will generate CTRL_VALUECHANGE messages when a different listbox item is selected The iNewValue of the message is the index of the item that was selected
Definition at line 58 of file wg_listbox.h.
wGui::CListBox::CListBox | ( | const CRect & | WindowRect, | |
CWindow * | pParent, | |||
bool | bSingleSelection = false , |
|||
unsigned int | iItemHeight = 15 , |
|||
CFontEngine * | pFontEngine = 0 | |||
) |
Constructs a new listbox
WindowRect | A CRect that defines the outer limits of the control | |
pParent | A pointer to the parent window | |
bSingleSelection | If true, only one item can be selected at a time, defaults to false | |
iItemHeight | The height of the items in the list, defaults to 15 | |
pFontEngine | A pointer to the font engine to use when drawing the control If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object) |
Definition at line 36 of file wg_listbox.cpp.
References wGui::COLOR_WHITE, wGui::CMessage::CTRL_VALUECHANGE, wGui::CMessage::CTRL_VALUECHANGING, Draw(), wGui::CApplication::GetDefaultFontEngine(), wGui::CRect::Height(), wGui::CMessageServer::Instance(), wGui::CApplication::Instance(), wGui::CMessage::KEYBOARD_KEYDOWN, wGui::CWindow::m_BackgroundColor, wGui::CWindow::m_ClientRect, m_pFontEngine, m_pVScrollbar, wGui::CWindow::m_WindowRect, wGui::CMessageServer::RegisterMessageClient(), wGui::CRangeControl< T >::SetMaxLimit(), wGui::CRect::SizeRect(), wGui::CScrollBar::VERTICAL, and wGui::CRect::Width().
unsigned int wGui::CListBox::GetItemHeight | ( | void | ) | [inline] |
Gets the height of the items
Definition at line 75 of file wg_listbox.h.
References m_iItemHeight.
Referenced by wGui::CDropDown::SetListboxHeight(), and wGui::CDropDown::SetWindowRect().
void wGui::CListBox::SetItemHeight | ( | unsigned int | iItemHeight | ) |
Sets the heigh of the items in the listbox
iItemHeight | The height of the items in the listbox |
Definition at line 72 of file wg_listbox.cpp.
References Draw(), and m_iItemHeight.
int wGui::CListBox::AddItem | ( | SListItem | ListItem | ) |
Adds a new item to the list
ListItem | A SListItem structure with the data for the item |
Definition at line 79 of file wg_listbox.cpp.
References Draw(), wGui::CRenderedString::HALIGN_LEFT, wGui::CRect::Height(), wGui::CWindow::m_ClientRect, m_iItemHeight, m_Items, m_pFontEngine, m_pVScrollbar, m_RenderedStrings, m_SelectedItems, wGui::CRangeControl< T >::SetMaxLimit(), wGui::SListItem::sItemText, and wGui::CRenderedString::VALIGN_TOP.
Referenced by wGui::CDropDown::AddItem().
SListItem& wGui::CListBox::GetItem | ( | int | iItemIndex | ) | [inline] |
Returns the desired item
iItemIndex | The index of the item to check (will throw an exception if the index is out of range) |
Definition at line 89 of file wg_listbox.h.
References m_Items.
Referenced by wGui::CDropDown::GetItem(), and wGui::CDropDown::HandleMessage().
void wGui::CListBox::RemoveItem | ( | int | iItemIndex | ) |
Remove an item from the list
iItemIndex | The index of the item to remove |
Definition at line 93 of file wg_listbox.cpp.
References Draw(), wGui::CRect::Height(), wGui::CWindow::m_ClientRect, m_iItemHeight, m_Items, m_pVScrollbar, m_SelectedItems, and wGui::CRangeControl< T >::SetMaxLimit().
Referenced by wGui::CDropDown::RemoveItem().
int wGui::CListBox::Size | ( | void | ) | [inline] |
Gets the number of items in the listbox
Definition at line 100 of file wg_listbox.h.
References m_Items.
Referenced by HandleMessage(), and wGui::CDropDown::Size().
bool wGui::CListBox::IsSelected | ( | int | iItemIndex | ) | [inline] |
iItemIndex | The index of the item to check (will return false if the index is out of range) |
Definition at line 104 of file wg_listbox.h.
References m_SelectedItems.
Referenced by HandleMessage(), wGui::CDropDown::IsSelected(), and OnMouseButtonUp().
int wGui::CListBox::GetFirstSelectedIndex | ( | void | ) | const |
Get the index of the first selected item
Definition at line 117 of file wg_listbox.cpp.
References m_Items, and m_SelectedItems.
Referenced by wGui::CDropDown::GetFirstSelectedIndex().
void wGui::CListBox::SetSelection | ( | int | iItemIndex, | |
bool | bSelected | |||
) |
Set an item as selected
iItemIndex | The index of the item to change | |
bSelected | Will select the item if true, or unselect if false |
Definition at line 133 of file wg_listbox.cpp.
References m_SelectedItems.
Referenced by HandleMessage(), OnMouseButtonUp(), and wGui::CDropDown::SetSelection().
void wGui::CListBox::SetAllSelections | ( | bool | bSelected | ) |
Set the selection for all of the items at once
bSelected | Will select all items if true, or unselect if false |
Definition at line 140 of file wg_listbox.cpp.
References m_Items, and m_SelectedItems.
Referenced by wGui::CDropDown::HandleMessage(), OnMouseButtonUp(), and wGui::CDropDown::SetAllSelections().
void wGui::CListBox::SetDropDown | ( | CWindow * | pDropDown | ) | [inline] |
Set the dropdown window this is a part of
pDropDown | A pointer to the dropdown window |
Definition at line 122 of file wg_listbox.h.
References m_pDropDown.
Referenced by wGui::CDropDown::CDropDown().
void wGui::CListBox::SetWindowRect | ( | const CRect & | WindowRect | ) | [virtual] |
Giving a control a new WindowRect will move and resize the control
WindowRect | A CRect that defines the outer limits of the control |
Reimplemented from wGui::CWindow.
Definition at line 184 of file wg_listbox.cpp.
References wGui::CRect::Grow(), wGui::CRect::Height(), wGui::CWindow::m_ClientRect, m_pVScrollbar, wGui::CWindow::m_WindowRect, wGui::CScrollBar::SetWindowRect(), wGui::CWindow::SetWindowRect(), wGui::CRect::SizeRect(), and wGui::CRect::Width().
Referenced by wGui::CDropDown::SetListboxHeight(), and wGui::CDropDown::SetWindowRect().
void wGui::CListBox::PaintToSurface | ( | SDL_Surface & | ScreenSurface, | |
SDL_Surface & | FloatingSurface, | |||
const CPoint & | Offset | |||
) | const [virtual] |
Blit the window to the given surface, using m_WindowRect as the offset into the surface
ScreenSurface | A reference to the surface that the window will be copied to | |
FloatingSurface | A reference to the floating surface which is overlayed at the very end (used for tooltips, menus and such) | |
Offset | This is the current offset into the Surface that should be used as reference |
Reimplemented from wGui::CWindow.
Definition at line 195 of file wg_listbox.cpp.
References wGui::CWindow::m_bVisible, wGui::CWindow::m_ChildWindows, wGui::CWindow::m_ClientRect, m_pDropDown, wGui::CWindow::m_pSDLSurface, wGui::CWindow::m_WindowRect, wGui::CWindow::PaintToSurface(), wGui::CRect::SizeRect(), and wGui::CRect::TopLeft().
bool wGui::CListBox::OnMouseButtonDown | ( | CPoint | Point, | |
unsigned int | Button | |||
) | [virtual] |
This is called whenever the listbox is clicked on by the mouse Only the topmost window that bounds the point will be called by the system
Point | The point where the mouse clicked | |
Button | A bitfield indicating which button the window was clicked with |
Reimplemented from wGui::CWindow.
Definition at line 218 of file wg_listbox.cpp.
References Draw(), wGui::CApplication::GetKeyFocus(), wGui::CRangeControl< T >::GetValue(), wGui::CRect::HitTest(), wGui::CApplication::Instance(), wGui::CMouseMessage::LEFT, wGui::CWindow::m_bVisible, wGui::CWindow::m_ClientRect, m_iFocusedItem, m_iItemHeight, m_Items, m_pVScrollbar, wGui::CWindow::m_WindowRect, wGui::CWindow::OnMouseButtonDown(), wGui::CRect::RELPOS_INSIDE, wGui::CApplication::SetKeyFocus(), wGui::CRect::SizeRect(), wGui::CRect::Top(), wGui::CWindow::ViewToWindow(), and wGui::CPoint::YPos().
bool wGui::CListBox::OnMouseButtonUp | ( | CPoint | Point, | |
unsigned int | Button | |||
) | [virtual] |
This is called whenever the a mouse button is released in the listbox Only the topmost window that bounds the point will be called by the system
Point | The point where the mouse clicked | |
Button | A bitfield indicating which button the window was clicked with |
Reimplemented from wGui::CWindow.
Definition at line 243 of file wg_listbox.cpp.
References wGui::CMessage::CTRL_VALUECHANGE, Draw(), wGui::CRangeControl< T >::GetValue(), wGui::CRect::HitTest(), wGui::CMessageServer::Instance(), IsSelected(), wGui::CMouseMessage::LEFT, m_bSingleSelection, wGui::CWindow::m_bVisible, wGui::CWindow::m_ClientRect, m_iFocusedItem, m_iItemHeight, m_pDropDown, wGui::CWindow::m_pParentWindow, m_pVScrollbar, wGui::CWindow::OnMouseButtonUp(), wGui::CMessageServer::QueueMessage(), wGui::CRect::RELPOS_INSIDE, SetAllSelections(), SetSelection(), wGui::CRect::Top(), wGui::CWindow::ViewToWindow(), and wGui::CPoint::YPos().
bool wGui::CListBox::HandleMessage | ( | CMessage * | pMessage | ) | [virtual] |
CListBoxes handle MOUSE_BUTTONDOWN, MOUSE_BUTTONUP and CTRL_VALUECHANGE messages
pMessage | A pointer to the message |
Reimplemented from wGui::CWindow.
Definition at line 272 of file wg_listbox.cpp.
References wGui::CMessage::CTRL_VALUECHANGE, wGui::CMessage::CTRL_VALUECHANGING, Draw(), wGui::CRangeControl< T >::GetValue(), wGui::CWindow::HandleMessage(), wGui::CRect::Height(), IsSelected(), wGui::CMessage::KEYBOARD_KEYDOWN, wGui::CWindow::m_ClientRect, m_iFocusedItem, m_iItemHeight, m_Items, m_pVScrollbar, wGui::CMessage::MessageType(), SetSelection(), wGui::CScrollBar::SetValue(), Size(), and wGui::CMessage::Source().