diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-07-10 12:05:48 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-07-10 23:27:40 +0200 |
commit | ece8699f8f22f6bae137c601bc29b83b75dc3bf3 (patch) | |
tree | a3c17d8e737140e065ff2134414a014e9412d243 /vcl | |
parent | 5fd84da4d638a11f087f74a216ff189dbccdfd96 (diff) |
vcl: pImplify ComboBox
The boost::signal stuff is quite heavy (33 kloc), so try to hide it
from the header.
Change-Id: I87826ccfd2a151aff274ffa6b7159a988f751808
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/combobox.cxx | 762 |
1 files changed, 425 insertions, 337 deletions
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 4f41c31c420c..15a3c0986588 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -17,7 +17,12 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <vcl/combobox.hxx> + #include <set> + +#include <boost/signals2/connection.hpp> + #include <comphelper/string.hxx> #include <tools/debug.hxx> #include <tools/rc.h> @@ -25,13 +30,59 @@ #include <vcl/lstbox.h> #include <vcl/button.hxx> #include <vcl/event.hxx> -#include <vcl/combobox.hxx> #include <vcl/settings.hxx> #include <svdata.hxx> #include <ilstbox.hxx> #include <controldata.hxx> + +struct ComboBoxBounds +{ + Point aSubEditPos; + Size aSubEditSize; + + Point aButtonPos; + Size aButtonSize; +}; + +struct ComboBox::Impl +{ + ComboBox & m_rThis; + VclPtr<Edit> m_pSubEdit; + VclPtr<ImplListBox> m_pImplLB; + VclPtr<ImplBtn> m_pBtn; + VclPtr<ImplListBoxFloatingWindow> m_pFloatWin; + sal_uInt16 m_nDDHeight; + sal_Unicode m_cMultiSep; + bool m_isDDAutoSize : 1; + bool m_isSyntheticModify : 1; + bool m_isMatchCase : 1; + sal_Int32 m_nMaxWidthChars; + Link<> m_SelectHdl; + Link<> m_DoubleClickHdl; + boost::signals2::scoped_connection m_AutocompleteConnection; + + Impl(ComboBox & rThis) : m_rThis(rThis) {} + + void ImplInitComboBoxData(); + void ImplUpdateFloatSelection(); + ComboBoxBounds calcComboBoxDropDownComponentBounds( + const Size &rOutSize, const Size &rBorderOutSize) const; + + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplListItemSelectHdl , void* ); + + void ImplClickButtonHandler( ImplBtn* ); + void ImplUserDrawHandler( UserDrawEvent* ); + void ImplAutocompleteHandler( Edit* ); +}; + + static void lcl_GetSelectedEntries( ::std::set< sal_Int32 >& rSelectedPos, const OUString& rText, sal_Unicode cTokenSep, const ImplEntryList* pEntryList ) { for (sal_Int32 n = comphelper::string::getTokenCount(rText, cTokenSep); n;) @@ -44,18 +95,20 @@ static void lcl_GetSelectedEntries( ::std::set< sal_Int32 >& rSelectedPos, const } } -ComboBox::ComboBox( vcl::Window* pParent, WinBits nStyle ) : - Edit( WINDOW_COMBOBOX ) +ComboBox::ComboBox(vcl::Window *const pParent, WinBits const nStyle) + : Edit( WINDOW_COMBOBOX ) + , m_pImpl(new Impl(*this)) { - ImplInitComboBoxData(); + m_pImpl->ImplInitComboBoxData(); ImplInit( pParent, nStyle ); SetWidthInChars(-1); } -ComboBox::ComboBox( vcl::Window* pParent, const ResId& rResId ) : - Edit( WINDOW_COMBOBOX ) +ComboBox::ComboBox(vcl::Window *const pParent, const ResId& rResId) + : Edit( WINDOW_COMBOBOX ) + , m_pImpl(new Impl(*this)) { - ImplInitComboBoxData(); + m_pImpl->ImplInitComboBoxData(); rResId.SetRT( RSC_COMBOBOX ); WinBits nStyle = ImplInitRes( rResId ); ImplInit( pParent, nStyle ); @@ -73,29 +126,29 @@ ComboBox::~ComboBox() void ComboBox::dispose() { - mpSubEdit.disposeAndClear(); + m_pImpl->m_pSubEdit.disposeAndClear(); - VclPtr< ImplListBox > pImplLB = mpImplLB; - mpImplLB.clear(); + VclPtr< ImplListBox > pImplLB = m_pImpl->m_pImplLB; + m_pImpl->m_pImplLB.clear(); pImplLB.disposeAndClear(); - mpFloatWin.disposeAndClear(); - mpBtn.disposeAndClear(); + m_pImpl->m_pFloatWin.disposeAndClear(); + m_pImpl->m_pBtn.disposeAndClear(); Edit::dispose(); } -void ComboBox::ImplInitComboBoxData() +void ComboBox::Impl::ImplInitComboBoxData() { - mpSubEdit.disposeAndClear(); - mpBtn = NULL; - mpImplLB = NULL; - mpFloatWin = NULL; + m_pSubEdit.disposeAndClear(); + m_pBtn = nullptr; + m_pImplLB = nullptr; + m_pFloatWin = nullptr; - mnDDHeight = 0; - mbDDAutoSize = true; - mbSyntheticModify = false; - mbMatchCase = false; - mcMultiSep = ';'; + m_nDDHeight = 0; + m_isDDAutoSize = true; + m_isSyntheticModify = false; + m_isMatchCase = false; + m_cMultiSep = ';'; m_nMaxWidthChars = -1; } @@ -103,9 +156,9 @@ void ComboBox::ImplCalcEditHeight() { sal_Int32 nLeft, nTop, nRight, nBottom; GetBorder( nLeft, nTop, nRight, nBottom ); - mnDDHeight = (sal_uInt16)(mpSubEdit->GetTextHeight() + nTop + nBottom + 4); + m_pImpl->m_nDDHeight = (sal_uInt16)(m_pImpl->m_pSubEdit->GetTextHeight() + nTop + nBottom + 4); if ( !IsDropDownBox() ) - mnDDHeight += 4; + m_pImpl->m_nDDHeight += 4; Rectangle aCtrlRegion( Point( 0, 0 ), Size( 10, 10 ) ); Rectangle aBoundRegion, aContentRegion; @@ -118,8 +171,8 @@ void ComboBox::ImplCalcEditHeight() aBoundRegion, aContentRegion ) ) { const long nNCHeight = aBoundRegion.GetHeight(); - if( mnDDHeight < nNCHeight ) - mnDDHeight = sal::static_int_cast<sal_uInt16>( nNCHeight ); + if (m_pImpl->m_nDDHeight < nNCHeight) + m_pImpl->m_nDDHeight = sal::static_int_cast<sal_uInt16>(nNCHeight); } } @@ -147,14 +200,14 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) WinBits nListStyle = nStyle; if( nStyle & WB_DROPDOWN ) { - mpFloatWin = VclPtr<ImplListBoxFloatingWindow>::Create( this ); - mpFloatWin->SetAutoWidth( true ); - mpFloatWin->SetPopupModeEndHdl( LINK( this, ComboBox, ImplPopupModeEndHdl ) ); + m_pImpl->m_pFloatWin = VclPtr<ImplListBoxFloatingWindow>::Create( this ); + m_pImpl->m_pFloatWin->SetAutoWidth( true ); + m_pImpl->m_pFloatWin->SetPopupModeEndHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplPopupModeEndHdl) ); - mpBtn = VclPtr<ImplBtn>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE ); - ImplInitDropDownButton( mpBtn ); - mpBtn->buttonDownSignal.connect( boost::bind( &ComboBox::ImplClickButtonHandler, this, _1 )); - mpBtn->Show(); + m_pImpl->m_pBtn = VclPtr<ImplBtn>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE ); + ImplInitDropDownButton( m_pImpl->m_pBtn ); + m_pImpl->m_pBtn->buttonDownSignal.connect( boost::bind( &ComboBox::Impl::ImplClickButtonHandler, m_pImpl.get(), _1 )); + m_pImpl->m_pBtn->Show(); nEditStyle |= WB_NOBORDER; nListStyle &= ~WB_BORDER; @@ -170,30 +223,30 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) } } - mpSubEdit.set( VclPtr<Edit>::Create( this, nEditStyle ) ); - mpSubEdit->EnableRTL( false ); - SetSubEdit( mpSubEdit ); - mpSubEdit->SetPosPixel( Point() ); + m_pImpl->m_pSubEdit.set( VclPtr<Edit>::Create( this, nEditStyle ) ); + m_pImpl->m_pSubEdit->EnableRTL( false ); + SetSubEdit( m_pImpl->m_pSubEdit ); + m_pImpl->m_pSubEdit->SetPosPixel( Point() ); EnableAutocomplete( true ); - mpSubEdit->Show(); + m_pImpl->m_pSubEdit->Show(); vcl::Window* pLBParent = this; - if ( mpFloatWin ) - pLBParent = mpFloatWin; - mpImplLB = VclPtr<ImplListBox>::Create( pLBParent, nListStyle|WB_SIMPLEMODE|WB_AUTOHSCROLL ); - mpImplLB->SetPosPixel( Point() ); - mpImplLB->SetSelectHdl( LINK( this, ComboBox, ImplSelectHdl ) ); - mpImplLB->SetCancelHdl( LINK( this, ComboBox, ImplCancelHdl ) ); - mpImplLB->SetDoubleClickHdl( LINK( this, ComboBox, ImplDoubleClickHdl ) ); - mpImplLB->userDrawSignal.connect( boost::bind( &ComboBox::ImplUserDrawHandler, this, _1 ) ); - mpImplLB->SetSelectionChangedHdl( LINK( this, ComboBox, ImplSelectionChangedHdl ) ); - mpImplLB->SetListItemSelectHdl( LINK( this, ComboBox, ImplListItemSelectHdl ) ); - mpImplLB->Show(); - - if ( mpFloatWin ) - mpFloatWin->SetImplListBox( mpImplLB ); + if (m_pImpl->m_pFloatWin) + pLBParent = m_pImpl->m_pFloatWin; + m_pImpl->m_pImplLB = VclPtr<ImplListBox>::Create( pLBParent, nListStyle|WB_SIMPLEMODE|WB_AUTOHSCROLL ); + m_pImpl->m_pImplLB->SetPosPixel( Point() ); + m_pImpl->m_pImplLB->SetSelectHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplSelectHdl) ); + m_pImpl->m_pImplLB->SetCancelHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplCancelHdl) ); + m_pImpl->m_pImplLB->SetDoubleClickHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplDoubleClickHdl) ); + m_pImpl->m_pImplLB->userDrawSignal.connect( boost::bind( &ComboBox::Impl::ImplUserDrawHandler, m_pImpl.get(), _1 ) ); + m_pImpl->m_pImplLB->SetSelectionChangedHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplSelectionChangedHdl) ); + m_pImpl->m_pImplLB->SetListItemSelectHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplListItemSelectHdl) ); + m_pImpl->m_pImplLB->Show(); + + if (m_pImpl->m_pFloatWin) + m_pImpl->m_pFloatWin->SetImplListBox( m_pImpl->m_pImplLB ); else - mpImplLB->GetMainWindow()->AllowGrabFocus( true ); + m_pImpl->m_pImplLB->GetMainWindow()->AllowGrabFocus( true ); ImplCalcEditHeight(); @@ -226,65 +279,66 @@ void ComboBox::ImplLoadRes( const ResId& rResId ) void ComboBox::EnableAutocomplete( bool bEnable, bool bMatchCase ) { - mbMatchCase = bMatchCase; + m_pImpl->m_isMatchCase = bMatchCase; if ( bEnable ) { - if( !mAutocompleteConnection.connected()) - mAutocompleteConnection = mpSubEdit->autocompleteSignal.connect( - boost::bind( &ComboBox::ImplAutocompleteHandler, this, _1 ) ); + if( !m_pImpl->m_AutocompleteConnection.connected()) + m_pImpl->m_AutocompleteConnection = m_pImpl->m_pSubEdit->autocompleteSignal.connect( + boost::bind( &ComboBox::Impl::ImplAutocompleteHandler, m_pImpl.get(), _1 ) ); } else - mAutocompleteConnection.disconnect(); + m_pImpl->m_AutocompleteConnection.disconnect(); } bool ComboBox::IsAutocompleteEnabled() const { - return mAutocompleteConnection.connected(); + return m_pImpl->m_AutocompleteConnection.connected(); } -void ComboBox::ImplClickButtonHandler( ImplBtn* ) +void ComboBox::Impl::ImplClickButtonHandler( ImplBtn* ) { - CallEventListeners( VCLEVENT_DROPDOWN_PRE_OPEN ); - mpSubEdit->GrabFocus(); - if ( !mpImplLB->GetEntryList()->GetMRUCount() ) + m_rThis.CallEventListeners( VCLEVENT_DROPDOWN_PRE_OPEN ); + m_pSubEdit->GrabFocus(); + if (!m_pImplLB->GetEntryList()->GetMRUCount()) ImplUpdateFloatSelection(); else - mpImplLB->SelectEntry( 0 , true ); - mpBtn->SetPressed( true ); - SetSelection( Selection( 0, SELECTION_MAX ) ); - mpFloatWin->StartFloat( true ); - CallEventListeners( VCLEVENT_DROPDOWN_OPEN ); + m_pImplLB->SelectEntry( 0 , true ); + m_pBtn->SetPressed( true ); + m_rThis.SetSelection( Selection( 0, SELECTION_MAX ) ); + m_pFloatWin->StartFloat( true ); + m_rThis.CallEventListeners( VCLEVENT_DROPDOWN_OPEN ); - ImplClearLayoutData(); - if( mpImplLB ) - mpImplLB->GetMainWindow()->ImplClearLayoutData(); + m_rThis.ImplClearLayoutData(); + if (m_pImplLB) + m_pImplLB->GetMainWindow()->ImplClearLayoutData(); } -IMPL_LINK_NOARG(ComboBox, ImplPopupModeEndHdl) +IMPL_LINK_NOARG(ComboBox::Impl, ImplPopupModeEndHdl) { - if( mpFloatWin->IsPopupModeCanceled() ) + if (m_pFloatWin->IsPopupModeCanceled()) { - if ( !mpImplLB->GetEntryList()->IsEntryPosSelected( mpFloatWin->GetPopupModeStartSaveSelection() ) ) + if (!m_pImplLB->GetEntryList()->IsEntryPosSelected( + m_pFloatWin->GetPopupModeStartSaveSelection())) { - mpImplLB->SelectEntry( mpFloatWin->GetPopupModeStartSaveSelection(), true ); - bool bTravelSelect = mpImplLB->IsTravelSelect(); - mpImplLB->SetTravelSelect( true ); - Select(); - mpImplLB->SetTravelSelect( bTravelSelect ); + m_pImplLB->SelectEntry(m_pFloatWin->GetPopupModeStartSaveSelection(), true); + bool bTravelSelect = m_pImplLB->IsTravelSelect(); + m_pImplLB->SetTravelSelect( true ); + m_rThis.Select(); + m_pImplLB->SetTravelSelect( bTravelSelect ); } } - ImplClearLayoutData(); - if( mpImplLB ) - mpImplLB->GetMainWindow()->ImplClearLayoutData(); + m_rThis.ImplClearLayoutData(); + if (m_pImplLB) + m_pImplLB->GetMainWindow()->ImplClearLayoutData(); - mpBtn->SetPressed( false ); - CallEventListeners( VCLEVENT_DROPDOWN_CLOSE ); + m_pBtn->SetPressed( false ); + m_rThis.CallEventListeners( VCLEVENT_DROPDOWN_CLOSE ); return 0; } -void ComboBox::ImplAutocompleteHandler( Edit* pEdit ) +void ComboBox::Impl::ImplAutocompleteHandler( Edit* pEdit ) { Selection aSel = pEdit->GetSelection(); AutocompleteAction eAction = pEdit->GetAutocompleteAction(); @@ -297,7 +351,7 @@ void ComboBox::ImplAutocompleteHandler( Edit* pEdit ) { OUString aFullText = pEdit->GetText(); OUString aStartText = aFullText.copy( 0, (sal_Int32)aSel.Max() ); - sal_Int32 nStart = mpImplLB->GetCurrentPos(); + sal_Int32 nStart = m_pImplLB->GetCurrentPos(); if ( nStart == LISTBOX_ENTRY_NOTFOUND ) nStart = 0; @@ -310,62 +364,66 @@ void ComboBox::ImplAutocompleteHandler( Edit* pEdit ) bForward = false; if (nStart) nStart = nStart - 1; - else if (mpImplLB->GetEntryList()->GetEntryCount()) - nStart = mpImplLB->GetEntryList()->GetEntryCount()-1; + else if (m_pImplLB->GetEntryList()->GetEntryCount()) + nStart = m_pImplLB->GetEntryList()->GetEntryCount()-1; } sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND; - if( ! mbMatchCase ) + if (!m_isMatchCase) { // Try match case insensitive from current position - nPos = mpImplLB->GetEntryList()->FindMatchingEntry( aStartText, nStart, bForward, true ); + nPos = m_pImplLB->GetEntryList()->FindMatchingEntry( aStartText, nStart, bForward, true ); if ( nPos == LISTBOX_ENTRY_NOTFOUND ) // Try match case insensitive, but from start - nPos = mpImplLB->GetEntryList()->FindMatchingEntry( aStartText, bForward ? 0 : (mpImplLB->GetEntryList()->GetEntryCount()-1), bForward, true ); + nPos = m_pImplLB->GetEntryList()->FindMatchingEntry( aStartText, + bForward ? 0 : (m_pImplLB->GetEntryList()->GetEntryCount()-1), + bForward, true ); } if ( nPos == LISTBOX_ENTRY_NOTFOUND ) // Try match full from current position - nPos = mpImplLB->GetEntryList()->FindMatchingEntry( aStartText, nStart, bForward, false ); + nPos = m_pImplLB->GetEntryList()->FindMatchingEntry( aStartText, nStart, bForward, false ); if ( nPos == LISTBOX_ENTRY_NOTFOUND ) // Match full, but from start - nPos = mpImplLB->GetEntryList()->FindMatchingEntry( aStartText, bForward ? 0 : (mpImplLB->GetEntryList()->GetEntryCount()-1), bForward, false ); + nPos = m_pImplLB->GetEntryList()->FindMatchingEntry( aStartText, + bForward ? 0 : (m_pImplLB->GetEntryList()->GetEntryCount()-1), + bForward, false ); if ( nPos != LISTBOX_ENTRY_NOTFOUND ) { - OUString aText = mpImplLB->GetEntryList()->GetEntryText( nPos ); + OUString aText = m_pImplLB->GetEntryList()->GetEntryText( nPos ); Selection aSelection( aText.getLength(), aStartText.getLength() ); pEdit->SetText( aText, aSelection ); } } } -IMPL_LINK_NOARG(ComboBox, ImplSelectHdl) +IMPL_LINK_NOARG(ComboBox::Impl, ImplSelectHdl) { - bool bPopup = IsInDropDown(); + bool bPopup = m_rThis.IsInDropDown(); bool bCallSelect = false; - if ( mpImplLB->IsSelectionChanged() || bPopup ) + if (m_pImplLB->IsSelectionChanged() || bPopup) { OUString aText; - if ( IsMultiSelectionEnabled() ) + if (m_rThis.IsMultiSelectionEnabled()) { - aText = mpSubEdit->GetText(); + aText = m_pSubEdit->GetText(); // remove all entries to which there is an entry, but which is not selected sal_Int32 nIndex = 0; while ( nIndex >= 0 ) { sal_Int32 nPrevIndex = nIndex; - OUString aToken = aText.getToken( 0, mcMultiSep, nIndex ); + OUString aToken = aText.getToken( 0, m_cMultiSep, nIndex ); sal_Int32 nTokenLen = aToken.getLength(); aToken = comphelper::string::strip(aToken, ' '); - sal_Int32 nP = mpImplLB->GetEntryList()->FindEntry( aToken ); - if ( (nP != LISTBOX_ENTRY_NOTFOUND) && (!mpImplLB->GetEntryList()->IsEntryPosSelected( nP )) ) + sal_Int32 nP = m_pImplLB->GetEntryList()->FindEntry( aToken ); + if ((nP != LISTBOX_ENTRY_NOTFOUND) && (!m_pImplLB->GetEntryList()->IsEntryPosSelected(nP))) { aText = aText.replaceAt( nPrevIndex, nTokenLen, "" ); nIndex = nIndex - nTokenLen; sal_Int32 nSepCount=0; - if ( (nPrevIndex+nSepCount < aText.getLength()) && (aText[nPrevIndex+nSepCount] == mcMultiSep) ) + if ((nPrevIndex+nSepCount < aText.getLength()) && (aText[nPrevIndex+nSepCount] == m_cMultiSep)) { nIndex--; ++nSepCount; @@ -377,87 +435,87 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl) // attach missing entries ::std::set< sal_Int32 > aSelInText; - lcl_GetSelectedEntries( aSelInText, aText, mcMultiSep, mpImplLB->GetEntryList() ); - sal_Int32 nSelectedEntries = mpImplLB->GetEntryList()->GetSelectEntryCount(); + lcl_GetSelectedEntries( aSelInText, aText, m_cMultiSep, m_pImplLB->GetEntryList() ); + sal_Int32 nSelectedEntries = m_pImplLB->GetEntryList()->GetSelectEntryCount(); for ( sal_Int32 n = 0; n < nSelectedEntries; n++ ) { - sal_Int32 nP = mpImplLB->GetEntryList()->GetSelectEntryPos( n ); + sal_Int32 nP = m_pImplLB->GetEntryList()->GetSelectEntryPos( n ); if ( !aSelInText.count( nP ) ) { - if ( !aText.isEmpty() && (aText[ aText.getLength()-1 ] != mcMultiSep) ) - aText += OUString(mcMultiSep); + if (!aText.isEmpty() && (aText[aText.getLength()-1] != m_cMultiSep)) + aText += OUString(m_cMultiSep); if ( !aText.isEmpty() ) aText += " "; // slightly loosen - aText += mpImplLB->GetEntryList()->GetEntryText( nP ); - aText += OUString(mcMultiSep); + aText += m_pImplLB->GetEntryList()->GetEntryText( nP ); + aText += OUString(m_cMultiSep); } } - aText = comphelper::string::stripEnd( aText, mcMultiSep ); + aText = comphelper::string::stripEnd( aText, m_cMultiSep ); } else { - aText = mpImplLB->GetEntryList()->GetSelectEntry( 0 ); + aText = m_pImplLB->GetEntryList()->GetSelectEntry( 0 ); } - mpSubEdit->SetText( aText ); + m_pSubEdit->SetText( aText ); Selection aNewSelection( 0, aText.getLength() ); - if ( IsMultiSelectionEnabled() ) + if (m_rThis.IsMultiSelectionEnabled()) aNewSelection.Min() = aText.getLength(); - mpSubEdit->SetSelection( aNewSelection ); + m_pSubEdit->SetSelection( aNewSelection ); bCallSelect = true; } // #84652# Call GrabFocus and EndPopupMode before calling Select/Modify, but after changing the text - if ( bPopup && !mpImplLB->IsTravelSelect() && - ( !IsMultiSelectionEnabled() || !mpImplLB->GetSelectModifier() ) ) + if (bPopup && !m_pImplLB->IsTravelSelect() && + (!m_rThis.IsMultiSelectionEnabled() || !m_pImplLB->GetSelectModifier())) { - mpFloatWin->EndPopupMode(); - GrabFocus(); + m_pFloatWin->EndPopupMode(); + m_rThis.GrabFocus(); } if ( bCallSelect ) { - mpSubEdit->SetModifyFlag(); - mbSyntheticModify = true; - Modify(); - mbSyntheticModify = false; - Select(); + m_pSubEdit->SetModifyFlag(); + m_isSyntheticModify = true; + m_rThis.Modify(); + m_isSyntheticModify = false; + m_rThis.Select(); } return 0; } -IMPL_LINK_NOARG( ComboBox, ImplListItemSelectHdl ) +IMPL_LINK_NOARG( ComboBox::Impl, ImplListItemSelectHdl ) { - CallEventListeners( VCLEVENT_DROPDOWN_SELECT ); + m_rThis.CallEventListeners( VCLEVENT_DROPDOWN_SELECT ); return 1; } -IMPL_LINK_NOARG(ComboBox, ImplCancelHdl) +IMPL_LINK_NOARG(ComboBox::Impl, ImplCancelHdl) { - if( IsInDropDown() ) - mpFloatWin->EndPopupMode(); + if (m_rThis.IsInDropDown()) + m_pFloatWin->EndPopupMode(); return 1; } -IMPL_LINK( ComboBox, ImplSelectionChangedHdl, void*, n ) +IMPL_LINK( ComboBox::Impl, ImplSelectionChangedHdl, void*, n ) { - if ( !mpImplLB->IsTrackingSelect() ) + if (!m_pImplLB->IsTrackingSelect()) { sal_Int32 nChanged = (sal_Int32)reinterpret_cast<sal_uLong>(n); - if ( !mpSubEdit->IsReadOnly() && mpImplLB->GetEntryList()->IsEntryPosSelected( nChanged ) ) - mpSubEdit->SetText( mpImplLB->GetEntryList()->GetEntryText( nChanged ) ); + if (!m_pSubEdit->IsReadOnly() && m_pImplLB->GetEntryList()->IsEntryPosSelected(nChanged)) + m_pSubEdit->SetText(m_pImplLB->GetEntryList()->GetEntryText(nChanged)); } return 1; } -IMPL_LINK_NOARG(ComboBox, ImplDoubleClickHdl) +IMPL_LINK_NOARG(ComboBox::Impl, ImplDoubleClickHdl) { - DoubleClick(); + m_rThis.DoubleClick(); return 0; } @@ -465,19 +523,19 @@ void ComboBox::ToggleDropDown() { if( IsDropDownBox() ) { - if( mpFloatWin->IsInPopupMode() ) - mpFloatWin->EndPopupMode(); + if (m_pImpl->m_pFloatWin->IsInPopupMode()) + m_pImpl->m_pFloatWin->EndPopupMode(); else { - mpSubEdit->GrabFocus(); - if ( !mpImplLB->GetEntryList()->GetMRUCount() ) - ImplUpdateFloatSelection(); + m_pImpl->m_pSubEdit->GrabFocus(); + if (!m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount()) + m_pImpl->ImplUpdateFloatSelection(); else - mpImplLB->SelectEntry( 0 , true ); + m_pImpl->m_pImplLB->SelectEntry( 0 , true ); CallEventListeners( VCLEVENT_DROPDOWN_PRE_OPEN ); - mpBtn->SetPressed( true ); + m_pImpl->m_pBtn->SetPressed( true ); SetSelection( Selection( 0, SELECTION_MAX ) ); - mpFloatWin->StartFloat( true ); + m_pImpl->m_pFloatWin->StartFloat( true ); CallEventListeners( VCLEVENT_DROPDOWN_OPEN ); } } @@ -485,41 +543,43 @@ void ComboBox::ToggleDropDown() void ComboBox::Select() { - ImplCallEventListenersAndHandler( VCLEVENT_COMBOBOX_SELECT, maSelectHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_COMBOBOX_SELECT, m_pImpl->m_SelectHdl, this ); } void ComboBox::DoubleClick() { - ImplCallEventListenersAndHandler( VCLEVENT_COMBOBOX_DOUBLECLICK, maDoubleClickHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_COMBOBOX_DOUBLECLICK, m_pImpl->m_DoubleClickHdl, this ); } +bool ComboBox::IsAutoSizeEnabled() const { return m_pImpl->m_isDDAutoSize; } + void ComboBox::EnableAutoSize( bool bAuto ) { - mbDDAutoSize = bAuto; - if ( mpFloatWin ) + m_pImpl->m_isDDAutoSize = bAuto; + if (m_pImpl->m_pFloatWin) { - if ( bAuto && !mpFloatWin->GetDropDownLineCount() ) + if (bAuto && !m_pImpl->m_pFloatWin->GetDropDownLineCount()) { // Adapt to GetListBoxMaximumLineCount here; was on fixed number of five before AdaptDropDownLineCountToMaximum(); } else if ( !bAuto ) { - mpFloatWin->SetDropDownLineCount( 0 ); + m_pImpl->m_pFloatWin->SetDropDownLineCount( 0 ); } } } void ComboBox::EnableDDAutoWidth( bool b ) { - if ( mpFloatWin ) - mpFloatWin->SetAutoWidth( b ); + if (m_pImpl->m_pFloatWin) + m_pImpl->m_pFloatWin->SetAutoWidth( b ); } void ComboBox::SetDropDownLineCount( sal_uInt16 nLines ) { - if ( mpFloatWin ) - mpFloatWin->SetDropDownLineCount( nLines ); + if (m_pImpl->m_pFloatWin) + m_pImpl->m_pFloatWin->SetDropDownLineCount( nLines ); } void ComboBox::AdaptDropDownLineCountToMaximum() @@ -531,8 +591,8 @@ void ComboBox::AdaptDropDownLineCountToMaximum() sal_uInt16 ComboBox::GetDropDownLineCount() const { sal_uInt16 nLines = 0; - if ( mpFloatWin ) - nLines = mpFloatWin->GetDropDownLineCount(); + if (m_pImpl->m_pFloatWin) + nLines = m_pImpl->m_pFloatWin->GetDropDownLineCount(); return nLines; } @@ -541,15 +601,15 @@ void ComboBox::setPosSizePixel( long nX, long nY, long nWidth, long nHeight, { if( IsDropDownBox() && ( nFlags & PosSizeFlags::Size ) ) { - Size aPrefSz = mpFloatWin->GetPrefSize(); - if ( ( nFlags & PosSizeFlags::Height ) && ( nHeight >= 2*mnDDHeight ) ) - aPrefSz.Height() = nHeight-mnDDHeight; + Size aPrefSz = m_pImpl->m_pFloatWin->GetPrefSize(); + if ((nFlags & PosSizeFlags::Height) && (nHeight >= 2*m_pImpl->m_nDDHeight)) + aPrefSz.Height() = nHeight-m_pImpl->m_nDDHeight; if ( nFlags & PosSizeFlags::Width ) aPrefSz.Width() = nWidth; - mpFloatWin->SetPrefSize( aPrefSz ); + m_pImpl->m_pFloatWin->SetPrefSize( aPrefSz ); if ( IsAutoSizeEnabled() && ! (nFlags & PosSizeFlags::Dropdown) ) - nHeight = mnDDHeight; + nHeight = m_pImpl->m_nDDHeight; } Edit::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags ); @@ -559,41 +619,44 @@ void ComboBox::Resize() { Control::Resize(); - if (mpSubEdit) + if (m_pImpl->m_pSubEdit) { Size aOutSz = GetOutputSizePixel(); if( IsDropDownBox() ) { - ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds(aOutSz, + ComboBoxBounds aBounds(m_pImpl->calcComboBoxDropDownComponentBounds(aOutSz, GetWindow(GetWindowType::Border)->GetOutputSizePixel())); - mpSubEdit->SetPosSizePixel(aBounds.aSubEditPos, aBounds.aSubEditSize); - mpBtn->SetPosSizePixel(aBounds.aButtonPos, aBounds.aButtonSize); + m_pImpl->m_pSubEdit->SetPosSizePixel(aBounds.aSubEditPos, aBounds.aSubEditSize); + m_pImpl->m_pBtn->SetPosSizePixel(aBounds.aButtonPos, aBounds.aButtonSize); } else { - mpSubEdit->SetSizePixel( Size( aOutSz.Width(), mnDDHeight ) ); - mpImplLB->setPosSizePixel( 0, mnDDHeight, aOutSz.Width(), aOutSz.Height() - mnDDHeight ); + m_pImpl->m_pSubEdit->SetSizePixel(Size(aOutSz.Width(), m_pImpl->m_nDDHeight)); + m_pImpl->m_pImplLB->setPosSizePixel(0, m_pImpl->m_nDDHeight, + aOutSz.Width(), aOutSz.Height() - m_pImpl->m_nDDHeight); if ( !GetText().isEmpty() ) - ImplUpdateFloatSelection(); + m_pImpl->ImplUpdateFloatSelection(); } } // adjust the size of the FloatingWindow even when invisible // as KEY_PGUP/DOWN is being processed... - if ( mpFloatWin ) - mpFloatWin->SetSizePixel( mpFloatWin->CalcFloatSize() ); + if (m_pImpl->m_pFloatWin) + m_pImpl->m_pFloatWin->SetSizePixel(m_pImpl->m_pFloatWin->CalcFloatSize()); } +bool ComboBox::IsDropDownBox() const { return m_pImpl->m_pFloatWin != nullptr; } + void ComboBox::FillLayoutData() const { mpControlData->mpLayoutData = new vcl::ControlLayoutData(); - AppendLayoutData( *mpSubEdit ); - mpSubEdit->SetLayoutDataParent( this ); - ImplListBoxWindow* rMainWindow = mpImplLB->GetMainWindow(); - if( mpFloatWin ) + AppendLayoutData( *m_pImpl->m_pSubEdit ); + m_pImpl->m_pSubEdit->SetLayoutDataParent( this ); + ImplListBoxWindow* rMainWindow = m_pImpl->m_pImplLB->GetMainWindow(); + if (m_pImpl->m_pFloatWin) { // dropdown mode - if( mpFloatWin->IsReallyVisible() ) + if (m_pImpl->m_pFloatWin->IsReallyVisible()) { AppendLayoutData( *rMainWindow ); rMainWindow->SetLayoutDataParent( this ); @@ -612,60 +675,60 @@ void ComboBox::StateChanged( StateChangedType nType ) if ( nType == StateChangedType::ReadOnly ) { - mpImplLB->SetReadOnly( IsReadOnly() ); - if ( mpBtn ) - mpBtn->Enable( IsEnabled() && !IsReadOnly() ); + m_pImpl->m_pImplLB->SetReadOnly( IsReadOnly() ); + if (m_pImpl->m_pBtn) + m_pImpl->m_pBtn->Enable( IsEnabled() && !IsReadOnly() ); } else if ( nType == StateChangedType::Enable ) { - mpSubEdit->Enable( IsEnabled() ); - mpImplLB->Enable( IsEnabled() && !IsReadOnly() ); - if ( mpBtn ) - mpBtn->Enable( IsEnabled() && !IsReadOnly() ); + m_pImpl->m_pSubEdit->Enable( IsEnabled() ); + m_pImpl->m_pImplLB->Enable( IsEnabled() && !IsReadOnly() ); + if (m_pImpl->m_pBtn) + m_pImpl->m_pBtn->Enable( IsEnabled() && !IsReadOnly() ); Invalidate(); } else if( nType == StateChangedType::UpdateMode ) { - mpImplLB->SetUpdateMode( IsUpdateMode() ); + m_pImpl->m_pImplLB->SetUpdateMode( IsUpdateMode() ); } else if ( nType == StateChangedType::Zoom ) { - mpImplLB->SetZoom( GetZoom() ); - mpSubEdit->SetZoom( GetZoom() ); + m_pImpl->m_pImplLB->SetZoom( GetZoom() ); + m_pImpl->m_pSubEdit->SetZoom( GetZoom() ); ImplCalcEditHeight(); Resize(); } else if ( nType == StateChangedType::ControlFont ) { - mpImplLB->SetControlFont( GetControlFont() ); - mpSubEdit->SetControlFont( GetControlFont() ); + m_pImpl->m_pImplLB->SetControlFont( GetControlFont() ); + m_pImpl->m_pSubEdit->SetControlFont( GetControlFont() ); ImplCalcEditHeight(); Resize(); } else if ( nType == StateChangedType::ControlForeground ) { - mpImplLB->SetControlForeground( GetControlForeground() ); - mpSubEdit->SetControlForeground( GetControlForeground() ); + m_pImpl->m_pImplLB->SetControlForeground( GetControlForeground() ); + m_pImpl->m_pSubEdit->SetControlForeground( GetControlForeground() ); } else if ( nType == StateChangedType::ControlBackground ) { - mpImplLB->SetControlBackground( GetControlBackground() ); - mpSubEdit->SetControlBackground( GetControlBackground() ); + m_pImpl->m_pImplLB->SetControlBackground( GetControlBackground() ); + m_pImpl->m_pSubEdit->SetControlBackground( GetControlBackground() ); } else if ( nType == StateChangedType::Style ) { SetStyle( ImplInitStyle( GetStyle() ) ); - mpImplLB->GetMainWindow()->EnableSort( ( GetStyle() & WB_SORT ) != 0 ); + m_pImpl->m_pImplLB->GetMainWindow()->EnableSort( ( GetStyle() & WB_SORT ) != 0 ); } else if( nType == StateChangedType::Mirroring ) { - if( mpBtn ) + if (m_pImpl->m_pBtn) { - mpBtn->EnableRTL( IsRTLEnabled() ); - ImplInitDropDownButton( mpBtn ); + m_pImpl->m_pBtn->EnableRTL( IsRTLEnabled() ); + ImplInitDropDownButton( m_pImpl->m_pBtn ); } - mpSubEdit->CompatStateChanged( StateChangedType::Mirroring ); - mpImplLB->EnableRTL( IsRTLEnabled() ); + m_pImpl->m_pSubEdit->CompatStateChanged( StateChangedType::Mirroring ); + m_pImpl->m_pImplLB->EnableRTL( IsRTLEnabled() ); Resize(); } } @@ -679,13 +742,13 @@ void ComboBox::DataChanged( const DataChangedEvent& rDCEvt ) ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) ) { - if ( mpBtn ) + if (m_pImpl->m_pBtn) { - mpBtn->SetSettings( GetSettings() ); - ImplInitDropDownButton( mpBtn ); + m_pImpl->m_pBtn->SetSettings( GetSettings() ); + ImplInitDropDownButton( m_pImpl->m_pBtn ); } Resize(); - mpImplLB->Resize(); // not called by ComboBox::Resize() if ImplLB is unchanged + m_pImpl->m_pImplLB->Resize(); // not called by ComboBox::Resize() if ImplLB is unchanged SetBackground(); // due to a hack in Window::UpdateSettings the background must be reset // otherwise it will overpaint NWF drawn comboboxes @@ -701,8 +764,9 @@ bool ComboBox::PreNotify( NotifyEvent& rNEvt ) bool ComboBox::Notify( NotifyEvent& rNEvt ) { bool nDone = false; - if( ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) && ( rNEvt.GetWindow() == mpSubEdit ) - && !IsReadOnly() ) + if ((rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) + && (rNEvt.GetWindow() == m_pImpl->m_pSubEdit) + && !IsReadOnly()) { KeyEvent aKeyEvt = *rNEvt.GetKeyEvent(); sal_uInt16 nKeyCode = aKeyEvt.GetKeyCode().GetCode(); @@ -713,51 +777,55 @@ bool ComboBox::Notify( NotifyEvent& rNEvt ) case KEY_PAGEUP: case KEY_PAGEDOWN: { - ImplUpdateFloatSelection(); - if( ( nKeyCode == KEY_DOWN ) && mpFloatWin && !mpFloatWin->IsInPopupMode() && aKeyEvt.GetKeyCode().IsMod2() ) + m_pImpl->ImplUpdateFloatSelection(); + if ((nKeyCode == KEY_DOWN) && m_pImpl->m_pFloatWin + && !m_pImpl->m_pFloatWin->IsInPopupMode() + && aKeyEvt.GetKeyCode().IsMod2()) { CallEventListeners( VCLEVENT_DROPDOWN_PRE_OPEN ); - mpBtn->SetPressed( true ); - if ( mpImplLB->GetEntryList()->GetMRUCount() ) - mpImplLB->SelectEntry( 0 , true ); + m_pImpl->m_pBtn->SetPressed( true ); + if (m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount()) + m_pImpl->m_pImplLB->SelectEntry( 0 , true ); SetSelection( Selection( 0, SELECTION_MAX ) ); - mpFloatWin->StartFloat( false ); + m_pImpl->m_pFloatWin->StartFloat( false ); CallEventListeners( VCLEVENT_DROPDOWN_OPEN ); nDone = true; } - else if( ( nKeyCode == KEY_UP ) && mpFloatWin && mpFloatWin->IsInPopupMode() && aKeyEvt.GetKeyCode().IsMod2() ) + else if ((nKeyCode == KEY_UP) && m_pImpl->m_pFloatWin + && m_pImpl->m_pFloatWin->IsInPopupMode() + && aKeyEvt.GetKeyCode().IsMod2()) { - mpFloatWin->EndPopupMode(); + m_pImpl->m_pFloatWin->EndPopupMode(); nDone = true; } else { - nDone = mpImplLB->ProcessKeyInput( aKeyEvt ); + nDone = m_pImpl->m_pImplLB->ProcessKeyInput( aKeyEvt ); } } break; case KEY_RETURN: { - if( ( rNEvt.GetWindow() == mpSubEdit ) && IsInDropDown() ) + if ((rNEvt.GetWindow() == m_pImpl->m_pSubEdit) && IsInDropDown()) { - mpImplLB->ProcessKeyInput( aKeyEvt ); + m_pImpl->m_pImplLB->ProcessKeyInput( aKeyEvt ); nDone = true; } } break; } } - else if ( (rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS) && mpFloatWin ) + else if ((rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS) && m_pImpl->m_pFloatWin) { - if( mpFloatWin->HasChildPathFocus() ) - mpSubEdit->GrabFocus(); - else if ( mpFloatWin->IsInPopupMode() && !HasChildPathFocus( true ) ) - mpFloatWin->EndPopupMode(); + if (m_pImpl->m_pFloatWin->HasChildPathFocus()) + m_pImpl->m_pSubEdit->GrabFocus(); + else if (m_pImpl->m_pFloatWin->IsInPopupMode() && !HasChildPathFocus(true)) + m_pImpl->m_pFloatWin->EndPopupMode(); } else if( (rNEvt.GetType() == MouseNotifyEvent::COMMAND) && (rNEvt.GetCommandEvent()->GetCommand() == CommandEventId::Wheel) && - (rNEvt.GetWindow() == mpSubEdit) ) + (rNEvt.GetWindow() == m_pImpl->m_pSubEdit) ) { MouseWheelBehaviour nWheelBehavior( GetSettings().GetMouseSettings().GetWheelBehavior() ); if ( ( nWheelBehavior == MouseWheelBehaviour::ALWAYS ) @@ -766,16 +834,17 @@ bool ComboBox::Notify( NotifyEvent& rNEvt ) ) ) { - nDone = mpImplLB->HandleWheelAsCursorTravel( *rNEvt.GetCommandEvent() ); + nDone = m_pImpl->m_pImplLB->HandleWheelAsCursorTravel( *rNEvt.GetCommandEvent() ); } else { nDone = false; // don't eat this event, let the default handling happen (i.e. scroll the context) } } - else if( ( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN ) && ( rNEvt.GetWindow() == mpImplLB->GetMainWindow() ) ) + else if ((rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN) + && (rNEvt.GetWindow() == m_pImpl->m_pImplLB->GetMainWindow())) { - mpSubEdit->GrabFocus(); + m_pImpl->m_pSubEdit->GrabFocus(); } return nDone || Edit::Notify( rNEvt ); @@ -786,7 +855,7 @@ void ComboBox::SetText( const OUString& rStr ) CallEventListeners( VCLEVENT_COMBOBOX_SETTEXT ); Edit::SetText( rStr ); - ImplUpdateFloatSelection(); + m_pImpl->ImplUpdateFloatSelection(); } void ComboBox::SetText( const OUString& rStr, const Selection& rNewSelection ) @@ -794,85 +863,86 @@ void ComboBox::SetText( const OUString& rStr, const Selection& rNewSelection ) CallEventListeners( VCLEVENT_COMBOBOX_SETTEXT ); Edit::SetText( rStr, rNewSelection ); - ImplUpdateFloatSelection(); + m_pImpl->ImplUpdateFloatSelection(); } void ComboBox::Modify() { - if ( !mbSyntheticModify ) - ImplUpdateFloatSelection(); + if (!m_pImpl->m_isSyntheticModify) + m_pImpl->ImplUpdateFloatSelection(); Edit::Modify(); } -void ComboBox::ImplUpdateFloatSelection() +void ComboBox::Impl::ImplUpdateFloatSelection() { - if (!mpImplLB || !mpSubEdit) + if (!m_pImplLB || m_pSubEdit) return; // move text in the ListBox into the visible region - mpImplLB->SetCallSelectionChangedHdl( false ); - if ( !IsMultiSelectionEnabled() ) + m_pImplLB->SetCallSelectionChangedHdl( false ); + if (!m_rThis.IsMultiSelectionEnabled()) { - OUString aSearchStr( mpSubEdit->GetText() ); + OUString aSearchStr( m_pSubEdit->GetText() ); sal_Int32 nSelect = LISTBOX_ENTRY_NOTFOUND; bool bSelect = true; - if ( mpImplLB->GetCurrentPos() != LISTBOX_ENTRY_NOTFOUND ) + if (m_pImplLB->GetCurrentPos() != LISTBOX_ENTRY_NOTFOUND) { - OUString aCurrent = mpImplLB->GetEntryList()->GetEntryText( mpImplLB->GetCurrentPos() ); + OUString aCurrent = m_pImplLB->GetEntryList()->GetEntryText( + m_pImplLB->GetCurrentPos()); if ( aCurrent == aSearchStr ) - nSelect = mpImplLB->GetCurrentPos(); + nSelect = m_pImplLB->GetCurrentPos(); } if ( nSelect == LISTBOX_ENTRY_NOTFOUND ) - nSelect = mpImplLB->GetEntryList()->FindEntry( aSearchStr ); + nSelect = m_pImplLB->GetEntryList()->FindEntry( aSearchStr ); if ( nSelect == LISTBOX_ENTRY_NOTFOUND ) { - nSelect = mpImplLB->GetEntryList()->FindMatchingEntry( aSearchStr ); + nSelect = m_pImplLB->GetEntryList()->FindMatchingEntry( aSearchStr ); bSelect = false; } if( nSelect != LISTBOX_ENTRY_NOTFOUND ) { - if ( !mpImplLB->IsVisible( nSelect ) ) - mpImplLB->ShowProminentEntry( nSelect ); - mpImplLB->SelectEntry( nSelect, bSelect ); + if (!m_pImplLB->IsVisible(nSelect)) + m_pImplLB->ShowProminentEntry( nSelect ); + m_pImplLB->SelectEntry( nSelect, bSelect ); } else { - nSelect = mpImplLB->GetEntryList()->GetSelectEntryPos( 0 ); + nSelect = m_pImplLB->GetEntryList()->GetSelectEntryPos( 0 ); if( nSelect != LISTBOX_ENTRY_NOTFOUND ) - mpImplLB->SelectEntry( nSelect, false ); - mpImplLB->ResetCurrentPos(); + m_pImplLB->SelectEntry( nSelect, false ); + m_pImplLB->ResetCurrentPos(); } } else { ::std::set< sal_Int32 > aSelInText; - lcl_GetSelectedEntries( aSelInText, mpSubEdit->GetText(), mcMultiSep, mpImplLB->GetEntryList() ); - for ( sal_Int32 n = 0; n < mpImplLB->GetEntryList()->GetEntryCount(); n++ ) - mpImplLB->SelectEntry( n, aSelInText.count( n ) ); + lcl_GetSelectedEntries(aSelInText, m_pSubEdit->GetText(), m_cMultiSep, m_pImplLB->GetEntryList()); + for (sal_Int32 n = 0; n < m_pImplLB->GetEntryList()->GetEntryCount(); n++) + m_pImplLB->SelectEntry( n, aSelInText.count( n ) ); } - mpImplLB->SetCallSelectionChangedHdl( true ); + m_pImplLB->SetCallSelectionChangedHdl( true ); } sal_Int32 ComboBox::InsertEntry(const OUString& rStr, sal_Int32 const nPos) { - assert(nPos >= 0 && COMBOBOX_MAX_ENTRIES > mpImplLB->GetEntryList()->GetEntryCount()); + assert(nPos >= 0 && COMBOBOX_MAX_ENTRIES > m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount()); sal_Int32 nRealPos; if (nPos == COMBOBOX_APPEND) nRealPos = nPos; else { - const sal_Int32 nMRUCount = mpImplLB->GetEntryList()->GetMRUCount(); + const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); assert(nPos <= COMBOBOX_MAX_ENTRIES - nMRUCount); nRealPos = nPos + nMRUCount; } - nRealPos = mpImplLB->InsertEntry( nRealPos, rStr ); - nRealPos -= mpImplLB->GetEntryList()->GetMRUCount(); + nRealPos = m_pImpl->m_pImplLB->InsertEntry( nRealPos, rStr ); + nRealPos -= m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); CallEventListeners( VCLEVENT_COMBOBOX_ITEMADDED, reinterpret_cast<void*>(nRealPos) ); return nRealPos; } @@ -880,20 +950,20 @@ sal_Int32 ComboBox::InsertEntry(const OUString& rStr, sal_Int32 const nPos) sal_Int32 ComboBox::InsertEntryWithImage( const OUString& rStr, const Image& rImage, sal_Int32 const nPos) { - assert(nPos >= 0 && COMBOBOX_MAX_ENTRIES > mpImplLB->GetEntryList()->GetEntryCount()); + assert(nPos >= 0 && COMBOBOX_MAX_ENTRIES > m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount()); sal_Int32 nRealPos; if (nPos == COMBOBOX_APPEND) nRealPos = nPos; else { - const sal_Int32 nMRUCount = mpImplLB->GetEntryList()->GetMRUCount(); + const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); assert(nPos <= COMBOBOX_MAX_ENTRIES - nMRUCount); nRealPos = nPos + nMRUCount; } - nRealPos = mpImplLB->InsertEntry( nRealPos, rStr, rImage ); - nRealPos -= mpImplLB->GetEntryList()->GetMRUCount(); + nRealPos = m_pImpl->m_pImplLB->InsertEntry( nRealPos, rStr, rImage ); + nRealPos -= m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); CallEventListeners( VCLEVENT_COMBOBOX_ITEMADDED, reinterpret_cast<void*>(nRealPos) ); return nRealPos; } @@ -905,81 +975,92 @@ void ComboBox::RemoveEntry( const OUString& rStr ) void ComboBox::RemoveEntryAt(sal_Int32 const nPos) { - const sal_Int32 nMRUCount = mpImplLB->GetEntryList()->GetMRUCount(); + const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); if (nPos < 0 || nPos > COMBOBOX_MAX_ENTRIES - nMRUCount) return; - mpImplLB->RemoveEntry( nPos + nMRUCount ); + m_pImpl->m_pImplLB->RemoveEntry( nPos + nMRUCount ); CallEventListeners( VCLEVENT_COMBOBOX_ITEMREMOVED, reinterpret_cast<void*>(nPos) ); } void ComboBox::Clear() { - mpImplLB->Clear(); + m_pImpl->m_pImplLB->Clear(); CallEventListeners( VCLEVENT_COMBOBOX_ITEMREMOVED, reinterpret_cast<void*>(-1) ); } Image ComboBox::GetEntryImage( sal_Int32 nPos ) const { - if ( mpImplLB->GetEntryList()->HasEntryImage( nPos ) ) - return mpImplLB->GetEntryList()->GetEntryImage( nPos ); + if (m_pImpl->m_pImplLB->GetEntryList()->HasEntryImage(nPos)) + return m_pImpl->m_pImplLB->GetEntryList()->GetEntryImage( nPos ); return Image(); } sal_Int32 ComboBox::GetEntryPos( const OUString& rStr ) const { - sal_Int32 nPos = mpImplLB->GetEntryList()->FindEntry( rStr ); + sal_Int32 nPos = m_pImpl->m_pImplLB->GetEntryList()->FindEntry( rStr ); if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - nPos -= mpImplLB->GetEntryList()->GetMRUCount(); + nPos -= m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); return nPos; } sal_Int32 ComboBox::GetEntryPos( const void* pData ) const { - sal_Int32 nPos = mpImplLB->GetEntryList()->FindEntry( pData ); + sal_Int32 nPos = m_pImpl->m_pImplLB->GetEntryList()->FindEntry( pData ); if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - nPos = nPos - mpImplLB->GetEntryList()->GetMRUCount(); + nPos = nPos - m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); return nPos; } OUString ComboBox::GetEntry( sal_Int32 nPos ) const { - const sal_Int32 nMRUCount = mpImplLB->GetEntryList()->GetMRUCount(); + const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); if (nPos < 0 || nPos > COMBOBOX_MAX_ENTRIES - nMRUCount) return OUString(); - return mpImplLB->GetEntryList()->GetEntryText( nPos + nMRUCount ); + return m_pImpl->m_pImplLB->GetEntryList()->GetEntryText( nPos + nMRUCount ); } sal_Int32 ComboBox::GetEntryCount() const { - return mpImplLB->GetEntryList()->GetEntryCount() - mpImplLB->GetEntryList()->GetMRUCount(); + return m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount() - m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(); } bool ComboBox::IsTravelSelect() const { - return mpImplLB->IsTravelSelect(); + return m_pImpl->m_pImplLB->IsTravelSelect(); } bool ComboBox::IsInDropDown() const { - return mpFloatWin && mpFloatWin->IsInPopupMode(); + return m_pImpl->m_pFloatWin && m_pImpl->m_pFloatWin->IsInPopupMode(); } +void ComboBox::SetMultiSelectionSeparator(sal_Unicode cSep) { m_pImpl->m_cMultiSep = cSep; } +sal_Unicode ComboBox::GetMultiSelectionSeparator() const { return m_pImpl->m_cMultiSep; } + void ComboBox::EnableMultiSelection( bool bMulti ) { - mpImplLB->EnableMultiSelection( bMulti, false ); - mpImplLB->SetMultiSelectionSimpleMode( true ); + m_pImpl->m_pImplLB->EnableMultiSelection( bMulti, false ); + m_pImpl->m_pImplLB->SetMultiSelectionSimpleMode( true ); } bool ComboBox::IsMultiSelectionEnabled() const { - return mpImplLB->IsMultiSelectionEnabled(); + return m_pImpl->m_pImplLB->IsMultiSelectionEnabled(); } +void ComboBox::SetSelectHdl(const Link<>& rLink) { m_pImpl->m_SelectHdl = rLink; } + +const Link<>& ComboBox::GetSelectHdl() const { return m_pImpl->m_SelectHdl; } + +void ComboBox::SetDoubleClickHdl(const Link<>& rLink) { m_pImpl->m_DoubleClickHdl = rLink; } + +const Link<>& ComboBox::GetDoubleClickHdl() const { return m_pImpl->m_DoubleClickHdl; } + long ComboBox::CalcWindowSizePixel( sal_uInt16 nLines ) const { - return mpImplLB->GetEntryHeight() * nLines; + return m_pImpl->m_pImplLB->GetEntryHeight() * nLines; } Size ComboBox::GetOptimalSize() const @@ -1014,30 +1095,30 @@ Size ComboBox::CalcMinimumSize() const { Size aSz; - if (!mpImplLB) + if (!m_pImpl->m_pImplLB) return aSz; if (!IsDropDownBox()) { - aSz = mpImplLB->CalcSize( mpImplLB->GetEntryList()->GetEntryCount() ); - aSz.Height() += mnDDHeight; + aSz = m_pImpl->m_pImplLB->CalcSize( m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount() ); + aSz.Height() += m_pImpl->m_nDDHeight; } else { aSz.Height() = Edit::CalcMinimumSizeForText(GetText()).Height(); - aSz.Width() = mpImplLB->GetMaxEntryWidth(); + aSz.Width() = m_pImpl->m_pImplLB->GetMaxEntryWidth(); } - if (m_nMaxWidthChars != -1) + if (m_pImpl->m_nMaxWidthChars != -1) { - long nMaxWidth = m_nMaxWidthChars * approximate_char_width(); + long nMaxWidth = m_pImpl->m_nMaxWidthChars * approximate_char_width(); aSz.Width() = std::min(aSz.Width(), nMaxWidth); } if (IsDropDownBox()) aSz.Width() += getMaxWidthScrollBarAndDownButton(); - ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds( + ComboBoxBounds aBounds(m_pImpl->calcComboBoxDropDownComponentBounds( Size(0xFFFF, 0xFFFF), Size(0xFFFF, 0xFFFF))); aSz.Width() += aBounds.aSubEditPos.X()*2; @@ -1060,11 +1141,11 @@ Size ComboBox::CalcAdjustedSize( const Size& rPrefSize ) const if ( nLines < 1 ) nLines = 1; aSz.Height() = nLines * nEntryHeight; - aSz.Height() += mnDDHeight; + aSz.Height() += m_pImpl->m_nDDHeight; } else { - aSz.Height() = mnDDHeight; + aSz.Height() = m_pImpl->m_nDDHeight; } aSz.Height() += nTop+nBottom; @@ -1082,9 +1163,9 @@ Size ComboBox::CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const if ( nLines ) { if ( !IsDropDownBox() ) - aSz.Height() = mpImplLB->CalcSize( nLines ).Height() + mnDDHeight; + aSz.Height() = m_pImpl->m_pImplLB->CalcSize( nLines ).Height() + m_pImpl->m_nDDHeight; else - aSz.Height() = mnDDHeight; + aSz.Height() = m_pImpl->m_nDDHeight; } else aSz.Height() = aMinSz.Height(); @@ -1117,13 +1198,13 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines long nCharWidth = GetTextWidth(OUString(static_cast<sal_Unicode>('x'))); if ( !IsDropDownBox() ) { - Size aOutSz = mpImplLB->GetMainWindow()->GetOutputSizePixel(); + Size aOutSz = m_pImpl->m_pImplLB->GetMainWindow()->GetOutputSizePixel(); rnCols = (nCharWidth > 0) ? (sal_uInt16)(aOutSz.Width()/nCharWidth) : 1; - rnLines = (sal_uInt16)(aOutSz.Height()/mpImplLB->GetEntryHeight()); + rnLines = (sal_uInt16)(aOutSz.Height()/m_pImpl->m_pImplLB->GetEntryHeight()); } else { - Size aOutSz = mpSubEdit->GetOutputSizePixel(); + Size aOutSz = m_pImpl->m_pSubEdit->GetOutputSizePixel(); rnCols = (nCharWidth > 0) ? (sal_uInt16)(aOutSz.Width()/nCharWidth) : 1; rnLines = 1; } @@ -1131,11 +1212,11 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) { - mpImplLB->GetMainWindow()->ApplySettings(*pDev); + m_pImpl->m_pImplLB->GetMainWindow()->ApplySettings(*pDev); Point aPos = pDev->LogicToPixel( rPos ); Size aSize = pDev->LogicToPixel( rSize ); - vcl::Font aFont = mpImplLB->GetMainWindow()->GetDrawPixelFont( pDev ); + vcl::Font aFont = m_pImpl->m_pImplLB->GetMainWindow()->GetDrawPixelFont( pDev ); OutDevType eOutDevType = pDev->GetOutDevType(); pDev->Push(); @@ -1172,7 +1253,7 @@ void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, D DrawTextFlags nTextStyle = DrawTextFlags::VCenter; // First, draw the edit part - mpSubEdit->Draw( pDev, aPos, Size( aSize.Width(), nEditHeight ), nFlags ); + m_pImpl->m_pSubEdit->Draw( pDev, aPos, Size( aSize.Width(), nEditHeight ), nFlags ); // Second, draw the listbox if ( GetStyle() & WB_CENTER ) @@ -1204,7 +1285,7 @@ void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, D sal_uInt16 nLines = (sal_uInt16) ( ( nTextHeight > 0 ) ? ( (aSize.Height()-nEditHeight) / nTextHeight ) : 1 ); if ( !nLines ) nLines = 1; - sal_uInt16 nTEntry = IsReallyVisible() ? mpImplLB->GetTopEntry() : 0; + sal_uInt16 nTEntry = IsReallyVisible() ? m_pImpl->m_pImplLB->GetTopEntry() : 0; Rectangle aTextRect( aPos, aSize ); @@ -1216,7 +1297,7 @@ void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, D // the drawing starts here for ( sal_uInt16 n = 0; n < nLines; n++ ) { - pDev->DrawText( aTextRect, mpImplLB->GetEntryList()->GetEntryText( n+nTEntry ), nTextStyle ); + pDev->DrawText( aTextRect, m_pImpl->m_pImplLB->GetEntryList()->GetEntryText( n+nTEntry ), nTextStyle ); aTextRect.Top() += nTextHeight; aTextRect.Bottom() += nTextHeight; } @@ -1227,15 +1308,15 @@ void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, D // Call Edit::Draw after restoring the MapMode... if ( IsDropDownBox() ) { - mpSubEdit->Draw( pDev, rPos, rSize, nFlags ); + m_pImpl->m_pSubEdit->Draw( pDev, rPos, rSize, nFlags ); // DD-Button ? } } -void::ComboBox::ImplUserDrawHandler( UserDrawEvent* pEvent ) +void::ComboBox::Impl::ImplUserDrawHandler( UserDrawEvent* pEvent ) { - UserDraw( *pEvent ); + m_rThis.UserDraw(*pEvent); } void ComboBox::UserDraw( const UserDrawEvent& ) @@ -1244,84 +1325,87 @@ void ComboBox::UserDraw( const UserDrawEvent& ) void ComboBox::SetUserItemSize( const Size& rSz ) { - mpImplLB->GetMainWindow()->SetUserItemSize( rSz ); + m_pImpl->m_pImplLB->GetMainWindow()->SetUserItemSize( rSz ); } void ComboBox::EnableUserDraw( bool bUserDraw ) { - mpImplLB->GetMainWindow()->EnableUserDraw( bUserDraw ); + m_pImpl->m_pImplLB->GetMainWindow()->EnableUserDraw( bUserDraw ); } void ComboBox::DrawEntry(const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos) { - DBG_ASSERT(rEvt.GetWindow() == mpImplLB->GetMainWindow(), "DrawEntry?!"); - mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetRenderContext(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos); + DBG_ASSERT(rEvt.GetWindow() == m_pImpl->m_pImplLB->GetMainWindow(), "DrawEntry?!"); + m_pImpl->m_pImplLB->GetMainWindow()->DrawEntry(*rEvt.GetRenderContext(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos); } void ComboBox::SetSeparatorPos( sal_Int32 n ) { - mpImplLB->SetSeparatorPos( n ); + m_pImpl->m_pImplLB->SetSeparatorPos( n ); } void ComboBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep ) { - mpImplLB->SetMRUEntries( rEntries, cSep ); + m_pImpl->m_pImplLB->SetMRUEntries( rEntries, cSep ); } OUString ComboBox::GetMRUEntries( sal_Unicode cSep ) const { - return mpImplLB ? mpImplLB->GetMRUEntries( cSep ) : OUString(); + return m_pImpl->m_pImplLB ? m_pImpl->m_pImplLB->GetMRUEntries( cSep ) : OUString(); } void ComboBox::SetMaxMRUCount( sal_Int32 n ) { - mpImplLB->SetMaxMRUCount( n ); + m_pImpl->m_pImplLB->SetMaxMRUCount( n ); } sal_Int32 ComboBox::GetMaxMRUCount() const { - return mpImplLB ? mpImplLB->GetMaxMRUCount() : 0; + return m_pImpl->m_pImplLB ? m_pImpl->m_pImplLB->GetMaxMRUCount() : 0; } sal_uInt16 ComboBox::GetDisplayLineCount() const { - return mpImplLB ? mpImplLB->GetDisplayLineCount() : 0; + return m_pImpl->m_pImplLB ? m_pImpl->m_pImplLB->GetDisplayLineCount() : 0; } void ComboBox::SetEntryData( sal_Int32 nPos, void* pNewData ) { - mpImplLB->SetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount(), pNewData ); + m_pImpl->m_pImplLB->SetEntryData( nPos + m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(), pNewData ); } void* ComboBox::GetEntryData( sal_Int32 nPos ) const { - return mpImplLB->GetEntryList()->GetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount() ); + return m_pImpl->m_pImplLB->GetEntryList()->GetEntryData( + nPos + m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount() ); } sal_Int32 ComboBox::GetTopEntry() const { - sal_Int32 nPos = GetEntryCount() ? mpImplLB->GetTopEntry() : LISTBOX_ENTRY_NOTFOUND; - if ( nPos < mpImplLB->GetEntryList()->GetMRUCount() ) + sal_Int32 nPos = GetEntryCount() ? m_pImpl->m_pImplLB->GetTopEntry() : LISTBOX_ENTRY_NOTFOUND; + if (nPos < m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount()) nPos = 0; return nPos; } void ComboBox::SetProminentEntryType( ProminentEntry eType ) { - mpImplLB->SetProminentEntryType( eType ); + m_pImpl->m_pImplLB->SetProminentEntryType( eType ); } Rectangle ComboBox::GetDropDownPosSizePixel() const { - return mpFloatWin ? mpFloatWin->GetWindowExtentsRelative( const_cast<ComboBox*>(this) ) : Rectangle(); + return m_pImpl->m_pFloatWin + ? m_pImpl->m_pFloatWin->GetWindowExtentsRelative(const_cast<ComboBox*>(this)) + : Rectangle(); } const Wallpaper& ComboBox::GetDisplayBackground() const { - if( ! mpSubEdit->IsBackground() ) + if (!m_pImpl->m_pSubEdit->IsBackground()) return Control::GetDisplayBackground(); - const Wallpaper& rBack = mpSubEdit->GetBackground(); + const Wallpaper& rBack = m_pImpl->m_pSubEdit->GetBackground(); if( ! rBack.IsBitmap() && ! rBack.IsGradient() && rBack.GetColor().GetColor() == COL_TRANSPARENT @@ -1332,42 +1416,44 @@ const Wallpaper& ComboBox::GetDisplayBackground() const sal_Int32 ComboBox::GetSelectEntryCount() const { - return mpImplLB->GetEntryList()->GetSelectEntryCount(); + return m_pImpl->m_pImplLB->GetEntryList()->GetSelectEntryCount(); } sal_Int32 ComboBox::GetSelectEntryPos( sal_Int32 nIndex ) const { - sal_Int32 nPos = mpImplLB->GetEntryList()->GetSelectEntryPos( nIndex ); + sal_Int32 nPos = m_pImpl->m_pImplLB->GetEntryList()->GetSelectEntryPos( nIndex ); if ( nPos != LISTBOX_ENTRY_NOTFOUND ) { - if ( nPos < mpImplLB->GetEntryList()->GetMRUCount() ) - nPos = mpImplLB->GetEntryList()->FindEntry( mpImplLB->GetEntryList()->GetEntryText( nPos ) ); - nPos = sal::static_int_cast<sal_Int32>(nPos - mpImplLB->GetEntryList()->GetMRUCount()); + if (nPos < m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount()) + nPos = m_pImpl->m_pImplLB->GetEntryList()->FindEntry(m_pImpl->m_pImplLB->GetEntryList()->GetEntryText(nPos)); + nPos = sal::static_int_cast<sal_Int32>(nPos - m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount()); } return nPos; } bool ComboBox::IsEntryPosSelected( sal_Int32 nPos ) const { - return mpImplLB->GetEntryList()->IsEntryPosSelected( nPos + mpImplLB->GetEntryList()->GetMRUCount() ); + return m_pImpl->m_pImplLB->GetEntryList()->IsEntryPosSelected( + nPos + m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount() ); } void ComboBox::SelectEntryPos( sal_Int32 nPos, bool bSelect) { - if ( nPos < mpImplLB->GetEntryList()->GetEntryCount() ) - mpImplLB->SelectEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), bSelect ); + if (nPos < m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount()) + m_pImpl->m_pImplLB->SelectEntry( + nPos + m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(), bSelect); } void ComboBox::SetNoSelection() { - mpImplLB->SetNoSelection(); - mpSubEdit->SetText( OUString() ); + m_pImpl->m_pImplLB->SetNoSelection(); + m_pImpl->m_pSubEdit->SetText( OUString() ); } Rectangle ComboBox::GetBoundingRectangle( sal_Int32 nItem ) const { - Rectangle aRect = mpImplLB->GetMainWindow()->GetBoundingRectangle( nItem ); - Rectangle aOffset = mpImplLB->GetMainWindow()->GetWindowExtentsRelative( static_cast<vcl::Window*>(const_cast<ComboBox *>(this)) ); + Rectangle aRect = m_pImpl->m_pImplLB->GetMainWindow()->GetBoundingRectangle( nItem ); + Rectangle aOffset = m_pImpl->m_pImplLB->GetMainWindow()->GetWindowExtentsRelative( static_cast<vcl::Window*>(const_cast<ComboBox *>(this)) ); aRect.Move( aOffset.TopLeft().X(), aOffset.TopLeft().Y() ); return aRect; } @@ -1377,8 +1463,8 @@ void ComboBox::SetBorderStyle( WindowBorderStyle nBorderStyle ) Window::SetBorderStyle( nBorderStyle ); if ( !IsDropDownBox() ) { - mpSubEdit->SetBorderStyle( nBorderStyle ); - mpImplLB->SetBorderStyle( nBorderStyle ); + m_pImpl->m_pSubEdit->SetBorderStyle( nBorderStyle ); + m_pImpl->m_pImplLB->SetBorderStyle( nBorderStyle ); } } @@ -1393,7 +1479,7 @@ long ComboBox::GetIndexForPoint( const Point& rPoint, sal_Int32& rPos ) const { // point must be either in main list window // or in impl window (dropdown case) - ImplListBoxWindow* rMain = mpImplLB->GetMainWindow(); + ImplListBoxWindow* rMain = m_pImpl->m_pImplLB->GetMainWindow(); // convert coordinates to ImplListBoxWindow pixel coordinate space Point aConvPoint = LogicToPixel( rPoint ); @@ -1416,15 +1502,15 @@ long ComboBox::GetIndexForPoint( const Point& rPoint, sal_Int32& rPos ) const return nIndex; } -ComboBox::ComboBoxBounds ComboBox::calcComboBoxDropDownComponentBounds(const Size &rOutSz, - const Size &rBorderOutSz) const +ComboBoxBounds ComboBox::Impl::calcComboBoxDropDownComponentBounds( + const Size &rOutSz, const Size &rBorderOutSz) const { ComboBoxBounds aBounds; long nTop = 0; long nBottom = rOutSz.Height(); - vcl::Window *pBorder = GetWindow( GetWindowType::Border ); + vcl::Window *pBorder = m_rThis.GetWindow( GetWindowType::Border ); ImplControlValue aControlValue; Point aPoint; Rectangle aContent, aBound; @@ -1432,18 +1518,18 @@ ComboBox::ComboBoxBounds ComboBox::calcComboBoxDropDownComponentBounds(const Siz // use the full extent of the control Rectangle aArea( aPoint, rBorderOutSz ); - if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_BUTTON_DOWN, + if (m_rThis.GetNativeControlRegion(CTRL_COMBOBOX, PART_BUTTON_DOWN, aArea, ControlState::NONE, aControlValue, OUString(), aBound, aContent) ) { // convert back from border space to local coordinates - aPoint = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aPoint ) ); + aPoint = pBorder->ScreenToOutputPixel(m_rThis.OutputToScreenPixel(aPoint)); aContent.Move(-aPoint.X(), -aPoint.Y()); aBounds.aButtonPos = Point(aContent.Left(), nTop); aBounds.aButtonSize = Size(aContent.getWidth(), (nBottom-nTop)); // adjust the size of the edit field - if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_SUB_EDIT, + if (m_rThis.GetNativeControlRegion(CTRL_COMBOBOX, PART_SUB_EDIT, aArea, ControlState::NONE, aControlValue, OUString(), aBound, aContent) ) { // convert back from border space to local coordinates @@ -1461,8 +1547,8 @@ ComboBox::ComboBoxBounds ComboBox::calcComboBoxDropDownComponentBounds(const Siz } else { - long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize(); - nSBWidth = CalcZoom( nSBWidth ); + long nSBWidth = m_rThis.GetSettings().GetStyleSettings().GetScrollBarSize(); + nSBWidth = m_rThis.CalcZoom( nSBWidth ); aBounds.aSubEditSize = Size(rOutSz.Width() - nSBWidth, rOutSz.Height()); aBounds.aButtonPos = Point(rOutSz.Width() - nSBWidth, nTop); aBounds.aButtonSize = Size(nSBWidth, (nBottom-nTop)); @@ -1470,11 +1556,13 @@ ComboBox::ComboBoxBounds ComboBox::calcComboBoxDropDownComponentBounds(const Siz return aBounds; } +sal_Int32 ComboBox::getMaxWidthChars() const { return m_pImpl->m_nMaxWidthChars; } + void ComboBox::setMaxWidthChars(sal_Int32 nWidth) { - if (nWidth != m_nMaxWidthChars) + if (nWidth != m_pImpl->m_nMaxWidthChars) { - m_nMaxWidthChars = nWidth; + m_pImpl->m_nMaxWidthChars = nWidth; queue_resize(); } } |