Advanced Strategic Command
multilistbox.cpp
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  ***************************************************************************/
10 
11 #include "multilistbox.h"
12 
13 
14 MultiListBox :: MultiListBox (PG_Widget *parent, const PG_Rect &r ) : PG_Widget( parent, r )
15 {
16  SetTransparency( 255 );
17 
18  listbox = new PG_ListBox( parent, PG_Rect( r.x, r.y, r.w, r.h - 30 ) );
19  listbox->SetMultiSelect( true );
20 
21  (new PG_Button( parent, PG_Rect( r.x, r.y + r.h - 25, r.w/2-5, 25 ), "All"))->sigClick.connect( sigc::hide( sigc::mem_fun( *this, &MultiListBox::all )));
22  (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::hide( sigc::mem_fun( *this, &MultiListBox::none )));
23 }
24 
26 {
27  for ( int i = 0; i < listbox->GetWidgetCount(); ++i ) {
28  PG_ListBoxBaseItem* bi = dynamic_cast<PG_ListBoxBaseItem*>(listbox->FindWidget(i));
29  if ( bi )
30  bi->Select( true );
31  }
32  listbox->Update();
33  return true;
34 }
35 
37 {
38  for ( int i = 0; i < listbox->GetWidgetCount(); ++i ) {
39  PG_ListBoxBaseItem* bi = dynamic_cast<PG_ListBoxBaseItem*>(listbox->FindWidget(i));
40  if ( bi )
41  bi->Select( false );
42  }
43  listbox->Update();
44  return true;
45 }
46 
MultiListBox(PG_Widget *parent, const PG_Rect &r)