summaryrefslogtreecommitdiff
path: root/vcl/source/window/toolbox.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/window/toolbox.cxx')
-rwxr-xr-xvcl/source/window/toolbox.cxx204
1 files changed, 116 insertions, 88 deletions
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 682c65e47a6f..50137643a2cc 100755
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -30,7 +31,6 @@
#include <rtl/logfile.hxx>
-#include <tools/list.hxx>
#include <tools/debug.hxx>
#include <tools/rc.h>
#include <tools/poly.hxx>
@@ -144,7 +144,7 @@ struct ImplToolSizeArray
// -----------------------------------------------------------------------
-DECLARE_LIST( ImplTBList, ToolBox* )
+typedef ::std::vector< ToolBox* > ImplTBList;
class ImplTBDragMgr
{
@@ -168,12 +168,19 @@ public:
ImplTBDragMgr();
~ImplTBDragMgr();
- void Insert( ToolBox* pBox )
- { mpBoxList->Insert( pBox ); }
- void Remove( ToolBox* pBox )
- { mpBoxList->Remove( pBox ); }
- sal_uLong Count() const
- { return mpBoxList->Count(); }
+ void push_back( ToolBox* pBox )
+ { mpBoxList->push_back( pBox ); }
+ void erase( ToolBox* pBox )
+ {
+ for ( ImplTBList::iterator it = mpBoxList->begin(); it < mpBoxList->end(); ++it ) {
+ if ( *it == pBox ) {
+ mpBoxList->erase( it );
+ break;
+ }
+ }
+ }
+ size_t size() const
+ { return mpBoxList->size(); }
ToolBox* FindToolBox( const Rectangle& rRect );
@@ -1122,7 +1129,7 @@ void ToolBox::ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRec
mbHorz = sal_True;
}
else {
- DBG_ERROR( "ImplLineSizing: Trailing else" );
+ OSL_FAIL( "ImplLineSizing: Trailing else" );
nCurSize = 0;
mbHorz = sal_False;
}
@@ -1253,7 +1260,7 @@ sal_uInt16 ToolBox::ImplFindItemPos( ToolBox* pBox, const Point& rPos )
ImplTBDragMgr::ImplTBDragMgr()
{
- mpBoxList = new ImplTBList( 4, 4 );
+ mpBoxList = new ImplTBList();
mnLineMode = 0;
mnStartLines = 0;
mbCustomizeMode = sal_False;
@@ -1277,9 +1284,9 @@ ImplTBDragMgr::~ImplTBDragMgr()
ToolBox* ImplTBDragMgr::FindToolBox( const Rectangle& rRect )
{
- ToolBox* pBox = mpBoxList->First();
- while ( pBox )
+ for ( size_t i = 0, n = mpBoxList->size(); i < n; ++i )
{
+ ToolBox* pBox = (*mpBoxList)[ i ];
/*
* FIXME: since we can have multiple frames now we cannot
* find the drag target by its position alone.
@@ -1287,8 +1294,9 @@ ToolBox* ImplTBDragMgr::FindToolBox( const Rectangle& rRect )
* this works in one frame only anyway. If the dialogue
* changes to a system window, we need a new implementation here
*/
- if ( pBox->IsReallyVisible() && pBox->ImplGetWindowImpl()->mpFrame == mpDragBox->ImplGetWindowImpl()->mpFrame )
- {
+ if ( pBox->IsReallyVisible()
+ && pBox->ImplGetWindowImpl()->mpFrame == mpDragBox->ImplGetWindowImpl()->mpFrame
+ ) {
if ( !pBox->ImplIsFloatingMode() )
{
Point aPos = pBox->GetPosPixel();
@@ -1298,11 +1306,9 @@ ToolBox* ImplTBDragMgr::FindToolBox( const Rectangle& rRect )
return pBox;
}
}
-
- pBox = mpBoxList->Next();
}
- return pBox;
+ return NULL;
}
// -----------------------------------------------------------------------
@@ -1501,11 +1507,8 @@ void ImplTBDragMgr::StartCustomizeMode()
{
mbCustomizeMode = sal_True;
- ToolBox* pBox = mpBoxList->First();
- while ( pBox )
- {
- pBox->ImplStartCustomizeMode();
- pBox = mpBoxList->Next();
+ for ( size_t i = 0, n = mpBoxList->size(); i < n; ++i ) {
+ (*mpBoxList)[ i ]->ImplStartCustomizeMode();
}
}
@@ -1515,11 +1518,8 @@ void ImplTBDragMgr::EndCustomizeMode()
{
mbCustomizeMode = sal_False;
- ToolBox* pBox = mpBoxList->First();
- while ( pBox )
- {
- pBox->ImplEndCustomizeMode();
- pBox = mpBoxList->Next();
+ for ( size_t i = 0, n = mpBoxList->size(); i < n; ++i ) {
+ (*mpBoxList)[ i ]->ImplEndCustomizeMode();
}
}
@@ -1621,7 +1621,6 @@ void ToolBox::ImplInit( Window* pParent, WinBits nStyle )
mbCustomize = sal_False;
mbCustomizeMode = sal_False;
mbDragging = sal_False;
- mbHideStatusText = sal_False;
mbMenuStrings = sal_False;
mbIsShift = sal_False;
mbIsKeyEvent = sal_False;
@@ -1840,9 +1839,9 @@ ToolBox::~ToolBox()
{
// Wenn im TBDrag-Manager, dann wieder rausnehmen
if ( mbCustomize )
- pSVData->maCtrlData.mpTBDragMgr->Remove( this );
+ pSVData->maCtrlData.mpTBDragMgr->erase( this );
- if ( !pSVData->maCtrlData.mpTBDragMgr->Count() )
+ if ( !pSVData->maCtrlData.mpTBDragMgr->size() )
{
delete pSVData->maCtrlData.mpTBDragMgr;
pSVData->maCtrlData.mpTBDragMgr = NULL;
@@ -3407,6 +3406,54 @@ void ToolBox::ImplDrawNext( sal_Bool bIn )
// -----------------------------------------------------------------------
+void ToolBox::ImplDrawSeparator( sal_uInt16 nPos, Rectangle rRect )
+{
+ bool bNativeOk = false;
+ ImplToolItem* pItem = &mpData->m_aItems[nPos];
+
+ if( IsNativeControlSupported( CTRL_TOOLBAR, PART_SEPARATOR ) )
+ {
+ ImplControlValue aControlValue;
+ ControlState nState = 0;
+ bNativeOk = DrawNativeControl( CTRL_TOOLBAR, PART_SEPARATOR,
+ rRect, nState, aControlValue, rtl::OUString() );
+ }
+
+ /* Draw the widget only if it can't be drawn natively. */
+ if( !bNativeOk )
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ ImplToolItem* pTempItem = &mpData->m_aItems[nPos-1];
+
+ // no separator before or after windows or at breaks
+ if ( pTempItem && !pTempItem->mbShowWindow && nPos < mpData->m_aItems.size()-1 )
+ {
+ pTempItem = &mpData->m_aItems[nPos+1];
+ if ( !pTempItem->mbShowWindow && !pTempItem->mbBreak )
+ {
+ long nCenterPos, nSlim;
+ SetLineColor( rStyleSettings.GetSeparatorColor() );
+ if ( IsHorizontal() )
+ {
+ nSlim = (pItem->maRect.Bottom() - pItem->maRect.Top ()) / 4;
+ nCenterPos = pItem->maRect.Center().X();
+ DrawLine( Point( nCenterPos, pItem->maRect.Top() + nSlim ),
+ Point( nCenterPos, pItem->maRect.Bottom() - nSlim ) );
+ }
+ else
+ {
+ nSlim = (pItem->maRect.Right() - pItem->maRect.Left ()) / 4;
+ nCenterPos = pItem->maRect.Center().Y();
+ DrawLine( Point( pItem->maRect.Left() + nSlim, nCenterPos ),
+ Point( pItem->maRect.Right() - nSlim, nCenterPos ) );
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
static void ImplDrawButton( ToolBox* pThis, const Rectangle &rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bEnabled, sal_Bool bIsWindow )
{
// draws toolbar button background either native or using a coloured selection
@@ -3468,6 +3515,33 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_Bool bHighlight, sal_Bool bPain
if( rStyleSettings.GetFaceColor() == Color( COL_WHITE ) )
bHighContrastWhite = sal_True;
+ // Compute buttons area.
+ Size aBtnSize = pItem->maRect.GetSize();
+ if( ImplGetSVData()->maNWFData.mbToolboxDropDownSeparate )
+ {
+ // separate button not for dropdown only where the whole button is painted
+ if ( pItem->mnBits & TIB_DROPDOWN &&
+ ((pItem->mnBits & TIB_DROPDOWNONLY) != TIB_DROPDOWNONLY) )
+ {
+ Rectangle aArrowRect = pItem->GetDropDownRect( mbHorz );
+ if( aArrowRect.Top() == pItem->maRect.Top() ) // dropdown arrow on right side
+ aBtnSize.Width() -= aArrowRect.GetWidth();
+ else // dropdown arrow on bottom side
+ aBtnSize.Height() -= aArrowRect.GetHeight();
+ }
+ }
+
+ /* Compute the button/separator rectangle here, we'll need it for
+ * both the buttons and the separators. */
+ Rectangle aButtonRect( pItem->maRect.TopLeft(), aBtnSize );
+ long nOffX = SMALLBUTTON_OFF_NORMAL_X;
+ long nOffY = SMALLBUTTON_OFF_NORMAL_Y;
+ long nImageOffX = 0;
+ long nImageOffY = 0;
+ long nTextOffX = 0;
+ long nTextOffY = 0;
+ sal_uInt16 nStyle = 0;
+
// draw separators in flat style only
if ( !bLayout &&
(mnOutStyle & TOOLBOX_STYLE_FLAT) &&
@@ -3475,31 +3549,7 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_Bool bHighlight, sal_Bool bPain
nPos > 0
)
{
- // no separator before or after windows or at breaks
- ImplToolItem* pTempItem = &mpData->m_aItems[nPos-1];
- if ( pTempItem && !pTempItem->mbShowWindow && nPos < mpData->m_aItems.size()-1 )
- {
- pTempItem = &mpData->m_aItems[nPos+1];
- if ( !pTempItem->mbShowWindow && !pTempItem->mbBreak )
- {
- long nCenterPos, nSlim;
- SetLineColor( rStyleSettings.GetSeparatorColor() );
- if ( IsHorizontal() )
- {
- nSlim = (pItem->maRect.Bottom() - pItem->maRect.Top ()) / 4;
- nCenterPos = pItem->maRect.Center().X();
- DrawLine( Point( nCenterPos, pItem->maRect.Top() + nSlim ),
- Point( nCenterPos, pItem->maRect.Bottom() - nSlim ) );
- }
- else
- {
- nSlim = (pItem->maRect.Right() - pItem->maRect.Left ()) / 4;
- nCenterPos = pItem->maRect.Center().Y();
- DrawLine( Point( pItem->maRect.Left() + nSlim, nCenterPos ),
- Point( pItem->maRect.Right() - nSlim, nCenterPos ) );
- }
- }
- }
+ ImplDrawSeparator( nPos, aButtonRect );
}
// do nothing if item is no button or will be displayed as window
@@ -3563,30 +3613,6 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_Bool bHighlight, sal_Bool bPain
return;
}
- // draw button
- Size aBtnSize = pItem->maRect.GetSize();
- if( ImplGetSVData()->maNWFData.mbToolboxDropDownSeparate )
- {
- // separate button not for dropdown only where the whole button is painted
- if ( pItem->mnBits & TIB_DROPDOWN &&
- ((pItem->mnBits & TIB_DROPDOWNONLY) != TIB_DROPDOWNONLY) )
- {
- Rectangle aArrowRect = pItem->GetDropDownRect( mbHorz );
- if( aArrowRect.Top() == pItem->maRect.Top() ) // dropdown arrow on right side
- aBtnSize.Width() -= aArrowRect.GetWidth();
- else // dropdown arrow on bottom side
- aBtnSize.Height() -= aArrowRect.GetHeight();
- }
- }
- Rectangle aButtonRect( pItem->maRect.TopLeft(), aBtnSize );
- long nOffX = SMALLBUTTON_OFF_NORMAL_X;
- long nOffY = SMALLBUTTON_OFF_NORMAL_Y;
- long nImageOffX=0;
- long nImageOffY=0;
- long nTextOffX=0;
- long nTextOffY=0;
- sal_uInt16 nStyle = 0;
-
if ( pItem->meState == STATE_CHECK )
{
nStyle |= BUTTON_DRAW_CHECKED;
@@ -5398,8 +5424,8 @@ sal_uInt16 ToolBox::ImplCountLineBreaks( const ToolBox *pThis )
while ( it != ((ToolBox*)pThis)->mpData->m_aItems.end() )
{
if( it->meType == TOOLBOXITEM_BREAK )
- nLines++;
- it++;
+ ++nLines;
+ ++it;
}
return nLines;
}
@@ -5410,7 +5436,7 @@ Size ToolBox::CalcPopupWindowSizePixel() const
sal_uInt16 nLines = ImplCountLineBreaks( this );
if( nLines )
- nLines++; // add the first line
+ ++nLines; // add the first line
else
{
// no breaks found: use quadratic layout
@@ -5430,7 +5456,7 @@ Size ToolBox::CalcPopupWindowSizePixel() const
Size ToolBox::CalcFloatingWindowSizePixel() const
{
sal_uInt16 nLines = ImplCountLineBreaks( this );
- nLines++; // add the first line
+ ++nLines; // add the first line
return CalcFloatingWindowSizePixel( nLines );
}
@@ -5471,7 +5497,7 @@ Size ToolBox::CalcMinimumWindowSizePixel() const
pToolBox->CopyItem( *this, it->mnId );
if( (it->meType != TOOLBOXITEM_BUTTON) ||
!it->mbVisible || ImplIsFixedControl( &(*it) ) )
- it++;
+ ++it;
else
break;
}
@@ -5506,9 +5532,9 @@ void ToolBox::EnableCustomize( sal_Bool bEnable )
ImplTBDragMgr* pMgr = ImplGetTBDragMgr();
if ( bEnable )
- pMgr->Insert( this );
+ pMgr->push_back( this );
else
- pMgr->Remove( this );
+ pMgr->erase( this );
}
}
@@ -5914,7 +5940,7 @@ sal_uInt16 ToolBox::ImplGetItemLine( ImplToolItem* pCurrentItem )
while( it != mpData->m_aItems.end() )
{
if ( it->mbBreak )
- nLine++;
+ ++nLine;
if( &(*it) == pCurrentItem)
break;
++it;
@@ -5994,7 +6020,7 @@ sal_uInt16 ToolBox::ImplFindItemPos( const ImplToolItem* pItem, const std::vecto
if( pItem )
{
sal_uInt16 nPos;
- for( nPos = 0; nPos < rList.size(); nPos++ )
+ for( nPos = 0; nPos < rList.size(); ++nPos )
if( &rList[ nPos ] == pItem )
return nPos;
}
@@ -6333,3 +6359,5 @@ void ToolBox::ImplDisableFlatButtons()
mnOutStyle &= ~TOOLBOX_STYLE_FLAT;
#endif
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */