From 3212f7eab9f5f4b36ab9907d01b33b61ce6f9683 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 16 Jul 2017 19:03:13 +0200 Subject: [PATCH] Fix positioning of TextCtrlEditor in wxPG (wxGTK) Position of the editor associated with properties like StringProperty, IntProperty, etc. needs to be adjusted in order to display edited text string at the same position as the text which is displayed as a property value prior to the editing. --- include/wx/propgrid/propgriddefs.h | 12 +++++++++--- src/propgrid/editors.cpp | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/wx/propgrid/propgriddefs.h b/include/wx/propgrid/propgriddefs.h index 7ccf8e7d9d..1d8ad0a88e 100644 --- a/include/wx/propgrid/propgriddefs.h +++ b/include/wx/propgrid/propgriddefs.h @@ -30,6 +30,8 @@ // Here are some platform dependent defines // NOTE: More in propertygrid.cpp // +// NB: Only define wxPG_TEXTCTRLXADJUST for platforms that do not +// (yet) support wxTextEntry::SetMargins() for the left margin. #if defined(__WXMSW__) @@ -38,6 +40,9 @@ // space between vertical line and value editor control #define wxPG_XBEFOREWIDGET 1 + // left margin can be set with wxTextEntry::SetMargins() + #undef wxPG_TEXTCTRLXADJUST + // comment to use bitmap buttons #define wxPG_ICON_WIDTH 9 // 1 if wxRendererNative should be employed @@ -67,9 +72,8 @@ #define wxPG_XBEFOREWIDGET 1 // x position adjustment for wxTextCtrl (and like) - // NB: Only define wxPG_TEXTCTRLXADJUST for platforms that do not - // (yet) support wxTextEntry::SetMargins() for the left margin. - //#define wxPG_TEXTCTRLXADJUST 3 + // left margin can be set with wxTextEntry::SetMargins() + #undef wxPG_TEXTCTRLXADJUST // comment to use bitmap buttons #define wxPG_ICON_WIDTH 9 @@ -100,6 +104,7 @@ #define wxPG_XBEFOREWIDGET 1 // x position adjustment for wxTextCtrl (and like) + // left margin cannot be set with wxTextEntry::SetMargins() #define wxPG_TEXTCTRLXADJUST 0 // comment to use bitmap buttons @@ -131,6 +136,7 @@ #define wxPG_XBEFOREWIDGET 1 // x position adjustment for wxTextCtrl (and like) + // left margin cannot be set with wxTextEntry::SetMargins() #define wxPG_TEXTCTRLXADJUST 3 // comment to use bitmap buttons diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index ccd7137883..27cac190ae 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1856,6 +1856,20 @@ void wxPropertyGrid::CorrectEditorWidgetPosY() // Fixes position of wxTextCtrl-like control (wxSpinCtrl usually // fits into that category as well). +#ifndef wxPG_TEXTCTRLXADJUST +#if defined(__WXMSW__) +#define wxPG_TEXTCTRLXADJUST2 0 +#elif defined(__WXGTK__) + #if defined(__WXGTK3__) + #define wxPG_TEXTCTRLXADJUST2 (-2) + #else + #define wxPG_TEXTCTRLXADJUST2 0 + #endif // wxGTK3/!wxGTK3 +#else +#error "wxPG_TEXTCTRLXADJUST should be defined for this platform" +#endif +#endif // !wxPG_TEXTCTRLXADJUST + void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl, unsigned int WXUNUSED(forColumn), const wxPoint& offset ) @@ -1872,7 +1886,7 @@ void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl, finalPos.height -= (y_adj+sz_dec); #ifndef wxPG_TEXTCTRLXADJUST - int textCtrlXAdjust = wxPG_XBEFORETEXT - 1; + int textCtrlXAdjust = wxPG_XBEFORETEXT - 1 + wxPG_TEXTCTRLXADJUST2; wxTextCtrl* tc = static_cast(ctrl); tc->SetMargins(0);