Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

Ars::XDropDown Class Reference

#include <xdropdown.h>

Inheritance diagram for Ars::XDropDown:

Inheritance graph
[legend]
Collaboration diagram for Ars::XDropDown:

Collaboration graph
[legend]

Public Member Functions

 XDropDown (void)
virtual ~XDropDown (void)
 Standard destructor.

virtual void Init (icstring &aStr)
virtual const bool SetupWindow (const Message &msg)
 Deregister the setup_window message.

const int AddItem (XListItem ListItem)
const int AddItem (const std::string &aText)
XListItemGetItem (const int iItemIndex)
void RemoveItem (const int iItemIndex)
void ClearItems (void)
 Remove all items from the list.

unsigned int GetItemHeight (void)
void SetItemHeight (const unsigned int iItemHeight)
 iItemHeight The height of the items in the listbox

const int Size (void)
 The number of items in the list.

const bool IsSelected (const int iItemIndex)
void SetSelection (const int iItemIndex, const bool bSelected)
void SetAllSelections (const bool bSelected)

Protected Member Functions

void ShowListBox (void)
 Shows the drop down listbox.

void HideListBox (void)
 Hides the drop down listbox.

virtual const bool evValueChange (const CtrlMessage &msg)
virtual const bool evMouseLClick (const CtrlMessage &msg)
virtual const bool wmLostFocus (const CtrlMessage &msg)

Private Attributes

XListBoxlistBox
 A pointer to teh drop down's list box.

XButtonImagedropButton
 A pointer to the drop down's drop button.


Constructor & Destructor Documentation

Ars::XDropDown::XDropDown void   ) 
 

Construct a new DropDown control

Parameters:
WindowRect A CRect that defines the outer limits of the control (this only controls the dimensions of the edit control portion of the drop down)

Definition at line 5 of file xdropdown.cpp.

00006 : listBox( 0 ) , dropButton( 0 )
00007 {
00008 }

virtual Ars::XDropDown::~XDropDown void   )  [inline, virtual]
 

Standard destructor.

Definition at line 18 of file xdropdown.h.

00018 { }


Member Function Documentation

const int Ars::XDropDown::AddItem const std::string &  aText  )  [inline]
 

Definition at line 35 of file xdropdown.h.

References Ars::XListBox::AddItem(), and listBox.

00035 {       return listBox->AddItem( aText );       }

const int Ars::XDropDown::AddItem XListItem  ListItem  )  [inline]
 

Adds a new item to the list

Parameters:
ListItem A XListItem structure with the data for the item
Returns:
The index of the added item

Definition at line 34 of file xdropdown.h.

References Ars::XListBox::AddItem(), and listBox.

00034 {       return listBox->AddItem( ListItem );    }

void Ars::XDropDown::ClearItems void   )  [inline]
 

Remove all items from the list.

Definition at line 47 of file xdropdown.h.

References Ars::XListBox::ClearItems(), and listBox.

00047 { listBox->ClearItems(); }

const bool Ars::XDropDown::evMouseLClick const CtrlMessage msg  )  [protected, virtual]
 

Reimplemented from Ars::MessageClient.

Definition at line 95 of file xdropdown.cpp.

References dropButton, HideListBox(), Ars::Window::IsVisible(), listBox, ShowListBox(), and Ars::CtrlMessage::source.

00096 {
00097         bool ans = XEditBox::evMouseLClick( msg );
00098 
00099         if( msg.source == dropButton )
00100         {
00101                 if( listBox->IsVisible() )
00102                         HideListBox();
00103                 else
00104                         ShowListBox();
00105                 ans = true;
00106         }
00107         return ans;
00108 }

const bool Ars::XDropDown::evValueChange const CtrlMessage msg  )  [protected, virtual]
 

Reimplemented from Ars::MessageClient.

Definition at line 70 of file xdropdown.cpp.

References ArsPostMessage, Ars::Message::Destination(), Ars::XListBox::GetItem(), Ars::Window::GetParent(), HideListBox(), Ars::XListItem::itemText, listBox, Ars::XListBox::SetAllSelections(), Ars::XEditBox::SetWndText(), Ars::CtrlMessage::source, and Ars::CtrlMessage::value.

00071 {
00072         bool ans = XEditBox::evValueChange( msg );
00073 
00074         if( msg.Destination() == this )
00075         {
00076                 if( msg.source == listBox )
00077                 {
00078                         const XListItem &ListItem = listBox->GetItem( msg.value );
00079                         SetWndText( ListItem.itemText );
00080                         HideListBox();
00081                         ArsPostMessage( CtrlMessage( Message::CTRL_VALUECHANGE, GetParent() , this , 0 ) );
00082                         ans = true;
00083                 }
00084                 else if( msg.source == this )
00085                 {
00086                         listBox->SetAllSelections( false );
00087                         HideListBox();
00088                         ArsPostMessage( CtrlMessage( Message::CTRL_VALUECHANGE, GetParent(), this, 0));
00089                         ans = true;
00090                 }
00091         }
00092         return ans;
00093 }

XListItem& Ars::XDropDown::GetItem const int  iItemIndex  )  [inline]
 

Returns the desired item

Parameters:
iItemIndex The index of the item to check
Returns:
A reference to the SListItem struct

Definition at line 40 of file xdropdown.h.

References Ars::XListBox::GetItem(), and listBox.

00040 { return listBox->GetItem( iItemIndex ); }

unsigned int Ars::XDropDown::GetItemHeight void   )  [inline]
 

Returns:
The height of the items in the listbox

Definition at line 52 of file xdropdown.h.

References Ars::XListBox::GetItemHeight(), and listBox.

00052 { return listBox->GetItemHeight(); }

void Ars::XDropDown::HideListBox void   )  [protected]
 

Hides the drop down listbox.

Definition at line 119 of file xdropdown.cpp.

References Ars::Window::HideWindow(), Ars::Window::IsVisible(), listBox, and Ars::Window::UpdateWindow().

Referenced by evMouseLClick(), evValueChange(), SetupWindow(), and wmLostFocus().

00120 {
00121         if( listBox->IsVisible() )
00122         {
00123                 listBox->HideWindow();
00124                 listBox->UpdateWindow( true );
00125         }
00126 }

void Ars::XDropDown::Init icstring aStr  )  [virtual]
 

Initialize the thing object via a string the CAR identifiers used are: (Button <s-expression> ): List of the drop button definition (listbox <s-expression> ): list for the listbox definition

Reimplemented from Ars::Window.

Definition at line 10 of file xdropdown.cpp.

References dropButton, F_NONE, F_SELECTABLE, Ars::Thing::GetBgColor(), Ars::Thing::GetFgColor(), Ars::HPaint::GetFont(), Ars::XRect::Grow(), Ars::XRect::Height(), icstring, Ars::XButtonImage::Init(), Ars::XListBox::Init(), listBox, Ars::XRect::Right(), S_RAISED, S_SUNKEN, Ars::Thing::SetBgColor(), Ars::Thing::SetFgColor(), Ars::Thing::SetFlags(), Ars::HPaint::SetFont(), Ars::Thing::SetState(), Ars::Window::SetWindowRect(), Ars::XListBox::SetWindowRect(), Ars::XLabel::SetWndText(), and Ars::XRect::XRect().

00011 {
00012         XEditBox::Init( aStr );
00013 
00014         XRect r( *this );
00015         r.y += 20;
00016         r.h -= 20;
00017         r.Grow( -1 );
00018         if( !listBox )
00019                 listBox = new XListBox();
00020         listBox->SetWindowRect( r );
00021         listBox->SetBgColor( GetBgColor() );
00022         listBox->SetFgColor( GetFgColor().FadeColor( 32 ) );
00023         listBox->SetFlags( F_NONE );
00024         listBox->SetState( S_SUNKEN );
00025         listBox->SetFont( GetFont() );
00026         icstring        tmp = Rsrc::FindCrdOf( aStr , "listbox" );
00027         listBox->Init( tmp );
00028 
00029         r = *this;
00030         r.h = 20;
00031         r.Grow( -1 );
00032         
00033         tmp = Rsrc::FindCrdOf( aStr , "button" );
00034 
00035         if( !dropButton )
00036                 dropButton = new XButtonImage();
00037         dropButton->SetWindowRect( XRect( r.Right() - 20, r.y , 20 , r.Height() ) );
00038         dropButton->SetBgColor( GetBgColor() );
00039         dropButton->SetFgColor( GetFgColor().FadeColor( 32 ) );
00040         dropButton->SetFlags( F_SELECTABLE );
00041         dropButton->SetState( S_RAISED );
00042         dropButton->SetFont( GetFont() );
00043         dropButton->SetWndText( "\\/" );
00044         dropButton->Init( tmp );
00045 
00046         r = *this;
00047         r.h = 20;
00048         r.w -= 20;
00049         SetWindowRect( r );
00050 }

const bool Ars::XDropDown::IsSelected const int  iItemIndex  )  [inline]
 

Parameters:
iItemIndex The index of the item to check
Returns:
true if the item is selected

Definition at line 63 of file xdropdown.h.

References Ars::XListBox::IsSelected(), and listBox.

00063 { return listBox->IsSelected(iItemIndex); }

void Ars::XDropDown::RemoveItem const int  iItemIndex  )  [inline]
 

Remove an item from the list

Parameters:
iItemIndex The index of the item to remove

Definition at line 44 of file xdropdown.h.

References listBox, and Ars::XListBox::RemoveItem().

00044 { listBox->RemoveItem( iItemIndex ); }

void Ars::XDropDown::SetAllSelections const bool  bSelected  )  [inline]
 

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 72 of file xdropdown.h.

References listBox, and Ars::XListBox::SetAllSelections().

00072 { listBox->SetAllSelections(bSelected); }

void Ars::XDropDown::SetItemHeight const unsigned int  iItemHeight  )  [inline]
 

iItemHeight The height of the items in the listbox

Definition at line 55 of file xdropdown.h.

References listBox, and Ars::XListBox::SetItemHeight().

00055 {       listBox->SetItemHeight( iItemHeight );  }

void Ars::XDropDown::SetSelection const int  iItemIndex,
const bool  bSelected
[inline]
 

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 68 of file xdropdown.h.

References listBox, and Ars::XListBox::SetSelection().

00068 { listBox->SetSelection(iItemIndex, bSelected); }

const bool Ars::XDropDown::SetupWindow const Message msg  )  [virtual]
 

Deregister the setup_window message.

Reimplemented from Ars::XEditBox.

Definition at line 52 of file xdropdown.cpp.

References dropButton, HideListBox(), listBox, Ars::Window::SetParent(), Ars::XButtonImage::SetupWindow(), and Ars::XListBox::SetupWindow().

00053 {
00054         XEditBox::SetupWindow( msg );
00055         
00056         listBox->SetParent( this );
00057         listBox->SetupWindow( msg );
00058 //      MessageServer::Instance().DeregisterMessageClient( listBox, Message::MOUSE_BUTTONDOWN );
00059 
00060         dropButton->SetParent( this );
00061         dropButton->SetupWindow( msg );
00062 
00063         HideListBox();
00064         MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_LCLICK);
00065         MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_VALUECHANGE);
00066 
00067         return true;
00068 }

void Ars::XDropDown::ShowListBox void   )  [protected]
 

Shows the drop down listbox.

Definition at line 110 of file xdropdown.cpp.

References Ars::Window::IsVisible(), listBox, Ars::Window::ShowWindow(), and Ars::Window::UpdateWindow().

Referenced by evMouseLClick().

00111 {
00112         if( !listBox->IsVisible() )
00113         {
00114                 listBox->ShowWindow();
00115                 listBox->UpdateWindow( true );
00116         }
00117 }

const int Ars::XDropDown::Size void   )  [inline]
 

The number of items in the list.

Reimplemented from Ars::XRect.

Definition at line 59 of file xdropdown.h.

References listBox, and Ars::XListBox::Size().

00059 { return listBox->Size(); }

const bool Ars::XDropDown::wmLostFocus const CtrlMessage msg  )  [protected, virtual]
 

Reimplemented from Ars::MessageClient.

Definition at line 128 of file xdropdown.cpp.

References HideListBox(), Ars::Window::IsChild(), Ars::Window::IsVisible(), listBox, and Ars::CtrlMessage::source.

00129 {
00130         bool ans = XEditBox::wmLostFocus( msg );
00131 
00132         if( !IsChild( (Window *)( msg.source ) ) )
00133         {
00134                 ans = listBox->IsVisible();
00135                 HideListBox();
00136         }
00137         return ans;
00138 
00139 }


Field Documentation

XButtonImage* Ars::XDropDown::dropButton [private]
 

A pointer to the drop down's drop button.

Definition at line 10 of file xdropdown.h.

Referenced by evMouseLClick(), Init(), and SetupWindow().

XListBox* Ars::XDropDown::listBox [private]
 

A pointer to teh drop down's list box.

Definition at line 9 of file xdropdown.h.

Referenced by AddItem(), ClearItems(), evMouseLClick(), evValueChange(), GetItem(), GetItemHeight(), HideListBox(), Init(), IsSelected(), RemoveItem(), SetAllSelections(), SetItemHeight(), SetSelection(), SetupWindow(), ShowListBox(), Size(), and wmLostFocus().


The documentation for this class was generated from the following files:
Generated on Fri Dec 5 04:06:56 2003 for Borqueror by doxygen 1.3.3