23 #include "wx/wxprec.h"
31 #include "ObjCryst/wxCryst/wxCryst.h"
34 #include "ObjCryst/Quirks/VFNDebug.h"
53 wxMultiChoiceDialog_ListBox::wxMultiChoiceDialog_ListBox(wxWindow* parent,
const wxString& message,
const wxString& caption,
54 int n,
const wxString* choices):
55 wxDialog(parent,-1,_T(
"Choose the molecule's atoms"),wxDefaultPosition,wxSize(300,400),wxCAPTION|wxSTAY_ON_TOP),
56 mListBox(this,-1,wxDefaultPosition,wxSize(250,350),n,choices,wxLB_MULTIPLE)
58 wxBoxSizer *sizer=
new wxBoxSizer(wxVERTICAL);
59 sizer->Add(&mListBox);
60 sizer->Add(this->CreateSeparatedButtonSizer(wxOK | wxCANCEL));
61 this->SetSizer(sizer);
62 sizer->SetSizeHints(
this);
66 wxArrayInt wxMultiChoiceDialog_ListBox::GetSelections()
const
69 mListBox.GetSelections(choice);
78 WXCRYST_ID::WXCRYST_ID(){mIndex=mCounter++;}
79 WXCRYST_ID::operator long(){
return mIndex;}
80 long WXCRYST_ID::mCounter=wxID_HIGHEST+100;
82 #ifdef VFN_CRYST_MUTEX
88 CrystMutex::CrystMutex():mNbLock(0){}
89 CrystMutex::~CrystMutex()
91 cout <<
"~CrystMutex("<<
this<<
"), Total number of Locks="<<mNbLock<<endl;
93 wxMutexError CrystMutex::Lock()
96 return this->wxMutex::Lock();
98 cout <<
"Thread:"<<wxThread::IsMain()<<
":CrystMutex("<<
this<<
")::Lock() ?"<<endl;
99 wxMutexError res=this->wxMutex::TryLock();
100 if(res==wxMUTEX_NO_ERROR)
101 cout <<
"Thread:"<<wxThread::IsMain()<<
":CrystMutex("<<
this<<
")::Lock()-OK"<<endl;
102 if(res==wxMUTEX_DEAD_LOCK)
104 cout <<
"Thread:"<<wxThread::IsMain()<<
":CrystMutex("<<
this<<
")::Lock()-DEADLOCK!"<<endl;
107 if(res==wxMUTEX_BUSY)
109 cout <<
"Thread:"<<wxThread::IsMain()<<
":CrystMutex("<<
this<<
")::Lock()-Busy?"<<endl;
110 res=this->wxMutex::Lock();
111 cout <<
"Thread:"<<wxThread::IsMain()<<
":CrystMutex("<<
this<<
")::Lock()-OK2"<<endl;
116 wxMutexError CrystMutex::Unlock()
120 return this->wxMutex::Unlock();
129 WXCrystObjBasic::WXCrystObjBasic(wxWindow* parent):
130 wxWindow(parent,-1),mWXCrystParent(0),mIsShown(true),mNeedUpdateUI(true)
132 VFN_DEBUG_MESSAGE(
"WXCrystObjBasic::WXCrystObjBasic() at "<<
this,6)
137 this->SetBackgroundColour(wxColour(240,240,240));
140 VFN_DEBUG_MESSAGE(
"WXCrystObjBasic::WXCrystObjBasic():End",6)
148 set<WXCrystObjBasicList*> vpList=
mvpList;
149 for(set<WXCrystObjBasicList*>::iterator pos=vpList.begin();pos!=vpList.end();++pos)
150 (*pos)->Remove(
this);
155 VFN_DEBUG_ENTRY(
"WXCrystObjBasic::BottomLayout(...)"<<this->GetSize().GetWidth()<<
","<<this->GetSize().GetHeight(),5);
156 wxTheApp->GetTopWindow()->SendSizeEvent();
157 VFN_DEBUG_EXIT(
"WXCrystObjBasic::BottomLayout(...)"<<this->GetSize().GetWidth()<<
","<<this->GetSize().GetHeight(),5);
161 VFN_DEBUG_ENTRY(
"WXCrystObjBasic::AddChild(...)"<<this->GetSize().GetWidth()<<
","<<this->GetSize().GetHeight(),5);
162 wxSizer *pSizer=this->GetSizer();
167 if(doBottomLayout) wxTheApp->GetTopWindow()->SendSizeEvent();
168 VFN_DEBUG_EXIT(
"WXCrystObjBasic::AddChild(...)"<<this->GetSize().GetWidth()<<
","<<this->GetSize().GetHeight(),5);
173 bool WXCrystObjBasic::Layout()
177 return wxWindow::Layout();
192 for(set<WXCrystObjBasic*>::iterator pos=vpWXCrystObj.begin();pos!=vpWXCrystObj.end();pos++)
193 (*pos)->RemovedFromList(
this);
201 VFN_DEBUG_MESSAGE(
"WXCrystObjBasicList::Add()",6)
208 VFN_DEBUG_MESSAGE(
"WXCrystObjBasicList::Remove():"<<win,6)
215 VFN_DEBUG_MESSAGE(
"WXCrystObjBasicList::Show(bool)",3)
219 VFN_DEBUG_MESSAGE(
"WXCrystObjBasicList::Show(bool):End",3)
225 VFN_DEBUG_ENTRY(
"WXCrystObjBasicList::CrystUpdate()",5)
228 VFN_DEBUG_MESSAGE(
"WXCrystObjBasicList::CrystUpdate("<<updateUI<<mutexlock<<
")@"<<*pos,5)
229 (*pos)->CrystUpdate(updateUI,mutexlock);
231 VFN_DEBUG_EXIT(
"WXCrystObjBasicList::CrystUpdate()",5)
235 VFN_DEBUG_ENTRY(
"WXCrystObjBasicList::UpdateUI("<<mutexlock<<
")"<<
"MainThread="<<wxThread::IsMain(),5)
237 (*pos)->UpdateUI(mutexlock);
238 VFN_DEBUG_EXIT(
"WXCrystObjBasicList::UpdateUI()",5)
240 void WXCrystObjBasicList::Enable(
bool enable)
243 (*pos)->Enable(enable);
259 if(0==spLastWXFieldInputNotValidated)
return;
260 VFN_DEBUG_ENTRY(
"WXCrystValidateAllUserInput()...",6)
263 spLastWXFieldInputNotValidated=0;
265 VFN_DEBUG_EXIT(
"WXCrystValidateAllUserInput()...",6)
276 VFN_DEBUG_ENTRY(
"WXField::WXField()",6)
277 mpSizer =
new wxBoxSizer(wxHORIZONTAL);
278 mpLabel=
new wxStaticText(
this,-1,wxString::FromAscii(label.c_str()));
283 VFN_DEBUG_EXIT(
"WXField::WXField()",6)
287 VFN_DEBUG_MESSAGE(
"WXField::SetLabel()",3)
288 mpLabel->SetLabel(wxString::FromAscii(s.c_str()));
293 VFN_DEBUG_MESSAGE(
"WXField::SetLabel()",3)
294 mpLabel->SetForegroundColour(colour);
295 return this->wxWindow::SetForegroundColour(colour);
311 const
int id,const
int hsize,
bool isEditable):
312 WXField(parent,"",
id),mpString(&st),mValue(st),mIsSelfUpdating(false)
314 VFN_DEBUG_MESSAGE(
"WXFieldString::WXFieldName():End",6)
317 mpField=new wxTextCtrl(this,ID_WXFIELD,wxString::FromAscii(mValue.c_str()),
318 wxDefaultPosition,wxSize(hsize,-1),wxTE_PROCESS_ENTER,
319 wxTextValidator(wxFILTER_ASCII));
321 mpField=new wxTextCtrl(this,ID_WXFIELD,wxString::FromAscii(mValue.c_str()),
322 wxDefaultPosition,wxSize(hsize,-1),wxTE_READONLY,
323 wxTextValidator(wxFILTER_ASCII));
325 mpSizer->Add(mpField,0,wxALIGN_CENTER);
326 mpSizer->SetSizeHints(this);
332 VFN_DEBUG_MESSAGE(
"WXFieldString::OnEnter()",6)
338 VFN_DEBUG_MESSAGE(
"WXFieldString::OnText():",6)
339 if(spLastWXFieldInputNotValidated!=
this)
342 spLastWXFieldInputNotValidated=
this;
348 VFN_DEBUG_ENTRY(
"WXFieldString::SetValue()",3)
349 wxMutexLocker mlock(
mMutex);
352 VFN_DEBUG_EXIT(
"WXFieldString::SetValue(): string unchanged",3)
357 VFN_DEBUG_EXIT(
"WXFieldString::SetValue()",3)
362 VFN_DEBUG_MESSAGE(
"WXFieldString::GetValue()"<<
mValue<<
":"<<
mpField->GetValue(),6)
367 VFN_DEBUG_ENTRY(
"WXFieldString::CrystUpdate()",3)
378 if(uui)
if(
true==wxThread::IsMain()) this->
UpdateUI(lock);
379 VFN_DEBUG_EXIT(
"WXFieldString::CrystUpdate()",3)
389 VFN_DEBUG_ENTRY(
"WXFieldString::UpdateUI("<<lock<<
")"<<
"MainThread="<<wxThread::IsMain(),4)
395 VFN_DEBUG_EXIT(
"WXFieldString::UpdateUI()",4)
399 VFN_DEBUG_MESSAGE(
"WXFieldString::Revert()",3)
400 wxMutexLocker mlock(
mMutex);
406 VFN_DEBUG_MESSAGE(
"WXFieldString::ValidateUserInput()",6)
408 wxMutexLocker mlock(
mMutex);
415 mpField->SetSize(width,height);
432 const
int id,const
int hsize,
bool isEditable):
433 WXField(parent,label,
id),mpWXObj(owner),mValue(""),mIsSelfUpdating(false)
435 VFN_DEBUG_ENTRY(
"WXFieldName::WXFieldName()",6)
437 mpField=new wxTextCtrl(this,ID_WXFIELD,wxString::FromAscii(mValue.c_str()),
438 wxDefaultPosition,wxSize(hsize,-1),wxTE_PROCESS_ENTER,
439 wxTextValidator(wxFILTER_ASCII));
441 mpField=new wxTextCtrl(this,ID_WXFIELD,wxString::FromAscii(mValue.c_str()),
442 wxDefaultPosition,wxSize(hsize,-1),wxTE_READONLY,
443 wxTextValidator(wxFILTER_ASCII));
445 mpSizer->Add(mpField,0,wxALIGN_CENTER);
451 void WXFieldName::OnEnter(wxCommandEvent & WXUNUSED(event))
453 VFN_DEBUG_MESSAGE(
"WXFieldName::OnEnter()",6)
459 VFN_DEBUG_MESSAGE(
"WXFieldName::OnText():",6)
460 if(spLastWXFieldInputNotValidated!=
this)
463 spLastWXFieldInputNotValidated=
this;
469 VFN_DEBUG_ENTRY(
"WXFieldName::SetValue()",3)
470 wxMutexLocker mlock(
mMutex);
473 VFN_DEBUG_EXIT(
"WXFieldName::SetValue():name unchanged",3)
478 VFN_DEBUG_EXIT(
"WXFieldName::SetValue()",3)
483 VFN_DEBUG_MESSAGE(
"WXFieldName::GetValue()"<<mValue<<
":"<<
mpField->GetValue(),6)
488 VFN_DEBUG_MESSAGE(
"WXFieldName::CrystUpdate()",3)
499 VFN_DEBUG_ENTRY(
"WXFieldName::UpdateUI("<<lock<<
")"<<
"MainThread="<<wxThread::IsMain(),4)
501 mpField->SetValue(wxString::FromAscii(mValue.c_str()));
503 int w=
mpField->GetTextExtent(wxString::FromAscii(mValue.c_str())).GetWidth();
504 const int wmax=wxTheApp->GetTopWindow()->GetSize().GetWidth();
506 if(w>
mpField->GetSize().GetWidth())
507 this->GetSizer()->SetItemMinSize(
mpField,w+30,-1);
508 this->GetSizer()->Fit(
this);
513 VFN_DEBUG_EXIT(
"WXFieldName::UpdateUI()",4)
517 VFN_DEBUG_MESSAGE(
"WXFieldName::Revert()",3)
518 wxMutexLocker mlock(
mMutex);
524 VFN_DEBUG_MESSAGE(
"WXFieldName::ValidateUserInput()",6)
527 mValue=
mpField->GetValue().ToAscii();
533 mpField->SetSize(width,height);
549 const
int id, const
int hsize):
550 WXField(parent,label,
id),mIsSelfUpdating(false),mFormat(_T("%8f"))
552 VFN_DEBUG_MESSAGE(
"WXFieldParBase::WXFieldName():End",6)
554 mpField=
new wxTextCtrl(
this,ID_WXFIELD,_T(
""),
555 wxDefaultPosition,wxSize(hsize,-1),wxTE_PROCESS_ENTER,
556 wxTextValidator(wxFILTER_NUMERIC));
557 mpSizer->Add(mpField,0,wxALIGN_CENTER);
565 VFN_DEBUG_MESSAGE(
"WXFieldRefPar::OnEnter()",6)
571 VFN_DEBUG_MESSAGE(
"WXFieldRefPar::OnText()",6)
572 if(spLastWXFieldInputNotValidated!=
this)
575 spLastWXFieldInputNotValidated=
this;
580 VFN_DEBUG_MESSAGE(
"WXFieldRefPar::ValidateUserInput()",6)
597 const int id,T *par,
const int hsize):
598 WXFieldParBase(parent,label,id,hsize),mpValue(par),mValue(*par),mValueOld(*par),mHumanScale(1)
604 const int id,
long *par,
const int hsize):
605 WXFieldParBase(parent,label,id,hsize),mpValue(par),mValue(*par),mValueOld(*par),mHumanScale(1)
613 if(lock) mMutex.Lock();
616 if(lock) mMutex.Unlock();
619 VFN_DEBUG_ENTRY(
"WXFieldPar<T>::CrystUpdate()",6)
623 if(lock) mMutex.Unlock();
624 if(uui)
if(
true==wxThread::IsMain()) this->UpdateUI(lock);
625 VFN_DEBUG_EXIT(
"WXFieldPar<T>::CrystUpdate()",6)
630 if(lock)mMutex.Lock();
631 if(mNeedUpdateUI==
false)
633 if(lock)mMutex.Unlock();
636 VFN_DEBUG_ENTRY(
"WXFieldPar<REAL>::UpdateUI("<<lock<<
")"<<
"MainThread="<<wxThread::IsMain(),4)
638 if((abs(mValue*mHumanScale)<1000)&&(abs(mValue*mHumanScale)>0.01)) tmp.Printf(_T(
"%6.4f"),mValue*mHumanScale);
639 else tmp.Printf(mFormat,mValue*mHumanScale);
640 mIsSelfUpdating=
true;
641 mpField->SetValue(tmp);
642 mIsSelfUpdating=
false;
644 if(lock)mMutex.Unlock();
645 VFN_DEBUG_EXIT(
"WXFieldPar<REAL>::UpdateUI()",4)
650 if(lock)mMutex.Lock();
651 if(mNeedUpdateUI==
false)
653 if(lock)mMutex.Unlock();
656 VFN_DEBUG_ENTRY(
"WXFieldPar<long>::UpdateUI("<<lock<<
")"<<
"MainThread="<<wxThread::IsMain(),4)
658 tmp.Printf(mFormat,mValue*mHumanScale);
659 mIsSelfUpdating=
true;
660 mpField->SetValue(tmp);
661 mIsSelfUpdating=
false;
663 if(lock)mMutex.Unlock();
664 VFN_DEBUG_EXIT(
"WXFieldPar<long>::UpdateUI()",4)
688 VFN_DEBUG_MESSAGE(
"WXFieldPar<T>::Revert()",6)
694 if(
true==wxThread::IsMain()) this->UpdateUI(
true);
704 VFN_DEBUG_MESSAGE(
"WXFieldPar<REAL>::ReadNewValue()",6)
705 wxMutexLocker mlock(mMutex);
707 wxString s=mpField->GetValue();
711 *mpValue /= mHumanScale;
715 VFN_DEBUG_MESSAGE(
"WXFieldPar<long>::ReadNewValue()",6)
716 wxMutexLocker mlock(mMutex);
718 wxString s=mpField->GetValue();
720 *mpValue /= mHumanScale;
733 WXFieldChoice::WXFieldChoice
734 (wxWindow *parent,
const int field_id,
const string &name,
const int hsize):
737 mpButton=
new wxButton(
this,field_id,wxString::FromAscii(name.c_str()),wxDefaultPosition,wxSize(hsize,-1));
738 mpSizer->Add(mpButton,0,wxALIGN_CENTER);
746 void WXFieldChoice::CrystUpdate(
const bool uui,
const bool lock)
750 void WXFieldChoice::UpdateUI(
const bool lock)
755 void WXFieldChoice::Revert()
759 void WXFieldChoice::SetValue(
const string&name)
761 mpButton->SetLabel(wxString::FromAscii(name.c_str()));
763 void WXFieldChoice::ValidateUserInput(){}
773 EVT_BUTTON(ID_WXOBJ_COLLAPSE,
WXCrystObj::OnToggleCollapse)
774 EVT_UPDATE_UI(ID_WXOBJ_ENABLE,
WXCrystObj::OnEnable)
775 EVT_UPDATE_UI(ID_WXOBJ_DISABLE,
WXCrystObj::OnEnable)
781 VFN_DEBUG_ENTRY(
"WXCrystObj::WXCrystObj()",6)
782 mpTopSizer=
new wxBoxSizer(orient);
783 this->SetSizer(mpTopSizer);
785 mpCollapseButton=
new wxButton(
this,ID_WXOBJ_COLLAPSE,_T(
"-"),
786 wxDefaultPosition,wxSize(14,14));
787 mpTopSizer->Add(mpCollapseButton,0, wxALIGN_TOP);
790 mpSizer=
new wxBoxSizer(wxVERTICAL);
791 mpTopSizer->Add(mpSizer,0, wxALIGN_TOP);
795 mpWXTitle =
new WXFieldName(
this,
"name:",
this,ID_WXOBJ_NAME,100);
796 mpSizer->Add(mpWXTitle,0,wxALIGN_LEFT);
800 VFN_DEBUG_EXIT(
"WXCrystObj::WXCrystObj():End",6)
803 WXCrystObj::~WXCrystObj()
813 void WXCrystObj::OnToggleCollapse(wxCommandEvent & WXUNUSED(event))
816 VFN_DEBUG_MESSAGE(
"WXCrystObj::OnToggleCollapse()",6)
817 mIsExpanded = !mIsExpanded;
818 mList.Show(mIsExpanded);
819 if(
true==mIsExpanded) mpCollapseButton->SetLabel(
"-");
820 else mpCollapseButton->SetLabel(
"+");
822 VFN_DEBUG_MESSAGE(
"WXCrystObj::OnToggleCollapse():End",6)
826 void WXCrystObj::CrystUpdate(
const bool uui,
const bool lock)
828 VFN_DEBUG_ENTRY(
"WXCrystObj::CrystUpdate("<<uui<<lock<<
")",6)
830 mList.CrystUpdate(uui,lock);
832 VFN_DEBUG_EXIT(
"WXCrystObj::CrystUpdate()",6)
834 void WXCrystObj::UpdateUI(
const bool lock)
836 VFN_DEBUG_ENTRY(
"WXCrystObj::UpdateUI("<<lock<<
")"<<
"MainThread="<<wxThread::IsMain(),6)
837 if(lock) mMutex.Lock();
838 if(mpWXTitle!=0) mpWXTitle->UpdateUI(
false);
839 mList.UpdateUI(
false);
840 if(lock) mMutex.Unlock();
841 VFN_DEBUG_EXIT(
"WXCrystObj::UpdateUI()",6)
843 void WXCrystObj::OnEnable(wxUpdateUIEvent &event)
845 if(ID_WXOBJ_ENABLE==event.GetId()) this->Enable(
true);
846 else this->Enable(
false);
849 bool WXCrystObj::Enable(
bool enable)
851 mList.Enable(enable);
852 return this->wxWindow::Enable(enable);
857 VFN_DEBUG_ENTRY(
"WXCrystObj::AddChild(..)"<<this->GetSize().GetWidth()<<
","<<this->GetSize().GetHeight(),5);
860 mpSizer->Add(pChild);
862 if(doBottomLayout) wxTheApp->GetTopWindow()->SendSizeEvent();
863 VFN_DEBUG_EXIT(
"WXCrystObj::AddChild(..)"<<this->GetSize().GetWidth()<<
","<<this->GetSize().GetHeight(),5);
904 VFN_DEBUG_MESSAGE(
"WXCrystMenuBar::WXCrystMenuBar():",6)
905 mpSizer=
new wxBoxSizer(wxHORIZONTAL);
906 this->SetSizer(mpSizer);
909 void WXCrystMenuBar::AddMenu(
const string &name,
const int menuId,
const string& help)
911 VFN_DEBUG_MESSAGE(
"WXCrystMenuBar::AddMenu()",6)
912 const long id=ID_CRYST_MENU1+mvpMenu.size();
913 mvpMenu[menuId]=make_pair(
new wxMenu(wxString::FromAscii(name.c_str())),
914 new wxButton(
this,
id,wxString::FromAscii(name.c_str())));
915 VFN_DEBUG_MESSAGE(
"WXCrystMenuBar::AddMenu():2",6)
916 mvpMenu[menuId].second->Layout();
917 mpSizer->Add(mvpMenu[menuId].second,0,wxALIGN_CENTER);
919 VFN_DEBUG_MESSAGE(
"WXCrystMenuBar::AddMenu():End",6)
922 wxMenu& WXCrystMenuBar::GetMenu(
const int menuId)
925 return *(mvpMenu[menuId].first);
928 void WXCrystMenuBar::AddMenuItem(
const int menuId,
int id,
const string& item,
const string& help,
const bool checkable)
930 VFN_DEBUG_MESSAGE(
"WXCrystMenuBar::AddMenuItem():",6)
932 this->GetMenu(menuId).Append(
id,wxString::FromAscii(item.c_str()),wxString::FromAscii(help.c_str()),checkable);
935 void WXCrystMenuBar::AddMenuItem(
const int menuId,
int id,
const wxString& item,
936 wxMenu *subMenu,
const wxString& helpString)
938 VFN_DEBUG_MESSAGE(
"WXCrystMenuBar::AddMenuItem():",6)
940 this->GetMenu(menuId).Append(
id,item,subMenu,helpString);
943 void WXCrystMenuBar::CrystUpdate(
const bool updateUI,
const bool mutexlock)
946 void WXCrystMenuBar::UpdateUI(
const bool mutexlock)
950 void WXCrystMenuBar::OnPopupMenu(wxCommandEvent & event)
952 VFN_DEBUG_MESSAGE(
"WXCrystMenuBar::OnPopupMenu():",6)
956 std::map<long,pair<wxMenu *,wxButton*> >::iterator pos;
957 const int i=
event.GetId();
958 for(pos=mvpMenu.begin();pos!=mvpMenu.end();++pos)
if(i==pos->second.second->GetId())
break;
959 if(pos!=mvpMenu.end())
960 this->PopupMenu(pos->second.first,pos->second.second->GetPosition());
962 void WXCrystMenuBar::SetToolTip(
const wxString& tip,
long menuId){mvpMenu[menuId].second->SetToolTip(tip);}
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.
A List of WXCrystObjBasic.
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
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...
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 ?
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window.
virtual void ValidateUserInput()
This function shall be called when a new value has been entered.
bool mIsSelfUpdating
Set to true if the Field is being updated, so that no 'EVT_TEXT' is understood as user input...
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)
std::map< wxWindowID, std::pair< wxPoint, wxSize > > gvWindowPosition
Used to remember window positions.
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.
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)
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)
Abstract base class for all objects in wxCryst.
wxTextCtrl * mpField
The field in which the value is written.
const string GetValue() const
Get the current name.
virtual bool SetForegroundColour(const wxColour &colour)
Change the colour of the field's title.
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.
const string GetValue() const
Get the current name.
Base class for all displayed ObjCryst objects (with a title, and a sizer to stack objects)...
string mValue
Last name displayed.
virtual void SetSize(int width, int height)
Change the size of the field (excluding the title)
wxTextCtrl * mpField
The text window.
virtual void SetToolTip(const wxString &tip)
Set tooltip for this window. It will be activated when going over the entry field.
virtual void ValidateUserInput()=0
This function shall be called when a new value has been entered.
WXCrystObjBasicList()
Constructor.
void SetFormat(const wxString &format)
Set Format.
string mValueOld
Last name displayed, before the value was changed by the user.
Class to automatically assign a unique wxID to each window.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
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.
WXField * spLastWXFieldInputNotValidated
This pointer records the last wxField in which something was enetered, so that it can be validated wh...
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.
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 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.