Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

multilistbox.cpp

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
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 

Generated on Tue Jun 24 01:27:46 2008 for Advanced Strategic Command by  doxygen 1.4.2