#include <xdropdown.h>
Inheritance diagram for Ars::XDropDown:


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) |
| XListItem & | GetItem (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 | |
| XListBox * | listBox |
| A pointer to teh drop down's list box. | |
| XButtonImage * | dropButton |
| A pointer to the drop down's drop button. | |
|
|
Construct a new DropDown control
Definition at line 5 of file xdropdown.cpp.
00006 : listBox( 0 ) , dropButton( 0 ) 00007 { 00008 } |
|
|
Standard destructor.
Definition at line 18 of file xdropdown.h.
00018 { }
|
|
|
Definition at line 35 of file xdropdown.h. References Ars::XListBox::AddItem(), and listBox.
00035 { return listBox->AddItem( aText ); }
|
|
|
Adds a new item to the list
Definition at line 34 of file xdropdown.h. References Ars::XListBox::AddItem(), and listBox.
00034 { return listBox->AddItem( ListItem ); }
|
|
|
Remove all items from the list.
Definition at line 47 of file xdropdown.h. References Ars::XListBox::ClearItems(), and listBox.
00047 { listBox->ClearItems(); }
|
|
|
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 }
|
|
|
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 }
|
|
|
Returns the desired item
Definition at line 40 of file xdropdown.h. References Ars::XListBox::GetItem(), and listBox.
00040 { return listBox->GetItem( iItemIndex ); }
|
|
|
Definition at line 52 of file xdropdown.h. References Ars::XListBox::GetItemHeight(), and listBox.
00052 { return listBox->GetItemHeight(); }
|
|
|
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().
|
|
|
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 }
|
|
|
Definition at line 63 of file xdropdown.h. References Ars::XListBox::IsSelected(), and listBox.
00063 { return listBox->IsSelected(iItemIndex); }
|
|
|
Remove an item from the list
Definition at line 44 of file xdropdown.h. References listBox, and Ars::XListBox::RemoveItem().
00044 { listBox->RemoveItem( iItemIndex ); }
|
|
|
Set the selection for all of the items at once
Definition at line 72 of file xdropdown.h. References listBox, and Ars::XListBox::SetAllSelections().
00072 { listBox->SetAllSelections(bSelected); }
|
|
|
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 ); }
|
|
||||||||||||
|
Set an item as selected
Definition at line 68 of file xdropdown.h. References listBox, and Ars::XListBox::SetSelection().
00068 { listBox->SetSelection(iItemIndex, bSelected); }
|
|
|
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 }
|
|
|
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().
|
|
|
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(); }
|
|
|
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 }
|
|
|
A pointer to the drop down's drop button.
Definition at line 10 of file xdropdown.h. Referenced by evMouseLClick(), Init(), and SetupWindow(). |
|
|
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(). |
1.3.3