From 7adf8bf391f56cf8be95cd64bfa1bcf5d49d3c74 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Fri, 3 Oct 2008 15:23:00 +0000 Subject: [PATCH] Remove wxPGClipperWindow, use wxBORDER_NONE instead of wxNO_BORDER git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56055 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/propgrid.h | 7 - src/propgrid/editors.cpp | 273 +-------------------------------- src/propgrid/propgrid.cpp | 2 - 3 files changed, 4 insertions(+), 278 deletions(-) diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index d16ad074ea..c524db9338 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1178,16 +1178,9 @@ public: const wxPGProperty* p2 ) const; /** Returns pointer to current active primary editor control (NULL if none). - - If editor uses clipper window, pointer is returned to the actual - editor, not the clipper. */ wxWindow* GetEditorControl() const; - /** Adjusts given position if topCtrlWnd is child of clipper window. - */ - bool AdjustPosForClipperWindow( wxWindow* topCtrlWnd, int* x, int* y ); - wxWindow* GetPrimaryEditor() const { return GetEditorControl(); diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index a16baa76c4..e53c0c29c0 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -85,9 +85,6 @@ #if defined(__WXMSW__) // tested - #define wxPG_NAT_TEXTCTRL_BORDER_X 0 // Unremovable border of native textctrl. - #define wxPG_NAT_TEXTCTRL_BORDER_Y 0 // Unremovable border of native textctrl. - #define wxPG_NAT_BUTTON_BORDER_ANY 1 #define wxPG_NAT_BUTTON_BORDER_X 1 #define wxPG_NAT_BUTTON_BORDER_Y 1 @@ -108,9 +105,6 @@ #define wxPG_CHECKMARK_HADJ (-1) #define wxPG_CHECKMARK_DEFLATE 3 - #define wxPG_NAT_TEXTCTRL_BORDER_X 0 // Unremovable border of native textctrl. - #define wxPG_NAT_TEXTCTRL_BORDER_Y 0 // Unremovable border of native textctrl. - #define wxPG_NAT_BUTTON_BORDER_ANY 1 #define wxPG_NAT_BUTTON_BORDER_X 1 #define wxPG_NAT_BUTTON_BORDER_Y 1 @@ -125,9 +119,6 @@ #define wxPG_CHECKMARK_HADJ 0 #define wxPG_CHECKMARK_DEFLATE 0 - #define wxPG_NAT_TEXTCTRL_BORDER_X 0 // Unremovable border of native textctrl. - #define wxPG_NAT_TEXTCTRL_BORDER_Y 0 // Unremovable border of native textctrl. - #define wxPG_NAT_BUTTON_BORDER_ANY 0 #define wxPG_NAT_BUTTON_BORDER_X 0 #define wxPG_NAT_BUTTON_BORDER_Y 0 @@ -142,9 +133,6 @@ #define wxPG_CHECKMARK_HADJ 0 #define wxPG_CHECKMARK_DEFLATE 0 - #define wxPG_NAT_TEXTCTRL_BORDER_X 0 // Unremovable border of native textctrl. - #define wxPG_NAT_TEXTCTRL_BORDER_Y 0 // Unremovable border of native textctrl. - #define wxPG_NAT_BUTTON_BORDER_ANY 0 #define wxPG_NAT_BUTTON_BORDER_X 0 #define wxPG_NAT_BUTTON_BORDER_Y 0 @@ -153,13 +141,6 @@ #endif -#if (!wxPG_NAT_TEXTCTRL_BORDER_X && !wxPG_NAT_TEXTCTRL_BORDER_Y) - #define wxPG_ENABLE_CLIPPER_WINDOW 0 -#else - #define wxPG_ENABLE_CLIPPER_WINDOW 1 -#endif - - // for odcombo #define wxPG_CHOICEXADJUST 0 #define wxPG_CHOICEYADJUST 0 @@ -224,199 +205,10 @@ bool wxPGEditor::CanContainCustomImage() const return false; } -// ----------------------------------------------------------------------- -// wxPGClipperWindow -// ----------------------------------------------------------------------- - - -#if wxPG_ENABLE_CLIPPER_WINDOW - -// -// Clipper window is used to "remove" borders from controls -// which otherwise insist on having them despite of supplied -// wxNO_BORDER window style. -// -class wxPGClipperWindow : public wxWindow -{ - DECLARE_CLASS(wxPGClipperWindow) -public: - - wxPGClipperWindow() - : wxWindow() - { - wxPGClipperWindow::Init(); - } - - wxPGClipperWindow(wxWindow* parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize) - { - Init(); - Create(parent,id,pos,size); - } - - void Create(wxWindow* parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize); - - virtual ~wxPGClipperWindow(); - - virtual bool ProcessEvent(wxEvent& event); - - inline wxWindow* GetControl() const { return m_ctrl; } - - // This is called before wxControl is constructed. - void GetControlRect( int xadj, int yadj, wxPoint& pt, wxSize& sz ); - - // This is caleed after wxControl has been constructed. - void SetControl( wxWindow* ctrl ); - - virtual void Refresh( bool eraseBackground = true, - const wxRect *rect = (const wxRect *) NULL ); - virtual void SetFocus(); - - virtual bool SetFont(const wxFont& font); - - inline int GetXClip() const { return m_xadj; } - - inline int GetYClip() const { return m_yadj; } - -protected: - wxWindow* m_ctrl; - - int m_xadj; // Horizontal border clip. - - int m_yadj; // Vertical border clip. - -private: - void Init () - { - m_ctrl = (wxWindow*) NULL; - } -}; - - -IMPLEMENT_CLASS(wxPGClipperWindow,wxWindow) - - -// This is called before wxControl is constructed. -void wxPGClipperWindow::GetControlRect( int xadj, int yadj, wxPoint& pt, wxSize& sz ) -{ - m_xadj = xadj; - m_yadj = yadj; - pt.x = -xadj; - pt.y = -yadj; - wxSize own_size = GetSize(); - sz.x = own_size.x+(xadj*2); - sz.y = own_size.y+(yadj*2); -} - - -// This is caleed after wxControl has been constructed. -void wxPGClipperWindow::SetControl( wxWindow* ctrl ) -{ - m_ctrl = ctrl; - - // GTK requires this. - ctrl->SetSizeHints(3,3); - - // Correct size of this window to match the child. - wxSize sz = GetSize(); - wxSize chsz = ctrl->GetSize(); - - int hei_adj = chsz.y - (sz.y+(m_yadj*2)); - if ( hei_adj ) - SetSize(sz.x,chsz.y-(m_yadj*2)); - -} - - -void wxPGClipperWindow::Refresh( bool eraseBackground, const wxRect *rect ) -{ - wxWindow::Refresh(false,rect); - if ( m_ctrl ) - m_ctrl->Refresh(eraseBackground); -} - - -// Pass focus to control -void wxPGClipperWindow::SetFocus() -{ - if ( m_ctrl ) - m_ctrl->SetFocus(); - else - wxWindow::SetFocus(); -} - - -bool wxPGClipperWindow::SetFont(const wxFont& font) -{ - bool res = wxWindow::SetFont(font); - if ( m_ctrl ) - return m_ctrl->SetFont(font); - return res; -} - - -void wxPGClipperWindow::Create(wxWindow* parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size ) -{ - wxWindow::Create(parent,id,pos,size); -} - - -wxPGClipperWindow::~wxPGClipperWindow() -{ -} - - -bool wxPGClipperWindow::ProcessEvent(wxEvent& event) -{ - if ( event.GetEventType() == wxEVT_SIZE ) - { - if ( m_ctrl ) - { - // Maintain correct size relationship. - wxSize sz = GetSize(); - m_ctrl->SetSize(sz.x+(m_xadj*2),sz.y+(m_yadj*2)); - event.Skip(); - return false; - } - } - return wxWindow::ProcessEvent(event); -} - -#endif // wxPG_ENABLE_CLIPPER_WINDOW - -/*wxWindow* wxPropertyGrid::GetActualEditorControl( wxWindow* ctrl ) -{ -#if wxPG_ENABLE_CLIPPER_WINDOW - // Pass real control instead of clipper window - if ( ctrl->IsKindOf(CLASSINFO(wxPGClipperWindow)) ) - { - return ((wxPGClipperWindow*)ctrl)->GetControl(); - } -#else - return ctrl; -#endif -}*/ - // ----------------------------------------------------------------------- // wxPGTextCtrlEditor // ----------------------------------------------------------------------- -// Clipper window support macro (depending on whether it is used -// for this editor or not) -#if wxPG_NAT_TEXTCTRL_BORDER_X || wxPG_NAT_TEXTCTRL_BORDER_Y - #define wxPG_NAT_TEXTCTRL_BORDER_ANY 1 -#else - #define wxPG_NAT_TEXTCTRL_BORDER_ANY 0 -#endif - WX_PG_IMPLEMENT_EDITOR_CLASS(TextCtrl,wxPGTextCtrlEditor,wxPGEditor) @@ -1017,7 +809,7 @@ wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid, si.x -= wxPG_CHOICEXADJUST; wxWindow* ctrlParent = propGrid->GetPanel(); - int odcbFlags = extraStyle | wxNO_BORDER | wxTE_PROCESS_ENTER; + int odcbFlags = extraStyle | wxBORDER_NONE | wxTE_PROCESS_ENTER; // // If common value specified, use appropriate index @@ -1432,7 +1224,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize ) - : wxControl(parent,id,pos,size,wxNO_BORDER|wxWANTS_CHARS) + : wxControl(parent,id,pos,size,wxBORDER_NONE|wxWANTS_CHARS) { // Due to SetOwnFont stuff necessary for GTK+ 1.2, we need to have this SetFont( parent->GetFont() ); @@ -1738,14 +1530,6 @@ wxWindow* wxPropertyGrid::GetEditorControl() const if ( !ctrl ) return ctrl; - // If it's clipper window, return its child instead -#if wxPG_ENABLE_CLIPPER_WINDOW - if ( ctrl->IsKindOf(CLASSINFO(wxPGClipperWindow)) ) - { - return ((wxPGClipperWindow*)ctrl)->GetControl(); - } -#endif - return ctrl; } @@ -1823,29 +1607,6 @@ void wxPropertyGrid::CorrectEditorWidgetPosY() // ----------------------------------------------------------------------- -bool wxPropertyGrid::AdjustPosForClipperWindow( wxWindow* topCtrlWnd, int* x, int* y ) -{ -#if wxPG_ENABLE_CLIPPER_WINDOW - // Take clipper window into account - if (topCtrlWnd->GetPosition().x < 1 && - !topCtrlWnd->IsKindOf(CLASSINFO(wxPGClipperWindow))) - { - topCtrlWnd = topCtrlWnd->GetParent(); - wxASSERT( topCtrlWnd->IsKindOf(CLASSINFO(wxPGClipperWindow)) ); - *x -= ((wxPGClipperWindow*)topCtrlWnd)->GetXClip(); - *y -= ((wxPGClipperWindow*)topCtrlWnd)->GetYClip(); - return true; - } -#else - wxUnusedVar(topCtrlWnd); - wxUnusedVar(x); - wxUnusedVar(y); -#endif - return false; -} - -// ----------------------------------------------------------------------- - // Fixes position of wxTextCtrl-like control (wxSpinCtrl usually // fits into that category as well). void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl, const wxPoint& offset ) @@ -1911,46 +1672,20 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos, if ( (sz.y - m_lineHeight) > 5 ) hasSpecialSize = true; -#if wxPG_NAT_TEXTCTRL_BORDER_ANY - - // Create clipper window - wxPGClipperWindow* wnd = new wxPGClipperWindow(); -#if defined(__WXMSW__) - wnd->Hide(); -#endif - wnd->Create(GetPanel(),id,p,s); - - // This generates rect of the control inside the clipper window - if ( !hasSpecialSize ) - wnd->GetControlRect(wxPG_NAT_TEXTCTRL_BORDER_X, wxPG_NAT_TEXTCTRL_BORDER_Y, p, s); - else - wnd->GetControlRect(0, 0, p, s); - - wxWindow* ctrlParent = wnd; - -#else - wxWindow* ctrlParent = GetPanel(); if ( !hasSpecialSize ) - tcFlags |= wxNO_BORDER; - -#endif + tcFlags |= wxBORDER_NONE; wxTextCtrl* tc = new wxTextCtrl(); -#if defined(__WXMSW__) && !wxPG_NAT_TEXTCTRL_BORDER_ANY +#if defined(__WXMSW__) tc->Hide(); #endif SetupTextCtrlValue(value); tc->Create(ctrlParent,id,value, p, s,tcFlags); -#if wxPG_NAT_TEXTCTRL_BORDER_ANY - wxWindow* ed = wnd; - wnd->SetControl(tc); -#else wxWindow* ed = tc; -#endif // Center the control vertically if ( !hasSpecialSize ) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 80d323e5e5..c1e994f7da 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -4789,8 +4789,6 @@ bool wxPropertyGrid::OnMouseChildCommon( wxMouseEvent &event, int* px, int *py ) int x, y; event.GetPosition(&x,&y); - AdjustPosForClipperWindow( topCtrlWnd, &x, &y ); - int splitterX = GetSplitterPosition(); wxRect r = topCtrlWnd->GetRect(); -- 2.45.2