00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "multilistbox.h"
00012
00013
00014 MultiListBox :: MultiListBox (PG_Widget *parent, const PG_Rect &r ) : PG_Widget( parent, r )
00015 {
00016 SetTransparency( 255 );
00017
00018 listbox = new PG_ListBox( parent, PG_Rect( r.x, r.y, r.w, r.h - 30 ) );
00019 listbox->SetMultiSelect( true );
00020
00021 (new PG_Button( parent, PG_Rect( r.x, r.y + r.h - 25, r.w/2-5, 25 ), "All"))->sigClick.connect( SigC::slot( *this, &MultiListBox::all ));
00022 (new PG_Button( parent, PG_Rect( r.x + r.w/2 + 5, r.y + r.h - 25, r.w/2-5, 25 ), "None"))->sigClick.connect( SigC::slot( *this, &MultiListBox::none ));
00023 }
00024
00025 bool MultiListBox::all()
00026 {
00027 for ( int i = 0; i < listbox->GetWidgetCount(); ++i ) {
00028 PG_ListBoxBaseItem* bi = dynamic_cast<PG_ListBoxBaseItem*>(listbox->FindWidget(i));
00029 if ( bi )
00030 bi->Select( true );
00031 }
00032 listbox->Update();
00033 return true;
00034 }
00035
00036 bool MultiListBox::none()
00037 {
00038 for ( int i = 0; i < listbox->GetWidgetCount(); ++i ) {
00039 PG_ListBoxBaseItem* bi = dynamic_cast<PG_ListBoxBaseItem*>(listbox->FindWidget(i));
00040 if ( bi )
00041 bi->Select( false );
00042 }
00043 listbox->Update();
00044 return true;
00045 }
00046