From fd71308fc89eac2dd212b715eba68a993fa78f53 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 9 Oct 1998 12:01:58 +0000 Subject: [PATCH] Dialog unit mods; wxProp tidying git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@816 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 3 + include/wx/gtk/window.h | 21 +- include/wx/gtk1/window.h | 21 +- include/wx/motif/window.h | 26 +- include/wx/msw/window.h | 28 +- include/wx/resource.h | 182 ++++---- include/wx/stubs/window.h | 26 +- include/wx/utils.h | 3 +- src/common/resource.cpp | 769 ++++++++++++++------------------ src/common/tbarsmpl.cpp | 1 - src/common/utilscmn.cpp | 22 +- src/common/wincmn.cpp | 24 + src/generic/panelg.cpp | 2 - src/gtk/treectrl.cpp | 2 +- src/gtk1/treectrl.cpp | 2 +- src/motif/window.cpp | 9 +- src/msw/bmpbuttn.cpp | 4 +- src/msw/button.cpp | 4 +- src/msw/checkbox.cpp | 8 +- src/msw/choice.cpp | 4 +- src/msw/combobox.cpp | 4 +- src/msw/dialog.cpp | 3 - src/msw/gauge95.cpp | 4 +- src/msw/gaugemsw.cpp | 4 +- src/msw/listbox.cpp | 4 +- src/msw/listctrl.cpp | 2 +- src/msw/notebook.cpp | 3 - src/msw/radiobox.cpp | 8 +- src/msw/radiobut.cpp | 8 +- src/msw/scrolbar.cpp | 4 +- src/msw/slider95.cpp | 4 +- src/msw/slidrmsw.cpp | 4 +- src/msw/spinbutt.cpp | 4 +- src/msw/statbmp.cpp | 4 +- src/msw/statbox.cpp | 4 +- src/msw/stattext.cpp | 4 +- src/msw/tabctrl.cpp | 6 - src/msw/tbar95.cpp | 6 - src/msw/textctrl.cpp | 4 +- src/msw/treectrl.cpp | 2 +- src/msw/window.cpp | 8 +- src/stubs/window.cpp | 10 +- utils/dialoged/src/dlghndlr.cpp | 66 ++- utils/dialoged/src/dlghndlr.h | 1 + utils/dialoged/src/edtree.cpp | 4 +- utils/dialoged/src/reseditr.cpp | 93 ++-- utils/dialoged/src/reseditr.h | 16 +- utils/dialoged/src/reswrite.cpp | 95 ++-- utils/dialoged/src/symbtabl.cpp | 2 +- utils/dialoged/src/winprop.cpp | 565 +++++++++++++++-------- utils/dialoged/src/winprop.h | 21 +- utils/wxprop/src/prop.cpp | 620 ++++++++++++------------- utils/wxprop/src/prop.h | 163 +++---- utils/wxprop/src/propform.cpp | 249 +++++------ utils/wxprop/src/propform.h | 90 ++-- utils/wxprop/src/proplist.cpp | 528 +++++++++++----------- utils/wxprop/src/proplist.h | 140 +++--- 57 files changed, 2064 insertions(+), 1854 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 22c8db9a99..3b47ec430b 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -849,6 +849,9 @@ enum { #define wxID_HIGHEST 5999 +// Shortcut for easier dialog-unit-to-pixel conversion +#define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixel(pt) + #ifdef __WXMSW__ // Stand-ins for Windows types, to avoid // #including all of windows.h diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index bd18a96e90..c59a01e25b 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -82,7 +82,7 @@ public: virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = (const wxResourceTable *) NULL); - virtual wxControl *CreateItem( const wxItemResource *childResource, + virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, const wxResourceTable *table = (const wxResourceTable *) NULL); bool Close( bool force = FALSE ); @@ -105,6 +105,14 @@ public: virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 ); + // Dialog units translations. Implemented in wincmn.cpp. + wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; + wxPoint ConvertDialogToPixels(const wxPoint& pt) ; + inline wxSize ConvertPixelsToDialog(const wxSize& sz) + { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + inline wxSize ConvertDialogToPixels(const wxSize& sz) + { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + void OnSize( wxSizeEvent &event ); void OnIdle( wxIdleEvent& event ); @@ -167,15 +175,6 @@ public: int *externalLeading = (int *) NULL, const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const; - virtual void SetDefaultBackgroundColour( const wxColour& col ) - { m_defaultBackgroundColour = col; } - virtual wxColour GetDefaultBackgroundColour() const - { return m_defaultBackgroundColour; } - virtual void SetDefaultForegroundColour( const wxColour& col ) - { m_defaultForegroundColour = col; } - virtual wxColour GetDefaultForegroundColour() const - { return m_defaultForegroundColour; } - virtual void SetFont( const wxFont &font ); virtual wxFont *GetFont(); // For backward compatibility @@ -259,9 +258,7 @@ public: wxCursor *m_cursor; wxFont m_font; wxColour m_backgroundColour; - wxColour m_defaultBackgroundColour; wxColour m_foregroundColour ; - wxColour m_defaultForegroundColour; wxRegion m_updateRegion; long m_windowStyle; bool m_isShown; diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index bd18a96e90..c59a01e25b 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -82,7 +82,7 @@ public: virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = (const wxResourceTable *) NULL); - virtual wxControl *CreateItem( const wxItemResource *childResource, + virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, const wxResourceTable *table = (const wxResourceTable *) NULL); bool Close( bool force = FALSE ); @@ -105,6 +105,14 @@ public: virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 ); + // Dialog units translations. Implemented in wincmn.cpp. + wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; + wxPoint ConvertDialogToPixels(const wxPoint& pt) ; + inline wxSize ConvertPixelsToDialog(const wxSize& sz) + { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + inline wxSize ConvertDialogToPixels(const wxSize& sz) + { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + void OnSize( wxSizeEvent &event ); void OnIdle( wxIdleEvent& event ); @@ -167,15 +175,6 @@ public: int *externalLeading = (int *) NULL, const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const; - virtual void SetDefaultBackgroundColour( const wxColour& col ) - { m_defaultBackgroundColour = col; } - virtual wxColour GetDefaultBackgroundColour() const - { return m_defaultBackgroundColour; } - virtual void SetDefaultForegroundColour( const wxColour& col ) - { m_defaultForegroundColour = col; } - virtual wxColour GetDefaultForegroundColour() const - { return m_defaultForegroundColour; } - virtual void SetFont( const wxFont &font ); virtual wxFont *GetFont(); // For backward compatibility @@ -259,9 +258,7 @@ public: wxCursor *m_cursor; wxFont m_font; wxColour m_backgroundColour; - wxColour m_defaultBackgroundColour; wxColour m_foregroundColour ; - wxColour m_defaultForegroundColour; wxRegion m_updateRegion; long m_windowStyle; bool m_isShown; diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index 0a24b42900..e369869d9e 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -318,15 +318,6 @@ public: inline virtual void SetForegroundColour(const wxColour& col); inline virtual wxColour GetForegroundColour() const; - // Set/get window default background colour (for children to inherit). - // NOTE: these may be removed in later revisions. - inline virtual void SetDefaultBackgroundColour(const wxColour& col); - inline virtual wxColour GetDefaultBackgroundColour(void) const; - - // Set/get window default foreground colour (for children to inherit) - inline virtual void SetDefaultForegroundColour(const wxColour& col); - inline virtual wxColour GetDefaultForegroundColour(void) const; - // Get the default button, if there is one inline virtual wxButton *GetDefaultItem() const; inline virtual void SetDefaultItem(wxButton *but); @@ -338,7 +329,8 @@ public: // Resource loading #if wxUSE_WX_RESOURCES virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL); - virtual wxControl *CreateItem(const wxItemResource *childResource, const wxResourceTable *table = NULL); + virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, + const wxResourceTable *table = (const wxResourceTable *) NULL); #endif virtual void GetTextExtent(const wxString& string, int *x, int *y, @@ -436,6 +428,14 @@ public: virtual void GetClientSizeConstraint(int *w, int *h) const ; virtual void GetPositionConstraint(int *x, int *y) const ; + // Dialog units translations. Implemented in wincmn.cpp. + wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; + wxPoint ConvertDialogToPixels(const wxPoint& pt) ; + inline wxSize ConvertPixelsToDialog(const wxSize& sz) + { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + inline wxSize ConvertDialogToPixels(const wxSize& sz) + { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + wxObject *GetChild(int number) const ; // Generates a new id for controls @@ -528,8 +528,6 @@ protected: wxColour m_backgroundColour ; wxColour m_foregroundColour ; - wxColour m_defaultBackgroundColour; - wxColour m_defaultForegroundColour; wxAcceleratorTable m_acceleratorTable; #if wxUSE_DRAG_AND_DROP @@ -598,10 +596,6 @@ inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundCol inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; }; inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; }; inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; }; -inline void wxWindow::SetDefaultForegroundColour(const wxColour& col) { m_defaultForegroundColour = col; }; -inline wxColour wxWindow::GetDefaultForegroundColour(void) const { return m_defaultForegroundColour; }; -inline void wxWindow::SetDefaultBackgroundColour(const wxColour& col) { m_defaultBackgroundColour = col; }; -inline wxColour wxWindow::GetDefaultBackgroundColour(void) const { return m_defaultBackgroundColour; }; inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; } inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; } diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 21952c2721..7573e0b6e2 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -330,15 +330,6 @@ public: inline virtual void SetForegroundColour(const wxColour& col); inline virtual wxColour GetForegroundColour(void) const; - // TODO: are these really necessary??? - // Set/get window default background colour (for children to inherit) - inline virtual void SetDefaultBackgroundColour(const wxColour& col); - inline virtual wxColour GetDefaultBackgroundColour(void) const; - - // Set/get window default foreground colour (for children to inherit) - inline virtual void SetDefaultForegroundColour(const wxColour& col); - inline virtual wxColour GetDefaultForegroundColour(void) const; - // For backward compatibility inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } @@ -359,7 +350,7 @@ public: // Resource loading #if wxUSE_WX_RESOURCES virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL); - virtual wxControl *CreateItem(const wxItemResource *childResource, const wxResourceTable *table = NULL); + virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, const wxResourceTable *table = NULL); #endif // Native resource loading @@ -474,6 +465,14 @@ public: virtual void GetClientSizeConstraint(int *w, int *h) const ; virtual void GetPositionConstraint(int *x, int *y) const ; + // Dialog units translations. Implemented in wincmn.cpp. + wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; + wxPoint ConvertDialogToPixels(const wxPoint& pt) ; + inline wxSize ConvertPixelsToDialog(const wxSize& sz) + { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + inline wxSize ConvertDialogToPixels(const wxSize& sz) + { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + wxObject *GetChild(int number) const ; void MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title, @@ -638,13 +637,8 @@ protected: #endif wxButton * m_defaultItem; - wxColour m_backgroundColour ; - wxColour m_defaultBackgroundColour; - wxColour m_foregroundColour ; - wxColour m_defaultForegroundColour; - bool m_backgroundTransparent; int m_xThumbSize; @@ -710,10 +704,6 @@ inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundCol inline wxColour wxWindow::GetBackgroundColour(void) const { return m_backgroundColour; }; inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; }; inline wxColour wxWindow::GetForegroundColour(void) const { return m_foregroundColour; }; -inline void wxWindow::SetDefaultForegroundColour(const wxColour& col) { m_defaultForegroundColour = col; }; -inline wxColour wxWindow::GetDefaultForegroundColour(void) const { return m_defaultForegroundColour; }; -inline void wxWindow::SetDefaultBackgroundColour(const wxColour& col) { m_defaultBackgroundColour = col; }; -inline wxColour wxWindow::GetDefaultBackgroundColour(void) const { return m_defaultBackgroundColour; }; inline wxButton *wxWindow::GetDefaultItem(void) const { return m_defaultItem; } inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; } diff --git a/include/wx/resource.h b/include/wx/resource.h index 9492193a47..2cfbe992ad 100644 --- a/include/wx/resource.h +++ b/include/wx/resource.h @@ -31,6 +31,17 @@ #define RESOURCE_PLATFORM_MAC 3 #define RESOURCE_PLATFORM_ANY 4 +// Extended styles: for resource usage only + +// Use dialog units instead of pixels +#define wxRESOURCE_DIALOG_UNITS 1 +// Use default system colour and font +#define wxRESOURCE_USE_DEFAULTS 2 + +// Macros to help use dialog units +#define wxDLG_POINT(x, y, parent, useDlgUnits) (useDlgUnits ? parent->ConvertDialogToPixel(wxPoint(x, y)) : wxPoint(x, y)) +#define wxDLG_SIZE(x, y, parent, useDlgUnits) (useDlgUnits ? parent->ConvertDialogToPixel(wxSize(x, y)) : wxSize(x, y)) + /* * Internal format for control/panel item */ @@ -39,71 +50,76 @@ class WXDLLEXPORT wxItemResource: public wxObject { DECLARE_DYNAMIC_CLASS(wxItemResource) - protected: - wxList children; - char *itemType; - int x, y, width, height; - char *title; - char *name; - long windowStyle; - long value1, value2, value3, value5; - char *value4; - int m_windowId; - wxStringList *stringValues; // Optional string values - wxBitmap *bitmap; - wxColour *backgroundColour; - wxColour *labelColour; - wxColour *buttonColour; - wxFont *windowFont; public: - wxItemResource(void); - ~wxItemResource(void); + wxItemResource(); + ~wxItemResource(); - void SetType(char *typ); - inline void SetStyle(long styl) { windowStyle = styl; } + inline void SetType(const wxString& type) { m_itemType = type; } + inline void SetStyle(long styl) { m_windowStyle = styl; } inline void SetId(int id) { m_windowId = id; } - inline void SetBitmap(wxBitmap *bm) { bitmap = bm; } - inline wxBitmap *GetBitmap(void) { return bitmap; } - inline void SetFont(wxFont *font) { windowFont = font; } - inline wxFont *GetFont(void) { return windowFont; } + inline void SetBitmap(const wxBitmap& bm) { m_bitmap = bm; } + inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; } + inline void SetFont(const wxFont& font) { m_windowFont = font; } + inline wxFont& GetFont() const { return (wxFont&) m_windowFont; } inline void SetSize(int xx, int yy, int ww, int hh) - { x = xx; y = yy; width = ww; height = hh; } - void SetTitle(char *t); - void SetName(char *n); - inline void SetValue1(long v) { value1 = v; } - inline void SetValue2(long v) { value2 = v; } - inline void SetValue3(long v) { value3 = v; } - inline void SetValue5(long v) { value5 = v; } - void SetValue4(char *v); - void SetStringValues(wxStringList *svalues); - - inline char *GetType(void) { return itemType; } - inline int GetX(void) { return x; } - inline int GetY(void) { return y; } - inline int GetWidth(void) { return width; } - inline int GetHeight(void) { return height; } - - inline char *GetTitle(void) { return title; } - inline char *GetName(void) { return name; } - inline long GetStyle(void) { return windowStyle; } - inline int GetId(void) { return m_windowId; } - - inline long GetValue1(void) { return value1; } - inline long GetValue2(void) { return value2; } - inline long GetValue3(void) { return value3; } - inline long GetValue5(void) { return value5; } - inline char *GetValue4(void) { return value4; } - inline wxList& GetChildren(void) { return children; } - inline wxStringList *GetStringValues(void) { return stringValues; } - - inline void SetBackgroundColour(wxColour *col) { if (backgroundColour) delete backgroundColour; backgroundColour = col; } - inline void SetLabelColour(wxColour *col) { if (labelColour) delete labelColour; labelColour = col; } - inline void SetButtonColour(wxColour *col) { if (buttonColour) delete buttonColour; buttonColour = col; } + { m_x = xx; m_y = yy; m_width = ww; m_height = hh; } + inline void SetTitle(const wxString& title) { m_title = title; } + inline void SetName(const wxString& name) { m_name = name; } + inline void SetValue1(long v) { m_value1 = v; } + inline void SetValue2(long v) { m_value2 = v; } + inline void SetValue3(long v) { m_value3 = v; } + inline void SetValue5(long v) { m_value5 = v; } + inline void SetValue4(const wxString& v) { m_value4 = v; } + inline void SetStringValues(const wxStringList& svalues) { m_stringValues = svalues; } + + inline wxString GetType() const { return m_itemType; } + inline int GetX() const { return m_x; } + inline int GetY() const { return m_y; } + inline int GetWidth() const { return m_width; } + inline int GetHeight() const { return m_height; } + + inline wxString GetTitle() const { return m_title; } + inline wxString GetName() const { return m_name; } + inline long GetStyle() const { return m_windowStyle; } + inline int GetId() const { return m_windowId; } + + inline long GetValue1() const { return m_value1; } + inline long GetValue2() const { return m_value2; } + inline long GetValue3() const { return m_value3; } + inline long GetValue5() const { return m_value5; } + inline wxString GetValue4() const { return m_value4; } + inline wxList& GetChildren() const { return (wxList&) m_children; } + inline wxStringList& GetStringValues() const { return (wxStringList&) m_stringValues; } + + inline void SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; } + inline void SetLabelColour(const wxColour& col) { m_labelColour = col; } + inline void SetButtonColour(const wxColour& col) { m_buttonColour = col; } - inline wxColour *GetBackgroundColour(void) { return backgroundColour; } - inline wxColour *GetLabelColour(void) { return labelColour; } - inline wxColour *GetButtonColour(void) { return buttonColour; } + inline wxColour& GetBackgroundColour() const { return (wxColour&) m_backgroundColour; } + inline wxColour& GetLabelColour() const { return (wxColour&) m_labelColour; } + inline wxColour& GetButtonColour() const { return (wxColour&) m_buttonColour; } + + inline void SetResourceStyle(long style) { m_exStyle = style; } + inline long GetResourceStyle() const { return m_exStyle; } + + protected: + wxList m_children; + wxString m_itemType; + int m_x, m_y, m_width, m_height; + wxString m_title; + wxString m_name; + long m_windowStyle; + long m_value1, m_value2, m_value3, m_value5; + wxString m_value4; + int m_windowId; + wxStringList m_stringValues; // Optional string values + wxBitmap m_bitmap; + wxColour m_backgroundColour; + wxColour m_labelColour; + wxColour m_buttonColour; + wxFont m_windowFont; + long m_exStyle; // Extended, resource-specific styles }; /* @@ -119,55 +135,55 @@ class WXDLLEXPORT wxResourceTable: public wxHashTable public: wxHashTable identifiers; - wxResourceTable(void); - ~wxResourceTable(void); - + wxResourceTable(); + ~wxResourceTable(); + virtual wxItemResource *FindResource(const wxString& name) const; virtual void AddResource(wxItemResource *item); virtual bool DeleteResource(const wxString& name); - virtual bool ParseResourceFile(char *filename); - virtual bool ParseResourceData(char *data); - virtual bool SaveResource(char *filename); + virtual bool ParseResourceFile(const wxString& filename); + virtual bool ParseResourceData(const wxString& data); + virtual bool SaveResource(const wxString& filename); // Register XBM/XPM data - virtual bool RegisterResourceBitmapData(char *name, char bits[], int width, int height); - virtual bool RegisterResourceBitmapData(char *name, char **data); + virtual bool RegisterResourceBitmapData(const wxString& name, char bits[], int width, int height); + virtual bool RegisterResourceBitmapData(const wxString& name, char **data); - virtual wxControl *CreateItem(wxWindow *panel, wxItemResource *childResource) const; + virtual wxControl *CreateItem(wxWindow *panel, const wxItemResource* childResource, const wxItemResource* parentResource) const; - virtual void ClearTable(void); + virtual void ClearTable(); }; -extern void WXDLLEXPORT wxInitializeResourceSystem(void); -extern void WXDLLEXPORT wxCleanUpResourceSystem(void); +extern void WXDLLEXPORT wxInitializeResourceSystem(); +extern void WXDLLEXPORT wxCleanUpResourceSystem(); WXDLLEXPORT_DATA(extern wxResourceTable*) wxDefaultResourceTable; -extern long WXDLLEXPORT wxParseWindowStyle(char *style); +extern long WXDLLEXPORT wxParseWindowStyle(const wxString& style); class WXDLLEXPORT wxMenuBar; class WXDLLEXPORT wxMenu; class WXDLLEXPORT wxBitmap; class WXDLLEXPORT wxIcon; -extern wxBitmap* WXDLLEXPORT wxResourceCreateBitmap(char *resource, wxResourceTable *table = (wxResourceTable *) NULL); -extern wxIcon* WXDLLEXPORT wxResourceCreateIcon(char *resource, wxResourceTable *table = (wxResourceTable *) NULL); -extern wxMenuBar* WXDLLEXPORT wxResourceCreateMenuBar(char *resource, wxResourceTable *table = (wxResourceTable *) NULL, wxMenuBar *menuBar = (wxMenuBar *) NULL); -extern wxMenu* WXDLLEXPORT wxResourceCreateMenu(char *resource, wxResourceTable *table = (wxResourceTable *) NULL); -extern bool WXDLLEXPORT wxResourceParseData(char *resource, wxResourceTable *table = (wxResourceTable *) NULL); -extern bool WXDLLEXPORT wxResourceParseFile(char *filename, wxResourceTable *table = (wxResourceTable *) NULL); -extern bool WXDLLEXPORT wxResourceParseString(char *s, wxResourceTable *table = (wxResourceTable *) NULL); +extern wxBitmap WXDLLEXPORT wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL); +extern wxIcon WXDLLEXPORT wxResourceCreateIcon(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL); +extern wxMenuBar* WXDLLEXPORT wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL, wxMenuBar *menuBar = (wxMenuBar *) NULL); +extern wxMenu* WXDLLEXPORT wxResourceCreateMenu(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL); +extern bool WXDLLEXPORT wxResourceParseData(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL); +extern bool WXDLLEXPORT wxResourceParseFile(const wxString& filename, wxResourceTable *table = (wxResourceTable *) NULL); +extern bool WXDLLEXPORT wxResourceParseString(const wxString& s, wxResourceTable *table = (wxResourceTable *) NULL); extern void WXDLLEXPORT wxResourceClear(wxResourceTable *table = (wxResourceTable *) NULL); // Register XBM/XPM data -extern bool WXDLLEXPORT wxResourceRegisterBitmapData(char *name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL); -extern bool WXDLLEXPORT wxResourceRegisterBitmapData(char *name, char **data, wxResourceTable *table = (wxResourceTable *) NULL); +extern bool WXDLLEXPORT wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL); +extern bool WXDLLEXPORT wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceTable *table = (wxResourceTable *) NULL); #define wxResourceRegisterIconData wxResourceRegisterBitmapData /* * Resource identifer code: #define storage */ -extern bool WXDLLEXPORT wxResourceAddIdentifier(char *name, int value, wxResourceTable *table = (wxResourceTable *) NULL); -extern int WXDLLEXPORT wxResourceGetIdentifier(char *name, wxResourceTable *table = (wxResourceTable *) NULL); +extern bool WXDLLEXPORT wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *table = (wxResourceTable *) NULL); +extern int WXDLLEXPORT wxResourceGetIdentifier(const wxString& name, wxResourceTable *table = (wxResourceTable *) NULL); #endif #endif diff --git a/include/wx/stubs/window.h b/include/wx/stubs/window.h index be71083d4a..5f75da3346 100644 --- a/include/wx/stubs/window.h +++ b/include/wx/stubs/window.h @@ -318,15 +318,6 @@ public: inline virtual void SetForegroundColour(const wxColour& col); inline virtual wxColour GetForegroundColour() const; - // Set/get window default background colour (for children to inherit). - // NOTE: these may be removed in later revisions. - inline virtual void SetDefaultBackgroundColour(const wxColour& col); - inline virtual wxColour GetDefaultBackgroundColour(void) const; - - // Set/get window default foreground colour (for children to inherit) - inline virtual void SetDefaultForegroundColour(const wxColour& col); - inline virtual wxColour GetDefaultForegroundColour(void) const; - // Get the default button, if there is one inline virtual wxButton *GetDefaultItem() const; inline virtual void SetDefaultItem(wxButton *but); @@ -338,7 +329,8 @@ public: // Resource loading #if wxUSE_WX_RESOURCES virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL); - virtual wxControl *CreateItem(const wxItemResource *childResource, const wxResourceTable *table = NULL); + virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, + const wxResourceTable *table = (const wxResourceTable *) NULL); #endif virtual void GetTextExtent(const wxString& string, int *x, int *y, @@ -436,6 +428,14 @@ public: virtual void GetClientSizeConstraint(int *w, int *h) const ; virtual void GetPositionConstraint(int *x, int *y) const ; + // Dialog units translations. Implemented in wincmn.cpp. + wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; + wxPoint ConvertDialogToPixels(const wxPoint& pt) ; + inline wxSize ConvertPixelsToDialog(const wxSize& sz) + { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + inline wxSize ConvertDialogToPixels(const wxSize& sz) + { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } + wxObject *GetChild(int number) const ; // Generates a new id for controls @@ -482,8 +482,6 @@ protected: wxColour m_backgroundColour ; wxColour m_foregroundColour ; - wxColour m_defaultBackgroundColour; - wxColour m_defaultForegroundColour; wxAcceleratorTable m_acceleratorTable; #if wxUSE_DRAG_AND_DROP @@ -522,10 +520,6 @@ inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundCol inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; }; inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; }; inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; }; -inline void wxWindow::SetDefaultForegroundColour(const wxColour& col) { m_defaultForegroundColour = col; }; -inline wxColour wxWindow::GetDefaultForegroundColour(void) const { return m_defaultForegroundColour; }; -inline void wxWindow::SetDefaultBackgroundColour(const wxColour& col) { m_defaultBackgroundColour = col; }; -inline wxColour wxWindow::GetDefaultBackgroundColour(void) const { return m_defaultBackgroundColour; }; inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; } inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; } diff --git a/include/wx/utils.h b/include/wx/utils.h index 46cbc9bf85..8a05c97a83 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -91,10 +91,11 @@ bool WXDLLEXPORT StringMatch(char *one, char *two, bool subString = TRUE, bool e #define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0)) // Convert 2-digit hex number to decimal -int WXDLLEXPORT wxHexToDec(char *buf); +int WXDLLEXPORT wxHexToDec(const wxString& buf); // Convert decimal integer to 2-character hex string void WXDLLEXPORT wxDecToHex(int dec, char *buf); +wxString WXDLLEXPORT wxDecToHex(int dec); // Execute another program. Returns 0 if there was an error, a PID otherwise. long WXDLLEXPORT wxExecute(char **argv, bool sync = FALSE, diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 3104e89a8f..9198586a1f 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -70,19 +70,19 @@ #include "wx/wxexpr.h" // Forward (private) declarations -bool wxResourceInterpretResources(wxResourceTable& table, PrologDatabase& db); -wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *expr, bool isPanel = FALSE); -wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretString(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretBitmap(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, PrologExpr *expr); +bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db); +wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel = FALSE); +wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretString(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretBitmap(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, wxExpr *expr); // Interpret list expression -wxFont *wxResourceInterpretFontSpec(PrologExpr *expr); +wxFont wxResourceInterpretFontSpec(wxExpr *expr); -bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResourceTable *table = (wxResourceTable *) NULL); -bool wxResourceParseIncludeFile(char *f, wxResourceTable *table = (wxResourceTable *) NULL); +bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table = (wxResourceTable *) NULL); +bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table = (wxResourceTable *) NULL); wxResourceTable *wxDefaultResourceTable = (wxResourceTable *) NULL; @@ -91,12 +91,12 @@ static long wxResourceBufferSize = 0; static long wxResourceBufferCount = 0; static int wxResourceStringPtr = 0; -void wxInitializeResourceSystem(void) +void wxInitializeResourceSystem() { wxDefaultResourceTable = new wxResourceTable; } -void wxCleanUpResourceSystem(void) +void wxCleanUpResourceSystem() { delete wxDefaultResourceTable; if (wxResourceBuffer) @@ -113,115 +113,40 @@ IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable) #endif -wxItemResource::wxItemResource(void) +wxItemResource::wxItemResource() { - itemType = (char *) NULL; - title = (char *) NULL; - name = (char *) NULL; - windowStyle = 0; - x = y = width = height = 0; - value1 = value2 = value3 = value5 = 0; - value4 = (char *) NULL; - stringValues = (wxStringList *) NULL; - bitmap = (wxBitmap *) NULL; - backgroundColour = labelColour = buttonColour = (wxColour *) NULL; - windowFont = (wxFont *) NULL; + m_itemType = ""; + m_title = ""; + m_name = ""; + m_windowStyle = 0; + m_x = m_y = m_width = m_height = 0; + m_value1 = m_value2 = m_value3 = m_value5 = 0; + m_value4 = ""; m_windowId = 0; + m_exStyle = 0; } -wxItemResource::~wxItemResource(void) +wxItemResource::~wxItemResource() { - if (itemType) delete[] itemType; - if (title) delete[] title; - if (name) delete[] name; - if (value4) delete[] value4; - if (stringValues) - delete stringValues; - if (bitmap) - delete bitmap; - if (backgroundColour) - delete backgroundColour; - if (labelColour) - delete labelColour; - if (buttonColour) - delete buttonColour; - wxNode *node = children.First(); + wxNode *node = m_children.First(); while (node) { wxItemResource *item = (wxItemResource *)node->Data(); delete item; delete node; - node = children.First(); + node = m_children.First(); } } -void wxItemResource::SetTitle(char *t) -{ - if (t == title) - return; - - if (title) delete[] title; - if (t) - title = copystring(t); - else - title = (char *) NULL; -} - -void wxItemResource::SetType(char *t) -{ - if (itemType == t) - return; - - if (itemType) delete[] itemType; - if (t) - itemType = copystring(t); - else - itemType = (char *) NULL; -} - -void wxItemResource::SetName(char *n) -{ - if (n == name) - return; - - if (name) delete[] name; - if (n) - name = copystring(n); - else - name = (char *) NULL; -} - -void wxItemResource::SetStringValues(wxStringList *svalues) -{ - if (stringValues) - delete stringValues; - if (svalues) - stringValues = svalues; - else - stringValues = (wxStringList *) NULL; -} - -void wxItemResource::SetValue4(char *v) -{ - if (value4 == v) - return; - - if (value4) delete[] value4; - if (v) - value4 = copystring(v); - else - value4 = (char *) NULL; -} - /* * Resource table */ -wxResourceTable::wxResourceTable(void):wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING) +wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING) { } -wxResourceTable::~wxResourceTable(void) +wxResourceTable::~wxResourceTable() { ClearTable(); } @@ -234,10 +159,10 @@ wxItemResource *wxResourceTable::FindResource(const wxString& name) const void wxResourceTable::AddResource(wxItemResource *item) { - char *name = item->GetName(); - if (!name) + wxString name = item->GetName(); + if (name == "") name = item->GetTitle(); - if (!name) + if (name == "") name = "no name"; // Delete existing resource, if any. @@ -272,11 +197,11 @@ bool wxResourceTable::DeleteResource(const wxString& name) return FALSE; } -bool wxResourceTable::ParseResourceFile(char *filename) +bool wxResourceTable::ParseResourceFile(const wxString& filename) { - PrologDatabase db; + wxExprDatabase db; - FILE *fd = fopen(filename, "r"); + FILE *fd = fopen((const char*) filename, "r"); if (!fd) return FALSE; bool eof = FALSE; @@ -288,10 +213,10 @@ bool wxResourceTable::ParseResourceFile(char *filename) return wxResourceInterpretResources(*this, db); } -bool wxResourceTable::ParseResourceData(char *data) +bool wxResourceTable::ParseResourceData(const wxString& data) { - PrologDatabase db; - if (!db.ReadPrologFromString(data)) + wxExprDatabase db; + if (!db.ReadFromString(data)) { wxLogWarning(_("Ill-formed resource file syntax.")); return FALSE; @@ -300,7 +225,7 @@ bool wxResourceTable::ParseResourceData(char *data) return wxResourceInterpretResources(*this, db); } -bool wxResourceTable::RegisterResourceBitmapData(char *name, char bits[], int width, int height) +bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char bits[], int width, int height) { // Register pre-loaded bitmap data wxItemResource *item = new wxItemResource; @@ -314,7 +239,7 @@ bool wxResourceTable::RegisterResourceBitmapData(char *name, char bits[], int wi return TRUE; } -bool wxResourceTable::RegisterResourceBitmapData(char *name, char **data) +bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char **data) { // Register pre-loaded bitmap data wxItemResource *item = new wxItemResource; @@ -326,12 +251,12 @@ bool wxResourceTable::RegisterResourceBitmapData(char *name, char **data) return TRUE; } -bool wxResourceTable::SaveResource(char *WXUNUSED(filename)) +bool wxResourceTable::SaveResource(const wxString& WXUNUSED(filename)) { return FALSE; } -void wxResourceTable::ClearTable(void) +void wxResourceTable::ClearTable() { BeginFind(); wxNode *node = Next(); @@ -345,78 +270,82 @@ void wxResourceTable::ClearTable(void) } } -wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childResource) const +wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* childResource, const wxItemResource* parentResource) const { int id = childResource->GetId(); if ( id == 0 ) id = -1; + bool dlgUnits = ((parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0); + wxControl *control = (wxControl *) NULL; wxString itemType(childResource->GetType()); + + wxPoint pos; + wxSize size; + if (dlgUnits) + { + pos = parent->ConvertDialogToPixels(wxPoint(childResource->GetX(), childResource->GetY())); + size = parent->ConvertDialogToPixels(wxSize(childResource->GetWidth(), childResource->GetHeight())); + } + else + { + pos = wxPoint(childResource->GetX(), childResource->GetY()); + size = wxSize(childResource->GetWidth(), childResource->GetHeight()); + } + if (itemType == wxString("wxButton") || itemType == wxString("wxBitmapButton")) { - if (childResource->GetValue4()) + if (childResource->GetValue4() != "") { // Bitmap button - wxBitmap *bitmap = childResource->GetBitmap(); - if (!bitmap) + wxBitmap bitmap = childResource->GetBitmap(); + if (!bitmap.Ok()) { bitmap = wxResourceCreateBitmap(childResource->GetValue4(), (wxResourceTable *)this); - childResource->SetBitmap(bitmap); + ((wxItemResource*) childResource)->SetBitmap(bitmap); } - if (bitmap) - control = new wxBitmapButton(parent, id, *bitmap, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + if (bitmap.Ok()) + control = new wxBitmapButton(parent, id, bitmap, pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } else // Normal, text button - control = new wxButton(parent, id, childResource->GetTitle(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxButton(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } else if (itemType == wxString("wxMessage") || itemType == wxString("wxStaticText") || itemType == wxString("wxStaticBitmap")) { - if (childResource->GetValue4()) + if (childResource->GetValue4() != "") { // Bitmap message - wxBitmap *bitmap = childResource->GetBitmap(); - if (!bitmap) + wxBitmap bitmap = childResource->GetBitmap(); + if (!bitmap.Ok()) { bitmap = wxResourceCreateBitmap(childResource->GetValue4(), (wxResourceTable *)this); - childResource->SetBitmap(bitmap); + ((wxItemResource*) childResource)->SetBitmap(bitmap); } #if wxUSE_BITMAP_MESSAGE - if (bitmap) - control = new wxStaticBitmap(parent, id, *bitmap, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + if (bitmap.Ok()) + control = new wxStaticBitmap(parent, id, bitmap, pos, size, childResource->GetStyle(), childResource->GetName()); #endif } else { - control = new wxStaticText(parent, id, childResource->GetTitle(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxStaticText(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), childResource->GetName()); } } else if (itemType == wxString("wxText") || itemType == wxString("wxTextCtrl") || itemType == wxString("wxMultiText")) { - control = new wxTextCtrl(parent, id, childResource->GetValue4(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxTextCtrl(parent, id, childResource->GetValue4(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } else if (itemType == wxString("wxCheckBox")) { - control = new wxCheckBox(parent, id, childResource->GetTitle(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxCheckBox(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); ((wxCheckBox *)control)->SetValue((childResource->GetValue1() != 0)); @@ -424,9 +353,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe #if wxUSE_GAUGE else if (itemType == wxString("wxGauge")) { - control = new wxGauge(parent, id, (int)childResource->GetValue2(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxGauge(parent, id, (int)childResource->GetValue2(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); ((wxGauge *)control)->SetValue((int)childResource->GetValue1()); @@ -436,17 +363,14 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe else if (itemType == wxString("wxRadioButton")) { control = new wxRadioButton(parent, id, childResource->GetTitle(), // (int)childResource->GetValue1(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } #endif #if wxUSE_SCROLLBAR else if (itemType == wxString("wxScrollBar")) { - control = new wxScrollBar(parent, id, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxScrollBar(parent, id, pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); ((wxScrollBar *)control)->SetValue((int)childResource->GetValue1()); ((wxScrollBar *)control)->SetPageSize((int)childResource->GetValue2()); @@ -457,28 +381,24 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe else if (itemType == wxString("wxSlider")) { control = new wxSlider(parent, id, (int)childResource->GetValue1(), - (int)childResource->GetValue2(), (int)childResource->GetValue3(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + (int)childResource->GetValue2(), (int)childResource->GetValue3(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } else if (itemType == wxString("wxGroupBox") || itemType == wxString("wxStaticBox")) { - control = new wxStaticBox(parent, id, childResource->GetTitle(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxStaticBox(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), childResource->GetName()); } else if (itemType == wxString("wxListBox")) { - wxStringList *stringList = childResource->GetStringValues(); + wxStringList& stringList = childResource->GetStringValues(); wxString *strings = (wxString *) NULL; int noStrings = 0; - if (stringList && (stringList->Number() > 0)) + if (stringList.Number() > 0) { - noStrings = stringList->Number(); + noStrings = stringList.Number(); strings = new wxString[noStrings]; - wxNode *node = stringList->First(); + wxNode *node = stringList.First(); int i = 0; while (node) { @@ -487,9 +407,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe node = node->Next(); } } - control = new wxListBox(parent, id, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxListBox(parent, id, pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); if (strings) @@ -497,14 +415,14 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe } else if (itemType == wxString("wxChoice")) { - wxStringList *stringList = childResource->GetStringValues(); + wxStringList& stringList = childResource->GetStringValues(); wxString *strings = (wxString *) NULL; int noStrings = 0; - if (stringList && (stringList->Number() > 0)) + if (stringList.Number() > 0) { - noStrings = stringList->Number(); + noStrings = stringList.Number(); strings = new wxString[noStrings]; - wxNode *node = stringList->First(); + wxNode *node = stringList.First(); int i = 0; while (node) { @@ -513,9 +431,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe node = node->Next(); } } - control = new wxChoice(parent, id, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxChoice(parent, id, pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); if (strings) @@ -524,14 +440,14 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe #if wxUSE_COMBOBOX else if (itemType == wxString("wxComboBox")) { - wxStringList *stringList = childResource->GetStringValues(); + wxStringList& stringList = childResource->GetStringValues(); wxString *strings = (wxString *) NULL; int noStrings = 0; - if (stringList && (stringList->Number() > 0)) + if (stringList.Number() > 0) { - noStrings = stringList->Number(); + noStrings = stringList.Number(); strings = new wxString[noStrings]; - wxNode *node = stringList->First(); + wxNode *node = stringList.First(); int i = 0; while (node) { @@ -540,9 +456,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe node = node->Next(); } } - control = new wxComboBox(parent, id, childResource->GetValue4(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxComboBox(parent, id, childResource->GetValue4(), pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); if (strings) @@ -551,14 +465,14 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe #endif else if (itemType == wxString("wxRadioBox")) { - wxStringList *stringList = childResource->GetStringValues(); + wxStringList& stringList = childResource->GetStringValues(); wxString *strings = (wxString *) NULL; int noStrings = 0; - if (stringList && (stringList->Number() > 0)) + if (stringList.Number() > 0) { - noStrings = stringList->Number(); + noStrings = stringList.Number(); strings = new wxString[noStrings]; - wxNode *node = stringList->First(); + wxNode *node = stringList.First(); int i = 0; while (node) { @@ -567,9 +481,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe node = node->Next(); } } - control = new wxRadioBox(parent, (wxWindowID) id, wxString(childResource->GetTitle()), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxRadioBox(parent, (wxWindowID) id, wxString(childResource->GetTitle()), pos, size, noStrings, strings, (int)childResource->GetValue1(), childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); @@ -577,8 +489,15 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe delete[] strings; } - if (control && childResource->GetFont()) - control->SetFont(*childResource->GetFont()); + if ((parentResource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) + { + // Don't set font; will be inherited from parent. + } + else + { + if (control && childResource->GetFont().Ok()) + control->SetFont(childResource->GetFont()); + } return control; } @@ -586,12 +505,12 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe * Interpret database as a series of resources */ -bool wxResourceInterpretResources(wxResourceTable& table, PrologDatabase& db) +bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db) { wxNode *node = db.First(); while (node) { - PrologExpr *clause = (PrologExpr *)node->Data(); + wxExpr *clause = (wxExpr *)node->Data(); wxString functor(clause->Functor()); wxItemResource *item = (wxItemResource *) NULL; @@ -613,7 +532,7 @@ bool wxResourceInterpretResources(wxResourceTable& table, PrologDatabase& db) if (item) { // Remove any existing resource of same name - if (item->GetName()) + if (item->GetName() != "") table.DeleteResource(item->GetName()); table.AddResource(item); } @@ -640,19 +559,19 @@ static bool wxIsValidControlClass(const wxString& c) return FALSE; } -wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *expr, bool isPanel) +wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel) { wxItemResource *dialogItem = new wxItemResource; if (isPanel) dialogItem->SetType("wxPanel"); else dialogItem->SetType("wxDialog"); - char *style = (char *) NULL; - char *title = (char *) NULL; - char *name = (char *) NULL; - char *backColourHex = (char *) NULL; - char *labelColourHex = (char *) NULL; - char *buttonColourHex = (char *) NULL; + wxString style = ""; + wxString title = ""; + wxString name = ""; + wxString backColourHex = ""; + wxString labelColourHex = ""; + wxString buttonColourHex = ""; long windowStyle = wxDEFAULT_DIALOG_STYLE; if (isPanel) @@ -660,81 +579,79 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *ex int x = 0; int y = 0; int width = -1; int height = -1; int isModal = 0; - PrologExpr *labelFontExpr = (PrologExpr *) NULL; - PrologExpr *buttonFontExpr = (PrologExpr *) NULL; - PrologExpr *fontExpr = (PrologExpr *) NULL; - expr->AssignAttributeValue("style", &style); - expr->AssignAttributeValue("name", &name); - expr->AssignAttributeValue("title", &title); - expr->AssignAttributeValue("x", &x); - expr->AssignAttributeValue("y", &y); - expr->AssignAttributeValue("width", &width); - expr->AssignAttributeValue("height", &height); - expr->AssignAttributeValue("modal", &isModal); - expr->AssignAttributeValue("label_font", &labelFontExpr); - expr->AssignAttributeValue("button_font", &buttonFontExpr); - expr->AssignAttributeValue("font", &fontExpr); - expr->AssignAttributeValue("background_colour", &backColourHex); - expr->AssignAttributeValue("label_colour", &labelColourHex); - expr->AssignAttributeValue("button_colour", &buttonColourHex); + wxExpr *labelFontExpr = (wxExpr *) NULL; + wxExpr *buttonFontExpr = (wxExpr *) NULL; + wxExpr *fontExpr = (wxExpr *) NULL; + expr->GetAttributeValue("style", style); + expr->GetAttributeValue("name", name); + expr->GetAttributeValue("title", title); + expr->GetAttributeValue("x", x); + expr->GetAttributeValue("y", y); + expr->GetAttributeValue("width", width); + expr->GetAttributeValue("height", height); + expr->GetAttributeValue("modal", isModal); + expr->GetAttributeValue("label_font", &labelFontExpr); + expr->GetAttributeValue("button_font", &buttonFontExpr); + expr->GetAttributeValue("font", &fontExpr); + expr->GetAttributeValue("background_colour", backColourHex); + expr->GetAttributeValue("label_colour", labelColourHex); + expr->GetAttributeValue("button_colour", buttonColourHex); + + int useDialogUnits = 0; + expr->GetAttributeValue("use_dialog_units", useDialogUnits); + if (useDialogUnits != 0) + dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS); + + int useDefaults = 0; + expr->GetAttributeValue("use_system_defaults", useDefaults); + if (useDefaults != 0) + dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS); long id = 0; expr->GetAttributeValue("id", id); dialogItem->SetId(id); - if (style) + if (style != "") { windowStyle = wxParseWindowStyle(style); } dialogItem->SetStyle(windowStyle); dialogItem->SetValue1(isModal); - if (name) - dialogItem->SetName(name); - if (title) - dialogItem->SetTitle(title); + dialogItem->SetName(name); + dialogItem->SetTitle(title); dialogItem->SetSize(x, y, width, height); - if (backColourHex) + if (backColourHex != "") { int r = 0; int g = 0; int b = 0; - r = wxHexToDec(backColourHex); - g = wxHexToDec(backColourHex+2); - b = wxHexToDec(backColourHex+4); - dialogItem->SetBackgroundColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); - delete[] backColourHex; + r = wxHexToDec(backColourHex.Mid(0, 2)); + g = wxHexToDec(backColourHex.Mid(2, 2)); + b = wxHexToDec(backColourHex.Mid(4, 2)); + dialogItem->SetBackgroundColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - if (labelColourHex) + if (labelColourHex != "") { int r = 0; int g = 0; int b = 0; - r = wxHexToDec(labelColourHex); - g = wxHexToDec(labelColourHex+2); - b = wxHexToDec(labelColourHex+4); - dialogItem->SetLabelColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); - delete[] labelColourHex; + r = wxHexToDec(labelColourHex.Mid(0, 2)); + g = wxHexToDec(labelColourHex.Mid(2, 2)); + b = wxHexToDec(labelColourHex.Mid(4, 2)); + dialogItem->SetLabelColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - if (buttonColourHex) + if (buttonColourHex != "") { int r = 0; int g = 0; int b = 0; - r = wxHexToDec(buttonColourHex); - g = wxHexToDec(buttonColourHex+2); - b = wxHexToDec(buttonColourHex+4); - dialogItem->SetButtonColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); - delete[] buttonColourHex; + r = wxHexToDec(buttonColourHex.Mid(0, 2)); + g = wxHexToDec(buttonColourHex.Mid(2, 2)); + b = wxHexToDec(buttonColourHex.Mid(4, 2)); + dialogItem->SetButtonColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - if (name) - delete[] name; - if (title) - delete[] title; - if (style) - delete[] style; - if (fontExpr) dialogItem->SetFont(wxResourceInterpretFontSpec(fontExpr)); else if (buttonFontExpr) @@ -743,7 +660,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *ex dialogItem->SetFont(wxResourceInterpretFontSpec(labelFontExpr)); // Now parse all controls - PrologExpr *controlExpr = expr->GetFirst(); + wxExpr *controlExpr = expr->GetFirst(); while (controlExpr) { if (controlExpr->Number() == 3) @@ -752,7 +669,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *ex if (controlKeyword != "" && controlKeyword == "control") { // The value part: always a list. - PrologExpr *listExpr = controlExpr->Nth(2); + wxExpr *listExpr = controlExpr->Nth(2); if (listExpr->Type() == PrologList) { wxItemResource *controlItem = wxResourceInterpretControl(table, listExpr); @@ -768,7 +685,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *ex return dialogItem; } -wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { wxItemResource *controlItem = new wxItemResource; @@ -784,7 +701,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e int x = 0; int y = 0; int width = -1; int height = -1; int count = 0; - PrologExpr *expr1 = expr->Nth(0); + wxExpr *expr1 = expr->Nth(0); if ( expr1->Type() == PrologString || expr1->Type() == PrologWord ) { @@ -796,7 +713,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e else { wxString str(expr1->StringValue()); - id = wxResourceGetIdentifier(WXSTRINGCAST str, &table); + id = wxResourceGetIdentifier(str, &table); if (id == 0) { wxLogWarning(_("Could not resolve control class or id '%s'. " @@ -832,7 +749,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e if (expr1) { style = expr1->StringValue(); - windowStyle = wxParseWindowStyle(WXSTRINGCAST style); + windowStyle = wxParseWindowStyle(style); } expr1 = expr->Nth(count); @@ -861,10 +778,10 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e height = (int)expr1->IntegerValue(); controlItem->SetStyle(windowStyle); - controlItem->SetName(WXSTRINGCAST name); - controlItem->SetTitle(WXSTRINGCAST title); + controlItem->SetName(name); + controlItem->SetTitle(title); controlItem->SetSize(x, y, width, height); - controlItem->SetType(WXSTRINGCAST controlType); + controlItem->SetType(controlType); controlItem->SetId(id); if (controlType == "wxButton") @@ -873,7 +790,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) { wxString str(expr->Nth(count)->StringValue()); - controlItem->SetValue4(WXSTRINGCAST str); + controlItem->SetValue4(str); count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); @@ -909,7 +826,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) { wxString str(expr->Nth(count)->StringValue()); - controlItem->SetValue4(WXSTRINGCAST str); + controlItem->SetValue4(str); count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) @@ -928,7 +845,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) { wxString str(expr->Nth(count)->StringValue()); - controlItem->SetValue4(WXSTRINGCAST str); + controlItem->SetValue4(str); count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); @@ -1027,22 +944,22 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e } else if (controlType == "wxListBox") { - PrologExpr *valueList = (PrologExpr *) NULL; + wxExpr *valueList = (wxExpr *) NULL; if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) { - wxStringList *stringList = new wxStringList; - PrologExpr *stringExpr = valueList->GetFirst(); + wxStringList stringList; + wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { - stringList->Add(stringExpr->StringValue()); + stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); count ++; // Check for wxSINGLE/wxMULTIPLE - PrologExpr *mult = (PrologExpr *) NULL; + wxExpr *mult = (wxExpr *) NULL; controlItem->SetValue1(wxLB_SINGLE); if ((mult = expr->Nth(count)) && ((mult->Type() == PrologString)||(mult->Type() == PrologWord))) { @@ -1064,15 +981,15 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e } else if (controlType == "wxChoice") { - PrologExpr *valueList = (PrologExpr *) NULL; + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) { - wxStringList *stringList = new wxStringList; - PrologExpr *stringExpr = valueList->GetFirst(); + wxStringList stringList; + wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { - stringList->Add(stringExpr->StringValue()); + stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); @@ -1092,23 +1009,23 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e #if wxUSE_COMBOBOX else if (controlType == "wxComboBox") { - PrologExpr *textValue = expr->Nth(count); + wxExpr *textValue = expr->Nth(count); if (textValue && (textValue->Type() == PrologString || textValue->Type() == PrologWord)) { wxString str(textValue->StringValue()); - controlItem->SetValue4(WXSTRINGCAST str); + controlItem->SetValue4(str); count ++; - PrologExpr *valueList = (PrologExpr *) NULL; + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) { - wxStringList *stringList = new wxStringList; - PrologExpr *stringExpr = valueList->GetFirst(); + wxStringList stringList; + wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { - stringList->Add(stringExpr->StringValue()); + stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); @@ -1130,15 +1047,15 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e #if 1 else if (controlType == "wxRadioBox") { - PrologExpr *valueList = (PrologExpr *) NULL; + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) { - wxStringList *stringList = new wxStringList; - PrologExpr *stringExpr = valueList->GetFirst(); + wxStringList stringList; + wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { - stringList->Add(stringExpr->StringValue()); + stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); @@ -1173,20 +1090,20 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e } // Forward declaration -wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, PrologExpr *expr); +wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr); /* * Interpet a menu item */ -wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr) { wxItemResource *item = new wxItemResource; - PrologExpr *labelExpr = expr->Nth(0); - PrologExpr *idExpr = expr->Nth(1); - PrologExpr *helpExpr = expr->Nth(2); - PrologExpr *checkableExpr = expr->Nth(3); + wxExpr *labelExpr = expr->Nth(0); + wxExpr *idExpr = expr->Nth(1); + wxExpr *helpExpr = expr->Nth(2); + wxExpr *checkableExpr = expr->Nth(3); // Further keywords/attributes to follow sometime... if (expr->Number() == 0) @@ -1202,7 +1119,7 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr * if (labelExpr) { wxString str(labelExpr->StringValue()); - item->SetTitle(WXSTRINGCAST str); + item->SetTitle(str); } if (idExpr) { @@ -1211,7 +1128,7 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr * if ((idExpr->Type() == PrologString) || (idExpr->Type() == PrologWord)) { wxString str(idExpr->StringValue()); - id = wxResourceGetIdentifier(WXSTRINGCAST str, &table); + id = wxResourceGetIdentifier(str, &table); if (id == 0) { wxLogWarning(_("Could not resolve menu id '%s'. " @@ -1227,13 +1144,13 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr * if (helpExpr) { wxString str(helpExpr->StringValue()); - item->SetValue4(WXSTRINGCAST str); + item->SetValue4(str); } if (checkableExpr) item->SetValue2(checkableExpr->IntegerValue()); // Find the first expression that's a list, for submenu - PrologExpr *subMenuExpr = expr->GetFirst(); + wxExpr *subMenuExpr = expr->GetFirst(); while (subMenuExpr && (subMenuExpr->Type() != PrologList)) subMenuExpr = subMenuExpr->GetNext(); @@ -1251,12 +1168,12 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr * * Interpret a nested list as a menu */ /* -wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr) { wxItemResource *menu = new wxItemResource; // menu->SetType(wxTYPE_MENU); menu->SetType("wxMenu"); - PrologExpr *element = expr->GetFirst(); + wxExpr *element = expr->GetFirst(); while (element) { wxItemResource *item = wxResourceInterpretMenuItem(table, element); @@ -1268,10 +1185,10 @@ wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, PrologExpr *exp } */ -wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) { - PrologExpr *listExpr = (PrologExpr *) NULL; - expr->AssignAttributeValue("menu", &listExpr); + wxExpr *listExpr = (wxExpr *) NULL; + expr->GetAttributeValue("menu", &listExpr); if (!listExpr) return (wxItemResource *) NULL; @@ -1279,22 +1196,20 @@ wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, PrologExpr *expr if (!menuResource) return (wxItemResource *) NULL; - - char *name = (char *) NULL; - expr->AssignAttributeValue("name", &name); - if (name) + + wxString name; + if (expr->GetAttributeValue("name", name)) { menuResource->SetName(name); - delete[] name; } return menuResource; } -wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) { - PrologExpr *listExpr = (PrologExpr *) NULL; - expr->AssignAttributeValue("menu", &listExpr); + wxExpr *listExpr = (wxExpr *) NULL; + expr->GetAttributeValue("menu", &listExpr); if (!listExpr) return (wxItemResource *) NULL; @@ -1302,7 +1217,7 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *e resource->SetType("wxMenu"); // resource->SetType(wxTYPE_MENU); - PrologExpr *element = listExpr->GetFirst(); + wxExpr *element = listExpr->GetFirst(); while (element) { wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr); @@ -1310,36 +1225,32 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *e element = element->GetNext(); } - char *name = (char *) NULL; - expr->AssignAttributeValue("name", &name); - if (name) + wxString name; + if (expr->GetAttributeValue("name", name)) { resource->SetName(name); - delete[] name; } return resource; } -wxItemResource *wxResourceInterpretString(wxResourceTable& WXUNUSED(table), PrologExpr *WXUNUSED(expr)) +wxItemResource *wxResourceInterpretString(wxResourceTable& WXUNUSED(table), wxExpr *WXUNUSED(expr)) { return (wxItemResource *) NULL; } -wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), PrologExpr *expr) +wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxExpr *expr) { wxItemResource *bitmapItem = new wxItemResource; // bitmapItem->SetType(wxTYPE_BITMAP); bitmapItem->SetType("wxBitmap"); - char *name = (char *) NULL; - expr->AssignAttributeValue("name", &name); - if (name) + wxString name; + if (expr->GetAttributeValue("name", name)) { bitmapItem->SetName(name); - delete[] name; } // Now parse all bitmap specifications - PrologExpr *bitmapExpr = expr->GetFirst(); + wxExpr *bitmapExpr = expr->GetFirst(); while (bitmapExpr) { if (bitmapExpr->Number() == 3) @@ -1348,7 +1259,7 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), Prol if (bitmapKeyword == "bitmap" || bitmapKeyword == "icon") { // The value part: always a list. - PrologExpr *listExpr = bitmapExpr->Nth(2); + wxExpr *listExpr = bitmapExpr->Nth(2); if (listExpr->Type() == PrologList) { wxItemResource *bitmapSpec = new wxItemResource; @@ -1357,21 +1268,19 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), Prol // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution] // where everything after 'filename' is optional. - PrologExpr *nameExpr = listExpr->Nth(0); - PrologExpr *typeExpr = listExpr->Nth(1); - PrologExpr *platformExpr = listExpr->Nth(2); - PrologExpr *coloursExpr = listExpr->Nth(3); - PrologExpr *xresExpr = listExpr->Nth(4); - PrologExpr *yresExpr = listExpr->Nth(5); + wxExpr *nameExpr = listExpr->Nth(0); + wxExpr *typeExpr = listExpr->Nth(1); + wxExpr *platformExpr = listExpr->Nth(2); + wxExpr *coloursExpr = listExpr->Nth(3); + wxExpr *xresExpr = listExpr->Nth(4); + wxExpr *yresExpr = listExpr->Nth(5); if (nameExpr && nameExpr->StringValue()) { - wxString str(nameExpr->StringValue()); - bitmapSpec->SetName(WXSTRINGCAST str); + bitmapSpec->SetName(nameExpr->StringValue()); } if (typeExpr && typeExpr->StringValue()) { - wxString str(typeExpr->StringValue()); - bitmapSpec->SetValue1(wxParseWindowStyle(WXSTRINGCAST str)); + bitmapSpec->SetValue1(wxParseWindowStyle(typeExpr->StringValue())); } else bitmapSpec->SetValue1(0); @@ -1411,7 +1320,7 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), Prol return bitmapItem; } -wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, wxExpr *expr) { wxItemResource *item = wxResourceInterpretBitmap(table, expr); if (item) @@ -1425,10 +1334,10 @@ wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, PrologExpr *expr } // Interpret list expression as a font -wxFont *wxResourceInterpretFontSpec(PrologExpr *expr) +wxFont wxResourceInterpretFontSpec(wxExpr *expr) { if (expr->Type() != PrologList) - return (wxFont *) NULL; + return wxNullFont; int point = 10; int family = wxSWISS; @@ -1437,12 +1346,12 @@ wxFont *wxResourceInterpretFontSpec(PrologExpr *expr) int underline = 0; wxString faceName(""); - PrologExpr *pointExpr = expr->Nth(0); - PrologExpr *familyExpr = expr->Nth(1); - PrologExpr *styleExpr = expr->Nth(2); - PrologExpr *weightExpr = expr->Nth(3); - PrologExpr *underlineExpr = expr->Nth(4); - PrologExpr *faceNameExpr = expr->Nth(5); + wxExpr *pointExpr = expr->Nth(0); + wxExpr *familyExpr = expr->Nth(1); + wxExpr *styleExpr = expr->Nth(2); + wxExpr *weightExpr = expr->Nth(3); + wxExpr *underlineExpr = expr->Nth(4); + wxExpr *faceNameExpr = expr->Nth(5); if (pointExpr) point = (int)pointExpr->IntegerValue(); @@ -1450,27 +1359,24 @@ wxFont *wxResourceInterpretFontSpec(PrologExpr *expr) if (familyExpr) { str = familyExpr->StringValue(); - family = (int)wxParseWindowStyle(WXSTRINGCAST str); + family = (int)wxParseWindowStyle(str); } if (styleExpr) { str = styleExpr->StringValue(); - style = (int)wxParseWindowStyle(WXSTRINGCAST str); + style = (int)wxParseWindowStyle(str); } if (weightExpr) { str = weightExpr->StringValue(); - weight = (int)wxParseWindowStyle(WXSTRINGCAST str); + weight = (int)wxParseWindowStyle(str); } if (underlineExpr) underline = (int)underlineExpr->IntegerValue(); if (faceNameExpr) faceName = faceNameExpr->StringValue(); - char *faceName1 = (char *) NULL; - if (faceName != "") - faceName1 = WXSTRINGCAST faceName; - wxFont *font = wxTheFontList->FindOrCreateFont(point, family, style, weight, (underline != 0), faceName1); + wxFont font(point, family, style, weight, (underline != 0), faceName); return font; } @@ -1478,7 +1384,7 @@ wxFont *wxResourceInterpretFontSpec(PrologExpr *expr) * (Re)allocate buffer for reading in from resource file */ -bool wxReallocateResourceBuffer(void) +bool wxReallocateResourceBuffer() { if (!wxResourceBuffer) { @@ -1611,7 +1517,7 @@ bool wxGetResourceToken(FILE *fd) with possible comments. */ -bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResourceTable *table) +bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -1749,10 +1655,10 @@ bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResour * "wxSYSTEM_MENU | wxBORDER" -> integer */ -char *wxResourceParseWord(char *s, int *i) +char* wxResourceParseWord(char*s, int *i) { if (!s) - return (char *) NULL; + return (char*) NULL; static char buf[150]; int len = strlen(s); @@ -1774,7 +1680,7 @@ char *wxResourceParseWord(char *s, int *i) } *i = ii; if (j == 0) - return (char *) NULL; + return (char*) NULL; else return buf; } @@ -2037,12 +1943,12 @@ static wxResourceBitListStruct wxResourceBitListTable[] = static int wxResourceBitListCount = (sizeof(wxResourceBitListTable)/sizeof(wxResourceBitListStruct)); -long wxParseWindowStyle(char *bitListString) +long wxParseWindowStyle(const wxString& bitListString) { int i = 0; char *word; long bitList = 0; - while ((word = wxResourceParseWord(bitListString, &i))) + while ((word = wxResourceParseWord((char*) (const char*) bitListString, &i))) { bool found = FALSE; int j; @@ -2067,7 +1973,7 @@ long wxParseWindowStyle(char *bitListString) * depth and appropriate type. */ -wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) +wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2077,8 +1983,8 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) { if (!item->GetType() || strcmp(item->GetType(), "wxBitmap") != 0) { - wxLogWarning(_("%s not a bitmap resource specification."), resource); - return (wxBitmap *) NULL; + wxLogWarning(_("%s not a bitmap resource specification."), (const char*) resource); + return wxNullBitmap; } int thisDepth = wxDisplayDepth(); long thisNoColours = (long)pow(2.0, (double)thisDepth); @@ -2164,11 +2070,10 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) } // If no matching resource, fail. if (!optResource) - return (wxBitmap *) NULL; + return wxNullBitmap; - char *name = optResource->GetName(); + wxString name = optResource->GetName(); int bitmapType = (int)optResource->GetValue1(); - wxBitmap *bitmap = (wxBitmap *) NULL; switch (bitmapType) { case wxBITMAP_TYPE_XBM_DATA: @@ -2178,10 +2083,10 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) if (!item) { wxLogWarning(_("Failed to find XBM resource %s.\n" - "Forgot to use wxResourceLoadBitmapData?"), name); + "Forgot to use wxResourceLoadBitmapData?"), (const char*) name); return (wxBitmap *) NULL; } - bitmap = new wxBitmap((char *)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); + return wxBitmap(item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()) ; #else wxLogWarning(_("No XBM facility available!")); #endif @@ -2194,10 +2099,10 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) if (!item) { wxLogWarning(_("Failed to find XPM resource %s.\n" - "Forgot to use wxResourceLoadBitmapData?"), name); + "Forgot to use wxResourceLoadBitmapData?"), (const char*) name); return (wxBitmap *) NULL; } - bitmap = new wxBitmap(item->GetValue1()); + return wxBitmap(item->GetValue1()); #else wxLogWarning(_("No XPM facility available!")); #endif @@ -2205,27 +2110,16 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) } default: { - bitmap = new wxBitmap(name, bitmapType); + return wxBitmap(name, bitmapType); break; } } - if (!bitmap) - return (wxBitmap *) NULL; - - if (bitmap->Ok()) - { - return bitmap; - } - else - { - delete bitmap; - return (wxBitmap *) NULL; - } + return wxNullBitmap; } else { - wxLogWarning(_("Bitmap resource specification %s not found."), resource); - return (wxBitmap *) NULL; + wxLogWarning(_("Bitmap resource specification %s not found."), (const char*) resource); + return wxNullBitmap; } } @@ -2234,18 +2128,18 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) * depth and appropriate type. */ -wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) +wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { if (!table) - table = wxDefaultResourceTable; + table = wxDefaultResourceTable; wxItemResource *item = table->FindResource(resource); if (item) { - if (!item->GetType() || strcmp(item->GetType(), "wxIcon") != 0) + if ((item->GetType() == "") || strcmp(item->GetType(), "wxIcon") != 0) { - wxLogWarning(_("%s not an icon resource specification."), resource); - return (wxIcon *) NULL; + wxLogWarning(_("%s not an icon resource specification."), (const char*) resource); + return wxNullIcon; } int thisDepth = wxDisplayDepth(); long thisNoColours = (long)pow(2.0, (double)thisDepth); @@ -2331,11 +2225,10 @@ wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) } // If no matching resource, fail. if (!optResource) - return (wxIcon *) NULL; + return wxNullIcon; - char *name = optResource->GetName(); + wxString name = optResource->GetName(); int bitmapType = (int)optResource->GetValue1(); - wxIcon *icon = (wxIcon *) NULL; switch (bitmapType) { case wxBITMAP_TYPE_XBM_DATA: @@ -2345,10 +2238,10 @@ wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) if (!item) { wxLogWarning(_("Failed to find XBM resource %s.\n" - "Forgot to use wxResourceLoadIconData?"), name); + "Forgot to use wxResourceLoadIconData?"), (const char*) name); return (wxIcon *) NULL; } - icon = new wxIcon((char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); + return wxIcon((char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); #else wxLogWarning(_("No XBM facility available!")); #endif @@ -2367,7 +2260,7 @@ wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) wxLogWarning(buf); return NULL; } - icon = new wxIcon((char **)item->GetValue1()); + return wxIcon((char **)item->GetValue1()); #else wxLogWarning(_("No XPM facility available!")); #endif @@ -2378,29 +2271,18 @@ wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) default: { #ifdef __WXGTK__ - wxLogWarning(_("Icon resource specification %s not found."), resource); + wxLogWarning(_("Icon resource specification %s not found."), (const char*) resource); #else - icon = new wxIcon(name, bitmapType); + return wxIcon(name, bitmapType); #endif break; } } - if (!icon) - return (wxIcon *) NULL; - - if (icon->Ok()) - { - return icon; - } - else - { - delete icon; - return (wxIcon *) NULL; - } + return wxNullIcon; } else { - wxLogWarning(_("Icon resource specification %s not found."), resource); + wxLogWarning(_("Icon resource specification %s not found."), (const char*) resource); return (wxIcon *) NULL; } } @@ -2412,7 +2294,7 @@ wxMenu *wxResourceCreateMenu(wxItemResource *item) while (node) { wxItemResource *child = (wxItemResource *)node->Data(); - if (child->GetType() && strcmp(child->GetType(), "wxMenuSeparator") == 0) + if ((child->GetType() != "") && (child->GetType() == "wxMenuSeparator")) menu->AppendSeparator(); else if (child->GetChildren().Number() > 0) { @@ -2429,13 +2311,13 @@ wxMenu *wxResourceCreateMenu(wxItemResource *item) return menu; } -wxMenuBar *wxResourceCreateMenuBar(char *resource, wxResourceTable *table, wxMenuBar *menuBar) +wxMenuBar *wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table, wxMenuBar *menuBar) { if (!table) table = wxDefaultResourceTable; wxItemResource *menuResource = table->FindResource(resource); - if (menuResource && menuResource->GetType() && strcmp(menuResource->GetType(), "wxMenu") == 0) + if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu")) { if (!menuBar) menuBar = new wxMenuBar; @@ -2453,20 +2335,20 @@ wxMenuBar *wxResourceCreateMenuBar(char *resource, wxResourceTable *table, wxMen return (wxMenuBar *) NULL; } -wxMenu *wxResourceCreateMenu(char *resource, wxResourceTable *table) +wxMenu *wxResourceCreateMenu(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; wxItemResource *menuResource = table->FindResource(resource); - if (menuResource && menuResource->GetType() && strcmp(menuResource->GetType(), "wxMenu") == 0) + if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu")) // if (menuResource && (menuResource->GetType() == wxTYPE_MENU)) return wxResourceCreateMenu(menuResource); return (wxMenu *) NULL; } // Global equivalents (so don't have to refer to default table explicitly) -bool wxResourceParseData(char *resource, wxResourceTable *table) +bool wxResourceParseData(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2474,7 +2356,7 @@ bool wxResourceParseData(char *resource, wxResourceTable *table) return table->ParseResourceData(resource); } -bool wxResourceParseFile(char *filename, wxResourceTable *table) +bool wxResourceParseFile(const wxString& filename, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2483,7 +2365,7 @@ bool wxResourceParseFile(char *filename, wxResourceTable *table) } // Register XBM/XPM data -bool wxResourceRegisterBitmapData(char *name, char bits[], int width, int height, wxResourceTable *table) +bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2491,7 +2373,7 @@ bool wxResourceRegisterBitmapData(char *name, char bits[], int width, int height return table->RegisterResourceBitmapData(name, bits, width, height); } -bool wxResourceRegisterBitmapData(char *name, char **data, wxResourceTable *table) +bool wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2511,7 +2393,7 @@ void wxResourceClear(wxResourceTable *table) * Identifiers */ -bool wxResourceAddIdentifier(char *name, int value, wxResourceTable *table) +bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2520,7 +2402,7 @@ bool wxResourceAddIdentifier(char *name, int value, wxResourceTable *table) return TRUE; } -int wxResourceGetIdentifier(char *name, wxResourceTable *table) +int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2532,7 +2414,7 @@ int wxResourceGetIdentifier(char *name, wxResourceTable *table) * Parse #include file for #defines (only) */ -bool wxResourceParseIncludeFile(char *f, wxResourceTable *table) +bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2579,7 +2461,7 @@ static int getc_string(char *s) } } -static int ungetc_string(void) +static int ungetc_string() { wxResourceStringPtr --; return 0; @@ -2701,7 +2583,7 @@ bool wxGetResourceTokenString(char *s) with possible comments. */ -bool wxResourceReadOneResourceString(char *s, PrologDatabase& db, bool *eof, wxResourceTable *table) +bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2855,7 +2737,7 @@ bool wxResourceParseString(char *s, wxResourceTable *table) } } - PrologDatabase db; + wxExprDatabase db; wxResourceStringPtr = 0; bool eof = FALSE; @@ -2881,61 +2763,86 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, ! ((strcmp(resource->GetType(), "wxDialog") == 0) || (strcmp(resource->GetType(), "wxPanel") == 0))) return FALSE; - char *title = resource->GetTitle(); + wxString title(resource->GetTitle()); long theWindowStyle = resource->GetStyle(); bool isModal = (resource->GetValue1() != 0); int x = resource->GetX(); int y = resource->GetY(); int width = resource->GetWidth(); int height = resource->GetHeight(); - char *name = resource->GetName(); - - wxFont *theFont = resource->GetFont(); + wxString name = resource->GetName(); if (IsKindOf(CLASSINFO(wxDialog))) { wxDialog *dialogBox = (wxDialog *)this; - long modalStyle = isModal ? wxDIALOG_MODAL : 0; + long modalStyle = isModal ? wxDIALOG_MODAL : 0; if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name)) return FALSE; - dialogBox->SetClientSize(width, height); + + // Only reset the client size if we know we're not going to do it again below. + if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == 0) + dialogBox->SetClientSize(width, height); + } + else if (IsKindOf(CLASSINFO(wxPanel))) + { + wxPanel* panel = (wxPanel *)this; + if (!panel->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) + return FALSE; } else { - if (!((wxWindow *)this)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) + if (!this->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) return FALSE; } - if (theFont) - SetFont(*theFont); + if ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) + { + // No need to do this since it's done in wxPanel or wxDialog constructor. + // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + } + else + { + if (resource->GetFont().Ok()) + SetFont(resource->GetFont()); + if (resource->GetBackgroundColour().Ok()) + SetBackgroundColour(resource->GetBackgroundColour()); + } - if (resource->GetBackgroundColour()) - SetBackgroundColour(*resource->GetBackgroundColour()); + // Should have some kind of font at this point + if (!GetFont()->Ok()) + SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + if (!GetBackgroundColour().Ok()) + SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + + // Only when we've created the window and set the font can we set the correct size, + // if based on dialog units. + if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) + { + wxSize sz = ConvertDialogToPixels(wxSize(width, height)); + SetClientSize(sz.x, sz.y); + + wxPoint pt = ConvertDialogToPixels(wxPoint(x, y)); + Move(pt.x, pt.y); + } - // TODO - if (resource->GetLabelColour()) - SetForegroundColour(*resource->GetLabelColour()); - else if (resource->GetButtonColour()) - SetForegroundColour(*resource->GetButtonColour()); - // Now create children wxNode *node = resource->GetChildren().First(); while (node) { wxItemResource *childResource = (wxItemResource *)node->Data(); - (void) CreateItem(childResource, table); + (void) CreateItem(childResource, resource, table); node = node->Next(); } return TRUE; } -wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxResourceTable *table) +wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - return table->CreateItem((wxWindow *)this, (wxItemResource *)resource); + return table->CreateItem((wxWindow *)this, resource, parentResource); } #endif // wxUSE_WX_RESOURCES diff --git a/src/common/tbarsmpl.cpp b/src/common/tbarsmpl.cpp index 1d052c8889..8976f942f2 100644 --- a/src/common/tbarsmpl.cpp +++ b/src/common/tbarsmpl.cpp @@ -55,7 +55,6 @@ bool wxToolBarSimple::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos // Set it to grey (or other 3D face colour) wxSystemSettings settings; SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_3DFACE)); if ( GetWindowStyleFlag() & wxTB_VERTICAL ) { m_lastX = 7; m_lastY = 3; } diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index db15e151fe..cb7890e7a8 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -240,19 +240,19 @@ static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A' 'C', 'D', 'E', 'F' }; // Convert 2-digit hex number to decimal -int wxHexToDec(char *buf) +int wxHexToDec(const wxString& buf) { int firstDigit, secondDigit; - if (buf[0] >= 'A') - firstDigit = buf[0] - 'A' + 10; + if (buf.GetChar(0) >= 'A') + firstDigit = buf.GetChar(0) - 'A' + 10; else - firstDigit = buf[0] - '0'; + firstDigit = buf.GetChar(0) - '0'; - if (buf[1] >= 'A') - secondDigit = buf[1] - 'A' + 10; + if (buf.GetChar(1) >= 'A') + secondDigit = buf.GetChar(1) - 'A' + 10; else - secondDigit = buf[1] - '0'; + secondDigit = buf.GetChar(1) - '0'; return firstDigit * 16 + secondDigit; } @@ -267,6 +267,14 @@ void wxDecToHex(int dec, char *buf) buf[2] = 0; } +// Convert decimal integer to 2-character hex string +wxString wxDecToHex(int dec) +{ + char buf[3]; + wxDecToHex(dec, buf); + return wxString(buf); +} + // Match a string INDEPENDENT OF CASE bool StringMatch (char *str1, char *str2, bool subString, bool exact) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 3486f2b6bd..4aebe4007e 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -64,3 +64,27 @@ void wxWindow::UpdateWindowUI() } } } + +// Dialog units translations. Implemented in wincmn.cpp. +wxPoint wxWindow::ConvertPixelsToDialog(const wxPoint& pt) +{ + int charWidth = GetCharWidth(); + int charHeight = GetCharHeight(); + wxPoint pt2; + pt2.x = (int) ((pt.x * 4) / charWidth) ; + pt2.y = (int) ((pt.y * 8) / charHeight) ; + + return pt2; +} + +wxPoint wxWindow::ConvertDialogToPixels(const wxPoint& pt) +{ + int charWidth = GetCharWidth(); + int charHeight = GetCharHeight(); + wxPoint pt2; + pt2.x = (int) ((pt.x * charWidth) / 4) ; + pt2.y = (int) ((pt.y * charHeight) / 8) ; + + return pt2; +} + diff --git a/src/generic/panelg.cpp b/src/generic/panelg.cpp index c58841ba5c..be008d5122 100644 --- a/src/generic/panelg.cpp +++ b/src/generic/panelg.cpp @@ -50,7 +50,6 @@ bool wxPanel::Create(wxWindow *parent, wxWindowID id, if ( ret ) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); } @@ -73,7 +72,6 @@ void wxPanel::SetFocus() void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); Refresh(); // Propagate the event to the non-top-level children diff --git a/src/gtk/treectrl.cpp b/src/gtk/treectrl.cpp index 4742ab7a79..69d424f523 100644 --- a/src/gtk/treectrl.cpp +++ b/src/gtk/treectrl.cpp @@ -127,7 +127,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con wxSystemSettings settings; SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetForegroundColour(parent->GetForegroundColour()); SetName(name); SetValidator(validator); diff --git a/src/gtk1/treectrl.cpp b/src/gtk1/treectrl.cpp index 4742ab7a79..69d424f523 100644 --- a/src/gtk1/treectrl.cpp +++ b/src/gtk1/treectrl.cpp @@ -127,7 +127,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con wxSystemSettings settings; SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetForegroundColour(parent->GetForegroundColour()); SetName(name); SetValidator(validator); diff --git a/src/motif/window.cpp b/src/motif/window.cpp index c3a6018292..edb62407c7 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -99,10 +99,9 @@ wxWindow::wxWindow() m_caretWidth = 0; m_caretHeight = 0; m_caretEnabled = FALSE; m_caretShown = FALSE; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_foregroundColour = *wxBLACK; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; #if wxUSE_DRAG_AND_DROP m_pDropTarget = NULL; @@ -320,10 +319,10 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, else m_windowId = id; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_foregroundColour = *wxBLACK; m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_windowStyle = style; diff --git a/src/msw/bmpbuttn.cpp b/src/msw/bmpbuttn.cpp index af8a1e72fe..d9d1da958b 100644 --- a/src/msw/bmpbuttn.cpp +++ b/src/msw/bmpbuttn.cpp @@ -44,8 +44,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit parent->AddChild(this); - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; m_windowStyle = style; m_marginX = 0; m_marginY = 0; diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 849eef8dbd..03200cfacf 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -56,8 +56,8 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, SetValidator(validator); parent->AddChild((wxButton *)this); - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; m_windowStyle = (long&)style; diff --git a/src/msw/checkbox.cpp b/src/msw/checkbox.cpp index 1beb5c6d35..32b1b32e2c 100644 --- a/src/msw/checkbox.cpp +++ b/src/msw/checkbox.cpp @@ -51,8 +51,8 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_windowStyle = style; @@ -221,8 +221,8 @@ bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *l SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_windowStyle = style; if ( id == -1 ) diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 0a802bdab0..8c4aede0bd 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -56,8 +56,8 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, SetName(name); SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_noStrings = n; m_windowStyle = style; diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 01a8df28be..bdef590146 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -70,8 +70,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, SetName(name); SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_noStrings = n; m_windowStyle = style; diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index 85ba82edd0..06b2398406 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -78,7 +78,6 @@ wxDialog::wxDialog(void) m_modalShowing = FALSE; SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); } bool wxDialog::Create(wxWindow *parent, wxWindowID id, @@ -89,7 +88,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, const wxString& name) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetName(name); if (!parent) @@ -592,7 +590,6 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) Ctl3dColorChange(); #else SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); Refresh(); #endif } diff --git a/src/msw/gauge95.cpp b/src/msw/gauge95.cpp index cd6e0902f4..e48513d680 100644 --- a/src/msw/gauge95.cpp +++ b/src/msw/gauge95.cpp @@ -52,8 +52,8 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id, m_rangeMax = range; m_gaugePos = 0; - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_windowStyle = style; diff --git a/src/msw/gaugemsw.cpp b/src/msw/gaugemsw.cpp index dacfc8f8d4..0c33ec4dda 100644 --- a/src/msw/gaugemsw.cpp +++ b/src/msw/gaugemsw.cpp @@ -87,8 +87,8 @@ bool wxGaugeMSW::Create(wxWindow *parent, wxWindowID id, m_rangeMax = range; m_gaugePos = 0; - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_windowStyle = style; diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 4d4a05769c..711d73cf00 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -160,7 +160,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, wxSystemSettings settings; SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetForegroundColour(parent->GetForegroundColour()); m_windowId = ( id == -1 ) ? (int)NewControlId() : id; @@ -266,7 +266,7 @@ wxListBox::~wxListBox(void) void wxListBox::SetupColours(void) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(GetParent()->GetDefaultForegroundColour()); + SetForegroundColour(GetParent()->GetForegroundColour()); } void wxListBox::SetFirstItem(int N) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 266ebb1853..584df93945 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -126,7 +126,7 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con wxSystemSettings settings; SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetForegroundColour(parent->GetForegroundColour()); if (parent) parent->AddChild(this); diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index c6df82a176..7800cc398f 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -130,9 +130,6 @@ bool wxNotebook::Create(wxWindow *parent, m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE)); m_foregroundColour = *wxBLACK ; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxColour(GetSysColor(COLOR_BTNFACE)); - // style m_windowStyle = style | wxTAB_TRAVERSAL; diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 82ecdf8600..a1cbdedce7 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -98,8 +98,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, SetValidator(val); parent->AddChild(this); - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; m_windowStyle = (long&)style; @@ -207,8 +207,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, SetValidator(val); parent->AddChild(this); - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; m_windowStyle = (long&)style; diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp index 47783bcd87..cb74479b3a 100644 --- a/src/msw/radiobut.cpp +++ b/src/msw/radiobut.cpp @@ -45,8 +45,8 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetBackgroundColour(parent->GetBackgroundColour()); + SetForegroundColour(parent->GetForegroundColour()); if ( id == -1 ) m_windowId = (int)NewControlId(); @@ -187,8 +187,8 @@ bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id, SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetBackgroundColour(parent->GetBackgroundColour()); + SetForegroundColour(parent->GetForegroundColour()); if ( id == -1 ) m_windowId = (int)NewControlId(); diff --git a/src/msw/scrolbar.cpp b/src/msw/scrolbar.cpp index 87c52ca273..a34df24e6e 100644 --- a/src/msw/scrolbar.cpp +++ b/src/msw/scrolbar.cpp @@ -55,8 +55,8 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, SetName(name); SetValidator(validator); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_windowStyle = style; if ( id == -1 ) diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 2197868d25..5347975b71 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -68,8 +68,8 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_staticValue = 0; m_staticMin = 0; diff --git a/src/msw/slidrmsw.cpp b/src/msw/slidrmsw.cpp index f8a6f33e2a..cd2b47760c 100644 --- a/src/msw/slidrmsw.cpp +++ b/src/msw/slidrmsw.cpp @@ -62,8 +62,8 @@ bool wxSliderMSW::Create(wxWindow *parent, wxWindowID id, SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_staticValue = 0; m_staticMin = 0; diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index a34bd654c4..56d537619e 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -47,8 +47,8 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c long style, const wxString& name) { wxSystemSettings settings; - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; SetName(name); diff --git a/src/msw/statbmp.cpp b/src/msw/statbmp.cpp index 5c56d88f69..8cf17984c8 100644 --- a/src/msw/statbmp.cpp +++ b/src/msw/statbmp.cpp @@ -46,8 +46,8 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, SetName(name); if (parent) parent->AddChild(this); - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; if ( id == -1 ) m_windowId = (int)NewControlId(); diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 3287dbf204..63ddabb570 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -52,8 +52,8 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; if ( id == -1 ) m_windowId = (int)NewControlId(); diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index e203b5ebd7..b45ca5e0cb 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -42,8 +42,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, SetName(name); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; if ( id == -1 ) m_windowId = (int)NewControlId(); diff --git a/src/msw/tabctrl.cpp b/src/msw/tabctrl.cpp index cec9af4086..d6f6a5415b 100644 --- a/src/msw/tabctrl.cpp +++ b/src/msw/tabctrl.cpp @@ -72,10 +72,6 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); m_foregroundColour = *wxBLACK ; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)), - GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); - SetName(name); int x = pos.x; @@ -196,8 +192,6 @@ void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent& event) { m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)), GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); - m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)), - GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); // Remap the buttons // CreateTools(); diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 6927c27c36..772e4cab64 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -100,10 +100,6 @@ bool wxToolBar95::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, co GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); m_foregroundColour = *wxBLACK ; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)), - GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); - if (style & wxTB_VERTICAL) wxMessageBox("Sorry, wxToolBar95 under Windows 95 only supports horizontal orientation.", "wxToolBar95 usage", wxOK); m_maxWidth = -1; @@ -475,8 +471,6 @@ void wxToolBar95::OnSysColourChanged(wxSysColourChangedEvent& event) { m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)), GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); - m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)), - GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); // Remap the buttons CreateTools(); diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 7ff7b78356..706acfcb0a 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -95,7 +95,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; if ( id == -1 ) m_windowId = (int)NewControlId(); @@ -254,7 +254,7 @@ void wxTextCtrl::AdoptAttributesFromHWND(void) void wxTextCtrl::SetupColours(void) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(GetParent()->GetDefaultForegroundColour()); + SetForegroundColour(GetParent()->GetForegroundColour()); } wxString wxTextCtrl::GetValue(void) const diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 549b53236f..24acc2ab18 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -61,7 +61,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con { wxSystemSettings settings; SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetForegroundColour(parent->GetForegroundColour()); SetName(name); SetValidator(validator); diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 8240c14c04..b851ac7919 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -238,10 +238,9 @@ wxWindow::wxWindow(void) wxSystemSettings settings; - m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ; + // m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; m_foregroundColour = *wxBLACK; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ; /* wxColour(GetRValue(GetSysColor(COLOR_WINDOW)), @@ -437,9 +436,8 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, wxSystemSettings settings; m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + // m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_foregroundColour = *wxBLACK; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_windowStyle = style; diff --git a/src/stubs/window.cpp b/src/stubs/window.cpp index cb9aec4ea6..1d51541d8d 100644 --- a/src/stubs/window.cpp +++ b/src/stubs/window.cpp @@ -75,10 +75,9 @@ wxWindow::wxWindow() m_caretWidth = 0; m_caretHeight = 0; m_caretEnabled = FALSE; m_caretShown = FALSE; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; + // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; m_foregroundColour = *wxBLACK; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; #if wxUSE_DRAG_AND_DROP m_pDropTarget = NULL; @@ -185,10 +184,9 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, else m_windowId = id; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_foregroundColour = *wxBLACK; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_windowStyle = style; diff --git a/utils/dialoged/src/dlghndlr.cpp b/utils/dialoged/src/dlghndlr.cpp index 4c6b67b9da..88f3a1ab92 100644 --- a/utils/dialoged/src/dlghndlr.cpp +++ b/utils/dialoged/src/dlghndlr.cpp @@ -46,6 +46,7 @@ IMPLEMENT_CLASS(wxResourceEditorControlHandler, wxEvtHandler) BEGIN_EVENT_TABLE(wxResourceEditorDialogHandler, wxEvtHandler) EVT_PAINT(wxResourceEditorDialogHandler::OnPaint) EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent) + EVT_SIZE(wxResourceEditorDialogHandler::OnSize) END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxResourceEditorControlHandler, wxEvtHandler) @@ -292,6 +293,23 @@ void wxResourceEditorDialogHandler::OnItemRightClick(wxControl *item, int x, int handlerDialog->PopupMenu(menu, x, y); } +// Under Windows 95, you can resize a panel interactively depending on +// window styles. +void wxResourceEditorDialogHandler::OnSize(wxSizeEvent& event) +{ + // Update the associated resource + int w, h; + handlerDialog->GetClientSize(& w, & h); + + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerDialog); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = handlerDialog->ConvertPixelsToDialog(wxSize(w, h)); + w = sz.x; h = sz.y; + } + resource->SetSize(resource->GetX(), resource->GetY(), w, h); +} + // An event outside any items: may be a drag event. void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent& event) { @@ -354,6 +372,15 @@ void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent& event) OnRightClick(x, y, keys); } + else if (event.LeftDClick()) + { + if (m_mouseCaptured) + { + handlerDialog->ReleaseMouse(); + m_mouseCaptured = FALSE; + } + wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog); + } } else event.Skip(); @@ -911,6 +938,9 @@ void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys), handlerControl->GetPosition(&xpos, &ypos); handlerControl->GetSize(&width, &height); + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl); + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl->GetParent()); + if (selectionHandle > 0) { int x1, y1, width1, height1; @@ -967,11 +997,33 @@ void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys), break; } handlerControl->SetSize(x1, y1, width1, height1); + + // Also update the associated resource + // We need to convert to dialog units if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(x1, y1)); + x1 = pt.x; y1 = pt.y; + wxSize sz = handlerControl->GetParent()->ConvertPixelsToDialog(wxSize(width1, height1)); + width1 = sz.x; height1 = sz.y; + } + resource->SetSize(x1, y1, width1, height1); } else { - handlerControl->Move((int)(x - dragOffsetX), (int)(y - dragOffsetY)); - OldOnMove((int)(x - dragOffsetX), (int)(y - dragOffsetY)); + int newX = (int)(x - dragOffsetX); + int newY = (int)(y - dragOffsetY); + handlerControl->Move(newX, newY); + OldOnMove(newX, newY); + + // Also update the associated resource + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY)); + newX = pt.x; newY = pt.y; + } + resource->SetSize(newX, newY, resource->GetWidth(), resource->GetHeight()); // Also move other selected items wxNode *node = panel->GetChildren()->First(); @@ -991,6 +1043,16 @@ void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys), item->Move(x2, y2); ((wxResourceEditorControlHandler *)item->GetEventHandler())->OldOnMove(x2, y2); ((wxResourceEditorControlHandler *)item->GetEventHandler())->DrawSelectionHandles(dc); + + // Also update the associated resource + resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY)); + x2 = pt.x; y2 = pt.y; + } + resource->SetSize(x2, y2, resource->GetWidth(), resource->GetHeight()); + } } node = node->Next(); diff --git a/utils/dialoged/src/dlghndlr.h b/utils/dialoged/src/dlghndlr.h index 948261a22e..80a9cf5ac8 100644 --- a/utils/dialoged/src/dlghndlr.h +++ b/utils/dialoged/src/dlghndlr.h @@ -50,6 +50,7 @@ DECLARE_CLASS(wxResourceEditorDialogHandler) void OnPaint(wxPaintEvent& event); void OnMouseEvent(wxMouseEvent& event); + void OnSize(wxSizeEvent& event); virtual void OnItemEvent(wxControl *win, wxMouseEvent& event); virtual void OnLeftClick(int x, int y, int keys); diff --git a/utils/dialoged/src/edtree.cpp b/utils/dialoged/src/edtree.cpp index a445963b7d..7bcd95b772 100644 --- a/utils/dialoged/src/edtree.cpp +++ b/utils/dialoged/src/edtree.cpp @@ -48,7 +48,7 @@ wxResourceEditorProjectTree::wxResourceEditorProjectTree(wxWindow* parent, wxWin { } -void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& event) +void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& WXUNUSED(event)) { #if 0 long sel = GetSelection(); @@ -70,7 +70,7 @@ void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& event) #endif } -void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& event) +void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& WXUNUSED(event)) { long sel = GetSelection(); if (sel == -1) diff --git a/utils/dialoged/src/reseditr.cpp b/utils/dialoged/src/reseditr.cpp index 507ced9872..46bf44ed4e 100644 --- a/utils/dialoged/src/reseditr.cpp +++ b/utils/dialoged/src/reseditr.cpp @@ -515,7 +515,7 @@ bool wxResourceManager::DisassociateWindows() { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); DisassociateResource(res); @@ -541,7 +541,7 @@ void wxResourceManager::AssociateResource(wxItemResource *resource, wxWindow *wi else { char buf[200]; - sprintf(buf, "AssociateResource: cannot find child window %s", child->GetName() ? child->GetName() : "(unnamed)"); + sprintf(buf, "AssociateResource: cannot find child window %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)"); wxMessageBox(buf, "Dialog Editor problem", wxOK); } @@ -644,7 +644,7 @@ wxItemResource *wxResourceManager::FindResourceForWindow(wxWindow *win) { m_resourceAssociations.BeginFind(); wxNode *node; - while (node = m_resourceAssociations.Next()) + while ((node = m_resourceAssociations.Next())) { wxWindow *w = (wxWindow *)node->Data(); if (w == win) @@ -675,8 +675,10 @@ void wxResourceManager::MakeUniqueName(char *prefix, char *buf) wxFrame *wxResourceManager::OnCreateEditorFrame(const char *title) { + /* int frameWidth = 420; int frameHeight = 300; + */ wxResourceEditorFrame *frame = new wxResourceEditorFrame(this, NULL, title, wxPoint(m_resourceEditorWindowSize.x, m_resourceEditorWindowSize.y), @@ -849,7 +851,7 @@ void wxResourceManager::UpdateResourceList() m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -956,6 +958,8 @@ bool wxResourceManager::CreateNewPanel() resource->SetType("wxDialog"); resource->SetName(buf); resource->SetTitle(buf); + resource->SetResourceStyle(wxRESOURCE_USE_DEFAULTS); + resource->SetResourceStyle(wxRESOURCE_DIALOG_UNITS); wxString newIdName; int id = GenerateWindowId("ID_DIALOG", newIdName); @@ -966,13 +970,19 @@ bool wxResourceManager::CreateNewPanel() m_resourceTable.AddResource(resource); + wxSize size(400, 300); + wxPanel *panel = new wxPanel(m_editorPanel, -1, wxPoint(m_editorPanel->GetMarginX(), m_editorPanel->GetMarginY()), - wxSize(400, 300), wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf); + size, wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf); m_editorPanel->m_childWindow = panel; resource->SetStyle(panel->GetWindowStyleFlag()); - resource->SetSize(10, 10, 400, 300); + + // Store dialog units in resource + size = panel->ConvertPixelsToDialog(size); + + resource->SetSize(10, 10, size.x, size.y); // For editing in situ we will need to use the hash table to ensure // we don't dereference invalid pointers. @@ -1006,7 +1016,14 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * wxItemResource *res = new wxItemResource; wxControl *newItem = NULL; - res->SetSize(x, y, -1, -1); + + if ((panelResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) + { + wxPoint pt = panel->ConvertPixelsToDialog(pt); + res->SetSize(pt.x, pt.y, -1, -1); + } + else res->SetSize(x, y, -1, -1); + res->SetType(iType); wxString prefix; @@ -1069,7 +1086,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel * wxString names[] = { "One", "Two" }; newItem = new wxRadioBox(panel, -1, "Radiobox", wxPoint(x, y), wxSize(-1, -1), 2, names, 2, wxHORIZONTAL, wxDefaultValidator, buf); - res->SetStringValues(new wxStringList("One", "Two", NULL)); + res->SetStringValues(wxStringList("One", "Two", NULL)); } else if (itemType == "wxRadioButton") { @@ -1183,16 +1200,13 @@ bool wxResourceManager::TestCurrentDialog(wxWindow* parent) InstantiateResourceFromWindow(item, m_editorPanel->m_childWindow, TRUE); wxDialog* dialog = new wxDialog; - long oldStyle = item->GetStyle(); bool success = FALSE; -// item->SetStyle(wxDEFAULT_DIALOG_STYLE); if (dialog->LoadFromResource(parent, item->GetName(), & m_resourceTable)) { dialog->Centre(); dialog->ShowModal(); success = TRUE; } -// item->SetStyle(oldStyle); return success; } return FALSE; @@ -1204,7 +1218,7 @@ wxWindow *wxResourceManager::FindParentOfSelection() { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxWindow *win = FindWindowForResource(res); @@ -1246,7 +1260,7 @@ void wxResourceManager::AlignItems(int flag) int centreX = (int)(firstX + (firstW / 2)); int centreY = (int)(firstY + (firstH / 2)); - while (node = node->Next()) + while ((node = node->Next())) { wxControl *item = (wxControl *)node->Data(); if (item->GetParent() == win) @@ -1325,10 +1339,8 @@ void wxResourceManager::CopySize() int firstW, firstH; firstSelection->GetPosition(&firstX, &firstY); firstSelection->GetSize(&firstW, &firstH); - int centreX = (int)(firstX + (firstW / 2)); - int centreY = (int)(firstY + (firstH / 2)); - while (node = node->Next()) + while ((node = node->Next())) { wxControl *item = (wxControl *)node->Data(); if (item->GetParent() == win) @@ -1389,7 +1401,7 @@ bool wxResourceManager::RemoveResourceFromParent(wxItemResource *res) { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *thisRes = (wxItemResource *)node->Data(); if (thisRes->GetChildren().Member(res)) @@ -1420,11 +1432,13 @@ bool wxResourceManager::DeleteResource(wxItemResource *res) // If this is a button or message resource, delete the // associate bitmap resource if not being used. wxString resType(res->GetType()); - + +/* shouldn't have to do this now bitmaps are ref-counted if ((resType == "wxMessage" || resType == "wxStaticBitmap" || resType == "wxButton" || resType == "wxBitmapButton") && res->GetValue4()) { PossiblyDeleteBitmapResource(res->GetValue4()); } +*/ // Remove symbol from table if appropriate if (!IsSymbolUsed(res, res->GetId())) @@ -1467,7 +1481,7 @@ bool wxResourceManager::DeleteResource(wxWindow *win) // Will eventually have bitmap type information, for different // kinds of bitmap. -char *wxResourceManager::AddBitmapResource(char *filename) +wxString wxResourceManager::AddBitmapResource(const wxString& filename) { wxItemResource *resource = FindBitmapResourceByFilename(filename); if (!resource) @@ -1496,11 +1510,11 @@ char *wxResourceManager::AddBitmapResource(char *filename) if (resource) return resource->GetName(); else - return NULL; + return wxEmptyString; } // Delete the bitmap resource if it isn't being used by another resource. -void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName) +void wxResourceManager::PossiblyDeleteBitmapResource(const wxString& resourceName) { if (!IsBitmapResourceUsed(resourceName)) { @@ -1510,11 +1524,11 @@ void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName) } } -bool wxResourceManager::IsBitmapResourceUsed(char *resourceName) +bool wxResourceManager::IsBitmapResourceUsed(const wxString& resourceName) { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -1538,13 +1552,13 @@ bool wxResourceManager::IsBitmapResourceUsed(char *resourceName) } // Given a wxButton or wxMessage, find the corresponding bitmap filename. -char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource) +wxString wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource) { - if (!resource || !resource->GetValue4()) - return NULL; + if (!resource || (resource->GetValue4() == "")) + return wxEmptyString; wxItemResource *bitmapResource = m_resourceTable.FindResource(resource->GetValue4()); if (!bitmapResource) - return NULL; + return wxEmptyString; wxNode *node = bitmapResource->GetChildren().First(); while (node) @@ -1557,14 +1571,14 @@ char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource) node = node->Next(); } - return NULL; + return wxEmptyString; } -wxItemResource *wxResourceManager::FindBitmapResourceByFilename(char *filename) +wxItemResource *wxResourceManager::FindBitmapResourceByFilename(const wxString& filename) { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -1591,7 +1605,7 @@ bool wxResourceManager::IsSymbolUsed(wxItemResource* thisResource, wxWindowID id { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); @@ -1634,7 +1648,7 @@ void wxResourceManager::ChangeIds(int oldId, int newId) { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); @@ -1666,7 +1680,7 @@ bool wxResourceManager::RepairResourceIds() m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -1742,6 +1756,9 @@ wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowP wxWindow *newWin = NULL; wxWindow *parent = win->GetParent(); + wxItemResource* parentResource = NULL; + if (parent) + FindResourceForWindow(parent); if (win->IsKindOf(CLASSINFO(wxPanel))) { @@ -1755,7 +1772,7 @@ wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowP win->PopEventHandler(TRUE); DeleteWindow(win); - newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource); + newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource, parentResource); newWin->PushEventHandler(new wxResourceEditorControlHandler((wxControl*) newWin, (wxControl*) newWin)); AssociateResource(resource, newWin); UpdateResourceList(); @@ -1811,7 +1828,7 @@ bool wxResourceManager::RecreateSelection() return TRUE; } -bool wxResourceManager::EditDialog(wxDialog *dialog, wxWindow *parent) +bool wxResourceManager::EditDialog(wxDialog *WXUNUSED(dialog), wxWindow *WXUNUSED(parent)) { return FALSE; } @@ -1822,7 +1839,7 @@ bool wxResourceManager::InstantiateAllResourcesFromWindows() { m_resourceTable.BeginFind(); wxNode *node; - while (node = m_resourceTable.Next()) + while ((node = m_resourceTable.Next())) { wxItemResource *res = (wxItemResource *)node->Data(); wxString resType(res->GetType()); @@ -1861,7 +1878,7 @@ bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource *resource, if (!childWindow) { char buf[200]; - sprintf(buf, "Could not find window %s", child->GetName()); + sprintf(buf, "Could not find window %s", (const char*) child->GetName()); wxMessageBox(buf, "Dialog Editor problem", wxOK); } else @@ -2231,7 +2248,7 @@ EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& s { } -bool EditorToolBar::OnLeftClick(int toolIndex, bool toggled) +bool EditorToolBar::OnLeftClick(int toolIndex, bool WXUNUSED(toggled)) { wxResourceManager *manager = wxResourceManager::GetCurrentResourceManager(); diff --git a/utils/dialoged/src/reseditr.h b/utils/dialoged/src/reseditr.h index 8b8af13ad2..221310c0d6 100644 --- a/utils/dialoged/src/reseditr.h +++ b/utils/dialoged/src/reseditr.h @@ -117,7 +117,7 @@ class wxResourceTableWithSaving: public wxResourceTable m_styleTable.Init(); } virtual bool Save(const wxString& filename); - virtual bool SaveResource(ostream& stream, wxItemResource *item); + virtual bool SaveResource(ostream& stream, wxItemResource* item, wxItemResource* parentItem); void GeneratePanelStyleString(long windowStyle, char *buf); void GenerateDialogStyleString(long windowStyle, char *buf); @@ -144,8 +144,8 @@ class wxResourceTableWithSaving: public wxResourceTable bool GenerateStyle(char *buf, long windowStyle, long flag, char *strStyle); */ - void OutputFont(ostream& stream, wxFont *font); - wxControl *CreateItem(wxPanel *panel, wxItemResource *childResource); + void OutputFont(ostream& stream, const wxFont& font); + wxControl *CreateItem(wxPanel *panel, const wxItemResource *childResource, const wxItemResource* parentResource); protected: wxWindowStyleTable m_styleTable; @@ -219,17 +219,17 @@ public: virtual bool DeleteResource(wxWindow *win); // Add bitmap resource if there isn't already one with this filename. - virtual char *AddBitmapResource(char *filename); + virtual wxString AddBitmapResource(const wxString& filename); // Delete the bitmap resource if it isn't being used by another resource. - virtual void PossiblyDeleteBitmapResource(char *resourceName); + virtual void PossiblyDeleteBitmapResource(const wxString& resourceName); // Helper function for above - virtual bool IsBitmapResourceUsed(char *resourceName); + virtual bool IsBitmapResourceUsed(const wxString& resourceName); - wxItemResource *FindBitmapResourceByFilename(char *filename); + wxItemResource *FindBitmapResourceByFilename(const wxString& filename); - char *FindBitmapFilenameForResource(wxItemResource *resource); + wxString FindBitmapFilenameForResource(wxItemResource *resource); // Is this window identifier in use? bool IsSymbolUsed(wxItemResource* thisResource, wxWindowID id) ; diff --git a/utils/dialoged/src/reswrite.cpp b/utils/dialoged/src/reswrite.cpp index dec8278fa8..57b0ed849e 100644 --- a/utils/dialoged/src/reswrite.cpp +++ b/utils/dialoged/src/reswrite.cpp @@ -43,27 +43,27 @@ #include "reseditr.h" char *SafeString(char *s); -char *SafeWord(char *s); +char *SafeWord(const wxString& s); // Save an association between the child resource and the panel item, to allow // us not to require unique window names. -wxControl *wxResourceTableWithSaving::CreateItem(wxPanel *panel, wxItemResource *childResource) +wxControl *wxResourceTableWithSaving::CreateItem(wxPanel *panel, const wxItemResource *childResource, const wxItemResource* parentResource) { - wxControl *item = wxResourceTable::CreateItem(panel, childResource); + wxControl *item = wxResourceTable::CreateItem(panel, childResource, parentResource); if (item) wxResourceManager::GetCurrentResourceManager()->GetResourceAssociations().Put((long)childResource, item); return item; } -void wxResourceTableWithSaving::OutputFont(ostream& stream, wxFont *font) +void wxResourceTableWithSaving::OutputFont(ostream& stream, const wxFont& font) { - stream << "[" << font->GetPointSize() << ", '"; - stream << font->GetFamilyString() << "', '"; - stream << font->GetStyleString() << "', '"; - stream << font->GetWeightString() << "', "; - stream << (int)font->GetUnderlined(); - if (font->GetFaceName() != "") - stream << ", '" << font->GetFaceName() << "'"; + stream << "[" << font.GetPointSize() << ", '"; + stream << font.GetFamilyString() << "', '"; + stream << font.GetStyleString() << "', '"; + stream << font.GetWeightString() << "', "; + stream << (int)font.GetUnderlined(); + if (font.GetFaceName() != "") + stream << ", '" << font.GetFaceName() << "'"; stream << "]"; } @@ -79,21 +79,21 @@ bool wxResourceTableWithSaving::Save(const wxString& filename) BeginFind(); wxNode *node = NULL; - while (node = Next()) + while ((node = Next())) { wxItemResource *item = (wxItemResource *)node->Data(); wxString resType(item->GetType()); if (resType == "wxDialogBox" || resType == "wxDialog" || resType == "wxPanel" || resType == "wxBitmap") { - if (!SaveResource(stream, item)) + if (!SaveResource(stream, item, (wxItemResource*) NULL)) return FALSE; } } return TRUE; } -bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *item) +bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource* item, wxItemResource* parentItem) { char styleBuf[400]; wxString itemType(item->GetType()); @@ -110,6 +110,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << "static char *" << item->GetName() << " = \"panel(name = '" << item->GetName() << "',\\\n"; GenerateDialogStyleString(item->GetStyle(), styleBuf); } + stream << " style = '" << styleBuf << "',\\\n"; stream << " title = '" << item->GetTitle() << "',\\\n"; stream << " id = " << item->GetId() << ",\\\n"; @@ -118,19 +119,29 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it if (1) // item->GetStyle() & wxNO_3D) { - if (item->GetBackgroundColour()) + if (item->GetBackgroundColour().Ok()) { char buf[7]; - wxDecToHex(item->GetBackgroundColour()->Red(), buf); - wxDecToHex(item->GetBackgroundColour()->Green(), buf+2); - wxDecToHex(item->GetBackgroundColour()->Blue(), buf+4); + wxDecToHex(item->GetBackgroundColour().Red(), buf); + wxDecToHex(item->GetBackgroundColour().Green(), buf+2); + wxDecToHex(item->GetBackgroundColour().Blue(), buf+4); buf[6] = 0; stream << ",\\\n " << "background_colour = '" << buf << "'"; } } + + int dialogUnits = 0; + int useDefaults = 0; + if ((item->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) + dialogUnits = 1; + if ((item->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) + useDefaults = 1; + + stream << ",\\\n " << "use_dialog_units = " << dialogUnits; + stream << ",\\\n " << "use_system_defaults = " << useDefaults; - if (item->GetFont() && item->GetFont()->Ok()) + if (item->GetFont().Ok()) { stream << ",\\\n font = "; OutputFont(stream, item->GetFont()); @@ -147,7 +158,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << " control = ["; - SaveResource(stream, child); + SaveResource(stream, child, item); stream << "]"; @@ -165,7 +176,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << item->GetWidth() << ", " << item->GetHeight(); if (item->GetValue4()) stream << ", '" << item->GetValue4() << "'"; - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -179,7 +190,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << item->GetWidth() << ", " << item->GetHeight(); if (item->GetValue4()) stream << ", '" << item->GetValue4() << "'"; - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -192,7 +203,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; stream << item->GetWidth() << ", " << item->GetHeight(); stream << ", " << item->GetValue1(); - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -205,7 +216,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; stream << item->GetWidth() << ", " << item->GetHeight(); stream << ", " << item->GetValue1(); - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -217,7 +228,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << item->GetId() << ", " << "wxStaticBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; stream << item->GetWidth() << ", " << item->GetHeight(); - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -231,7 +242,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; stream << item->GetWidth() << ", " << item->GetHeight(); stream << ", " << SafeWord(item->GetValue4()); - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -244,7 +255,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; stream << item->GetWidth() << ", " << item->GetHeight(); stream << ", " << item->GetValue1() << ", " << item->GetValue2(); - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -257,7 +268,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; stream << item->GetWidth() << ", " << item->GetHeight(); stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3(); - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -282,9 +293,9 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it // Default list of values stream << ", ["; - if (item->GetStringValues()) + if (item->GetStringValues().Number() > 0) { - wxNode *node = item->GetStringValues()->First(); + wxNode *node = item->GetStringValues().First(); while (node) { char *s = (char *)node->Data(); @@ -314,7 +325,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it break; } } - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -334,9 +345,9 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it // Default list of values stream << ", ["; - if (item->GetStringValues()) + if (item->GetStringValues().Number() > 0) { - wxNode *node = item->GetStringValues()->First(); + wxNode *node = item->GetStringValues().First(); while (node) { char *s = (char *)node->Data(); @@ -347,7 +358,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it } } stream << "]"; - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -364,9 +375,9 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it // Default list of values stream << ", ["; - if (item->GetStringValues()) + if (item->GetStringValues().Number() > 0) { - wxNode *node = item->GetStringValues()->First(); + wxNode *node = item->GetStringValues().First(); while (node) { char *s = (char *)node->Data(); @@ -377,7 +388,7 @@ bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *it } } stream << "], " << item->GetValue1(); - if (item->GetFont()) + if (item->GetFont().Ok()) { stream << ",\\\n "; OutputFont(stream, item->GetFont()); @@ -552,9 +563,9 @@ void wxResourceTableWithSaving::GenerateControlStyleString(const wxString& windo } // Returns quoted string or "NULL" -char *SafeString(char *s) +char *SafeString(const wxString& s) { - if (!s) + if (s == "") return "NULL"; else { @@ -566,14 +577,14 @@ char *SafeString(char *s) } // Returns quoted string or '' -char *SafeWord(char *s) +char *SafeWord(const wxString& s) { - if (!s) + if (s == "") return "''"; else { strcpy(wxBuffer, "'"); - strcat(wxBuffer, s); + strcat(wxBuffer, (const char*) s); strcat(wxBuffer, "'"); return wxBuffer; } diff --git a/utils/dialoged/src/symbtabl.cpp b/utils/dialoged/src/symbtabl.cpp index 48c0cb40ae..b82e0ccb37 100644 --- a/utils/dialoged/src/symbtabl.cpp +++ b/utils/dialoged/src/symbtabl.cpp @@ -70,7 +70,7 @@ bool wxResourceSymbolTable::ReadIncludeFile(const wxString& filename) str.UngetWriteBuf(); // Look for #define occurrences - size_t pos = str.Find("#define"); + int pos = str.Find("#define"); while (pos != -1) { size_t len = str.Length(); diff --git a/utils/dialoged/src/winprop.cpp b/utils/dialoged/src/winprop.cpp index 7902ece0b9..7eabff4260 100644 --- a/utils/dialoged/src/winprop.cpp +++ b/utils/dialoged/src/winprop.cpp @@ -49,8 +49,9 @@ void wxResourcePropertyListView::OnPropertyChanged(wxProperty *property) // IF the property value was modified. if (property->GetValue().GetModified()) { - propertyInfo->SetProperty(property->GetName(), property); + m_propertyInfo->SetProperty(property->GetName(), property); property->GetValue().SetModified(FALSE); + wxResourceManager::GetCurrentResourceManager()->Modify(TRUE); } } @@ -114,7 +115,7 @@ wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame() // Edit the information represented by this object, whatever that // might be. -bool wxPropertyInfo::Edit(wxWindow *parent, const wxString& title) +bool wxPropertyInfo::Edit(wxWindow *WXUNUSED(parent), const wxString& title) { if (sm_propertyWindow) { @@ -156,18 +157,18 @@ bool wxPropertyInfo::Edit(wxWindow *parent, const wxString& title) wxSize(width, height), wxDEFAULT_FRAME_STYLE); sm_propertyWindow = propWin; - propWin->m_registry.RegisterValidator((wxString)"real", new wxRealListValidator); - propWin->m_registry.RegisterValidator((wxString)"string", new wxStringListValidator); - propWin->m_registry.RegisterValidator((wxString)"integer", new wxIntegerListValidator); - propWin->m_registry.RegisterValidator((wxString)"bool", new wxBoolListValidator); - propWin->m_registry.RegisterValidator((wxString)"filename", new wxFilenameListValidator); - propWin->m_registry.RegisterValidator((wxString)"stringlist", new wxListOfStringsListValidator); - propWin->m_registry.RegisterValidator((wxString)"window_id", new wxResourceSymbolValidator); + propWin->m_registry.RegisterValidator(wxString("real"), new wxRealListValidator); + propWin->m_registry.RegisterValidator(wxString("string"), new wxStringListValidator); + propWin->m_registry.RegisterValidator(wxString("integer"), new wxIntegerListValidator); + propWin->m_registry.RegisterValidator(wxString("bool"), new wxBoolListValidator); + propWin->m_registry.RegisterValidator(wxString("filename"), new wxFilenameListValidator); + propWin->m_registry.RegisterValidator(wxString("stringlist"), new wxListOfStringsListValidator); + propWin->m_registry.RegisterValidator(wxString("window_id"), new wxResourceSymbolValidator); propWin->m_propInfo = this; propWin->m_propSheet = propSheet; -// view->propertyWindow = propWin; +// view->m_propertyWindow = propWin; view->AddRegistry(&(propWin->m_registry)); propWin->Initialize(); @@ -183,8 +184,8 @@ bool wxPropertyInfo::Edit(wxWindow *parent, const wxString& title) wxWindowPropertyInfo::wxWindowPropertyInfo(wxWindow *win, wxItemResource *res) { - propertyWindow = win; - propertyResource = res; + m_propertyWindow = win; + m_propertyResource = res; } wxWindowPropertyInfo::~wxWindowPropertyInfo(void) @@ -279,41 +280,35 @@ wxFont *wxWindowPropertyInfo::SetFontProperty(wxString& name, wxProperty *proper wxProperty *wxWindowPropertyInfo::GetProperty(wxString& name) { - wxFont *font = propertyWindow->GetFont(); + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + + wxFont *font = m_propertyWindow->GetFont(); if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined") return GetFontProperty(name, font); else if (name == "name") - return new wxProperty("name", propertyWindow->GetName(), "string"); + return new wxProperty("name", m_propertyWindow->GetName(), "string"); else if (name == "title") - return new wxProperty("title", propertyWindow->GetTitle(), "string"); + return new wxProperty("title", m_propertyWindow->GetTitle(), "string"); else if (name == "x") { - int x, y; - propertyWindow->GetPosition(&x, &y); - return new wxProperty("x", (long)x, "integer"); + return new wxProperty("x", (long)resource->GetX(), "integer"); } else if (name == "y") { - int x, y; - propertyWindow->GetPosition(&x, &y); - return new wxProperty("y", (long)y, "integer"); + return new wxProperty("y", (long)resource->GetY(), "integer"); } else if (name == "width") { - int width, height; - propertyWindow->GetSize(&width, &height); - return new wxProperty("width", (long)width, "integer"); + return new wxProperty("width", (long)resource->GetWidth(), "integer"); } else if (name == "height") { - int width, height; - propertyWindow->GetSize(&width, &height); - return new wxProperty("height", (long)height, "integer"); + return new wxProperty("width", (long)resource->GetHeight(), "integer"); } else if (name == "id") { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); if (resource) { int id = resource->GetId(); @@ -331,15 +326,15 @@ wxProperty *wxWindowPropertyInfo::GetProperty(wxString& name) else if (name == "border") { wxString border(""); - if (propertyWindow->GetWindowStyleFlag() & wxSIMPLE_BORDER) + if (m_propertyWindow->GetWindowStyleFlag() & wxSIMPLE_BORDER) border = "wxSIMPLE_BORDER"; - else if (propertyWindow->GetWindowStyleFlag() & wxRAISED_BORDER) + else if (m_propertyWindow->GetWindowStyleFlag() & wxRAISED_BORDER) border = "wxRAISED_BORDER"; - else if (propertyWindow->GetWindowStyleFlag() & wxSUNKEN_BORDER) + else if (m_propertyWindow->GetWindowStyleFlag() & wxSUNKEN_BORDER) border = "wxSUNKEN_BORDER"; - else if (propertyWindow->GetWindowStyleFlag() & wxDOUBLE_BORDER) + else if (m_propertyWindow->GetWindowStyleFlag() & wxDOUBLE_BORDER) border = "wxDOUBLE_BORDER"; - else if (propertyWindow->GetWindowStyleFlag() & wxSTATIC_BORDER) + else if (m_propertyWindow->GetWindowStyleFlag() & wxSTATIC_BORDER) border = "wxSTATIC_BORDER"; else border = "wxNO_BORDER"; @@ -354,30 +349,30 @@ wxProperty *wxWindowPropertyInfo::GetProperty(wxString& name) bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxFont *font = propertyWindow->GetFont(); + wxFont *font = m_propertyWindow->GetFont(); if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" )) { wxFont *newFont = SetFontProperty(name, property, font); if (newFont) - propertyWindow->SetFont(newFont); + m_propertyWindow->SetFont(newFont); return TRUE; } else if (name == "name") { // Remove old name from resource table, if it's there. - wxItemResource *oldResource = (wxItemResource *)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(propertyWindow->GetName()); + wxItemResource *oldResource = (wxItemResource *)wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Delete(m_propertyWindow->GetName()); if (oldResource) { // It's a top-level resource - propertyWindow->SetName(property->GetValue().StringValue()); + m_propertyWindow->SetName(property->GetValue().StringValue()); oldResource->SetName(property->GetValue().StringValue()); - wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(propertyWindow->GetName(), oldResource); + wxResourceManager::GetCurrentResourceManager()->GetResourceTable().Put(m_propertyWindow->GetName(), oldResource); } else { // It's a child of something; just set the name of the resource and the window. - propertyWindow->SetName(property->GetValue().StringValue()); - propertyResource->SetName(property->GetValue().StringValue()); + m_propertyWindow->SetName(property->GetValue().StringValue()); + m_propertyResource->SetName(property->GetValue().StringValue()); } // Refresh the resource manager list, because the name changed. wxResourceManager::GetCurrentResourceManager()->UpdateResourceList(); @@ -385,64 +380,140 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) } else if (name == "title") { - propertyWindow->SetTitle(property->GetValue().StringValue()); + m_propertyWindow->SetTitle(property->GetValue().StringValue()); return TRUE; } else if (name == "x") { int x, y; - propertyWindow->GetPosition(&x, &y); + m_propertyWindow->GetPosition(&x, &y); int newX = (int)property->GetValue().IntegerValue(); + + // We need to convert to pixels if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(newX, y)); + newX = pt.x; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(newX, y)); + newX = pt.x; + } + } + if (x != newX) - propertyWindow->Move(newX, y); + m_propertyWindow->Move(newX, y); return TRUE; } else if (name == "y") { int x, y; - propertyWindow->GetPosition(&x, &y); + m_propertyWindow->GetPosition(&x, &y); int newY = (int)property->GetValue().IntegerValue(); + + // We need to convert to pixels if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(x, newY)); + newY = pt.y; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(x, newY)); + newY = pt.y; + } + } + if (y != newY) - propertyWindow->Move(x, newY); + m_propertyWindow->Move(x, newY); return TRUE; } else if (name == "width") { int width, height; - propertyWindow->GetSize(&width, &height); + m_propertyWindow->GetSize(&width, &height); int newWidth = (int)property->GetValue().IntegerValue(); + + // We need to convert to pixels if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(newWidth, height)); + newWidth = sz.x; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(newWidth, height)); + newWidth = sz.x; + } + } + if (width != newWidth) { - propertyWindow->SetSize(newWidth, height); -/* - if (propertyWindow->IsKindOf(CLASSINFO(wxPanel)) && !propertyWindow->IsKindOf(CLASSINFO(wxDialog))) - { - propertyWindow->GetParent()->SetClientSize(newWidth, height); - } -*/ + m_propertyWindow->SetSize(newWidth, height); } return TRUE; } else if (name == "height") { int width, height; - propertyWindow->GetSize(&width, &height); + m_propertyWindow->GetSize(&width, &height); int newHeight = (int)property->GetValue().IntegerValue(); + + // We need to convert to pixels if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(width, newHeight)); + newHeight = sz.y; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(width, newHeight)); + newHeight = sz.y; + } + } + if (height != newHeight) { - propertyWindow->SetSize(width, newHeight); -/* - if (propertyWindow->IsKindOf(CLASSINFO(wxPanel)) && !propertyWindow->IsKindOf(CLASSINFO(wxDialog))) - { - propertyWindow->GetParent()->SetClientSize(width, newHeight); - } -*/ + m_propertyWindow->SetSize(width, newHeight); } return TRUE; } else if (name == "id") { - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); if (resource) { wxString value = property->GetValue().StringValue(); @@ -532,17 +603,17 @@ bool wxWindowPropertyInfo::SetProperty(wxString& name, wxProperty *property) else borderStyle = wxNO_BORDER; - SetWindowStyle(propertyWindow, wxSIMPLE_BORDER, FALSE); - SetWindowStyle(propertyWindow, wxRAISED_BORDER, FALSE); - SetWindowStyle(propertyWindow, wxSUNKEN_BORDER, FALSE); - SetWindowStyle(propertyWindow, wxDOUBLE_BORDER, FALSE); - SetWindowStyle(propertyWindow, wxSTATIC_BORDER, FALSE); - SetWindowStyle(propertyWindow, wxNO_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxSIMPLE_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxRAISED_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxSUNKEN_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxDOUBLE_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxSTATIC_BORDER, FALSE); + SetWindowStyle(m_propertyWindow, wxNO_BORDER, FALSE); - SetWindowStyle(propertyWindow, borderStyle, TRUE); + SetWindowStyle(m_propertyWindow, borderStyle, TRUE); - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow); - resource->SetStyle(propertyWindow->GetWindowStyleFlag()); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); return TRUE; } else @@ -558,7 +629,7 @@ void wxWindowPropertyInfo::GetPropertyNames(wxStringList& names) names.Add("width"); names.Add("height"); names.Add("border"); - if (!propertyWindow->IsKindOf(CLASSINFO(wxControl))) + if (!m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) { names.Add("fontPoints"); names.Add("fontFamily"); @@ -571,16 +642,49 @@ void wxWindowPropertyInfo::GetPropertyNames(wxStringList& names) // Fill in the wxItemResource members to mirror the current window settings bool wxWindowPropertyInfo::InstantiateResource(wxItemResource *resource) { -// resource->SetType(propertyWindow->GetClassInfo()->GetClassName()); - -// resource->SetStyle(propertyWindow->GetWindowStyleFlag()); - wxString str(propertyWindow->GetName()); - resource->SetName(WXSTRINGCAST str); +// resource->SetType(m_propertyWindow->GetClassInfo()->GetClassName()); + +// resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); + wxString str(m_propertyWindow->GetName()); + resource->SetName(str); + +#if 0 int x, y, w, h; - propertyWindow->GetSize(&w, &h); - propertyWindow->GetPosition(&x, &y); + if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + m_propertyWindow->GetClientSize(&w, &h); + else + m_propertyWindow->GetSize(&w, &h); + + m_propertyWindow->GetPosition(&x, &y); + + // We need to convert to dialog units if this is not a dialog or panel, but + // the parent resource specifies dialog units. + if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl))) + { + wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent()); + if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y)); + x = pt.x; y = pt.y; + wxSize sz = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxSize(w, h)); + w = sz.x; h = sz.y; + } + } + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel))) + { + if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) + { + wxPoint pt = m_propertyWindow->ConvertPixelsToDialog(wxPoint(x, y)); + x = pt.x; y = pt.y; + wxSize sz = m_propertyWindow->ConvertPixelsToDialog(wxSize(w, h)); + w = sz.x; h = sz.y; + } + } + resource->SetSize(x, y, w, h); +#endif + return TRUE; } @@ -612,21 +716,21 @@ void wxWindowPropertyInfo::SetWindowStyle(wxWindow* win, long style, bool set) wxProperty *wxItemPropertyInfo::GetProperty(wxString& name) { - wxControl *itemWindow = (wxControl *)propertyWindow; + wxControl *itemWindow = (wxControl *)m_propertyWindow; wxFont *font = itemWindow->GetFont(); if (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined") return GetFontProperty(name, font); else if (name == "label" && itemWindow->GetLabel()) - return new wxProperty("label", propertyWindow->GetLabel(), "string"); + return new wxProperty("label", m_propertyWindow->GetLabel(), "string"); else return wxWindowPropertyInfo::GetProperty(name); } bool wxItemPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxControl *itemWindow = (wxControl *)propertyWindow; + wxControl *itemWindow = (wxControl *)m_propertyWindow; wxFont *font = itemWindow->GetFont(); if (font && (name == "fontPoints" || name == "fontFamily" || name == "fontStyle" || name == "fontWeight" || name == "fontUnderlined" )) @@ -660,9 +764,9 @@ bool wxItemPropertyInfo::InstantiateResource(wxItemResource *resource) { wxWindowPropertyInfo::InstantiateResource(resource); - wxControl *item = (wxControl *)propertyWindow; + wxControl *item = (wxControl *)m_propertyWindow; wxString str(item->GetLabel()); - resource->SetTitle(WXSTRINGCAST str); + resource->SetTitle(str); if (item->GetFont() && item->GetFont()->Ok()) resource->SetFont(wxTheFontList->FindOrCreateFont(item->GetFont()->GetPointSize(), item->GetFont()->GetFamily(), item->GetFont()->GetStyle(), item->GetFont()->GetWeight(), @@ -676,13 +780,11 @@ bool wxItemPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxButtonPropertyInfo::GetProperty(wxString& name) { - wxButton *button = (wxButton *)propertyWindow; return wxItemPropertyInfo::GetProperty(name); } bool wxButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxButton *button = (wxButton *)propertyWindow; return wxItemPropertyInfo::SetProperty(name, property); } @@ -703,7 +805,7 @@ bool wxButtonPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxBitmapButtonPropertyInfo::GetProperty(wxString& name) { - wxBitmapButton *button = (wxBitmapButton *)propertyWindow; + wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow; if (name == "label") { wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(button); @@ -711,9 +813,7 @@ wxProperty *wxBitmapButtonPropertyInfo::GetProperty(wxString& name) if (resource) { - char *filename = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); - if (filename) - str = filename; + str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); } return new wxProperty("label", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); } @@ -723,7 +823,7 @@ wxProperty *wxBitmapButtonPropertyInfo::GetProperty(wxString& name) bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxBitmapButton *button = (wxBitmapButton *)propertyWindow; + wxBitmapButton *button = (wxBitmapButton *)m_propertyWindow; if (name == "label") { char *s = property->GetValue().StringValue(); @@ -743,11 +843,11 @@ bool wxBitmapButtonPropertyInfo::SetProperty(wxString& name, wxProperty *propert if (resource) { wxString oldResource(resource->GetValue4()); - char *resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s); + wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s); resource->SetValue4(resName); if (!oldResource.IsNull()) - wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(WXSTRINGCAST oldResource); + wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource); } button->SetLabel(bitmap); @@ -778,13 +878,11 @@ bool wxBitmapButtonPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxStaticTextPropertyInfo::GetProperty(wxString& name) { - wxStaticText *message = (wxStaticText *)propertyWindow; return wxItemPropertyInfo::GetProperty(name); } bool wxStaticTextPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxStaticText *message = (wxStaticText *)propertyWindow; return wxItemPropertyInfo::SetProperty(name, property); } @@ -805,7 +903,7 @@ bool wxStaticTextPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxStaticBitmapPropertyInfo::GetProperty(wxString& name) { - wxStaticBitmap *message = (wxStaticBitmap *)propertyWindow; + wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow; if (name == "label") { wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(message); @@ -813,9 +911,7 @@ wxProperty *wxStaticBitmapPropertyInfo::GetProperty(wxString& name) if (resource) { - char *filename = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); - if (filename) - str = filename; + str = wxResourceManager::GetCurrentResourceManager()->FindBitmapFilenameForResource(resource); } return new wxProperty("label", str.GetData(), "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp")); } @@ -825,7 +921,7 @@ wxProperty *wxStaticBitmapPropertyInfo::GetProperty(wxString& name) bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxStaticBitmap *message = (wxStaticBitmap *)propertyWindow; + wxStaticBitmap *message = (wxStaticBitmap *)m_propertyWindow; if (name == "label") { char *s = property->GetValue().StringValue(); @@ -846,11 +942,11 @@ bool wxStaticBitmapPropertyInfo::SetProperty(wxString& name, wxProperty *propert if (resource) { wxString oldResource(resource->GetValue4()); - char *resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s); + wxString resName = wxResourceManager::GetCurrentResourceManager()->AddBitmapResource(s); resource->SetValue4(resName); if (!oldResource.IsNull()) - wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(WXSTRINGCAST oldResource); + wxResourceManager::GetCurrentResourceManager()->PossiblyDeleteBitmapResource(oldResource); } message->SetBitmap(bitmap); @@ -881,7 +977,7 @@ bool wxStaticBitmapPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxTextPropertyInfo::GetProperty(wxString& name) { - wxTextCtrl *text = (wxTextCtrl *)propertyWindow; + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; if (name == "value") return new wxProperty("value", text->GetValue(), "string"); else if (name == "password") @@ -900,7 +996,7 @@ wxProperty *wxTextPropertyInfo::GetProperty(wxString& name) bool wxTextPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxTextCtrl *text = (wxTextCtrl *)propertyWindow; + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; if (name == "value") { text->SetValue(property->GetValue().StringValue()); @@ -958,9 +1054,9 @@ void wxTextPropertyInfo::GetPropertyNames(wxStringList& names) bool wxTextPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxTextCtrl *text = (wxTextCtrl *)propertyWindow; + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; wxString str(text->GetValue()); - resource->SetValue4(WXSTRINGCAST str); + resource->SetValue4(str); return wxItemPropertyInfo::InstantiateResource(resource); } @@ -971,7 +1067,7 @@ bool wxTextPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxListBoxPropertyInfo::GetProperty(wxString& name) { - wxListBox *listBox = (wxListBox *)propertyWindow; + wxListBox *listBox = (wxListBox *)m_propertyWindow; if (name == "values") { wxStringList *stringList = new wxStringList; @@ -983,7 +1079,6 @@ wxProperty *wxListBoxPropertyInfo::GetProperty(wxString& name) } else if (name == "multiple") { - char *pos = NULL; wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(listBox); if (!resource) return NULL; @@ -1013,7 +1108,7 @@ wxProperty *wxListBoxPropertyInfo::GetProperty(wxString& name) bool wxListBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxListBox *listBox = (wxListBox *)propertyWindow; + wxListBox *listBox = (wxListBox *)m_propertyWindow; if (name == "values") { listBox->Clear(); @@ -1056,7 +1151,7 @@ void wxListBoxPropertyInfo::GetPropertyNames(wxStringList& names) bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxListBox *lbox = (wxListBox *)propertyWindow; + wxListBox *lbox = (wxListBox *)m_propertyWindow; // This will be set for the wxItemResource on reading or in SetProperty // resource->SetValue1(lbox->GetSelectionMode()); int i; @@ -1064,10 +1159,10 @@ bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource *resource) resource->SetStringValues(NULL); else { - wxStringList *slist = new wxStringList; + wxStringList slist; for (i = 0; i < lbox->Number(); i++) - slist->Add(lbox->GetString(i)); + slist.Add(lbox->GetString(i)); resource->SetStringValues(slist); } @@ -1080,10 +1175,10 @@ bool wxListBoxPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxChoicePropertyInfo::GetProperty(wxString& name) { - wxChoice *choice = (wxChoice *)propertyWindow; + wxChoice *choice = (wxChoice *)m_propertyWindow; if (name == "values") { - wxStringList *stringList = new wxStringList; + wxStringList* stringList = new wxStringList; int i; for (i = 0; i < choice->Number(); i++) stringList->Add(choice->GetString(i)); @@ -1096,7 +1191,7 @@ wxProperty *wxChoicePropertyInfo::GetProperty(wxString& name) bool wxChoicePropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxChoice *choice = (wxChoice *)propertyWindow; + wxChoice *choice = (wxChoice *)m_propertyWindow; if (name == "values") { choice->Clear(); @@ -1124,16 +1219,16 @@ void wxChoicePropertyInfo::GetPropertyNames(wxStringList& names) bool wxChoicePropertyInfo::InstantiateResource(wxItemResource *resource) { - wxChoice *choice = (wxChoice *)propertyWindow; + wxChoice *choice = (wxChoice *)m_propertyWindow; int i; if (choice->Number() == 0) resource->SetStringValues(NULL); else { - wxStringList *slist = new wxStringList; + wxStringList slist; for (i = 0; i < choice->Number(); i++) - slist->Add(choice->GetString(i)); + slist.Add(choice->GetString(i)); resource->SetStringValues(slist); } @@ -1146,7 +1241,7 @@ bool wxChoicePropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxComboBoxPropertyInfo::GetProperty(wxString& name) { - wxComboBox *choice = (wxComboBox *)propertyWindow; + wxComboBox *choice = (wxComboBox *)m_propertyWindow; if (name == "values") { wxStringList *stringList = new wxStringList; @@ -1158,15 +1253,15 @@ wxProperty *wxComboBoxPropertyInfo::GetProperty(wxString& name) } else if (name == "sort") { - bool sort = ((propertyWindow->GetWindowStyleFlag() & wxCB_SORT) == wxCB_SORT); + bool sort = ((m_propertyWindow->GetWindowStyleFlag() & wxCB_SORT) == wxCB_SORT); return new wxProperty(name, sort, "bool"); } else if (name == "style") { wxString styleStr("dropdown"); - if (propertyWindow->GetWindowStyleFlag() & wxCB_SIMPLE) + if (m_propertyWindow->GetWindowStyleFlag() & wxCB_SIMPLE) styleStr = "simple"; - else if (propertyWindow->GetWindowStyleFlag() & wxCB_READONLY) + else if (m_propertyWindow->GetWindowStyleFlag() & wxCB_READONLY) styleStr = "readonly"; else styleStr = "dropdown"; @@ -1181,7 +1276,7 @@ wxProperty *wxComboBoxPropertyInfo::GetProperty(wxString& name) bool wxComboBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxComboBox *choice = (wxComboBox *)propertyWindow; + wxComboBox *choice = (wxComboBox *)m_propertyWindow; if (name == "values") { choice->Clear(); @@ -1199,33 +1294,33 @@ bool wxComboBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) } else if (name == "sort") { - SetWindowStyle(propertyWindow, wxCB_SORT, property->GetValue().BoolValue()); + SetWindowStyle(m_propertyWindow, wxCB_SORT, property->GetValue().BoolValue()); - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow); - resource->SetStyle(propertyWindow->GetWindowStyleFlag()); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(propertyWindow, this); + wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); return TRUE; } else if (name == "style") { - SetWindowStyle(propertyWindow, wxCB_SIMPLE, FALSE); - SetWindowStyle(propertyWindow, wxCB_DROPDOWN, FALSE); - SetWindowStyle(propertyWindow, wxCB_READONLY, FALSE); + SetWindowStyle(m_propertyWindow, wxCB_SIMPLE, FALSE); + SetWindowStyle(m_propertyWindow, wxCB_DROPDOWN, FALSE); + SetWindowStyle(m_propertyWindow, wxCB_READONLY, FALSE); wxString styleStr(property->GetValue().StringValue()); if (styleStr == "simple") - SetWindowStyle(propertyWindow, wxCB_SIMPLE, TRUE); + SetWindowStyle(m_propertyWindow, wxCB_SIMPLE, TRUE); else if (styleStr == "dropdown") - SetWindowStyle(propertyWindow, wxCB_DROPDOWN, TRUE); + SetWindowStyle(m_propertyWindow, wxCB_DROPDOWN, TRUE); else if (styleStr == "readonly") - SetWindowStyle(propertyWindow, wxCB_READONLY, TRUE); + SetWindowStyle(m_propertyWindow, wxCB_READONLY, TRUE); // Necesary? - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow); - resource->SetStyle(propertyWindow->GetWindowStyleFlag()); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + resource->SetStyle(m_propertyWindow->GetWindowStyleFlag()); - wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(propertyWindow, this); + wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(m_propertyWindow, this); return TRUE; } @@ -1243,16 +1338,16 @@ void wxComboBoxPropertyInfo::GetPropertyNames(wxStringList& names) bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxComboBox *choice = (wxComboBox *)propertyWindow; + wxComboBox *choice = (wxComboBox *)m_propertyWindow; int i; if (choice->Number() == 0) resource->SetStringValues(NULL); else { - wxStringList *slist = new wxStringList; + wxStringList slist; for (i = 0; i < choice->Number(); i++) - slist->Add(choice->GetString(i)); + slist.Add(choice->GetString(i)); resource->SetStringValues(slist); } @@ -1265,7 +1360,7 @@ bool wxComboBoxPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxRadioBoxPropertyInfo::GetProperty(wxString& name) { - wxRadioBox *radioBox = (wxRadioBox *)propertyWindow; + wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow; if (name == "numberRowsOrCols") { return new wxProperty("numberRowsOrCols", (long)radioBox->GetNumberOfRowsOrCols(), "integer"); @@ -1273,7 +1368,7 @@ wxProperty *wxRadioBoxPropertyInfo::GetProperty(wxString& name) if (name == "orientation") { wxString orient; - if (propertyWindow->GetWindowStyleFlag() & wxRA_HORIZONTAL) + if (m_propertyWindow->GetWindowStyleFlag() & wxRA_HORIZONTAL) orient = "wxRA_HORIZONTAL"; else orient = "wxRA_VERTICAL"; @@ -1296,7 +1391,7 @@ wxProperty *wxRadioBoxPropertyInfo::GetProperty(wxString& name) bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxRadioBox *radioBox = (wxRadioBox *)propertyWindow; + wxRadioBox *radioBox = (wxRadioBox *)m_propertyWindow; if (name == "numberRowsOrCols") { radioBox->SetNumberOfRowsOrCols((int)property->GetValue().IntegerValue()); @@ -1331,26 +1426,20 @@ bool wxRadioBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) // Set property into *resource*, not wxRadioBox, and then recreate // the wxRadioBox. This is because we can't dynamically set the strings // of a wxRadioBox. - wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow); + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); if (!resource) return FALSE; - wxStringList *stringList = resource->GetStringValues(); - if (!stringList) - { - stringList = new wxStringList; - resource->SetStringValues(stringList); - } - stringList->Clear(); - + wxStringList stringList; wxPropertyValue *expr = property->GetValue().GetFirst(); while (expr) { char *s = expr->StringValue(); if (s) - stringList->Add(s); + stringList.Add(s); expr = expr->GetNext(); } + resource->SetStringValues(stringList); wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(radioBox, this); return TRUE; } @@ -1368,7 +1457,7 @@ void wxRadioBoxPropertyInfo::GetPropertyNames(wxStringList& names) bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxRadioBox *rbox = (wxRadioBox *)propertyWindow; + wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow; // Take strings from resource instead /* int i; @@ -1394,7 +1483,6 @@ bool wxRadioBoxPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxGroupBoxPropertyInfo::GetProperty(wxString& name) { - wxStaticBox *groupBox = (wxStaticBox *)propertyWindow; return wxItemPropertyInfo::GetProperty(name); } @@ -1411,7 +1499,6 @@ void wxGroupBoxPropertyInfo::GetPropertyNames(wxStringList& names) bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxStaticBox *gbox = (wxStaticBox *)propertyWindow; return wxItemPropertyInfo::InstantiateResource(resource); } @@ -1421,7 +1508,7 @@ bool wxGroupBoxPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxCheckBoxPropertyInfo::GetProperty(wxString& name) { - wxCheckBox *checkBox = (wxCheckBox *)propertyWindow; + wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow; if (name == "value") return new wxProperty("value", checkBox->GetValue(), "bool"); else @@ -1430,7 +1517,7 @@ wxProperty *wxCheckBoxPropertyInfo::GetProperty(wxString& name) bool wxCheckBoxPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxCheckBox *checkBox = (wxCheckBox *)propertyWindow; + wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow; if (name == "value") { checkBox->SetValue((bool)property->GetValue().BoolValue()); @@ -1449,7 +1536,7 @@ void wxCheckBoxPropertyInfo::GetPropertyNames(wxStringList& names) bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxCheckBox *cbox = (wxCheckBox *)propertyWindow; + wxCheckBox *cbox = (wxCheckBox *)m_propertyWindow; resource->SetValue1(cbox->GetValue()); return wxItemPropertyInfo::InstantiateResource(resource); } @@ -1460,7 +1547,7 @@ bool wxCheckBoxPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxRadioButtonPropertyInfo::GetProperty(wxString& name) { - wxRadioButton *checkBox = (wxRadioButton *)propertyWindow; + wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow; if (name == "value") return new wxProperty("value", checkBox->GetValue(), "bool"); else @@ -1469,7 +1556,7 @@ wxProperty *wxRadioButtonPropertyInfo::GetProperty(wxString& name) bool wxRadioButtonPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxRadioButton *checkBox = (wxRadioButton *)propertyWindow; + wxRadioButton *checkBox = (wxRadioButton *)m_propertyWindow; if (name == "value") { checkBox->SetValue((bool)property->GetValue().BoolValue()); @@ -1488,7 +1575,7 @@ void wxRadioButtonPropertyInfo::GetPropertyNames(wxStringList& names) bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxRadioButton *cbox = (wxRadioButton *)propertyWindow; + wxRadioButton *cbox = (wxRadioButton *)m_propertyWindow; resource->SetValue1(cbox->GetValue()); return wxItemPropertyInfo::InstantiateResource(resource); } @@ -1499,13 +1586,13 @@ bool wxRadioButtonPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxSliderPropertyInfo::GetProperty(wxString& name) { - wxSlider *slider = (wxSlider *)propertyWindow; + wxSlider *slider = (wxSlider *)m_propertyWindow; if (name == "value") return new wxProperty("value", (long)slider->GetValue(), "integer"); else if (name == "orientation") { char *pos = NULL; - if (propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL) + if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL) pos = "wxHORIZONTAL"; else pos = "wxVERTICAL"; @@ -1524,7 +1611,7 @@ wxProperty *wxSliderPropertyInfo::GetProperty(wxString& name) bool wxSliderPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxSlider *slider = (wxSlider *)propertyWindow; + wxSlider *slider = (wxSlider *)m_propertyWindow; if (name == "value") { slider->SetValue((int)property->GetValue().IntegerValue()); @@ -1587,7 +1674,7 @@ void wxSliderPropertyInfo::GetPropertyNames(wxStringList& names) bool wxSliderPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxSlider *slider = (wxSlider *)propertyWindow; + wxSlider *slider = (wxSlider *)m_propertyWindow; resource->SetValue1(slider->GetValue()); resource->SetValue2(slider->GetMin()); resource->SetValue3(slider->GetMax()); @@ -1600,7 +1687,7 @@ bool wxSliderPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxGaugePropertyInfo::GetProperty(wxString& name) { - wxGauge *gauge = (wxGauge *)propertyWindow; + wxGauge *gauge = (wxGauge *)m_propertyWindow; if (name == "value") return new wxProperty("value", (long)gauge->GetValue(), "integer"); else if (name == "maxValue") @@ -1611,7 +1698,7 @@ wxProperty *wxGaugePropertyInfo::GetProperty(wxString& name) bool wxGaugePropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxGauge *gauge = (wxGauge *)propertyWindow; + wxGauge *gauge = (wxGauge *)m_propertyWindow; if (name == "value") { gauge->SetValue((int)property->GetValue().IntegerValue()); @@ -1635,7 +1722,7 @@ void wxGaugePropertyInfo::GetPropertyNames(wxStringList& names) bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource) { - wxGauge *gauge = (wxGauge *)propertyWindow; + wxGauge *gauge = (wxGauge *)m_propertyWindow; resource->SetValue1(gauge->GetValue()); resource->SetValue2(gauge->GetRange()); return wxItemPropertyInfo::InstantiateResource(resource); @@ -1647,13 +1734,13 @@ bool wxGaugePropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxScrollBarPropertyInfo::GetProperty(wxString& name) { - wxScrollBar *scrollBar = (wxScrollBar *)propertyWindow; + wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow; if (name == "value") return new wxProperty("value", (long)scrollBar->GetValue(), "integer"); else if (name == "orientation") { char *pos = NULL; - if (propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL) + if (m_propertyWindow->GetWindowStyleFlag() & wxHORIZONTAL) pos = "wxHORIZONTAL"; else pos = "wxVERTICAL"; @@ -1689,7 +1776,7 @@ wxProperty *wxScrollBarPropertyInfo::GetProperty(wxString& name) bool wxScrollBarPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxScrollBar *scrollBar = (wxScrollBar *)propertyWindow; + wxScrollBar *scrollBar = (wxScrollBar *)m_propertyWindow; if (name == "value") { scrollBar->SetValue((int)property->GetValue().IntegerValue()); @@ -1765,8 +1852,8 @@ void wxScrollBarPropertyInfo::GetPropertyNames(wxStringList& names) bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxScrollBar *sbar = (wxScrollBar *)propertyWindow; - + wxScrollBar *sbar = (wxScrollBar *)m_propertyWindow; + resource->SetValue1(sbar->GetValue()); int viewStart, pageLength, objectLength, viewLength; @@ -1785,7 +1872,7 @@ bool wxScrollBarPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxPanelPropertyInfo::GetProperty(wxString& name) { - wxPanel *panelWindow = (wxPanel *)propertyWindow; + wxPanel *panelWindow = (wxPanel *)m_propertyWindow; wxFont *labelFont = panelWindow->GetLabelFont(); wxFont *buttonFont = panelWindow->GetButtonFont(); @@ -1838,13 +1925,25 @@ wxProperty *wxPanelPropertyInfo::GetProperty(wxString& name) return new wxProperty(name, ((panelWindow->GetWindowStyleFlag() & wxTHICK_FRAME) == wxTHICK_FRAME), "bool"); } + else if (name == "useSystemDefaults") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) == wxRESOURCE_USE_DEFAULTS), + "bool"); + } + else if (name == "useDialogUnits") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + return new wxProperty(name, ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == wxRESOURCE_DIALOG_UNITS), + "bool"); + } else return wxWindowPropertyInfo::GetProperty(name); } bool wxPanelPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxPanel *panelWindow = (wxPanel *)propertyWindow; + wxPanel *panelWindow = (wxPanel *)m_propertyWindow; wxFont *labelFont = panelWindow->GetLabelFont(); wxFont *buttonFont = panelWindow->GetButtonFont(); @@ -1865,7 +1964,6 @@ bool wxPanelPropertyInfo::SetProperty(wxString& name, wxProperty *property) else if (name == "no3D") { bool userColours = property->GetValue().BoolValue(); - long flag = panelWindow->GetWindowStyleFlag(); if (userColours) { @@ -1930,6 +2028,51 @@ bool wxPanelPropertyInfo::SetProperty(wxString& name, wxProperty *property) resource->SetStyle(panelWindow->GetWindowStyleFlag()); return TRUE; } + else if (name == "useSystemDefaults") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + bool useDefaults = property->GetValue().BoolValue(); + long style = resource->GetResourceStyle(); + if (useDefaults) + { + if ((style & wxRESOURCE_USE_DEFAULTS) == 0) + style |= wxRESOURCE_USE_DEFAULTS; + } + else + { + if ((style & wxRESOURCE_USE_DEFAULTS) != 0) + style -= wxRESOURCE_USE_DEFAULTS; + } + resource->SetResourceStyle(style); + panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); + return TRUE; + } + else if (name == "useDialogUnits") + { + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(panelWindow); + bool useDialogUnits = property->GetValue().BoolValue(); + long style = resource->GetResourceStyle(); + if (useDialogUnits) + { + if ((style & wxRESOURCE_DIALOG_UNITS) == 0) + { + style |= wxRESOURCE_DIALOG_UNITS; + ConvertDialogUnits(TRUE); // Convert all resources + } + } + else + { + if ((style & wxRESOURCE_DIALOG_UNITS) != 0) + { + style -= wxRESOURCE_DIALOG_UNITS; + ConvertDialogUnits(FALSE); // Convert all resources + } + } + resource->SetResourceStyle(style); + panelWindow = (wxPanel *)wxResourceManager::GetCurrentResourceManager()->RecreateWindowFromResource(panelWindow, this); + // TODO: need to regenerate the width and height properties else they'll be inconsistent. + return TRUE; + } else return wxWindowPropertyInfo::SetProperty(name, property); } @@ -1944,21 +2087,65 @@ void wxPanelPropertyInfo::GetPropertyNames(wxStringList& names) names.Add("caption"); names.Add("systemMenu"); names.Add("thickFrame"); + names.Add("useSystemDefaults"); + names.Add("useDialogUnits"); } bool wxPanelPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxPanel *panel = (wxPanel *)propertyWindow; - if (panel->GetFont()) + wxPanel *panel = (wxPanel *)m_propertyWindow; + if (panel->GetFont() && panel->GetFont()->Ok()) resource->SetFont(wxTheFontList->FindOrCreateFont(panel->GetFont()->GetPointSize(), panel->GetFont()->GetFamily(), panel->GetFont()->GetStyle(), panel->GetFont()->GetWeight(), panel->GetFont()->GetUnderlined(), panel->GetFont()->GetFaceName())); - resource->SetBackgroundColour(new wxColour(panel->GetBackgroundColour())); + resource->SetBackgroundColour(wxColour(panel->GetBackgroundColour())); return wxWindowPropertyInfo::InstantiateResource(resource); } +// Convert this dialog, and its children, to or from dialog units +void wxPanelPropertyInfo::ConvertDialogUnits(bool toDialogUnits) +{ + wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow); + + wxPoint pt; + wxSize sz; + if (toDialogUnits) + { + sz = m_propertyWindow->ConvertPixelsToDialog(wxSize(resource->GetWidth(), resource->GetHeight())); + pt = m_propertyWindow->ConvertPixelsToDialog(wxPoint(resource->GetX(), resource->GetY())); + } + else + { + sz = m_propertyWindow->ConvertDialogToPixels(wxSize(resource->GetWidth(), resource->GetHeight())); + pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(resource->GetX(), resource->GetY())); + } + resource->SetSize(pt.x, pt.y, sz.x, sz.y); + + wxNode* node = m_propertyWindow->GetChildren()->First(); + while (node) + { + wxWindow* child = (wxWindow*) node->Data(); + if (child->IsKindOf(CLASSINFO(wxControl))) + { + resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(child); + if (toDialogUnits) + { + sz = m_propertyWindow->ConvertPixelsToDialog(wxSize(resource->GetWidth(), resource->GetHeight())); + pt = m_propertyWindow->ConvertPixelsToDialog(wxPoint(resource->GetX(), resource->GetY())); + } + else + { + sz = m_propertyWindow->ConvertDialogToPixels(wxSize(resource->GetWidth(), resource->GetHeight())); + pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(resource->GetX(), resource->GetY())); + } + resource->SetSize(pt.x, pt.y, sz.x, sz.y); + } + node = node->Next(); + } +} + #if 0 /* * Dialog boxes @@ -1966,7 +2153,7 @@ bool wxPanelPropertyInfo::InstantiateResource(wxItemResource *resource) wxProperty *wxDialogPropertyInfo::GetProperty(wxString& name) { - wxDialog *dialogWindow = (wxDialog *)propertyWindow; + wxDialog *dialogWindow = (wxDialog *)m_propertyWindow; if (name == "modal") { wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(dialogWindow); @@ -1982,7 +2169,7 @@ wxProperty *wxDialogPropertyInfo::GetProperty(wxString& name) bool wxDialogPropertyInfo::SetProperty(wxString& name, wxProperty *property) { - wxDialog *dialogWindow = (wxDialog *)propertyWindow; + wxDialog *dialogWindow = (wxDialog *)m_propertyWindow; if (name == "modal") { @@ -2006,9 +2193,9 @@ void wxDialogPropertyInfo::GetPropertyNames(wxStringList& names) bool wxDialogPropertyInfo::InstantiateResource(wxItemResource *resource) { - wxDialog *dialog = (wxDialog *)propertyWindow; + wxDialog *dialog = (wxDialog *)m_propertyWindow; wxString str(dialog->GetTitle()); - resource->SetTitle(WXSTRINGCAST str); + resource->SetTitle(str); return wxPanelPropertyInfo::InstantiateResource(resource); } @@ -2056,7 +2243,7 @@ wxResourceSymbolValidator::~wxResourceSymbolValidator(void) { } -bool wxResourceSymbolValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxResourceSymbolValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow)) { return TRUE; } @@ -2064,7 +2251,7 @@ bool wxResourceSymbolValidator::OnCheckValue(wxProperty *property, wxPropertyLis // 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 wxResourceSymbolValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -2076,7 +2263,7 @@ bool wxResourceSymbolValidator::OnRetrieveValue(wxProperty *property, wxProperty // 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 wxResourceSymbolValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxResourceSymbolValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -2095,7 +2282,7 @@ bool wxResourceSymbolValidator::OnDoubleClick(wxProperty *property, wxPropertyLi return TRUE; } -bool wxResourceSymbolValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxResourceSymbolValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) view->GetConfirmButton()->Enable(TRUE); @@ -2277,7 +2464,7 @@ bool wxResourceSymbolDialog::CheckValues() return TRUE; } -void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent& event) +void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent& WXUNUSED(event)) { wxString str(m_nameCtrl->GetStringSelection()); if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str)) @@ -2301,7 +2488,7 @@ void wxResourceSymbolDialog::OnComboBoxSelect(wxCommandEvent& event) } } -void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent& event) +void wxResourceSymbolDialog::OnSymbolNameUpdate(wxCommandEvent& WXUNUSED(event)) { wxString str(m_nameCtrl->GetValue()); if (wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(str)) diff --git a/utils/dialoged/src/winprop.h b/utils/dialoged/src/winprop.h index 8b4032a8a0..197963d61a 100644 --- a/utils/dialoged/src/winprop.h +++ b/utils/dialoged/src/winprop.h @@ -40,15 +40,16 @@ private: class wxResourcePropertyListView: public wxPropertyListView { public: - wxPropertyInfo *propertyInfo; - wxResourcePropertyListView(wxPropertyInfo *info, wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT): wxPropertyListView(propPanel, flags) { - propertyInfo = info; + m_propertyInfo = info; } void OnPropertyChanged(wxProperty *property); bool OnClose(void); + + wxPropertyInfo* m_propertyInfo; + }; // Generic class for relating an object to a collection of properties. @@ -76,9 +77,6 @@ class wxPropertyInfo: public wxObject // For all windows class wxWindowPropertyInfo: public wxPropertyInfo { - protected: - wxWindow *propertyWindow; - wxItemResource *propertyResource; public: wxWindowPropertyInfo(wxWindow *win, wxItemResource *res = NULL); ~wxWindowPropertyInfo(void); @@ -86,9 +84,9 @@ class wxWindowPropertyInfo: public wxPropertyInfo bool SetProperty(wxString& name, wxProperty *property); void GetPropertyNames(wxStringList& names); - inline void SetPropertyWindow(wxWindow *win) { propertyWindow = win; } + inline void SetPropertyWindow(wxWindow *win) { m_propertyWindow = win; } - inline void SetResource(wxItemResource *res) { propertyResource = res; } + inline void SetResource(wxItemResource *res) { m_propertyResource = res; } // Helper functions for font properties @@ -100,6 +98,10 @@ class wxWindowPropertyInfo: public wxPropertyInfo // Set the window style void SetWindowStyle(wxWindow* win, long style, bool set); + + protected: + wxWindow* m_propertyWindow; + wxItemResource* m_propertyResource; }; // For panel items @@ -338,6 +340,9 @@ class wxPanelPropertyInfo: public wxWindowPropertyInfo bool SetProperty(wxString& name, wxProperty *property); void GetPropertyNames(wxStringList& names); bool InstantiateResource(wxItemResource *resource); + + // Convert this dialog, and its children, to or from dialog units + void ConvertDialogUnits(bool toDialogUnits); }; int wxStringToFontWeight(wxString& val); diff --git a/utils/wxprop/src/prop.cpp b/utils/wxprop/src/prop.cpp index 3a487cf997..933f38a56c 100644 --- a/utils/wxprop/src/prop.cpp +++ b/utils/wxprop/src/prop.cpp @@ -44,124 +44,124 @@ IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue, wxObject) wxPropertyValue::wxPropertyValue(void) { - type = wxPropertyValueNull; - next = NULL; - last = NULL; - value.first = NULL; - client_data = NULL; - modifiedFlag = FALSE; + m_type = wxPropertyValueNull; + m_next = NULL; + m_last = NULL; + m_value.first = NULL; + m_clientData = NULL; + m_modifiedFlag = FALSE; } wxPropertyValue::wxPropertyValue(const wxPropertyValue& copyFrom) { - modifiedFlag = FALSE; + m_modifiedFlag = FALSE; Copy((wxPropertyValue& )copyFrom); } wxPropertyValue::wxPropertyValue(const char *val) { - modifiedFlag = FALSE; - type = wxPropertyValueString; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueString; - value.string = copystring(val); - client_data = NULL; - next = NULL; - last = NULL; + m_value.string = copystring(val); + m_clientData = NULL; + m_next = NULL; + m_last = NULL; } wxPropertyValue::wxPropertyValue(const wxString& val) { - modifiedFlag = FALSE; - type = wxPropertyValueString; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueString; - value.string = copystring((const char *)val); - client_data = NULL; - next = NULL; - last = NULL; + m_value.string = copystring((const char *)val); + m_clientData = NULL; + m_next = NULL; + m_last = NULL; } wxPropertyValue::wxPropertyValue(long the_integer) { - modifiedFlag = FALSE; - type = wxPropertyValueInteger; - value.integer = the_integer; - client_data = NULL; - next = NULL; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueInteger; + m_value.integer = the_integer; + m_clientData = NULL; + m_next = NULL; } wxPropertyValue::wxPropertyValue(bool val) { - modifiedFlag = FALSE; - type = wxPropertyValuebool; - value.integer = val; - client_data = NULL; - next = NULL; + m_modifiedFlag = FALSE; + m_type = wxPropertyValuebool; + m_value.integer = val; + m_clientData = NULL; + m_next = NULL; } wxPropertyValue::wxPropertyValue(float the_real) { - modifiedFlag = FALSE; - type = wxPropertyValueReal; - value.real = the_real; - client_data = NULL; - next = NULL; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueReal; + m_value.real = the_real; + m_clientData = NULL; + m_next = NULL; } wxPropertyValue::wxPropertyValue(double the_real) { - modifiedFlag = FALSE; - type = wxPropertyValueReal; - value.real = (float)the_real; - client_data = NULL; - next = NULL; + 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(char **val) { - modifiedFlag = FALSE; - type = wxPropertyValueStringPtr; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueStringPtr; - value.stringPtr = val; - client_data = NULL; - next = NULL; - last = NULL; + m_value.stringPtr = val; + m_clientData = NULL; + m_next = NULL; + m_last = NULL; } wxPropertyValue::wxPropertyValue(long *val) { - modifiedFlag = FALSE; - type = wxPropertyValueIntegerPtr; - value.integerPtr = val; - client_data = NULL; - next = NULL; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueIntegerPtr; + m_value.integerPtr = val; + m_clientData = NULL; + m_next = NULL; } wxPropertyValue::wxPropertyValue(bool *val) { - modifiedFlag = FALSE; - type = wxPropertyValueboolPtr; - value.boolPtr = val; - client_data = NULL; - next = NULL; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueboolPtr; + m_value.boolPtr = val; + m_clientData = NULL; + m_next = NULL; } wxPropertyValue::wxPropertyValue(float *val) { - modifiedFlag = FALSE; - type = wxPropertyValueRealPtr; - value.realPtr = val; - client_data = NULL; - next = NULL; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueRealPtr; + m_value.realPtr = val; + m_clientData = NULL; + m_next = NULL; } wxPropertyValue::wxPropertyValue(wxList *the_list) { - modifiedFlag = FALSE; - type = wxPropertyValueList; - client_data = NULL; - last = NULL; - value.first = NULL; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueList; + m_clientData = NULL; + m_last = NULL; + m_value.first = NULL; wxNode *node = the_list->First(); while (node) @@ -176,11 +176,11 @@ wxPropertyValue::wxPropertyValue(wxList *the_list) wxPropertyValue::wxPropertyValue(wxStringList *the_list) { - modifiedFlag = FALSE; - type = wxPropertyValueList; - client_data = NULL; - last = NULL; - value.first = NULL; + m_modifiedFlag = FALSE; + m_type = wxPropertyValueList; + m_clientData = NULL; + m_last = NULL; + m_value.first = NULL; wxNode *node = the_list->First(); while (node) @@ -194,7 +194,7 @@ wxPropertyValue::wxPropertyValue(wxStringList *the_list) wxPropertyValue::~wxPropertyValue(void) { - switch (type) + switch (m_type) { case wxPropertyValueInteger: case wxPropertyValuebool: @@ -204,15 +204,15 @@ wxPropertyValue::~wxPropertyValue(void) } case wxPropertyValueString: { - delete value.string; + delete m_value.string; break; } case wxPropertyValueList: { - wxPropertyValue *expr = value.first; + wxPropertyValue *expr = m_value.first; while (expr) { - wxPropertyValue *expr1 = expr->next; + wxPropertyValue *expr1 = expr->m_next; delete expr; expr = expr1; @@ -226,23 +226,23 @@ wxPropertyValue::~wxPropertyValue(void) void wxPropertyValue::Append(wxPropertyValue *expr) { - modifiedFlag = TRUE; - if (!value.first) - value.first = expr; + m_modifiedFlag = TRUE; + if (!m_value.first) + m_value.first = expr; - if (last) - last->next = expr; - last = expr; + if (m_last) + m_last->m_next = expr; + m_last = expr; } void wxPropertyValue::Insert(wxPropertyValue *expr) { - modifiedFlag = TRUE; - expr->next = value.first; - value.first = expr; + m_modifiedFlag = TRUE; + expr->m_next = m_value.first; + m_value.first = expr; - if (!last) - last = expr; + if (!m_last) + m_last = expr; } // Delete from list @@ -260,13 +260,13 @@ void wxPropertyValue::Delete(wxPropertyValue *node) if (expr) { if (previous) - previous->next = expr->next; + 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) { - value.first = expr->next; + m_value.first = expr->m_next; } // If node was the last in the list, @@ -274,11 +274,11 @@ void wxPropertyValue::Delete(wxPropertyValue *node) if (GetLast() == expr) { if (previous) - last = previous; + m_last = previous; else - last = NULL; + m_last = NULL; } - modifiedFlag = TRUE; + m_modifiedFlag = TRUE; delete expr; } @@ -288,51 +288,51 @@ void wxPropertyValue::ClearList(void) { wxPropertyValue *val = GetFirst(); if (val) - modifiedFlag = TRUE; - + m_modifiedFlag = TRUE; + while (val) { wxPropertyValue *next = val->GetNext(); delete val; val = next; } - value.first = NULL; - last = NULL; + m_value.first = NULL; + m_last = NULL; } -wxPropertyValue *wxPropertyValue::NewCopy(void) +wxPropertyValue *wxPropertyValue::NewCopy(void) const { - switch (type) + switch (m_type) { case wxPropertyValueInteger: - return new wxPropertyValue(value.integer); + return new wxPropertyValue(m_value.integer); case wxPropertyValuebool: - return new wxPropertyValue((bool) (value.integer != 0)); + return new wxPropertyValue((bool) (m_value.integer != 0)); case wxPropertyValueReal: - return new wxPropertyValue(value.real); + return new wxPropertyValue(m_value.real); case wxPropertyValueString: - return new wxPropertyValue(value.string); + return new wxPropertyValue(m_value.string); case wxPropertyValueList: { - wxPropertyValue *expr = value.first; + 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->next; + expr = expr->m_next; } return new_list; } case wxPropertyValueIntegerPtr: - return new wxPropertyValue(value.integerPtr); + return new wxPropertyValue(m_value.integerPtr); case wxPropertyValueRealPtr: - return new wxPropertyValue(value.realPtr); + return new wxPropertyValue(m_value.realPtr); case wxPropertyValueboolPtr: - return new wxPropertyValue(value.boolPtr); + return new wxPropertyValue(m_value.boolPtr); case wxPropertyValueStringPtr: - return new wxPropertyValue(value.stringPtr); + return new wxPropertyValue(m_value.stringPtr); case wxPropertyValueNull: #ifdef __X__ @@ -345,9 +345,9 @@ wxPropertyValue *wxPropertyValue::NewCopy(void) void wxPropertyValue::Copy(wxPropertyValue& copyFrom) { - type = copyFrom.Type(); - - switch (type) + m_type = copyFrom.Type(); + + switch (m_type) { case wxPropertyValueInteger: (*this) = copyFrom.IntegerValue(); @@ -384,15 +384,15 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) case wxPropertyValueList: { - value.first = NULL; - next = NULL; - last = NULL; - wxPropertyValue *expr = copyFrom.value.first; + 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->next; + expr = expr->m_next; } return; } @@ -405,29 +405,29 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) } // Return nth argument of a clause (starting from 1) -wxPropertyValue *wxPropertyValue::Arg(wxPropertyValueType type, int arg) +wxPropertyValue *wxPropertyValue::Arg(wxPropertyValueType type, int arg) const { - wxPropertyValue *expr = value.first; + wxPropertyValue *expr = m_value.first; for (int i = 1; i < arg; i++) if (expr) - expr = expr->next; + expr = expr->m_next; - if (expr && (expr->type == type)) + 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) +wxPropertyValue *wxPropertyValue::Nth(int arg) const { - if (type != wxPropertyValueList) + if (m_type != wxPropertyValueList) return NULL; - wxPropertyValue *expr = value.first; + wxPropertyValue *expr = m_value.first; for (int i = 0; i < arg; i++) if (expr) - expr = expr->next; + expr = expr->m_next; else return NULL; if (expr) @@ -437,16 +437,16 @@ wxPropertyValue *wxPropertyValue::Nth(int arg) } // Returns the number of elements in a list expression -int wxPropertyValue::Number(void) +int wxPropertyValue::Number(void) const { - if (type != wxPropertyValueList) + if (m_type != wxPropertyValueList) return 0; int i = 0; - wxPropertyValue *expr = value.first; + wxPropertyValue *expr = m_value.first; while (expr) { - expr = expr->next; + expr = expr->m_next; i ++; } return i; @@ -454,22 +454,22 @@ int wxPropertyValue::Number(void) void wxPropertyValue::WritePropertyClause(ostream& stream) // Write this expression as a top-level clause { - if (type != wxPropertyValueList) + if (m_type != wxPropertyValueList) return; - wxPropertyValue *node = value.first; + wxPropertyValue *node = m_value.first; if (node) { node->WritePropertyType(stream); stream << "("; - node = node->next; + node = node->m_next; bool first = TRUE; while (node) { if (!first) stream << " "; node->WritePropertyType(stream); - node = node->next; + node = node->m_next; if (node) stream << ",\n"; first = FALSE; } @@ -479,21 +479,21 @@ void wxPropertyValue::WritePropertyClause(ostream& stream) // Write this expres void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any other subexpression { - switch (type) + switch (m_type) { case wxPropertyValueInteger: { - stream << value.integer; + stream << m_value.integer; break; } case wxPropertyValueIntegerPtr: { - stream << *value.integerPtr; + stream << *m_value.integerPtr; break; } case wxPropertyValuebool: { - if (value.integer) + if (m_value.integer) stream << "True"; else stream << "False"; @@ -501,7 +501,7 @@ void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any othe } case wxPropertyValueboolPtr: { - if (*value.integerPtr) + if (*m_value.integerPtr) stream << "True"; else stream << "False"; @@ -509,14 +509,14 @@ void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any othe } case wxPropertyValueReal: { - float f = value.real; + float f = m_value.real; sprintf(wxBuffer, "%.6g", (double)f); stream << wxBuffer; break; } case wxPropertyValueRealPtr: { - float f = *value.realPtr; + float f = *m_value.realPtr; /* Now the parser can cope with this. // Prevent printing in 'e' notation. Any better way? if (fabs(f) < 0.00001) @@ -530,10 +530,10 @@ void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any othe { // stream << "\""; int i; - int len = strlen(value.string); + int len = strlen(m_value.string); for (i = 0; i < len; i++) { - char ch = value.string[i]; + char ch = m_value.string[i]; // if (ch == '"' || ch == '\\') // stream << "\\"; stream << ch; @@ -545,27 +545,27 @@ void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any othe case wxPropertyValueStringPtr: { int i; - int len = strlen(*(value.stringPtr)); + int len = strlen(*(m_value.stringPtr)); for (i = 0; i < len; i++) { - char ch = *(value.stringPtr)[i]; + char ch = *(m_value.stringPtr)[i]; } break; } case wxPropertyValueList: { - if (!value.first) + if (!m_value.first) stream << "[]"; else { - wxPropertyValue *expr = value.first; + wxPropertyValue *expr = m_value.first; stream << "["; while (expr) { expr->WritePropertyType(stream); - expr = expr->next; + expr = expr->m_next; if (expr) stream << ", "; } stream << "]"; @@ -592,7 +592,7 @@ wxString wxPropertyValue::GetStringRepresentation(void) void wxPropertyValue::operator=(const wxPropertyValue& val) { - modifiedFlag = TRUE; + m_modifiedFlag = TRUE; Copy((wxPropertyValue&)val); } @@ -601,195 +601,195 @@ void wxPropertyValue::operator=(const wxString& val1) { const char *val = (const char *)val1; - modifiedFlag = TRUE; - if (type == wxPropertyValueNull) - type = wxPropertyValueString; + m_modifiedFlag = TRUE; + if (m_type == wxPropertyValueNull) + m_type = wxPropertyValueString; - if (type == wxPropertyValueString) + if (m_type == wxPropertyValueString) { if (val) - value.string = copystring(val); + m_value.string = copystring(val); else - value.string = NULL; + m_value.string = NULL; } - else if (type == wxPropertyValueStringPtr) + else if (m_type == wxPropertyValueStringPtr) { - if (*value.stringPtr) - delete[] *value.stringPtr; + if (*m_value.stringPtr) + delete[] *m_value.stringPtr; if (val) - *value.stringPtr = copystring(val); + *m_value.stringPtr = copystring(val); else - *value.stringPtr = NULL; + *m_value.stringPtr = NULL; } - client_data = NULL; - next = NULL; - last = NULL; + m_clientData = NULL; + m_next = NULL; + m_last = NULL; } void wxPropertyValue::operator=(const long val) { - modifiedFlag = TRUE; - if (type == wxPropertyValueNull) - type = wxPropertyValueInteger; - - if (type == wxPropertyValueInteger) - value.integer = val; - else if (type == wxPropertyValueIntegerPtr) - *value.integerPtr = val; - else if (type == wxPropertyValueReal) - value.real = (float)val; - else if (type == wxPropertyValueRealPtr) - *value.realPtr = (float)val; - - client_data = NULL; - next = 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) { - modifiedFlag = TRUE; - if (type == wxPropertyValueNull) - type = wxPropertyValuebool; + m_modifiedFlag = TRUE; + if (m_type == wxPropertyValueNull) + m_type = wxPropertyValuebool; - if (type == wxPropertyValuebool) - value.integer = (long)val; - else if (type == wxPropertyValueboolPtr) - *value.boolPtr = val; + if (m_type == wxPropertyValuebool) + m_value.integer = (long)val; + else if (m_type == wxPropertyValueboolPtr) + *m_value.boolPtr = val; - client_data = NULL; - next = NULL; + m_clientData = NULL; + m_next = NULL; } void wxPropertyValue::operator=(const float val) { - modifiedFlag = TRUE; - if (type == wxPropertyValueNull) - type = wxPropertyValueReal; - - if (type == wxPropertyValueInteger) - value.integer = (long)val; - else if (type == wxPropertyValueIntegerPtr) - *value.integerPtr = (long)val; - else if (type == wxPropertyValueReal) - value.real = val; - else if (type == wxPropertyValueRealPtr) - *value.realPtr = val; - - client_data = NULL; - next = 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 char **val) { - modifiedFlag = TRUE; - type = wxPropertyValueStringPtr; + m_modifiedFlag = TRUE; + m_type = wxPropertyValueStringPtr; if (val) - value.stringPtr = (char **)val; + m_value.stringPtr = (char **)val; else - value.stringPtr = NULL; - client_data = NULL; - next = NULL; - last = NULL; + m_value.stringPtr = NULL; + m_clientData = NULL; + m_next = NULL; + m_last = NULL; } void wxPropertyValue::operator=(const long *val) { - modifiedFlag = TRUE; - type = wxPropertyValueIntegerPtr; - value.integerPtr = (long *)val; - client_data = NULL; - next = NULL; + m_modifiedFlag = TRUE; + m_type = wxPropertyValueIntegerPtr; + m_value.integerPtr = (long *)val; + m_clientData = NULL; + m_next = NULL; } void wxPropertyValue::operator=(const bool *val) { - modifiedFlag = TRUE; - type = wxPropertyValueboolPtr; - value.boolPtr = (bool *)val; - client_data = NULL; - next = NULL; + m_modifiedFlag = TRUE; + m_type = wxPropertyValueboolPtr; + m_value.boolPtr = (bool *)val; + m_clientData = NULL; + m_next = NULL; } void wxPropertyValue::operator=(const float *val) { - modifiedFlag = TRUE; - type = wxPropertyValueRealPtr; - value.realPtr = (float *)val; - client_data = NULL; - next = NULL; + m_modifiedFlag = TRUE; + m_type = wxPropertyValueRealPtr; + m_value.realPtr = (float *)val; + m_clientData = NULL; + m_next = NULL; } -long wxPropertyValue::IntegerValue(void) +long wxPropertyValue::IntegerValue(void) const { - if (type == wxPropertyValueInteger) - return value.integer; - else if (type == wxPropertyValueReal) - return (long)value.real; - else if (type == wxPropertyValueIntegerPtr) - return *value.integerPtr; - else if (type == wxPropertyValueRealPtr) - return (long)(*value.realPtr); + 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) +long *wxPropertyValue::IntegerValuePtr(void) const { - return value.integerPtr; + return m_value.integerPtr; } -float wxPropertyValue::RealValue(void) { - if (type == wxPropertyValueReal) - return value.real; - else if (type == wxPropertyValueRealPtr) - return *value.realPtr; - else if (type == wxPropertyValueInteger) - return (float)value.integer; - else if (type == wxPropertyValueIntegerPtr) - return (float)*(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) +float *wxPropertyValue::RealValuePtr(void) const { - return value.realPtr; + return m_value.realPtr; } -bool wxPropertyValue::BoolValue(void) { - if (type == wxPropertyValueReal) - return (value.real != 0.0); - if (type == wxPropertyValueRealPtr) - return (*(value.realPtr) != 0.0); - else if (type == wxPropertyValueInteger) - return (value.integer != 0); - else if (type == wxPropertyValueIntegerPtr) - return (*(value.integerPtr) != 0); - else if (type == wxPropertyValuebool) - return (value.integer != 0); - else if (type == wxPropertyValueboolPtr) - return (*(value.boolPtr) != 0); +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) +bool *wxPropertyValue::BoolValuePtr(void) const { - return value.boolPtr; + return m_value.boolPtr; } -char *wxPropertyValue::StringValue(void) { - if (type == wxPropertyValueString) - return value.string; - else if (type == wxPropertyValueStringPtr) - return *(value.stringPtr); +char *wxPropertyValue::StringValue(void) const { + if (m_type == wxPropertyValueString) + return m_value.string; + else if (m_type == wxPropertyValueStringPtr) + return *(m_value.stringPtr); else return NULL; } -char **wxPropertyValue::StringValuePtr(void) +char **wxPropertyValue::StringValuePtr(void) const { - return value.stringPtr; + return m_value.stringPtr; } /* @@ -800,86 +800,86 @@ IMPLEMENT_DYNAMIC_CLASS(wxProperty, wxObject) wxProperty::wxProperty(void) { - propertyRole = (char *)NULL; - propertyValidator = NULL; - propertyWindow = NULL; - enabled = TRUE; + m_propertyRole = (char *)NULL; + m_propertyValidator = NULL; + m_propertyWindow = NULL; + m_enabled = TRUE; } wxProperty::wxProperty(wxProperty& copyFrom) { - value = copyFrom.GetValue(); - name = copyFrom.GetName(); - propertyRole = copyFrom.GetRole(); - propertyValidator = copyFrom.GetValidator(); - enabled = copyFrom.IsEnabled(); - propertyWindow = NULL; + 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):name(nm), propertyRole(role) +wxProperty::wxProperty(wxString nm, wxString role, wxPropertyValidator *ed):m_name(nm), m_propertyRole(role) { - propertyValidator = ed; - propertyWindow = NULL; - enabled = TRUE; + m_propertyValidator = ed; + m_propertyWindow = NULL; + m_enabled = TRUE; } wxProperty::wxProperty(wxString nm, const wxPropertyValue& val, wxString role, wxPropertyValidator *ed): - name(nm), value(val), propertyRole(role) + m_name(nm), m_value(val), m_propertyRole(role) { - propertyValidator = ed; - propertyWindow = NULL; - enabled = TRUE; + m_propertyValidator = ed; + m_propertyWindow = NULL; + m_enabled = TRUE; } wxProperty::~wxProperty(void) { - if (propertyValidator) - delete propertyValidator; + if (m_propertyValidator) + delete m_propertyValidator; } -wxPropertyValue& wxProperty::GetValue(void) +wxPropertyValue& wxProperty::GetValue(void) const { - return value; + return (wxPropertyValue&) m_value; } -wxPropertyValidator *wxProperty::GetValidator(void) +wxPropertyValidator *wxProperty::GetValidator(void) const { - return propertyValidator; + return m_propertyValidator; } -wxString& wxProperty::GetName(void) +wxString& wxProperty::GetName(void) const { - return name; + return (wxString&) m_name; } -wxString& wxProperty::GetRole(void) +wxString& wxProperty::GetRole(void) const { - return propertyRole; + return (wxString&) m_propertyRole; } void wxProperty::SetValue(const wxPropertyValue& val) { - value = val; + m_value = val; } void wxProperty::SetValidator(wxPropertyValidator *ed) { - propertyValidator = ed; + m_propertyValidator = ed; } void wxProperty::SetRole(wxString& role) { - propertyRole = role; + m_propertyRole = role; } void wxProperty::SetName(wxString& nm) { - name = nm; + m_name = nm; } void wxProperty::operator=(const wxPropertyValue& val) { - value = val; + m_value = val; } /* @@ -890,10 +890,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxPropertyView, wxEvtHandler) wxPropertyView::wxPropertyView(long flags) { - buttonFlags = flags; - propertySheet = NULL; - currentValidator = NULL; - currentProperty = NULL; + m_buttonFlags = flags; + m_propertySheet = NULL; + m_currentValidator = NULL; + m_currentProperty = NULL; } wxPropertyView::~wxPropertyView(void) @@ -902,7 +902,7 @@ wxPropertyView::~wxPropertyView(void) void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry *registry) { - validatorRegistryList.Append(registry); + m_validatorRegistryList.Append(registry); } wxPropertyValidator *wxPropertyView::FindPropertyValidator(wxProperty *property) @@ -910,7 +910,7 @@ wxPropertyValidator *wxPropertyView::FindPropertyValidator(wxProperty *property) if (property->GetValidator()) return property->GetValidator(); - wxNode *node = validatorRegistryList.First(); + wxNode *node = m_validatorRegistryList.First(); while (node) { wxPropertyValidatorRegistry *registry = (wxPropertyValidatorRegistry *)node->Data(); @@ -933,7 +933,7 @@ wxPropertyValidator *wxPropertyView::FindPropertyValidator(wxProperty *property) IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet, wxObject) -wxPropertySheet::wxPropertySheet(void):properties(wxKEY_STRING) +wxPropertySheet::wxPropertySheet(void):m_properties(wxKEY_STRING) { } @@ -959,13 +959,13 @@ void wxPropertySheet::UpdateAllViews( wxPropertyView *WXUNUSED(thisView) ) // Add a property void wxPropertySheet::AddProperty(wxProperty *property) { - properties.Append(property->GetName().GetData(), property); + m_properties.Append(property->GetName().GetData(), property); } // Get property by name wxProperty *wxPropertySheet::GetProperty(wxString name) { - wxNode *node = properties.Find(name.GetData()); + wxNode *node = m_properties.Find(name.GetData()); if (!node) return NULL; else @@ -975,7 +975,7 @@ wxProperty *wxPropertySheet::GetProperty(wxString name) // Clear all properties void wxPropertySheet::Clear(void) { - wxNode *node = properties.First(); + wxNode *node = m_properties.First(); while (node) { wxProperty *prop = (wxProperty *)node->Data(); @@ -989,7 +989,7 @@ void wxPropertySheet::Clear(void) // Sets/clears the modified flag for each property value void wxPropertySheet::SetAllModified(bool flag) { - wxNode *node = properties.First(); + wxNode *node = m_properties.First(); while (node) { wxProperty *prop = (wxProperty *)node->Data(); @@ -1043,8 +1043,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator, wxEvtHandler) wxPropertyValidator::wxPropertyValidator(long flags) { - validatorFlags = flags; - validatorProperty = NULL; + m_validatorFlags = flags; + m_validatorProperty = NULL; } wxPropertyValidator::~wxPropertyValidator(void) diff --git a/utils/wxprop/src/prop.h b/utils/wxprop/src/prop.h index 45c529a8a6..616268f4c9 100644 --- a/utils/wxprop/src/prop.h +++ b/utils/wxprop/src/prop.h @@ -41,11 +41,6 @@ class wxPropertyValidatorRegistry; class wxPropertySheet: public wxObject { DECLARE_DYNAMIC_CLASS(wxPropertySheet) - protected: - wxObject *viewedObject; - wxList properties; - wxPropertyView *propertyView; - public: wxPropertySheet(void); ~wxPropertySheet(void); @@ -63,10 +58,16 @@ class wxPropertySheet: public wxObject virtual bool Load(ostream& str); virtual void UpdateAllViews(wxPropertyView *thisView = NULL); - inline virtual wxList& GetProperties(void) { return properties; } + inline virtual wxList& GetProperties(void) 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; + }; @@ -75,12 +76,6 @@ class wxPropertySheet: public wxObject class wxPropertyView: public wxEvtHandler { DECLARE_DYNAMIC_CLASS(wxPropertyView) - protected: - long buttonFlags; - wxPropertySheet *propertySheet; - wxProperty *currentProperty; - wxList validatorRegistryList; - wxPropertyValidator *currentValidator; public: wxPropertyView(long flags = 0); ~wxPropertyView(void); @@ -97,35 +92,39 @@ class wxPropertyView: public wxEvtHandler virtual void OnPropertyChanged(wxProperty *WXUNUSED(property)) {} virtual void AddRegistry(wxPropertyValidatorRegistry *registry); - inline virtual wxList& GetRegistryList(void) - { return validatorRegistryList; } + inline virtual wxList& GetRegistryList(void) const + { return (wxList&) m_validatorRegistryList; } virtual wxPropertyValidator *FindPropertyValidator(wxProperty *property); - inline virtual void SetPropertySheet(wxPropertySheet *sheet) { propertySheet = sheet; } - inline virtual wxPropertySheet *GetPropertySheet(void) { return propertySheet; } + inline virtual void SetPropertySheet(wxPropertySheet *sheet) { m_propertySheet = sheet; } + inline virtual wxPropertySheet *GetPropertySheet(void) const { return m_propertySheet; } virtual void OnOk(void) {}; virtual void OnCancel(void) {}; virtual void OnHelp(void) {}; inline virtual bool OnClose(void) { return FALSE; } - inline long GetFlags(void) { return buttonFlags; } + inline long GetFlags(void) { return m_buttonFlags; } + + protected: + long m_buttonFlags; + wxPropertySheet* m_propertySheet; + wxProperty* m_currentProperty; + wxList m_validatorRegistryList; + wxPropertyValidator* m_currentValidator; }; class wxPropertyValidator: public wxEvtHandler { DECLARE_DYNAMIC_CLASS(wxPropertyValidator) - protected: - long validatorFlags; - wxProperty *validatorProperty; public: wxPropertyValidator(long flags = 0); ~wxPropertyValidator(void); - inline long GetFlags(void) { return validatorFlags; } - inline void SetValidatorProperty(wxProperty *prop) { validatorProperty = prop; } - inline wxProperty *GetValidatorProperty(void) { return validatorProperty; } + inline long GetFlags(void) const { return m_validatorFlags; } + inline void SetValidatorProperty(wxProperty *prop) { m_validatorProperty = prop; } + inline wxProperty *GetValidatorProperty(void) const { return m_validatorProperty; } virtual bool StringToFloat (char *s, float *number); virtual bool StringToDouble (char *s, double *number); @@ -135,6 +134,10 @@ class wxPropertyValidator: public wxEvtHandler virtual char *DoubleToString (double number); virtual char *IntToString (int number); virtual char *LongToString (long number); + + protected: + long m_validatorFlags; + wxProperty* m_validatorProperty; }; @@ -172,24 +175,6 @@ typedef enum { class wxPropertyValue: public wxObject { DECLARE_DYNAMIC_CLASS(wxPropertyValue) - public: - wxObject *client_data; - wxPropertyValueType type; - bool modifiedFlag; - - union { - long integer; // Also doubles as bool - char *string; - float real; - long *integerPtr; - bool *boolPtr; - char **stringPtr; - float *realPtr; - wxPropertyValue *first; // If is a list expr, points to the first node - } value; - - wxPropertyValue *next; // If this is a node in a list, points to the next node - wxPropertyValue *last; // If is a list expr, points to the last node wxPropertyValue(void); // Unknown type wxPropertyValue(const wxPropertyValue& copyFrom); // Copy constructor @@ -209,26 +194,26 @@ class wxPropertyValue: public wxObject ~wxPropertyValue(void); - virtual inline wxPropertyValueType Type(void) { return type; } - virtual inline void SetType(wxPropertyValueType typ) { type = typ; } - virtual long IntegerValue(void); - virtual float RealValue(void); - virtual bool BoolValue(void); - virtual char *StringValue(void); - virtual long *IntegerValuePtr(void); - virtual float *RealValuePtr(void); - virtual bool *BoolValuePtr(void); - virtual char **StringValuePtr(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 char *StringValue(void) const; + virtual long *IntegerValuePtr(void) const; + virtual float *RealValuePtr(void) const; + virtual bool *BoolValuePtr(void) const; + virtual char **StringValuePtr(void) const; // Get nth arg of clause (starting from 1) - virtual wxPropertyValue *Arg(wxPropertyValueType type, int arg); + virtual wxPropertyValue *Arg(wxPropertyValueType type, int arg) const; // Return nth argument of a list expression (starting from zero) - virtual wxPropertyValue *Nth(int arg); + virtual wxPropertyValue *Nth(int arg) const; // Returns the number of elements in a list expression - virtual int Number(void); + virtual int Number(void) const; - virtual wxPropertyValue *NewCopy(void); + virtual wxPropertyValue *NewCopy(void) const; virtual void Copy(wxPropertyValue& copyFrom); virtual void WritePropertyClause(ostream& stream); // Write this expression as a top-level clause @@ -240,16 +225,16 @@ class wxPropertyValue: public wxObject virtual void Insert(wxPropertyValue *expr); // Get first expr in list - virtual inline wxPropertyValue *GetFirst(void) - { return ((type == wxPropertyValueList) ? value.first : (wxPropertyValue*)NULL); } + 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) - { return next; } + virtual inline wxPropertyValue *GetNext(void) const + { return m_next; } // Get last expr in list - virtual inline wxPropertyValue *GetLast(void) - { return ((type == wxPropertyValueList) ? last : (wxPropertyValue*)NULL); } + 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); @@ -257,13 +242,13 @@ class wxPropertyValue: public wxObject // Clear list virtual void ClearList(void); - virtual inline void SetClientData(wxObject *data) { client_data = data; } - virtual inline wxObject *GetClientData(void) { return client_data; } + 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) { modifiedFlag = flag; } - inline bool GetModified(void) { return modifiedFlag; } + inline void SetModified(bool flag = TRUE) { m_modifiedFlag = flag; } + inline bool GetModified(void) { return m_modifiedFlag; } // Operators void operator=(const wxPropertyValue& val); @@ -276,6 +261,26 @@ class wxPropertyValue: public wxObject 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 + char *string; + float real; + long *integerPtr; + bool *boolPtr; + char **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 + }; /* @@ -286,13 +291,13 @@ class wxProperty: public wxObject { DECLARE_DYNAMIC_CLASS(wxProperty) protected: - bool enabled; + bool m_enabled; public: - wxPropertyValue value; - wxString name; - wxString propertyRole; - wxPropertyValidator *propertyValidator; - wxWindow *propertyWindow; // Usually a panel item, if anything + 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); @@ -300,20 +305,20 @@ class wxProperty: public wxObject wxProperty(wxString name, const wxPropertyValue& val, wxString role, wxPropertyValidator *ed = NULL); ~wxProperty(void); - virtual wxPropertyValue& GetValue(void); - virtual wxPropertyValidator *GetValidator(void); - virtual wxString& GetName(void); - virtual wxString& GetRole(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) { propertyWindow = win; } - virtual inline wxWindow *GetWindow(void) { return propertyWindow; } + virtual inline void SetWindow(wxWindow *win) { m_propertyWindow = win; } + virtual inline wxWindow *GetWindow(void) const { return m_propertyWindow; } - inline void Enable(bool en) { enabled = en; } - inline bool IsEnabled(void) { return enabled; } + inline void Enable(bool en) { m_enabled = en; } + inline bool IsEnabled(void) const { return m_enabled; } }; #endif diff --git a/utils/wxprop/src/propform.cpp b/utils/wxprop/src/propform.cpp index ccbacde54a..d05b3f15be 100644 --- a/utils/wxprop/src/propform.cpp +++ b/utils/wxprop/src/propform.cpp @@ -54,18 +54,18 @@ BEGIN_EVENT_TABLE(wxPropertyFormView, wxPropertyView) EVT_BUTTON(wxID_PROP_UPDATE, wxPropertyFormView::OnUpdate) END_EVENT_TABLE() -bool wxPropertyFormView::dialogCancelled = FALSE; +bool wxPropertyFormView::sm_dialogCancelled = FALSE; wxPropertyFormView::wxPropertyFormView(wxWindow *propPanel, long flags):wxPropertyView(flags) { - propertyWindow = propPanel; - managedWindow = NULL; + m_propertyWindow = propPanel; + m_managedWindow = NULL; - windowCloseButton = NULL; - windowCancelButton = NULL; - windowHelpButton = NULL; + m_windowCloseButton = NULL; + m_windowCancelButton = NULL; + m_windowHelpButton = NULL; - detailedEditing = FALSE; + m_detailedEditing = FALSE; } wxPropertyFormView::~wxPropertyFormView(void) @@ -74,8 +74,8 @@ wxPropertyFormView::~wxPropertyFormView(void) void wxPropertyFormView::ShowView(wxPropertySheet *ps, wxWindow *panel) { - propertySheet = ps; - + m_propertySheet = ps; + AssociatePanel(panel); // CreateControls(); // UpdatePropertyList(); @@ -90,10 +90,10 @@ bool wxPropertyFormView::OnUpdateView(void) bool wxPropertyFormView::Check(void) { - if (!propertySheet) + if (!m_propertySheet) return FALSE; - wxNode *node = propertySheet->GetProperties().First(); + wxNode *node = m_propertySheet->GetProperties().First(); while (node) { wxProperty *prop = (wxProperty *)node->Data(); @@ -101,7 +101,7 @@ bool wxPropertyFormView::Check(void) if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator))) { wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator; - if (!formValidator->OnCheckValue(prop, this, propertyWindow)) + if (!formValidator->OnCheckValue(prop, this, m_propertyWindow)) return FALSE; } node = node->Next(); @@ -111,10 +111,10 @@ bool wxPropertyFormView::Check(void) bool wxPropertyFormView::TransferToPropertySheet(void) { - if (!propertySheet) + if (!m_propertySheet) return FALSE; - wxNode *node = propertySheet->GetProperties().First(); + wxNode *node = m_propertySheet->GetProperties().First(); while (node) { wxProperty *prop = (wxProperty *)node->Data(); @@ -122,7 +122,7 @@ bool wxPropertyFormView::TransferToPropertySheet(void) if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator))) { wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator; - formValidator->OnRetrieveValue(prop, this, propertyWindow); + formValidator->OnRetrieveValue(prop, this, m_propertyWindow); } node = node->Next(); } @@ -131,10 +131,10 @@ bool wxPropertyFormView::TransferToPropertySheet(void) bool wxPropertyFormView::TransferToDialog(void) { - if (!propertySheet) + if (!m_propertySheet) return FALSE; - wxNode *node = propertySheet->GetProperties().First(); + wxNode *node = m_propertySheet->GetProperties().First(); while (node) { wxProperty *prop = (wxProperty *)node->Data(); @@ -142,7 +142,7 @@ bool wxPropertyFormView::TransferToDialog(void) if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator))) { wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator; - formValidator->OnDisplayValue(prop, this, propertyWindow); + formValidator->OnDisplayValue(prop, this, m_propertyWindow); } node = node->Next(); } @@ -151,16 +151,16 @@ bool wxPropertyFormView::TransferToDialog(void) bool wxPropertyFormView::AssociateNames(void) { - if (!propertySheet || !propertyWindow) + if (!m_propertySheet || !m_propertyWindow) return FALSE; - wxNode *node = propertyWindow->GetChildren()->First(); + wxNode *node = m_propertyWindow->GetChildren()->First(); while (node) { wxWindow *win = (wxWindow *)node->Data(); if (win->GetName() != "") { - wxProperty *prop = propertySheet->GetProperty(win->GetName()); + wxProperty *prop = m_propertySheet->GetProperty(win->GetName()); if (prop) prop->SetWindow(win); } @@ -182,16 +182,16 @@ void wxPropertyFormView::OnOk(wxCommandEvent& WXUNUSED(event)) if (!Check()) return; - dialogCancelled = FALSE; + sm_dialogCancelled = FALSE; - managedWindow->Close(TRUE); + m_managedWindow->Close(TRUE); } void wxPropertyFormView::OnCancel(wxCommandEvent& WXUNUSED(event)) { - dialogCancelled = TRUE; - - managedWindow->Close(TRUE); + sm_dialogCancelled = TRUE; + + m_managedWindow->Close(TRUE); } void wxPropertyFormView::OnHelp(wxCommandEvent& WXUNUSED(event)) @@ -210,7 +210,7 @@ void wxPropertyFormView::OnRevert(wxCommandEvent& WXUNUSED(event)) void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event) { - if (!propertySheet) + if (!m_propertySheet) return; if (win.GetName() == "") @@ -229,7 +229,7 @@ void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event) else { // Find a validator to route the command to. - wxNode *node = propertySheet->GetProperties().First(); + wxNode *node = m_propertySheet->GetProperties().First(); while (node) { wxProperty *prop = (wxProperty *)node->Data(); @@ -239,7 +239,7 @@ void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event) if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator))) { wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator; - formValidator->OnCommand(prop, this, propertyWindow, event); + formValidator->OnCommand(prop, this, m_propertyWindow, event); return; } } @@ -250,11 +250,11 @@ void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event) void wxPropertyFormView::OnDoubleClick(wxControl *item) { - if (!propertySheet) + if (!m_propertySheet) return; // Find a validator to route the command to. - wxNode *node = propertySheet->GetProperties().First(); + wxNode *node = m_propertySheet->GetProperties().First(); while (node) { wxProperty *prop = (wxProperty *)node->Data(); @@ -264,7 +264,7 @@ void wxPropertyFormView::OnDoubleClick(wxControl *item) if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator))) { wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator; - formValidator->OnDoubleClick(prop, this, propertyWindow); + formValidator->OnDoubleClick(prop, this, m_propertyWindow); return; } } @@ -282,18 +282,18 @@ wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *pare const wxPoint& pos, const wxSize& size, long style, const wxString& name): wxDialog(parent, -1, title, pos, size, style, name) { - view = v; - view->AssociatePanel(this); - view->SetManagedWindow(this); + m_view = v; + m_view->AssociatePanel(this); + m_view->SetManagedWindow(this); // SetAutoLayout(TRUE); } bool wxPropertyFormDialog::OnClose(void) { - if (view) + if (m_view) { - view->OnClose(); - view = NULL; + m_view->OnClose(); + m_view = NULL; return TRUE; } else @@ -302,19 +302,19 @@ bool wxPropertyFormDialog::OnClose(void) void wxPropertyFormDialog::OnDefaultAction(wxControl *item) { - view->OnDoubleClick(item); + m_view->OnDoubleClick(item); } void wxPropertyFormDialog::OnCommand(wxWindow& win, wxCommandEvent& event) { - if ( view ) - view->OnCommand(win, 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 ( !view || ! view->ProcessEvent(event) ) + if ( !m_view || ! m_view->ProcessEvent(event) ) return wxEvtHandler::ProcessEvent(event); else return TRUE; @@ -329,18 +329,18 @@ IMPLEMENT_CLASS(wxPropertyFormPanel, wxPanel) void wxPropertyFormPanel::OnDefaultAction(wxControl *item) { - view->OnDoubleClick(item); + m_view->OnDoubleClick(item); } void wxPropertyFormPanel::OnCommand(wxWindow& win, wxCommandEvent& event) { - view->OnCommand(win, event); + m_view->OnCommand(win, event); } // Extend event processing to search the view's event table bool wxPropertyFormPanel::ProcessEvent(wxEvent& event) { - if ( !view || ! view->ProcessEvent(event) ) + if ( !m_view || ! m_view->ProcessEvent(event) ) return wxEvtHandler::ProcessEvent(event); else return TRUE; @@ -354,8 +354,8 @@ IMPLEMENT_CLASS(wxPropertyFormFrame, wxFrame) bool wxPropertyFormFrame::OnClose(void) { - if (view) - return view->OnClose(); + if (m_view) + return m_view->OnClose(); else return FALSE; } @@ -367,12 +367,11 @@ wxPanel *wxPropertyFormFrame::OnCreatePanel(wxFrame *parent, wxPropertyFormView bool wxPropertyFormFrame::Initialize(void) { - propertyPanel = OnCreatePanel(this, view); - if (propertyPanel) + m_propertyPanel = OnCreatePanel(this, m_view); + if (m_propertyPanel) { - view->AssociatePanel(propertyPanel); - view->SetManagedWindow(this); -// propertyPanel->SetAutoLayout(TRUE); + m_view->AssociatePanel(m_propertyPanel); + m_view->SetManagedWindow(this); return TRUE; } else @@ -398,15 +397,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxRealFormValidator, wxPropertyFormValidator) bool wxRealFormValidator::OnCheckValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view), wxWindow *parentWindow) { - if (realMin == 0.0 && realMax == 0.0) + 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 *propertyWindow = property->GetWindow(); - if (!propertyWindow || !propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) return FALSE; - wxString value(((wxTextCtrl *)propertyWindow)->GetValue()); + wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue()); float val = 0.0; if (!StringToFloat(WXSTRINGCAST value, &val)) @@ -417,10 +416,10 @@ bool wxRealFormValidator::OnCheckValue( wxProperty *property, wxPropertyFormView return FALSE; } - if (val < realMin || val > realMax) + if (val < m_realMin || val > m_realMax) { char buf[200]; - sprintf(buf, "Value must be a real number between %.2f and %.2f!", realMin, realMax); + sprintf(buf, "Value must be a real number between %.2f and %.2f!", m_realMin, m_realMax); wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } @@ -431,11 +430,11 @@ bool wxRealFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormVi wxWindow *WXUNUSED(parentWindow) ) { // The item used for viewing the real number: should be a text item. - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow || !propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) return FALSE; - wxString value(((wxTextCtrl *)propertyWindow)->GetValue()); + wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue()); if (value.Length() == 0) return FALSE; @@ -449,11 +448,11 @@ bool wxRealFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormVie wxWindow *WXUNUSED(parentWindow) ) { // The item used for viewing the real number: should be a text item. - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow || !propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) return FALSE; - wxTextCtrl *textItem = (wxTextCtrl *)propertyWindow; + wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow; textItem->SetValue(FloatToString(property->GetValue().RealValue())); return TRUE; } @@ -466,19 +465,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxIntegerFormValidator, wxPropertyFormValidator) bool wxIntegerFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view), wxWindow *parentWindow) { - if (integerMin == 0.0 && integerMax == 0.0) + 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 *propertyWindow = property->GetWindow(); - if (!propertyWindow) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow) return FALSE; long val = 0; - if (propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) { - wxString value(((wxTextCtrl *)propertyWindow)->GetValue()); + wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue()); if (!StringToLong(WXSTRINGCAST value, &val)) { @@ -488,17 +487,17 @@ bool wxIntegerFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormVi return FALSE; } } - else if (propertyWindow->IsKindOf(CLASSINFO(wxSlider))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider))) { - val = (long)((wxSlider *)propertyWindow)->GetValue(); + val = (long)((wxSlider *)m_propertyWindow)->GetValue(); } else return FALSE; - if (val < integerMin || val > integerMax) + if (val < m_integerMin || val > m_integerMax) { char buf[200]; - sprintf(buf, "Value must be an integer between %ld and %ld!", integerMin, integerMax); + sprintf(buf, "Value must be an integer between %ld and %ld!", m_integerMin, m_integerMax); wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } @@ -509,13 +508,13 @@ bool wxIntegerFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFor wxWindow *WXUNUSED(parentWindow)) { // The item used for viewing the real number: should be a text item or a slider - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow) return FALSE; - if (propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) { - wxString value(((wxTextCtrl *)propertyWindow)->GetValue()); + wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue()); if (value.Length() == 0) return FALSE; @@ -523,9 +522,9 @@ bool wxIntegerFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFor long i = atol((const char *)value); property->GetValue() = i; } - else if (propertyWindow->IsKindOf(CLASSINFO(wxSlider))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider))) { - property->GetValue() = (long)((wxSlider *)propertyWindow)->GetValue(); + property->GetValue() = (long)((wxSlider *)m_propertyWindow)->GetValue(); } else return FALSE; @@ -537,18 +536,18 @@ bool wxIntegerFormValidator::OnDisplayValue( wxProperty *property, wxPropertyFor wxWindow *WXUNUSED(parentWindow)) { // The item used for viewing the real number: should be a text item or a slider - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow) return FALSE; - if (propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) { - wxTextCtrl *textItem = (wxTextCtrl *)propertyWindow; + wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow; textItem->SetValue(LongToString(property->GetValue().IntegerValue())); } - else if (propertyWindow->IsKindOf(CLASSINFO(wxSlider))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider))) { - ((wxSlider *)propertyWindow)->SetValue((int)property->GetValue().IntegerValue()); + ((wxSlider *)m_propertyWindow)->SetValue((int)property->GetValue().IntegerValue()); } else return FALSE; @@ -564,8 +563,8 @@ bool wxBoolFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView wxWindow *WXUNUSED(parentWindow)) { // The item used for viewing the boolean: should be a checkbox - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow || !propertyWindow->IsKindOf(CLASSINFO(wxCheckBox))) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox))) return FALSE; return TRUE; @@ -575,12 +574,12 @@ bool wxBoolFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormVi wxWindow *WXUNUSED(parentWindow) ) { // The item used for viewing the boolean: should be a checkbox. - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow || !propertyWindow->IsKindOf(CLASSINFO(wxCheckBox))) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox))) return FALSE; - wxCheckBox *checkBox = (wxCheckBox *)propertyWindow; - + wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow; + property->GetValue() = (bool)checkBox->GetValue(); return TRUE; } @@ -589,11 +588,11 @@ bool wxBoolFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormVie wxWindow *WXUNUSED(parentWindow)) { // The item used for viewing the boolean: should be a checkbox. - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow || !propertyWindow->IsKindOf(CLASSINFO(wxCheckBox))) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox))) return FALSE; - wxCheckBox *checkBox = (wxCheckBox *)propertyWindow; + wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow; checkBox->SetValue((bool)property->GetValue().BoolValue()); return TRUE; } @@ -606,23 +605,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxStringFormValidator, wxPropertyFormValidator) wxStringFormValidator::wxStringFormValidator(wxStringList *list, long flags): wxPropertyFormValidator(flags) { - strings = list; + m_strings = list; } bool wxStringFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view), wxWindow *parentWindow ) { - if (!strings) + if (!m_strings) return TRUE; // The item used for viewing the string: should be a text item, choice item or listbox. - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow) return FALSE; - if (propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) { - wxTextCtrl *text = (wxTextCtrl *)propertyWindow; - if (!strings->Member(text->GetValue())) + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; + if (!m_strings->Member(text->GetValue())) { wxString s("Value "); s += text->GetValue(); @@ -643,32 +642,32 @@ bool wxStringFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyForm wxWindow *WXUNUSED(parentWindow) ) { // The item used for viewing the string: should be a text item, choice item or listbox. - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow) return FALSE; - if (propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) { - wxTextCtrl *text = (wxTextCtrl *)propertyWindow; + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; property->GetValue() = text->GetValue(); } - else if (propertyWindow->IsKindOf(CLASSINFO(wxListBox))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox))) { - wxListBox *lbox = (wxListBox *)propertyWindow; + wxListBox *lbox = (wxListBox *)m_propertyWindow; if (lbox->GetSelection() > -1) property->GetValue() = lbox->GetStringSelection(); } /* - else if (propertyWindow->IsKindOf(CLASSINFO(wxRadioBox))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxRadioBox))) { - wxRadioBox *rbox = (wxRadioBox *)propertyWindow; + wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow; int n = 0; if ((n = rbox->GetSelection()) > -1) property->GetValue() = rbox->GetString(n); } */ - else if (propertyWindow->IsKindOf(CLASSINFO(wxChoice))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice))) { - wxChoice *choice = (wxChoice *)propertyWindow; + wxChoice *choice = (wxChoice *)m_propertyWindow; if (choice->GetSelection() > -1) property->GetValue() = choice->GetStringSelection(); } @@ -681,21 +680,21 @@ bool wxStringFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormV wxWindow *WXUNUSED(parentWindow) ) { // The item used for viewing the string: should be a text item, choice item or listbox. - wxWindow *propertyWindow = property->GetWindow(); - if (!propertyWindow) + wxWindow *m_propertyWindow = property->GetWindow(); + if (!m_propertyWindow) return FALSE; - if (propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) + if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) { - wxTextCtrl *text = (wxTextCtrl *)propertyWindow; + wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow; text->SetValue(property->GetValue().StringValue()); } - else if (propertyWindow->IsKindOf(CLASSINFO(wxListBox))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox))) { - wxListBox *lbox = (wxListBox *)propertyWindow; - if (lbox->Number() == 0 && strings) + wxListBox *lbox = (wxListBox *)m_propertyWindow; + if (lbox->Number() == 0 && m_strings) { // Try to initialize the listbox from 'strings' - wxNode *node = strings->First(); + wxNode *node = m_strings->First(); while (node) { char *s = (char *)node->Data(); @@ -706,21 +705,21 @@ bool wxStringFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormV lbox->SetStringSelection(property->GetValue().StringValue()); } /* - else if (propertyWindow->IsKindOf(CLASSINFO(wxRadioBox))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxRadioBox))) { - wxRadioBox *rbox = (wxRadioBox *)propertyWindow; + wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow; rbox->SetStringSelection(property->GetValue().StringValue()); } */ - else if (propertyWindow->IsKindOf(CLASSINFO(wxChoice))) + else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice))) { - wxChoice *choice = (wxChoice *)propertyWindow; + wxChoice *choice = (wxChoice *)m_propertyWindow; #ifndef __XVIEW__ - if (choice->Number() == 0 && strings) + if (choice->Number() == 0 && m_strings) { // Try to initialize the choice item from 'strings' // XView doesn't allow this kind of thing. - wxNode *node = strings->First(); + wxNode *node = m_strings->First(); while (node) { char *s = (char *)node->Data(); diff --git a/utils/wxprop/src/propform.h b/utils/wxprop/src/propform.h index f00ad7f701..fd31eccaf5 100644 --- a/utils/wxprop/src/propform.h +++ b/utils/wxprop/src/propform.h @@ -29,18 +29,7 @@ class wxPropertyFormView: public wxPropertyView { DECLARE_DYNAMIC_CLASS(wxPropertyFormView) - protected: - bool detailedEditing; // E.g. using listbox for choices - - wxWindow *propertyWindow; // Panel that the controls will appear on - wxWindow *managedWindow; // Frame or dialog - - wxButton *windowCloseButton; // Or OK - wxButton *windowCancelButton; - wxButton *windowHelpButton; public: - static bool dialogCancelled; - wxPropertyFormView(wxWindow *propPanel = NULL, long flags = 0); ~wxPropertyFormView(void); @@ -78,15 +67,28 @@ class wxPropertyFormView: public wxPropertyView // TODO: does OnCommand still get called...??? virtual void OnCommand(wxWindow& win, wxCommandEvent& event); - inline virtual void AssociatePanel(wxWindow *win) { propertyWindow = win; } - inline virtual wxWindow *GetPanel(void) { return propertyWindow; } + 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; - inline virtual void SetManagedWindow(wxWindow *win) { managedWindow = win; } - inline virtual wxWindow *GetManagedWindow(void) { return managedWindow; } + protected: + bool m_detailedEditing; // E.g. using listbox for choices - inline virtual wxButton *GetWindowCloseButton() { return windowCloseButton; } - inline virtual wxButton *GetWindowCancelButton() { return windowCancelButton; } - inline virtual wxButton *GetHelpButton() { return windowHelpButton; } + 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() @@ -144,14 +146,11 @@ class wxPropertyFormValidator: public wxPropertyValidator class wxRealFormValidator: public wxPropertyFormValidator { DECLARE_DYNAMIC_CLASS(wxRealFormValidator) - protected: - float realMin; - float realMax; public: // 0.0, 0.0 means no range wxRealFormValidator(float min = 0.0, float max = 0.0, long flags = 0):wxPropertyFormValidator(flags) { - realMin = min; realMax = max; + m_realMin = min; m_realMax = max; } ~wxRealFormValidator(void) {} @@ -159,25 +158,30 @@ class wxRealFormValidator: public wxPropertyFormValidator 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 wxIntegerFormValidator: public wxPropertyFormValidator { DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator) - protected: - long integerMin; - long integerMax; public: // 0, 0 means no range wxIntegerFormValidator(long min = 0, long max = 0, long flags = 0):wxPropertyFormValidator(flags) { - integerMin = min; integerMax = max; + 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 wxBoolFormValidator: public wxPropertyFormValidator @@ -198,20 +202,21 @@ class wxBoolFormValidator: public wxPropertyFormValidator class wxStringFormValidator: public wxPropertyFormValidator { DECLARE_DYNAMIC_CLASS(wxStringFormValidator) - protected: - wxStringList *strings; public: wxStringFormValidator(wxStringList *list = NULL, long flags = 0); ~wxStringFormValidator(void) { - if (strings) - delete strings; + 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; }; /* @@ -221,8 +226,6 @@ class wxStringFormValidator: public wxPropertyFormValidator class wxPropertyFormDialog: public wxDialog { DECLARE_CLASS(wxPropertyFormDialog) - private: - wxPropertyFormView *view; public: wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -233,6 +236,9 @@ class wxPropertyFormDialog: public wxDialog // Extend event processing to search the view's event table virtual bool ProcessEvent(wxEvent& event); + + private: + wxPropertyFormView* m_view; }; /* @@ -242,20 +248,21 @@ class wxPropertyFormDialog: public wxDialog class wxPropertyFormPanel: public wxPanel { DECLARE_CLASS(wxPropertyFormPanel) - private: - wxPropertyFormView *view; public: wxPropertyFormPanel(wxPropertyFormView *v, wxWindow *parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "panel"): wxPanel(parent, -1, pos, size, style, name) { - view = v; + 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); + + private: + wxPropertyFormView* m_view; }; /* @@ -265,24 +272,25 @@ class wxPropertyFormPanel: public wxPanel class wxPropertyFormFrame: public wxFrame { DECLARE_CLASS(wxPropertyFormFrame) - private: - wxPropertyFormView *view; - wxPanel *propertyPanel; public: wxPropertyFormFrame(wxPropertyFormView *v, wxFrame *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME, const wxString& name = "frame"): wxFrame(parent, -1, title, pos, size, style, name) { - view = v; - propertyPanel = NULL; + m_view = v; + m_propertyPanel = NULL; } bool OnClose(void); // 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) { return propertyPanel; } + inline virtual wxPanel *GetPropertyPanel(void) const { return m_propertyPanel; } + + private: + wxPropertyFormView* m_view; + wxPanel* m_propertyPanel; }; #endif diff --git a/utils/wxprop/src/proplist.cpp b/utils/wxprop/src/proplist.cpp index 6087120744..5f3cd18978 100644 --- a/utils/wxprop/src/proplist.cpp +++ b/utils/wxprop/src/proplist.cpp @@ -53,7 +53,7 @@ wxPropertyTextEdit::wxPropertyTextEdit(wxPropertyListView *v, wxWindow *parent, long style, const wxString& name): wxTextCtrl(parent, id, value, pos, size, style, wxDefaultValidator, name) { - view = v; + m_view = v; } void wxPropertyTextEdit::OnSetFocus(void) @@ -83,42 +83,42 @@ BEGIN_EVENT_TABLE(wxPropertyListView, wxPropertyView) EVT_LISTBOX(wxID_PROP_VALUE_SELECT, wxPropertyListView::OnValueListSelect) END_EVENT_TABLE() -bool wxPropertyListView::dialogCancelled = FALSE; -wxBitmap *wxPropertyListView::tickBitmap = NULL; -wxBitmap *wxPropertyListView::crossBitmap = NULL; +bool wxPropertyListView::sm_dialogCancelled = FALSE; +wxBitmap *wxPropertyListView::sm_tickBitmap = NULL; +wxBitmap *wxPropertyListView::sm_crossBitmap = NULL; wxPropertyListView::wxPropertyListView(wxPanel *propPanel, long flags):wxPropertyView(flags) { - propertyScrollingList = NULL; - valueList = NULL; - valueText = NULL; - editButton = NULL; - confirmButton = NULL; - cancelButton = NULL; - propertyWindow = propPanel; - managedWindow = NULL; + m_propertyScrollingList = NULL; + m_valueList = NULL; + m_valueText = NULL; + m_editButton = NULL; + m_confirmButton = NULL; + m_cancelButton = NULL; + m_propertyWindow = propPanel; + m_managedWindow = NULL; - windowCloseButton = NULL; - windowCancelButton = NULL; - windowHelpButton = NULL; + m_windowCloseButton = NULL; + m_windowCancelButton = NULL; + m_windowHelpButton = NULL; - detailedEditing = FALSE; + m_detailedEditing = FALSE; } wxPropertyListView::~wxPropertyListView(void) { /* - if (tickBitmap) - delete tickBitmap; - if (crossBitmap) - delete crossBitmap; + if (m_tickBitmap) + delete m_tickBitmap; + if (m_crossBitmap) + delete m_crossBitmap; */ } void wxPropertyListView::ShowView(wxPropertySheet *ps, wxPanel *panel) { - propertySheet = ps; - + m_propertySheet = ps; + AssociatePanel(panel); CreateControls(); @@ -135,16 +135,16 @@ bool wxPropertyListView::OnUpdateView(void) bool wxPropertyListView::UpdatePropertyList(bool clearEditArea) { - if (!propertyScrollingList || !propertySheet) + if (!m_propertyScrollingList || !m_propertySheet) return FALSE; - propertyScrollingList->Clear(); + m_propertyScrollingList->Clear(); if (clearEditArea) { - valueList->Clear(); - valueText->SetValue(""); + m_valueList->Clear(); + m_valueText->SetValue(""); } - wxNode *node = propertySheet->GetProperties().First(); + wxNode *node = m_propertySheet->GetProperties().First(); // Should sort them... later... while (node) @@ -153,7 +153,7 @@ bool wxPropertyListView::UpdatePropertyList(bool clearEditArea) wxString stringValueRepr(property->GetValue().GetStringRepresentation()); wxString paddedString(MakeNameValueString(property->GetName(), stringValueRepr)); - propertyScrollingList->Append(paddedString.GetData(), (char *)property); + m_propertyScrollingList->Append(paddedString.GetData(), (char *)property); node = node->Next(); } return TRUE; @@ -161,10 +161,10 @@ bool wxPropertyListView::UpdatePropertyList(bool clearEditArea) bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty *property) { - if (!propertyScrollingList || !propertySheet) + if (!m_propertyScrollingList || !m_propertySheet) return FALSE; - int currentlySelected = propertyScrollingList->GetSelection(); + int currentlySelected = m_propertyScrollingList->GetSelection(); // #ifdef __WXMSW__ wxString stringValueRepr(property->GetValue().GetStringRepresentation()); wxString paddedString(MakeNameValueString(property->GetName(), stringValueRepr)); @@ -175,8 +175,8 @@ bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty *property) // Don't update the listbox unnecessarily because it can cause // ugly flashing. - if (paddedString != propertyScrollingList->GetString(sel)) - propertyScrollingList->SetString(sel, paddedString.GetData()); + if (paddedString != m_propertyScrollingList->GetString(sel)) + m_propertyScrollingList->SetString(sel, paddedString.GetData()); } //#else // UpdatePropertyList(FALSE); @@ -185,7 +185,7 @@ bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty *property) // TODO: why is this necessary? #ifdef __WXMSW__ if (currentlySelected > -1) - propertyScrollingList->SetSelection(currentlySelected); + m_propertyScrollingList->SetSelection(currentlySelected); #endif return TRUE; @@ -194,10 +194,10 @@ bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty *property) // Find the wxListBox index corresponding to this property int wxPropertyListView::FindListIndexForProperty(wxProperty *property) { - int n = propertyScrollingList->Number(); + int n = m_propertyScrollingList->Number(); for (int i = 0; i < n; i++) { - if (property == (wxProperty *)propertyScrollingList->wxListBox::GetClientData(i)) + if (property == (wxProperty *)m_propertyScrollingList->wxListBox::GetClientData(i)) return i; } return -1; @@ -226,25 +226,25 @@ wxString wxPropertyListView::MakeNameValueString(wxString name, wxString value) // property. NULL resets to show no property. bool wxPropertyListView::ShowProperty(wxProperty *property, bool select) { - if (currentProperty) + if (m_currentProperty) { - EndShowingProperty(currentProperty); - currentProperty = NULL; + EndShowingProperty(m_currentProperty); + m_currentProperty = NULL; } - valueList->Clear(); - valueText->SetValue(""); + m_valueList->Clear(); + m_valueText->SetValue(""); if (property) { - currentProperty = property; + m_currentProperty = property; BeginShowingProperty(property); } if (select) { int sel = FindListIndexForProperty(property); if (sel > -1) - propertyScrollingList->SetSelection(sel); + m_propertyScrollingList->SetSelection(sel); } return TRUE; } @@ -252,16 +252,16 @@ bool wxPropertyListView::ShowProperty(wxProperty *property, bool select) // Find appropriate validator and load property into value controls bool wxPropertyListView::BeginShowingProperty(wxProperty *property) { - currentValidator = FindPropertyValidator(property); - if (!currentValidator) + m_currentValidator = FindPropertyValidator(property); + if (!m_currentValidator) return FALSE; - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return FALSE; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - listValidator->OnPrepareControls(property, this, propertyWindow); + listValidator->OnPrepareControls(property, this, m_propertyWindow); DisplayProperty(property); return TRUE; } @@ -269,99 +269,99 @@ bool wxPropertyListView::BeginShowingProperty(wxProperty *property) // Find appropriate validator and unload property from value controls bool wxPropertyListView::EndShowingProperty(wxProperty *property) { - if (!currentValidator) + if (!m_currentValidator) return FALSE; RetrieveProperty(property); - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return FALSE; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - listValidator->OnClearControls(property, this, propertyWindow); - if (detailedEditing) + listValidator->OnClearControls(property, this, m_propertyWindow); + if (m_detailedEditing) { - listValidator->OnClearDetailControls(property, this, propertyWindow); - detailedEditing = FALSE; + listValidator->OnClearDetailControls(property, this, m_propertyWindow); + m_detailedEditing = FALSE; } return TRUE; } void wxPropertyListView::BeginDetailedEditing(void) { - if (!currentValidator) + if (!m_currentValidator) return; - if (!currentProperty) + if (!m_currentProperty) return; - if (detailedEditing) + if (m_detailedEditing) return; - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return; - if (!currentProperty->IsEnabled()) + if (!m_currentProperty->IsEnabled()) return; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - if (listValidator->OnPrepareDetailControls(currentProperty, this, propertyWindow)) - detailedEditing = TRUE; + if (listValidator->OnPrepareDetailControls(m_currentProperty, this, m_propertyWindow)) + m_detailedEditing = TRUE; } void wxPropertyListView::EndDetailedEditing(void) { - if (!currentValidator) + if (!m_currentValidator) return; - if (!currentProperty) + if (!m_currentProperty) return; - RetrieveProperty(currentProperty); + RetrieveProperty(m_currentProperty); - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - if (detailedEditing) + if (m_detailedEditing) { - listValidator->OnClearDetailControls(currentProperty, this, propertyWindow); - detailedEditing = FALSE; + listValidator->OnClearDetailControls(m_currentProperty, this, m_propertyWindow); + m_detailedEditing = FALSE; } } bool wxPropertyListView::DisplayProperty(wxProperty *property) { - if (!currentValidator) + if (!m_currentValidator) return FALSE; - if (((currentValidator->GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == 0) || !property->IsEnabled()) - valueText->SetEditable(FALSE); + if (((m_currentValidator->GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == 0) || !property->IsEnabled()) + m_valueText->SetEditable(FALSE); else - valueText->SetEditable(TRUE); + m_valueText->SetEditable(TRUE); - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return FALSE; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - listValidator->OnDisplayValue(property, this, propertyWindow); + listValidator->OnDisplayValue(property, this, m_propertyWindow); return TRUE; } bool wxPropertyListView::RetrieveProperty(wxProperty *property) { - if (!currentValidator) + if (!m_currentValidator) return FALSE; if (!property->IsEnabled()) return FALSE; - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return FALSE; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - if (listValidator->OnCheckValue(property, this, propertyWindow)) + if (listValidator->OnCheckValue(property, this, m_propertyWindow)) { - if (listValidator->OnRetrieveValue(property, this, propertyWindow)) + if (listValidator->OnRetrieveValue(property, this, m_propertyWindow)) { UpdatePropertyDisplayInList(property); OnPropertyChanged(property); @@ -370,7 +370,7 @@ bool wxPropertyListView::RetrieveProperty(wxProperty *property) else { // Revert to old value - listValidator->OnDisplayValue(property, this, propertyWindow); + listValidator->OnDisplayValue(property, this, m_propertyWindow); } return TRUE; } @@ -384,11 +384,11 @@ bool wxPropertyListView::EditProperty(wxProperty *WXUNUSED(property)) // Called by the listbox callback void wxPropertyListView::OnPropertySelect(wxCommandEvent& WXUNUSED(event)) { - int sel = propertyScrollingList->GetSelection(); + int sel = m_propertyScrollingList->GetSelection(); if (sel > -1) { - wxProperty *newSel = (wxProperty *)propertyScrollingList->wxListBox::GetClientData(sel); - if (newSel && newSel != currentProperty) + wxProperty *newSel = (wxProperty *)m_propertyScrollingList->wxListBox::GetClientData(sel); + if (newSel && newSel != m_currentProperty) { ShowProperty(newSel, FALSE); } @@ -397,7 +397,7 @@ void wxPropertyListView::OnPropertySelect(wxCommandEvent& WXUNUSED(event)) bool wxPropertyListView::CreateControls(void) { - wxPanel *panel = (wxPanel *)propertyWindow; + wxPanel *panel = (wxPanel *)m_propertyWindow; int largeButtonWidth = 60; int largeButtonHeight = 25; @@ -414,7 +414,7 @@ bool wxPropertyListView::CreateControls(void) smallButtonHeight = -1; #endif - if (valueText) + if (m_valueText) return TRUE; if (!panel) @@ -438,30 +438,30 @@ bool wxPropertyListView::CreateControls(void) // These buttons are at the bottom of the window, but create them now // so the constraints are evaluated in the correct order - if (buttonFlags & wxPROP_BUTTON_OK) + if (m_buttonFlags & wxPROP_BUTTON_OK) { - windowCloseButton = new wxButton(panel, wxID_OK, "OK", + m_windowCloseButton = new wxButton(panel, wxID_OK, "OK", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - windowCloseButton->SetDefault(); - windowCloseButton->SetFocus(); + m_windowCloseButton->SetDefault(); + m_windowCloseButton->SetFocus(); } - else if (buttonFlags & wxPROP_BUTTON_CLOSE) + else if (m_buttonFlags & wxPROP_BUTTON_CLOSE) { - windowCloseButton = new wxButton(panel, wxID_OK, "Close", + m_windowCloseButton = new wxButton(panel, wxID_OK, "Close", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); } - if (buttonFlags & wxPROP_BUTTON_CANCEL) + if (m_buttonFlags & wxPROP_BUTTON_CANCEL) { - windowCancelButton = new wxButton(panel, wxID_CANCEL, "Cancel", + m_windowCancelButton = new wxButton(panel, wxID_CANCEL, "Cancel", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); } - if (buttonFlags & wxPROP_BUTTON_HELP) + if (m_buttonFlags & wxPROP_BUTTON_HELP) { - windowHelpButton = new wxButton(panel, wxID_HELP, "Help", + m_windowHelpButton = new wxButton(panel, wxID_HELP, "Help", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); } - if (windowCloseButton) + if (m_windowCloseButton) { wxLayoutConstraints *c1 = new wxLayoutConstraints; @@ -469,10 +469,10 @@ bool wxPropertyListView::CreateControls(void) c1->bottom.SameAs (panel, wxBottom, 2); c1->width.AsIs(); c1->height.AsIs(); - windowCloseButton->SetConstraints(c1); - leftMostWindow = windowCloseButton; + m_windowCloseButton->SetConstraints(c1); + leftMostWindow = m_windowCloseButton; } - if (windowCancelButton) + if (m_windowCancelButton) { wxLayoutConstraints *c2 = new wxLayoutConstraints; @@ -480,10 +480,10 @@ bool wxPropertyListView::CreateControls(void) c2->bottom.SameAs (panel, wxBottom, 2); c2->width.AsIs(); c2->height.AsIs(); - windowCancelButton->SetConstraints(c2); - leftMostWindow = windowCancelButton; + m_windowCancelButton->SetConstraints(c2); + leftMostWindow = m_windowCancelButton; } - if (windowHelpButton) + if (m_windowHelpButton) { wxLayoutConstraints *c2 = new wxLayoutConstraints; if (leftMostWindow == panel) @@ -494,11 +494,11 @@ bool wxPropertyListView::CreateControls(void) c2->bottom.SameAs (panel, wxBottom, 2); c2->width.AsIs(); c2->height.AsIs(); - windowHelpButton->SetConstraints(c2); - leftMostWindow = windowHelpButton; + m_windowHelpButton->SetConstraints(c2); + leftMostWindow = m_windowHelpButton; } - if (buttonFlags & wxPROP_BUTTON_CHECK_CROSS) + if (m_buttonFlags & wxPROP_BUTTON_CHECK_CROSS) { /* if (!tickBitmap) @@ -521,17 +521,17 @@ bool wxPropertyListView::CreateControls(void) /* if (tickBitmap && crossBitmap) { - confirmButton = new wxBitmapButton(panel, wxID_PROP_CHECK, tickBitmap, + m_confirmButton = new wxBitmapButton(panel, wxID_PROP_CHECK, tickBitmap, wxPoint(-1, -1), wxSize(smallButtonWidth-5, smallButtonHeight-5)); - cancelButton = new wxBitmapButton(panel, wxID_PROP_CROSS, crossBitmap, + m_cancelButton = new wxBitmapButton(panel, wxID_PROP_CROSS, crossBitmap, wxPoint(-1, -1), wxSize(smallButtonWidth-5, smallButtonHeight-5)); } else */ { - confirmButton = new wxButton(panel, wxID_PROP_CHECK, ":-)", + m_confirmButton = new wxButton(panel, wxID_PROP_CHECK, ":-)", wxPoint(-1, -1), wxSize(smallButtonWidth, smallButtonHeight)); - cancelButton = new wxButton(panel, wxID_PROP_CROSS, "X", + m_cancelButton = new wxButton(panel, wxID_PROP_CROSS, "X", wxPoint(-1, -1), wxSize(smallButtonWidth, smallButtonHeight)); } @@ -539,7 +539,7 @@ bool wxPropertyListView::CreateControls(void) c->left.SameAs (panel, wxLeft, 2); /* if (windowCloseButton) - c->top.Below (windowCloseButton, 2); + c->top.Below (m_windowCloseButton, 2); else */ c->top.SameAs (panel, wxTop, 2); @@ -547,30 +547,30 @@ bool wxPropertyListView::CreateControls(void) c->width.AsIs(); c->height.AsIs(); - cancelButton->SetConstraints(c); + m_cancelButton->SetConstraints(c); c = new wxLayoutConstraints; - c->left.RightOf (cancelButton, 2); - c->top.SameAs (cancelButton, wxTop, 0); + c->left.RightOf (m_cancelButton, 2); + c->top.SameAs (m_cancelButton, wxTop, 0); c->width.AsIs(); c->height.AsIs(); - confirmButton->SetConstraints(c); + m_confirmButton->SetConstraints(c); - cancelButton->Enable(FALSE); - confirmButton->Enable(FALSE); + m_cancelButton->Enable(FALSE); + m_confirmButton->Enable(FALSE); } - if (buttonFlags & wxPROP_PULLDOWN) + if (m_buttonFlags & wxPROP_PULLDOWN) { - editButton = new wxButton(panel, wxID_PROP_EDIT, "...", + m_editButton = new wxButton(panel, wxID_PROP_EDIT, "...", wxPoint(-1, -1), wxSize(smallButtonWidth, smallButtonHeight)); - editButton->Enable(FALSE); + m_editButton->Enable(FALSE); wxLayoutConstraints *c = new wxLayoutConstraints; /* - if (windowCloseButton) - c->top.Below (windowCloseButton, 2); + if (m_windowCloseButton) + c->top.Below (m_windowCloseButton, 2); else */ c->top.SameAs (panel, wxTop, 2); @@ -578,67 +578,66 @@ bool wxPropertyListView::CreateControls(void) c->right.SameAs (panel, wxRight, 2); c->width.AsIs(); c->height.AsIs(); - editButton->SetConstraints(c); + m_editButton->SetConstraints(c); } - valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, "", wxPoint(-1, -1), wxSize(-1, -1), wxPROCESS_ENTER); - valueText->Enable(FALSE); + m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, "", wxPoint(-1, -1), wxSize(-1, -1), wxPROCESS_ENTER); + m_valueText->Enable(FALSE); wxLayoutConstraints *c = new wxLayoutConstraints; - if (cancelButton) - c->left.RightOf (confirmButton, 2); + if (m_cancelButton) + c->left.RightOf (m_confirmButton, 2); else c->left.SameAs (panel, wxLeft, 2); /* - if (windowCloseButton) - c->top.Below (windowCloseButton, 2); + if (m_windowCloseButton) + c->top.Below (m_windowCloseButton, 2); else */ c->top.SameAs (panel, wxTop, 2); - if (editButton) - c->right.LeftOf (editButton, 2); + if (m_editButton) + c->right.LeftOf (m_editButton, 2); else c->right.SameAs (panel, wxRight, 2); c->height.AsIs(); - valueText->SetConstraints(c); + m_valueText->SetConstraints(c); - valueList = new wxListBox(panel, wxID_PROP_VALUE_SELECT, wxPoint(-1, -1), wxSize(-1, 60)); - valueList->Show(FALSE); + m_valueList = new wxListBox(panel, wxID_PROP_VALUE_SELECT, wxPoint(-1, -1), wxSize(-1, 60)); + m_valueList->Show(FALSE); c = new wxLayoutConstraints; c->left.SameAs (panel, wxLeft, 2); - c->top.Below (valueText, 2); + c->top.Below (m_valueText, 2); c->right.SameAs (panel, wxRight, 2); c->height.Absolute(60); - valueList->SetConstraints(c); + m_valueList->SetConstraints(c); - propertyScrollingList = new wxListBox(panel, wxID_PROP_SELECT, + m_propertyScrollingList = new wxListBox(panel, wxID_PROP_SELECT, wxPoint(-1, -1), wxSize(300, 300)); - propertyScrollingList->SetFont(boringFont); + m_propertyScrollingList->SetFont(boringFont); c = new wxLayoutConstraints; c->left.SameAs (panel, wxLeft, 2); - if (buttonFlags & wxPROP_DYNAMIC_VALUE_FIELD) - c->top.Below (valueText, 2); + if (m_buttonFlags & wxPROP_DYNAMIC_VALUE_FIELD) + c->top.Below (m_valueText, 2); else - c->top.Below (valueList, 2); + c->top.Below (m_valueList, 2); c->right.SameAs (panel, wxRight, 2); - if (windowCloseButton) - c->bottom.Above (windowCloseButton, -2); + if (m_windowCloseButton) + c->bottom.Above (m_windowCloseButton, -2); else c->bottom.SameAs (panel, wxBottom, 2); - propertyScrollingList->SetConstraints(c); - + m_propertyScrollingList->SetConstraints(c); // Note: if this is called now, it causes a GPF. // Why? @@ -649,33 +648,33 @@ bool wxPropertyListView::CreateControls(void) void wxPropertyListView::ShowTextControl(bool show) { - if (valueText) - valueText->Show(show); + if (m_valueText) + m_valueText->Show(show); } void wxPropertyListView::ShowListBoxControl(bool show) { - if (valueList) + if (m_valueList) { - valueList->Show(show); - if (buttonFlags & wxPROP_DYNAMIC_VALUE_FIELD) + m_valueList->Show(show); + if (m_buttonFlags & wxPROP_DYNAMIC_VALUE_FIELD) { - wxLayoutConstraints *constraints = propertyScrollingList->GetConstraints(); + wxLayoutConstraints *constraints = m_propertyScrollingList->GetConstraints(); if (constraints) { if (show) { - constraints->top.Below(valueList, 2); + constraints->top.Below(m_valueList, 2); // Maintain back-pointer so when valueList is deleted, // any reference to it from this window is removed. - valueList->AddConstraintReference(propertyScrollingList); + m_valueList->AddConstraintReference(m_propertyScrollingList); } else { - constraints->top.Below(valueText, 2); - valueText->AddConstraintReference(propertyScrollingList); + constraints->top.Below(m_valueText, 2); + m_valueText->AddConstraintReference(m_propertyScrollingList); } - propertyWindow->Layout(); + m_propertyWindow->Layout(); } } } @@ -683,14 +682,14 @@ void wxPropertyListView::ShowListBoxControl(bool show) void wxPropertyListView::EnableCheck(bool show) { - if (confirmButton) - confirmButton->Enable(show); + if (m_confirmButton) + m_confirmButton->Enable(show); } void wxPropertyListView::EnableCross(bool show) { - if (cancelButton) - cancelButton->Enable(show); + if (m_cancelButton) + m_cancelButton->Enable(show); } bool wxPropertyListView::OnClose(void) @@ -705,14 +704,14 @@ bool wxPropertyListView::OnClose(void) void wxPropertyListView::OnValueListSelect(wxCommandEvent& WXUNUSED(event)) { - if (currentProperty && currentValidator) + if (m_currentProperty && m_currentValidator) { - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - listValidator->OnValueListSelect(currentProperty, this, propertyWindow); + listValidator->OnValueListSelect(m_currentProperty, this, m_propertyWindow); } } @@ -721,14 +720,14 @@ void wxPropertyListView::OnOk(wxCommandEvent& event) // Retrieve the value if any OnCheck(event); - managedWindow->Close(TRUE); + m_managedWindow->Close(TRUE); } void wxPropertyListView::OnCancel(wxCommandEvent& WXUNUSED(event)) { // SetReturnCode(wxID_CANCEL); - managedWindow->Close(TRUE); - dialogCancelled = TRUE; + m_managedWindow->Close(TRUE); + sm_dialogCancelled = TRUE; } void wxPropertyListView::OnHelp(wxCommandEvent& WXUNUSED(event)) @@ -737,50 +736,50 @@ void wxPropertyListView::OnHelp(wxCommandEvent& WXUNUSED(event)) void wxPropertyListView::OnCheck(wxCommandEvent& WXUNUSED(event)) { - if (currentProperty) + if (m_currentProperty) { - RetrieveProperty(currentProperty); + RetrieveProperty(m_currentProperty); } } void wxPropertyListView::OnCross(wxCommandEvent& WXUNUSED(event)) { - if (currentProperty && currentValidator) + if (m_currentProperty && m_currentValidator) { - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; // Revert to old value - listValidator->OnDisplayValue(currentProperty, this, propertyWindow); + listValidator->OnDisplayValue(m_currentProperty, this, m_propertyWindow); } } void wxPropertyListView::OnPropertyDoubleClick(wxCommandEvent& WXUNUSED(event)) { - if (currentProperty && currentValidator) + if (m_currentProperty && m_currentValidator) { - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; // Revert to old value - listValidator->OnDoubleClick(currentProperty, this, propertyWindow); + listValidator->OnDoubleClick(m_currentProperty, this, m_propertyWindow); } } void wxPropertyListView::OnEdit(wxCommandEvent& WXUNUSED(event)) { - if (currentProperty && currentValidator) + if (m_currentProperty && m_currentValidator) { - if (!currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) + if (!m_currentValidator->IsKindOf(CLASSINFO(wxPropertyListValidator))) return; - wxPropertyListValidator *listValidator = (wxPropertyListValidator *)currentValidator; + wxPropertyListValidator *listValidator = (wxPropertyListValidator *)m_currentValidator; - listValidator->OnEdit(currentProperty, this, propertyWindow); + listValidator->OnEdit(m_currentProperty, this, m_propertyWindow); } } @@ -807,19 +806,19 @@ wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView *v, wxWindow *pare const wxSize& size, long style, const wxString& name): wxDialog(parent, -1, title, pos, size, style, name) { - view = v; - view->AssociatePanel( ((wxPanel*)this) ); - view->SetManagedWindow(this); + m_view = v; + m_view->AssociatePanel( ((wxPanel*)this) ); + m_view->SetManagedWindow(this); SetAutoLayout(TRUE); } bool wxPropertyListDialog::OnClose(void) { - if (view) + if (m_view) { SetReturnCode(wxID_CANCEL); - view->OnClose(); - view = NULL; + m_view->OnClose(); + m_view = NULL; return TRUE; } else @@ -835,7 +834,7 @@ void wxPropertyListDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) void wxPropertyListDialog::OnDefaultAction(wxControl *item) { /* - if (item == view->GetPropertyScrollingList()) + if (item == m_view->GetPropertyScrollingList()) view->OnDoubleClick(); */ } @@ -843,7 +842,7 @@ void wxPropertyListDialog::OnDefaultAction(wxControl *item) // Extend event processing to search the view's event table bool wxPropertyListDialog::ProcessEvent(wxEvent& event) { - if ( !view || ! view->ProcessEvent(event) ) + if ( !m_view || ! m_view->ProcessEvent(event) ) return wxEvtHandler::ProcessEvent(event); else return TRUE; @@ -874,7 +873,7 @@ void wxPropertyListPanel::OnDefaultAction(wxControl *item) // Extend event processing to search the view's event table bool wxPropertyListPanel::ProcessEvent(wxEvent& event) { - if ( !view || ! view->ProcessEvent(event) ) + if ( !m_view || ! m_view->ProcessEvent(event) ) return wxEvtHandler::ProcessEvent(event); else return TRUE; @@ -893,12 +892,12 @@ IMPLEMENT_CLASS(wxPropertyListFrame, wxFrame) bool wxPropertyListFrame::OnClose(void) { - if (view) + if (m_view) { - if (propertyPanel) - propertyPanel->SetView(NULL); - view->OnClose(); - view = NULL; + if (m_propertyPanel) + m_propertyPanel->SetView(NULL); + m_view->OnClose(); + m_view = NULL; return TRUE; } else @@ -912,12 +911,12 @@ wxPropertyListPanel *wxPropertyListFrame::OnCreatePanel(wxFrame *parent, wxPrope bool wxPropertyListFrame::Initialize(void) { - propertyPanel = OnCreatePanel(this, view); - if (propertyPanel) + m_propertyPanel = OnCreatePanel(this, m_view); + if (m_propertyPanel) { - view->AssociatePanel(propertyPanel); - view->SetManagedWindow(this); - propertyPanel->SetAutoLayout(TRUE); + m_view->AssociatePanel(m_propertyPanel); + m_view->SetManagedWindow(this); + m_propertyPanel->SetAutoLayout(TRUE); return TRUE; } else @@ -999,7 +998,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxRealListValidator, wxPropertyListValidator) /// bool wxRealListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) { - if (realMin == 0.0 && realMax == 0.0) + if (m_realMin == 0.0 && m_realMax == 0.0) return TRUE; if (!view->GetValueText()) @@ -1015,10 +1014,10 @@ bool wxRealListValidator::OnCheckValue(wxProperty *property, wxPropertyListView return FALSE; } - if (val < realMin || val > realMax) + if (val < m_realMin || val > m_realMax) { char buf[200]; - sprintf(buf, "Value must be a real number between %.2f and %.2f!", realMin, realMax); + sprintf(buf, "Value must be a real number between %.2f and %.2f!", m_realMin, m_realMax); wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } @@ -1062,7 +1061,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxIntegerListValidator, wxPropertyListValidator) bool wxIntegerListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) { - if (integerMin == 0 && integerMax == 0) + if (m_integerMin == 0 && m_integerMax == 0) return TRUE; if (!view->GetValueText()) @@ -1077,10 +1076,10 @@ bool wxIntegerListValidator::OnCheckValue(wxProperty *property, wxPropertyListVi wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } - if (val < integerMin || val > integerMax) + if (val < m_integerMin || val > m_integerMax) { char buf[200]; - sprintf(buf, "Value must be an integer between %ld and %ld!", integerMin, integerMax); + sprintf(buf, "Value must be an integer between %ld and %ld!", m_integerMin, m_integerMax); wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } @@ -1235,22 +1234,22 @@ IMPLEMENT_DYNAMIC_CLASS(wxStringListValidator, wxPropertyListValidator) wxStringListValidator::wxStringListValidator(wxStringList *list, long flags): wxPropertyListValidator(flags) { - strings = list; + m_strings = list; // If no constraint, we just allow the string to be edited. - if (!strings && ((validatorFlags & wxPROP_ALLOW_TEXT_EDITING) == 0)) - validatorFlags |= wxPROP_ALLOW_TEXT_EDITING; + if (!m_strings && ((m_validatorFlags & wxPROP_ALLOW_TEXT_EDITING) == 0)) + m_validatorFlags |= wxPROP_ALLOW_TEXT_EDITING; } bool wxStringListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) { - if (!strings) + if (!m_strings) return TRUE; if (!view->GetValueText()) return FALSE; wxString value(view->GetValueText()->GetValue()); - if (!strings->Member(value.GetData())) + if (!m_strings->Member(value.GetData())) { wxString s("Value "); s += value.GetData(); @@ -1282,7 +1281,7 @@ bool wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListV return FALSE; wxString str(property->GetValue().GetStringRepresentation()); view->GetValueText()->SetValue(str); - if (strings && view->GetValueList() && view->GetValueList()->IsShown() && view->GetValueList()->Number() > 0) + if (m_strings && view->GetValueList() && view->GetValueList()->IsShown() && view->GetValueList()->Number() > 0) { view->GetValueList()->SetStringSelection(str); } @@ -1292,7 +1291,7 @@ bool wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListV bool wxStringListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) { // Unconstrained - if (!strings) + if (!m_strings) { if (view->GetEditButton()) view->GetEditButton()->Enable(FALSE); @@ -1325,7 +1324,7 @@ bool wxStringListValidator::OnPrepareDetailControls(wxProperty *property, wxProp { view->ShowListBoxControl(TRUE); view->GetValueList()->Enable(TRUE); - wxNode *node = strings->First(); + wxNode *node = m_strings->First(); while (node) { char *s = (char *)node->Data(); @@ -1340,7 +1339,7 @@ bool wxStringListValidator::OnPrepareDetailControls(wxProperty *property, wxProp bool wxStringListValidator::OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) { - if (!strings) + if (!m_strings) { return TRUE; } @@ -1360,10 +1359,10 @@ bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListVi { if (!view->GetValueText()) return FALSE; - if (!strings) + if (!m_strings) return FALSE; - wxNode *node = strings->First(); + wxNode *node = m_strings->First(); char *currentString = property->GetValue().StringValue(); while (node) { @@ -1374,7 +1373,7 @@ bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListVi if (node->Next()) nextString = (char *)node->Next()->Data(); else - nextString = (char *)strings->First()->Data(); + nextString = (char *)m_strings->First()->Data(); property->GetValue() = wxString(nextString); view->DisplayProperty(property); view->UpdatePropertyDisplayInList(property); @@ -1392,7 +1391,7 @@ bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListVi IMPLEMENT_DYNAMIC_CLASS(wxFilenameListValidator, wxPropertyListValidator) wxFilenameListValidator::wxFilenameListValidator(wxString message , wxString wildcard, long flags): - wxPropertyListValidator(flags), filenameWildCard(wildcard), filenameMessage(message) + wxPropertyListValidator(flags), m_filenameWildCard(wildcard), m_filenameMessage(message) { } @@ -1458,11 +1457,11 @@ void wxFilenameListValidator::OnEdit(wxProperty *property, wxPropertyListView *v return; char *s = wxFileSelector( - filenameMessage.GetData(), + m_filenameMessage.GetData(), wxPathOnly(property->GetValue().StringValue()), wxFileNameFromPath(property->GetValue().StringValue()), NULL, - filenameWildCard.GetData(), + m_filenameWildCard.GetData(), 0, parentWindow); if (s) @@ -1684,21 +1683,16 @@ void wxListOfStringsListValidator::OnEdit(wxProperty *property, wxPropertyListVi class wxPropertyStringListEditorDialog: public wxDialog { public: - wxStringList *stringList; - wxListBox *listBox; - wxTextCtrl *stringText; - static bool dialogCancelled; - int currentSelection; wxPropertyStringListEditorDialog(wxWindow *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = "stringEditorDialogBox"): wxDialog(parent, -1, title, pos, size, windowStyle, name) { - stringList = NULL; - stringText = NULL; - listBox = NULL; - dialogCancelled = FALSE; - currentSelection = -1; + m_stringList = NULL; + m_stringText = NULL; + m_listBox = NULL; + sm_dialogCancelled = FALSE; + m_currentSelection = -1; } ~wxPropertyStringListEditorDialog(void) {} bool OnClose(void); @@ -1712,6 +1706,12 @@ class wxPropertyStringListEditorDialog: public wxDialog 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() }; @@ -1745,7 +1745,7 @@ class wxPropertyStringListEditorText: public wxTextCtrl } }; -bool wxPropertyStringListEditorDialog::dialogCancelled = FALSE; +bool wxPropertyStringListEditorDialog::sm_dialogCancelled = FALSE; // Edit the string list. bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList *stringList, const char *title) @@ -1757,15 +1757,15 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList wxPropertyStringListEditorDialog *dialog = new wxPropertyStringListEditorDialog(parent, title, wxPoint(10, 10), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); - dialog->stringList = stringList; + dialog->m_stringList = stringList; - dialog->listBox = new wxListBox(dialog, wxID_PROP_SL_STRINGS, + dialog->m_listBox = new wxListBox(dialog, wxID_PROP_SL_STRINGS, wxPoint(-1, -1), wxSize(-1, -1), 0, NULL, wxLB_SINGLE); - dialog->stringText = new wxPropertyStringListEditorText(dialog, + dialog->m_stringText = new wxPropertyStringListEditorText(dialog, wxID_PROP_SL_TEXT, "", wxPoint(5, 240), wxSize(300, -1), wxPROCESS_ENTER); - dialog->stringText->Enable(FALSE); + dialog->m_stringText->Enable(FALSE); wxButton *addButton = new wxButton(dialog, wxID_PROP_SL_ADD, "Add", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); wxButton *deleteButton = new wxButton(dialog, wxID_PROP_SL_DELETE, "Delete", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); @@ -1779,15 +1779,15 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList c->top.SameAs (dialog, wxTop, 2); c->left.SameAs (dialog, wxLeft, 2); c->right.SameAs (dialog, wxRight, 2); - c->bottom.SameAs (dialog->stringText, wxTop, 2); - dialog->listBox->SetConstraints(c); + 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->stringText->SetConstraints(c); + dialog->m_stringText->SetConstraints(c); c = new wxLayoutConstraints; c->bottom.SameAs (dialog, wxBottom, 2); @@ -1822,7 +1822,7 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList { char *str = (char *)node->Data(); // Save node as client data for each listbox item - dialog->listBox->Append(str, (char *)node); + dialog->m_listBox->Append(str, (char *)node); node = node->Next(); } @@ -1844,10 +1844,10 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList void wxPropertyStringListEditorDialog::OnStrings(wxCommandEvent& WXUNUSED(event)) { - int sel = listBox->GetSelection(); + int sel = m_listBox->GetSelection(); if (sel > -1) { - currentSelection = sel; + m_currentSelection = sel; ShowCurrentSelection(); } @@ -1855,19 +1855,19 @@ void wxPropertyStringListEditorDialog::OnStrings(wxCommandEvent& WXUNUSED(event) void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& WXUNUSED(event)) { - int sel = listBox->GetSelection(); + int sel = m_listBox->GetSelection(); if (sel == -1) return; - wxNode *node = (wxNode *)listBox->wxListBox::GetClientData(sel); + wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(sel); if (!node) return; - listBox->Delete(sel); + m_listBox->Delete(sel); delete[] (char *)node->Data(); delete node; - currentSelection = -1; - stringText->SetValue(""); + m_currentSelection = -1; + m_stringText->SetValue(""); } void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event)) @@ -1875,12 +1875,12 @@ void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event)) SaveCurrentSelection(); char *initialText = ""; - wxNode *node = stringList->Add(initialText); - listBox->Append(initialText, (char *)node); - currentSelection = stringList->Number() - 1; - listBox->SetSelection(currentSelection); + wxNode *node = m_stringList->Add(initialText); + m_listBox->Append(initialText, (char *)node); + m_currentSelection = m_stringList->Number() - 1; + m_listBox->SetSelection(m_currentSelection); ShowCurrentSelection(); - stringText->SetFocus(); + m_stringText->SetFocus(); } void wxPropertyStringListEditorDialog::OnOK(wxCommandEvent& WXUNUSED(event)) @@ -1892,7 +1892,7 @@ void wxPropertyStringListEditorDialog::OnOK(wxCommandEvent& WXUNUSED(event)) void wxPropertyStringListEditorDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { - dialogCancelled = TRUE; + sm_dialogCancelled = TRUE; EndModal(wxID_CANCEL); Close(TRUE); } @@ -1913,30 +1913,30 @@ bool wxPropertyStringListEditorDialog::OnClose(void) void wxPropertyStringListEditorDialog::SaveCurrentSelection(void) { - if (currentSelection == -1) + if (m_currentSelection == -1) return; - wxNode *node = (wxNode *)listBox->wxListBox::GetClientData(currentSelection); + wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(m_currentSelection); if (!node) return; - wxString txt(stringText->GetValue()); + wxString txt(m_stringText->GetValue()); if (node->Data()) delete[] (char *)node->Data(); node->SetData((wxObject *)copystring(txt)); - listBox->SetString(currentSelection, (char *)node->Data()); + m_listBox->SetString(m_currentSelection, (char *)node->Data()); } void wxPropertyStringListEditorDialog::ShowCurrentSelection(void) { - if (currentSelection == -1) + if (m_currentSelection == -1) { - stringText->SetValue(""); + m_stringText->SetValue(""); return; } - wxNode *node = (wxNode *)listBox->wxListBox::GetClientData(currentSelection); + wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(m_currentSelection); char *txt = (char *)node->Data(); - stringText->SetValue(txt); - stringText->Enable(TRUE); + m_stringText->SetValue(txt); + m_stringText->Enable(TRUE); } diff --git a/utils/wxprop/src/proplist.h b/utils/wxprop/src/proplist.h index 5c066a5071..d3eaf777df 100644 --- a/utils/wxprop/src/proplist.h +++ b/utils/wxprop/src/proplist.h @@ -74,28 +74,7 @@ class wxPropertyListView: public wxPropertyView { DECLARE_DYNAMIC_CLASS(wxPropertyListView) - protected: - wxListBox *propertyScrollingList; - wxListBox *valueList; // Should really be a combobox, but we don't have one. - wxTextCtrl *valueText; - wxButton *confirmButton; // A tick, as in VB - wxButton *cancelButton; // A cross, as in VB - wxButton *editButton; // Invokes the custom validator, if any - - bool detailedEditing; // E.g. using listbox for choices - - static wxBitmap *tickBitmap; - static wxBitmap *crossBitmap; - - wxPanel *propertyWindow; // Panel that the controls will appear on - wxWindow *managedWindow; // Frame or dialog - - wxButton *windowCloseButton; // Or OK - wxButton *windowCancelButton; - wxButton *windowHelpButton; public: - static bool dialogCancelled; - wxPropertyListView(wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT); ~wxPropertyListView(void); @@ -161,26 +140,49 @@ class wxPropertyListView: public wxPropertyView void OnEdit(wxCommandEvent& event); void OnText(wxCommandEvent& event); - inline virtual wxListBox *GetPropertyScrollingList() { return propertyScrollingList; } - inline virtual wxListBox *GetValueList() { return valueList; } - inline virtual wxTextCtrl *GetValueText() { return valueText; } - inline virtual wxButton *GetConfirmButton() { return confirmButton; } - inline virtual wxButton *GetCancelButton() { return cancelButton; } - inline virtual wxButton *GetEditButton() { return editButton; } - inline virtual bool GetDetailedEditing(void) { return detailedEditing; } + 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) { propertyWindow = win; } - inline virtual wxPanel *GetPanel(void) { return propertyWindow; } + inline virtual void AssociatePanel(wxPanel *win) { m_propertyWindow = win; } + inline virtual wxPanel *GetPanel(void) const { return m_propertyWindow; } - inline virtual void SetManagedWindow(wxWindow *win) { managedWindow = win; } - inline virtual wxWindow *GetManagedWindow(void) { return managedWindow; } + inline virtual void SetManagedWindow(wxWindow *win) { m_managedWindow = win; } + inline virtual wxWindow *GetManagedWindow(void) const { return m_managedWindow; } - inline virtual wxButton *GetWindowCloseButton() { return windowCloseButton; } - inline virtual wxButton *GetWindowCancelButton() { return windowCancelButton; } - inline virtual wxButton *GetHelpButton() { return windowHelpButton; } + 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 + + bool m_detailedEditing; // E.g. using listbox for choices + + static wxBitmap* sm_tickBitmap; + static wxBitmap* sm_crossBitmap; + + 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; + DECLARE_EVENT_TABLE() }; @@ -188,12 +190,13 @@ class wxPropertyTextEdit: public wxTextCtrl { DECLARE_CLASS(wxPropertyTextEdit) public: - wxPropertyListView *view; wxPropertyTextEdit(wxPropertyListView *v, wxWindow *parent, const wxWindowID id, const wxString& value, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "text"); void OnSetFocus(void); void OnKillFocus(void); + + wxPropertyListView* m_view; }; #define wxPROP_ALLOW_TEXT_EDITING 1 @@ -267,8 +270,6 @@ class wxPropertyListValidator: public wxPropertyValidator class wxPropertyListDialog: public wxDialog { DECLARE_CLASS(wxPropertyListDialog) - private: - wxPropertyListView *view; public: wxPropertyListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -280,6 +281,9 @@ class wxPropertyListDialog: public wxDialog // Extend event processing to search the view's event table virtual bool ProcessEvent(wxEvent& event); + private: + wxPropertyListView* m_view; + DECLARE_EVENT_TABLE() }; @@ -290,21 +294,19 @@ DECLARE_EVENT_TABLE() class wxPropertyListPanel: public wxPanel { DECLARE_CLASS(wxPropertyListPanel) - private: - wxPropertyListView *view; public: wxPropertyListPanel(wxPropertyListView *v, wxWindow *parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "panel"): wxPanel(parent, -1, pos, size, style, name) { - view = v; + m_view = v; } ~wxPropertyListPanel(); void OnDefaultAction(wxControl *item); - inline void SetView(wxPropertyListView* v) { view = v; } - inline wxPropertyListView* GetView() const { return view; } + 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); @@ -312,6 +314,9 @@ class wxPropertyListPanel: public wxPanel // Call Layout() void OnSize(wxSizeEvent& event); + private: + wxPropertyListView* m_view; + DECLARE_EVENT_TABLE() }; @@ -322,24 +327,25 @@ DECLARE_EVENT_TABLE() class wxPropertyListFrame: public wxFrame { DECLARE_CLASS(wxPropertyListFrame) - private: - wxPropertyListView *view; - wxPropertyListPanel *propertyPanel; public: wxPropertyListFrame(wxPropertyListView *v, wxFrame *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME, const wxString& name = "frame"): wxFrame(parent, -1, title, pos, size, style, name) { - view = v; - propertyPanel = NULL; + m_view = v; + m_propertyPanel = NULL; } bool OnClose(void); // 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) { return propertyPanel; } + inline virtual wxPropertyListPanel *GetPropertyPanel(void) const { return m_propertyPanel; } + + private: + wxPropertyListView* m_view; + wxPropertyListPanel* m_propertyPanel; }; /* @@ -349,14 +355,11 @@ class wxPropertyListFrame: public wxFrame class wxRealListValidator: public wxPropertyListValidator { DECLARE_DYNAMIC_CLASS(wxRealListValidator) - protected: - float realMin; - float realMax; 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) { - realMin = min; realMax = max; + m_realMin = min; m_realMax = max; } ~wxRealListValidator(void) {} @@ -370,19 +373,20 @@ class wxRealListValidator: public wxPropertyListValidator // 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; }; class wxIntegerListValidator: public wxPropertyListValidator { DECLARE_DYNAMIC_CLASS(wxIntegerListValidator) - protected: - long integerMin; - long integerMax; public: // 0, 0 means no range wxIntegerListValidator(long min = 0, long max = 0, long flags = wxPROP_ALLOW_TEXT_EDITING):wxPropertyListValidator(flags) { - integerMin = min; integerMax = max; + m_integerMin = min; m_integerMax = max; } ~wxIntegerListValidator(void) {} @@ -396,6 +400,10 @@ class wxIntegerListValidator: public wxPropertyListValidator // 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; }; class wxBoolListValidator: public wxPropertyListValidator @@ -430,15 +438,13 @@ class wxBoolListValidator: public wxPropertyListValidator class wxStringListValidator: public wxPropertyListValidator { DECLARE_DYNAMIC_CLASS(wxStringListValidator) - protected: - wxStringList *strings; public: wxStringListValidator(wxStringList *list = NULL, long flags = 0); ~wxStringListValidator(void) { - if (strings) - delete strings; + if (m_strings) + delete m_strings; } bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); @@ -458,15 +464,14 @@ class wxStringListValidator: public wxPropertyListValidator // 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; }; class wxFilenameListValidator: public wxPropertyListValidator { DECLARE_DYNAMIC_CLASS(wxFilenameListValidator) - protected: - wxString filenameWildCard; - wxString filenameMessage; - public: wxFilenameListValidator(wxString message = "Select a file", wxString wildcard = "*.*", long flags = 0); @@ -488,6 +493,11 @@ class wxFilenameListValidator: public wxPropertyListValidator // Called when the edit (...) button is pressed. void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); + + protected: + wxString m_filenameWildCard; + wxString m_filenameMessage; + }; class wxColourListValidator: public wxPropertyListValidator -- 2.45.2