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);
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()
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
void WXCrystValidateAllUserInput()
This function validates all user input (in a WXField) not yet taken into account, if needs be.
std::map< wxWindowID, std::pair< wxPoint, wxSize > > gvWindowPosition
Used to remember window positions.
Provides the same functionnality as wxMultiChoiceDialog, but always using a wxListBox,...
Class to automatically assign a unique wxID to each window.
Abstract base class for all objects in wxCryst.
virtual ~WXCrystObjBasic()
Destructor.
bool mIsShown
Is the the window currently shown ?
virtual void UpdateUI(const bool mutexlock=false)=0
Update the User Interface, if necessary.
CrystMutex mMutex
Mutex used to lock data when preparing to update the UI in non-main thread.
wxDEPRECATED(virtual void BottomLayout(WXCrystObjBasic *pChild))
Redo the Layout for the object and ask parent to take it into account.
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window.
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...
void AddedToList(WXCrystObjBasicList *list)
void RemovedFromList(WXCrystObjBasicList *list)
WXCrystObjBasic * mWXCrystParent
Parent, if a WXCrystObjBasic itself.
WXCrystObjBasic(wxWindow *parent)
Constructor.
bool mNeedUpdateUI
Do we need to update the display ?
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 ...
std::set< WXCrystObjBasicList * > mvpList
WXCrystObjBasicList which are aware of this object, and which should be told on destruction.
A List of WXCrystObjBasic.
void Remove(WXCrystObjBasic *)
remove an object from the list
unsigned int GetNb() const
Number of objects.
void UpdateUI(const bool mutexlock=false)
Forces all objects in the list to update.
void Add(WXCrystObjBasic *)
Add an object to the list.
std::set< WXCrystObjBasic * > mvpWXCrystObj
List of pointers to the objects.
WXCrystObjBasicList()
Constructor.
void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
Forces all objects in the list to update.
bool Show(bool)
Show or hide all of the windows.
~WXCrystObjBasicList()
Destructor.
Base class for all displayed ObjCryst objects (with a title, and a sizer to stack objects).
WXFieldName * mpWXTitle
The title.
bool mIsExpanded
To be used for collapsing the sub-objects.
wxBoxSizer * mpSizer
Sizer including all sub-objects.
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 ...
WXCrystObjBasicList mList
All windows but the title and collapse button are in this list.
virtual bool OnChangeName(const int id)=0
When a WXFieldName has been changed by the user, it is handled here.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
wxBoxSizer * mpTopSizer
Top sizer including the title and WXCrystObj::mpSizer.
wxButton * mpCollapseButton
The collapse button.
void OnToggleCollapse(wxCommandEvent &WXUNUSED(event))
Only display the title, and collapse everything else.
WXCrystObj(wxWindow *parent, int orient=wxHORIZONTAL, bool showName=true)
Constructor, with a.
This is the abstract base class for all fields, wether they contain a floating-point parameter,...
void SetLabel(const string &)
Change the field's label.
wxStaticText * mpLabel
The label.
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...
virtual bool SetForegroundColour(const wxColour &colour)
Change the colour of the field's title.
WXField(wxWindow *parent, const string &label, const int field_id)
Constructor, specifying the label of the field.
wxBoxSizer * mpSizer
The horizontal sizer in which the title, button, fields, are put.
virtual void SetSize(int width, int height)
Change the size of the field (excluding the title)
virtual void ValidateUserInput()=0
This function shall be called when a new value has been entered.
const int mId
The Id of this field.
A field which directly links to a string.
void Revert()
After a user entry, this allows to go back to the last value, if for some reason the entry was reject...
void OnText(wxCommandEvent &WXUNUSED(event))
Records when text is entered (either from self-updating or user input)
virtual void SetSize(int width, int height)
Change the size of the field (excluding the title)
void SetValue(const string &)
This actually posts an UpdateUI event, so that it is safe to call it from a non-graphic thread.
string mValueOld
Last name displayed, before the value was changed by the user.
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.
string mValue
Last name displayed.
bool mIsSelfUpdating
Set to true if the Field is being updated, so that no 'EVT_TEXT' is understood as user input.
wxTextCtrl * mpField
The text window.
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 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.
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the entry field.
string * mpString
The WXCrystObj whose name is shown here.
A field with the name of a WXCrystObj.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
This does nothing.
wxTextCtrl * mpField
The text window.
void SetValue(const string &)
This actually posts an UpdateUI event, so that it is safe to call it from a non-graphic thread.
string mValueOld
Last name displayed, before the value was changed by the user.
bool mIsSelfUpdating
Set to true if the Field is being updated, so that no 'EVT_TEXT' is understood as 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...
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)
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the entry field.
string mValue
Last name displayed.
virtual void ValidateUserInput()
This function shall be called when a new value has been entered.
void OnText(wxCommandEvent &WXUNUSED(event))
Records when text is entered (either from self-updating or user input)
WXCrystObj * mpWXObj
The WXCrystObj whose name is shown here.
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.
bool mIsSelfUpdating
Set to true if the Field is being updated, so that no 'EVT_TEXT' is understood as user input.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)=0
This gets a new value from the parameter.
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 &WXUNUSED(event))
When a new value is entered (must type it and then hit the 'enter' key).
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the entry field.
wxString mFormat
Format to be used, default = _T("%8f")
wxTextCtrl * mpField
The field in which the value is written.
virtual void ValidateUserInput()
This function shall be called when a new value has been entered.
virtual void ReadNewValue()=0
Reads the new value when the Enter key is hit.
WXFieldParBase(wxWindow *parent, const string &label, const int field_id, const int hsize=65)
Constructor.
void OnText(wxCommandEvent &WXUNUSED(event))
Records when text is entered (either from self-updating or user input)
void SetFormat(const wxString &format)
Set Format.
T mValue
The value displayed.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
virtual 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)
This gets a new value from the parameter.
virtual void ReadNewValue()
Reads the new value when the Enter key is hit.
T mHumanScale
Coefficient between the value used by ObjCryst++ and the one to be displayed to the user.
T * mpValue
A pointer to the value displayed.
WXFieldPar(wxWindow *parent, const string &label, const int field_id, T *par, const int hsize=65)
Constructor.
void SetHumanValueScale(const T s)
Set Coefficient between the value used by ObjCryst++ and the one to be displayed to the user.
Class to pick one choice...
WXFieldChoice(wxWindow *parent, const int field_id, const string &name, const int hsize=80)
Constructor.
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)
Does nothing.
wxButton * mpButton
The button to be clicked to change the value.
virtual void UpdateUI(const bool mutexlock=false)
Does nothing.
void SetValue(const string &)
Used by the owner to change the name of the choice.
virtual void ValidateUserInput()
Unnecessary here. Any change is immediately taken into account.
Our own local menu bar, using buttons and Popup menus.
wxBoxSizer * mpSizer
The sizer of the menu.
virtual void SetToolTip(const wxString &tip, long menu=0)
Set tooltip for each menu.
wxMenu & GetMenu(const int menuId)
Get access to a menu.
void AddMenuItem(const int menuId, int id, const string &item, const string &help="", const bool checkable=false)
Add an entry to a menu.
std::map< long, pair< wxMenu *, wxButton * > > mvpMenu
List of menus, first is the menu Id and second is a pair of <pointer to the menu, pointer to the butt...
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
void AddMenu(const string &name, const int menuId, const string &help="")
Add a menu.
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...
WXCrystMenuBar(wxWindow *parent, WXCrystObj *owner)
Ctor.
void OnPopupMenu(wxCommandEvent &event)
Event handler to popu the menu when the button is clicked.