From 1ac5cfc7c9d2df832a4e8f5737f43995e3308ab4 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Sun, 13 Jun 2010 09:59:32 +0000 Subject: [PATCH] Added wxComboCtrl::SetTextCtrlStyle() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64577 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/combo.h | 7 +++++++ interface/wx/combo.h | 16 ++++++++++++++++ src/common/combocmn.cpp | 11 ++++++++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index fee187ad4d..12422a6ed6 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -523,6 +523,7 @@ All (GUI): - Added wxTreeCtrl::{Clear,Set}FocusedItem() (Nikolay Tiushkov). - Added "filter changed" event to wxFileCtrl (Bill Jones). - wxAUI: update floating window position and not only size on resize (MacGyver). +- Added wxComboCtrl::SetTextCtrlStyle(). GTK: diff --git a/include/wx/combo.h b/include/wx/combo.h index cfb202be2b..6a190e524a 100644 --- a/include/wx/combo.h +++ b/include/wx/combo.h @@ -402,6 +402,10 @@ public: wxPoint GetMargins() const { return DoGetMargins(); } + // Set custom style flags for embedded wxTextCtrl. Usually must be used + // with two-step creation, before Create() call. + void SetTextCtrlStyle( int style ); + // Return internal flags wxUint32 GetInternalFlags() const { return m_iFlags; } @@ -649,6 +653,9 @@ protected: // platform-dependant customization and other flags wxUint32 m_iFlags; + // custom style for m_text + int m_textCtrlStyle; + // draw blank button background under bitmap? bool m_blankButtonBg; diff --git a/interface/wx/combo.h b/interface/wx/combo.h index 82c63e4c42..9ed3db36cf 100644 --- a/interface/wx/combo.h +++ b/interface/wx/combo.h @@ -734,6 +734,22 @@ public: */ void SetText(const wxString& value); + /** + Set a custom window style for the embedded wxTextCtrl. Usually you + will need to use this during two-step creation, just before Create(). + For example: + + @code + wxComboCtrl* comboCtrl = new wxComboCtrl(); + + // Let's make the text right-aligned + comboCtrl->SetTextCtrlStyle(wxTE_RIGHT); + + comboCtrl->Create(parent, wxID_ANY, wxEmptyString); + @endcode + */ + void SetTextCtrlStyle( int style ); + /** 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 diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index a256b660c4..b32ef217ed 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -905,6 +905,7 @@ void wxComboCtrlBase::Init() m_extRight = 0; m_marginLeft = -1; m_iFlags = 0; + m_textCtrlStyle = 0; m_timeCanAcceptClick = 0; m_resetFocus = false; @@ -968,7 +969,7 @@ wxComboCtrlBase::CreateTextCtrl(int style, const wxValidator& validator) // not used by the wxPropertyGrid and therefore the tab is processed by // looking at ancestors to see if they have wxTAB_TRAVERSAL. The // navigation event is then sent to the wrong window. - style |= wxTE_PROCESS_TAB; + style |= wxTE_PROCESS_TAB | m_textCtrlStyle; if ( HasFlag(wxTE_PROCESS_ENTER) ) style |= wxTE_PROCESS_ENTER; @@ -2545,6 +2546,14 @@ wxCoord wxComboCtrlBase::GetNativeTextIndent() const return DEFAULT_TEXT_INDENT; } +void wxComboCtrlBase::SetTextCtrlStyle( int style ) +{ + m_textCtrlStyle = style; + + if ( m_text ) + m_text->SetWindowStyle(style); +} + // ---------------------------------------------------------------------------- // methods forwarded to wxTextCtrl // ---------------------------------------------------------------------------- -- 2.45.2