From 60285fdc868635f99644ef1d8a195a2be87074c7 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Mon, 22 Apr 2013 15:38:05 +0000 Subject: Related: #i122041# More unifications for FillStyles better defaults and better preview visualizations (cherry picked from commit 35c9acfc98fc98399005815e0464b1944f327d4e) Conflicts: officecfg/registry/schema/org/openoffice/Office/Common.xcs svtools/inc/svtools/accessibilityoptions.hxx svtools/inc/svtools/valueset.hxx svtools/source/config/accessibilityoptions.cxx svtools/source/control/ctrlbox.cxx svtools/source/control/valueset.cxx svtools/source/inc/configitems/accessibilityoptions_const.hxx svx/inc/svx/dlgctrl.hxx svx/inc/svx/xtable.hxx svx/source/dialog/dlgctrl.cxx svx/source/tbxctrls/SvxColorValueSet.cxx svx/source/xoutdev/xtabdash.cxx svx/source/xoutdev/xtable.cxx vcl/inc/ilstbox.hxx vcl/inc/vcl/combobox.hxx vcl/inc/vcl/lstbox.hxx vcl/inc/vcl/settings.hxx vcl/source/app/settings.cxx vcl/source/control/combobox.cxx vcl/source/control/ilstbox.cxx vcl/source/control/lstbox.cxx Change-Id: I905b6814cb796a35aa23fedb9ce716f77e2bfda0 --- vcl/inc/ilstbox.hxx | 165 ++++++++++++++++++---------------- vcl/source/app/settings.cxx | 41 ++++++++- vcl/source/control/combobox.cxx | 15 +++- vcl/source/control/ilstbox.cxx | 191 +++++++++++++++++++++++++--------------- vcl/source/control/lstbox.cxx | 56 ++++++++++-- 5 files changed, 317 insertions(+), 151 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/ilstbox.hxx b/vcl/inc/ilstbox.hxx index a18b2931709c..8962c1d79ee0 100644 --- a/vcl/inc/ilstbox.hxx +++ b/vcl/inc/ilstbox.hxx @@ -64,33 +64,33 @@ struct ImplEntryType long mnFlags; long mnHeight; - ImplEntryType( const OUString& rStr, const Image& rImage ) : - maStr( rStr ), - maImage( rImage ), - mnFlags( 0 ), - mnHeight( 0 ) - { - mbIsSelected = sal_False; - mpUserData = NULL; - } - - ImplEntryType( const OUString& rStr ) : - maStr( rStr ), - mnFlags( 0 ), - mnHeight( 0 ) - { - mbIsSelected = sal_False; - mpUserData = NULL; - } - - ImplEntryType( const Image& rImage ) : - maImage( rImage ), - mnFlags( 0 ), - mnHeight( 0 ) - { - mbIsSelected = sal_False; - mpUserData = NULL; - } + ImplEntryType( const OUString& rStr, const Image& rImage ) : + maStr( rStr ), + maImage( rImage ), + mnFlags( 0 ), + mnHeight( 0 ) + { + mbIsSelected = sal_False; + mpUserData = NULL; + } + + ImplEntryType( const OUString& rStr ) : + maStr( rStr ), + mnFlags( 0 ), + mnHeight( 0 ) + { + mbIsSelected = sal_False; + mpUserData = NULL; + } + + ImplEntryType( const Image& rImage ) : + maImage( rImage ), + mnFlags( 0 ), + mnHeight( 0 ) + { + mbIsSelected = sal_False; + mpUserData = NULL; + } }; // ----------------- @@ -226,24 +226,26 @@ private: sal_uInt16 mnSelectModifier; // Modifiers - sal_Bool mbHasFocusRect: 1, - mbSort: 1, // ListBox sorted - mbTrack: 1, // Tracking - mbMulti: 1, // MultiListBox - mbStackMode: 1, // StackSelection - mbSimpleMode: 1, // SimpleMode for MultiListBox - mbImgsDiffSz: 1, // Images have different sizes - mbTravelSelect: 1, // TravelSelect - mbTrackingSelect: 1, // Selected at a MouseMove - mbSelectionChanged: 1, // Do not call Select() too often ... - mbMouseMoveSelect: 1, // Select at MouseMove - mbGrabFocus: 1, // Grab focus at MBDown - mbUserDrawEnabled: 1, // UserDraw possible - mbInUserDraw: 1, // In UserDraw - mbReadOnly: 1, // ReadOnly - mbMirroring: 1, // pb: #106948# explicit mirroring for calc - mbRight: 1, // right align Text output - mbCenter: 1; // center Text output + /// bitfield + bool mbHasFocusRect : 1; + bool mbSort : 1; // ListBox sorted + bool mbTrack : 1; // Tracking + bool mbMulti : 1; // MultiListBox + bool mbStackMode : 1; // StackSelection + bool mbSimpleMode : 1; // SimpleMode for MultiListBox + bool mbImgsDiffSz : 1; // Images have different sizes + bool mbTravelSelect : 1; // TravelSelect + bool mbTrackingSelect : 1; // Selected at a MouseMove + bool mbSelectionChanged : 1; // Do not call Select() too often ... + bool mbMouseMoveSelect : 1; // Select at MouseMove + bool mbGrabFocus : 1; // Grab focus at MBDown + bool mbUserDrawEnabled : 1; // UserDraw possible + bool mbInUserDraw : 1; // In UserDraw + bool mbReadOnly : 1; // ReadOnly + bool mbMirroring : 1; // pb: #106948# explicit mirroring for calc + bool mbRight : 1; // right align Text output + bool mbCenter : 1; // center Text output + bool mbEdgeBlending : 1; Link maScrollHdl; Link maSelectHdl; @@ -252,8 +254,7 @@ private: Link maUserDrawHdl; Link maMRUChangedHdl; - ::vcl::QuickSelectionEngine - maQuickSelectionEngine; + ::vcl::QuickSelectionEngine maQuickSelectionEngine; protected: virtual void KeyInput( const KeyEvent& rKEvt ); @@ -318,31 +319,31 @@ public: void SetLeftIndent( long n ); void ScrollHorz( long nDiff ); - void AllowGrabFocus( sal_Bool b ) { mbGrabFocus = b; } - sal_Bool IsGrabFocusAllowed() const { return mbGrabFocus; } + void AllowGrabFocus( bool b ) { mbGrabFocus = b; } + bool IsGrabFocusAllowed() const { return mbGrabFocus; } void SetSeparatorPos( sal_uInt16 n ) { mnSeparatorPos = n; } sal_uInt16 GetSeparatorPos() const { return mnSeparatorPos; } - void SetTravelSelect( sal_Bool bTravelSelect ) { mbTravelSelect = bTravelSelect; } - sal_Bool IsTravelSelect() const { return mbTravelSelect; } - sal_Bool IsTrackingSelect() const { return mbTrackingSelect; } + void SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; } + bool IsTravelSelect() const { return mbTravelSelect; } + bool IsTrackingSelect() const { return mbTrackingSelect; } void SetUserItemSize( const Size& rSz ); const Size& GetUserItemSize() const { return maUserItemSize; } - void EnableUserDraw( sal_Bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } - sal_Bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } + void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } + bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } - void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; } - sal_Bool IsMultiSelectionEnabled() const { return mbMulti; } + void EnableMultiSelection( bool bMulti, bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; } + bool IsMultiSelectionEnabled() const { return mbMulti; } - void SetMultiSelectionSimpleMode( sal_Bool bSimple ) { mbSimpleMode = bSimple; } - sal_Bool IsMultiSelectionSimpleMode() const { return mbSimpleMode; } + void SetMultiSelectionSimpleMode( bool bSimple ) { mbSimpleMode = bSimple; } + bool IsMultiSelectionSimpleMode() const { return mbSimpleMode; } - void EnableMouseMoveSelect( sal_Bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; } - sal_Bool IsMouseMoveSelectEnabled() const { return mbMouseMoveSelect; } - sal_Bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; } + void EnableMouseMoveSelect( bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; } + bool IsMouseMoveSelectEnabled() const { return mbMouseMoveSelect; } + bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; } Size CalcSize( sal_uInt16 nMaxLines ) const; Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const; @@ -363,21 +364,24 @@ public: void SetMRUChangedHdl( const Link& rLink ) { maMRUChangedHdl = rLink; } const Link& GetMRUChangedHdl() const { return maMRUChangedHdl; } - sal_Bool IsSelectionChanged() const { return mbSelectionChanged; } + bool IsSelectionChanged() const { return mbSelectionChanged; } sal_uInt16 GetSelectModifier() const { return mnSelectModifier; } - void EnableSort( sal_Bool b ) { mbSort = b; } + void EnableSort( bool b ) { mbSort = b; } - void SetReadOnly( sal_Bool bReadOnly ) { mbReadOnly = bReadOnly; } - sal_Bool IsReadOnly() const { return mbReadOnly; } + void SetReadOnly( bool bReadOnly ) { mbReadOnly = bReadOnly; } + bool IsReadOnly() const { return mbReadOnly; } using Control::ImplInitSettings; void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); sal_uInt16 ImplGetTextStyle() const; // pb: #106948# explicit mirroring for calc - inline void EnableMirroring() { mbMirroring = sal_True; } - inline sal_Bool IsMirroring() const { return mbMirroring; } + inline void EnableMirroring() { mbMirroring = true; } + inline bool IsMirroring() const { return mbMirroring; } + + bool GetEdgeBlending() const { return mbEdgeBlending; } + void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; } protected: // ISearchableStringList @@ -397,9 +401,13 @@ private: ScrollBar* mpHScrollBar; ScrollBar* mpVScrollBar; ScrollBarBox* mpScrollBarBox; - sal_Bool mbVScroll : 1, // VScroll an oder aus - mbHScroll : 1, // HScroll an oder aus - mbAutoHScroll : 1; // AutoHScroll an oder aus + + /// bitfield + bool mbVScroll : 1; // VScroll an oder aus + bool mbHScroll : 1; // HScroll an oder aus + bool mbAutoHScroll : 1; // AutoHScroll an oder aus + bool mbEdgeBlending : 1; + Link maScrollHdl; // Weil der vom ImplListBoxWindow selbst benoetigt wird. ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; @@ -503,6 +511,9 @@ public: sal_uInt16 GetDisplayLineCount() const { return maLBWindow.GetDisplayLineCount(); } + bool GetEdgeBlending() const { return mbEdgeBlending; } + void SetEdgeBlending(bool bNew); + // pb: #106948# explicit mirroring for calc inline void EnableMirroring() { maLBWindow.EnableMirroring(); } inline void SetDropTraget(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; } @@ -569,9 +580,10 @@ private: Link maMBDownHdl; Link maUserDrawHdl; - sal_Bool mbUserDrawEnabled : 1, - mbInUserDraw : 1; - + /// bitfield + bool mbUserDrawEnabled : 1; + bool mbInUserDraw : 1; + bool mbEdgeBlending : 1; void ImplDraw( bool bLayout = false ); protected: @@ -607,10 +619,13 @@ public: void SetUserItemSize( const Size& rSz ) { maUserItemSize = rSz; } const Size& GetUserItemSize() const { return maUserItemSize; } - void EnableUserDraw( sal_Bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } - sal_Bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } + void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } + bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } void DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False, bool bLayout = false ); + + bool GetEdgeBlending() const { return mbEdgeBlending; } + void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; } }; // ----------- diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 638d27f725e2..94f17520d5e6 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -34,6 +34,7 @@ #include "vcl/i18nhelp.hxx" #include "vcl/configsettings.hxx" #include "vcl/gradient.hxx" +#include "vcl/outdev.hxx" #include "unotools/fontcfg.hxx" #include "unotools/localedatawrapper.hxx" @@ -233,6 +234,15 @@ ImplStyleData::ImplStyleData() : mnUseImagesInMenus = STYLE_MENUIMAGES_AUTO; mnPreferredSymbolsStyle = STYLE_SYMBOLS_AUTO; mpFontOptions = NULL; + mnEdgeBlending = 35; + maEdgeBlendingTopLeftColor = RGB_COLORDATA(0xC0, 0xC0, 0xC0); + maEdgeBlendingBottomRightColor = RGB_COLORDATA(0x40, 0x40, 0x40); + mnListBoxMaximumLineCount = 25; + mnColorValueSetColumnCount = 12; + mnColorValueSetMaximumRowCount = 40; + maListBoxPreviewDefaultLogicSize = Size(15, 7); + maListBoxPreviewDefaultPixelSize = Size(0, 0); // on-demand calculated in GetListBoxPreviewDefaultPixelSize() + mnListBoxPreviewDefaultLineWidth = 1; SetStandardStyles(); } @@ -345,6 +355,15 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) : mnSymbolsStyle = rData.mnSymbolsStyle; mnPreferredSymbolsStyle = rData.mnPreferredSymbolsStyle; mpFontOptions = rData.mpFontOptions; + mnEdgeBlending = rData.mnEdgeBlending; + maEdgeBlendingTopLeftColor = rData.maEdgeBlendingTopLeftColor; + maEdgeBlendingBottomRightColor = rData.maEdgeBlendingBottomRightColor; + mnListBoxMaximumLineCount = rData.mnListBoxMaximumLineCount; + mnColorValueSetColumnCount = rData.mnColorValueSetColumnCount; + mnColorValueSetMaximumRowCount = rData.mnColorValueSetMaximumRowCount; + maListBoxPreviewDefaultLogicSize = rData.maListBoxPreviewDefaultLogicSize; + maListBoxPreviewDefaultPixelSize = rData.maListBoxPreviewDefaultPixelSize; + mnListBoxPreviewDefaultLineWidth = rData.mnListBoxPreviewDefaultLineWidth; } // ----------------------------------------------------------------------- @@ -466,6 +485,17 @@ StyleSettings::~StyleSettings() mpData->mnRefCount--; } +const Size& StyleSettings::GetListBoxPreviewDefaultPixelSize() const +{ + if(0 == mpData->maListBoxPreviewDefaultPixelSize.Width() || 0 == mpData->maListBoxPreviewDefaultPixelSize.Height()) + { + const_cast< StyleSettings* >(this)->mpData->maListBoxPreviewDefaultPixelSize = + Application::GetDefaultDevice()->LogicToPixel(mpData->maListBoxPreviewDefaultLogicSize, MAP_APPFONT); + } + + return mpData->maListBoxPreviewDefaultPixelSize; +} + // ----------------------------------------------------------------------- void StyleSettings::Set3DColors( const Color& rColor ) @@ -934,7 +964,16 @@ sal_Bool StyleSettings::operator ==( const StyleSettings& rSet ) const (mpData->mbHideDisabledMenuItems == rSet.mpData->mbHideDisabledMenuItems) && (mpData->mbAcceleratorsInContextMenus == rSet.mpData->mbAcceleratorsInContextMenus)&& (mpData->mbPrimaryButtonWarpsSlider == rSet.mpData->mbPrimaryButtonWarpsSlider) && - (mpData->maFontColor == rSet.mpData->maFontColor )) + (mpData->maFontColor == rSet.mpData->maFontColor) && + (mpData->mnEdgeBlending == rSet.mpData->mnEdgeBlending) && + (mpData->maEdgeBlendingTopLeftColor == rSet.mpData->maEdgeBlendingTopLeftColor) && + (mpData->maEdgeBlendingBottomRightColor == rSet.mpData->maEdgeBlendingBottomRightColor) && + (mpData->mnListBoxMaximumLineCount == rSet.mpData->mnListBoxMaximumLineCount) && + (mpData->mnColorValueSetColumnCount == rSet.mpData->mnColorValueSetColumnCount) && + (mpData->mnColorValueSetMaximumRowCount == rSet.mpData->mnColorValueSetMaximumRowCount) && + (mpData->maListBoxPreviewDefaultLogicSize == rSet.mpData->maListBoxPreviewDefaultLogicSize) && + (mpData->maListBoxPreviewDefaultPixelSize == rSet.mpData->maListBoxPreviewDefaultPixelSize) && + (mpData->mnListBoxPreviewDefaultLineWidth == rSet.mpData->mnListBoxPreviewDefaultLineWidth)) return sal_True; else return sal_False; diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 6c2387a23293..425bd5e29d83 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -537,9 +537,14 @@ void ComboBox::EnableAutoSize( sal_Bool bAuto ) if ( mpFloatWin ) { if ( bAuto && !mpFloatWin->GetDropDownLineCount() ) - mpFloatWin->SetDropDownLineCount( 16 ); + { + // Adapt to GetListBoxMaximumLineCount here; was on fixed number of five before + AdaptDropDownLineCountToMaximum(); + } else if ( !bAuto ) + { mpFloatWin->SetDropDownLineCount( 0 ); + } } } @@ -561,6 +566,14 @@ void ComboBox::SetDropDownLineCount( sal_uInt16 nLines ) // ----------------------------------------------------------------------- +void ComboBox::AdaptDropDownLineCountToMaximum() +{ + // adapt to maximum allowed number + SetDropDownLineCount(std::min(GetEntryCount(), GetSettings().GetStyleSettings().GetListBoxMaximumLineCount())); +} + +// ----------------------------------------------------------------------- + sal_uInt16 ComboBox::GetDropDownLineCount() const { sal_uInt16 nLines = 0; diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 2fc66bb5fd55..b15bfc3b37fe 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -544,26 +544,27 @@ ImplListBoxWindow::ImplListBoxWindow( Window* pParent, WinBits nWinStyle ) : mnBorder = 1; mnSelectModifier = 0; mnUserDrawEntry = LISTBOX_ENTRY_NOTFOUND; - mbTrack = sal_False; - mbImgsDiffSz = sal_False; - mbTravelSelect = sal_False; - mbTrackingSelect = sal_False; - mbSelectionChanged = sal_False; - mbMouseMoveSelect = sal_False; - mbMulti = sal_False; - mbStackMode = sal_False; - mbGrabFocus = sal_False; - mbUserDrawEnabled = sal_False; - mbInUserDraw = sal_False; - mbReadOnly = sal_False; - mbHasFocusRect = sal_False; - mbRight = ( nWinStyle & WB_RIGHT ) ? sal_True : sal_False; - mbCenter = ( nWinStyle & WB_CENTER ) ? sal_True : sal_False; - mbSimpleMode = ( nWinStyle & WB_SIMPLEMODE ) ? sal_True : sal_False; - mbSort = ( nWinStyle & WB_SORT ) ? sal_True : sal_False; + mbTrack = false; + mbImgsDiffSz = false; + mbTravelSelect = false; + mbTrackingSelect = false; + mbSelectionChanged = false; + mbMouseMoveSelect = false; + mbMulti = false; + mbStackMode = false; + mbGrabFocus = false; + mbUserDrawEnabled = false; + mbInUserDraw = false; + mbReadOnly = false; + mbHasFocusRect = false; + mbRight = ( nWinStyle & WB_RIGHT ); + mbCenter = ( nWinStyle & WB_CENTER ); + mbSimpleMode = ( nWinStyle & WB_SIMPLEMODE ); + mbSort = ( nWinStyle & WB_SORT ); + mbEdgeBlending = false; // pb: #106948# explicit mirroring for calc - mbMirroring = sal_False; + mbMirroring = false; mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND; @@ -638,7 +639,7 @@ void ImplListBoxWindow::Clear() mnMaxImgHeight = 0; mnTop = 0; mnLeft = 0; - mbImgsDiffSz = sal_False; + mbImgsDiffSz = false; ImplClearLayoutData(); mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; @@ -714,9 +715,9 @@ void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry ) aMetrics.nImgHeight = (sal_uInt16) CalcZoom( aImgSz.Height() ); if( mnMaxImgWidth && ( aMetrics.nImgWidth != mnMaxImgWidth ) ) - mbImgsDiffSz = sal_True; + mbImgsDiffSz = true; else if ( mnMaxImgHeight && ( aMetrics.nImgHeight != mnMaxImgHeight ) ) - mbImgsDiffSz = sal_True; + mbImgsDiffSz = true; if( aMetrics.nImgWidth > mnMaxImgWidth ) mnMaxImgWidth = aMetrics.nImgWidth; @@ -791,7 +792,7 @@ void ImplListBoxWindow::ImplCallSelect() } maSelectHdl.Call( NULL ); - mbSelectionChanged = sal_False; + mbSelectionChanged = false; } // ----------------------------------------------------------------------- @@ -836,7 +837,7 @@ void ImplListBoxWindow::ImplShowFocusRect() if ( mbHasFocusRect ) HideFocus(); ShowFocus( maFocusRect ); - mbHasFocusRect = sal_True; + mbHasFocusRect = true; } // ----------------------------------------------------------------------- @@ -846,7 +847,7 @@ void ImplListBoxWindow::ImplHideFocusRect() if ( mbHasFocusRect ) { HideFocus(); - mbHasFocusRect = sal_False; + mbHasFocusRect = false; } } @@ -912,7 +913,7 @@ sal_uInt16 ImplListBoxWindow::GetLastVisibleEntry() const void ImplListBoxWindow::MouseButtonDown( const MouseEvent& rMEvt ) { - mbMouseMoveSelect = sal_False; // only till the first MouseButtonDown + mbMouseMoveSelect = false; // only till the first MouseButtonDown maQuickSelectionEngine.Reset(); if ( !IsReadOnly() ) @@ -928,9 +929,9 @@ void ImplListBoxWindow::MouseButtonDown( const MouseEvent& rMEvt ) mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND; mnCurrentPos = nSelect; - mbTrackingSelect = sal_True; + mbTrackingSelect = true; SelectEntries( nSelect, LET_MBDOWN, rMEvt.IsShift(), rMEvt.IsMod1() ); - mbTrackingSelect = sal_False; + mbTrackingSelect = false; if ( mbGrabFocus ) GrabFocus(); @@ -963,10 +964,10 @@ void ImplListBoxWindow::MouseMove( const MouseEvent& rMEvt ) SetTopEntry( 0 ); if ( mbStackMode ) // #87072#, #92323# { - mbTravelSelect = sal_True; + mbTravelSelect = true; mnSelectModifier = rMEvt.GetModifier(); ImplCallSelect(); - mbTravelSelect = sal_False; + mbTravelSelect = false; } } @@ -990,18 +991,18 @@ void ImplListBoxWindow::MouseMove( const MouseEvent& rMEvt ) mpEntryList->IsEntrySelectable( nSelect ) && ( ( nSelect != mnCurrentPos ) || !GetEntryList()->GetSelectEntryCount() || ( nSelect != GetEntryList()->GetSelectEntryPos( 0 ) ) ) ) { - mbTrackingSelect = sal_True; + mbTrackingSelect = true; if ( SelectEntries( nSelect, LET_TRACKING, sal_False, sal_False ) ) { if ( mbStackMode ) // #87072# { - mbTravelSelect = sal_True; + mbTravelSelect = true; mnSelectModifier = rMEvt.GetModifier(); ImplCallSelect(); - mbTravelSelect = sal_False; + mbTravelSelect = false; } } - mbTrackingSelect = sal_False; + mbTrackingSelect = false; } } @@ -1081,7 +1082,7 @@ void ImplListBoxWindow::SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ) mpEntryList->SelectEntry( nPos, sal_False ); ImplPaint( nPos, sal_True ); } - mbSelectionChanged = sal_True; + mbSelectionChanged = true; } } @@ -1221,7 +1222,7 @@ sal_Bool ImplListBoxWindow::SelectEntries( sal_uInt16 nSelect, LB_EVENT_TYPE eLE } if( bSelectionChanged ) - mbSelectionChanged = sal_True; + mbSelectionChanged = true; if( bFocusChanged ) { @@ -1258,9 +1259,9 @@ void ImplListBoxWindow::Tracking( const TrackingEvent& rTEvt ) maCancelHdl.Call( NULL ); if ( !mbMulti ) { - mbTrackingSelect = sal_True; + mbTrackingSelect = true; SelectEntry( mnTrackingSaveSelection, sal_True ); - mbTrackingSelect = sal_False; + mbTrackingSelect = false; if ( mnTrackingSaveSelection != LISTBOX_ENTRY_NOTFOUND ) { long nHeightDiff = mpEntryList->GetAddedHeight( mnCurrentPos, mnTop, 0 ); @@ -1273,7 +1274,7 @@ void ImplListBoxWindow::Tracking( const TrackingEvent& rTEvt ) } } - mbTrack = sal_False; + mbTrack = false; } else { @@ -1282,14 +1283,14 @@ void ImplListBoxWindow::Tracking( const TrackingEvent& rTEvt ) { if ( bInside ) { - mbTrack = sal_True; + mbTrack = true; } // this case only happens, if the mouse button is pressed very briefly if( rTEvt.IsTrackingEnded() && mbTrack ) { bTrackOrQuickClick = sal_True; - mbTrack = sal_False; + mbTrack = false; } } @@ -1330,27 +1331,27 @@ void ImplListBoxWindow::Tracking( const TrackingEvent& rTEvt ) { if ( ( nSelect != mnCurrentPos ) || !GetEntryList()->GetSelectEntryCount() ) { - mbTrackingSelect = sal_True; + mbTrackingSelect = true; if ( SelectEntries( nSelect, LET_TRACKING, bShift, bCtrl ) ) { if ( mbStackMode ) // #87734# (#87072#) { - mbTravelSelect = sal_True; + mbTravelSelect = true; mnSelectModifier = rTEvt.GetMouseEvent().GetModifier(); ImplCallSelect(); - mbTravelSelect = sal_False; + mbTravelSelect = false; } } - mbTrackingSelect = sal_False; + mbTrackingSelect = false; } } else { if ( !mbMulti && GetEntryList()->GetSelectEntryCount() ) { - mbTrackingSelect = sal_True; + mbTrackingSelect = true; SelectEntry( GetEntryList()->GetSelectEntryPos( 0 ), sal_False ); - mbTrackingSelect = sal_False; + mbTrackingSelect = false; } else if ( mbStackMode ) { @@ -1372,18 +1373,18 @@ void ImplListBoxWindow::Tracking( const TrackingEvent& rTEvt ) } else { - mbTrackingSelect = sal_True; + mbTrackingSelect = true; bSelectionChanged = SelectEntries( nSelect, LET_TRACKING, bShift, bCtrl ); - mbTrackingSelect = sal_False; + mbTrackingSelect = false; } if ( bSelectionChanged ) { - mbSelectionChanged = sal_True; - mbTravelSelect = sal_True; + mbSelectionChanged = true; + mbTravelSelect = true; mnSelectModifier = rTEvt.GetMouseEvent().GetModifier(); ImplCallSelect(); - mbTravelSelect = sal_False; + mbTravelSelect = false; } } } @@ -1693,10 +1694,10 @@ sal_Bool ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) mnCurrentPos = nSelect; if ( SelectEntries( nSelect, eLET, bShift, bCtrl ) ) { - mbTravelSelect = sal_True; + mbTravelSelect = true; mnSelectModifier = rKEvt.GetKeyCode().GetModifier(); ImplCallSelect(); - mbTravelSelect = sal_False; + mbTravelSelect = false; } } @@ -1762,10 +1763,10 @@ void ImplListBoxWindow::SelectEntry( ::vcl::StringEntryIdentifier _entry ) mnCurrentPos = nSelect; if ( SelectEntries( nSelect, LET_KEYMOVE, sal_False, sal_False ) ) { - mbTravelSelect = sal_True; + mbTravelSelect = true; mnSelectModifier = 0; ImplCallSelect(); - mbTravelSelect = sal_False; + mbTravelSelect = false; } } @@ -1805,7 +1806,7 @@ void ImplListBoxWindow::ImplPaint( sal_uInt16 nPos, sal_Bool bErase, bool bLayou if ( IsUserDrawEnabled() ) { - mbInUserDraw = sal_True; + mbInUserDraw = true; mnUserDrawEntry = nPos; aRect.Left() -= mnLeft; if ( nPos < GetEntryList()->GetMRUCount() ) @@ -1818,7 +1819,7 @@ void ImplListBoxWindow::ImplPaint( sal_uInt16 nPos, sal_Bool bErase, bool bLayou UserDrawEvent aUDEvt( this, aRect, nPos, nCurr ); maUserDrawHdl.Call( &aUDEvt ); - mbInUserDraw = sal_False; + mbInUserDraw = false; } else { @@ -1865,6 +1866,25 @@ void ImplListBoxWindow::DrawEntry( sal_uInt16 nPos, sal_Bool bDrawImage, sal_Boo aImgSz.Height() = CalcZoom( aImgSz.Height() ); DrawImage( aPtImg, aImgSz, aImage ); } + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); + + if(nEdgeBlendingPercent) + { + const Rectangle aRect(aPtImg, aImgSz); + Bitmap aBitmap(GetBitmap(aRect.TopLeft(), aRect.GetSize())); + + if(!aBitmap.IsEmpty()) + { + const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); + const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); + const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); + + aBitmap.DrawBlendFrame(nAlpha, rTopLeft, rBottomRight); + DrawBitmap(aRect.TopLeft(), aBitmap); + } + } } } @@ -2238,12 +2258,14 @@ ImplListBox::ImplListBox( Window* pParent, WinBits nWinStyle ) : mpVScrollBar->SetScrollHdl( aLink ); mpHScrollBar->SetScrollHdl( aLink ); - mbVScroll = sal_False; - mbHScroll = sal_False; - mbAutoHScroll = ( nWinStyle & WB_AUTOHSCROLL ) ? sal_True : sal_False; + mbVScroll = false; + mbHScroll = false; + mbAutoHScroll = ( nWinStyle & WB_AUTOHSCROLL ); + mbEdgeBlending = false; maLBWindow.SetScrollHdl( LINK( this, ImplListBox, LBWindowScrolled ) ); maLBWindow.SetMRUChangedHdl( LINK( this, ImplListBox, MRUChanged ) ); + maLBWindow.SetEdgeBlending(GetEdgeBlending()); maLBWindow.Show(); } @@ -2406,7 +2428,7 @@ void ImplListBox::ImplCheckScrollBars() { if( !mbVScroll ) bArrange = true; - mbVScroll = sal_True; + mbVScroll = true; // check of the scrolled-out region if( GetEntryList()->GetSelectEntryCount() == 1 && @@ -2419,7 +2441,7 @@ void ImplListBox::ImplCheckScrollBars() { if( mbVScroll ) bArrange = true; - mbVScroll = sal_False; + mbVScroll = false; SetTopEntry( 0 ); } @@ -2435,7 +2457,7 @@ void ImplListBox::ImplCheckScrollBars() { if( !mbHScroll ) bArrange = true; - mbHScroll = sal_True; + mbHScroll = true; if ( !mbVScroll ) // maybe we do need one now { @@ -2443,7 +2465,7 @@ void ImplListBox::ImplCheckScrollBars() if( nEntries > nMaxVisEntries ) { bArrange = true; - mbVScroll = sal_True; + mbVScroll = true; // check of the scrolled-out region if( GetEntryList()->GetSelectEntryCount() == 1 && @@ -2463,7 +2485,7 @@ void ImplListBox::ImplCheckScrollBars() { if( mbHScroll ) bArrange = true; - mbHScroll = sal_False; + mbHScroll = false; SetLeftIndent( 0 ); } } @@ -2712,6 +2734,17 @@ OUString ImplListBox::GetMRUEntries( sal_Unicode cSep ) const return aEntries.makeStringAndClear(); } +// ----------------------------------------------------------------------- + +void ImplListBox::SetEdgeBlending(bool bNew) +{ + if(mbEdgeBlending != bNew) + { + mbEdgeBlending = bNew; + maLBWindow.SetEdgeBlending(GetEdgeBlending()); + } +} + // ======================================================================= ImplWin::ImplWin( Window* pParent, WinBits nWinStyle ) : @@ -2723,8 +2756,9 @@ ImplWin::ImplWin( Window* pParent, WinBits nWinStyle ) : else SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) ); - mbInUserDraw = sal_False; - mbUserDrawEnabled = sal_False; + mbInUserDraw = false; + mbUserDrawEnabled = false; + mbEdgeBlending = false; mnItemPos = LISTBOX_ENTRY_NOTFOUND; } @@ -2878,10 +2912,10 @@ void ImplWin::ImplDraw( bool bLayout ) if ( IsUserDrawEnabled() ) { - mbInUserDraw = sal_True; + mbInUserDraw = true; UserDrawEvent aUDEvt( this, maFocusRect, mnItemPos, 0 ); maUserDrawHdl.Call( &aUDEvt ); - mbInUserDraw = sal_False; + mbInUserDraw = false; } else { @@ -2909,6 +2943,7 @@ void ImplWin::DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDraw sal_uInt16 nStyle = 0; Size aImgSz = maImage.GetSizePixel(); Point aPtImg( nBorder, ( ( aOutSz.Height() - aImgSz.Height() ) / 2 ) ); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); // check for HC mode Image *pImage = &maImage; @@ -2923,6 +2958,24 @@ void ImplWin::DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDraw aImgSz.Height() = CalcZoom( aImgSz.Height() ); DrawImage( aPtImg, aImgSz, *pImage, nStyle ); } + + const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); + + if(nEdgeBlendingPercent) + { + const Rectangle aRect(aPtImg, aImgSz); + Bitmap aBitmap(GetBitmap(aRect.TopLeft(), aRect.GetSize())); + + if(!aBitmap.IsEmpty()) + { + const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); + const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); + const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); + + aBitmap.DrawBlendFrame(nAlpha, rTopLeft, rBottomRight); + DrawBitmap(aRect.TopLeft(), aBitmap); + } + } } if( bDrawText && !maString.isEmpty() ) diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 6278f8e66f78..741558e2fd2d 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -87,12 +87,12 @@ void ListBox::ImplInitListBoxData() mpFloatWin = NULL; mpImplWin = NULL; mpBtn = NULL; - mnDDHeight = 0; - mbDDAutoSize = sal_True; mnSaveValue = LISTBOX_ENTRY_NOTFOUND; mnLineCount = 0; m_nMaxWidthChars = -1; + mbDDAutoSize = true; + mbEdgeBlending = false; } @@ -140,13 +140,13 @@ void ListBox::ImplInit( Window* pParent, WinBits nStyle ) mpImplWin->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) ); mpImplWin->Show(); mpImplWin->GetDropTarget()->addDropTargetListener(xDrop); + mpImplWin->SetEdgeBlending(GetEdgeBlending()); mpBtn = new ImplBtn( this, WB_NOLIGHTBORDER | WB_RECTSTYLE ); ImplInitDropDownButton( mpBtn ); mpBtn->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) ); mpBtn->Show(); mpBtn->GetDropTarget()->addDropTargetListener(xDrop); - } Window* pLBParent = this; @@ -159,6 +159,7 @@ void ListBox::ImplInit( Window* pParent, WinBits nStyle ) mpImplLB->SetDoubleClickHdl( LINK( this, ListBox, ImplDoubleClickHdl ) ); mpImplLB->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) ); mpImplLB->SetPosPixel( Point() ); + mpImplLB->SetEdgeBlending(GetEdgeBlending()); mpImplLB->Show(); mpImplLB->GetDropTarget()->addDropTargetListener(xDrop); @@ -556,15 +557,20 @@ void ListBox::DataChanged( const DataChangedEvent& rDCEvt ) } -void ListBox::EnableAutoSize( sal_Bool bAuto ) +void ListBox::EnableAutoSize( bool bAuto ) { mbDDAutoSize = bAuto; if ( mpFloatWin ) { if ( bAuto && !mpFloatWin->GetDropDownLineCount() ) - mpFloatWin->SetDropDownLineCount( 16 ); + { + // use GetListBoxMaximumLineCount here; before, was on fixed number of five + AdaptDropDownLineCountToMaximum(); + } else if ( !bAuto ) + { mpFloatWin->SetDropDownLineCount( 0 ); + } } } @@ -584,6 +590,14 @@ void ListBox::SetDropDownLineCount( sal_uInt16 nLines ) } +void ListBox::AdaptDropDownLineCountToMaximum() +{ + // adapt to maximum allowed number + SetDropDownLineCount(std::min(GetEntryCount(), GetSettings().GetStyleSettings().GetListBoxMaximumLineCount())); +} + +// ----------------------------------------------------------------------- + sal_uInt16 ListBox::GetDropDownLineCount() const { if ( mpFloatWin ) @@ -1498,6 +1512,38 @@ bool ListBox::set_property(const OString &rKey, const OString &rValue) return true; } +// ----------------------------------------------------------------------- + +void ListBox::SetEdgeBlending(bool bNew) +{ + if(mbEdgeBlending != bNew) + { + mbEdgeBlending = bNew; + + if(IsDropDownBox()) + { + mpImplWin->Invalidate(); + } + else + { + mpImplLB->Invalidate(); + } + + if(mpImplWin) + { + mpImplWin->SetEdgeBlending(GetEdgeBlending()); + } + + if(mpImplLB) + { + mpImplLB->SetEdgeBlending(GetEdgeBlending()); + } + + Invalidate(); + } +} + +// ======================================================================= MultiListBox::MultiListBox( Window* pParent, WinBits nStyle ) : ListBox( WINDOW_MULTILISTBOX ) { -- cgit v1.2.3