// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma hdrstop
#endif
+#if wxUSE_PROPSHEET
+
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormView, wxPropertyView)
BEGIN_EVENT_TABLE(wxPropertyFormView, wxPropertyView)
-EVT_BUTTON(wxID_OK, wxPropertyFormView::OnOk)
-EVT_BUTTON(wxID_CANCEL, wxPropertyFormView::OnCancel)
-EVT_BUTTON(wxID_HELP, wxPropertyFormView::OnHelp)
-EVT_BUTTON(wxID_PROP_REVERT, wxPropertyFormView::OnRevert)
-EVT_BUTTON(wxID_PROP_UPDATE, wxPropertyFormView::OnUpdate)
+EVT_BUTTON(wxID_OK, wxPropertyFormView::OnOk)
+EVT_BUTTON(wxID_CANCEL, wxPropertyFormView::OnCancel)
+EVT_BUTTON(wxID_HELP, wxPropertyFormView::OnHelp)
+EVT_BUTTON(wxID_PROP_REVERT, wxPropertyFormView::OnRevert)
+EVT_BUTTON(wxID_PROP_UPDATE, wxPropertyFormView::OnUpdate)
END_EVENT_TABLE()
bool wxPropertyFormView::sm_dialogCancelled = FALSE;
{
m_propertyWindow = propPanel;
m_managedWindow = NULL;
-
+
m_windowCloseButton = NULL;
m_windowCancelButton = NULL;
m_windowHelpButton = NULL;
-
+
m_detailedEditing = FALSE;
}
void wxPropertyFormView::ShowView(wxPropertySheet *ps, wxWindow *panel)
{
m_propertySheet = ps;
-
+
AssociatePanel(panel);
// CreateControls();
// UpdatePropertyList();
{
if (!m_propertySheet)
return FALSE;
-
+
wxNode *node = m_propertySheet->GetProperties().First();
while (node)
{
{
if (!m_propertySheet)
return FALSE;
-
+
wxNode *node = m_propertySheet->GetProperties().First();
while (node)
{
{
if (!m_propertySheet)
return FALSE;
-
+
wxNode *node = m_propertySheet->GetProperties().First();
while (node)
{
{
if (!m_propertySheet || !m_propertyWindow)
return FALSE;
-
+
wxNode *node = m_propertyWindow->GetChildren().First();
while (node)
{
// Retrieve the value if any
if (!Check())
return;
-
+
sm_dialogCancelled = FALSE;
TransferToPropertySheet();
-
+
m_managedWindow->Close(TRUE);
}
void wxPropertyFormView::OnCancel(wxCommandEvent& WXUNUSED(event))
{
sm_dialogCancelled = TRUE;
-
+
m_managedWindow->Close(TRUE);
}
{
if (!m_propertySheet)
return;
-
+
if (win.GetName() == wxT(""))
return;
-
+
if (wxStrcmp(win.GetName(), wxT("ok")) == 0)
OnOk(event);
else if (wxStrcmp(win.GetName(), wxT("cancel")) == 0)
{
if (!m_propertySheet)
return;
-
+
// Find a validator to route the command to.
wxNode *node = m_propertySheet->GetProperties().First();
while (node)
///
/// Real number form validator
-///
-bool wxRealFormValidator::OnCheckValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+///
+bool wxRealFormValidator::OnCheckValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *parentWindow)
{
if (m_realMin == 0.0 && m_realMax == 0.0)
return TRUE;
-
+
// The item used for viewing the real number: should be a text item.
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
return FALSE;
-
+
wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
-
+
float val = 0.0;
if (!StringToFloat(WXSTRINGCAST value, &val))
{
wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
return FALSE;
}
-
+
if (val < m_realMin || val > m_realMax)
{
wxChar buf[200];
return TRUE;
}
-bool wxRealFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxRealFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow) )
{
// The item used for viewing the real number: should be a text item.
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
return FALSE;
-
+
wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
-
+
if (value.Length() == 0)
return FALSE;
-
+
float f = (float)wxAtof((const wxChar *)value);
property->GetValue() = f;
return TRUE;
}
-bool wxRealFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxRealFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow) )
{
// The item used for viewing the real number: should be a text item.
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
return FALSE;
-
+
wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow;
textItem->SetValue(FloatToString(property->GetValue().RealValue()));
return TRUE;
///
/// Integer validator
-///
+///
IMPLEMENT_DYNAMIC_CLASS(wxIntegerFormValidator, wxPropertyFormValidator)
-bool wxIntegerFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxIntegerFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *parentWindow)
{
if (m_integerMin == 0.0 && m_integerMax == 0.0)
return TRUE;
-
+
// The item used for viewing the real number: should be a text item or a slider
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow)
return FALSE;
-
+
long val = 0;
-
+
if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
{
wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
-
+
if (!StringToLong(WXSTRINGCAST value, &val))
{
wxChar buf[200];
}
else
return FALSE;
-
+
if (val < m_integerMin || val > m_integerMax)
{
char buf[200];
return TRUE;
}
-bool wxIntegerFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxIntegerFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow))
{
// The item used for viewing the real number: should be a text item or a slider
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow)
return FALSE;
-
+
if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
{
wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
-
+
if (value.Length() == 0)
return FALSE;
-
+
long i = wxAtol((const wxChar *)value);
property->GetValue() = i;
}
}
else
return FALSE;
-
+
return TRUE;
}
-bool wxIntegerFormValidator::OnDisplayValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxIntegerFormValidator::OnDisplayValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow))
{
// The item used for viewing the real number: should be a text item or a slider
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow)
return FALSE;
-
+
if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
{
wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow;
///
/// Boolean validator
-///
+///
IMPLEMENT_DYNAMIC_CLASS(wxBoolFormValidator, wxPropertyFormValidator)
-bool wxBoolFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxBoolFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow))
{
// The item used for viewing the boolean: should be a checkbox
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox)))
return FALSE;
-
+
return TRUE;
}
-bool wxBoolFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxBoolFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow) )
{
// The item used for viewing the boolean: should be a checkbox.
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox)))
return FALSE;
-
+
wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow;
-
+
property->GetValue() = (bool)checkBox->GetValue();
return TRUE;
}
-bool wxBoolFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxBoolFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow))
{
// The item used for viewing the boolean: should be a checkbox.
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox)))
return FALSE;
-
+
wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow;
checkBox->SetValue((bool)property->GetValue().BoolValue());
return TRUE;
///
/// String validator
-///
+///
IMPLEMENT_DYNAMIC_CLASS(wxStringFormValidator, wxPropertyFormValidator)
wxStringFormValidator::wxStringFormValidator(wxStringList *list, long flags):
m_strings = list;
}
-bool wxStringFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxStringFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *parentWindow )
{
if (!m_strings)
return TRUE;
-
+
// The item used for viewing the string: should be a text item, choice item or listbox.
wxWindow *m_propertyWindow = property->GetWindow();
if (!m_propertyWindow)
return TRUE;
}
-bool wxStringFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxStringFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow) )
{
// The item used for viewing the string: should be a text item, choice item or listbox.
return TRUE;
}
-bool wxStringFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
+bool wxStringFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
wxWindow *WXUNUSED(parentWindow) )
{
// The item used for viewing the string: should be a text item, choice item or listbox.
else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox)))
{
wxListBox *lbox = (wxListBox *)m_propertyWindow;
- if (lbox->Number() == 0 && m_strings)
+ if (lbox->GetCount() == 0 && m_strings)
{
// Try to initialize the listbox from 'strings'
wxNode *node = m_strings->First();
{
wxChoice *choice = (wxChoice *)m_propertyWindow;
#ifndef __XVIEW__
- if (choice->Number() == 0 && m_strings)
+ if (choice->GetCount() == 0 && m_strings)
{
// Try to initialize the choice item from 'strings'
// XView doesn't allow this kind of thing.
return TRUE;
}
+#endif // wxUSE_PROPSHEET