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:
@@ -30,6 +30,8 @@
|
|||||||
// Here are some platform dependent defines
|
// Here are some platform dependent defines
|
||||||
// NOTE: More in propertygrid.cpp
|
// 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__)
|
#if defined(__WXMSW__)
|
||||||
|
|
||||||
@@ -38,6 +40,9 @@
|
|||||||
// space between vertical line and value editor control
|
// space between vertical line and value editor control
|
||||||
#define wxPG_XBEFOREWIDGET 1
|
#define wxPG_XBEFOREWIDGET 1
|
||||||
|
|
||||||
|
// left margin can be set with wxTextEntry::SetMargins()
|
||||||
|
#undef wxPG_TEXTCTRLXADJUST
|
||||||
|
|
||||||
// comment to use bitmap buttons
|
// comment to use bitmap buttons
|
||||||
#define wxPG_ICON_WIDTH 9
|
#define wxPG_ICON_WIDTH 9
|
||||||
// 1 if wxRendererNative should be employed
|
// 1 if wxRendererNative should be employed
|
||||||
@@ -67,9 +72,8 @@
|
|||||||
#define wxPG_XBEFOREWIDGET 1
|
#define wxPG_XBEFOREWIDGET 1
|
||||||
|
|
||||||
// x position adjustment for wxTextCtrl (and like)
|
// x position adjustment for wxTextCtrl (and like)
|
||||||
// NB: Only define wxPG_TEXTCTRLXADJUST for platforms that do not
|
// left margin can be set with wxTextEntry::SetMargins()
|
||||||
// (yet) support wxTextEntry::SetMargins() for the left margin.
|
#undef wxPG_TEXTCTRLXADJUST
|
||||||
//#define wxPG_TEXTCTRLXADJUST 3
|
|
||||||
|
|
||||||
// comment to use bitmap buttons
|
// comment to use bitmap buttons
|
||||||
#define wxPG_ICON_WIDTH 9
|
#define wxPG_ICON_WIDTH 9
|
||||||
@@ -100,6 +104,7 @@
|
|||||||
#define wxPG_XBEFOREWIDGET 1
|
#define wxPG_XBEFOREWIDGET 1
|
||||||
|
|
||||||
// x position adjustment for wxTextCtrl (and like)
|
// x position adjustment for wxTextCtrl (and like)
|
||||||
|
// left margin cannot be set with wxTextEntry::SetMargins()
|
||||||
#define wxPG_TEXTCTRLXADJUST 0
|
#define wxPG_TEXTCTRLXADJUST 0
|
||||||
|
|
||||||
// comment to use bitmap buttons
|
// comment to use bitmap buttons
|
||||||
@@ -131,6 +136,7 @@
|
|||||||
#define wxPG_XBEFOREWIDGET 1
|
#define wxPG_XBEFOREWIDGET 1
|
||||||
|
|
||||||
// x position adjustment for wxTextCtrl (and like)
|
// x position adjustment for wxTextCtrl (and like)
|
||||||
|
// left margin cannot be set with wxTextEntry::SetMargins()
|
||||||
#define wxPG_TEXTCTRLXADJUST 3
|
#define wxPG_TEXTCTRLXADJUST 3
|
||||||
|
|
||||||
// comment to use bitmap buttons
|
// comment to use bitmap buttons
|
||||||
|
@@ -1856,6 +1856,20 @@ void wxPropertyGrid::CorrectEditorWidgetPosY()
|
|||||||
|
|
||||||
// Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
|
// Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
|
||||||
// fits into that category as well).
|
// 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,
|
void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl,
|
||||||
unsigned int WXUNUSED(forColumn),
|
unsigned int WXUNUSED(forColumn),
|
||||||
const wxPoint& offset )
|
const wxPoint& offset )
|
||||||
@@ -1872,7 +1886,7 @@ void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl,
|
|||||||
finalPos.height -= (y_adj+sz_dec);
|
finalPos.height -= (y_adj+sz_dec);
|
||||||
|
|
||||||
#ifndef wxPG_TEXTCTRLXADJUST
|
#ifndef wxPG_TEXTCTRLXADJUST
|
||||||
int textCtrlXAdjust = wxPG_XBEFORETEXT - 1;
|
int textCtrlXAdjust = wxPG_XBEFORETEXT - 1 + wxPG_TEXTCTRLXADJUST2;
|
||||||
|
|
||||||
wxTextCtrl* tc = static_cast<wxTextCtrl*>(ctrl);
|
wxTextCtrl* tc = static_cast<wxTextCtrl*>(ctrl);
|
||||||
tc->SetMargins(0);
|
tc->SetMargins(0);
|
||||||
|
Reference in New Issue
Block a user