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.
This commit is contained in:
Artur Wieczorek
2017-07-16 19:03:13 +02:00
parent afdb7eca87
commit 3212f7eab9
2 changed files with 24 additions and 4 deletions

View File

@@ -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

View File

@@ -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<wxTextCtrl*>(ctrl);
tc->SetMargins(0);