wGui::CListBox Class Reference

A simple listbox class. More...

#include <wg_listbox.h>

Inheritance diagram for wGui::CListBox:

wGui::CWindow wGui::CMessageClient

Public Member Functions

Protected Attributes


Detailed Description

A simple listbox class.

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.


Constructor & Destructor Documentation

wGui::CListBox::CListBox ( const CRect WindowRect,
CWindow pParent,
bool  bSingleSelection = false,
unsigned int  iItemHeight = 15,
CFontEngine pFontEngine = 0 
)

Constructs a new listbox

Parameters:
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().


Member Function Documentation

unsigned int wGui::CListBox::GetItemHeight ( void   )  [inline]

Gets the height of the items

Returns:
The height of the items in the listbox

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

Parameters:
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

Parameters:
ListItem A SListItem structure with the data for the item
Returns:
The index of the added 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

Parameters:
iItemIndex The index of the item to check (will throw an exception if the index is out of range)
Returns:
A reference to the SListItem struct

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

Parameters:
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

Returns:
The number of items in the list

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]

Parameters:
iItemIndex The index of the item to check (will return false if the index is out of range)
Returns:
true if the item is selected

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

Returns:
The index of the first selected item, or -1 if no item is selected

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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
Point The point where the mouse clicked
Button A bitfield indicating which button the window was clicked with
Returns:
True if it's in the bounds of the listbox

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

Parameters:
Point The point where the mouse clicked
Button A bitfield indicating which button the window was clicked with
Returns:
True if it's in the bounds of the listbox

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

Parameters:
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().


The documentation for this class was generated from the following files:
Generated on Wed May 16 23:11:27 2007 for wGui by  doxygen 1.5.1