From 8d772832a04a3d2380ac6b3ffea6bfe6a72dcff6 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 23 Dec 1999 19:23:13 +0000 Subject: [PATCH 1/1] Added a constructor that allows creation of independent wxControl (for more easily creating custom controls) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/control.h | 16 ++++++++++++++-- include/wx/gtk1/control.h | 16 ++++++++++++++-- include/wx/msw/control.h | 23 ++++++++++++++++++++++- src/gtk/control.cpp | 14 ++++++++++++++ src/gtk/data.cpp | 1 + src/gtk1/control.cpp | 14 ++++++++++++++ src/gtk1/data.cpp | 1 + src/msw/control.cpp | 18 ++++++++++++++++++ src/msw/data.cpp | 1 + 9 files changed, 99 insertions(+), 5 deletions(-) diff --git a/include/wx/gtk/control.h b/include/wx/gtk/control.h index e7869e4f0e..93b2e82566 100644 --- a/include/wx/gtk/control.h +++ b/include/wx/gtk/control.h @@ -29,6 +29,8 @@ class wxControl; // wxControl //----------------------------------------------------------------------------- +extern const wxChar* wxControlNameStr; + class wxControl : public wxControlBase { public: @@ -38,7 +40,17 @@ public: const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = 0, - const wxString &name = wxPanelNameStr ); + const wxString &name = wxControlNameStr ); + +#if wxUSE_VALIDATORS + wxControl( wxWindow *parent, + wxWindowID id, + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString &name = wxControlNameStr ); +#endif // this function will filter out '&' characters and will put the accelerator // char (the one immediately after '&') into m_chAccel (TODO not yet) @@ -50,7 +62,7 @@ protected: wxString m_label; char m_chAccel; // enabled to avoid breaking binary compatibility later on - + private: DECLARE_DYNAMIC_CLASS(wxControl) }; diff --git a/include/wx/gtk1/control.h b/include/wx/gtk1/control.h index e7869e4f0e..93b2e82566 100644 --- a/include/wx/gtk1/control.h +++ b/include/wx/gtk1/control.h @@ -29,6 +29,8 @@ class wxControl; // wxControl //----------------------------------------------------------------------------- +extern const wxChar* wxControlNameStr; + class wxControl : public wxControlBase { public: @@ -38,7 +40,17 @@ public: const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = 0, - const wxString &name = wxPanelNameStr ); + const wxString &name = wxControlNameStr ); + +#if wxUSE_VALIDATORS + wxControl( wxWindow *parent, + wxWindowID id, + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString &name = wxControlNameStr ); +#endif // this function will filter out '&' characters and will put the accelerator // char (the one immediately after '&') into m_chAccel (TODO not yet) @@ -50,7 +62,7 @@ protected: wxString m_label; char m_chAccel; // enabled to avoid breaking binary compatibility later on - + private: DECLARE_DYNAMIC_CLASS(wxControl) }; diff --git a/include/wx/msw/control.h b/include/wx/msw/control.h index 4c566bfb15..e63718755f 100644 --- a/include/wx/msw/control.h +++ b/include/wx/msw/control.h @@ -18,6 +18,8 @@ #include "wx/dynarray.h" +WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr; + // General item class class WXDLLEXPORT wxControl : public wxControlBase { @@ -25,7 +27,26 @@ class WXDLLEXPORT wxControl : public wxControlBase public: wxControl(); - virtual ~wxControl(); + wxControl(wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, +#if wxUSE_VALIDATORS + const wxValidator& validator = wxDefaultValidator, +#endif + const wxString& name = wxControlNameStr) + { + Create(parent, id, pos, size, style, validator, name); + } + + bool Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, +#if wxUSE_VALIDATORS + const wxValidator& validator = wxDefaultValidator, +#endif + const wxString& name = wxControlNameStr); + + virtual ~wxControl(); // Simulates an event virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index c150c147ee..b369c4d8c1 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -36,6 +36,20 @@ wxControl::wxControl( wxWindow *parent, (void)Create(parent, id, pos, size, style, name); } +#if wxUSE_VALIDATORS +wxControl::wxControl( wxWindow *parent, + wxWindowID id, + const wxPoint &pos, + const wxSize &size, + long style, + const wxValidator& validator, + const wxString &name) +{ + (void)Create(parent, id, pos, size, style, name); + SetValidator(validator); +} +#endif + void wxControl::SetLabel( const wxString &label ) { m_label.Empty(); diff --git a/src/gtk/data.cpp b/src/gtk/data.cpp index 6ecbf2a917..9971508a7b 100644 --- a/src/gtk/data.cpp +++ b/src/gtk/data.cpp @@ -130,6 +130,7 @@ wxColour wxNullColour; wxPalette wxNullPalette; /* Default window names */ +const wxChar *wxControlNameStr = wxT("control"); const wxChar *wxButtonNameStr = wxT("button"); const wxChar *wxCanvasNameStr = wxT("canvas"); const wxChar *wxCheckBoxNameStr = wxT("check"); diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index c150c147ee..b369c4d8c1 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -36,6 +36,20 @@ wxControl::wxControl( wxWindow *parent, (void)Create(parent, id, pos, size, style, name); } +#if wxUSE_VALIDATORS +wxControl::wxControl( wxWindow *parent, + wxWindowID id, + const wxPoint &pos, + const wxSize &size, + long style, + const wxValidator& validator, + const wxString &name) +{ + (void)Create(parent, id, pos, size, style, name); + SetValidator(validator); +} +#endif + void wxControl::SetLabel( const wxString &label ) { m_label.Empty(); diff --git a/src/gtk1/data.cpp b/src/gtk1/data.cpp index 6ecbf2a917..9971508a7b 100644 --- a/src/gtk1/data.cpp +++ b/src/gtk1/data.cpp @@ -130,6 +130,7 @@ wxColour wxNullColour; wxPalette wxNullPalette; /* Default window names */ +const wxChar *wxControlNameStr = wxT("control"); const wxChar *wxButtonNameStr = wxT("button"); const wxChar *wxCanvasNameStr = wxT("canvas"); const wxChar *wxCheckBoxNameStr = wxT("check"); diff --git a/src/msw/control.cpp b/src/msw/control.cpp index f6f67bac35..0a177e8d69 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -56,6 +56,24 @@ wxControl::~wxControl() m_isBeingDeleted = TRUE; } + +bool wxControl::Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos, + const wxSize& size, long style, +#if wxUSE_VALIDATORS + const wxValidator& validator, +#endif + const wxString& name) +{ + bool rval = wxWindow::Create(parent, id, pos, size, style, name); + if (rval) { +#if wxUSE_VALIDATORS + SetValidator(validator); +#endif + } + return rval; +} + bool wxControl::MSWCreateControl(const wxChar *classname, WXDWORD style, const wxPoint& pos, diff --git a/src/msw/data.cpp b/src/msw/data.cpp index b925bccfd5..103f694ce0 100644 --- a/src/msw/data.cpp +++ b/src/msw/data.cpp @@ -112,6 +112,7 @@ wxFont wxNullFont; wxColour wxNullColour; // Default window names +const wxChar *wxControlNameStr = wxT("control"); const wxChar *wxButtonNameStr = wxT("button"); const wxChar *wxCanvasNameStr = wxT("canvas"); const wxChar *wxCheckBoxNameStr = wxT("check"); -- 2.45.2