FOX/ObjCryst++  1.10.X (development)
wxRefinableObj.h
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2000-2002 Vincent Favre-Nicolin vincefn@users.sourceforge.net
3  2000-2001 University of Geneva (Switzerland)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /*
20 * header file for the RefinablePar and RefinableObj classes
21 *
22 * This is still in early development stages !! Not secure !
23 *
24 */
25 
26 #ifndef _VFN_WX_REFINABLE_OBJ_H_
27 #define _VFN_WX_REFINABLE_OBJ_H_
28 
29 namespace ObjCryst
30 {
31 template<class T> class WXRegistry;
32 class WXFieldOption;
33 class WXFieldRefPar;
34 } //namespace
35 
36 #include "ObjCryst/wxCryst/wxCryst.h"
37 
38 // We should not have to put this here. !! :TODO:
39 #include "ObjCryst/RefinableObj/RefinableObj.h"
40 
41 namespace ObjCryst
42 {
43 class RefinablePar;
44 class RefinableObj;
47 template<class T> T* WXDialogChooseFromRegistry(ObjRegistry<T> &reg,wxWindow*parent,
48  const string &message,int &);
51 template<class T> const T* WXDialogChooseFromRegistry(const ObjRegistry<T> &reg,
52  wxWindow*parent, const string &message,
53  int &);
54 
58 class WXFieldRefPar:public WXField
59 {
60  public:
61  WXFieldRefPar(wxWindow *parent,const string& label,
62  RefinablePar *refpar,const int hsize=65,
63  const bool enableFixButton=true, const bool enableLimitedButton=true);
69  void OnEnter(wxCommandEvent & WXUNUSED(event));
71  void OnText(wxCommandEvent & WXUNUSED(event));
73  void OnToggleFix(wxCommandEvent & WXUNUSED(event));
75  void OnToggleLimited(wxCommandEvent & WXUNUSED(event));
77  void OnPopupMenu(wxMouseEvent & event);
79  void OnPopupMenuChoice(wxCommandEvent& event);
80  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
81  virtual void UpdateUI(const bool mutexlock=false);
84  void Revert();
85  virtual void ValidateUserInput();
87  virtual void SetToolTip(const wxString& tip);
89  void SetFormat(const wxString &format);
90  protected:
91  REAL mValue;
92  wxCheckBox *mpButtonFix;
93  wxCheckBox *mpButtonLimited;
94  wxTextCtrl *mpField;
95  RefinablePar *mpRefPar;
96  REAL mValueOld;
97  bool mIsSelfUpdating;
99  wxString mFormat;
100  DECLARE_EVENT_TABLE()
101 };
102 
103 class RefObjOpt;// Declared in RefinableObj.h
105 class WXFieldOption:public WXField
106 {
107  public:
108  WXFieldOption(wxWindow *parent,const int field_id,
109  RefObjOpt* option);
110  virtual ~WXFieldOption();
111  void OnUpdateUI(wxUpdateUIEvent & WXUNUSED(event));
115  void OnChoice(wxCommandEvent & WXUNUSED(event));
116  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
117  virtual void UpdateUI(const bool mutexlock=false);
118  void Revert();
120  virtual void ValidateUserInput();
122  virtual void SetToolTip(const wxString& tip);
123  protected:
124  int mChoice;
125  int mChoiceOld;
126  RefObjOpt* mpOption;
127  wxChoice *mpList;
128  DECLARE_EVENT_TABLE()
129 };
130 
132 template<class T> class WXRegistry:public WXCrystObj
133 {
134  public:
135  WXRegistry(wxWindow *parent,ObjRegistry<T>* reg);
136  ~WXRegistry();
137  void Add(WXCrystObjBasic *obj);
138  void Remove(WXCrystObjBasic *obj);
139  virtual bool OnChangeName(const int id);
140  private:
141  ObjRegistry<T> *mpRegistry;
142 };
143 
147 {
148  public:
149  WXRefinableObj(wxWindow *parent, RefinableObj*);
150  ~WXRefinableObj();
151  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
152  virtual void UpdateUI(const bool mutexlock=false);
153  virtual bool OnChangeName(const int id);
154  void OnMenuSave(wxCommandEvent & WXUNUSED(event));
155  void OnMenuLoad(wxCommandEvent & WXUNUSED(event));
156  void OnMenuFixAllPar(wxCommandEvent & WXUNUSED(event));
157  void OnMenuUnFixAllPar(wxCommandEvent & WXUNUSED(event));
158  void OnMenuParRandomize(wxCommandEvent & WXUNUSED(event));
159  virtual void OnUpdateUI(wxUpdateUIEvent& event);
160  protected:
161  WXCrystMenuBar* mpMenuBar;
162  private:
163  RefinableObj* mpRefinableObj;
164  DECLARE_EVENT_TABLE()
165 };
166 } //namespace
167 
168 #endif //_VFN_WX_REFINABLE_OBJ_H_
T * WXDialogChooseFromRegistry(ObjRegistry< T > &reg, wxWindow *parent, const string &message, int &choice)
This function allows to pick up one object in a registry.
void Revert()
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
void OnToggleLimited(wxCommandEvent &WXUNUSED(event))
Toggle the 'limited' status of the parameter.
WX representation of a RefObj option. This displays the names of the different choices.
A field for a RefinablePar.
void OnPopupMenuChoice(wxCommandEvent &event)
Opens the popu menu, to allow changing limits.
void OnToggleFix(wxCommandEvent &WXUNUSED(event))
Toggle the 'fixed' status of the parameter.
RefinablePar & GetRefPar()
Get the RefinablePar associated to this field.
This displays all components of a ObjCryst++ Registry.
This is the abstract base class for all fields, wether they contain a floating-point parameter...
Definition: wxCryst.h:291
wxString mFormat
Format to be used, default = _T("%8f")
Generic Refinable Object.
Definition: RefinableObj.h:752
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:127
void OnPopupMenu(wxMouseEvent &event)
Opens the popu menu, to allow changing limits.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
Get new values to be displayed from the underlying object, and raise flag if an UI update is necessar...
Base class for options.
Definition: RefinableObj.h:550
void OnText(wxCommandEvent &WXUNUSED(event))
Records when text is entered (either from self-updating or user input)
void Revert()
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
~WXFieldRefPar()
When a new value is entered (must type it and then hit the 'enter' key).
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
Get new values to be displayed from the underlying object, and raise flag if an UI update is necessar...
Base class for all displayed ObjCryst objects (with a title, and a sizer to stack objects)...
Definition: wxCryst.h:248
virtual void ValidateUserInput()
This function shall be called when a new value has been entered.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
void SetFormat(const wxString &format)
Set Format.
The base wxCryst class for all RefinableObj objects.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the choice field.
Generic class for parameters of refinable objects.
Definition: RefinableObj.h:223
void OnChoice(wxCommandEvent &WXUNUSED(event))
When a new value is entered.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
virtual void ValidateUserInput()
Does nothing. Any user input is directly validated (OnChoice).
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the entry field.
Object Registry.
Definition: RefinableObj.h:643
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
Get new values to be displayed from the underlying object, and raise flag if an UI update is necessar...
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
Our own local menu bar, using buttons and Popup menus.
Definition: wxCryst.h:503