1998-12-31 16:15:45 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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_
|
|
|
|
|
2002-08-31 11:29:13 +00:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1998-12-31 16:15:45 +00:00
|
|
|
#pragma interface "prop.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-21 05:23:06 +00:00
|
|
|
#if wxUSE_PROPSHEET
|
|
|
|
|
1998-12-31 16:15:45 +00:00
|
|
|
#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"
|
1999-08-16 20:17:48 +00:00
|
|
|
#include "wx/sizer.h"
|
1998-12-31 16:15:45 +00:00
|
|
|
|
|
|
|
class wxWindow;
|
|
|
|
class wxProperty;
|
|
|
|
class wxPropertyValue;
|
|
|
|
class wxPropertySheet;
|
|
|
|
class wxPropertyView;
|
|
|
|
class wxPropertyValidator;
|
|
|
|
class wxPropertyValidatorRegistry;
|
|
|
|
|
|
|
|
#define wxPROPERTY_VERSION 2.0
|
|
|
|
|
|
|
|
// A storable sheet of values
|
1999-01-08 10:24:35 +00:00
|
|
|
class WXDLLEXPORT wxPropertySheet: public wxObject
|
1998-12-31 16:15:45 +00:00
|
|
|
{
|
2002-12-04 14:11:26 +00:00
|
|
|
public:
|
|
|
|
wxPropertySheet(const wxString& name = wxT(""));
|
|
|
|
~wxPropertySheet();
|
1998-12-31 16:15:45 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
// 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;
|
1999-01-21 17:38:28 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
// Set property name to value
|
|
|
|
virtual bool SetProperty(const wxString& name, const wxPropertyValue& value);
|
1999-01-21 17:38:28 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
// Remove property from sheet by name, deleting it
|
|
|
|
virtual void RemoveProperty(const wxString& name);
|
1999-01-21 17:38:28 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
// Get the name of the sheet
|
|
|
|
// Add a property
|
|
|
|
virtual void AddProperty(wxProperty *property);
|
1998-12-31 16:15:45 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
// Get property by name
|
|
|
|
virtual wxProperty *GetProperty(const wxString& name) const;
|
1998-12-31 16:15:45 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
// Clear all properties
|
|
|
|
virtual void Clear();
|
1998-12-31 16:15:45 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
virtual void UpdateAllViews(wxPropertyView *thisView = NULL);
|
|
|
|
inline virtual wxList& GetProperties() const { return (wxList&) m_properties; }
|
1998-12-31 16:15:45 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
// 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)
|
1998-12-31 16:15:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Base class for property sheet views. There are currently two directly derived
|
|
|
|
// classes: wxPropertyListView, and wxPropertyFormView.
|
1999-01-08 10:24:35 +00:00
|
|
|
class WXDLLEXPORT wxPropertyView: public wxEvtHandler
|
1998-12-31 16:15:45 +00:00
|
|
|
{
|
2002-12-04 14:11:26 +00:00
|
|
|
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)
|
1998-12-31 16:15:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-01-08 10:24:35 +00:00
|
|
|
class WXDLLEXPORT wxPropertyValidator: public wxEvtHandler
|
1998-12-31 16:15:45 +00:00
|
|
|
{
|
2002-12-04 14:11:26 +00:00
|
|
|
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)
|
1998-12-31 16:15:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// extern wxPropertyValidator *wxDefaultPropertyValidator;
|
|
|
|
|
1999-01-08 10:24:35 +00:00
|
|
|
class WXDLLEXPORT wxPropertyValidatorRegistry: public wxHashTable
|
1998-12-31 16:15:45 +00:00
|
|
|
{
|
2002-12-04 14:11:26 +00:00
|
|
|
public:
|
|
|
|
wxPropertyValidatorRegistry();
|
|
|
|
~wxPropertyValidatorRegistry();
|
|
|
|
|
|
|
|
virtual void RegisterValidator(const wxString& roleName, wxPropertyValidator *validator);
|
|
|
|
virtual wxPropertyValidator *GetValidator(const wxString& roleName);
|
|
|
|
void ClearRegistry();
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxPropertyValidatorRegistry)
|
1998-12-31 16:15:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Property value class
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
wxPropertyValueNull,
|
|
|
|
wxPropertyValueInteger,
|
|
|
|
wxPropertyValueReal,
|
|
|
|
wxPropertyValuebool,
|
|
|
|
wxPropertyValueString,
|
|
|
|
wxPropertyValueList,
|
|
|
|
wxPropertyValueIntegerPtr,
|
|
|
|
wxPropertyValueRealPtr,
|
|
|
|
wxPropertyValueboolPtr,
|
|
|
|
wxPropertyValueStringPtr
|
|
|
|
} wxPropertyValueType;
|
|
|
|
|
1999-01-08 10:24:35 +00:00
|
|
|
class WXDLLEXPORT wxPropertyValue: public wxObject
|
1998-12-31 16:15:45 +00:00
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxPropertyValue)
|
|
|
|
|
|
|
|
wxPropertyValue(void); // Unknown type
|
|
|
|
wxPropertyValue(const wxPropertyValue& copyFrom); // Copy constructor
|
1999-04-16 14:14:47 +00:00
|
|
|
wxPropertyValue(const wxChar *val);
|
1998-12-31 16:15:45 +00:00
|
|
|
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
|
1999-04-16 14:14:47 +00:00
|
|
|
wxPropertyValue(wxChar **val);
|
1998-12-31 16:15:45 +00:00
|
|
|
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;
|
1999-04-16 14:14:47 +00:00
|
|
|
virtual wxChar *StringValue(void) const;
|
1998-12-31 16:15:45 +00:00
|
|
|
virtual long *IntegerValuePtr(void) const;
|
|
|
|
virtual float *RealValuePtr(void) const;
|
|
|
|
virtual bool *BoolValuePtr(void) const;
|
1999-04-16 14:14:47 +00:00
|
|
|
virtual wxChar **StringValuePtr(void) const;
|
1998-12-31 16:15:45 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
1999-06-28 13:22:00 +00:00
|
|
|
virtual void WritePropertyClause(wxString &stream); // Write this expression as a top-level clause
|
|
|
|
virtual void WritePropertyType(wxString &stream); // Write as any other subexpression
|
1998-12-31 16:15:45 +00:00
|
|
|
|
|
|
|
// 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);
|
1999-04-16 14:14:47 +00:00
|
|
|
void operator=(const wxChar **val);
|
1998-12-31 16:15:45 +00:00
|
|
|
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
|
1999-04-16 14:14:47 +00:00
|
|
|
wxChar *string;
|
1998-12-31 16:15:45 +00:00
|
|
|
float real;
|
|
|
|
long *integerPtr;
|
|
|
|
bool *boolPtr;
|
1999-04-16 14:14:47 +00:00
|
|
|
wxChar **stringPtr;
|
1998-12-31 16:15:45 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
1999-01-08 10:24:35 +00:00
|
|
|
class WXDLLEXPORT wxProperty: public wxObject
|
1998-12-31 16:15:45 +00:00
|
|
|
{
|
|
|
|
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; }
|
|
|
|
};
|
|
|
|
|
2001-07-21 05:23:06 +00:00
|
|
|
#endif
|
|
|
|
// wxUSE_PROPSHEET
|
|
|
|
|
1998-12-31 16:15:45 +00:00
|
|
|
#endif
|
|
|
|
// _WX_PROP_H_
|