options_dlg.cc
Go to the documentation of this file.
1 #include "options_dlg.hh"
2 #include <FL/Fl.H>
3 
4 namespace Stg {
5 
6  OptionsDlg::OptionsDlg( int x, int y, int w, int h ) :
7  Fl_Window( x,y, w,h, "Visualize" ),
8  changedItem( NULL ),
9  showAll( NULL ),
10  status( NO_EVENT ),
11  hm( w/6 )
12  {
13  set_non_modal(); // keep on top but do not grab all events
14 
15  showAllCheck = new Fl_Check_Button( 0,0, w,boxH );
16  showAllCheck->callback( checkChanged, this );
17  showAllCheck->box( FL_UP_FRAME );
18 
19  scroll = new Fl_Scroll( 0,boxH+vm, w,h-boxH-3*vm );
20  resizable( scroll );
21  scroll->type( Fl_Scroll::VERTICAL );
22  scroll->end();
23 
24  this->end();
25  }
26 
28  delete scroll; // deletes members
29  delete showAllCheck;
30  }
31 
32 
33  void OptionsDlg::checkChanged( Fl_Widget* w, void* p ) {
34  Fl_Check_Button* check = static_cast<Fl_Check_Button*>( w );
35  OptionsDlg* oDlg = static_cast<OptionsDlg*>( p );
36 
37  if ( check == oDlg->showAllCheck && oDlg->showAll )
38  {
39  oDlg->status = CHANGE_ALL;
40  oDlg->showAll->set( check->value() );
41  oDlg->do_callback();
42  oDlg->status = NO_EVENT;
43  }
44  else
45  {
46  int item = oDlg->scroll->find( check );
47  oDlg->options[ item ]->set( check->value() );
48  oDlg->changedItem = oDlg->options[ item ];
49  oDlg->status = CHANGE;
50  oDlg->do_callback();
51  oDlg->changedItem = NULL;
52  oDlg->status = NO_EVENT;
53  }
54  }
55 
57  if (scroll->children())
58  scroll->clear();
59  scroll->begin();
60  Fl_Check_Button* check;
61  for ( unsigned int i=0; i<options.size(); i++ ) {
62  check = new Fl_Check_Button( 0,boxH*(i+1)+vm, scroll->w(), boxH, options[ i ]->name().c_str() );
63  if ( options[ i ]->val() )
64  check->set();
65  check->callback( checkChanged, this );
66  }
67  scroll->end();
68  this->redraw();
69  }
70 
71  void OptionsDlg::setOptions( const std::set<Option*>& opts ) {
72  options.clear();
73  options.assign( opts.begin(), opts.end() );
74  updateChecks();
75  }
76 
77 
79  showAll = opt;
80  showAllCheck->label( opt->name().c_str() );
81  showAllCheck->value( opt->val() );
82  }
83 
84 } // namespace Stg
void redraw(int val)
void setOptions(const std::set< Option * > &opts)
Definition: options_dlg.cc:71
bool val() const
Definition: option.hh:43
void updateChecks()
Definition: options_dlg.cc:56
The Stage library uses its own namespace.
Definition: canvas.hh:8
Option * showAll
Definition: options_dlg.hh:27
void showAllOpt(Option *opt)
Definition: options_dlg.cc:78
std::vector< Option * > options
Definition: options_dlg.hh:25
virtual ~OptionsDlg()
Definition: options_dlg.cc:27
static void checkChanged(Fl_Widget *w, void *p)
Definition: options_dlg.cc:33
Option * changedItem
Definition: options_dlg.hh:26
void set(bool val)
Definition: option.cc:68
static const int boxH
Definition: options_dlg.hh:38
const std::string name() const
Definition: option.hh:41
Fl_Scroll * scroll
Definition: options_dlg.hh:29
Fl_Check_Button * showAllCheck
Definition: options_dlg.hh:30
static const int vm
Definition: options_dlg.hh:36
OptionsDlg(int x, int y, int w, int h)
Definition: options_dlg.cc:6


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Mon Jun 10 2019 15:06:09