25 #ifndef _VFN_WX_CRYST_H_
26 #define _VFN_WX_CRYST_H_
34 #include "wx/wxprec.h"
42 #include "ObjCryst/CrystVector/CrystVector.h"
60 int n,
const wxString* choices);
61 wxArrayInt GetSelections()
const;
83 extern const long ID_WXOBJ_ENABLE;
84 extern const long ID_WXOBJ_DISABLE;
86 #undef VFN_CRYST_MUTEX
87 #ifdef VFN_CRYST_MUTEX
91 class CrystMutex:
public wxMutex
97 wxMutexError Unlock();
99 unsigned long mNbLock;
102 #define CrystMutex wxMutex
104 #ifndef DOXYGEN_SKIP_THIS
110 ID_REFOBJ_MENU_OBJ=wxID_HIGHEST+1,
111 ID_REFOBJ_MENU_OBJ_SAVE,
112 ID_REFOBJ_MENU_OBJ_LOAD,
114 ID_REFOBJ_MENU_PAR_FIXALL,
115 ID_REFOBJ_MENU_PAR_UNFIXALL,
116 ID_REFOBJ_MENU_PAR_RANDOMIZE,
124 class WXCrystObjBasicList;
148 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false)=0;
160 virtual void UpdateUI(
const bool mutexlock=
false)=0;
175 virtual bool Layout();
204 unsigned int GetNb()
const;
219 void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false);
227 void UpdateUI(
const bool mutexlock=
false);
228 void Enable(
bool enable);
252 WXCrystObj(wxWindow* parent,
int orient=wxHORIZONTAL,
bool showName=
true);
262 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false);
263 virtual void UpdateUI(
const bool mutexlock=
false);
264 virtual void OnEnable(wxUpdateUIEvent &event);
265 virtual bool Enable(
bool enable);
280 DECLARE_EVENT_TABLE()
297 WXField(wxWindow *parent,
const string& label,
const int field_id);
309 virtual void SetSize(
int width,
int height);
331 WXFieldString(wxWindow *parent,
string& st,
const int field_id,
332 const int hsize=50,
bool isEditable=
true);
337 void OnEnter(wxCommandEvent & event);
339 void OnText(wxCommandEvent & WXUNUSED(event));
345 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false);
346 virtual void UpdateUI(
const bool mutexlock=
false);
349 virtual void SetSize(
int width,
int height);
365 DECLARE_EVENT_TABLE()
375 const int hsize=50,
bool isEditable=
true);
380 void OnEnter(wxCommandEvent & event);
382 void OnText(wxCommandEvent & WXUNUSED(event));
390 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false);
391 virtual void UpdateUI(
const bool mutexlock=
false);
394 virtual void SetSize(
int width,
int height);
410 DECLARE_EVENT_TABLE()
420 WXFieldParBase(wxWindow *parent,
const string& label,
const int field_id,
426 void OnEnter(wxCommandEvent & WXUNUSED(event));
428 void OnText(wxCommandEvent & WXUNUSED(event));
430 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false)=0;
447 DECLARE_EVENT_TABLE()
456 WXFieldPar(wxWindow *parent,
const string& label,
const int field_id,
457 T *par,
const int hsize=65);
459 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false);
460 virtual void UpdateUI(
const bool mutexlock=
false);
487 const string &name,
const int hsize=80);
489 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false);
491 virtual void UpdateUI(
const bool mutexlock=
false);
509 void AddMenu(
const string &name,
const int menuId,
const string& help=
"");
511 wxMenu&
GetMenu(
const int menuId);
513 void AddMenuItem(
const int menuId,
int id,
const string& item,
const string& help=
"",
514 const bool checkable=
false);
516 void AddMenuItem(
const int menuId,
int id,
const wxString& item,
517 wxMenu *subMenu,
const wxString& helpString = _T(
""));
518 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false);
519 virtual void UpdateUI(
const bool mutexlock=
false);
523 virtual void SetToolTip(
const wxString& tip,
long menu=0);
529 std::map<long,pair<wxMenu *,wxButton*> >
mvpMenu;
530 DECLARE_EVENT_TABLE()
535 #endif //_VFN_WX_CRYST_H_
void SetHumanValueScale(const T s)
Set Coefficient between the value used by ObjCryst++ and the one to be displayed to the user...
wxButton * mpButton
The button to be clicked to change the value.
WXCrystObj * mpWXObj
The WXCrystObj whose name is shown here.
wxString mFormat
Format to be used, default = _T("%8f")
void SetValue(const string &)
This actually posts an UpdateUI event, so that it is safe to call it from a non-graphic thread...
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the entry field.
WXFieldParBase(wxWindow *parent, const string &label, const int field_id, const int hsize=65)
Constructor.
A List of WXCrystObjBasic.
virtual void UpdateUI(const bool mutexlock=false)=0
Update the User Interface, if necessary.
bool mIsSelfUpdating
Set to true if the Field is being updated, so that no 'EVT_TEXT' is understood as user input...
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
virtual ~WXCrystObjBasic()
Destructor.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
This gets a new value from the parameter.
wxTextCtrl * mpField
The text window.
string mValueOld
Last name displayed, before the value was changed by the user.
void SetValue(const string &)
This actually posts an UpdateUI event, so that it is safe to call it from a non-graphic thread...
void WXCrystValidateAllUserInput()
This function validates all user input (in a WXField) not yet taken into account, if needs be...
CrystMutex mMutex
Mutex used to lock data when preparing to update the UI in non-main thread.
void Remove(WXCrystObjBasic *)
remove an object from the list
Class to pick one choice...
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...
WXFieldChoice(wxWindow *parent, const int field_id, const string &name, const int hsize=80)
Constructor.
T mValue
The value displayed.
bool mIsSelfUpdating
Set to true if the Field is being updated, so that no 'EVT_TEXT' is understood as user input...
virtual void ReadNewValue()=0
Reads the new value when the Enter key is hit.
const int mId
The Id of this field.
WXFieldPar(wxWindow *parent, const string &label, const int field_id, T *par, const int hsize=65)
Constructor.
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the entry field.
std::set< WXCrystObjBasic * > mvpWXCrystObj
List of pointers to the objects.
void Add(WXCrystObjBasic *)
Add an object to the list.
unsigned int GetNb() const
Number of objects.
bool mNeedUpdateUI
Do we need to update the display ?
void SetValue(const string &)
Used by the owner to change the name of the choice.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)=0
Get new values to be displayed from the underlying object, and raise flag if an UI update is necessar...
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window.
void OnEnter(wxCommandEvent &event)
When a new value is entered (must type it and then hit the 'enter' key).
virtual void ValidateUserInput()
This function shall be called when a new value has been entered.
bool mIsShown
Is the the window currently shown ?
bool mIsSelfUpdating
Set to true if the Field is being updated, so that no 'EVT_TEXT' is understood as user input...
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
virtual void SetSize(int width, int height)
Change the size of the field (excluding the title)
void OnText(wxCommandEvent &WXUNUSED(event))
Records when text is entered (either from self-updating or user input)
void OnToggleCollapse(wxCommandEvent &WXUNUSED(event))
Only display the title, and collapse everything else.
std::map< wxWindowID, std::pair< wxPoint, wxSize > > gvWindowPosition
Used to remember window positions.
virtual void Revert()=0
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
wxBoxSizer * mpSizer
The sizer of the menu.
bool Show(bool)
Show or hide all of the windows.
void SetLabel(const string &)
Change the field's label.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
This does nothing.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
virtual void SetToolTip(const wxString &tip, long menu=0)
Set tooltip for each menu.
virtual void Revert()
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
wxMenu & GetMenu(const int menuId)
Get access to a menu.
bool mIsExpanded
To be used for collapsing the sub-objects.
WXFieldName * mpWXTitle
The title.
void OnEnter(wxCommandEvent &WXUNUSED(event))
When a new value is entered (must type it and then hit the 'enter' key).
A field with the name of a WXCrystObj.
This is the abstract base class for all fields, wether they contain a floating-point parameter...
void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
Forces all objects in the list to update.
WXCrystObjBasic * mWXCrystParent
Parent, if a WXCrystObjBasic itself.
void OnText(wxCommandEvent &WXUNUSED(event))
Records when text is entered (either from self-updating or user input)
WXCrystObjBasicList mList
All windows but the title and collapse button are in this list.
void Revert()
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
WXCrystMenuBar(wxWindow *parent, WXCrystObj *owner)
Ctor.
void RemovedFromList(WXCrystObjBasicList *list)
void AddedToList(WXCrystObjBasicList *list)
void Revert()
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
virtual void SetSize(int width, int height)
Change the size of the field (excluding the title)
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...
Abstract base class for all objects in wxCryst.
wxTextCtrl * mpField
The field in which the value is written.
void AddMenuItem(const int menuId, int id, const string &item, const string &help="", const bool checkable=false)
Add an entry to a menu.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
Does nothing.
virtual void Revert()=0
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
void OnEnter(wxCommandEvent &event)
When a new value is entered (must type it and then hit the 'enter' key).
const string GetValue() const
Get the current name.
virtual bool SetForegroundColour(const wxColour &colour)
Change the colour of the field's title.
std::map< long, pair< wxMenu *, wxButton * > > mvpMenu
List of menus, first is the menu Id and second is a pair of
Provides the same functionnality as wxMultiChoiceDialog, but always using a wxListBox, which is much easier when selecting a large number of successive choices (using shift-click).
string mValue
Last name displayed.
virtual bool OnChangeName(const int id)=0
When a WXFieldName has been changed by the user, it is handled here.
wxBoxSizer * mpSizer
The horizontal sizer in which the title, button, fields, are put.
~WXCrystObjBasicList()
Destructor.
WXCrystObj(wxWindow *parent, int orient=wxHORIZONTAL, bool showName=true)
Constructor, with a.
WXCrystObjBasic(wxWindow *parent)
Constructor.
const string GetValue() const
Get the current name.
virtual void UpdateUI(const bool mutexlock=false)
Does nothing.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)=0
This gets a new value from the parameter.
Base class for all displayed ObjCryst objects (with a title, and a sizer to stack objects)...
string mValue
Last name displayed.
T * mpValue
A pointer to the value displayed.
virtual void SetSize(int width, int height)
Change the size of the field (excluding the title)
wxTextCtrl * mpField
The text window.
virtual void AddChild(WXCrystObjBasic *pChild, bool doBottomLayout=true)
Notify that a new children has been added, also adding it to the correct sizer (which can be the top ...
virtual void ValidateUserInput()
Unnecessary here. Any change is immediately taken into account.
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the entry field.
void OnPopupMenu(wxCommandEvent &event)
Event handler to popu the menu when the button is clicked.
virtual void ValidateUserInput()=0
This function shall be called when a new value has been entered.
void AddMenu(const string &name, const int menuId, const string &help="")
Add a menu.
WXCrystObjBasicList()
Constructor.
virtual void ReadNewValue()
Reads the new value when the Enter key is hit.
void SetFormat(const wxString &format)
Set Format.
string mValueOld
Last name displayed, before the value was changed by the user.
wxBoxSizer * mpSizer
Sizer including all sub-objects.
wxDEPRECATED(virtual void BottomLayout(WXCrystObjBasic *pChild))
Redo the Layout for the object and ask parent to take it into account.
Class to automatically assign a unique wxID to each window.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
wxBoxSizer * mpTopSizer
Top sizer including the title and WXCrystObj::mpSizer.
wxStaticText * mpLabel
The label.
virtual void ValidateUserInput()
This function shall be called when a new value has been entered.
virtual void ValidateUserInput()
This function shall be called when a new value has been entered.
T mHumanScale
Coefficient between the value used by ObjCryst++ and the one to be displayed to the user...
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
std::set< WXCrystObjBasicList * > mvpList
WXCrystObjBasicList which are aware of this object, and which should be told on destruction.
string * mpString
The WXCrystObj whose name is shown here.
wxButton * mpCollapseButton
The collapse button.
void OnText(wxCommandEvent &WXUNUSED(event))
Records when text is entered (either from self-updating or user input)
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
WXField(wxWindow *parent, const string &label, const int field_id)
Constructor, specifying the label of the field.
void Revert()
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
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 void AddChild(WXCrystObjBasic *pChild, bool doBottomLayout=true)
Notify that a new children has been added, also adding it to the correct sizer (which can be the top ...
A field which directly links to a string.
void UpdateUI(const bool mutexlock=false)
Forces all objects in the list to update.
Our own local menu bar, using buttons and Popup menus.