From 94dc12383de2f73ba3e101ee2f5ee303e5629741 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 17 Apr 2003 09:48:24 +0000 Subject: [PATCH] Removed old files git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20244 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/treelay.h | 154 --- include/wx/prop.h | 346 ------- include/wx/propform.h | 336 ------- include/wx/proplist.h | 595 ----------- src/generic/prop.cpp | 1162 --------------------- src/generic/propform.cpp | 761 -------------- src/generic/proplist.cpp | 1836 ---------------------------------- 7 files changed, 5190 deletions(-) delete mode 100644 include/wx/generic/treelay.h delete mode 100644 include/wx/prop.h delete mode 100644 include/wx/propform.h delete mode 100644 include/wx/proplist.h delete mode 100644 src/generic/prop.cpp delete mode 100644 src/generic/propform.cpp delete mode 100644 src/generic/proplist.cpp diff --git a/include/wx/generic/treelay.h b/include/wx/generic/treelay.h deleted file mode 100644 index 9a1973f37b..0000000000 --- a/include/wx/generic/treelay.h +++ /dev/null @@ -1,154 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: treelay.h -// Purpose: wxTreeLayout class -// Author: Julian Smart -// Modified by: -// Created: 7/4/98 -// RCS-ID: $Id$ -// Copyright: (c) 1998 Julian Smart -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TREELAY_H_ -#define _WX_TREELAY_H_ - -#if defined(__GNUG__) && !defined(__APPLE__) -#pragma interface "wxtree.h" -#endif - -#ifndef WX_PRECOMP -#include "wx/object.h" -class wxList; -class wxDC; -class wxMouseEvent; -#endif - -#include "wx/string.h" - -#if wxUSE_TREELAYOUT - -class WXDLLEXPORT wxTreeLayout: public wxObject -{ -public: - wxTreeLayout(); - virtual ~wxTreeLayout() { } - - // Redefine these - virtual void GetChildren(long id, wxList& list) = 0; - virtual long GetNextNode(long id) = 0; - virtual long GetNodeParent(long id) = 0; - virtual long GetNodeX(long id) = 0; - virtual long GetNodeY(long id) = 0; - virtual void SetNodeX(long id, long x) = 0; - virtual void SetNodeY(long id, long y) = 0; - virtual void ActivateNode(long id, bool active) = 0; - virtual bool NodeActive(long id) = 0; - - // Optional redefinition - void Initialize(void); - inline virtual void SetNodeName(long WXUNUSED(id), const wxString& WXUNUSED(name)) {} - inline virtual wxString GetNodeName(long WXUNUSED(id)) { return wxString(wxT("")); } - virtual void GetNodeSize(long id, long *x, long *y, wxDC& dc); - virtual void Draw(wxDC& dc); - virtual void DrawNodes(wxDC& dc); - virtual void DrawBranches(wxDC& dc); - virtual void DrawNode(long id, wxDC& dc); - virtual void DrawBranch(long from, long to, wxDC& dc); - - // Don't redefine - virtual void DoLayout(wxDC& dc, long topNode = -1); - - // Accessors -- don't redefine - inline void SetTopNode(long id) { m_parentNode = id; } - inline long GetTopNode(void) const { return m_parentNode; } - inline void SetSpacing(long x, long y) { m_xSpacing = x; m_ySpacing = y; } - inline long GetXSpacing(void) const { return m_xSpacing; } - inline long GetYSpacing(void) const { return m_ySpacing; } - inline void SetMargins(long x, long y) { m_leftMargin = x; m_topMargin = y; } - inline long GetTopMargin(void) const { return m_topMargin; } - inline long GetLeftMargin(void) const { return m_leftMargin; } - - inline bool GetOrientation(void) const { return m_orientation; } - inline void SetOrientation(bool orient) { m_orientation = orient; } - -private: - void CalcLayout(long node_id, int level, wxDC& dc); - -protected: - long m_parentNode; - long m_lastY; - long m_lastX; - long m_xSpacing; - long m_ySpacing; - long m_topMargin; - long m_leftMargin; - bool m_orientation; // TRUE for top-to-bottom, FALSE for left-to-right - -private: - DECLARE_ABSTRACT_CLASS(wxTreeLayout) -}; - -class WXDLLEXPORT wxStoredNode -{ -public: - wxString m_name; - long m_x, m_y; - long m_parentId; - bool m_active; - long m_clientData; -}; - -/* - * A version of wxTreeLayout with storage for nodes - */ - -class WXDLLEXPORT wxTreeLayoutStored: public wxTreeLayout -{ -public: - wxTreeLayoutStored(int noNodes = 200); - virtual ~wxTreeLayoutStored(void); - void Initialize(int n); - - wxString HitTest(wxMouseEvent& event, wxDC& dc); - wxStoredNode* GetNode(long id) const; - inline int GetNumNodes() const { return m_maxNodes; }; - inline int GetNodeCount() const { return m_num; }; - - virtual void GetChildren(long id, wxList& list); - virtual long GetNextNode(long id); - virtual long GetNodeParent(long id); - virtual long GetNodeX(long id); - virtual long GetNodeY(long id); - virtual void SetNodeX(long id, long x); - virtual void SetNodeY(long id, long y); - virtual void SetNodeName(long id, const wxString& name); - virtual wxString GetNodeName(long id); - virtual void ActivateNode(long id, bool active); - virtual bool NodeActive(long id); - virtual void SetClientData(long id, long clientData); - virtual long GetClientData(long id) const; - - virtual long AddChild(const wxString& name, const wxString& parent = wxT("")); - virtual long AddChild(const wxString& name, long parent); - virtual long NameToId(const wxString& name); - - // Data members -private: - wxStoredNode* m_nodes; - int m_num; - int m_maxNodes; - -private: - DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored) - DECLARE_NO_COPY_CLASS(wxTreeLayoutStored) -}; - -// For backward compatibility -#define wxStoredTree wxTreeLayoutStored - -#endif - // wxUSE_TREELAYOUT - -#endif - // _WX_TREELAY_H_ - diff --git a/include/wx/prop.h b/include/wx/prop.h deleted file mode 100644 index efc9573399..0000000000 --- a/include/wx/prop.h +++ /dev/null @@ -1,346 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: prop.h -// Purpose: Property sheet classes -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PROP_H_ -#define _WX_PROP_H_ - -#if defined(__GNUG__) && !defined(__APPLE__) -#pragma interface "prop.h" -#endif - -#if wxUSE_PROPSHEET - -#include "wx/defs.h" -#include "wx/string.h" -#include "wx/hash.h" -#include "wx/dialog.h" -#include "wx/frame.h" -#include "wx/button.h" -#include "wx/listbox.h" -#include "wx/textctrl.h" -#include "wx/gdicmn.h" -#include "wx/layout.h" -#include "wx/sizer.h" - -class wxWindow; -class wxProperty; -class wxPropertyValue; -class wxPropertySheet; -class wxPropertyView; -class wxPropertyValidator; -class wxPropertyValidatorRegistry; - -#define wxPROPERTY_VERSION 2.0 - -// A storable sheet of values -class WXDLLEXPORT wxPropertySheet: public wxObject -{ -public: - wxPropertySheet(const wxString& name = wxT("")); - ~wxPropertySheet(); - - // Set the name of the sheet - inline virtual void SetName(const wxString& name) { m_name=name; } - inline virtual wxString GetName() const { return m_name; } - - // Does this sheet contain a property with this name - virtual bool HasProperty(const wxString& name) const; - - // Set property name to value - virtual bool SetProperty(const wxString& name, const wxPropertyValue& value); - - // Remove property from sheet by name, deleting it - virtual void RemoveProperty(const wxString& name); - - // Get the name of the sheet - // Add a property - virtual void AddProperty(wxProperty *property); - - // Get property by name - virtual wxProperty *GetProperty(const wxString& name) const; - - // Clear all properties - virtual void Clear(); - - virtual void UpdateAllViews(wxPropertyView *thisView = NULL); - inline virtual wxList& GetProperties() const { return (wxList&) m_properties; } - - // Sets/clears the modified flag for each property value - virtual void SetAllModified(bool flag = TRUE); - -protected: - wxObject* m_viewedObject; - wxList m_properties; - wxPropertyView* m_propertyView; - wxString m_name; - -private: - DECLARE_DYNAMIC_CLASS(wxPropertySheet) -}; - - -// Base class for property sheet views. There are currently two directly derived -// classes: wxPropertyListView, and wxPropertyFormView. -class WXDLLEXPORT wxPropertyView: public wxEvtHandler -{ -public: - wxPropertyView(long flags = 0); - ~wxPropertyView(); - - // Associates and shows the view - virtual void ShowView(wxPropertySheet *WXUNUSED(propertySheet), wxWindow *WXUNUSED(panel)) {} - - // Update this view of the viewed object, called e.g. by - // the object itself. - virtual bool OnUpdateView() {return FALSE;}; - - // Override this to do something as soon as the property changed, - // if the view and validators support it. - virtual void OnPropertyChanged(wxProperty *WXUNUSED(property)) {} - - virtual void AddRegistry(wxPropertyValidatorRegistry *registry); - inline virtual wxList& GetRegistryList() const - { return (wxList&) m_validatorRegistryList; } - - virtual wxPropertyValidator *FindPropertyValidator(wxProperty *property); - inline virtual void SetPropertySheet(wxPropertySheet *sheet) { m_propertySheet = sheet; } - inline virtual wxPropertySheet *GetPropertySheet() const { return m_propertySheet; } - - inline virtual bool OnClose() { return FALSE; } - inline long GetFlags(void) { return m_buttonFlags; } - -protected: - long m_buttonFlags; - wxPropertySheet* m_propertySheet; - wxProperty* m_currentProperty; - wxList m_validatorRegistryList; - wxPropertyValidator* m_currentValidator; - -private: - DECLARE_DYNAMIC_CLASS(wxPropertyView) -}; - - -class WXDLLEXPORT wxPropertyValidator: public wxEvtHandler -{ -public: - wxPropertyValidator(long flags = 0); - ~wxPropertyValidator(); - - inline long GetFlags() const { return m_validatorFlags; } - inline void SetValidatorProperty(wxProperty *prop) { m_validatorProperty = prop; } - inline wxProperty *GetValidatorProperty(void) const { return m_validatorProperty; } - - virtual bool StringToFloat (wxChar *s, float *number); - virtual bool StringToDouble (wxChar *s, double *number); - virtual bool StringToInt (wxChar *s, int *number); - virtual bool StringToLong (wxChar *s, long *number); - virtual wxChar *FloatToString (float number); - virtual wxChar *DoubleToString (double number); - virtual wxChar *IntToString (int number); - virtual wxChar *LongToString (long number); - -protected: - long m_validatorFlags; - wxProperty* m_validatorProperty; - -private: - DECLARE_DYNAMIC_CLASS(wxPropertyValidator) -}; - - -// extern wxPropertyValidator *wxDefaultPropertyValidator; - -class WXDLLEXPORT wxPropertyValidatorRegistry: public wxHashTable -{ -public: - wxPropertyValidatorRegistry(); - ~wxPropertyValidatorRegistry(); - - virtual void RegisterValidator(const wxString& roleName, wxPropertyValidator *validator); - virtual wxPropertyValidator *GetValidator(const wxString& roleName); - void ClearRegistry(); - -private: - DECLARE_DYNAMIC_CLASS(wxPropertyValidatorRegistry) -}; - -/* - * Property value class - */ - -typedef enum { - wxPropertyValueNull, - wxPropertyValueInteger, - wxPropertyValueReal, - wxPropertyValuebool, - wxPropertyValueString, - wxPropertyValueList, - wxPropertyValueIntegerPtr, - wxPropertyValueRealPtr, - wxPropertyValueboolPtr, - wxPropertyValueStringPtr -} wxPropertyValueType; - -class WXDLLEXPORT wxPropertyValue: public wxObject -{ - DECLARE_DYNAMIC_CLASS(wxPropertyValue) - - wxPropertyValue(void); // Unknown type - wxPropertyValue(const wxPropertyValue& copyFrom); // Copy constructor - wxPropertyValue(const wxChar *val); - wxPropertyValue(const wxString& val); - wxPropertyValue(long val); - wxPropertyValue(bool val); - wxPropertyValue(float val); - wxPropertyValue(double the_real); - wxPropertyValue(wxList *val); - wxPropertyValue(wxStringList *val); - // Pointer versions - wxPropertyValue(wxChar **val); - wxPropertyValue(long *val); - wxPropertyValue(bool *val); - wxPropertyValue(float *val); - - ~wxPropertyValue(void); - - virtual inline wxPropertyValueType Type(void) const { return m_type; } - virtual inline void SetType(wxPropertyValueType typ) { m_type = typ; } - virtual long IntegerValue(void) const; - virtual float RealValue(void) const; - virtual bool BoolValue(void) const; - virtual wxChar *StringValue(void) const; - virtual long *IntegerValuePtr(void) const; - virtual float *RealValuePtr(void) const; - virtual bool *BoolValuePtr(void) const; - virtual wxChar **StringValuePtr(void) const; - - // Get nth arg of clause (starting from 1) - virtual wxPropertyValue *Arg(wxPropertyValueType type, int arg) const; - - // Return nth argument of a list expression (starting from zero) - virtual wxPropertyValue *Nth(int arg) const; - // Returns the number of elements in a list expression - virtual int Number(void) const; - - virtual wxPropertyValue *NewCopy(void) const; - virtual void Copy(wxPropertyValue& copyFrom); - - virtual void WritePropertyClause(wxString &stream); // Write this expression as a top-level clause - virtual void WritePropertyType(wxString &stream); // Write as any other subexpression - - // Append an expression to a list - virtual void Append(wxPropertyValue *expr); - // Insert at beginning of list - virtual void Insert(wxPropertyValue *expr); - - // Get first expr in list - virtual inline wxPropertyValue *GetFirst(void) const - { return ((m_type == wxPropertyValueList) ? m_value.first : (wxPropertyValue*)NULL); } - - // Get next expr if this is a node in a list - virtual inline wxPropertyValue *GetNext(void) const - { return m_next; } - - // Get last expr in list - virtual inline wxPropertyValue *GetLast(void) const - { return ((m_type == wxPropertyValueList) ? m_last : (wxPropertyValue*)NULL); } - - // Delete this node from the list - virtual void Delete(wxPropertyValue *node); - - // Clear list - virtual void ClearList(void); - - virtual inline void SetClientData(wxObject *data) { m_clientData = data; } - virtual inline wxObject *GetClientData(void) { return m_clientData; } - - virtual wxString GetStringRepresentation(void); - - inline void SetModified(bool flag = TRUE) { m_modifiedFlag = flag; } - inline bool GetModified(void) { return m_modifiedFlag; } - - // Operators - void operator=(const wxPropertyValue& val); -// void operator=(const char *val); - void operator=(const wxString& val); - void operator=(const long val); - void operator=(const bool val); - void operator=(const float val); - void operator=(const wxChar **val); - void operator=(const long *val); - void operator=(const bool *val); - void operator=(const float *val); - - public: - wxObject* m_clientData; - wxPropertyValueType m_type; - bool m_modifiedFlag; - - union { - long integer; // Also doubles as bool - wxChar *string; - float real; - long *integerPtr; - bool *boolPtr; - wxChar **stringPtr; - float *realPtr; - wxPropertyValue *first; // If is a list expr, points to the first node - } m_value; - - wxPropertyValue* m_next; // If this is a node in a list, points to the next node - wxPropertyValue* m_last; // If is a list expr, points to the last node - -}; - -/* - * Property class: contains a name and a value. - */ - -class WXDLLEXPORT wxProperty: public wxObject -{ - DECLARE_DYNAMIC_CLASS(wxProperty) - protected: - bool m_enabled; - public: - wxPropertyValue m_value; - wxString m_name; - wxString m_propertyRole; - wxPropertyValidator* m_propertyValidator; - wxWindow* m_propertyWindow; // Usually a panel item, if anything - - wxProperty(void); - wxProperty(wxProperty& copyFrom); - wxProperty(wxString name, wxString role, wxPropertyValidator *ed = NULL); - wxProperty(wxString name, const wxPropertyValue& val, wxString role, wxPropertyValidator *ed = NULL); - ~wxProperty(void); - - virtual wxPropertyValue& GetValue(void) const; - virtual wxPropertyValidator *GetValidator(void) const; - virtual wxString& GetName(void) const; - virtual wxString& GetRole(void) const; - virtual void SetValue(const wxPropertyValue& val); - virtual void SetValidator(wxPropertyValidator *v); - virtual void SetName(wxString& nm); - virtual void SetRole(wxString& role); - void operator=(const wxPropertyValue& val); - virtual inline void SetWindow(wxWindow *win) { m_propertyWindow = win; } - virtual inline wxWindow *GetWindow(void) const { return m_propertyWindow; } - - inline void Enable(bool en) { m_enabled = en; } - inline bool IsEnabled(void) const { return m_enabled; } -}; - -#endif - // wxUSE_PROPSHEET - -#endif - // _WX_PROP_H_ diff --git a/include/wx/propform.h b/include/wx/propform.h deleted file mode 100644 index 255b85204b..0000000000 --- a/include/wx/propform.h +++ /dev/null @@ -1,336 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: propform.h -// Purpose: Property form classes -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PROPFORM_H_ -#define _WX_PROPFORM_H_ - -#if defined(__GNUG__) && !defined(__APPLE__) -#pragma interface "propform.h" -#endif - -#if wxUSE_PROPSHEET - -#include "wx/prop.h" -#include "wx/panel.h" - -class WXDLLEXPORT wxPropertyFormView; - -//// -//// Property form classes: for using an existing dialog or panel -//// - -#define wxID_PROP_REVERT 3100 -#define wxID_PROP_UPDATE 3101 - -// Mediates between a physical panel and the property sheet -class WXDLLEXPORT wxPropertyFormView: public wxPropertyView -{ - DECLARE_DYNAMIC_CLASS(wxPropertyFormView) - public: - wxPropertyFormView(wxWindow *propPanel = NULL, long flags = 0); - ~wxPropertyFormView(void); - - // Associates and shows the view - virtual void ShowView(wxPropertySheet *propertySheet, wxWindow *panel); - - // Update this view of the viewed object, called e.g. by - // the object itself. - virtual bool OnUpdateView(void); - - // Transfer values from property sheet to dialog - virtual bool TransferToDialog(void); - - // Transfer values from dialog to property sheet - virtual bool TransferToPropertySheet(void); - - // Check that all the values are valid - virtual bool Check(void); - - // Give each property in the sheet a panel item, by matching - // the name of the property to the name of the panel item. - // The user doesn't always want to call this; sometimes, it - // will have been done explicitly (e.g., no matching names). - virtual bool AssociateNames(void); - - void OnOk(wxCommandEvent& event); - void OnCancel(wxCommandEvent& event); - void OnHelp(wxCommandEvent& event); - void OnUpdate(wxCommandEvent& event); - void OnRevert(wxCommandEvent& event); - - virtual bool OnClose(); - virtual void OnDoubleClick(wxControl *item); - - // TODO: does OnCommand still get called...??? No, - // make ProcessEvent do it. - virtual void OnCommand(wxWindow& win, wxCommandEvent& event); - - // Extend event processing to process OnCommand - virtual bool ProcessEvent(wxEvent& event); - - inline virtual void AssociatePanel(wxWindow *win) { m_propertyWindow = win; } - inline virtual wxWindow *GetPanel(void) const { return m_propertyWindow; } - - inline virtual void SetManagedWindow(wxWindow *win) { m_managedWindow = win; } - inline virtual wxWindow *GetManagedWindow(void) const { return m_managedWindow; } - - inline virtual wxButton *GetWindowCloseButton() const { return m_windowCloseButton; } - inline virtual wxButton *GetWindowCancelButton() const { return m_windowCancelButton; } - inline virtual wxButton *GetHelpButton() const { return m_windowHelpButton; } - -public: - static bool sm_dialogCancelled; - - protected: - bool m_detailedEditing; // E.g. using listbox for choices - - wxWindow* m_propertyWindow; // Panel that the controls will appear on - wxWindow* m_managedWindow; // Frame or dialog - - wxButton* m_windowCloseButton; // Or OK - wxButton* m_windowCancelButton; - wxButton* m_windowHelpButton; - -DECLARE_EVENT_TABLE() - -}; - -/* - * The type of validator used for forms (wxForm style but using an existing panel - * or dialog box). - * Classes derived from this know how to map from whatever widget they - * find themselves paired with, to the wxProperty and vice versa. - * Should the widget pointer be stored with the validator, or - * the wxProperty? If with the property, we don't have to supply - * a validator for every property. Otherwise, there ALWAYS needs - * to be a validator. On the other hand, not storing a wxWindow pointer - * in the wxProperty is more elegant. Perhaps. - * I think on balance, should put wxWindow pointer into wxProperty. - * After all, wxProperty will often be used to represent the data - * assocated with a window. It's that kinda thing. - */ - -class WXDLLEXPORT wxPropertyFormValidator: public wxPropertyValidator -{ - DECLARE_DYNAMIC_CLASS(wxPropertyFormValidator) - protected: - public: - wxPropertyFormValidator(long flags = 0): wxPropertyValidator(flags) { } - ~wxPropertyFormValidator(void) {} - - // Called to check value is OK (e.g. when OK is pressed) - // Return FALSE if value didn't check out; signal to restore old value. - virtual bool OnCheckValue( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view), - wxWindow *WXUNUSED(parentWindow) ) { return TRUE; } - - // Does the transferance from the property editing area to the property itself. - // Called by the view, e.g. when closing the window. - virtual bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow) = 0; - - // Called by the view to transfer the property to the window. - virtual bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow) = 0; - - virtual void OnDoubleClick( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view), - wxWindow *WXUNUSED(parentWindow) ) { } - virtual void OnSetFocus( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view), - wxWindow *WXUNUSED(parentWindow) ) { } - virtual void OnKillFocus( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view), - wxWindow *WXUNUSED(parentWindow) ) { } - virtual void OnCommand( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view), - wxWindow *WXUNUSED(parentWindow), wxCommandEvent& WXUNUSED(event) ) {} -private: -// Virtual function hiding suppression -#if WXWIN_COMPATIBILITY_2 - virtual void OnCommand(wxWindow& win, - wxCommandEvent& event) - { wxEvtHandler::OnCommand(win, event); } -#endif -}; - -/* - * Some default validators - */ - -class WXDLLEXPORT wxRealFormValidator: public wxPropertyFormValidator -{ - DECLARE_DYNAMIC_CLASS(wxRealFormValidator) - public: - // 0.0, 0.0 means no range - wxRealFormValidator(float min = 0.0, float max = 0.0, long flags = 0):wxPropertyFormValidator(flags) - { - m_realMin = min; m_realMax = max; - } - ~wxRealFormValidator(void) {} - - bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - // Called by the view to transfer the property to the window. - bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - - protected: - float m_realMin; - float m_realMax; -}; - -class WXDLLEXPORT wxIntegerFormValidator: public wxPropertyFormValidator -{ - DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator) - public: - // 0, 0 means no range - wxIntegerFormValidator(long min = 0, long max = 0, long flags = 0):wxPropertyFormValidator(flags) - { - m_integerMin = min; m_integerMax = max; - } - ~wxIntegerFormValidator(void) {} - - bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - - protected: - long m_integerMin; - long m_integerMax; -}; - -class WXDLLEXPORT wxBoolFormValidator: public wxPropertyFormValidator -{ - DECLARE_DYNAMIC_CLASS(wxBoolFormValidator) - protected: - public: - wxBoolFormValidator(long flags = 0):wxPropertyFormValidator(flags) - { - } - ~wxBoolFormValidator(void) {} - - bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); -}; - -class WXDLLEXPORT wxStringFormValidator: public wxPropertyFormValidator -{ - DECLARE_DYNAMIC_CLASS(wxStringFormValidator) - public: - wxStringFormValidator(wxStringList *list = NULL, long flags = 0); - - ~wxStringFormValidator(void) - { - if (m_strings) - delete m_strings; - } - - bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow); - - protected: - wxStringList* m_strings; -}; - -/* - * A default dialog box class to use. - */ - -class WXDLLEXPORT wxPropertyFormDialog: public wxDialog -{ -public: - wxPropertyFormDialog(wxPropertyFormView *v = NULL, - wxWindow *parent = NULL, - const wxString& title = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString& name = _T("dialogBox")); - - void OnCloseWindow(wxCloseEvent& event); - void OnDefaultAction(wxControl *item); - void OnCommand(wxWindow& win, wxCommandEvent& event); - - // Extend event processing to search the view's event table - virtual bool ProcessEvent(wxEvent& event); - -private: - wxPropertyFormView* m_view; - - DECLARE_EVENT_TABLE() - DECLARE_CLASS(wxPropertyFormDialog) -}; - -/* - * A default panel class to use. - */ - -class WXDLLEXPORT wxPropertyFormPanel: public wxPanel -{ -public: - wxPropertyFormPanel(wxPropertyFormView *v = NULL, - wxWindow *parent = NULL, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = _T("panel")) - : wxPanel(parent, -1, pos, size, style, name) - { - m_view = v; - } - void OnDefaultAction(wxControl *item); - void OnCommand(wxWindow& win, wxCommandEvent& event); - - // Extend event processing to search the view's event table - virtual bool ProcessEvent(wxEvent& event); - void SetView(wxPropertyFormView* view) { m_view = view; } - wxPropertyFormView* GetView() const { return m_view; } - -private: - wxPropertyFormView* m_view; - - DECLARE_CLASS(wxPropertyFormPanel) -}; - -/* - * A default frame class to use. - */ - -class WXDLLEXPORT wxPropertyFormFrame: public wxFrame -{ -public: - wxPropertyFormFrame(wxPropertyFormView *v = NULL, - wxFrame *parent = NULL, - const wxString& title = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = _T("frame")) - : wxFrame(parent, -1, title, pos, size, style, name) - { - m_view = v; - m_propertyPanel = NULL; - } - void OnCloseWindow(wxCloseEvent& event); - - // Must call this to create panel and associate view - virtual bool Initialize(void); - virtual wxPanel *OnCreatePanel(wxFrame *parent, wxPropertyFormView *v); - inline virtual wxPanel *GetPropertyPanel(void) const { return m_propertyPanel; } - -private: - wxPropertyFormView* m_view; - wxPanel* m_propertyPanel; - - DECLARE_EVENT_TABLE() - DECLARE_CLASS(wxPropertyFormFrame) -}; - -#endif - // wxUSE_PROPSHEET - -#endif - // _WX_PROPFORM_H_ diff --git a/include/wx/proplist.h b/include/wx/proplist.h deleted file mode 100644 index 72e0fad5fd..0000000000 --- a/include/wx/proplist.h +++ /dev/null @@ -1,595 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: proplist.h -// Purpose: Property list classes -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - /* - - TO DO: - - (1) Optional popup-help for each item, and an optional Help button - for dialog. - - (2) Align Ok, Cancel, Help buttons properly. - - (3) Consider retrieving the rectangle on the panel that can be - drawn into (where the value listbox is) and giving an example - of editing graphically. May be too fancy. - - (4) Deriveable types for wxPropertyValue => may need to reorganise - wxPropertyValue to use inheritance rather than present all-types-in-one - scheme. - - (5) Optional popup panel for value list, perhaps. - - (6) Floating point checking routine still crashes with Floating - point error for zany input. - - (7) Property sheet with choice (or listbox) to select alternative - sheets... multiple views per panel, only one active. For this - we really need a wxChoice that can be dynamically set: XView - may be a problem; Motif? - - (8) More example validators, e.g. colour selector. - */ - -#ifndef _WX_PROPLIST_H_ -#define _WX_PROPLIST_H_ - -#if defined(__GNUG__) && !defined(__APPLE__) -#pragma interface "proplist.h" -#endif - -#if wxUSE_PROPSHEET - -#include "wx/prop.h" -#include "wx/panel.h" - -#define wxPROP_BUTTON_CLOSE 1 -#define wxPROP_BUTTON_OK 2 -#define wxPROP_BUTTON_CANCEL 4 -#define wxPROP_BUTTON_CHECK_CROSS 8 -#define wxPROP_BUTTON_HELP 16 -#define wxPROP_DYNAMIC_VALUE_FIELD 32 -#define wxPROP_PULLDOWN 64 -#define wxPROP_SHOWVALUES 128 - -// Show OK/Cancel buttons on X-based systems where window management is -// more awkward -#if defined(__WXMOTIF__) || defined(__WXGTK__) -#define wxPROP_BUTTON_DEFAULT wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | wxPROP_BUTTON_CHECK_CROSS | wxPROP_PULLDOWN -#else -#define wxPROP_BUTTON_DEFAULT wxPROP_BUTTON_CHECK_CROSS | wxPROP_PULLDOWN | wxPROP_SHOWVALUES -#endif - -#define wxID_PROP_CROSS 3000 -#define wxID_PROP_CHECK 3001 -#define wxID_PROP_EDIT 3002 -#define wxID_PROP_TEXT 3003 -#define wxID_PROP_SELECT 3004 -#define wxID_PROP_VALUE_SELECT 3005 - -// Mediates between a physical panel and the property sheet -class WXDLLEXPORT wxPropertyListView: public wxPropertyView -{ -public: - wxPropertyListView(wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT); - ~wxPropertyListView(void); - - // Associates and shows the view - virtual void ShowView(wxPropertySheet *propertySheet, wxPanel *panel); - - // Update this view of the viewed object, called e.g. by - // the object itself. - virtual bool OnUpdateView(void); - - wxString MakeNameValueString(wxString name, wxString value); - - // Update a single line in the list of properties - virtual bool UpdatePropertyDisplayInList(wxProperty *property); - - // Update the whole list - virtual bool UpdatePropertyList(bool clearEditArea = TRUE); - - // Find the wxListBox index corresponding to this property - virtual int FindListIndexForProperty(wxProperty *property); - - // Select and show string representation in editor the given - // property. NULL resets to show no property. - virtual bool ShowProperty(wxProperty *property, bool select = TRUE); - virtual bool EditProperty(wxProperty *property); - - // Update the display from the property - virtual bool DisplayProperty(wxProperty *property); - // Update the property from the display - virtual bool RetrieveProperty(wxProperty *property); - - // Find appropriate validator and load property into value controls - virtual bool BeginShowingProperty(wxProperty *property); - // Find appropriate validator and unload property from value controls - virtual bool EndShowingProperty(wxProperty *property); - - // Begin detailed editing (e.g. using value listbox) - virtual void BeginDetailedEditing(void); - - // End detailed editing (e.g. using value listbox) - virtual void EndDetailedEditing(void); - - // Called by the property listbox - void OnPropertySelect(wxCommandEvent& event); - - // Called by the value listbox - void OnValueListSelect(wxCommandEvent& event); - - virtual bool CreateControls(void); - virtual void ShowTextControl(bool show); - virtual void ShowListBoxControl(bool show); - virtual void EnableCheck(bool show); - virtual void EnableCross(bool show); - - void OnOk(wxCommandEvent& event); - void OnCancel(wxCommandEvent& event); - void OnHelp(wxCommandEvent& event); - void OnPropertyDoubleClick(wxCommandEvent& event); -// virtual void OnDoubleClick(void); - - void OnCheck(wxCommandEvent& event); - void OnCross(wxCommandEvent& event); - void OnEdit(wxCommandEvent& event); - void OnText(wxCommandEvent& event); - - inline virtual wxListBox *GetPropertyScrollingList() const { return m_propertyScrollingList; } - inline virtual wxListBox *GetValueList() const { return m_valueList; } - inline virtual wxTextCtrl *GetValueText() const { return m_valueText; } - inline virtual wxButton *GetConfirmButton() const { return m_confirmButton; } - inline virtual wxButton *GetCancelButton() const { return m_cancelButton; } - inline virtual wxButton *GetEditButton() const { return m_editButton; } - inline virtual bool GetDetailedEditing(void) const { return m_detailedEditing; } - - inline virtual void AssociatePanel(wxPanel *win) { m_propertyWindow = win; } - inline virtual wxPanel *GetPanel(void) const { return m_propertyWindow; } - - inline virtual void SetManagedWindow(wxWindow *win) { m_managedWindow = win; } - inline virtual wxWindow *GetManagedWindow(void) const { return m_managedWindow; } - - inline virtual wxButton *GetWindowCloseButton() const { return m_windowCloseButton; } - inline virtual wxButton *GetWindowCancelButton() const { return m_windowCancelButton; } - inline virtual wxButton *GetHelpButton() const { return m_windowHelpButton; } - - bool OnClose(void); - -public: - static bool sm_dialogCancelled; - - protected: - wxListBox* m_propertyScrollingList; - wxListBox* m_valueList; // Should really be a combobox, but we don't have one. - wxTextCtrl* m_valueText; - wxButton* m_confirmButton; // A tick, as in VB - wxButton* m_cancelButton; // A cross, as in VB - wxButton* m_editButton; // Invokes the custom validator, if any - wxSizer* m_middleSizer; - - bool m_detailedEditing; // E.g. using listbox for choices - - wxPanel* m_propertyWindow; // Panel that the controls will appear on - wxWindow* m_managedWindow; // Frame or dialog - - wxButton* m_windowCloseButton; // Or OK - wxButton* m_windowCancelButton; - wxButton* m_windowHelpButton; - -private: - DECLARE_DYNAMIC_CLASS(wxPropertyListView) - DECLARE_EVENT_TABLE() - - virtual void ShowView(wxPropertySheet *propertySheet, wxWindow *window) - { wxPropertyView::ShowView(propertySheet, window); }; -}; - -class WXDLLEXPORT wxPropertyTextEdit: public wxTextCtrl -{ -public: - wxPropertyTextEdit(wxPropertyListView *v = NULL, - wxWindow *parent = NULL, - const wxWindowID id = -1, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxT("text")); - - void OnSetFocus(); - void OnKillFocus(); - - wxPropertyListView* m_view; - -private: - DECLARE_CLASS(wxPropertyTextEdit) -}; - -#define wxPROP_ALLOW_TEXT_EDITING 1 - -/* - * The type of validator used for property lists (Visual Basic style) - */ - -class WXDLLEXPORT wxPropertyListValidator: public wxPropertyValidator -{ -public: - wxPropertyListValidator(long flags = wxPROP_ALLOW_TEXT_EDITING): wxPropertyValidator(flags) { } - ~wxPropertyListValidator() {} - - // Called when the property is selected or deselected: typically displays the value - // in the edit control (having chosen a suitable control to display: (non)editable text or listbox) - virtual bool OnSelect(bool select, wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the property is double clicked. Extra functionality can be provided, such as - // cycling through possible values. - inline virtual bool OnDoubleClick( - wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) ) - { return TRUE; } - - // Called when the value listbox is selected. Default behaviour is to copy - // string to text control, and retrieve the value into the property. - virtual bool OnValueListSelect(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the property value is edited using standard text control - inline virtual bool OnPrepareControls( - wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) ) - { return TRUE; } - - virtual bool OnClearControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the property is edited in detail - inline virtual bool OnPrepareDetailControls( - wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) ) - { return TRUE; } - - // Called if focus lost, IF we're in a modeless property editing situation. - inline virtual bool OnClearDetailControls( - wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) ) - { return TRUE; } - - // Called when the edit (...) button is pressed. The default implementation - // calls view->BeginDetailedEditing; the filename validator (for example) overrides - // this function to show the file selector. - virtual void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost. - // Return FALSE if value didn't check out; signal to restore old value. - inline virtual bool 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 - virtual bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - virtual bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - -private: - DECLARE_DYNAMIC_CLASS(wxPropertyListValidator) -}; - -/* - * A default dialog box class to use. - */ - -class WXDLLEXPORT wxPropertyListDialog: public wxDialog -{ -public: - wxPropertyListDialog(wxPropertyListView *v = NULL, - wxWindow *parent = NULL, - const wxString& title = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString& name = wxT("dialogBox")); - - void OnCloseWindow(wxCloseEvent& event); - void OnDefaultAction(wxControl *item); - void OnCancel(wxCommandEvent& event); - - // Extend event processing to search the view's event table - virtual bool ProcessEvent(wxEvent& event); - -private: - wxPropertyListView* m_view; - -private: - DECLARE_CLASS(wxPropertyListDialog) - DECLARE_EVENT_TABLE() -}; - -/* - * A default panel class to use. - */ - -class WXDLLEXPORT wxPropertyListPanel: public wxPanel -{ -public: - wxPropertyListPanel(wxPropertyListView *v = NULL, - wxWindow *parent = NULL, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxT("panel")) - : wxPanel(parent, -1, pos, size, style, name) - { - m_view = v; - } - ~wxPropertyListPanel(); - void OnDefaultAction(wxControl *item); - - inline void SetView(wxPropertyListView* v) { m_view = v; } - inline wxPropertyListView* GetView() const { return m_view; } - - // Extend event processing to search the view's event table - virtual bool ProcessEvent(wxEvent& event); - - // Call Layout() - void OnSize(wxSizeEvent& event); - -private: - wxPropertyListView* m_view; - -private: - DECLARE_EVENT_TABLE() - DECLARE_CLASS(wxPropertyListPanel) -}; - -/* - * A default frame class to use. - */ - -class WXDLLEXPORT wxPropertyListFrame: public wxFrame -{ -public: - wxPropertyListFrame(wxPropertyListView *v = NULL, - wxFrame *parent = NULL, - const wxString& title = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = _T("frame")) - : wxFrame(parent, -1, title, pos, size, style, name) - { - m_view = v; - m_propertyPanel = NULL; - } - void OnCloseWindow(wxCloseEvent& event); - - // Must call this to create panel and associate view - virtual bool Initialize(void); - virtual wxPropertyListPanel *OnCreatePanel(wxFrame *parent, wxPropertyListView *v); - inline virtual wxPropertyListPanel *GetPropertyPanel(void) const { return m_propertyPanel; } - inline wxPropertyListView* GetView() const { return m_view; } - -private: - wxPropertyListView* m_view; - wxPropertyListPanel* m_propertyPanel; - -private: - DECLARE_EVENT_TABLE() - DECLARE_CLASS(wxPropertyListFrame) -}; - -/* - * Some default validators - */ - -class WXDLLEXPORT wxRealListValidator: public wxPropertyListValidator -{ -public: - // 0.0, 0.0 means no range - wxRealListValidator(float min = 0.0, float max = 0.0, long flags = wxPROP_ALLOW_TEXT_EDITING):wxPropertyListValidator(flags) - { m_realMin = min; m_realMax = max; } - ~wxRealListValidator() {} - - bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost. - // Return FALSE if value didn't check out; signal to restore old value. - bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost or view wants to update - // the property list. - // Does the transfer from the property editing area to the property itself - bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - -protected: - float m_realMin; - float m_realMax; - -private: - DECLARE_DYNAMIC_CLASS(wxRealListValidator) -}; - -class WXDLLEXPORT wxIntegerListValidator: public wxPropertyListValidator -{ -public: - // 0, 0 means no range - wxIntegerListValidator(long min = 0, long max = 0, long flags = wxPROP_ALLOW_TEXT_EDITING):wxPropertyListValidator(flags) - { - m_integerMin = min; m_integerMax = max; - } - ~wxIntegerListValidator() {} - - bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost. - // Return FALSE if value didn't check out; signal to restore old value. - bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost or view wants to update - // the property list. - // Does the transfer from the property editing area to the property itself - bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - -protected: - long m_integerMin; - long m_integerMax; - -private: - DECLARE_DYNAMIC_CLASS(wxIntegerListValidator) -}; - -class WXDLLEXPORT wxBoolListValidator: public wxPropertyListValidator -{ -public: - wxBoolListValidator(long flags = 0):wxPropertyListValidator(flags) {} - ~wxBoolListValidator() {} - - bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost. - // Return FALSE if value didn't check out; signal to restore old value. - bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost or view wants to update - // the property list. - // Does the transfer from the property editing area to the property itself - bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the property is double clicked. Extra functionality can be provided, - // cycling through possible values. - virtual bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - -private: - DECLARE_DYNAMIC_CLASS(wxBoolListValidator) -}; - -class WXDLLEXPORT wxStringListValidator: public wxPropertyListValidator -{ -public: - wxStringListValidator(wxStringList *list = NULL, long flags = 0); - - ~wxStringListValidator() - { - if (m_strings) - delete m_strings; - } - - bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost. - // Return FALSE if value didn't check out; signal to restore old value. - bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost or view wants to update - // the property list. - // Does the transfer from the property editing area to the property itself - bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the property is double clicked. Extra functionality can be provided, - // cycling through possible values. - bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - -protected: - wxStringList* m_strings; - -private: - DECLARE_DYNAMIC_CLASS(wxStringListValidator) -}; - -class WXDLLEXPORT wxFilenameListValidator: public wxPropertyListValidator -{ -public: - wxFilenameListValidator(wxString message = wxT("Select a file"), wxString wildcard = wxALL_FILES_PATTERN, long flags = 0); - ~wxFilenameListValidator(); - - // Called when TICK is pressed or focus is lost. - // Return FALSE if value didn't check out; signal to restore old value. - bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // 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 OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the edit (...) button is pressed. - void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - -protected: - wxString m_filenameWildCard; - wxString m_filenameMessage; - -private: - DECLARE_DYNAMIC_CLASS(wxFilenameListValidator) -}; - -class WXDLLEXPORT wxColourListValidator: public wxPropertyListValidator -{ -public: - wxColourListValidator(long flags = 0); - ~wxColourListValidator(); - - bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the edit (...) button is pressed. - void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - -private: - DECLARE_DYNAMIC_CLASS(wxColourListValidator) -}; - -class WXDLLEXPORT wxListOfStringsListValidator: public wxPropertyListValidator -{ -public: - wxListOfStringsListValidator(long flags = 0); - ~wxListOfStringsListValidator() {} - - bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost. - // Return FALSE if value didn't check out; signal to restore old value. - bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when TICK is pressed or focus is lost or view wants to update - // the property list. - // Does the transfer from the property editing area to the property itself - bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - // Called when the property is double clicked. - bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - - bool EditStringList(wxWindow *parent, wxStringList *stringList, const wxChar *title = wxT("String List Editor")); - - // Called when the edit (...) button is pressed. - void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); - -private: - DECLARE_DYNAMIC_CLASS(wxListOfStringsListValidator) -}; - -#endif - // wxUSE_PROPSHEET - -#endif - // _WX_PROPLIST_H_ diff --git a/src/generic/prop.cpp b/src/generic/prop.cpp deleted file mode 100644 index 49889e8afc..0000000000 --- a/src/generic/prop.cpp +++ /dev/null @@ -1,1162 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: prop.cpp -// Purpose: Propert sheet classes implementation -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "prop.h" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if wxUSE_PROPSHEET - -#ifndef WX_PRECOMP -#endif - -#include "wx/debug.h" -#include "wx/prop.h" - -#include -#include -#include -#include - - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue, wxObject) - -wxPropertyValue::wxPropertyValue(void) -{ - m_type = wxPropertyValueNull; - m_next = NULL; - m_last = NULL; - m_value.first = NULL; - m_clientData = NULL; - m_modifiedFlag = FALSE; -} - -wxPropertyValue::wxPropertyValue(const wxPropertyValue& copyFrom) - : wxObject() -{ - m_value.string = (wxChar*) NULL; - m_modifiedFlag = FALSE; - Copy((wxPropertyValue& )copyFrom); -} - -wxPropertyValue::wxPropertyValue(const wxChar *val) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueString; - - m_value.string = copystring(val); - m_clientData = NULL; - m_next = NULL; - m_last = NULL; -} - -wxPropertyValue::wxPropertyValue(const wxString& val) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueString; - - m_value.string = copystring((const wxChar *)val); - m_clientData = NULL; - m_next = NULL; - m_last = NULL; -} - -wxPropertyValue::wxPropertyValue(long the_integer) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueInteger; - m_value.integer = the_integer; - m_clientData = NULL; - m_next = NULL; -} - -wxPropertyValue::wxPropertyValue(bool val) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValuebool; - m_value.integer = val; - m_clientData = NULL; - m_next = NULL; -} - -wxPropertyValue::wxPropertyValue(float the_real) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueReal; - m_value.real = the_real; - m_clientData = NULL; - m_next = NULL; -} - -wxPropertyValue::wxPropertyValue(double the_real) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueReal; - m_value.real = (float)the_real; - m_clientData = NULL; - m_next = NULL; -} - -// Pointer versions: we have a pointer to the real C++ value. -wxPropertyValue::wxPropertyValue(wxChar **val) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueStringPtr; - - m_value.stringPtr = val; - m_clientData = NULL; - m_next = NULL; - m_last = NULL; -} - -wxPropertyValue::wxPropertyValue(long *val) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueIntegerPtr; - m_value.integerPtr = val; - m_clientData = NULL; - m_next = NULL; -} - -wxPropertyValue::wxPropertyValue(bool *val) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueboolPtr; - m_value.boolPtr = val; - m_clientData = NULL; - m_next = NULL; -} - -wxPropertyValue::wxPropertyValue(float *val) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueRealPtr; - m_value.realPtr = val; - m_clientData = NULL; - m_next = NULL; -} - -wxPropertyValue::wxPropertyValue(wxList *the_list) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueList; - m_clientData = NULL; - m_last = NULL; - m_value.first = NULL; - - wxNode *node = the_list->GetFirst(); - while (node) - { - wxPropertyValue *expr = (wxPropertyValue *)node->GetData(); - Append(expr); - node = node->GetNext(); - } - - delete the_list; -} - -wxPropertyValue::wxPropertyValue(wxStringList *the_list) -{ - m_modifiedFlag = FALSE; - m_type = wxPropertyValueList; - m_clientData = NULL; - m_last = NULL; - m_value.first = NULL; - - wxStringList::Node *node = the_list->GetFirst(); - while (node) - { - wxChar *s = node->GetData(); - Append(new wxPropertyValue(s)); - node = node->GetNext(); - } - delete the_list; -} - -wxPropertyValue::~wxPropertyValue(void) -{ - switch (m_type) - { - case wxPropertyValueInteger: - case wxPropertyValuebool: - case wxPropertyValueReal: - { - break; - } - case wxPropertyValueString: - { - delete[] m_value.string; - break; - } - case wxPropertyValueList: - { - wxPropertyValue *expr = m_value.first; - while (expr) - { - wxPropertyValue *expr1 = expr->m_next; - - delete expr; - expr = expr1; - } - break; - } - default: - case wxPropertyValueNull: break; - } -} - -void wxPropertyValue::Append(wxPropertyValue *expr) -{ - m_modifiedFlag = TRUE; - if (!m_value.first) - m_value.first = expr; - - if (m_last) - m_last->m_next = expr; - m_last = expr; -} - -void wxPropertyValue::Insert(wxPropertyValue *expr) -{ - m_modifiedFlag = TRUE; - expr->m_next = m_value.first; - m_value.first = expr; - - if (!m_last) - m_last = expr; -} - -// Delete from list -void wxPropertyValue::Delete(wxPropertyValue *node) -{ - wxPropertyValue *expr = GetFirst(); - - wxPropertyValue *previous = NULL; - while (expr && (expr != node)) - { - previous = expr; - expr = expr->GetNext(); - } - - if (expr) - { - if (previous) - previous->m_next = expr->m_next; - - // If node was the first in the list, - // make the list point to the NEXT one. - if (GetFirst() == expr) - { - m_value.first = expr->m_next; - } - - // If node was the last in the list, - // make the list 'last' pointer point to the PREVIOUS one. - if (GetLast() == expr) - { - if (previous) - m_last = previous; - else - m_last = NULL; - } - m_modifiedFlag = TRUE; - delete expr; - } - -} - -void wxPropertyValue::ClearList(void) -{ - wxPropertyValue *val = GetFirst(); - if (val) - m_modifiedFlag = TRUE; - - while (val) - { - wxPropertyValue *next = val->GetNext(); - delete val; - val = next; - } - m_value.first = NULL; - m_last = NULL; -} - -wxPropertyValue *wxPropertyValue::NewCopy(void) const -{ - switch (m_type) - { - case wxPropertyValueInteger: - return new wxPropertyValue(m_value.integer); - case wxPropertyValuebool: - return new wxPropertyValue((bool) (m_value.integer != 0)); - case wxPropertyValueReal: - return new wxPropertyValue(m_value.real); - case wxPropertyValueString: - return new wxPropertyValue(m_value.string); - case wxPropertyValueList: - { - wxPropertyValue *expr = m_value.first; - wxPropertyValue *new_list = new wxPropertyValue; - new_list->SetType(wxPropertyValueList); - while (expr) - { - wxPropertyValue *expr2 = expr->NewCopy(); - new_list->Append(expr2); - expr = expr->m_next; - } - return new_list; - } - case wxPropertyValueIntegerPtr: - return new wxPropertyValue(m_value.integerPtr); - case wxPropertyValueRealPtr: - return new wxPropertyValue(m_value.realPtr); - case wxPropertyValueboolPtr: - return new wxPropertyValue(m_value.boolPtr); - case wxPropertyValueStringPtr: - return new wxPropertyValue(m_value.stringPtr); - - case wxPropertyValueNull: - wxFAIL_MSG( wxT("Should never get here!\n" ) ); - break; - } - return NULL; -} - -void wxPropertyValue::Copy(wxPropertyValue& copyFrom) -{ - if (m_type == wxPropertyValueString) - { - delete[] m_value.string ; - m_value.string = NULL; - } - m_type = copyFrom.Type(); - - switch (m_type) - { - case wxPropertyValueInteger: - (*this) = copyFrom.IntegerValue(); - return ; - - case wxPropertyValueReal: - (*this) = copyFrom.RealValue(); - return ; - - case wxPropertyValueString: - (*this) = wxString(copyFrom.StringValue()); - return ; - - case wxPropertyValuebool: - (*this) = copyFrom.BoolValue(); - return ; - - // Pointers - case wxPropertyValueboolPtr: - (*this) = copyFrom.BoolValuePtr(); - return ; - case wxPropertyValueRealPtr: - (*this) = copyFrom.RealValuePtr(); - return ; - case wxPropertyValueIntegerPtr: - (*this) = copyFrom.IntegerValuePtr(); - return ; - case wxPropertyValueStringPtr: - { - wxChar** s = copyFrom.StringValuePtr(); - -#if 0 - // what is this? are you trying to assign a bool or a string? VA can't figure it out.. -#if defined(__VISAGECPP__) || defined( __VISUALC__ ) - (*this) = s; -#else - (*this) = s != 0; -#endif -#endif // if 0 - - (*this) = (bool)(s != 0); - - return ; - } - - case wxPropertyValueList: - { - m_value.first = NULL; - m_next = NULL; - m_last = NULL; - wxPropertyValue *expr = copyFrom.m_value.first; - while (expr) - { - wxPropertyValue *expr2 = expr->NewCopy(); - Append(expr2); - expr = expr->m_next; - } - return; - } - case wxPropertyValueNull: - wxFAIL_MSG( wxT("Should never get here!\n" ) ); - break; - } -} - -// Return nth argument of a clause (starting from 1) -wxPropertyValue *wxPropertyValue::Arg(wxPropertyValueType type, int arg) const -{ - wxPropertyValue *expr = m_value.first; - for (int i = 1; i < arg; i++) - if (expr) - expr = expr->m_next; - - if (expr && (expr->m_type == type)) - return expr; - else - return NULL; -} - -// Return nth argument of a list expression (starting from zero) -wxPropertyValue *wxPropertyValue::Nth(int arg) const -{ - if (m_type != wxPropertyValueList) - return NULL; - - wxPropertyValue *expr = m_value.first; - for (int i = 0; i < arg; i++) - if (expr) - expr = expr->m_next; - else return NULL; - - if (expr) - return expr; - else - return NULL; -} - - // Returns the number of elements in a list expression -int wxPropertyValue::Number(void) const -{ - if (m_type != wxPropertyValueList) - return 0; - - int i = 0; - wxPropertyValue *expr = m_value.first; - while (expr) - { - expr = expr->m_next; - i ++; - } - return i; -} - -void wxPropertyValue::WritePropertyClause(wxString& stream) // Write this expression as a top-level clause -{ - if (m_type != wxPropertyValueList) - return; - - wxPropertyValue *node = m_value.first; - if (node) - { - node->WritePropertyType(stream); - stream.Append( wxT("(") ); - node = node->m_next; - bool first = TRUE; - while (node) - { - if (!first) - stream.Append( wxT(" ") ); - node->WritePropertyType(stream); - node = node->m_next; - if (node) - stream.Append( wxT(",\n" ) ); - first = FALSE; - } - stream.Append( wxT(").\n\n") ); - } -} - -void wxPropertyValue::WritePropertyType(wxString& stream) // Write as any other subexpression -{ - wxString tmp; - switch (m_type) - { - case wxPropertyValueInteger: - { - tmp.Printf( wxT("%ld"), m_value.integer ); - stream.Append( tmp ); - break; - } - case wxPropertyValueIntegerPtr: - { - tmp.Printf( wxT("%ld"), *m_value.integerPtr ); - stream.Append( tmp ); - break; - } - case wxPropertyValuebool: - { - if (m_value.integer) - stream.Append( wxT("True") ); - else - stream.Append( wxT("False") ); - break; - } - case wxPropertyValueboolPtr: - { - if (*m_value.integerPtr) - stream.Append( wxT("True") ); - else - stream.Append( wxT("False") ); - break; - } - case wxPropertyValueReal: - { - double d = m_value.real; - tmp.Printf( wxT("%.6g"), d ); - stream.Append( tmp ); - break; - } - case wxPropertyValueRealPtr: - { - double d = *m_value.realPtr; - tmp.Printf( wxT("%.6g"), d ); - stream.Append( tmp ); - break; - } - case wxPropertyValueString: - { - stream.Append( m_value.string ); - break; - } - case wxPropertyValueStringPtr: - { - wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") ); - /* - int i; - int len = strlen(*(m_value.stringPtr)); - for (i = 0; i < len; i++) - { - char ch = *(m_value.stringPtr)[i]; - - } - */ - break; - } - case wxPropertyValueList: - { - if (!m_value.first) - stream.Append( wxT("[]") ); - else - { - wxPropertyValue *expr = m_value.first; - - stream.Append( wxT("[") ); - while (expr) - { - expr->WritePropertyType(stream); - expr = expr->m_next; - if (expr) - stream.Append( wxT(", ") ); - } - stream.Append( wxT("]") ); - } - break; - } - case wxPropertyValueNull: break; - } -} - -wxString wxPropertyValue::GetStringRepresentation(void) -{ - wxString str; - WritePropertyType(str); - return str; -} - -void wxPropertyValue::operator=(const wxPropertyValue& val) -{ - m_modifiedFlag = TRUE; - Copy((wxPropertyValue&)val); -} - -// void wxPropertyValue::operator=(const char *val) -void wxPropertyValue::operator=(const wxString& val1) -{ - const wxChar *val = (const wxChar *)val1; - - m_modifiedFlag = TRUE; - - wxPropertyValueType oldType = m_type; - if (oldType == wxPropertyValueString) - { - delete[] m_value.string ; - m_value.string = NULL; - } - - if (m_type == wxPropertyValueNull) - m_type = wxPropertyValueString; - - if (m_type == wxPropertyValueString) - { - if (val) - m_value.string = copystring(val); - else - m_value.string = NULL; - } - else if (m_type == wxPropertyValueStringPtr) - { - wxFAIL_MSG( wxT("Shouldn't try to assign a wxString reference to a char* pointer.") ); - if (val) - *m_value.stringPtr = copystring(val); - else - *m_value.stringPtr = NULL; - } - - m_clientData = NULL; - m_next = NULL; - m_last = NULL; - -} - -void wxPropertyValue::operator=(const long val) -{ - wxPropertyValueType oldType = m_type; - if (oldType == wxPropertyValueString) - { - delete[] m_value.string ; - m_value.string = NULL; - } - - m_modifiedFlag = TRUE; - if (m_type == wxPropertyValueNull) - m_type = wxPropertyValueInteger; - - if (m_type == wxPropertyValueInteger) - m_value.integer = val; - else if (m_type == wxPropertyValueIntegerPtr) - *m_value.integerPtr = val; - else if (m_type == wxPropertyValueReal) - m_value.real = (float)val; - else if (m_type == wxPropertyValueRealPtr) - *m_value.realPtr = (float)val; - - m_clientData = NULL; - m_next = NULL; -} - -void wxPropertyValue::operator=(const bool val) -{ - wxPropertyValueType oldType = m_type; - if (oldType == wxPropertyValueString) - { - delete[] m_value.string ; - m_value.string = NULL; - } - - m_modifiedFlag = TRUE; - if (m_type == wxPropertyValueNull) - m_type = wxPropertyValuebool; - - if (m_type == wxPropertyValuebool) - m_value.integer = (long)val; - else if (m_type == wxPropertyValueboolPtr) - *m_value.boolPtr = val; - - m_clientData = NULL; - m_next = NULL; -} - -void wxPropertyValue::operator=(const float val) -{ - wxPropertyValueType oldType = m_type; - if (oldType == wxPropertyValueString) - { - delete[] m_value.string ; - m_value.string = NULL; - } - - m_modifiedFlag = TRUE; - if (m_type == wxPropertyValueNull) - m_type = wxPropertyValueReal; - - if (m_type == wxPropertyValueInteger) - m_value.integer = (long)val; - else if (m_type == wxPropertyValueIntegerPtr) - *m_value.integerPtr = (long)val; - else if (m_type == wxPropertyValueReal) - m_value.real = val; - else if (m_type == wxPropertyValueRealPtr) - *m_value.realPtr = val; - - m_clientData = NULL; - m_next = NULL; -} - -void wxPropertyValue::operator=(const wxChar **val) -{ - wxPropertyValueType oldType = m_type; - if (oldType == wxPropertyValueString) - { - delete[] m_value.string ; - m_value.string = NULL; - } - - m_modifiedFlag = TRUE; - m_type = wxPropertyValueStringPtr; - - if (val) - m_value.stringPtr = (wxChar **)val; - else - m_value.stringPtr = NULL; - m_clientData = NULL; - m_next = NULL; - m_last = NULL; - -} - -void wxPropertyValue::operator=(const long *val) -{ - m_modifiedFlag = TRUE; - m_type = wxPropertyValueIntegerPtr; - m_value.integerPtr = (long *)val; - m_clientData = NULL; - m_next = NULL; -} - -void wxPropertyValue::operator=(const bool *val) -{ - m_modifiedFlag = TRUE; - m_type = wxPropertyValueboolPtr; - m_value.boolPtr = (bool *)val; - m_clientData = NULL; - m_next = NULL; -} - -void wxPropertyValue::operator=(const float *val) -{ - m_modifiedFlag = TRUE; - m_type = wxPropertyValueRealPtr; - m_value.realPtr = (float *)val; - m_clientData = NULL; - m_next = NULL; -} - -long wxPropertyValue::IntegerValue(void) const - { - if (m_type == wxPropertyValueInteger) - return m_value.integer; - else if (m_type == wxPropertyValueReal) - return (long)m_value.real; - else if (m_type == wxPropertyValueIntegerPtr) - return *m_value.integerPtr; - else if (m_type == wxPropertyValueRealPtr) - return (long)(*m_value.realPtr); - else return 0; - } - -long *wxPropertyValue::IntegerValuePtr(void) const -{ - return m_value.integerPtr; -} - -float wxPropertyValue::RealValue(void) const { - if (m_type == wxPropertyValueReal) - return m_value.real; - else if (m_type == wxPropertyValueRealPtr) - return *m_value.realPtr; - else if (m_type == wxPropertyValueInteger) - return (float)m_value.integer; - else if (m_type == wxPropertyValueIntegerPtr) - return (float)*(m_value.integerPtr); - else return 0.0; - } - -float *wxPropertyValue::RealValuePtr(void) const -{ - return m_value.realPtr; -} - -bool wxPropertyValue::BoolValue(void) const { - if (m_type == wxPropertyValueReal) - return (m_value.real != 0.0); - if (m_type == wxPropertyValueRealPtr) - return (*(m_value.realPtr) != 0.0); - else if (m_type == wxPropertyValueInteger) - return (m_value.integer != 0); - else if (m_type == wxPropertyValueIntegerPtr) - return (*(m_value.integerPtr) != 0); - else if (m_type == wxPropertyValuebool) - return (m_value.integer != 0); - else if (m_type == wxPropertyValueboolPtr) - return (*(m_value.boolPtr) != 0); - else return FALSE; - } - -bool *wxPropertyValue::BoolValuePtr(void) const -{ - return m_value.boolPtr; -} - -wxChar *wxPropertyValue::StringValue(void) const { - if (m_type == wxPropertyValueString) - return m_value.string; - else if (m_type == wxPropertyValueStringPtr) - return *(m_value.stringPtr); - else return NULL; - } - -wxChar **wxPropertyValue::StringValuePtr(void) const -{ - return m_value.stringPtr; -} - -/* - * A property (name plus value) - */ - -IMPLEMENT_DYNAMIC_CLASS(wxProperty, wxObject) - -wxProperty::wxProperty(void) -{ - m_propertyRole = wxEmptyString; - m_propertyValidator = NULL; - m_propertyWindow = NULL; - m_enabled = TRUE; -} - -wxProperty::wxProperty(wxProperty& copyFrom) - : wxObject() -{ - m_value = copyFrom.GetValue(); - m_name = copyFrom.GetName(); - m_propertyRole = copyFrom.GetRole(); - m_propertyValidator = copyFrom.GetValidator(); - m_enabled = copyFrom.IsEnabled(); - m_propertyWindow = NULL; -} - -wxProperty::wxProperty(wxString nm, wxString role, wxPropertyValidator *ed):m_name(nm), m_propertyRole(role) -{ - m_propertyValidator = ed; - m_propertyWindow = NULL; - m_enabled = TRUE; -} - -wxProperty::wxProperty(wxString nm, const wxPropertyValue& val, wxString role, wxPropertyValidator *ed): - m_value(val), m_name(nm), m_propertyRole(role) -{ - m_propertyValidator = ed; - m_propertyWindow = NULL; - m_enabled = TRUE; -} - -wxProperty::~wxProperty(void) -{ - if (m_propertyValidator) - delete m_propertyValidator; -} - -wxPropertyValue& wxProperty::GetValue(void) const -{ - return (wxPropertyValue&) m_value; -} - -wxPropertyValidator *wxProperty::GetValidator(void) const -{ - return m_propertyValidator; -} - -wxString& wxProperty::GetName(void) const -{ - return (wxString&) m_name; -} - -wxString& wxProperty::GetRole(void) const -{ - return (wxString&) m_propertyRole; -} - -void wxProperty::SetValue(const wxPropertyValue& val) -{ - m_value = val; -} - -void wxProperty::SetValidator(wxPropertyValidator *ed) -{ - m_propertyValidator = ed; -} - -void wxProperty::SetRole(wxString& role) -{ - m_propertyRole = role; -} - -void wxProperty::SetName(wxString& nm) -{ - m_name = nm; -} - -void wxProperty::operator=(const wxPropertyValue& val) -{ - m_value = val; -} - -/* - * Base property view class - */ - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyView, wxEvtHandler) - -wxPropertyView::wxPropertyView(long flags) -{ - m_buttonFlags = flags; - m_propertySheet = NULL; - m_currentValidator = NULL; - m_currentProperty = NULL; -} - -wxPropertyView::~wxPropertyView(void) -{ -} - -void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry *registry) -{ - m_validatorRegistryList.Append(registry); -} - -wxPropertyValidator *wxPropertyView::FindPropertyValidator(wxProperty *property) -{ - if (property->GetValidator()) - return property->GetValidator(); - - wxNode *node = m_validatorRegistryList.GetFirst(); - while (node) - { - wxPropertyValidatorRegistry *registry = (wxPropertyValidatorRegistry *)node->GetData(); - wxPropertyValidator *validator = registry->GetValidator(property->GetRole()); - if (validator) - return validator; - node = node->GetNext(); - } - return NULL; -/* - if (!wxDefaultPropertyValidator) - wxDefaultPropertyValidator = new wxPropertyListValidator; - return wxDefaultPropertyValidator; -*/ -} - -/* - * Property sheet - */ - -IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet, wxObject) - -wxPropertySheet::wxPropertySheet(const wxString& name) -:m_properties(wxKEY_STRING),m_name(name) -{ -} - -wxPropertySheet::~wxPropertySheet(void) -{ - Clear(); -} - -void wxPropertySheet::UpdateAllViews( wxPropertyView *WXUNUSED(thisView) ) -{ -} - -// Add a property -void wxPropertySheet::AddProperty(wxProperty *property) -{ - m_properties.Append((const wxChar*) property->GetName(), property); -} - -// Get property by name -wxProperty *wxPropertySheet::GetProperty(const wxString& name) const -{ - wxNode *node = m_properties.Find((const wxChar*) name); - if (!node) - return NULL; - else - return (wxProperty *)node->GetData(); -} - -bool wxPropertySheet::SetProperty(const wxString& name, const wxPropertyValue& value) -{ - wxProperty* prop = GetProperty(name); - if(prop){ - prop->SetValue(value); - return TRUE; - }else{ - return FALSE; - } -} - -void wxPropertySheet::RemoveProperty(const wxString& name) -{ - wxNode *node = m_properties.Find(name); - if(node) - { - wxProperty *prop = (wxProperty *)node->GetData(); - delete prop; - m_properties.DeleteNode(node); - } -} - -bool wxPropertySheet::HasProperty(const wxString& name) const -{ - return (GetProperty(name)?TRUE:FALSE); -} - -// Clear all properties -void wxPropertySheet::Clear(void) -{ - wxNode *node = m_properties.GetFirst(); - while (node) - { - wxProperty *prop = (wxProperty *)node->GetData(); - wxNode *next = node->GetNext(); - delete prop; - delete node; - node = next; - } -} - -// Sets/clears the modified flag for each property value -void wxPropertySheet::SetAllModified(bool flag) -{ - wxNode *node = m_properties.GetFirst(); - while (node) - { - wxProperty *prop = (wxProperty *)node->GetData(); - prop->GetValue().SetModified(flag); - node = node->GetNext(); - } -} - -/* - * Property validator registry - * - */ - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry, wxHashTable) - -wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING) -{ -} - -wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void) -{ - ClearRegistry(); -} - -void wxPropertyValidatorRegistry::RegisterValidator(const wxString& typeName, wxPropertyValidator *validator) -{ - Put((const wxChar*) typeName, validator); -} - -wxPropertyValidator *wxPropertyValidatorRegistry::GetValidator(const wxString& typeName) -{ - return (wxPropertyValidator *)Get((const wxChar*) typeName); -} - -void wxPropertyValidatorRegistry::ClearRegistry(void) -{ - BeginFind(); - wxNode *node; - while ((node = Next()) != NULL) - { - delete (wxPropertyValidator *)node->GetData(); - } -} - - /* - * Property validator - */ - - -IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator, wxEvtHandler) - -wxPropertyValidator::wxPropertyValidator(long flags) -{ - m_validatorFlags = flags; - m_validatorProperty = NULL; -} - -wxPropertyValidator::~wxPropertyValidator(void) -{} - -bool wxPropertyValidator::StringToFloat (wxChar *s, float *number) { - double num; - bool ok = StringToDouble (s, &num); - *number = (float) num; - return ok; -} - -bool wxPropertyValidator::StringToDouble (wxChar *s, double *number) { - bool ok = TRUE; - wxChar *value_ptr; - *number = wxStrtod (s, &value_ptr); - if (value_ptr) { - int len = wxStrlen (value_ptr); - for (int i = 0; i < len; i++) { - ok = (wxIsspace (value_ptr[i]) != 0); - if (!ok) return FALSE; - } - } - return ok; -} - -bool wxPropertyValidator::StringToInt (wxChar *s, int *number) { - long num; - bool ok = StringToLong (s, &num); - *number = (int) num; - return ok; -} - -bool wxPropertyValidator::StringToLong (wxChar *s, long *number) { - bool ok = TRUE; - wxChar *value_ptr; - *number = wxStrtol (s, &value_ptr, 10); - if (value_ptr) { - int len = wxStrlen (value_ptr); - for (int i = 0; i < len; i++) { - ok = (wxIsspace (value_ptr[i]) != 0); - if (!ok) return FALSE; - } - } - return ok; -} - -wxChar *wxPropertyValidator::FloatToString (float number) { - static wxChar buf[20]; - wxSnprintf (buf, 20, wxT("%.6g"), number); - return buf; -} - -wxChar *wxPropertyValidator::DoubleToString (double number) { - static wxChar buf[20]; - wxSnprintf (buf, 20, wxT("%.6g"), number); - return buf; -} - -wxChar *wxPropertyValidator::IntToString (int number) { - return ::IntToString (number); -} - -wxChar *wxPropertyValidator::LongToString (long number) { - return ::LongToString (number); - } - -#endif // wxUSE_PROPSHEET diff --git a/src/generic/propform.cpp b/src/generic/propform.cpp deleted file mode 100644 index 5fc2aa91e0..0000000000 --- a/src/generic/propform.cpp +++ /dev/null @@ -1,761 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: propform.cpp -// Purpose: Property form classes -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "propform.h" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if wxUSE_PROPSHEET - -#ifndef WX_PRECOMP - #include "wx/choice.h" - #include "wx/checkbox.h" - #include "wx/slider.h" - #include "wx/msgdlg.h" -#endif - -#include "wx/propform.h" - -#include -#include -#include -#include - - -/* -* Property view -*/ - -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) -END_EVENT_TABLE() - -bool wxPropertyFormView::sm_dialogCancelled = FALSE; - -wxPropertyFormView::wxPropertyFormView(wxWindow *propPanel, long flags):wxPropertyView(flags) -{ - m_propertyWindow = propPanel; - m_managedWindow = NULL; - - m_windowCloseButton = NULL; - m_windowCancelButton = NULL; - m_windowHelpButton = NULL; - - m_detailedEditing = FALSE; -} - -wxPropertyFormView::~wxPropertyFormView(void) -{ -} - -void wxPropertyFormView::ShowView(wxPropertySheet *ps, wxWindow *panel) -{ - m_propertySheet = ps; - - AssociatePanel(panel); - // CreateControls(); - // UpdatePropertyList(); -} - -// Update this view of the viewed object, called e.g. by -// the object itself. -bool wxPropertyFormView::OnUpdateView(void) -{ - return TRUE; -} - -bool wxPropertyFormView::Check(void) -{ - if (!m_propertySheet) - return FALSE; - - wxNode *node = m_propertySheet->GetProperties().GetFirst(); - while (node) - { - wxProperty *prop = (wxProperty *)node->GetData(); - wxPropertyValidator *validator = FindPropertyValidator(prop); - if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator))) - { - wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator; - if (!formValidator->OnCheckValue(prop, this, m_propertyWindow)) - return FALSE; - } - node = node->GetNext(); - } - return TRUE; -} - -bool wxPropertyFormView::TransferToPropertySheet(void) -{ - if (!m_propertySheet) - return FALSE; - - wxNode *node = m_propertySheet->GetProperties().GetFirst(); - while (node) - { - 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->GetNext(); - } - return TRUE; -} - -bool wxPropertyFormView::TransferToDialog(void) -{ - if (!m_propertySheet) - return FALSE; - - wxNode *node = m_propertySheet->GetProperties().GetFirst(); - while (node) - { - 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->GetNext(); - } - return TRUE; -} - -bool wxPropertyFormView::AssociateNames(void) -{ - if (!m_propertySheet || !m_propertyWindow) - return FALSE; - - wxWindowList::Node *node = m_propertyWindow->GetChildren().GetFirst(); - while (node) - { - wxWindow *win = node->GetData(); - if ( win->GetName() != wxEmptyString ) - { - wxProperty *prop = m_propertySheet->GetProperty(win->GetName()); - if (prop) - prop->SetWindow(win); - } - node = node->GetNext(); - } - return TRUE; -} - - -bool wxPropertyFormView::OnClose(void) -{ - if (m_propertyWindow->IsKindOf(CLASSINFO(wxPropertyFormPanel))) - { - ((wxPropertyFormPanel*)m_propertyWindow)->SetView(NULL); - } - delete this; - return TRUE; -} - -void wxPropertyFormView::OnOk(wxCommandEvent& WXUNUSED(event)) -{ - // 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); -} - -void wxPropertyFormView::OnHelp(wxCommandEvent& WXUNUSED(event)) -{ -} - -void wxPropertyFormView::OnUpdate(wxCommandEvent& WXUNUSED(event)) -{ - if (Check()) - TransferToPropertySheet(); -} - -void wxPropertyFormView::OnRevert(wxCommandEvent& WXUNUSED(event)) -{ - TransferToDialog(); -} - -void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event) -{ - 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) - OnCancel(event); - else if (wxStrcmp(win.GetName(), wxT("help")) == 0) - OnHelp(event); - else if (wxStrcmp(win.GetName(), wxT("update")) == 0) - OnUpdate(event); - else if (wxStrcmp(win.GetName(), wxT("revert")) == 0) - OnRevert(event); - else - { - // Find a validator to route the command to. - wxNode *node = m_propertySheet->GetProperties().GetFirst(); - while (node) - { - wxProperty *prop = (wxProperty *)node->GetData(); - if (prop->GetWindow() && (prop->GetWindow() == &win)) - { - wxPropertyValidator *validator = FindPropertyValidator(prop); - if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator))) - { - wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator; - formValidator->OnCommand(prop, this, m_propertyWindow, event); - return; - } - } - node = node->GetNext(); - } - } -} - -// Extend event processing to call OnCommand -bool wxPropertyFormView::ProcessEvent(wxEvent& event) -{ - if (wxEvtHandler::ProcessEvent(event)) - return TRUE; - else if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxUpdateUIEvent)) && event.GetEventObject()) - { - OnCommand(* ((wxWindow*) event.GetEventObject()), (wxCommandEvent&) event); - return TRUE; - } - else - return FALSE; -} - -void wxPropertyFormView::OnDoubleClick(wxControl *item) -{ - if (!m_propertySheet) - return; - - // Find a validator to route the command to. - wxNode *node = m_propertySheet->GetProperties().GetFirst(); - while (node) - { - wxProperty *prop = (wxProperty *)node->GetData(); - if (prop->GetWindow() && ((wxControl *)prop->GetWindow() == item)) - { - wxPropertyValidator *validator = FindPropertyValidator(prop); - if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator))) - { - wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator; - formValidator->OnDoubleClick(prop, this, m_propertyWindow); - return; - } - } - node = node->GetNext(); - } -} - -/* -* Property form dialog box -*/ - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxPropertyFormDialog, wxDialog) -EVT_CLOSE(wxPropertyFormDialog::OnCloseWindow) -END_EVENT_TABLE() - -wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title, - const wxPoint& pos, const wxSize& size, long style, const wxString& name): -wxDialog(parent, -1, title, pos, size, style, name) -{ - m_view = v; - m_view->AssociatePanel(this); - m_view->SetManagedWindow(this); - // SetAutoLayout(TRUE); -} - -void wxPropertyFormDialog::OnCloseWindow(wxCloseEvent& event) -{ - if (m_view) - { - m_view->OnClose(); - m_view = NULL; - this->Destroy(); - } - else - event.Veto(); -} - -void wxPropertyFormDialog::OnDefaultAction(wxControl *item) -{ - m_view->OnDoubleClick(item); -} - -void wxPropertyFormDialog::OnCommand(wxWindow& win, wxCommandEvent& event) -{ - if ( m_view ) - m_view->OnCommand(win, event); -} - -// Extend event processing to search the view's event table -bool wxPropertyFormDialog::ProcessEvent(wxEvent& event) -{ - if ( !m_view || ! m_view->ProcessEvent(event) ) - return wxEvtHandler::ProcessEvent(event); - else - return TRUE; -} - - -/* -* Property form panel -*/ - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormPanel, wxPanel) - -void wxPropertyFormPanel::OnDefaultAction(wxControl *item) -{ - m_view->OnDoubleClick(item); -} - -void wxPropertyFormPanel::OnCommand(wxWindow& win, wxCommandEvent& event) -{ - m_view->OnCommand(win, event); -} - -// Extend event processing to search the view's event table -bool wxPropertyFormPanel::ProcessEvent(wxEvent& event) -{ - if ( !m_view || ! m_view->ProcessEvent(event) ) - return wxEvtHandler::ProcessEvent(event); - else - return TRUE; -} - -/* -* Property frame -*/ - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormFrame, wxFrame) - -BEGIN_EVENT_TABLE(wxPropertyFormFrame, wxFrame) -EVT_CLOSE(wxPropertyFormFrame::OnCloseWindow) -END_EVENT_TABLE() - -void wxPropertyFormFrame::OnCloseWindow(wxCloseEvent& event) -{ - if (m_view && m_view->OnClose()) - this->Destroy(); - else - event.Veto(); -} - -wxPanel *wxPropertyFormFrame::OnCreatePanel(wxFrame *parent, wxPropertyFormView *v) -{ - return new wxPropertyFormPanel(v, parent); -} - -bool wxPropertyFormFrame::Initialize(void) -{ - m_propertyPanel = OnCreatePanel(this, m_view); - if (m_propertyPanel) - { - m_view->AssociatePanel(m_propertyPanel); - m_view->SetManagedWindow(this); - return TRUE; - } - else - return FALSE; -} - -/* -* Property form specific validator -*/ - -IMPLEMENT_ABSTRACT_CLASS(wxPropertyFormValidator, wxPropertyValidator) - - -/* -* Default validators -*/ - -IMPLEMENT_DYNAMIC_CLASS(wxRealFormValidator, wxPropertyFormValidator) - -/// -/// Real number form validator -/// -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)) - { - wxChar buf[200]; - wxSprintf(buf, wxT("Value %s is not a valid real number!"), (const wxChar *)value); - wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); - return FALSE; - } - - if (val < m_realMin || val > m_realMax) - { - wxChar buf[200]; - wxSprintf(buf, wxT("Value must be a real number between %.2f and %.2f!"), m_realMin, m_realMax); - wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); - return FALSE; - } - return TRUE; -} - -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), - 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), - 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]; - wxSprintf(buf, wxT("Value %s is not a valid integer!"), (const wxChar *)value); - wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); - return FALSE; - } - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider))) - { - val = (long)((wxSlider *)m_propertyWindow)->GetValue(); - } - else - return FALSE; - - if (val < m_integerMin || val > m_integerMax) - { - 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), - 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 if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider))) - { - property->GetValue() = (long)((wxSlider *)m_propertyWindow)->GetValue(); - } - else - return FALSE; - - return TRUE; -} - -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; - textItem->SetValue(LongToString(property->GetValue().IntegerValue())); - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider))) - { - ((wxSlider *)m_propertyWindow)->SetValue((int)property->GetValue().IntegerValue()); - } - else - return FALSE; - return TRUE; -} - -/// -/// Boolean validator -/// -IMPLEMENT_DYNAMIC_CLASS(wxBoolFormValidator, wxPropertyFormValidator) - -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), - 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), - 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): -wxPropertyFormValidator(flags) -{ - m_strings = list; -} - -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 FALSE; - if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) - { - wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; - if (!m_strings->Member(text->GetValue())) - { - wxString str( wxT("Value ") ); - str += text->GetValue(); - str += wxT(" is not valid."); - wxMessageBox(str, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); - return FALSE; - } - } - else - { - // Any other item constrains the string value, - // so we don't have to check it. - } - return TRUE; -} - -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. - wxWindow *m_propertyWindow = property->GetWindow(); - if (!m_propertyWindow) - return FALSE; - if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) - { - wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; - property->GetValue() = text->GetValue(); - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox))) - { - wxListBox *lbox = (wxListBox *)m_propertyWindow; - if (lbox->GetSelection() > -1) - property->GetValue() = lbox->GetStringSelection(); - } - /* - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxRadioBox))) - { - wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow; - int n = 0; - if ((n = rbox->GetSelection()) > -1) - property->GetValue() = rbox->GetString(n); - } - */ - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice))) - { - wxChoice *choice = (wxChoice *)m_propertyWindow; - if (choice->GetSelection() > -1) - property->GetValue() = choice->GetStringSelection(); - } - else - return FALSE; - return TRUE; -} - -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. - wxWindow *m_propertyWindow = property->GetWindow(); - if (!m_propertyWindow) - return FALSE; - if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) - { - wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; - text->SetValue(property->GetValue().StringValue()); - } - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox))) - { - wxListBox *lbox = (wxListBox *)m_propertyWindow; - if (lbox->GetCount() == 0 && m_strings) - { - // Try to initialize the listbox from 'strings' - wxStringList::Node *node = m_strings->GetFirst(); - while (node) - { - wxChar *s = node->GetData(); - lbox->Append(s); - node = node->GetNext(); - } - } - lbox->SetStringSelection(property->GetValue().StringValue()); - } - /* - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxRadioBox))) - { - wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow; - rbox->SetStringSelection(property->GetValue().StringValue()); - } - */ - else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice))) - { - wxChoice *choice = (wxChoice *)m_propertyWindow; - if (choice->GetCount() == 0 && m_strings) - { - // Try to initialize the choice item from 'strings' - // XView doesn't allow this kind of thing. - wxStringList::Node *node = m_strings->GetFirst(); - while (node) - { - wxChar *s = node->GetData(); - choice->Append(s); - node = node->GetNext(); - } - } - choice->SetStringSelection(property->GetValue().StringValue()); - } - else - return FALSE; - return TRUE; -} - -#endif // wxUSE_PROPSHEET diff --git a/src/generic/proplist.cpp b/src/generic/proplist.cpp deleted file mode 100644 index f6aa8cf737..0000000000 --- a/src/generic/proplist.cpp +++ /dev/null @@ -1,1836 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: proplist.cpp -// Purpose: Property list classes -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#ifdef __GNUG__ - #pragma implementation "proplist.h" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#if wxUSE_PROPSHEET - -#ifndef WX_PRECOMP - #include "wx/window.h" - #include "wx/font.h" - #include "wx/button.h" - #include "wx/bmpbuttn.h" - #include "wx/textctrl.h" - #include "wx/listbox.h" - #include "wx/settings.h" - #include "wx/msgdlg.h" - #include "wx/filedlg.h" -#endif - -#include "wx/sizer.h" -#include "wx/module.h" -#include "wx/intl.h" -#include "wx/artprov.h" - -#include "wx/colordlg.h" -#include "wx/proplist.h" - -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -// Property text edit control -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyTextEdit, wxTextCtrl) - -wxPropertyTextEdit::wxPropertyTextEdit(wxPropertyListView *v, wxWindow *parent, - const wxWindowID id, const wxString& value, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name): - wxTextCtrl(parent, id, value, pos, size, style, wxDefaultValidator, name) -{ - m_view = v; -} - -void wxPropertyTextEdit::OnSetFocus() -{ -} - -void wxPropertyTextEdit::OnKillFocus() -{ -} - -// ---------------------------------------------------------------------------- -// Property list view -// ---------------------------------------------------------------------------- - -bool wxPropertyListView::sm_dialogCancelled = FALSE; - -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) -END_EVENT_TABLE() - -wxPropertyListView::wxPropertyListView(wxPanel *propPanel, long flags):wxPropertyView(flags) -{ - m_propertyScrollingList = NULL; - m_valueList = NULL; - m_valueText = NULL; - m_editButton = NULL; - m_confirmButton = NULL; - m_cancelButton = NULL; - m_propertyWindow = propPanel; - m_managedWindow = NULL; - - m_windowCloseButton = NULL; - m_windowCancelButton = NULL; - m_windowHelpButton = NULL; - - m_detailedEditing = FALSE; -} - -wxPropertyListView::~wxPropertyListView() -{ -} - -void wxPropertyListView::ShowView(wxPropertySheet *ps, wxPanel *panel) -{ - m_propertySheet = ps; - - AssociatePanel(panel); - CreateControls(); - - UpdatePropertyList(); - panel->Layout(); -} - -// Update this view of the viewed object, called e.g. by -// the object itself. -bool wxPropertyListView::OnUpdateView() -{ - return TRUE; -} - -bool wxPropertyListView::UpdatePropertyList(bool clearEditArea) -{ - if (!m_propertyScrollingList || !m_propertySheet) - return FALSE; - - m_propertyScrollingList->Clear(); - if (clearEditArea) - { - m_valueList->Clear(); - m_valueText->SetValue( wxT("") ); - } - wxNode *node = m_propertySheet->GetProperties().GetFirst(); - - // Should sort them... later... - while (node) - { - wxProperty *property = (wxProperty *)node->GetData(); - wxString stringValueRepr(property->GetValue().GetStringRepresentation()); - wxString paddedString(MakeNameValueString(property->GetName(), stringValueRepr)); - m_propertyScrollingList->Append(paddedString.GetData(), (void *)property); - node = node->GetNext(); - } - return TRUE; -} - -bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty *property) -{ - 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)); - int sel = FindListIndexForProperty(property); - - if (sel > -1) - { - // Don't update the listbox unnecessarily because it can cause - // ugly flashing. - - if (paddedString != m_propertyScrollingList->GetString(sel)) - m_propertyScrollingList->SetString(sel, paddedString.GetData()); - } -//#else -// UpdatePropertyList(FALSE); -//#endif - - // TODO: why is this necessary? -#ifdef __WXMSW__ - if (currentlySelected > -1) - m_propertyScrollingList->SetSelection(currentlySelected); -#endif - - return TRUE; -} - -// Find the wxListBox index corresponding to this property -int wxPropertyListView::FindListIndexForProperty(wxProperty *property) -{ - int n = m_propertyScrollingList->GetCount(); - for (int i = 0; i < n; i++) - { - if (property == (wxProperty *)m_propertyScrollingList->wxListBox::GetClientData(i)) - return i; - } - return -1; -} - -wxString wxPropertyListView::MakeNameValueString(wxString name, wxString value) -{ - wxString theString(name); - - int nameWidth = 25; - int padWith = nameWidth - theString.Length(); - if (padWith < 0) - padWith = 0; - - if (GetFlags() & wxPROP_SHOWVALUES) - { - // Want to pad with spaces - theString.Append( wxT(' '), padWith); - theString += value; - } - - return theString; -} - -// Select and show string representation in validator the given -// property. NULL resets to show no property. -bool wxPropertyListView::ShowProperty(wxProperty *property, bool select) -{ - if (m_currentProperty) - { - EndShowingProperty(m_currentProperty); - m_currentProperty = NULL; - } - - m_valueList->Clear(); - m_valueText->SetValue( wxT("") ); - - if (property) - { - m_currentProperty = property; - BeginShowingProperty(property); - } - if (select) - { - int sel = FindListIndexForProperty(property); - if (sel > -1) - m_propertyScrollingList->SetSelection(sel); - } - return TRUE; -} - -// Find appropriate validator and load property into value controls -bool wxPropertyListView::BeginShowingProperty(wxProperty *property) -{ - m_currentValidator = FindPropertyValidator(property); - if (!m_currentValidator) - return FALSE; - - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return FALSE; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - listValidator->OnPrepareControls(property, this, m_propertyWindow); - DisplayProperty(property); - return TRUE; -} - -// Find appropriate validator and unload property from value controls -bool wxPropertyListView::EndShowingProperty(wxProperty *property) -{ - if (!m_currentValidator) - return FALSE; - - RetrieveProperty(property); - - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return FALSE; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - listValidator->OnClearControls(property, this, m_propertyWindow); - if (m_detailedEditing) - { - listValidator->OnClearDetailControls(property, this, m_propertyWindow); - m_detailedEditing = FALSE; - } - return TRUE; -} - -void wxPropertyListView::BeginDetailedEditing() -{ - if (!m_currentValidator) - return; - if (!m_currentProperty) - return; - if (m_detailedEditing) - return; - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return; - if (!m_currentProperty->IsEnabled()) - return; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - if (listValidator->OnPrepareDetailControls(m_currentProperty, this, m_propertyWindow)) - m_detailedEditing = TRUE; -} - -void wxPropertyListView::EndDetailedEditing() -{ - if (!m_currentValidator) - return; - if (!m_currentProperty) - return; - - RetrieveProperty(m_currentProperty); - - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - if (m_detailedEditing) - { - listValidator->OnClearDetailControls(m_currentProperty, this, m_propertyWindow); - m_detailedEditing = FALSE; - } -} - -bool wxPropertyListView::DisplayProperty(wxProperty *property) -{ - if (!m_currentValidator) - return FALSE; - - if (((m_currentValidator->GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == 0) || !property->IsEnabled()) - m_valueText->SetEditable(FALSE); - else - m_valueText->SetEditable(TRUE); - - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return FALSE; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - listValidator->OnDisplayValue(property, this, m_propertyWindow); - return TRUE; -} - -bool wxPropertyListView::RetrieveProperty(wxProperty *property) -{ - if (!m_currentValidator) - return FALSE; - if (!property->IsEnabled()) - return FALSE; - - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return FALSE; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - if (listValidator->OnCheckValue(property, this, m_propertyWindow)) - { - if (listValidator->OnRetrieveValue(property, this, m_propertyWindow)) - { - UpdatePropertyDisplayInList(property); - OnPropertyChanged(property); - } - } - else - { - // Revert to old value - listValidator->OnDisplayValue(property, this, m_propertyWindow); - } - return TRUE; -} - - -bool wxPropertyListView::EditProperty(wxProperty *WXUNUSED(property)) -{ - return TRUE; -} - -// Called by the listbox callback -void wxPropertyListView::OnPropertySelect(wxCommandEvent& WXUNUSED(event)) -{ - int sel = m_propertyScrollingList->GetSelection(); - if (sel > -1) - { - wxProperty *newSel = (wxProperty *)m_propertyScrollingList->wxListBox::GetClientData(sel); - if (newSel && newSel != m_currentProperty) - { - ShowProperty(newSel, FALSE); - } - } -} - -bool wxPropertyListView::CreateControls() -{ - wxPanel *panel = (wxPanel *)m_propertyWindow; - - wxSize largeButtonSize( 70, 25 ); - wxSize smallButtonSize( 23, 23 ); - - if (m_valueText) - return TRUE; - - if (!panel) - return FALSE; - - wxFont guiFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); - -#ifdef __WXMSW__ - wxFont *boringFont = - wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxMODERN, - wxNORMAL, wxNORMAL, FALSE, _T("Courier New")); -#else - wxFont *boringFont = wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxTELETYPE, wxNORMAL, wxNORMAL); -#endif - - // May need to be changed in future to eliminate clashes with app. - // WHAT WAS THIS FOR? -// panel->SetClientData((char *)this); - - wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); - - // top row with optional buttons and input line - - wxBoxSizer *topsizer = new wxBoxSizer( wxHORIZONTAL ); - int buttonborder = 3; - - if (m_buttonFlags & wxPROP_BUTTON_CHECK_CROSS) - { - wxBitmap tickBitmap = wxArtProvider::GetBitmap(wxART_TICK_MARK); - wxBitmap crossBitmap = wxArtProvider::GetBitmap(wxART_CROSS_MARK); - - if ( tickBitmap.Ok() && crossBitmap.Ok() ) - { - m_confirmButton = new wxBitmapButton(panel, wxID_PROP_CHECK, tickBitmap, wxPoint(-1, -1), smallButtonSize ); - m_cancelButton = new wxBitmapButton(panel, wxID_PROP_CROSS, crossBitmap, wxPoint(-1, -1), smallButtonSize ); - } - else - { - m_confirmButton = new wxButton(panel, wxID_PROP_CHECK, _T(":-)"), wxPoint(-1, -1), smallButtonSize ); - m_cancelButton = new wxButton(panel, wxID_PROP_CROSS, _T("X"), wxPoint(-1, -1), smallButtonSize ); - } - - topsizer->Add( m_confirmButton, 0, wxLEFT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); - topsizer->Add( m_cancelButton, 0, wxLEFT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); - } - - m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, _T(""), - wxPoint(-1, -1), wxSize(-1, smallButtonSize.y), wxPROCESS_ENTER); - m_valueText->Enable(FALSE); - topsizer->Add( m_valueText, 1, wxALL | wxEXPAND, buttonborder ); - - if (m_buttonFlags & wxPROP_PULLDOWN) - { - m_editButton = new wxButton(panel, wxID_PROP_EDIT, _T("..."), wxPoint(-1, -1), smallButtonSize); - m_editButton->Enable(FALSE); - topsizer->Add( m_editButton, 0, wxRIGHT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); - } - - mainsizer->Add( topsizer, 0, wxEXPAND ); - - // middle section with two list boxes - - m_middleSizer = new wxBoxSizer( wxVERTICAL ); - - m_valueList = new wxListBox(panel, wxID_PROP_VALUE_SELECT, wxPoint(-1, -1), wxSize(-1, 60)); - m_valueList->Show(FALSE); - - m_propertyScrollingList = new wxListBox(panel, wxID_PROP_SELECT, wxPoint(-1, -1), wxSize(100, 100)); - m_propertyScrollingList->SetFont(* boringFont); - m_middleSizer->Add( m_propertyScrollingList, 1, wxALL|wxEXPAND, buttonborder ); - - mainsizer->Add( m_middleSizer, 1, wxEXPAND ); - - // bottom row with buttons - - if ((m_buttonFlags & wxPROP_BUTTON_OK) || - (m_buttonFlags & wxPROP_BUTTON_CLOSE) || - (m_buttonFlags & wxPROP_BUTTON_CANCEL) || - (m_buttonFlags & wxPROP_BUTTON_HELP)) - { - wxBoxSizer *bottomsizer = new wxBoxSizer( wxHORIZONTAL ); - buttonborder = 5; - - if (m_buttonFlags & wxPROP_BUTTON_OK) - { - m_windowCloseButton = new wxButton(panel, wxID_OK, _("OK"), wxPoint(-1, -1), largeButtonSize ); - m_windowCloseButton->SetDefault(); - m_windowCloseButton->SetFocus(); - bottomsizer->Add( m_windowCloseButton, 0, wxALL, buttonborder ); - } - else if (m_buttonFlags & wxPROP_BUTTON_CLOSE) - { - m_windowCloseButton = new wxButton(panel, wxID_OK, _("Close"), wxPoint(-1, -1), largeButtonSize ); - bottomsizer->Add( m_windowCloseButton, 0, wxALL, buttonborder ); - } - if (m_buttonFlags & wxPROP_BUTTON_CANCEL) - { - m_windowCancelButton = new wxButton(panel, wxID_CANCEL, _("Cancel"), wxPoint(-1, -1), largeButtonSize ); - bottomsizer->Add( m_windowCancelButton, 0, wxALL, buttonborder ); - } - if (m_buttonFlags & wxPROP_BUTTON_HELP) - { - m_windowHelpButton = new wxButton(panel, wxID_HELP, _("Help"), wxPoint(-1, -1), largeButtonSize ); - bottomsizer->Add( m_windowHelpButton, 0, wxALL, buttonborder ); - } - - mainsizer->Add( bottomsizer, 0, wxALIGN_RIGHT | wxEXPAND ); - } - - panel->SetSizer( mainsizer ); - - return TRUE; -} - -void wxPropertyListView::ShowTextControl(bool show) -{ - if (m_valueText) - m_valueText->Show(show); -} - -void wxPropertyListView::ShowListBoxControl(bool show) -{ - if (!m_valueList) return; - - m_valueList->Show(show); - - if (m_buttonFlags & wxPROP_DYNAMIC_VALUE_FIELD) - { - if (show) - m_middleSizer->Prepend( m_valueList, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 3 ); - else - m_middleSizer->Remove( 0 ); - - m_propertyWindow->Layout(); - } -} - -void wxPropertyListView::EnableCheck(bool show) -{ - if (m_confirmButton) - m_confirmButton->Enable(show); -} - -void wxPropertyListView::EnableCross(bool show) -{ - if (m_cancelButton) - m_cancelButton->Enable(show); -} - -bool wxPropertyListView::OnClose() -{ - // Retrieve the value if any - wxCommandEvent event; - OnCheck(event); - - delete this; - return TRUE; -} - -void wxPropertyListView::OnValueListSelect(wxCommandEvent& WXUNUSED(event)) -{ - if (m_currentProperty && m_currentValidator) - { - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - listValidator->OnValueListSelect(m_currentProperty, this, m_propertyWindow); - } -} - -void wxPropertyListView::OnOk(wxCommandEvent& event) -{ - // Retrieve the value if any - OnCheck(event); - - m_managedWindow->Close(TRUE); - sm_dialogCancelled = FALSE; -} - -void wxPropertyListView::OnCancel(wxCommandEvent& WXUNUSED(event)) -{ -// SetReturnCode(wxID_CANCEL); - m_managedWindow->Close(TRUE); - sm_dialogCancelled = TRUE; -} - -void wxPropertyListView::OnHelp(wxCommandEvent& WXUNUSED(event)) -{ -} - -void wxPropertyListView::OnCheck(wxCommandEvent& WXUNUSED(event)) -{ - if (m_currentProperty) - { - RetrieveProperty(m_currentProperty); - } -} - -void wxPropertyListView::OnCross(wxCommandEvent& WXUNUSED(event)) -{ - if (m_currentProperty && m_currentValidator) - { - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - // Revert to old value - listValidator->OnDisplayValue(m_currentProperty, this, m_propertyWindow); - } -} - -void wxPropertyListView::OnPropertyDoubleClick(wxCommandEvent& WXUNUSED(event)) -{ - if (m_currentProperty && m_currentValidator) - { - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - // Revert to old value - listValidator->OnDoubleClick(m_currentProperty, this, m_propertyWindow); - } -} - -void wxPropertyListView::OnEdit(wxCommandEvent& WXUNUSED(event)) -{ - if (m_currentProperty && m_currentValidator) - { - if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) - return; - - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - - listValidator->OnEdit(m_currentProperty, this, m_propertyWindow); - } -} - -void wxPropertyListView::OnText(wxCommandEvent& event) -{ - if (event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER) - { - OnCheck(event); - } -} - -// ---------------------------------------------------------------------------- -// Property dialog box -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyListDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxPropertyListDialog, wxDialog) - 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 wxSize& size, long style, const wxString& name): - wxDialog(parent, -1, title, pos, size, style, name) -{ - m_view = v; - m_view->AssociatePanel( ((wxPanel*)this) ); - m_view->SetManagedWindow(this); - SetAutoLayout(TRUE); -} - -void wxPropertyListDialog::OnCloseWindow(wxCloseEvent& event) -{ - if (m_view) - { - SetReturnCode(wxID_CANCEL); - m_view->OnClose(); - m_view = NULL; - this->Destroy(); - } - else - { - event.Veto(); - } -} - -void wxPropertyListDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) -{ - SetReturnCode(wxID_CANCEL); - this->Close(); -} - -void wxPropertyListDialog::OnDefaultAction(wxControl *WXUNUSED(item)) -{ -/* - if (item == m_view->GetPropertyScrollingList()) - view->OnDoubleClick(); -*/ -} - -// 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; -} - -// ---------------------------------------------------------------------------- -// Property panel -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyListPanel, wxPanel) - -BEGIN_EVENT_TABLE(wxPropertyListPanel, wxPanel) - EVT_SIZE(wxPropertyListPanel::OnSize) -END_EVENT_TABLE() - -wxPropertyListPanel::~wxPropertyListPanel() -{ -} - -void wxPropertyListPanel::OnDefaultAction(wxControl *WXUNUSED(item)) -{ -/* - if (item == view->GetPropertyScrollingList()) - view->OnDoubleClick(); -*/ -} - -// 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; -} - -void wxPropertyListPanel::OnSize(wxSizeEvent& WXUNUSED(event)) -{ - Layout(); -} - -// ---------------------------------------------------------------------------- -// Property frame -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxPropertyListFrame, wxFrame) - -BEGIN_EVENT_TABLE(wxPropertyListFrame, wxFrame) - EVT_CLOSE(wxPropertyListFrame::OnCloseWindow) -END_EVENT_TABLE() - -void wxPropertyListFrame::OnCloseWindow(wxCloseEvent& event) -{ - if (m_view) - { - if (m_propertyPanel) - m_propertyPanel->SetView(NULL); - m_view->OnClose(); - m_view = NULL; - this->Destroy(); - } - else - { - event.Veto(); - } -} - -wxPropertyListPanel *wxPropertyListFrame::OnCreatePanel(wxFrame *parent, wxPropertyListView *v) -{ - return new wxPropertyListPanel(v, parent); -} - -bool wxPropertyListFrame::Initialize() -{ - m_propertyPanel = OnCreatePanel(this, m_view); - if (m_propertyPanel) - { - m_view->AssociatePanel(m_propertyPanel); - m_view->SetManagedWindow(this); - m_propertyPanel->SetAutoLayout(TRUE); - return TRUE; - } - else - return FALSE; -} - -// ---------------------------------------------------------------------------- -// Property list specific validator -// ---------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxPropertyListValidator, wxPropertyValidator) - -bool wxPropertyListValidator::OnSelect(bool select, wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) -{ -// view->GetValueText()->Show(TRUE); - if (select) - OnDisplayValue(property, view, parentWindow); - - return TRUE; -} - -bool wxPropertyListValidator::OnValueListSelect(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - wxString s(view->GetValueList()->GetStringSelection()); - if (s != wxT("")) - { - view->GetValueText()->SetValue(s); - view->RetrieveProperty(property); - } - return TRUE; -} - -bool wxPropertyListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ -// view->GetValueText()->Show(TRUE); - wxString str(property->GetValue().GetStringRepresentation()); - - view->GetValueText()->SetValue(str); - 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 wxPropertyListValidator::OnRetrieveValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - return FALSE; -} - -void wxPropertyListValidator::OnEdit(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetDetailedEditing()) - view->EndDetailedEditing(); - else - view->BeginDetailedEditing(); -} - -bool wxPropertyListValidator::OnClearControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(FALSE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(FALSE); - if (view->GetEditButton()) - view->GetEditButton()->Enable(FALSE); - return TRUE; -} - -// ---------------------------------------------------------------------------- -// Default validators -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxRealListValidator, wxPropertyListValidator) - -/// -/// Real number validator -/// -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)) - { - wxChar buf[200]; - wxSprintf(buf, wxT("Value %s is not a valid real number!"), value.GetData()); - wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); - return FALSE; - } - - if (val < m_realMin || val > m_realMax) - { - wxChar buf[200]; - wxSprintf(buf, wxT("Value must be a real number between %.2f and %.2f!"), m_realMin, m_realMax); - wxMessageBox(buf, wxT("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 wxRealListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - - if (wxStrlen(view->GetValueText()->GetValue()) == 0) - return FALSE; - - wxString value(view->GetValueText()->GetValue()); - float f = (float)wxAtof(value.GetData()); - property->GetValue() = f; - return TRUE; -} - -bool wxRealListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(TRUE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(TRUE); - if (view->GetEditButton()) - view->GetEditButton()->Enable(FALSE); - if (view->GetValueText()) - view->GetValueText()->Enable(TRUE); - return TRUE; -} - -/// -/// Integer validator -/// -IMPLEMENT_DYNAMIC_CLASS(wxIntegerListValidator, wxPropertyListValidator) - -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)) - { - wxChar buf[200]; - wxSprintf(buf, wxT("Value %s is not a valid integer!"), value.GetData()); - wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); - return FALSE; - } - if (val < m_integerMin || val > m_integerMax) - { - 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; -} - -// 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 *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - - if (wxStrlen(view->GetValueText()->GetValue()) == 0) - return FALSE; - - wxString value(view->GetValueText()->GetValue()); - long val = (long)wxAtoi(value.GetData()); - property->GetValue() = (long)val; - return TRUE; -} - -bool wxIntegerListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(TRUE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(TRUE); - if (view->GetEditButton()) - view->GetEditButton()->Enable(FALSE); - if (view->GetValueText()) - view->GetValueText()->Enable(TRUE); - return TRUE; -} - -/// -/// boolean validator -/// -IMPLEMENT_DYNAMIC_CLASS(wxBoolListValidator, wxPropertyListValidator) - -bool wxBoolListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow) -{ - if (!view->GetValueText()) - return FALSE; - wxString value(view->GetValueText()->GetValue()); - if (value != wxT("True") && value != wxT("False")) - { - wxMessageBox(wxT("Value must be True or False!"), wxT("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 *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - - if (wxStrlen(view->GetValueText()->GetValue()) == 0) - return FALSE; - - wxString value(view->GetValueText()->GetValue()); - bool boolValue = FALSE; - if (value == wxT("True")) - boolValue = TRUE; - else - boolValue = FALSE; - property->GetValue() = (bool)boolValue; - return TRUE; -} - -bool wxBoolListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - wxString str(property->GetValue().GetStringRepresentation()); - - view->GetValueText()->SetValue(str); - - if (view->GetValueList()->IsShown()) - { - view->GetValueList()->SetStringSelection(str); - } - return TRUE; -} - -bool wxBoolListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(FALSE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(FALSE); - if (view->GetEditButton()) - view->GetEditButton()->Enable(TRUE); - if (view->GetValueText()) - view->GetValueText()->Enable(FALSE); - return TRUE; -} - -bool wxBoolListValidator::OnPrepareDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetValueList()) - { - view->ShowListBoxControl(TRUE); - view->GetValueList()->Enable(TRUE); - - view->GetValueList()->Append(wxT("True")); - view->GetValueList()->Append(wxT("False")); - wxChar *currentString = copystring(view->GetValueText()->GetValue()); - view->GetValueList()->SetStringSelection(currentString); - delete[] currentString; - } - return TRUE; -} - -bool wxBoolListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetValueList()) - { - view->GetValueList()->Clear(); - view->ShowListBoxControl(FALSE); - view->GetValueList()->Enable(FALSE); - } - return TRUE; -} - -// Called when the property is double clicked. Extra functionality can be provided, -// cycling through possible values. -bool wxBoolListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - if (property->GetValue().BoolValue()) - property->GetValue() = (bool)FALSE; - else - property->GetValue() = (bool)TRUE; - view->DisplayProperty(property); - view->UpdatePropertyDisplayInList(property); - view->OnPropertyChanged(property); - return TRUE; -} - -/// -/// String validator -/// -IMPLEMENT_DYNAMIC_CLASS(wxStringListValidator, wxPropertyListValidator) - -wxStringListValidator::wxStringListValidator(wxStringList *list, long flags): - wxPropertyListValidator(flags) -{ - m_strings = list; - // If no constraint, we just allow the string to be edited. - if (!m_strings && ((m_validatorFlags & wxPROP_ALLOW_TEXT_EDITING) == 0)) - m_validatorFlags |= wxPROP_ALLOW_TEXT_EDITING; -} - -bool wxStringListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow) -{ - if (!m_strings) - return TRUE; - - if (!view->GetValueText()) - return FALSE; - wxString value(view->GetValueText()->GetValue()); - - if (!m_strings->Member(value.GetData())) - { - wxString str( wxT("Value ") ); - str += value.GetData(); - str += wxT(" is not valid."); - wxMessageBox( str.GetData(), wxT("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 wxStringListValidator::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 wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - wxString str(property->GetValue().GetStringRepresentation()); - view->GetValueText()->SetValue(str); - if (m_strings && view->GetValueList() && view->GetValueList()->IsShown() && view->GetValueList()->GetCount() > 0) - { - view->GetValueList()->SetStringSelection(str); - } - return TRUE; -} - -bool wxStringListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - // Unconstrained - if (!m_strings) - { - if (view->GetEditButton()) - view->GetEditButton()->Enable(FALSE); - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(TRUE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(TRUE); - if (view->GetValueText()) - view->GetValueText()->Enable(TRUE); - return TRUE; - } - - // Constrained - if (view->GetValueText()) - view->GetValueText()->Enable(FALSE); - - if (view->GetEditButton()) - view->GetEditButton()->Enable(TRUE); - - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(FALSE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(FALSE); - return TRUE; -} - -bool wxStringListValidator::OnPrepareDetailControls( wxProperty *property, - wxPropertyListView *view, - wxWindow *WXUNUSED(parentWindow) ) -{ - if (view->GetValueList()) - { - view->ShowListBoxControl(TRUE); - view->GetValueList()->Enable(TRUE); - wxStringList::Node *node = m_strings->GetFirst(); - while (node) - { - wxChar *s = node->GetData(); - view->GetValueList()->Append(s); - node = node->GetNext(); - } - wxChar *currentString = property->GetValue().StringValue(); - view->GetValueList()->SetStringSelection(currentString); - } - return TRUE; -} - -bool wxStringListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (!m_strings) - { - return TRUE; - } - - if (view->GetValueList()) - { - view->GetValueList()->Clear(); - view->ShowListBoxControl(FALSE); - view->GetValueList()->Enable(FALSE); - } - return TRUE; -} - -// Called when the property is double clicked. Extra functionality can be provided, -// cycling through possible values. -bool wxStringListValidator::OnDoubleClick( wxProperty *property, - wxPropertyListView *view, - wxWindow *WXUNUSED(parentWindow) ) -{ - if (!view->GetValueText()) - return FALSE; - if (!m_strings) - return FALSE; - - wxStringList::Node *node = m_strings->GetFirst(); - wxChar *currentString = property->GetValue().StringValue(); - while (node) - { - wxChar *s = node->GetData(); - if (wxStrcmp(s, currentString) == 0) - { - wxChar *nextString = NULL; - if (node->GetNext()) - nextString = node->GetNext()->GetData(); - else - nextString = m_strings->GetFirst()->GetData(); - property->GetValue() = wxString(nextString); - view->DisplayProperty(property); - view->UpdatePropertyDisplayInList(property); - view->OnPropertyChanged(property); - return TRUE; - } - else node = node->GetNext(); - } - return TRUE; -} - -/// -/// Filename validator -/// -IMPLEMENT_DYNAMIC_CLASS(wxFilenameListValidator, wxPropertyListValidator) - -wxFilenameListValidator::wxFilenameListValidator(wxString message , wxString wildcard, long flags): - wxPropertyListValidator(flags), m_filenameWildCard(wildcard), m_filenameMessage(message) -{ -} - -wxFilenameListValidator::~wxFilenameListValidator() -{ -} - -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 *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 wxFilenameListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - wxString str(property->GetValue().GetStringRepresentation()); - view->GetValueText()->SetValue(str); - return TRUE; -} - -// Called when the property is double clicked. Extra functionality can be provided, -// cycling through possible values. -bool wxFilenameListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) -{ - if (!view->GetValueText()) - return FALSE; - OnEdit(property, view, parentWindow); - return TRUE; -} - -bool wxFilenameListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(TRUE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(TRUE); - if (view->GetEditButton()) - view->GetEditButton()->Enable(TRUE); - if (view->GetValueText()) - view->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == wxPROP_ALLOW_TEXT_EDITING); - return TRUE; -} - -void wxFilenameListValidator::OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) -{ - if (!view->GetValueText()) - return; - - wxString s = wxFileSelector( - m_filenameMessage.GetData(), - wxPathOnly(property->GetValue().StringValue()), - wxFileNameFromPath(property->GetValue().StringValue()), - NULL, - m_filenameWildCard.GetData(), - 0, - parentWindow); - if (s != wxT("")) - { - property->GetValue() = s; - view->DisplayProperty(property); - view->UpdatePropertyDisplayInList(property); - view->OnPropertyChanged(property); - } -} - -/// -/// Colour validator -/// -IMPLEMENT_DYNAMIC_CLASS(wxColourListValidator, wxPropertyListValidator) - -wxColourListValidator::wxColourListValidator(long flags): - wxPropertyListValidator(flags) -{ -} - -wxColourListValidator::~wxColourListValidator() -{ -} - -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 *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 *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - wxString str(property->GetValue().GetStringRepresentation()); - view->GetValueText()->SetValue(str); - return TRUE; -} - -// Called when the property is double clicked. Extra functionality can be provided, -// cycling through possible values. -bool wxColourListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) -{ - if (!view->GetValueText()) - return FALSE; - OnEdit(property, view, parentWindow); - return TRUE; -} - -bool wxColourListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(TRUE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(TRUE); - if (view->GetEditButton()) - view->GetEditButton()->Enable(TRUE); - if (view->GetValueText()) - view->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == wxPROP_ALLOW_TEXT_EDITING); - return TRUE; -} - -void wxColourListValidator::OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) -{ - if (!view->GetValueText()) - return; - - wxChar *s = property->GetValue().StringValue(); - int r = 0; - int g = 0; - int b = 0; - if (s) - { - r = wxHexToDec(s); - 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(); - - wxChar buf[7]; - wxDecToHex(col.Red(), buf); - wxDecToHex(col.Green(), buf+2); - wxDecToHex(col.Blue(), buf+4); - - property->GetValue() = wxString(buf); - view->DisplayProperty(property); - view->UpdatePropertyDisplayInList(property); - view->OnPropertyChanged(property); - } -} - -/// -/// List of strings validator. For this we need more user interface than -/// we get with a property list; so create a new dialog for editing the list. -/// -IMPLEMENT_DYNAMIC_CLASS(wxListOfStringsListValidator, wxPropertyListValidator) - -wxListOfStringsListValidator::wxListOfStringsListValidator(long flags): - wxPropertyListValidator(flags) -{ -} - -bool wxListOfStringsListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow)) -{ - // No constraints for an arbitrary, user-editable list of 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. -// In this case, the user cannot directly edit the string list. -bool wxListOfStringsListValidator::OnRetrieveValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow)) -{ - return TRUE; -} - -bool wxListOfStringsListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (!view->GetValueText()) - return FALSE; - wxString str(property->GetValue().GetStringRepresentation()); - view->GetValueText()->SetValue(str); - return TRUE; -} - -bool wxListOfStringsListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) -{ - if (view->GetEditButton()) - view->GetEditButton()->Enable(TRUE); - if (view->GetValueText()) - view->GetValueText()->Enable(FALSE); - - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(FALSE); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(FALSE); - return TRUE; -} - -// Called when the property is double clicked. Extra functionality can be provided, -// cycling through possible values. -bool wxListOfStringsListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) -{ - OnEdit(property, view, parentWindow); - return TRUE; -} - -void wxListOfStringsListValidator::OnEdit( wxProperty *property, - wxPropertyListView *view, - wxWindow *parentWindow ) -{ - // Convert property value to a list of strings for editing - wxStringList *stringList = new wxStringList; - - wxPropertyValue *expr = property->GetValue().GetFirst(); - while (expr) - { - wxChar *s = expr->StringValue(); - if (s) - stringList->Add(s); - expr = expr->GetNext(); - } - - wxString title(wxT("Editing ")); - title += property->GetName(); - - if (EditStringList(parentWindow, stringList, title.GetData())) - { - wxPropertyValue& oldValue = property->GetValue(); - oldValue.ClearList(); - wxStringList::Node *node = stringList->GetFirst(); - while (node) - { - wxChar *s = node->GetData(); - oldValue.Append(new wxPropertyValue(s)); - - node = node->GetNext(); - } - - view->DisplayProperty(property); - view->UpdatePropertyDisplayInList(property); - view->OnPropertyChanged(property); - } - delete stringList; -} - -class wxPropertyStringListEditorDialog: public wxDialog -{ - public: - wxPropertyStringListEditorDialog(wxWindow *parent, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxT("stringEditorDialogBox")): - wxDialog(parent, -1, title, pos, size, windowStyle, name) - { - m_stringList = NULL; - m_stringText = NULL; - m_listBox = NULL; - sm_dialogCancelled = FALSE; - m_currentSelection = -1; - } - ~wxPropertyStringListEditorDialog(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); - -public: - wxStringList* m_stringList; - wxListBox* m_listBox; - wxTextCtrl* m_stringText; - static bool sm_dialogCancelled; - int m_currentSelection; -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 - -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_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, - long windowStyle = 0, const wxString& name = wxT("text")): - wxTextCtrl(parent, id, val, pos, size, windowStyle, wxDefaultValidator, name) - { - } - void OnKillFocus() - { - wxPropertyStringListEditorDialog *dialog = (wxPropertyStringListEditorDialog *)GetParent(); - dialog->SaveCurrentSelection(); - } -}; - -bool wxPropertyStringListEditorDialog::sm_dialogCancelled = FALSE; - -// Edit the string list. -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); - - 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->m_stringText = new wxPropertyStringListEditorText(dialog, - wxID_PROP_SL_TEXT, wxT(""), wxPoint(5, 240), - wxSize(300, -1), wxPROCESS_ENTER); - dialog->m_stringText->Enable(FALSE); - - wxButton *addButton = new wxButton(dialog, wxID_PROP_SL_ADD, wxT("Add"), wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - wxButton *deleteButton = new wxButton(dialog, wxID_PROP_SL_DELETE, wxT("Delete"), wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - wxButton *cancelButton = new wxButton(dialog, wxID_CANCEL, wxT("Cancel"), wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - wxButton *okButton = new wxButton(dialog, wxID_OK, wxT("OK"), wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - -#ifndef __WXGTK__ - okButton->SetDefault(); -#endif - - wxLayoutConstraints *c = new wxLayoutConstraints; - - c->top.SameAs (dialog, wxTop, 2); - c->left.SameAs (dialog, wxLeft, 2); - c->right.SameAs (dialog, wxRight, 2); - c->bottom.SameAs (dialog->m_stringText, wxTop, 2); - dialog->m_listBox->SetConstraints(c); - - c = new wxLayoutConstraints; - c->left.SameAs (dialog, wxLeft, 2); - c->right.SameAs (dialog, wxRight, 2); - c->bottom.SameAs (addButton, wxTop, 2); - c->height.AsIs(); - dialog->m_stringText->SetConstraints(c); - - c = new wxLayoutConstraints; - c->bottom.SameAs (dialog, wxBottom, 2); - c->left.SameAs (dialog, wxLeft, 2); - c->width.AsIs(); - c->height.AsIs(); - addButton->SetConstraints(c); - - c = new wxLayoutConstraints; - c->bottom.SameAs (dialog, wxBottom, 2); - c->left.SameAs (addButton, wxRight, 2); - c->width.AsIs(); - c->height.AsIs(); - deleteButton->SetConstraints(c); - - c = new wxLayoutConstraints; - c->bottom.SameAs (dialog, wxBottom, 2); - c->right.SameAs (dialog, wxRight, 2); - c->width.AsIs(); - c->height.AsIs(); - cancelButton->SetConstraints(c); - - c = new wxLayoutConstraints; - c->bottom.SameAs (dialog, wxBottom, 2); - c->right.SameAs (cancelButton, wxLeft, 2); - c->width.AsIs(); - c->height.AsIs(); - okButton->SetConstraints(c); - - wxStringList::Node *node = stringList->GetFirst(); - while (node) - { - wxChar *str = node->GetData(); - // Save node as client data for each listbox item - dialog->m_listBox->Append(str, (wxChar *)node); - node = node->GetNext(); - } - - dialog->SetClientSize(310, 305); - dialog->Layout(); - - dialog->Centre(wxBOTH); - wxEndBusyCursor(); - if (dialog->ShowModal() == wxID_CANCEL) - return FALSE; - else - return TRUE; -} - -/* - * String list editor callbacks - * - */ - -void wxPropertyStringListEditorDialog::OnStrings(wxCommandEvent& WXUNUSED(event)) -{ - int sel = m_listBox->GetSelection(); - if (sel > -1) - { - m_currentSelection = sel; - - ShowCurrentSelection(); - } -} - -void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& WXUNUSED(event)) -{ - 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[] (wxChar *)node->GetData(); - delete node; - m_currentSelection = -1; - m_stringText->SetValue(_T("")); -} - -void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event)) -{ - SaveCurrentSelection(); - - wxString initialText; - wxNode *node = m_stringList->Add(initialText); - m_listBox->Append(initialText, (void *)node); - m_currentSelection = m_stringList->GetCount() - 1; - m_listBox->SetSelection(m_currentSelection); - ShowCurrentSelection(); - m_stringText->SetFocus(); -} - -void wxPropertyStringListEditorDialog::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - SaveCurrentSelection(); - EndModal(wxID_OK); - // Close(TRUE); - this->Destroy(); -} - -void wxPropertyStringListEditorDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) -{ - sm_dialogCancelled = TRUE; - EndModal(wxID_CANCEL); -// Close(TRUE); - this->Destroy(); -} - -void wxPropertyStringListEditorDialog::OnText(wxCommandEvent& event) -{ - if (event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER) - { - SaveCurrentSelection(); - } -} - -void -wxPropertyStringListEditorDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) -{ - SaveCurrentSelection(); - - Destroy(); -} - -void wxPropertyStringListEditorDialog::SaveCurrentSelection() -{ - if (m_currentSelection == -1) - return; - - wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(m_currentSelection); - if (!node) - return; - - wxString txt(m_stringText->GetValue()); - if (node->GetData()) - delete[] (wxChar *)node->GetData(); - node->SetData((wxObject *)wxStrdup(txt)); - - m_listBox->SetString(m_currentSelection, (wxChar *)node->GetData()); -} - -void wxPropertyStringListEditorDialog::ShowCurrentSelection() -{ - if (m_currentSelection == -1) - { - m_stringText->SetValue(wxT("")); - return; - } - wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(m_currentSelection); - wxChar *txt = (wxChar *)node->GetData(); - m_stringText->SetValue(txt); - m_stringText->Enable(TRUE); -} - - -#endif // wxUSE_PROPSHEET -- 2.45.2