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

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