// 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
+#include "wx/wx.h"
#include "wx/propform.h"
#include <ctype.h>
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();
+
+ wxNode *node = m_propertySheet->GetProperties().GetFirst();
while (node)
{
- wxProperty *prop = (wxProperty *)node->Data();
+ wxProperty *prop = (wxProperty *)node->GetData();
wxPropertyValidator *validator = FindPropertyValidator(prop);
if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
{
if (!formValidator->OnCheckValue(prop, this, m_propertyWindow))
return FALSE;
}
- node = node->Next();
+ node = node->GetNext();
}
return TRUE;
}
{
if (!m_propertySheet)
return FALSE;
-
- wxNode *node = m_propertySheet->GetProperties().First();
+
+ wxNode *node = m_propertySheet->GetProperties().GetFirst();
while (node)
{
- wxProperty *prop = (wxProperty *)node->Data();
+ wxProperty *prop = (wxProperty *)node->GetData();
wxPropertyValidator *validator = FindPropertyValidator(prop);
if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
{
wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
formValidator->OnRetrieveValue(prop, this, m_propertyWindow);
}
- node = node->Next();
+ node = node->GetNext();
}
return TRUE;
}
{
if (!m_propertySheet)
return FALSE;
-
- wxNode *node = m_propertySheet->GetProperties().First();
+
+ wxNode *node = m_propertySheet->GetProperties().GetFirst();
while (node)
{
- wxProperty *prop = (wxProperty *)node->Data();
+ wxProperty *prop = (wxProperty *)node->GetData();
wxPropertyValidator *validator = FindPropertyValidator(prop);
if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
{
wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
formValidator->OnDisplayValue(prop, this, m_propertyWindow);
}
- node = node->Next();
+ node = node->GetNext();
}
return TRUE;
}
{
if (!m_propertySheet || !m_propertyWindow)
return FALSE;
-
- wxNode *node = m_propertyWindow->GetChildren().First();
+
+ wxWindowList::Node *node = m_propertyWindow->GetChildren().GetFirst();
while (node)
{
- wxWindow *win = (wxWindow *)node->Data();
- if (win->GetName() != wxT(""))
+ wxWindow *win = node->GetData();
+ if ( win->GetName() != wxEmptyString )
{
wxProperty *prop = m_propertySheet->GetProperty(win->GetName());
if (prop)
prop->SetWindow(win);
}
- node = node->Next();
+ node = node->GetNext();
}
return TRUE;
}
// 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)
else
{
// Find a validator to route the command to.
- wxNode *node = m_propertySheet->GetProperties().First();
+ wxNode *node = m_propertySheet->GetProperties().GetFirst();
while (node)
{
- wxProperty *prop = (wxProperty *)node->Data();
+ wxProperty *prop = (wxProperty *)node->GetData();
if (prop->GetWindow() && (prop->GetWindow() == &win))
{
wxPropertyValidator *validator = FindPropertyValidator(prop);
return;
}
}
- node = node->Next();
+ node = node->GetNext();
}
}
}
{
if (!m_propertySheet)
return;
-
+
// Find a validator to route the command to.
- wxNode *node = m_propertySheet->GetProperties().First();
+ wxNode *node = m_propertySheet->GetProperties().GetFirst();
while (node)
{
- wxProperty *prop = (wxProperty *)node->Data();
+ wxProperty *prop = (wxProperty *)node->GetData();
if (prop->GetWindow() && ((wxControl *)prop->GetWindow() == item))
{
wxPropertyValidator *validator = FindPropertyValidator(prop);
return;
}
}
- node = node->Next();
+ node = node->GetNext();
}
}
///
/// 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];
- sprintf(buf, "Value must be an integer between %ld and %ld!", m_integerMin, m_integerMax);
- wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
+ wxChar buf[200];
+ wxSprintf(buf, wxT("Value must be an integer between %ld and %ld!"), m_integerMin, m_integerMax);
+ wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
return FALSE;
}
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)
wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
if (!m_strings->Member(text->GetValue()))
{
- wxString s("Value ");
- s += text->GetValue();
- s += " is not valid.";
- wxMessageBox(s, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
+ wxString str( wxT("Value ") );
+ str += text->GetValue();
+ str += wxT(" is not valid.");
+ wxMessageBox(str, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
return FALSE;
}
}
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();
+ wxStringList::Node *node = m_strings->GetFirst();
while (node)
{
- char *s = (char *)node->Data();
+ wxChar *s = node->GetData();
lbox->Append(s);
- node = node->Next();
+ node = node->GetNext();
}
}
lbox->SetStringSelection(property->GetValue().StringValue());
else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice)))
{
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.
- wxNode *node = m_strings->First();
+ wxStringList::Node *node = m_strings->GetFirst();
while (node)
{
- char *s = (char *)node->Data();
+ wxChar *s = node->GetData();
choice->Append(s);
- node = node->Next();
+ node = node->GetNext();
}
}
-#endif
choice->SetStringSelection(property->GetValue().StringValue());
}
else
return TRUE;
}
+#endif // wxUSE_PROPSHEET