wxTextEntry::SetMargins(), GetMargins() - implemented on wxMSW and wxGTK (GTK+ 2.10+); also added similar functions into wxComboCtrl, deprecated old indent-functions; wxPropertyGrid modified to use the new functionality
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61834 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -86,8 +86,8 @@ enum
|
||||
wxCC_IFLAG_CREATED = 0x0100,
|
||||
// Internal use: really put button outside
|
||||
wxCC_IFLAG_BUTTON_OUTSIDE = 0x0200,
|
||||
// Internal use: SetTextIndent has been called
|
||||
wxCC_IFLAG_INDENT_SET = 0x0400,
|
||||
// Internal use: SetMargins has been succesfully called
|
||||
wxCC_IFLAG_LEFT_MARGIN_SET = 0x0400,
|
||||
// Internal use: Set wxTAB_TRAVERSAL to parent when popup is dismissed
|
||||
wxCC_IFLAG_PARENT_TAB_TRAVERSAL = 0x0800,
|
||||
// Internal use: Secondary popup window type should be used (if available).
|
||||
@@ -118,7 +118,8 @@ struct wxComboCtrlFeatures
|
||||
BitmapButton = 0x0002, // Button may be replaced with bitmap
|
||||
ButtonSpacing = 0x0004, // Button can have spacing from the edge
|
||||
// of the control
|
||||
TextIndent = 0x0008, // SetTextIndent can be used
|
||||
TextIndent = 0x0008, // SetMargins can be used to control
|
||||
// left margin.
|
||||
PaintControl = 0x0010, // Combo control itself can be custom painted
|
||||
PaintWritable = 0x0020, // A variable-width area in front of writable
|
||||
// combo control's textctrl can be custom
|
||||
@@ -302,19 +303,18 @@ public:
|
||||
const wxBitmap& bmpHover = wxNullBitmap,
|
||||
const wxBitmap& bmpDisabled = wxNullBitmap );
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_6
|
||||
//
|
||||
// This will set the space in pixels between left edge of the control and the
|
||||
// text, regardless whether control is read-only (ie. no wxTextCtrl) or not.
|
||||
// Platform-specific default can be set with value-1.
|
||||
// Remarks
|
||||
// * This method may do nothing on some native implementations.
|
||||
void SetTextIndent( int indent );
|
||||
wxDEPRECTED( void SetTextIndent( int indent ) );
|
||||
|
||||
// Returns actual indentation in pixels.
|
||||
wxCoord GetTextIndent() const
|
||||
{
|
||||
return m_absIndent;
|
||||
}
|
||||
wxDEPRECTED( wxCoord GetTextIndent() const );
|
||||
#endif
|
||||
|
||||
// Returns area covered by the text field.
|
||||
const wxRect& GetTextRect() const
|
||||
@@ -385,6 +385,17 @@ public:
|
||||
const wxBitmap& GetBitmapHover() const { return m_bmpHover; }
|
||||
const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; }
|
||||
|
||||
// Margins functions mirrored from TextEntryBase
|
||||
// (wxComboCtrl does not inherit from wxTextEntry, but may embed a
|
||||
// wxTextCtrl, so we need these). Also note that these functions
|
||||
// have replaced SetTextIndent() in wxWidgets 2.9.1 and later.
|
||||
bool SetMargins(const wxPoint& pt)
|
||||
{ return DoSetMargins(pt); }
|
||||
bool SetMargins(wxCoord left, wxCoord top = -1)
|
||||
{ return DoSetMargins(wxPoint(left, top)); }
|
||||
wxPoint GetMargins() const
|
||||
{ return DoGetMargins(); }
|
||||
|
||||
// Return internal flags
|
||||
wxUint32 GetInternalFlags() const { return m_iFlags; }
|
||||
|
||||
@@ -423,7 +434,8 @@ protected:
|
||||
// called from wxSizeEvent handler
|
||||
virtual void OnResize() = 0;
|
||||
|
||||
// Return native text identation (for pure text, not textctrl)
|
||||
// Return native text identation
|
||||
// (i.e. text margin, for pure text, not textctrl)
|
||||
virtual wxCoord GetNativeTextIndent() const;
|
||||
|
||||
// Called in syscolourchanged handler and base create
|
||||
@@ -521,6 +533,10 @@ protected:
|
||||
virtual void DoSetToolTip( wxToolTip *tip );
|
||||
#endif
|
||||
|
||||
// margins functions
|
||||
virtual bool DoSetMargins(const wxPoint& pt);
|
||||
virtual wxPoint DoGetMargins() const;
|
||||
|
||||
// This is used when m_text is hidden (readonly).
|
||||
wxString m_valueString;
|
||||
|
||||
@@ -572,8 +588,8 @@ protected:
|
||||
// selection indicator.
|
||||
wxCoord m_widthCustomPaint;
|
||||
|
||||
// absolute text indentation, in pixels
|
||||
wxCoord m_absIndent;
|
||||
// left margin, in pixels
|
||||
wxCoord m_marginLeft;
|
||||
|
||||
// side on which the popup is aligned
|
||||
int m_anchorSide;
|
||||
|
@@ -135,8 +135,8 @@ protected:
|
||||
// custom list stores.
|
||||
virtual void GTKCreateComboBoxWidget();
|
||||
|
||||
// return the GtkEntry part of the combobox
|
||||
GtkEntry *GetEntry() const { return m_entry; }
|
||||
virtual GtkEntry *GetEntry() const
|
||||
{ return m_entry; }
|
||||
|
||||
GtkEntry* m_entry;
|
||||
|
||||
|
@@ -178,6 +178,7 @@ protected:
|
||||
private:
|
||||
// overridden wxTextEntry virtual methods
|
||||
virtual GtkEditable *GetEditable() const;
|
||||
virtual GtkEntry *GetEntry() const;
|
||||
virtual void EnableTextChangedEvents(bool enable);
|
||||
|
||||
// change the font for everything in this control
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#define _WX_GTK_TEXTENTRY_H_
|
||||
|
||||
typedef struct _GtkEditable GtkEditable;
|
||||
typedef struct _GtkEntry GtkEntry;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextEntry: roughly corresponds to GtkEditable
|
||||
@@ -55,10 +56,17 @@ public:
|
||||
protected:
|
||||
virtual wxString DoGetValue() const;
|
||||
|
||||
// margins functions
|
||||
virtual bool DoSetMargins(const wxPoint& pt);
|
||||
virtual wxPoint DoGetMargins() const;
|
||||
|
||||
private:
|
||||
// implement this to return the associated GtkEntry or another widget
|
||||
// implementing GtkEditable
|
||||
virtual GtkEditable *GetEditable() const = 0;
|
||||
|
||||
// implement this to return the associated GtkEntry
|
||||
virtual GtkEntry *GetEntry() const = 0;
|
||||
};
|
||||
|
||||
#endif // _WX_GTK_TEXTENTRY_H_
|
||||
|
@@ -76,6 +76,10 @@ protected:
|
||||
};
|
||||
virtual void DoSetSelection(long from, long to, int flags = SetSel_Scroll);
|
||||
|
||||
// margins functions
|
||||
virtual bool DoSetMargins(const wxPoint& pt);
|
||||
virtual wxPoint DoGetMargins() const;
|
||||
|
||||
private:
|
||||
// implement this to return the HWND of the EDIT control
|
||||
virtual WXHWND GetEditHWND() const = 0;
|
||||
|
@@ -37,9 +37,6 @@
|
||||
// space between vertical line and value editor control
|
||||
#define wxPG_XBEFOREWIDGET 1
|
||||
|
||||
// x position adjustment for wxTextCtrl (and like)
|
||||
#define wxPG_TEXTCTRLXADJUST 3
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 9
|
||||
// 1 if wxRendererNative should be employed
|
||||
@@ -75,7 +72,9 @@
|
||||
#define wxPG_XBEFOREWIDGET 1
|
||||
|
||||
// x position adjustment for wxTextCtrl (and like)
|
||||
#define wxPG_TEXTCTRLXADJUST 3
|
||||
// NB: Only define wxPG_TEXTCTRLXADJUST for platforms that do not
|
||||
// (yet) support wxTextEntry::SetMargins() for the left margin.
|
||||
//#define wxPG_TEXTCTRLXADJUST 3
|
||||
|
||||
// comment to use bitmap buttons
|
||||
#define wxPG_ICON_WIDTH 9
|
||||
|
@@ -783,6 +783,7 @@ protected:
|
||||
#ifdef __WXGTK20__
|
||||
virtual wxWindow *GetEditableWindow() { return this; }
|
||||
virtual GtkEditable *GetEditable() const { return NULL; }
|
||||
virtual GtkEntry *GetEntry() const { return NULL; }
|
||||
#endif
|
||||
|
||||
// Overrides
|
||||
|
@@ -142,6 +142,20 @@ public:
|
||||
virtual wxString GetHint() const;
|
||||
|
||||
|
||||
// margins
|
||||
// -------
|
||||
|
||||
// margins are the empty space between borders of control and the text
|
||||
// itself. When setting margin, use value -1 to indicate that specific
|
||||
// margin should not be changed.
|
||||
|
||||
bool SetMargins(const wxPoint& pt)
|
||||
{ return DoSetMargins(pt); }
|
||||
bool SetMargins(wxCoord left, wxCoord top = -1)
|
||||
{ return DoSetMargins(wxPoint(left, top)); }
|
||||
wxPoint GetMargins() const
|
||||
{ return DoGetMargins(); }
|
||||
|
||||
protected:
|
||||
// flags for DoSetValue(): common part of SetValue() and ChangeValue() and
|
||||
// also used to implement WriteText() in wxMSW
|
||||
@@ -159,6 +173,10 @@ protected:
|
||||
// generation and also by generic hints implementation
|
||||
virtual wxWindow *GetEditableWindow() = 0;
|
||||
|
||||
// margins functions
|
||||
virtual bool DoSetMargins(const wxPoint& pt);
|
||||
virtual wxPoint DoGetMargins() const;
|
||||
|
||||
|
||||
// class which should be used to temporarily disable text change events
|
||||
//
|
||||
|
@@ -159,7 +159,7 @@ struct wxComboCtrlFeatures
|
||||
BitmapButton = 0x0002, ///< Button may be replaced with bitmap.
|
||||
ButtonSpacing = 0x0004, ///< Button can have spacing from the edge
|
||||
///< of the control.
|
||||
TextIndent = 0x0008, ///< wxComboCtrl::SetTextIndent() can be used.
|
||||
TextIndent = 0x0008, ///< wxComboCtrl::SetMargins() can be used.
|
||||
PaintControl = 0x0010, ///< Combo control itself can be custom painted.
|
||||
PaintWritable = 0x0020, ///< A variable-width area in front of writable
|
||||
///< combo control's textctrl can be custom
|
||||
@@ -454,6 +454,19 @@ public:
|
||||
*/
|
||||
virtual long GetLastPosition() const;
|
||||
|
||||
/**
|
||||
Returns the margins used by the control. The @c x field of the returned
|
||||
point is the horizontal margin and the @c y field is the vertical one.
|
||||
|
||||
@remarks If given margin cannot be accurately determined, its value
|
||||
will be set to -1.
|
||||
|
||||
@see SetMargins()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxPoint GetMargins() const;
|
||||
|
||||
/**
|
||||
Returns current popup interface that has been set with
|
||||
SetPopupControl().
|
||||
@@ -472,6 +485,8 @@ public:
|
||||
|
||||
/**
|
||||
Returns actual indentation in pixels.
|
||||
|
||||
@deprecated Use GetMargins() instead.
|
||||
*/
|
||||
wxCoord GetTextIndent() const;
|
||||
|
||||
@@ -607,6 +622,21 @@ public:
|
||||
*/
|
||||
virtual void SetInsertionPointEnd();
|
||||
|
||||
//@{
|
||||
/**
|
||||
Attempts to set the control margins. When margins are given as wxPoint,
|
||||
x indicates the left and y the top margin. Use -1 to indicate that
|
||||
an existing value should be used.
|
||||
|
||||
@return
|
||||
@true if setting of all requested margins was successful.
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
bool SetMargins(const wxPoint& pt);
|
||||
bool SetMargins(wxCoord left, wxCoord top = -1);
|
||||
//@}
|
||||
|
||||
/**
|
||||
Set side of the control to which the popup will align itself. Valid
|
||||
values are @c wxLEFT, @c wxRIGHT and 0. The default value 0 means that
|
||||
@@ -676,6 +706,8 @@ public:
|
||||
This will set the space in pixels between left edge of the control and
|
||||
the text, regardless whether control is read-only or not. Value -1 can
|
||||
be given to indicate platform default.
|
||||
|
||||
@deprecated Use SetMargins() instead.
|
||||
*/
|
||||
void SetTextIndent(int indent);
|
||||
|
||||
|
@@ -381,6 +381,35 @@ public:
|
||||
*/
|
||||
virtual wxString GetHint() const;
|
||||
|
||||
//@{
|
||||
/**
|
||||
Attempts to set the control margins. When margins are given as wxPoint,
|
||||
x indicates the left and y the top margin. Use -1 to indicate that
|
||||
an existing value should be used.
|
||||
|
||||
@return
|
||||
@true if setting of all requested margins was successful.
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
bool SetMargins(const wxPoint& pt);
|
||||
bool SetMargins(wxCoord left, wxCoord top = -1);
|
||||
//@}
|
||||
|
||||
/**
|
||||
Returns the margins used by the control. The @c x field of the returned
|
||||
point is the horizontal margin and the @c y field is the vertical one.
|
||||
|
||||
@remarks If given margin cannot be accurately determined, its value
|
||||
will be set to -1. On some platforms you cannot obtain valid
|
||||
margin values until you have called SetMargins().
|
||||
|
||||
@see SetMargins()
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
wxPoint GetMargins() const;
|
||||
|
||||
/**
|
||||
Sets the new text control value.
|
||||
|
||||
|
@@ -66,11 +66,20 @@
|
||||
#define TEXTCTRL_TEXT_CENTERED 0 // 1 if text in textctrl is vertically centered
|
||||
#define FOCUS_RING 0 // No focus ring on wxMSW
|
||||
|
||||
#if !defined(__WXWINCE__)
|
||||
// 1 if wxTextEntry::SetMargins() can be used to set the left margin
|
||||
#define LEFT_MARGIN_CAN_BE_SET 1
|
||||
#else
|
||||
#define LEFT_MARGIN_CAN_BE_SET 0
|
||||
#endif
|
||||
|
||||
//#undef wxUSE_POPUPWIN
|
||||
//#define wxUSE_POPUPWIN 0
|
||||
|
||||
#elif defined(__WXGTK__)
|
||||
|
||||
#include "wx/gtk/private.h"
|
||||
|
||||
// NB: It is not recommended to use wxDialog as popup on wxGTK, because of
|
||||
// this bug: If wxDialog is hidden, its position becomes corrupt
|
||||
// between hide and next show, but without internal coordinates being
|
||||
@@ -88,6 +97,13 @@
|
||||
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
|
||||
#define FOCUS_RING 0 // No focus ring on wxGTK
|
||||
|
||||
#if GTK_CHECK_VERSION(2,10,0)
|
||||
// 1 if wxTextEntry::SetMargins() can be used to set the left margin
|
||||
#define LEFT_MARGIN_CAN_BE_SET 1
|
||||
#else
|
||||
#define LEFT_MARGIN_CAN_BE_SET 0
|
||||
#endif
|
||||
|
||||
#elif defined(__WXMAC__)
|
||||
|
||||
#define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
|
||||
@@ -102,6 +118,9 @@
|
||||
#undef COMBO_MARGIN
|
||||
#define COMBO_MARGIN FOCUS_RING
|
||||
|
||||
// 1 if wxTextEntry::SetMargins() can be used to set the left margin
|
||||
#define LEFT_MARGIN_CAN_BE_SET 0
|
||||
|
||||
#else
|
||||
|
||||
#define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
|
||||
@@ -111,6 +130,9 @@
|
||||
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
|
||||
#define FOCUS_RING 0
|
||||
|
||||
// 1 if wxTextEntry::SetMargins() can be used to set the left margin
|
||||
#define LEFT_MARGIN_CAN_BE_SET 0
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -519,7 +541,7 @@ void wxComboPopup::DefaultPaintComboControl( wxComboCtrlBase* combo,
|
||||
combo->PrepareBackground(dc,rect,0);
|
||||
|
||||
dc.DrawText( combo->GetValue(),
|
||||
rect.x + combo->GetTextIndent(),
|
||||
rect.x + combo->m_marginLeft,
|
||||
(rect.height-dc.GetCharHeight())/2 + rect.y );
|
||||
}
|
||||
}
|
||||
@@ -804,7 +826,7 @@ void wxComboCtrlBase::Init()
|
||||
|
||||
m_extLeft = 0;
|
||||
m_extRight = 0;
|
||||
m_absIndent = -1;
|
||||
m_marginLeft = -1;
|
||||
m_iFlags = 0;
|
||||
m_timeCanAcceptClick = 0;
|
||||
|
||||
@@ -833,7 +855,7 @@ bool wxComboCtrlBase::Create(wxWindow *parent,
|
||||
|
||||
// Get colours
|
||||
OnThemeChange();
|
||||
m_absIndent = GetNativeTextIndent();
|
||||
m_marginLeft = GetNativeTextIndent();
|
||||
|
||||
m_iFlags |= wxCC_IFLAG_CREATED;
|
||||
|
||||
@@ -953,8 +975,8 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth )
|
||||
}
|
||||
|
||||
// Defaul indentation
|
||||
if ( m_absIndent < 0 )
|
||||
m_absIndent = GetNativeTextIndent();
|
||||
if ( m_marginLeft < 0 )
|
||||
m_marginLeft = GetNativeTextIndent();
|
||||
|
||||
int butWidth = btnWidth;
|
||||
|
||||
@@ -1058,43 +1080,54 @@ void wxComboCtrlBase::PositionTextCtrl( int textCtrlXAdjust, int textCtrlYAdjust
|
||||
if ( !m_text )
|
||||
return;
|
||||
|
||||
#if !TEXTCTRL_TEXT_CENTERED
|
||||
|
||||
wxSize sz = GetClientSize();
|
||||
|
||||
int customBorder = m_widthCustomBorder;
|
||||
if ( (m_text->GetWindowStyleFlag() & wxBORDER_MASK) == wxNO_BORDER )
|
||||
{
|
||||
#if LEFT_MARGIN_CAN_BE_SET
|
||||
// Call SetMargins() on textctrl if LEFT_MARGIN_CAN_BE_SET == 1
|
||||
wxUnusedVar(textCtrlXAdjust);
|
||||
m_text->SetMargins(0);
|
||||
textCtrlXAdjust = 0;
|
||||
#endif
|
||||
|
||||
// Centre textctrl
|
||||
#if !TEXTCTRL_TEXT_CENTERED
|
||||
int tcSizeY = m_text->GetBestSize().y;
|
||||
int diff = sz.y - tcSizeY;
|
||||
int y = textCtrlYAdjust + (diff/2);
|
||||
int diff0 = sz.y - tcSizeY;
|
||||
int y = textCtrlYAdjust + (diff0/2);
|
||||
#else
|
||||
wxUnusedVar(textCtrlYAdjust);
|
||||
int y = 0;
|
||||
#endif
|
||||
|
||||
if ( y < customBorder )
|
||||
y = customBorder;
|
||||
|
||||
m_text->SetSize( m_tcArea.x + m_widthCustomPaint + m_absIndent + textCtrlXAdjust,
|
||||
int x = m_tcArea.x + m_widthCustomPaint +
|
||||
m_marginLeft + textCtrlXAdjust;
|
||||
|
||||
m_text->SetSize(x,
|
||||
y,
|
||||
m_tcArea.width - COMBO_MARGIN -
|
||||
(textCtrlXAdjust + m_widthCustomPaint + m_absIndent),
|
||||
m_tcArea.width - m_tcArea.x - x,
|
||||
/*m_tcArea.width - COMBO_MARGIN -
|
||||
(textCtrlXAdjust + m_widthCustomPaint +
|
||||
m_marginLeft),*/
|
||||
-1 );
|
||||
|
||||
// Make sure textctrl doesn't exceed the bottom custom border
|
||||
wxSize tsz = m_text->GetSize();
|
||||
diff = (y + tsz.y) - (sz.y - customBorder);
|
||||
if ( diff >= 0 )
|
||||
int diff1 = (y + tsz.y) - (sz.y - customBorder);
|
||||
if ( diff1 >= 0 )
|
||||
{
|
||||
tsz.y = tsz.y - diff - 1;
|
||||
tsz.y = tsz.y - diff1 - 1;
|
||||
m_text->SetSize(tsz);
|
||||
}
|
||||
}
|
||||
else
|
||||
#else // TEXTCTRL_TEXT_CENTERED
|
||||
wxUnusedVar(textCtrlXAdjust);
|
||||
wxUnusedVar(textCtrlYAdjust);
|
||||
#endif // !TEXTCTRL_TEXT_CENTERED/TEXTCTRL_TEXT_CENTERED
|
||||
{
|
||||
// If it has border, have textctrl will the entire text field.
|
||||
// If it has border, have textctrl fill the entire text field.
|
||||
m_text->SetSize( m_tcArea.x + m_widthCustomPaint,
|
||||
m_tcArea.y,
|
||||
m_tcArea.width - m_widthCustomPaint,
|
||||
@@ -1729,9 +1762,9 @@ void wxComboCtrlBase::OnIdleEvent( wxIdleEvent& WXUNUSED(event) )
|
||||
void wxComboCtrlBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
|
||||
{
|
||||
OnThemeChange();
|
||||
// indentation may also have changed
|
||||
if ( !(m_iFlags & wxCC_IFLAG_INDENT_SET) )
|
||||
m_absIndent = GetNativeTextIndent();
|
||||
// left margin may also have changed
|
||||
if ( !(m_iFlags & wxCC_IFLAG_LEFT_MARGIN_SET) )
|
||||
m_marginLeft = GetNativeTextIndent();
|
||||
RecalcAndRefresh();
|
||||
}
|
||||
|
||||
@@ -2217,22 +2250,61 @@ void wxComboCtrlBase::SetCustomPaintWidth( int width )
|
||||
RecalcAndRefresh();
|
||||
}
|
||||
|
||||
bool wxComboCtrlBase::DoSetMargins(const wxPoint& margins)
|
||||
{
|
||||
// For general sanity's sake, we ignore top margin. Instead
|
||||
// we will always try to center the text vertically.
|
||||
bool res = true;
|
||||
|
||||
if ( margins.x != -1 )
|
||||
{
|
||||
m_marginLeft = margins.x;
|
||||
m_iFlags |= wxCC_IFLAG_LEFT_MARGIN_SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_marginLeft = GetNativeTextIndent();
|
||||
m_iFlags &= ~(wxCC_IFLAG_LEFT_MARGIN_SET);
|
||||
}
|
||||
|
||||
if ( margins.y != -1 )
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
|
||||
RecalcAndRefresh();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
wxPoint wxComboCtrlBase::DoGetMargins() const
|
||||
{
|
||||
return wxPoint(m_marginLeft, -1);
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_6
|
||||
void wxComboCtrlBase::SetTextIndent( int indent )
|
||||
{
|
||||
if ( indent < 0 )
|
||||
{
|
||||
m_absIndent = GetNativeTextIndent();
|
||||
m_iFlags &= ~(wxCC_IFLAG_INDENT_SET);
|
||||
m_marginLeft = GetNativeTextIndent();
|
||||
m_iFlags &= ~(wxCC_IFLAG_LEFT_MARGIN_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_absIndent = indent;
|
||||
m_iFlags |= wxCC_IFLAG_INDENT_SET;
|
||||
m_marginLeft = indent;
|
||||
m_iFlags |= wxCC_IFLAG_LEFT_MARGIN_SET;
|
||||
}
|
||||
|
||||
RecalcAndRefresh();
|
||||
}
|
||||
|
||||
wxCoord wxComboCtrlBase::GetTextIndent() const;
|
||||
{
|
||||
return m_marginLeft;
|
||||
}
|
||||
#endif
|
||||
|
||||
wxCoord wxComboCtrlBase::GetNativeTextIndent() const
|
||||
{
|
||||
return DEFAULT_TEXT_INDENT;
|
||||
|
@@ -265,4 +265,18 @@ wxString wxTextEntryBase::GetHint() const
|
||||
return m_hintData ? m_hintData->GetHintString() : wxString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// margins support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTextEntryBase::DoSetMargins(const wxPoint& WXUNUSED(pt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
wxPoint wxTextEntryBase::DoGetMargins() const
|
||||
{
|
||||
return wxPoint(-1, -1);
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX
|
||||
|
@@ -42,35 +42,50 @@
|
||||
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
|
||||
#define TEXTCTRLXADJUST 0 // position adjustment for wxTextCtrl, with zero indent
|
||||
// position adjustment for wxTextCtrl, to achieve zero left margin
|
||||
// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp
|
||||
#define TEXTCTRLXADJUST 0
|
||||
|
||||
#define TEXTCTRLYADJUST 0
|
||||
#define TEXTXADJUST 0 // how much is read-only text's x adjusted
|
||||
#define DEFAULT_DROPBUTTON_WIDTH 19
|
||||
|
||||
#elif defined(__WXMSW__)
|
||||
|
||||
#define TEXTCTRLXADJUST 2 // position adjustment for wxTextCtrl, with zero indent
|
||||
// position adjustment for wxTextCtrl, to achieve zero left margin
|
||||
// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp
|
||||
#define TEXTCTRLXADJUST 2
|
||||
|
||||
#define TEXTCTRLYADJUST 3
|
||||
#define TEXTXADJUST 0 // how much is read-only text's x adjusted
|
||||
#define DEFAULT_DROPBUTTON_WIDTH 17
|
||||
|
||||
#elif defined(__WXGTK__)
|
||||
|
||||
#define TEXTCTRLXADJUST -1 // position adjustment for wxTextCtrl, with zero indent
|
||||
// position adjustment for wxTextCtrl, to achieve zero left margin
|
||||
// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp
|
||||
#define TEXTCTRLXADJUST -1
|
||||
|
||||
#define TEXTCTRLYADJUST 0
|
||||
#define TEXTXADJUST 1 // how much is read-only text's x adjusted
|
||||
#define DEFAULT_DROPBUTTON_WIDTH 23
|
||||
|
||||
#elif defined(__WXMAC__)
|
||||
|
||||
#define TEXTCTRLXADJUST 0 // position adjustment for wxTextCtrl, with zero indent
|
||||
// position adjustment for wxTextCtrl, to achieve zero left margin
|
||||
// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp
|
||||
#define TEXTCTRLXADJUST 0
|
||||
|
||||
#define TEXTCTRLYADJUST 0
|
||||
#define TEXTXADJUST 0 // how much is read-only text's x adjusted
|
||||
#define DEFAULT_DROPBUTTON_WIDTH 22
|
||||
|
||||
#else
|
||||
|
||||
#define TEXTCTRLXADJUST 0 // position adjustment for wxTextCtrl, with zero indent
|
||||
// position adjustment for wxTextCtrl, to achieve zero left margin
|
||||
// meaningless if LEFT_MARGIN_CAN_BE_SET set to 1 in combocmn.cpp
|
||||
#define TEXTCTRLXADJUST 0
|
||||
|
||||
#define TEXTCTRLYADJUST 0
|
||||
#define TEXTXADJUST 0 // how much is read-only text's x adjusted
|
||||
#define DEFAULT_DROPBUTTON_WIDTH 19
|
||||
|
@@ -1085,7 +1085,7 @@ void wxOwnerDrawnComboBox::OnDrawItem( wxDC& dc,
|
||||
if ( flags & wxODCB_PAINTING_CONTROL )
|
||||
{
|
||||
dc.DrawText( GetValue(),
|
||||
rect.x + GetTextIndent(),
|
||||
rect.x + GetMargins().x,
|
||||
(rect.height-dc.GetCharHeight())/2 + rect.y );
|
||||
}
|
||||
else
|
||||
|
@@ -818,6 +818,11 @@ GtkEditable *wxTextCtrl::GetEditable() const
|
||||
return GTK_EDITABLE(m_text);
|
||||
}
|
||||
|
||||
GtkEntry *wxTextCtrl::GetEntry() const
|
||||
{
|
||||
return GTK_ENTRY(m_text);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// flags handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -326,4 +326,74 @@ void wxTextEntry::SendMaxLenEvent()
|
||||
win->HandleWindowEvent(event);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// margins support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTextEntry::DoSetMargins(const wxPoint& margins)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2,10,0)
|
||||
GtkEntry* entry = GetEntry();
|
||||
|
||||
if ( !entry )
|
||||
return false;
|
||||
|
||||
const GtkBorder* oldBorder = gtk_entry_get_inner_border(entry);
|
||||
GtkBorder* newBorder;
|
||||
|
||||
if ( oldBorder )
|
||||
{
|
||||
newBorder = gtk_border_copy(oldBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2,14,0)
|
||||
newBorder = gtk_border_new();
|
||||
#else
|
||||
newBorder = new GtkBorder;
|
||||
#endif
|
||||
// Use some reasonable defaults for initial margins
|
||||
newBorder->left = 2;
|
||||
newBorder->right = 2;
|
||||
|
||||
// These numbers seem to let the text remain vertically centered
|
||||
// in common use scenarios when margins.y == -1.
|
||||
newBorder->top = 3;
|
||||
newBorder->bottom = 3;
|
||||
}
|
||||
|
||||
if ( margins.x != -1 )
|
||||
newBorder->left = (gint) margins.x;
|
||||
|
||||
if ( margins.y != -1 )
|
||||
newBorder->top = (gint) margins.y;
|
||||
|
||||
gtk_entry_set_inner_border(entry, newBorder);
|
||||
|
||||
return true;
|
||||
#else
|
||||
wxUnusedVar(margins);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxPoint wxTextEntry::DoGetMargins() const
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2,10,0)
|
||||
GtkEntry* entry = GetEntry();
|
||||
|
||||
if ( !entry )
|
||||
return wxPoint(-1, -1);
|
||||
|
||||
const GtkBorder* border = gtk_entry_get_inner_border(entry);
|
||||
|
||||
if ( !border )
|
||||
return wxPoint(-1, -1);
|
||||
|
||||
return wxPoint((wxCoord) border->left, (wxCoord) border->top);
|
||||
#else
|
||||
return wxPoint(-1, -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX
|
||||
|
@@ -117,9 +117,7 @@
|
||||
#define NATIVE_TEXT_INDENT_XP 4
|
||||
#define NATIVE_TEXT_INDENT_CLASSIC 2
|
||||
|
||||
#define TEXTCTRLXADJUST_XP 1
|
||||
#define TEXTCTRLYADJUST_XP 3
|
||||
#define TEXTCTRLXADJUST_CLASSIC 1
|
||||
#define TEXTCTRLYADJUST_CLASSIC 3
|
||||
|
||||
#define COMBOBOX_ANIMATION_RESOLUTION 10
|
||||
@@ -264,19 +262,16 @@ void wxComboCtrl::OnResize()
|
||||
//
|
||||
// Recalculates button and textctrl areas
|
||||
|
||||
int textCtrlXAdjust;
|
||||
int textCtrlYAdjust;
|
||||
|
||||
#if wxUSE_UXTHEME
|
||||
if ( wxUxThemeEngine::GetIfActive() )
|
||||
{
|
||||
textCtrlXAdjust = TEXTCTRLXADJUST_XP;
|
||||
textCtrlYAdjust = TEXTCTRLYADJUST_XP;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
textCtrlXAdjust = TEXTCTRLXADJUST_CLASSIC;
|
||||
textCtrlYAdjust = TEXTCTRLYADJUST_CLASSIC;
|
||||
}
|
||||
|
||||
@@ -286,7 +281,7 @@ void wxComboCtrl::OnResize()
|
||||
CalculateAreas(btnWidth);
|
||||
|
||||
// Position textctrl using standard routine
|
||||
PositionTextCtrl(textCtrlXAdjust,textCtrlYAdjust);
|
||||
PositionTextCtrl(0, textCtrlYAdjust);
|
||||
}
|
||||
|
||||
// Draws non-XP GUI dotted line around the focus area
|
||||
|
@@ -474,4 +474,44 @@ wxString wxTextEntry::GetHint() const
|
||||
|
||||
#endif // wxUSE_UXTHEME
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// margins support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTextEntry::DoSetMargins(const wxPoint& margins)
|
||||
{
|
||||
#if !defined(__WXWINCE__)
|
||||
bool res = true;
|
||||
|
||||
if ( margins.x != -1 )
|
||||
{
|
||||
// left margin
|
||||
::SendMessage(GetEditHwnd(), EM_SETMARGINS,
|
||||
EC_LEFTMARGIN, MAKELONG(margins.x, 0));
|
||||
}
|
||||
|
||||
if ( margins.y != -1 )
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
|
||||
return res;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxPoint wxTextEntry::DoGetMargins() const
|
||||
{
|
||||
#if !defined(__WXWINCE__)
|
||||
LRESULT lResult = ::SendMessage(GetEditHwnd(), EM_GETMARGINS,
|
||||
0, 0);
|
||||
int left = LOWORD(lResult);
|
||||
int top = -1;
|
||||
return wxPoint(left, top);
|
||||
#else
|
||||
return wxPoint(-1, -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX
|
||||
|
@@ -77,10 +77,6 @@
|
||||
|
||||
#include "wx/odcombo.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/msw/private.h"
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
@@ -150,7 +146,8 @@
|
||||
#define wxPG_CHOICEYADJUST 0
|
||||
#endif
|
||||
|
||||
#define ODCB_CUST_PAINT_MARGIN 6 // Number added to image width for SetCustomPaintWidth
|
||||
// Number added to image width for SetCustomPaintWidth
|
||||
#define ODCB_CUST_PAINT_MARGIN 9
|
||||
|
||||
// Milliseconds to wait for two mouse-ups after focus inorder
|
||||
// to trigger a double-click.
|
||||
@@ -288,12 +285,7 @@ void wxPGTextCtrlEditor::UpdateControl( wxPGProperty* property, wxWindow* ctrl )
|
||||
//
|
||||
// Fix indentation, just in case (change in font boldness is one good
|
||||
// reason).
|
||||
#if defined(__WXMSW__) && !defined(__WXWINCE__)
|
||||
::SendMessage(GetHwndOf(tc),
|
||||
EM_SETMARGINS,
|
||||
EC_LEFTMARGIN | EC_RIGHTMARGIN,
|
||||
MAKELONG(0, 0));
|
||||
#endif
|
||||
tc->SetMargins(0);
|
||||
}
|
||||
|
||||
// Provided so that, for example, ComboBox editor can use the same code
|
||||
@@ -582,13 +574,16 @@ public:
|
||||
return rect.width;
|
||||
}
|
||||
|
||||
virtual void PositionTextCtrl( int WXUNUSED(textCtrlXAdjust),
|
||||
virtual void PositionTextCtrl( int textCtrlXAdjust,
|
||||
int WXUNUSED(textCtrlYAdjust) )
|
||||
{
|
||||
wxPropertyGrid* pg = GetGrid();
|
||||
wxOwnerDrawnComboBox::PositionTextCtrl(
|
||||
wxPG_TEXTCTRLXADJUST -
|
||||
#ifdef wxPG_TEXTCTRLXADJUST
|
||||
textCtrlXAdjust = wxPG_TEXTCTRLXADJUST -
|
||||
(wxPG_XBEFOREWIDGET+wxPG_CONTROL_MARGIN+1) - 1,
|
||||
#endif
|
||||
wxOwnerDrawnComboBox::PositionTextCtrl(
|
||||
textCtrlXAdjust,
|
||||
pg->GetSpacingY() + 2
|
||||
);
|
||||
}
|
||||
@@ -877,7 +872,7 @@ wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid,
|
||||
odcbFlags);
|
||||
|
||||
cb->SetButtonPosition(si.y,0,wxRIGHT);
|
||||
cb->SetTextIndent(wxPG_XBEFORETEXT-1);
|
||||
cb->SetMargins(wxPG_XBEFORETEXT-1);
|
||||
|
||||
wxPGChoiceEditor_SetCustomPaintWidth( propGrid, cb, property->GetCommonValue() );
|
||||
|
||||
@@ -1598,7 +1593,7 @@ void wxPropertyGrid::CorrectEditorWidgetPosY()
|
||||
// Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
|
||||
// fits into that category as well).
|
||||
void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl,
|
||||
unsigned int forColumn,
|
||||
unsigned int WXUNUSED(forColumn),
|
||||
const wxPoint& offset )
|
||||
{
|
||||
// Center the control vertically
|
||||
@@ -1612,10 +1607,14 @@ void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl,
|
||||
finalPos.y += y_adj;
|
||||
finalPos.height -= (y_adj+sz_dec);
|
||||
|
||||
int textCtrlXAdjust = wxPG_TEXTCTRLXADJUST;
|
||||
#ifndef wxPG_TEXTCTRLXADJUST
|
||||
int textCtrlXAdjust = wxPG_XBEFORETEXT - 1;
|
||||
|
||||
if ( forColumn != 1 )
|
||||
textCtrlXAdjust -= 3; // magic number!
|
||||
wxTextCtrl* tc = static_cast<wxTextCtrl*>(ctrl);
|
||||
tc->SetMargins(0);
|
||||
#else
|
||||
int textCtrlXAdjust = wxPG_TEXTCTRLXADJUST;
|
||||
#endif
|
||||
|
||||
finalPos.x += textCtrlXAdjust;
|
||||
finalPos.width -= textCtrlXAdjust;
|
||||
@@ -1691,13 +1690,6 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
|
||||
{
|
||||
tc->SetBackgroundColour(m_colSelBack);
|
||||
tc->SetForegroundColour(m_colSelFore);
|
||||
|
||||
// Normalize margins
|
||||
#ifdef __WXMSW__
|
||||
::SendMessage(GetHwndOf(tc), EM_SETMARGINS,
|
||||
EC_LEFTMARGIN | EC_RIGHTMARGIN,
|
||||
MAKELONG(3, 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
|
@@ -64,10 +64,6 @@
|
||||
#include "wx/timer.h"
|
||||
#include "wx/dcbuffer.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/msw/private.h"
|
||||
#endif
|
||||
|
||||
// Two pics for the expand / collapse buttons.
|
||||
// Files are not supplied with this project (since it is
|
||||
// recommended to use either custom or native rendering).
|
||||
@@ -3867,18 +3863,6 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
|
||||
if ( (p->m_flags & wxPG_PROP_MODIFIED) && (m_windowStyle & wxPG_BOLD_MODIFIED) )
|
||||
SetCurControlBoldFont();
|
||||
|
||||
//
|
||||
// Fix TextCtrl indentation
|
||||
#if defined(__WXMSW__) && !defined(__WXWINCE__)
|
||||
wxTextCtrl* tc = NULL;
|
||||
if ( primaryCtrl->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) )
|
||||
tc = ((wxOwnerDrawnComboBox*)primaryCtrl)->GetTextCtrl();
|
||||
else
|
||||
tc = wxDynamicCast(primaryCtrl, wxTextCtrl);
|
||||
if ( tc )
|
||||
::SendMessage(GetHwndOf(tc), EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0, 0));
|
||||
#endif
|
||||
|
||||
// Store x relative to splitter (we'll need it).
|
||||
m_ctrlXAdjust = m_wndEditor->GetPosition().x - splitterX;
|
||||
|
||||
|
Reference in New Issue
Block a user