// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include "wx/wx.h"
#endif
+#include "wx/colordlg.h"
+#include "wx/proplist.h"
+
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
-#if wxUSE_IOSTREAMH
-#if defined(__WXMSW__) && !defined(__GNUWIN32__)
-#include <strstrea.h>
-#else
-#include <strstream.h>
-#endif
-#else
-#include <strstream>
-#endif
-
-#include "wx/window.h"
-#include "wx/utils.h"
-#include "wx/list.h"
-#include "wx/colordlg.h"
-#include "wx/proplist.h"
/*
* Property text edit control
*/
-
+
IMPLEMENT_CLASS(wxPropertyTextEdit, wxTextCtrl)
wxPropertyTextEdit::wxPropertyTextEdit(wxPropertyListView *v, wxWindow *parent,
const wxWindowID id, const wxString& value,
- const wxPoint& pos, const wxSize& size,
+ const wxPoint& pos, const wxSize& size,
long style, const wxString& name):
wxTextCtrl(parent, id, value, pos, size, style, wxDefaultValidator, name)
{
IMPLEMENT_DYNAMIC_CLASS(wxPropertyListView, wxPropertyView)
BEGIN_EVENT_TABLE(wxPropertyListView, wxPropertyView)
- EVT_BUTTON(wxID_OK, wxPropertyListView::OnOk)
- EVT_BUTTON(wxID_CANCEL, wxPropertyListView::OnCancel)
- EVT_BUTTON(wxID_HELP, wxPropertyListView::OnHelp)
- EVT_BUTTON(wxID_PROP_CROSS, wxPropertyListView::OnCross)
- EVT_BUTTON(wxID_PROP_CHECK, wxPropertyListView::OnCheck)
- EVT_BUTTON(wxID_PROP_EDIT, wxPropertyListView::OnEdit)
- EVT_TEXT_ENTER(wxID_PROP_TEXT, wxPropertyListView::OnText)
- EVT_LISTBOX(wxID_PROP_SELECT, wxPropertyListView::OnPropertySelect)
- EVT_COMMAND(wxID_PROP_SELECT, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxPropertyListView::OnPropertyDoubleClick)
- EVT_LISTBOX(wxID_PROP_VALUE_SELECT, wxPropertyListView::OnValueListSelect)
+ EVT_BUTTON(wxID_OK, wxPropertyListView::OnOk)
+ EVT_BUTTON(wxID_CANCEL, wxPropertyListView::OnCancel)
+ EVT_BUTTON(wxID_HELP, wxPropertyListView::OnHelp)
+ EVT_BUTTON(wxID_PROP_CROSS, wxPropertyListView::OnCross)
+ EVT_BUTTON(wxID_PROP_CHECK, wxPropertyListView::OnCheck)
+ EVT_BUTTON(wxID_PROP_EDIT, wxPropertyListView::OnEdit)
+ EVT_TEXT_ENTER(wxID_PROP_TEXT, wxPropertyListView::OnText)
+ EVT_LISTBOX(wxID_PROP_SELECT, wxPropertyListView::OnPropertySelect)
+ EVT_COMMAND(wxID_PROP_SELECT, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
+ wxPropertyListView::OnPropertyDoubleClick)
+ EVT_LISTBOX(wxID_PROP_VALUE_SELECT, wxPropertyListView::OnValueListSelect)
END_EVENT_TABLE()
bool wxPropertyListView::sm_dialogCancelled = FALSE;
wxString stringValueRepr(property->GetValue().GetStringRepresentation());
wxString paddedString(MakeNameValueString(property->GetName(), stringValueRepr));
- m_propertyScrollingList->Append(paddedString.GetData(), (char *)property);
+ m_propertyScrollingList->Append(paddedString.GetData(), (void *)property);
node = node->Next();
}
return TRUE;
if (!m_propertyScrollingList || !m_propertySheet)
return FALSE;
+#ifdef __WXMSW__
int currentlySelected = m_propertyScrollingList->GetSelection();
+#endif
// #ifdef __WXMSW__
wxString stringValueRepr(property->GetValue().GetStringRepresentation());
wxString paddedString(MakeNameValueString(property->GetName(), stringValueRepr));
{
// Don't update the listbox unnecessarily because it can cause
// ugly flashing.
-
+
if (paddedString != m_propertyScrollingList->GetString(sel))
m_propertyScrollingList->SetString(sel, paddedString.GetData());
}
smallButtonWidth = -1;
smallButtonHeight = -1;
#endif
-
+
if (m_valueText)
return TRUE;
-
+
if (!panel)
return FALSE;
wxWindow *leftMostWindow = panel;
+/*
wxWindow *topMostWindow = panel;
wxWindow *rightMostWindow = panel;
+*/
wxSystemSettings settings;
wxFont guiFont = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
c2->left.SameAs (panel, wxLeft, 2);
else
c2->left.RightOf (leftMostWindow, 2);
-
+
c2->bottom.SameAs (panel, wxBottom, 2);
c2->width.AsIs();
c2->height.AsIs();
m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, "", wxPoint(-1, -1), wxSize(-1, -1), wxPROCESS_ENTER);
m_valueText->Enable(FALSE);
-
+
wxLayoutConstraints *c = new wxLayoutConstraints;
if (m_cancelButton)
// Retrieve the value if any
wxCommandEvent event;
OnCheck(event);
-
+
delete this;
return TRUE;
}
{
// Retrieve the value if any
OnCheck(event);
-
+
m_managedWindow->Close(TRUE);
}
/*
* Property dialog box
*/
-
+
IMPLEMENT_CLASS(wxPropertyListDialog, wxDialog)
BEGIN_EVENT_TABLE(wxPropertyListDialog, wxDialog)
- EVT_BUTTON(wxID_CANCEL, wxPropertyListDialog::OnCancel)
+ EVT_BUTTON(wxID_CANCEL, wxPropertyListDialog::OnCancel)
+ EVT_CLOSE(wxPropertyListDialog::OnCloseWindow)
END_EVENT_TABLE()
wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView *v, wxWindow *parent,
- const wxString& title, const wxPoint& pos,
+ const wxString& title, const wxPoint& pos,
const wxSize& size, long style, const wxString& name):
wxDialog(parent, -1, title, pos, size, style, name)
{
SetAutoLayout(TRUE);
}
-bool wxPropertyListDialog::OnClose(void)
+void wxPropertyListDialog::OnCloseWindow(wxCloseEvent& event)
{
if (m_view)
{
- SetReturnCode(wxID_CANCEL);
+ SetReturnCode(wxID_CANCEL);
m_view->OnClose();
- m_view = NULL;
- return TRUE;
+ m_view = NULL;
+ this->Destroy();
}
else
- return FALSE;
+ {
+ event.Veto();
+ }
}
void wxPropertyListDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{
- SetReturnCode(wxID_CANCEL);
+ SetReturnCode(wxID_CANCEL);
this->Close();
}
-void wxPropertyListDialog::OnDefaultAction(wxControl *item)
+void wxPropertyListDialog::OnDefaultAction(wxControl *WXUNUSED(item))
{
/*
if (item == m_view->GetPropertyScrollingList())
// Extend event processing to search the view's event table
bool wxPropertyListDialog::ProcessEvent(wxEvent& event)
{
- if ( !m_view || ! m_view->ProcessEvent(event) )
- return wxEvtHandler::ProcessEvent(event);
- else
- return TRUE;
+ if ( !m_view || ! m_view->ProcessEvent(event) )
+ return wxEvtHandler::ProcessEvent(event);
+ else
+ return TRUE;
}
/*
* Property panel
*/
-
+
IMPLEMENT_CLASS(wxPropertyListPanel, wxPanel)
BEGIN_EVENT_TABLE(wxPropertyListPanel, wxPanel)
{
}
-void wxPropertyListPanel::OnDefaultAction(wxControl *item)
+void wxPropertyListPanel::OnDefaultAction(wxControl *WXUNUSED(item))
{
/*
if (item == view->GetPropertyScrollingList())
// Extend event processing to search the view's event table
bool wxPropertyListPanel::ProcessEvent(wxEvent& event)
{
- if ( !m_view || ! m_view->ProcessEvent(event) )
- return wxEvtHandler::ProcessEvent(event);
- else
- return TRUE;
+ if ( !m_view || ! m_view->ProcessEvent(event) )
+ return wxEvtHandler::ProcessEvent(event);
+ else
+ return TRUE;
}
void wxPropertyListPanel::OnSize(wxSizeEvent& WXUNUSED(event))
/*
* Property frame
*/
-
+
IMPLEMENT_CLASS(wxPropertyListFrame, wxFrame)
-bool wxPropertyListFrame::OnClose(void)
+BEGIN_EVENT_TABLE(wxPropertyListFrame, wxFrame)
+ EVT_CLOSE(wxPropertyListFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
+void wxPropertyListFrame::OnCloseWindow(wxCloseEvent& event)
{
if (m_view)
{
m_propertyPanel->SetView(NULL);
m_view->OnClose();
m_view = NULL;
- return TRUE;
+ this->Destroy();
}
else
- return FALSE;
+ {
+ event.Veto();
+ }
}
wxPropertyListPanel *wxPropertyListFrame::OnCreatePanel(wxFrame *parent, wxPropertyListView *v)
/*
* Property list specific validator
*/
-
+
IMPLEMENT_ABSTRACT_CLASS(wxPropertyListValidator, wxPropertyValidator)
bool wxPropertyListValidator::OnSelect(bool select, wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
return TRUE;
}
-bool wxPropertyListValidator::OnValueListSelect(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxPropertyListValidator::OnValueListSelect(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
wxString s(view->GetValueList()->GetStringSelection());
- if (s != "")
+ if (s != _T(""))
{
view->GetValueText()->SetValue(s);
view->RetrieveProperty(property);
return TRUE;
}
-bool wxPropertyListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxPropertyListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
// view->GetValueText()->Show(TRUE);
wxString str(property->GetValue().GetStringRepresentation());
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxPropertyListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxPropertyListValidator::OnRetrieveValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
return FALSE;
}
-void wxPropertyListValidator::OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+void wxPropertyListValidator::OnEdit(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetDetailedEditing())
view->EndDetailedEditing();
view->BeginDetailedEditing();
}
-bool wxPropertyListValidator::OnClearControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxPropertyListValidator::OnClearControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetConfirmButton())
view->GetConfirmButton()->Enable(FALSE);
///
/// Real number validator
-///
-bool wxRealListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+///
+bool wxRealListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow)
{
if (m_realMin == 0.0 && m_realMax == 0.0)
return TRUE;
-
+
if (!view->GetValueText())
return FALSE;
wxString value(view->GetValueText()->GetValue());
float val = 0.0;
if (!StringToFloat(WXSTRINGCAST value, &val))
{
- char buf[200];
- sprintf(buf, "Value %s is not a valid real number!", value.GetData());
- wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
+ wxChar buf[200];
+ wxSprintf(buf, _T("Value %s is not a valid real number!"), value.GetData());
+ wxMessageBox(buf, _T("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
return FALSE;
}
-
+
if (val < m_realMin || val > m_realMax)
{
char buf[200];
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxRealListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxRealListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
- if (strlen(view->GetValueText()->GetValue()) == 0)
+ if (wxStrlen(view->GetValueText()->GetValue()) == 0)
return FALSE;
-
+
wxString value(view->GetValueText()->GetValue());
- float f = (float)atof(value.GetData());
+ float f = (float)wxAtof(value.GetData());
property->GetValue() = f;
return TRUE;
}
-bool wxRealListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxRealListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetConfirmButton())
view->GetConfirmButton()->Enable(TRUE);
///
/// Integer validator
-///
+///
IMPLEMENT_DYNAMIC_CLASS(wxIntegerListValidator, wxPropertyListValidator)
-bool wxIntegerListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxIntegerListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow)
{
if (m_integerMin == 0 && m_integerMax == 0)
return TRUE;
-
+
if (!view->GetValueText())
return FALSE;
wxString value(view->GetValueText()->GetValue());
long val = 0;
if (!StringToLong(WXSTRINGCAST value, &val))
{
- char buf[200];
- sprintf(buf, "Value %s is not a valid integer!", value.GetData());
- wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
+ wxChar buf[200];
+ wxSprintf(buf, _T("Value %s is not a valid integer!"), value.GetData());
+ wxMessageBox(buf, _T("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
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, _T("Value must be an integer between %ld and %ld!"), m_integerMin, m_integerMax);
+ wxMessageBox(buf, _T("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
return FALSE;
}
return TRUE;
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxIntegerListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxIntegerListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
- if (strlen(view->GetValueText()->GetValue()) == 0)
+ if (wxStrlen(view->GetValueText()->GetValue()) == 0)
return FALSE;
-
+
wxString value(view->GetValueText()->GetValue());
- long val = (long)atoi(value.GetData());
+ long val = (long)wxAtoi(value.GetData());
property->GetValue() = (long)val;
return TRUE;
}
-bool wxIntegerListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxIntegerListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetConfirmButton())
view->GetConfirmButton()->Enable(TRUE);
///
IMPLEMENT_DYNAMIC_CLASS(wxBoolListValidator, wxPropertyListValidator)
-bool wxBoolListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxBoolListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow)
{
if (!view->GetValueText())
return FALSE;
wxString value(view->GetValueText()->GetValue());
- if (value != "True" && value != "False")
+ if (value != _T("True") && value != _T("False"))
{
- wxMessageBox("Value must be True or False!", "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
+ wxMessageBox(_T("Value must be True or False!"), _T("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
return FALSE;
}
return TRUE;
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxBoolListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxBoolListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
- if (strlen(view->GetValueText()->GetValue()) == 0)
+ if (wxStrlen(view->GetValueText()->GetValue()) == 0)
return FALSE;
-
+
wxString value(view->GetValueText()->GetValue());
bool boolValue = FALSE;
- if (value == "True")
+ if (value == _T("True"))
boolValue = TRUE;
else
boolValue = FALSE;
return TRUE;
}
-bool wxBoolListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxBoolListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
return TRUE;
}
-bool wxBoolListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxBoolListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetConfirmButton())
view->GetConfirmButton()->Enable(FALSE);
return TRUE;
}
-bool wxBoolListValidator::OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxBoolListValidator::OnPrepareDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetValueList())
{
view->ShowListBoxControl(TRUE);
view->GetValueList()->Enable(TRUE);
-
- view->GetValueList()->Append("True");
- view->GetValueList()->Append("False");
- char *currentString = copystring(view->GetValueText()->GetValue());
+
+ view->GetValueList()->Append(_T("True"));
+ view->GetValueList()->Append(_T("False"));
+ wxChar *currentString = copystring(view->GetValueText()->GetValue());
view->GetValueList()->SetStringSelection(currentString);
delete[] currentString;
}
return TRUE;
}
-bool wxBoolListValidator::OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxBoolListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetValueList())
{
// Called when the property is double clicked. Extra functionality can be provided,
// cycling through possible values.
-bool wxBoolListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxBoolListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
///
/// String validator
-///
+///
IMPLEMENT_DYNAMIC_CLASS(wxStringListValidator, wxPropertyListValidator)
wxStringListValidator::wxStringListValidator(wxStringList *list, long flags):
m_validatorFlags |= wxPROP_ALLOW_TEXT_EDITING;
}
-bool wxStringListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxStringListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow)
{
if (!m_strings)
return TRUE;
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxStringListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxStringListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
return TRUE;
}
-bool wxStringListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxStringListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
// Unconstrained
if (!m_strings)
view->GetValueText()->Enable(TRUE);
return TRUE;
}
-
+
// Constrained
if (view->GetValueText())
view->GetValueText()->Enable(FALSE);
return TRUE;
}
-bool wxStringListValidator::OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxStringListValidator::OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetValueList())
{
wxNode *node = m_strings->First();
while (node)
{
- char *s = (char *)node->Data();
+ wxChar *s = (wxChar *)node->Data();
view->GetValueList()->Append(s);
node = node->Next();
}
- char *currentString = property->GetValue().StringValue();
+ wxChar *currentString = property->GetValue().StringValue();
view->GetValueList()->SetStringSelection(currentString);
}
return TRUE;
}
-bool wxStringListValidator::OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxStringListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!m_strings)
{
// Called when the property is double clicked. Extra functionality can be provided,
// cycling through possible values.
-bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
return FALSE;
wxNode *node = m_strings->First();
- char *currentString = property->GetValue().StringValue();
+ wxChar *currentString = property->GetValue().StringValue();
while (node)
{
- char *s = (char *)node->Data();
- if (strcmp(s, currentString) == 0)
+ wxChar *s = (wxChar *)node->Data();
+ if (wxStrcmp(s, currentString) == 0)
{
- char *nextString = NULL;
+ wxChar *nextString = NULL;
if (node->Next())
- nextString = (char *)node->Next()->Data();
+ nextString = (wxChar *)node->Next()->Data();
else
- nextString = (char *)m_strings->First()->Data();
+ nextString = (wxChar *)m_strings->First()->Data();
property->GetValue() = wxString(nextString);
view->DisplayProperty(property);
view->UpdatePropertyDisplayInList(property);
///
/// Filename validator
-///
+///
IMPLEMENT_DYNAMIC_CLASS(wxFilenameListValidator, wxPropertyListValidator)
wxFilenameListValidator::wxFilenameListValidator(wxString message , wxString wildcard, long flags):
{
}
-bool wxFilenameListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxFilenameListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow))
{
return TRUE;
}
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxFilenameListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxFilenameListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxFilenameListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxFilenameListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
return TRUE;
}
-bool wxFilenameListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxFilenameListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetConfirmButton())
view->GetConfirmButton()->Enable(TRUE);
if (!view->GetValueText())
return;
- char *s = wxFileSelector(
+ wxString s = wxFileSelector(
m_filenameMessage.GetData(),
wxPathOnly(property->GetValue().StringValue()),
wxFileNameFromPath(property->GetValue().StringValue()),
m_filenameWildCard.GetData(),
0,
parentWindow);
- if (s)
+ if (s != _T(""))
{
- property->GetValue() = wxString(s);
+ property->GetValue() = s;
view->DisplayProperty(property);
view->UpdatePropertyDisplayInList(property);
view->OnPropertyChanged(property);
///
/// Colour validator
-///
+///
IMPLEMENT_DYNAMIC_CLASS(wxColourListValidator, wxPropertyListValidator)
wxColourListValidator::wxColourListValidator(long flags):
{
}
-bool wxColourListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxColourListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow))
{
return TRUE;
}
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxColourListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxColourListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
wxString value(view->GetValueText()->GetValue());
-
+
property->GetValue() = value ;
return TRUE;
}
// Called when TICK is pressed or focus is lost or view wants to update
// the property list.
// Does the transferance from the property editing area to the property itself
-bool wxColourListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxColourListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
return TRUE;
}
-bool wxColourListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxColourListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetConfirmButton())
view->GetConfirmButton()->Enable(TRUE);
{
if (!view->GetValueText())
return;
-
- char *s = property->GetValue().StringValue();
+
+ wxChar *s = property->GetValue().StringValue();
int r = 0;
int g = 0;
int b = 0;
g = wxHexToDec(s+2);
b = wxHexToDec(s+4);
}
-
+
wxColour col(r,g,b);
-
+
wxColourData data;
data.SetChooseFull(TRUE);
data.SetColour(col);
-
+
for (int i = 0; i < 16; i++)
{
wxColour colour(i*16, i*16, i*16);
data.SetCustomColour(i, colour);
}
-
+
wxColourDialog dialog(parentWindow, &data);
if (dialog.ShowModal() != wxID_CANCEL)
{
wxColourData retData = dialog.GetColourData();
col = retData.GetColour();
-
- char buf[7];
+
+ wxChar buf[7];
wxDecToHex(col.Red(), buf);
wxDecToHex(col.Green(), buf+2);
wxDecToHex(col.Blue(), buf+4);
{
}
-bool wxListOfStringsListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxListOfStringsListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow))
{
// No constraints for an arbitrary, user-editable list of strings.
return TRUE;
// the property list.
// Does the transferance from the property editing area to the property itself.
// In this case, the user cannot directly edit the string list.
-bool wxListOfStringsListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxListOfStringsListValidator::OnRetrieveValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow))
{
return TRUE;
}
-bool wxListOfStringsListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxListOfStringsListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (!view->GetValueText())
return FALSE;
return TRUE;
}
-bool wxListOfStringsListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow)
+bool wxListOfStringsListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow))
{
if (view->GetEditButton())
view->GetEditButton()->Enable(TRUE);
{
// Convert property value to a list of strings for editing
wxStringList *stringList = new wxStringList;
-
+
wxPropertyValue *expr = property->GetValue().GetFirst();
while (expr)
{
- char *s = expr->StringValue();
+ wxChar *s = expr->StringValue();
if (s)
stringList->Add(s);
expr = expr->GetNext();
}
-
- wxString title("Editing ");
+
+ wxString title(_T("Editing "));
title += property->GetName();
-
+
if (EditStringList(parentWindow, stringList, title.GetData()))
{
wxPropertyValue& oldValue = property->GetValue();
wxNode *node = stringList->First();
while (node)
{
- char *s = (char *)node->Data();
+ wxChar *s = (wxChar *)node->Data();
oldValue.Append(new wxPropertyValue(s));
-
+
node = node->Next();
}
-
+
view->DisplayProperty(property);
view->UpdatePropertyDisplayInList(property);
view->OnPropertyChanged(property);
{
public:
wxPropertyStringListEditorDialog(wxWindow *parent, const wxString& title,
- const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = "stringEditorDialogBox"):
- wxDialog(parent, -1, title, pos, size, windowStyle, name)
+ const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+ long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = "stringEditorDialogBox"):
+ wxDialog(parent, -1, title, pos, size, windowStyle, name)
{
m_stringList = NULL;
m_stringText = NULL;
m_currentSelection = -1;
}
~wxPropertyStringListEditorDialog(void) {}
- bool OnClose(void);
+ void OnCloseWindow(wxCloseEvent& event);
void SaveCurrentSelection(void);
void ShowCurrentSelection(void);
- void OnOK(wxCommandEvent& event);
- void OnCancel(wxCommandEvent& event);
- void OnAdd(wxCommandEvent& event);
- void OnDelete(wxCommandEvent& event);
- void OnStrings(wxCommandEvent& event);
- void OnText(wxCommandEvent& event);
+ void OnOK(wxCommandEvent& event);
+ void OnCancel(wxCommandEvent& event);
+ void OnAdd(wxCommandEvent& event);
+ void OnDelete(wxCommandEvent& event);
+ void OnStrings(wxCommandEvent& event);
+ void OnText(wxCommandEvent& event);
public:
wxStringList* m_stringList;
DECLARE_EVENT_TABLE()
};
-#define wxID_PROP_SL_ADD 3000
-#define wxID_PROP_SL_DELETE 3001
-#define wxID_PROP_SL_STRINGS 3002
-#define wxID_PROP_SL_TEXT 3003
+#define wxID_PROP_SL_ADD 3000
+#define wxID_PROP_SL_DELETE 3001
+#define wxID_PROP_SL_STRINGS 3002
+#define wxID_PROP_SL_TEXT 3003
BEGIN_EVENT_TABLE(wxPropertyStringListEditorDialog, wxDialog)
- EVT_BUTTON(wxID_OK, wxPropertyStringListEditorDialog::OnOK)
- EVT_BUTTON(wxID_CANCEL, wxPropertyStringListEditorDialog::OnCancel)
- EVT_BUTTON(wxID_PROP_SL_ADD, wxPropertyStringListEditorDialog::OnAdd)
- EVT_BUTTON(wxID_PROP_SL_DELETE, wxPropertyStringListEditorDialog::OnDelete)
- EVT_LISTBOX(wxID_PROP_SL_STRINGS, wxPropertyStringListEditorDialog::OnStrings)
- EVT_TEXT_ENTER(wxID_PROP_SL_TEXT, wxPropertyStringListEditorDialog::OnText)
+ EVT_BUTTON(wxID_OK, wxPropertyStringListEditorDialog::OnOK)
+ EVT_BUTTON(wxID_CANCEL, wxPropertyStringListEditorDialog::OnCancel)
+ EVT_BUTTON(wxID_PROP_SL_ADD, wxPropertyStringListEditorDialog::OnAdd)
+ EVT_BUTTON(wxID_PROP_SL_DELETE, wxPropertyStringListEditorDialog::OnDelete)
+ EVT_LISTBOX(wxID_PROP_SL_STRINGS, wxPropertyStringListEditorDialog::OnStrings)
+ EVT_TEXT_ENTER(wxID_PROP_SL_TEXT, wxPropertyStringListEditorDialog::OnText)
+ EVT_CLOSE(wxPropertyStringListEditorDialog::OnCloseWindow)
END_EVENT_TABLE()
class wxPropertyStringListEditorText: public wxTextCtrl
{
public:
wxPropertyStringListEditorText(wxWindow *parent, wxWindowID id, const wxString& val,
- const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+ const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long windowStyle = 0, const wxString& name = "text"):
wxTextCtrl(parent, id, val, pos, size, windowStyle, wxDefaultValidator, name)
{
bool wxPropertyStringListEditorDialog::sm_dialogCancelled = FALSE;
// Edit the string list.
-bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList *stringList, const char *title)
+bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList *stringList, const wxChar *title)
{
int largeButtonWidth = 60;
int largeButtonHeight = 25;
wxBeginBusyCursor();
wxPropertyStringListEditorDialog *dialog = new wxPropertyStringListEditorDialog(parent,
- title, wxPoint(10, 10), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL);
-
+ title, wxPoint(10, 10), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL);
+
dialog->m_stringList = stringList;
-
+
dialog->m_listBox = new wxListBox(dialog, wxID_PROP_SL_STRINGS,
wxPoint(-1, -1), wxSize(-1, -1), 0, NULL, wxLB_SINGLE);
dialog->Centre(wxBOTH);
wxEndBusyCursor();
if (dialog->ShowModal() == wxID_CANCEL)
- return FALSE;
+ return FALSE;
else
- return TRUE;
+ return TRUE;
}
/*
int sel = m_listBox->GetSelection();
if (sel == -1)
return;
-
+
wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(sel);
if (!node)
return;
-
+
m_listBox->Delete(sel);
- delete[] (char *)node->Data();
+ delete[] (wxChar *)node->Data();
delete node;
m_currentSelection = -1;
m_stringText->SetValue("");
void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event))
{
SaveCurrentSelection();
-
- char *initialText = "";
+
+ wxChar *initialText = _T("");
wxNode *node = m_stringList->Add(initialText);
- m_listBox->Append(initialText, (char *)node);
+ m_listBox->Append(initialText, (void *)node);
m_currentSelection = m_stringList->Number() - 1;
m_listBox->SetSelection(m_currentSelection);
ShowCurrentSelection();
{
SaveCurrentSelection();
EndModal(wxID_OK);
- Close(TRUE);
+ // Close(TRUE);
+ this->Destroy();
}
void wxPropertyStringListEditorDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{
sm_dialogCancelled = TRUE;
EndModal(wxID_CANCEL);
- Close(TRUE);
+// Close(TRUE);
+ this->Destroy();
}
void wxPropertyStringListEditorDialog::OnText(wxCommandEvent& event)
{
- if (event.GetEventType() == wxEVENT_TYPE_TEXT_ENTER_COMMAND)
+ if (event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER)
{
SaveCurrentSelection();
}
}
-bool wxPropertyStringListEditorDialog::OnClose(void)
+void wxPropertyStringListEditorDialog::OnCloseWindow(wxCloseEvent& event)
{
SaveCurrentSelection();
- return TRUE;
+ this->Destroy();
}
void wxPropertyStringListEditorDialog::SaveCurrentSelection(void)
{
if (m_currentSelection == -1)
return;
-
+
wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(m_currentSelection);
if (!node)
return;
-
+
wxString txt(m_stringText->GetValue());
if (node->Data())
delete[] (char *)node->Data();
node->SetData((wxObject *)copystring(txt));
-
+
m_listBox->SetString(m_currentSelection, (char *)node->Data());
}