ALBA
albaGUIValidator.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaGUIValidator
5 Authors: Silvano Imboden
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 __albaGUIValidator_H__
17#define __albaGUIValidator_H__
18//----------------------------------------------------------------------------
19// Include:
20//----------------------------------------------------------------------------
21#include <wx/validate.h>
22#include "wx/listctrl.h"
23#include "albaDecl.h"
24#include "albaString.h"
25
26//-----------------------------------------------------------------------------
27//forward ref
28//-----------------------------------------------------------------------------
30class albaObserver;
31
32//-----------------------------------------------------------------------------
33// constant :
34//-----------------------------------------------------------------------------
36{
39 VAL_STRING, //TEXT
47 VAL_INTEGER, //TEXT
48 VAL_FLOAT, //TEXT
49 VAL_DOUBLE, //TEXT
64};
65//-----------------------------------------------------------------------------
66// albaGUIValidator :
67//-----------------------------------------------------------------------------
68class ALBA_EXPORT albaGUIValidator : public wxValidator
69{
70public:
71 albaGUIValidator (albaObserver* listener,int mid,wxStaticText *win, wxString* var); //String
72 albaGUIValidator (albaObserver* listener,int mid,wxStaticText *win, albaString* var); //String
73 albaGUIValidator (albaObserver* listener,int mid,wxTextCtrl *win, albaString* var, bool interactive = false, bool multiline=false); //String
74 albaGUIValidator (albaObserver* listener,int mid,wxTextCtrl *win,wxString* var, bool interactive = false, bool multiline=false); //String
75 albaGUIValidator (albaObserver* listener,int mid,wxTextCtrl *win, int* var, int min=-2147483647-1, int max=2147483647); //Integer
76 albaGUIValidator (albaObserver* listener,int mid,wxTextCtrl *win, float* var, float min=-1.0e+38F, float max=1.0e+38F, int dec_digits = 2);//Float
77 albaGUIValidator (albaObserver* listener,int mid,wxTextCtrl *win, double* var, double min=-1.0e+299, double max=1.0e+299, int dec_digits = 2);//Double
78 albaGUIValidator (albaObserver* listener,int mid,wxSlider *win, int* var, wxTextCtrl* lab);
79 albaGUIValidator (albaObserver* listener,int mid,wxTextCtrl *win, int* var, wxSlider* lab, int min=-2147483647-1, int max=2147483647);
80 albaGUIValidator (albaObserver* listener,int mid,albaGUIFloatSlider *win, double* var, wxTextCtrl* lab);
81 albaGUIValidator (albaObserver* listener,int mid,wxTextCtrl *win, double* var, albaGUIFloatSlider* lab, double min=-1.0e+299, double max=1.0e+299);
82 albaGUIValidator (albaObserver* listener,int mid,wxCheckBox *win, int* var);
83 albaGUIValidator (albaObserver* listener,int mid,wxRadioBox *win, int* var);
84 albaGUIValidator (albaObserver* listener,int mid,wxComboBox *win, int* var);
85 albaGUIValidator (albaObserver* listener,int mid,wxListBox *win);
86 albaGUIValidator (albaObserver* listener,int mid,wxListCtrl *win);
87 albaGUIValidator (albaObserver* listener,int mid,wxButton *win);
88 albaGUIValidator (albaObserver* listener,int mid,wxButton *win,albaString* var, wxTextCtrl* lab, bool openfile, const albaString wildcard); // FileOpen/Save
89 albaGUIValidator (albaObserver* listener,int mid,wxButton *win,albaString* var, wxTextCtrl* lab); // DirOpen
90 albaGUIValidator (albaObserver* listener,int mid,wxButton *win,wxColour* var, wxTextCtrl* lab);
91
92 albaGUIValidator(const albaGUIValidator& val) {Copy(val);};
94 virtual wxObject *Clone(void) const {return new albaGUIValidator(*this);};
95 bool Copy(const albaGUIValidator& val);
96
97 virtual bool IsValid();
98 virtual bool Validate(wxWindow *parent);
99 virtual bool TransferToWindow(void);
100 virtual bool TransferFromWindow(void);
101
102// float RoundValue(float f_in);
103// double RoundValue(double d_in);
104
105 void Init(albaObserver* listener, int mid, wxControl *win);
106 void OnChar(wxKeyEvent& event);
107 void OnKeyUp(wxKeyEvent& event);
108 void OnKillFocus(wxFocusEvent& event);
109 void OnScrollEvent(wxScrollEvent& event);
110 void OnCommandEvent(wxCommandEvent& event);
111 void OnButton(wxCommandEvent& event);
112
114 void GetWidgetData(WidgetDataType &widget_data);
115
117 void SetWidgetData(WidgetDataType &widget_data);
118
119DECLARE_EVENT_TABLE()
120
121protected:
122 enum VALIDATOR_MODES m_Mode;
123 // associated control (one of these)
124 wxStaticText *m_StaticText;
125 wxTextCtrl *m_TextCtrl;
126 wxSlider *m_Slider;
127 albaGUIFloatSlider *m_FloatSlider;
128 wxCheckBox *m_CheckBox;
129 wxRadioBox *m_RadioBox;
130 wxComboBox *m_ComboBox;
131 wxButton *m_Button;
132 wxListBox *m_ListBox;
133 wxListCtrl *m_ListCtrl;
134 // associated variable (one of these)
135 float *m_FloatVar;
136 double *m_DoubleVar;
137 int *m_IntVar;
138 wxString *m_StringVar;
139 albaString *m_MafStringVar;
140 wxColour *m_ColorVar;
141 // associated valid range (int or float)
142 float m_FloatMax;
143 float m_FloatMin;
144 double m_DoubleMin;
145 double m_DoubleMax;
146 int m_IntMax;
147 int m_IntMin;
148
149 WidgetDataType m_WidgetData;
150
151 albaObserver *m_Listener;
152 int m_ModuleId;
153 int m_DecimalDigits;
154 albaString m_Wildcard;
155};
156#endif
VALIDATOR_MODES
@ VAL_WRONG
@ VAL_FLOAT_SLIDER_2
@ VAL_ALBA_MULTILINE_STRING
@ VAL_RADIOBOX
@ VAL_MULTILINE_INTERACTIVE_STRING
@ VAL_ALBA_STRING
@ VAL_MULTILINE_STRING
@ VAL_INTERACTIVE_STRING
@ VAL_LISTCTRL
@ VAL_DOUBLE
@ VAL_SLIDER
@ VAL_ALBA_MULTILINE_INTERACTIVE_STRING
@ VAL_BUTTON
@ VAL_SLIDER_2
@ VAL_COLOR
@ VAL_ALBA_INTERACTIVE_STRING
@ VAL_DIROPEN
@ VAL_COMBOBOX
@ VAL_CHECKBOX
@ VAL_LISTBOX
@ VAL_FLOAT_SLIDER
@ VAL_INTEGER
@ VAL_FILEOPEN
@ VAL_LABEL
@ VAL_STRING
@ VAL_FILESAVE
@ VAL_FLOAT
a Slider that can be used to set double values, albaGUIFloatSlider send usual wxWindows Events; Use a...
bool Copy(const albaGUIValidator &val)
albaGUIValidator(albaObserver *listener, int mid, wxSlider *win, int *var, wxTextCtrl *lab)
void GetWidgetData(WidgetDataType &widget_data)
Fill widget_data with the active widget value.
albaGUIValidator(albaObserver *listener, int mid, wxButton *win, albaString *var, wxTextCtrl *lab)
void OnKillFocus(wxFocusEvent &event)
albaGUIValidator(albaObserver *listener, int mid, wxButton *win, wxColour *var, wxTextCtrl *lab)
albaGUIValidator(albaObserver *listener, int mid, wxComboBox *win, int *var)
void OnButton(wxCommandEvent &event)
albaGUIValidator(albaObserver *listener, int mid, albaGUIFloatSlider *win, double *var, wxTextCtrl *lab)
virtual bool IsValid()
albaGUIValidator(albaObserver *listener, int mid, wxTextCtrl *win, float *var, float min=-1.0e+38F, float max=1.0e+38F, int dec_digits=2)
albaGUIValidator(const albaGUIValidator &val)
albaGUIValidator(albaObserver *listener, int mid, wxStaticText *win, albaString *var)
virtual wxObject * Clone(void) const
virtual bool TransferToWindow(void)
albaGUIValidator(albaObserver *listener, int mid, wxTextCtrl *win, int *var, int min=-2147483647-1, int max=2147483647)
void OnKeyUp(wxKeyEvent &event)
void OnScrollEvent(wxScrollEvent &event)
albaGUIValidator(albaObserver *listener, int mid, wxTextCtrl *win, wxString *var, bool interactive=false, bool multiline=false)
void Init(albaObserver *listener, int mid, wxControl *win)
albaGUIValidator(albaObserver *listener, int mid, wxTextCtrl *win, int *var, wxSlider *lab, int min=-2147483647-1, int max=2147483647)
virtual bool TransferFromWindow(void)
albaGUIValidator(albaObserver *listener, int mid, wxListCtrl *win)
void SetWidgetData(WidgetDataType &widget_data)
Fill m_WidgetData member variable with widget_data information and validate it.
albaGUIValidator(albaObserver *listener, int mid, wxTextCtrl *win, double *var, albaGUIFloatSlider *lab, double min=-1.0e+299, double max=1.0e+299)
albaGUIValidator(albaObserver *listener, int mid, wxButton *win)
void OnChar(wxKeyEvent &event)
albaGUIValidator(albaObserver *listener, int mid, wxTextCtrl *win, double *var, double min=-1.0e+299, double max=1.0e+299, int dec_digits=2)
void OnCommandEvent(wxCommandEvent &event)
virtual bool Validate(wxWindow *parent)
albaGUIValidator(albaObserver *listener, int mid, wxButton *win, albaString *var, wxTextCtrl *lab, bool openfile, const albaString wildcard)
albaGUIValidator(albaObserver *listener, int mid, wxCheckBox *win, int *var)
albaGUIValidator(albaObserver *listener, int mid, wxListBox *win)
albaGUIValidator(albaObserver *listener, int mid, wxTextCtrl *win, albaString *var, bool interactive=false, bool multiline=false)
albaGUIValidator(albaObserver *listener, int mid, wxStaticText *win, wxString *var)
albaGUIValidator(albaObserver *listener, int mid, wxRadioBox *win, int *var)
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