ALBA
albaGUI.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaGUI
5 Authors: Silvano Imboden - Paolo Quadrani
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16#ifndef __albaGUI_H__
17#define __albaGUI_H__
18//----------------------------------------------------------------------------
19// Include:
20//----------------------------------------------------------------------------
21
22#include "wx/grid.h"
23#include "wx/listctrl.h"
24#include "albaDecl.h"
25#include "albaGUIPanel.h"
26#include "albaEvent.h"
27#include "albaObserver.h"
28#include <map>
29
30
31//----------------------------------------------------------------------------
32// class forward :
33//----------------------------------------------------------------------------
38class albaGUIRollOut;
39
40
41#ifdef ALBA_USE_VTK //:::::::::::::::::::::::::::::::::
42class vtkLookupTable;
43#endif //:::::::::::::::::::::::::::::::::
44
45
46#ifdef ALBA_EXPORTS
47#include "albaDllMacros.h"
48EXPORT_STL_MAP(ALBA_EXPORT, int, int);
49#endif
50
51
57//extern "C" int ALBAWidgetId;
58
59//----------------------------------------------------------------------------
60// Constants :
61//----------------------------------------------------------------------------
62#pragma warning(push)
63#pragma warning (disable:4005)
64
65#define MININT -2147483647-1
66#define MAXINT 2147483647
67#define MINFLOAT -1.0e+38F
68#define MAXFLOAT 1.0e+38F
69#define MINDOUBLE -1.0e+299
70#define MAXDOUBLE 1.0e+299
71#pragma warning(pop)
72
73//----------------------------------------------------------------------------
74// Constants to be used with albaGUI::GetMetrics()
75//----------------------------------------------------------------------------
77{
88};
89//----------------------------------------------------------------------------
90// albaGUI :
108//----------------------------------------------------------------------------
109class ALBA_EXPORT albaGUI: public albaGUIPanel, public albaObserver
110{
111public:
113 virtual ~albaGUI();
114
116 void SetListener(albaObserver *listener) {m_Listener = listener;};
117
119 void Divider(long style = 0);
120
122 void Label(albaString label,bool bold = false, bool multiline = false);
123
125 void Label(albaString *var ,bool bold = false, bool multiline = false);
126
128 void Label(albaString label1,albaString label2, bool bold_label = false, bool bold_var = false, double customSizer = 1.0);
129
131 void Label(albaString label1,albaString *var, bool bold_label = false, bool bold_var = false, bool multiline = false, double customSizer = 1.0);
132
134 void HintBox(int id, wxString label, wxString title = "Hint", int mode = 0 /*0=Hint (default), 1=Info, 2=Warning*/, bool showIcon = true);
135
137 void String(int id, wxString label, wxString *var, wxString tooltip = "", bool multiline = false, bool password = false, bool interactive = false, double customSizer = 1.0);
138
140 void String(int id,albaString label,albaString *var, albaString tooltip = "", bool multiline = false, bool password = false, bool interactive = false, double customSizer = 1.0);
141
143 void Integer(int id,albaString label,int *var, int min = MININT, int max = MAXINT, albaString tooltip = "", bool labelAlwaysEnable = false, double customSizer = 1.0);
144
146 void Float(int id,albaString label,float *var, float min = MINFLOAT, float max = MAXFLOAT, int flag=0, int decimal_digit = -1, albaString tooltip = "", double customSizer = 1.0);
147
149 void Double(int id,albaString label,double *var, double min = MINDOUBLE, double max = MAXDOUBLE, int decimal_digit = -1, albaString tooltip = "", bool labelAlwaysEnable = false, double customSizer = 1.0,wxColour fontColor=wxColour(0,0,0));
150
152 void Vector(int id,wxString label, int var[3], int min = MININT, int max = MAXINT, wxString tooltip = "", wxColour *bg_colour = NULL);
153
155 void Vector(int id,wxString label, int var[3], int minx, int maxx, int miny, int maxy, int minz, int maxz, wxString tooltip = "", wxColour *bg_colour = NULL);
156
158 void Vector(int id,wxString label, float var[3], float min = MINFLOAT, float max = MAXFLOAT, int decimal_digit = -1, wxString tooltip = "", wxColour *bg_colour = NULL);
159
161 void Vector(int id,wxString label, float var[3], float minx, float maxx, float miny, float maxy, float minz, float maxz, int decimal_digit = -1, wxString tooltip = "", wxColour *bg_colour = NULL);
162
164 void Vector(int id,wxString label, double var[3], double min = MINFLOAT, double max = MAXFLOAT, int decimal_digit = -1, wxString tooltip = "", wxColour *bg_colour = NULL);
165
167 void Vector(int id,wxString label, double var[3], double minx, double maxx, double miny, double maxy, double minz, double maxz, int decimal_digit = -1, wxString tooltip = "", wxColour *bg_colour = NULL);
168
170 void VectorN(int id,wxString label, double *var, int num_elem = 3, double min = MINFLOAT, double max = MAXFLOAT, int decimal_digit = -1, wxString tooltip = "");
171
173 void VectorN(int id,wxString label, int *var,int num_elem = 3,int min = MININT, int max = MAXINT, wxString tooltip = "");
174
176 void Bool(int id, albaString label, int *var, int flag = 0, albaString tooltip = "" );
177
179 void BoolGrid(int numRows, int numColumns, std::vector<int> &ids, std::vector<const char*> &labelsRows,std::vector<const char*> &labelsColumns, int *var, albaString tooltip = "" );
180
182 void Radio(int id,wxString label, int *var, int numchoices = 0, const wxString choices[] = NULL, int dim = 1, wxString tooltip = "", int style = wxRA_SPECIFY_COLS);
183
185 void RadioButton(int id, wxString label, int selected=true, wxString tooltip = "");
186
188 wxComboBox *Combo(int id,albaString label, int *var, int numchoices = 0, const wxString choices[] = NULL, albaString tooltip = "", double customSizer = 1.0);
189
191 void FileOpen(int id,albaString label,albaString *var, const albaString wildcard = "", albaString tooltip = "");
192
194 void FileSave(int id,albaString label,albaString *var, const albaString wildcard = "", albaString tooltip = "", bool enableTextCtrl = true);
195
197 void DirOpen(int id,albaString label,albaString *var, albaString tooltip = "");
198
200 void Color(int id,wxString label,wxColour *var, wxString tooltip = "");
201
202 #ifdef ALBA_USE_VTK //:::::::::::::::::::::::::::::::::
204 albaGUILutSwatch *Lut(int id,wxString label,vtkLookupTable *lut);
205 #endif //:::::::::::::::::::::::::::::::::
206
208 void Button(int id,albaString button_text,albaString label="", albaString tooltip="");
209
211 void Button(int id,albaString *label,albaString button_text, albaString tooltip="");
212
214 albaGUICrossIncremental *CrossIncremental(int id,const char* label, double *stepVariable, double *topBottomVariable, double *leftRightVariable, int modality ,wxString tooltip ="", bool boldLabel = true, bool comboStep = false, int digits = -1, albaString *buttonUpDown_text = NULL, albaString *buttonLeftRight_text = NULL);
215
217 void TwoButtons(int firstID, int secondID, const char* label1, const char* label2, int alignment = wxALL, int width = -1);
218
220 void DoubleUpDown(int labelID, int firstID, int secondID, albaString label, double *var, double min = MINDOUBLE, double max = MAXDOUBLE, int decimal_digit = -1, albaString tooltip = "", bool labelAlwaysEnable = false);
221
222 /*Image Button widget*/
223 void ImageButton(int id, const char* label, wxBitmap bitmap, albaString tooltip);
224
226 void ButtonAndHelp(int firstID, int secondID, const char* label1, albaString tooltip = "", int alignment = wxALL, int width = -1);
227
229 void MultipleButtons(int numButtons, int numColumns, std::vector<int> &ids, std::vector<const char*> &labels, int alignment = wxALL );
230
232 void MultipleImageButtons(int numButtons, int numColumns, std::vector<int> &ids, std::vector<const char*> &labels, std::vector<const char*> &images, int alignment);
233
235 void OkCancel();
236
238 wxSlider *Slider(int id, wxString label, int *var,int min = MININT, int max = MAXINT, wxString tooltip = "",bool showText=true);
239
241 albaGUIFloatSlider *FloatSlider(int id, wxString label, double *var,double min, double max, wxSize size = wxDefaultSize, wxString tooltip = "", bool textBoxEnable = true);
242
244 albaGUIFloatSlider *FloatExpandedSlider(int id, wxString label, double *var, double min, double max, wxSize size = wxDefaultSize, wxString tooltip = "", bool textBoxEnable = true);
245
247 albaGUIFloatSlider *FloatSlider(int id, double *var, double min, double max, wxString minLab, wxString maxLab, wxSize size = wxDefaultSize, wxString tooltip = "", bool textBoxEnable = true);
248
250 albaGUICheckListBox *CheckList(int id, wxString label = "", int height = 60, wxString tooltip = "");
251
253 wxListBox *ListBox(int id, wxString label = "", int height = 60, wxString tooltip = "", long lbox_style = 0, int width = -1);
254
256 wxListCtrl *ListCtrl(int id, wxString label = "", int height = 60, wxString tooltip = "", long lbox_style = 0, int width = -1);
257
259 wxGrid *Grid(int id, wxString label = "", int height = 60, int row = 2,int cols = 2, wxString tooltip = "");
260
262 albaGUIRollOut *RollOut(int id, albaString title, albaGUI *roll_gui, bool rollOutOpen = true);
263
265 void Add(wxWindow* window,int option = 0, int flag = wxEXPAND, int border = 0) {window->Reparent(this); window->Show(true); m_Sizer->Add(window,option,flag,border);};
266
268 void Add(wxSizer* sizer, int option = 0, int flag = wxEXPAND, int border = 0) {m_Sizer->Add(sizer, option,flag,border);};
269
271 void AddGui(albaGUI* gui, int option = 0, int flag = wxEXPAND, int border = 0);
272
274 bool Remove(wxWindow* window) {window->Show(false); window->Reparent(albaGetFrame()); return m_Sizer->Detach(window);};
275
277 bool Remove(wxSizer* sizer ) {return m_Sizer->Detach(sizer);};
278
282 void FitGui();
283
285 void Update();
286
288 void Enable(int mod_id, bool enable);
289
291 wxFont GetBoldFont() {return m_BoldFont;};
292
293 wxFont GetGuiFont() {return m_Font;};
294
296 int GetMetrics( int id);
297
298 void OnEvent(albaEventBase *alba_event);
299
305 int GetWidgetId(int mod_id);
306
308
309 void GetWidgetValue(long widget_id, WidgetDataType &widget_data);
310
311 void SetWidgetValue(int id, WidgetDataType &widget_data);
312
314 void Reparent(wxWindow *parent);
315
316 static void AddMenuItem(wxMenu *menu,int id, wxString label, char **icon=NULL);
317
318protected:
320 wxBoxSizer *m_Sizer;
321
325
329 wxFont m_Font;
330
337 std::map<int,int> m_WidgetTableID;
338
344 int GetModuleId(int w_id) {assert(w_id > 0 && w_id <= (*GetALBAWidgetId())); return m_WidgetTableID[w_id - MINID];};
345
346 void OnSlider (wxCommandEvent &event) { }//@@@ this->OnEvent(albaEvent(this, GetModuleId(event.GetWidgetId()))); }
347 void OnListBox (wxCommandEvent &event);
348 void OnListCtrl (wxCommandEvent &event);
349 void OnCheckListBox (wxCommandEvent &event);
350 void OnRadioButton (wxCommandEvent &event);
351 void OnMouseWheel (wxMouseEvent &event);
352
353DECLARE_EVENT_TABLE()
354};
355#endif
MINID
Definition: albaDecl.h:420
ALBA_EXPORT wxWindow * albaGetFrame()
return the application frame window.
#define EXPORT_STL_MAP(declspec_, K_, V_)
Definition: albaDllMacros.h:90
#define MININT
Definition: albaGUI.h:65
#define MINFLOAT
Definition: albaGUI.h:67
#define MAXFLOAT
Definition: albaGUI.h:68
GUI_CONSTANTS
Definition: albaGUI.h:77
@ GUI_WIDGET_MARGIN
Definition: albaGUI.h:80
@ GUI_LABEL_WIDTH
Definition: albaGUI.h:83
@ GUI_ROW_MARGIN
Definition: albaGUI.h:78
@ GUI_LABEL_HEIGHT
Definition: albaGUI.h:81
@ GUI_DATA_WIDTH
Definition: albaGUI.h:86
@ GUI_LABEL_MARGIN
Definition: albaGUI.h:79
@ GUI_WIDGET_WIDTH
Definition: albaGUI.h:84
@ GUI_FULL_WIDTH
Definition: albaGUI.h:85
@ GUI_BUTTON_HEIGHT
Definition: albaGUI.h:82
@ GUI_HOLDER_WIDTH
Definition: albaGUI.h:87
#define MINDOUBLE
Definition: albaGUI.h:69
#define MAXDOUBLE
Definition: albaGUI.h:70
#define MAXINT
Definition: albaGUI.h:66
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
a CheckList that send albaEventNotification in the form albaEvent(this, widget_id,...
Class that represent a widget with 4 buttons and a text array disposed like a cross It can use two ac...
a Slider that can be used to set double values, albaGUIFloatSlider send usual wxWindows Events; Use a...
albaGUILutSwatch : widget representing a LUT, usually used to call the LutEditor.
class name: albaGUIPanel Inherits directly from wxPanel and adds the pointer to the next panel
Definition: albaGUIPanel.h:27
This class plugs and manage a roll-out gui.
albaGUI is a panel with function to easily create GUI.
Definition: albaGUI.h:110
void VectorN(int id, wxString label, int *var, int num_elem=3, int min=MININT, int max=MAXINT, wxString tooltip="")
Int vectorN entry widget.
void BoolGrid(int numRows, int numColumns, std::vector< int > &ids, std::vector< const char * > &labelsRows, std::vector< const char * > &labelsColumns, int *var, albaString tooltip="")
Checkbutton grid widget.
void Float(int id, albaString label, float *var, float min=MINFLOAT, float max=MAXFLOAT, int flag=0, int decimal_digit=-1, albaString tooltip="", double customSizer=1.0)
Float entry widget.
void FitGui()
Recalculate 'this' Gui Size and MinSize considering the space required by the children widgets.
void Double(int id, albaString label, double *var, double min=MINDOUBLE, double max=MAXDOUBLE, int decimal_digit=-1, albaString tooltip="", bool labelAlwaysEnable=false, double customSizer=1.0, wxColour fontColor=wxColour(0, 0, 0))
Double entry widget.
wxColour m_BackgroundColor
Definition: albaGUI.h:322
void Button(int id, albaString button_text, albaString label="", albaString tooltip="")
Button widget.
void Enable(int mod_id, bool enable)
Enable/Disable gui widget.
void Bool(int id, albaString label, int *var, int flag=0, albaString tooltip="")
Checkbutton widget.
void Label(albaString *var, bool bold=false, bool multiline=false)
Label widget.
wxComboBox * Combo(int id, albaString label, int *var, int numchoices=0, const wxString choices[]=NULL, albaString tooltip="", double customSizer=1.0)
Combo widget.
void RadioButton(int id, wxString label, int selected=true, wxString tooltip="")
Radiobutton widget.
void Vector(int id, wxString label, float var[3], float minx, float maxx, float miny, float maxy, float minz, float maxz, int decimal_digit=-1, wxString tooltip="", wxColour *bg_colour=NULL)
Float vector3 entry widget.
void Add(wxSizer *sizer, int option=0, int flag=wxEXPAND, int border=0)
Add sizer to gui sizer.
Definition: albaGUI.h:268
albaObserver * m_Listener
Definition: albaGUI.h:319
void OnMouseWheel(wxMouseEvent &event)
void Vector(int id, wxString label, int var[3], int min=MININT, int max=MAXINT, wxString tooltip="", wxColour *bg_colour=NULL)
Integer vector3 entry widget.
wxFont GetBoldFont()
Return the font used for bold label.
Definition: albaGUI.h:291
void Vector(int id, wxString label, double var[3], double minx, double maxx, double miny, double maxy, double minz, double maxz, int decimal_digit=-1, wxString tooltip="", wxColour *bg_colour=NULL)
Double vector3 entry widget.
int * GetALBAWidgetId()
void TwoButtons(int firstID, int secondID, const char *label1, const char *label2, int alignment=wxALL, int width=-1)
two generic Buttons widget.
void ButtonAndHelp(int firstID, int secondID, const char *label1, albaString tooltip="", int alignment=wxALL, int width=-1)
two generic Buttons widget.
int GetModuleId(int w_id)
Definition: albaGUI.h:344
void OnCheckListBox(wxCommandEvent &event)
albaGUIFloatSlider * FloatExpandedSlider(int id, wxString label, double *var, double min, double max, wxSize size=wxDefaultSize, wxString tooltip="", bool textBoxEnable=true)
Float Expanded slider widget.
void SetWidgetValue(int id, WidgetDataType &widget_data)
void ImageButton(int id, const char *label, wxBitmap bitmap, albaString tooltip)
void DirOpen(int id, albaString label, albaString *var, albaString tooltip="")
Dir Open dialog widget.
static void AddMenuItem(wxMenu *menu, int id, wxString label, char **icon=NULL)
void VectorN(int id, wxString label, double *var, int num_elem=3, double min=MINFLOAT, double max=MAXFLOAT, int decimal_digit=-1, wxString tooltip="")
Double vectorN entry widget.
void Vector(int id, wxString label, double var[3], double min=MINFLOAT, double max=MAXFLOAT, int decimal_digit=-1, wxString tooltip="", wxColour *bg_colour=NULL)
Double vector3 entry widget.
void OkCancel()
Ok-Cancel Button widget.
bool Remove(wxWindow *window)
Remove window from gui sizer.
Definition: albaGUI.h:274
albaGUIFloatSlider * FloatSlider(int id, wxString label, double *var, double min, double max, wxSize size=wxDefaultSize, wxString tooltip="", bool textBoxEnable=true)
Float slider widget.
void OnListBox(wxCommandEvent &event)
void FileSave(int id, albaString label, albaString *var, const albaString wildcard="", albaString tooltip="", bool enableTextCtrl=true)
File save dialog widget.
wxSlider * Slider(int id, wxString label, int *var, int min=MININT, int max=MAXINT, wxString tooltip="", bool showText=true)
Integer slider widget.
bool m_UseBackgroundColor
Definition: albaGUI.h:323
void Vector(int id, wxString label, int var[3], int minx, int maxx, int miny, int maxy, int minz, int maxz, wxString tooltip="", wxColour *bg_colour=NULL)
Integer vector3 entry widget.
wxListBox * ListBox(int id, wxString label="", int height=60, wxString tooltip="", long lbox_style=0, int width=-1)
Listbox widget.
void OnRadioButton(wxCommandEvent &event)
void DoubleUpDown(int labelID, int firstID, int secondID, albaString label, double *var, double min=MINDOUBLE, double max=MAXDOUBLE, int decimal_digit=-1, albaString tooltip="", bool labelAlwaysEnable=false)
Double entry widget and two generic Buttons widget.
std::map< int, int > m_WidgetTableID
Definition: albaGUI.h:337
wxBoxSizer * m_Sizer
Definition: albaGUI.h:320
void SetListener(albaObserver *listener)
Set the Listener that will receive event-notification, the Listener can be changed any time
Definition: albaGUI.h:116
void Update()
Update gui widget.
void Color(int id, wxString label, wxColour *var, wxString tooltip="")
Color dialog widget.
void OnListCtrl(wxCommandEvent &event)
void FileOpen(int id, albaString label, albaString *var, const albaString wildcard="", albaString tooltip="")
File open dialog widget.
void Integer(int id, albaString label, int *var, int min=MININT, int max=MAXINT, albaString tooltip="", bool labelAlwaysEnable=false, double customSizer=1.0)
Integer entry widget.
wxFont GetGuiFont()
Definition: albaGUI.h:293
void OnSlider(wxCommandEvent &event)
Definition: albaGUI.h:346
albaGUIFloatSlider * FloatSlider(int id, double *var, double min, double max, wxString minLab, wxString maxLab, wxSize size=wxDefaultSize, wxString tooltip="", bool textBoxEnable=true)
Float slider widget.
void MultipleImageButtons(int numButtons, int numColumns, std::vector< int > &ids, std::vector< const char * > &labels, std::vector< const char * > &images, int alignment)
Multiple Image Buttons widget.
void Label(albaString label1, albaString *var, bool bold_label=false, bool bold_var=false, bool multiline=false, double customSizer=1.0)
Double label widget.
void String(int id, wxString label, wxString *var, wxString tooltip="", bool multiline=false, bool password=false, bool interactive=false, double customSizer=1.0)
String entry widget.
void String(int id, albaString label, albaString *var, albaString tooltip="", bool multiline=false, bool password=false, bool interactive=false, double customSizer=1.0)
String entry widget.
void Label(albaString label, bool bold=false, bool multiline=false)
Label widget.
albaGUIRollOut * RollOut(int id, albaString title, albaGUI *roll_gui, bool rollOutOpen=true)
Create a roll out gui.
bool Remove(wxSizer *sizer)
Remove sizer from gui sizer.
Definition: albaGUI.h:277
long m_EntryStyle
Definition: albaGUI.h:324
wxFont m_Font
Definition: albaGUI.h:329
void Vector(int id, wxString label, float var[3], float min=MINFLOAT, float max=MAXFLOAT, int decimal_digit=-1, wxString tooltip="", wxColour *bg_colour=NULL)
Float vector3 entry widget.
void MultipleButtons(int numButtons, int numColumns, std::vector< int > &ids, std::vector< const char * > &labels, int alignment=wxALL)
Multiple Generic Buttons widget.
void Label(albaString label1, albaString label2, bool bold_label=false, bool bold_var=false, double customSizer=1.0)
Double label widget.
int GetMetrics(int id)
Return the measure used to layout the widgets - pass one of the GUI_xxx constants.
void HintBox(int id, wxString label, wxString title="Hint", int mode=0, bool showIcon=true)
Hint Box widget.
int GetWidgetId(int mod_id)
wxGrid * Grid(int id, wxString label="", int height=60, int row=2, int cols=2, wxString tooltip="")
Grid widget.
wxListCtrl * ListCtrl(int id, wxString label="", int height=60, wxString tooltip="", long lbox_style=0, int width=-1)
ListCtrl widget.
void AddGui(albaGUI *gui, int option=0, int flag=wxEXPAND, int border=0)
Add gui to gui sizer.
albaGUICrossIncremental * CrossIncremental(int id, const char *label, double *stepVariable, double *topBottomVariable, double *leftRightVariable, int modality, wxString tooltip="", bool boldLabel=true, bool comboStep=false, int digits=-1, albaString *buttonUpDown_text=NULL, albaString *buttonLeftRight_text=NULL)
Widget with 4 buttons and a text array disposed like a cross.
void Radio(int id, wxString label, int *var, int numchoices=0, const wxString choices[]=NULL, int dim=1, wxString tooltip="", int style=wxRA_SPECIFY_COLS)
RadioBox widget.
void Button(int id, albaString *label, albaString button_text, albaString tooltip="")
Button widget with variable label.
albaGUICheckListBox * CheckList(int id, wxString label="", int height=60, wxString tooltip="")
Checked listbox widget.
virtual ~albaGUI()
wxFont m_BoldFont
Definition: albaGUI.h:328
albaGUI(albaObserver *listener)
void GetWidgetValue(long widget_id, WidgetDataType &widget_data)
void Add(wxWindow *window, int option=0, int flag=wxEXPAND, int border=0)
Add window to gui sizer.
Definition: albaGUI.h:265
void OnEvent(albaEventBase *alba_event)
process the events sent by subjects
void Reparent(wxWindow *parent)
place the GUI on a different parent, and perform the required Resize/Stretch/ and Show
void Divider(long style=0)
Separator widget.
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36
albaString - performs common string operations on c-strings.
Definition: albaString.h:43