Evita  0.16
evGUIMultiBrowser.h
Go to the documentation of this file.
1 /*
2  *
3  * EVITA: Efficient Visualization of Terascale Datasets
4  * Copyright (C) 2000-2016 Team Evita
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
19  * MA 02139, USA.
20  *
21  */
22 
23 
24 #ifndef __evGUIMultiBrowser_h
25 #define __evGUIMultiBrowser_h
26 
27 
28 #include <FL/Fl_Multi_Browser.H>
29 #include <FL/Fl_Button.H>
30 
31 #include "evGUIObject.h"
32 
33 
34 #define EVGUIMULTIBROWSER_BUTTON_WIDTH 80
35 #define EVGUIMULTIBROWSER_BUTTON_HEIGHT 20
36 
37 
38 class evGUIMultiBrowser : public evGUIObject, public Fl_Group
39 {
40 public:
41  evGUIMultiBrowser(const int x, const int y,
42  const int width, const int height,
43  const char *label);
44  virtual ~evGUIMultiBrowser(void);
45 
46  virtual const evString GetClassName(void) const
47  {
48  return(evString("evGUIMultiBrowser"));
49  }
50 
51  virtual void Clear(void);
52  void AddLine(const char *line);
53  unsigned int GetNumSelected(void) const;
54  unsigned int *GetSelected(void) const;
55 
56 protected:
57  Fl_Multi_Browser *Browser;
58 
59 private:
60  Fl_Button *SelectAllButton;
61  Fl_Button *ClearAllButton;
62 
63  static void SelectAll(Fl_Widget *widget, void *data);
64  static void ClearAll(Fl_Widget *widget, void *data);
65 
66 };
67 
68 
69 inline void evGUIMultiBrowser::Clear(void)
70 {
71  this->Browser->clear();
72 }
73 
74 
75 inline void evGUIMultiBrowser::AddLine(const char *line)
76 {
77  this->Browser->add(line);
78 }
79 
80 
81 inline unsigned int evGUIMultiBrowser::GetNumSelected(void) const
82 {
83  unsigned int cnt = 0;
84 
85  for (unsigned int line = 1;
86  line <= (unsigned int)this->Browser->size();
87  line++)
88  if (this->Browser->selected(line))
89  cnt++;
90 
91  return(cnt);
92 }
93 
94 
95 inline unsigned int *evGUIMultiBrowser::GetSelected(void) const
96 {
97  unsigned int *selected = new unsigned int[this->GetNumSelected()];
98 
99  unsigned int index = 0;
100  for (unsigned int line = 1;
101  line <= (unsigned int)this->Browser->size();
102  line++)
103  if (this->Browser->selected(line))
104  selected[index++] = line - 1;
105 
106  return(selected);
107 }
108 
109 
110 #endif
111 
void AddLine(const char *line)
Definition: evGUIMultiBrowser.h:75
Fl_Multi_Browser * Browser
Definition: evGUIMultiBrowser.h:57
virtual void Clear(void)
Definition: evGUIMultiBrowser.h:69
Fl_Button * ClearAllButton
Definition: evGUIMultiBrowser.h:61
unsigned int * GetSelected(void) const
Definition: evGUIMultiBrowser.h:95
virtual const evString GetClassName(void) const
Definition: evGUIMultiBrowser.h:46
unsigned int GetNumSelected(void) const
Definition: evGUIMultiBrowser.h:81
static void SelectAll(Fl_Widget *widget, void *data)
Definition: evGUIObject.h:33
static void ClearAll(Fl_Widget *widget, void *data)
virtual ~evGUIMultiBrowser(void)
Fl_Button * SelectAllButton
Definition: evGUIMultiBrowser.h:60
Definition: evGUIMultiBrowser.h:38
evGUIMultiBrowser(const int x, const int y, const int width, const int height, const char *label)
Definition: evString.h:30