1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <tools/debug.hxx>
24 #include <vcl/event.hxx>
25 #include <vcl/decoview.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/help.hxx>
28 #include <vcl/status.hxx>
29 #include <vcl/virdev.hxx>
34 // =======================================================================
36 #define STATUSBAR_OFFSET_X STATUSBAR_OFFSET
37 #define STATUSBAR_OFFSET_Y 2
38 #define STATUSBAR_OFFSET_TEXTY 3
40 #define STATUSBAR_PRGS_OFFSET 3
41 #define STATUSBAR_PRGS_COUNT 100
42 #define STATUSBAR_PRGS_MIN 5
44 // -----------------------------------------------------------------------
46 class StatusBar::ImplData
52 VirtualDevice
* mpVirDev
;
53 long mnItemBorderWidth
;
54 bool mbDrawItemFrames
:1;
57 StatusBar::ImplData::ImplData()
60 mbDrawItemFrames
= false;
61 mnItemBorderWidth
= 0;
64 StatusBar::ImplData::~ImplData()
71 StatusBarItemBits mnBits
;
78 OUString maQuickHelpText
;
82 OUString maAccessibleName
;
86 // =======================================================================
88 inline long ImplCalcProgessWidth( sal_uInt16 nMax
, long nSize
)
90 return ((nMax
*(nSize
+(nSize
/2)))-(nSize
/2)+(STATUSBAR_PRGS_OFFSET
*2));
93 // -----------------------------------------------------------------------
95 static Point
ImplGetItemTextPos( const Size
& rRectSize
, const Size
& rTextSize
,
100 long delta
= (rTextSize
.Height()/4) + 1;
101 if( delta
+ rTextSize
.Width() > rRectSize
.Width() )
104 if ( nStyle
& SIB_LEFT
)
106 else if ( nStyle
& SIB_RIGHT
)
107 nX
= rRectSize
.Width()-rTextSize
.Width()-delta
;
109 nX
= (rRectSize
.Width()-rTextSize
.Width())/2;
110 nY
= (rRectSize
.Height()-rTextSize
.Height())/2 + 1;
111 return Point( nX
, nY
);
114 // -----------------------------------------------------------------------
116 sal_Bool
StatusBar::ImplIsItemUpdate()
118 if ( !mbProgressMode
&& mbVisibleItems
&& IsReallyVisible() && IsUpdateMode() )
124 // -----------------------------------------------------------------------
126 void StatusBar::ImplInit( Window
* pParent
, WinBits nStyle
)
128 mpImplData
= new ImplData
;
130 // Default ist RightAlign
131 if ( !(nStyle
& (WB_LEFT
| WB_RIGHT
)) )
134 Window::ImplInit( pParent
, nStyle
& ~WB_BORDER
, NULL
);
137 mpItemList
= new ImplStatusItemList
;
138 mpImplData
->mpVirDev
= new VirtualDevice( *this );
141 mbVisibleItems
= sal_True
;
142 mbProgressMode
= sal_False
;
143 mbInUserDraw
= sal_False
;
144 mnItemsWidth
= STATUSBAR_OFFSET_X
;
148 mnItemY
= STATUSBAR_OFFSET_Y
;
149 mnTextY
= STATUSBAR_OFFSET_TEXTY
;
151 ImplInitSettings( sal_True
, sal_True
, sal_True
);
154 SetOutputSizePixel( CalcWindowSizePixel() );
157 // -----------------------------------------------------------------------
159 StatusBar::StatusBar( Window
* pParent
, WinBits nStyle
) :
160 Window( WINDOW_STATUSBAR
)
162 ImplInit( pParent
, nStyle
);
165 // -----------------------------------------------------------------------
167 StatusBar::~StatusBar()
169 // Alle Items loeschen
170 for ( size_t i
= 0, n
= mpItemList
->size(); i
< n
; ++i
) {
171 delete (*mpItemList
)[ i
];
175 // VirtualDevice loeschen
176 delete mpImplData
->mpVirDev
;
180 // -----------------------------------------------------------------------
182 void StatusBar::ImplInitSettings( sal_Bool bFont
,
183 sal_Bool bForeground
, sal_Bool bBackground
)
185 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
189 Font aFont
= rStyleSettings
.GetToolFont();
190 if ( IsControlFont() )
191 aFont
.Merge( GetControlFont() );
192 SetZoomedPointFont( aFont
);
195 if ( bForeground
|| bFont
)
198 if ( IsControlForeground() )
199 aColor
= GetControlForeground();
200 else if ( GetStyle() & WB_3DLOOK
)
201 aColor
= rStyleSettings
.GetButtonTextColor();
203 aColor
= rStyleSettings
.GetWindowTextColor();
204 SetTextColor( aColor
);
207 mpImplData
->mpVirDev
->SetFont( GetFont() );
208 mpImplData
->mpVirDev
->SetTextColor( GetTextColor() );
209 mpImplData
->mpVirDev
->SetTextAlign( GetTextAlign() );
210 mpImplData
->mpVirDev
->SetTextFillColor();
216 if ( IsControlBackground() )
217 aColor
= GetControlBackground();
218 else if ( GetStyle() & WB_3DLOOK
)
219 aColor
= rStyleSettings
.GetFaceColor();
221 aColor
= rStyleSettings
.GetWindowColor();
222 SetBackground( aColor
);
223 mpImplData
->mpVirDev
->SetBackground( GetBackground() );
226 if( ! IsControlBackground() &&
227 IsNativeControlSupported( CTRL_WINDOW_BACKGROUND
, PART_BACKGROUND_WINDOW
) )
229 ImplGetWindowImpl()->mnNativeBackground
= PART_BACKGROUND_WINDOW
;
230 EnableChildTransparentMode( sal_True
);
235 // -----------------------------------------------------------------------
237 void StatusBar::ImplFormat()
239 ImplStatusItem
* pItem
;
243 sal_uInt16 nAutoSizeItems
= 0;
245 // Breiten zusammenrechnen
246 mnItemsWidth
= STATUSBAR_OFFSET_X
;
248 for ( size_t i
= 0, n
= mpItemList
->size(); i
< n
; ++i
) {
249 pItem
= (*mpItemList
)[ i
];
250 if ( pItem
->mbVisible
)
252 if ( pItem
->mnBits
& SIB_AUTOSIZE
) {
256 mnItemsWidth
+= pItem
->mnWidth
+ nOffset
;
257 nOffset
= pItem
->mnOffset
;
261 if ( GetStyle() & WB_RIGHT
)
263 // Bei rechtsbuendiger Ausrichtung wird kein AutoSize ausgewertet,
264 // da wir links den Text anzeigen, der mit SetText gesetzt wird
265 nX
= mnDX
- mnItemsWidth
;
271 mnItemsWidth
+= STATUSBAR_OFFSET_X
;
273 // Bei linksbuendiger Ausrichtung muessen wir gegebenenfalls noch
274 // AutoSize auswerten
275 if ( nAutoSizeItems
&& (mnDX
> (mnItemsWidth
- STATUSBAR_OFFSET
)) )
277 nExtraWidth
= (mnDX
- mnItemsWidth
- 1) / nAutoSizeItems
;
278 nExtraWidth2
= (mnDX
- mnItemsWidth
- 1) % nAutoSizeItems
;
285 nX
= STATUSBAR_OFFSET_X
;
286 if( ImplHasMirroredGraphics() && IsRTLEnabled() )
287 nX
+= ImplGetSVData()->maNWFData
.mnStatusBarLowerRightOffset
;
290 for ( size_t i
= 0, n
= mpItemList
->size(); i
< n
; ++i
) {
291 pItem
= (*mpItemList
)[ i
];
292 if ( pItem
->mbVisible
) {
293 if ( pItem
->mnBits
& SIB_AUTOSIZE
) {
294 pItem
->mnExtraWidth
= nExtraWidth
;
295 if ( nExtraWidth2
) {
296 pItem
->mnExtraWidth
++;
300 pItem
->mnExtraWidth
= 0;
304 nX
+= pItem
->mnWidth
+ pItem
->mnExtraWidth
+ pItem
->mnOffset
;
308 mbFormat
= sal_False
;
311 // -----------------------------------------------------------------------
313 Rectangle
StatusBar::ImplGetItemRectPos( sal_uInt16 nPos
) const
316 ImplStatusItem
* pItem
;
317 pItem
= ( nPos
< mpItemList
->size() ) ? (*mpItemList
)[ nPos
] : NULL
;
320 if ( pItem
->mbVisible
)
322 aRect
.Left() = pItem
->mnX
;
323 aRect
.Right() = aRect
.Left() + pItem
->mnWidth
+ pItem
->mnExtraWidth
;
324 aRect
.Top() = mnItemY
;
325 aRect
.Bottom() = mnCalcHeight
- STATUSBAR_OFFSET_Y
;
332 // -----------------------------------------------------------------------
334 sal_uInt16
StatusBar::ImplGetFirstVisiblePos() const
336 ImplStatusItem
* pItem
;
338 for( size_t nPos
= 0; nPos
< mpItemList
->size(); nPos
++ )
340 pItem
= (*mpItemList
)[ nPos
];
343 if ( pItem
->mbVisible
)
344 return sal_uInt16(nPos
);
351 // -----------------------------------------------------------------------
353 void StatusBar::ImplDrawText( sal_Bool bOffScreen
, long nOldTextWidth
)
355 // Das ueberschreiben der Item-Box verhindern
357 aTextRect
.Left() = STATUSBAR_OFFSET_X
+1;
358 aTextRect
.Top() = mnTextY
;
359 if ( mbVisibleItems
&& (GetStyle() & WB_RIGHT
) )
360 aTextRect
.Right() = mnDX
- mnItemsWidth
- 1;
362 aTextRect
.Right() = mnDX
- 1;
363 if ( aTextRect
.Right() > aTextRect
.Left() )
365 // Position ermitteln
366 OUString aStr
= GetText();
367 sal_Int32 nPos
= aStr
.indexOf('\n');
369 aStr
= aStr
.copy(0, nPos
);
371 aTextRect
.Bottom() = aTextRect
.Top()+GetTextHeight()+1;
375 long nMaxWidth
= std::max( nOldTextWidth
, GetTextWidth( aStr
) );
376 Size
aVirDevSize( nMaxWidth
, aTextRect
.GetHeight() );
377 mpImplData
->mpVirDev
->SetOutputSizePixel( aVirDevSize
);
378 Rectangle aTempRect
= aTextRect
;
379 aTempRect
.SetPos( Point( 0, 0 ) );
380 mpImplData
->mpVirDev
->DrawText( aTempRect
, aStr
, TEXT_DRAW_LEFT
| TEXT_DRAW_TOP
| TEXT_DRAW_CLIP
| TEXT_DRAW_ENDELLIPSIS
);
381 DrawOutDev( aTextRect
.TopLeft(), aVirDevSize
, Point(), aVirDevSize
, *mpImplData
->mpVirDev
);
384 DrawText( aTextRect
, aStr
, TEXT_DRAW_LEFT
| TEXT_DRAW_TOP
| TEXT_DRAW_CLIP
| TEXT_DRAW_ENDELLIPSIS
);
388 // -----------------------------------------------------------------------
390 void StatusBar::ImplDrawItem( sal_Bool bOffScreen
, sal_uInt16 nPos
, sal_Bool bDrawText
, sal_Bool bDrawFrame
)
392 Rectangle aRect
= ImplGetItemRectPos( nPos
);
394 if ( aRect
.IsEmpty() )
397 // Ausgabebereich berechnen
398 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
399 long nW
= mpImplData
->mnItemBorderWidth
+ 1;
400 Rectangle
aTextRect( aRect
.Left()+nW
, aRect
.Top()+nW
,
401 aRect
.Right()-nW
, aRect
.Bottom()-nW
);
402 Size
aTextRectSize( aTextRect
.GetSize() );
405 mpImplData
->mpVirDev
->SetOutputSizePixel( aTextRectSize
);
408 Region
aRegion( aTextRect
);
409 SetClipRegion( aRegion
);
415 Size
aTextSize( GetTextWidth( pItem
->maText
), GetTextHeight() );
416 Point aTextPos
= ImplGetItemTextPos( aTextRectSize
, aTextSize
, pItem
->mnBits
);
418 mpImplData
->mpVirDev
->DrawText( aTextPos
, pItem
->maText
);
421 aTextPos
.X() += aTextRect
.Left();
422 aTextPos
.Y() += aTextRect
.Top();
423 DrawText( aTextPos
, pItem
->maText
);
427 // Gegebenenfalls auch DrawItem aufrufen
428 if ( pItem
->mnBits
& SIB_USERDRAW
)
432 mbInUserDraw
= sal_True
;
433 mpImplData
->mpVirDev
->EnableRTL( IsRTLEnabled() );
434 UserDrawEvent
aODEvt( mpImplData
->mpVirDev
, Rectangle( Point(), aTextRectSize
), pItem
->mnId
);
436 mpImplData
->mpVirDev
->EnableRTL( sal_False
);
437 mbInUserDraw
= sal_False
;
441 UserDrawEvent
aODEvt( this, aTextRect
, pItem
->mnId
);
447 DrawOutDev( aTextRect
.TopLeft(), aTextRectSize
, Point(), aTextRectSize
, *mpImplData
->mpVirDev
);
454 if( mpImplData
->mbDrawItemFrames
)
456 if( !(pItem
->mnBits
& SIB_FLAT
) )
460 if ( pItem
->mnBits
& SIB_IN
)
461 nStyle
= FRAME_DRAW_IN
;
463 nStyle
= FRAME_DRAW_OUT
;
465 DecorationView
aDecoView( this );
466 aDecoView
.DrawFrame( aRect
, nStyle
);
469 else if( nPos
!= ImplGetFirstVisiblePos() )
472 Point
aFrom( aRect
.TopLeft() );
475 Point
aTo( aRect
.BottomLeft() );
479 DecorationView
aDecoView( this );
480 aDecoView
.DrawSeparator( aFrom
, aTo
);
484 if ( !ImplIsRecordLayout() )
485 ImplCallEventListeners( VCLEVENT_STATUSBAR_DRAWITEM
, (void*) sal_IntPtr(pItem
->mnId
) );
488 // -----------------------------------------------------------------------
490 void DrawProgress( Window
* pWindow
, const Point
& rPos
,
491 long nOffset
, long nPrgsWidth
, long nPrgsHeight
,
492 sal_uInt16 nPercent1
, sal_uInt16 nPercent2
, sal_uInt16 nPercentCount
,
493 const Rectangle
& rFramePosSize
496 if( pWindow
->IsNativeControlSupported( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
) )
498 bool bNeedErase
= ImplGetSVData()->maNWFData
.mbProgressNeedsErase
;
500 long nFullWidth
= (nPrgsWidth
+ nOffset
) * (10000 / nPercentCount
);
501 long nPerc
= (nPercent2
> 10000) ? 10000 : nPercent2
;
502 ImplControlValue
aValue( nFullWidth
* (long)nPerc
/ 10000 );
503 Rectangle
aDrawRect( rPos
, Size( nFullWidth
, nPrgsHeight
) );
504 Rectangle
aControlRegion( aDrawRect
);
507 Window
* pEraseWindow
= pWindow
;
508 while( pEraseWindow
->IsPaintTransparent() &&
509 ! pEraseWindow
->ImplGetWindowImpl()->mbFrame
)
511 pEraseWindow
= pEraseWindow
->ImplGetWindowImpl()->mpParent
;
513 if( pEraseWindow
== pWindow
)
514 // restore background of pWindow
515 pEraseWindow
->Erase( rFramePosSize
);
518 // restore transparent background
519 Point
aTL( pWindow
->OutputToAbsoluteScreenPixel( rFramePosSize
.TopLeft() ) );
520 aTL
= pEraseWindow
->AbsoluteScreenToOutputPixel( aTL
);
521 Rectangle
aRect( aTL
, rFramePosSize
.GetSize() );
522 pEraseWindow
->Invalidate( aRect
, INVALIDATE_NOCHILDREN
|
523 INVALIDATE_NOCLIPCHILDREN
|
524 INVALIDATE_TRANSPARENT
);
525 pEraseWindow
->Update();
527 pWindow
->Push( PUSH_CLIPREGION
);
528 pWindow
->IntersectClipRegion( rFramePosSize
);
530 sal_Bool bNativeOK
= pWindow
->DrawNativeControl( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
, aControlRegion
,
531 CTRL_STATE_ENABLED
, aValue
, OUString() );
541 // Werte vorberechnen
542 sal_uInt16 nPerc1
= nPercent1
/ nPercentCount
;
543 sal_uInt16 nPerc2
= nPercent2
/ nPercentCount
;
545 if ( nPerc1
> nPerc2
)
547 // Support progress that can also decrease
549 // Rechteck berechnen
550 long nDX
= nPrgsWidth
+ nOffset
;
551 long nLeft
= rPos
.X()+((nPerc1
-1)*nDX
);
552 Rectangle
aRect( nLeft
, rPos
.Y(), nLeft
+nPrgsWidth
, rPos
.Y()+nPrgsHeight
);
556 pWindow
->Erase( aRect
);
558 aRect
.Right() -= nDX
;
561 while ( nPerc1
> nPerc2
);
565 else if ( nPerc1
< nPerc2
)
567 // Percent-Rechtecke malen
568 // Wenn Percent2 ueber 100%, Werte anpassen
569 if ( nPercent2
> 10000 )
571 nPerc2
= 10000 / nPercentCount
;
572 if ( nPerc1
>= nPerc2
)
576 // Rechteck berechnen
577 long nDX
= nPrgsWidth
+ nOffset
;
578 long nLeft
= rPos
.X()+(nPerc1
*nDX
);
579 Rectangle
aRect( nLeft
, rPos
.Y(), nLeft
+nPrgsWidth
, rPos
.Y()+nPrgsHeight
);
583 pWindow
->DrawRect( aRect
);
585 aRect
.Right() += nDX
;
588 while ( nPerc1
< nPerc2
);
590 // Bei mehr als 100%, lassen wir das Rechteck blinken
591 if ( nPercent2
> 10000 )
593 // an/aus-Status festlegen
594 if ( ((nPercent2
/ nPercentCount
) & 0x01) == (nPercentCount
& 0x01) )
597 aRect
.Right() -= nDX
;
598 pWindow
->Erase( aRect
);
606 // -----------------------------------------------------------------------
608 void StatusBar::ImplDrawProgress( sal_Bool bPaint
,
609 sal_uInt16 nPercent1
, sal_uInt16 nPercent2
)
611 bool bNative
= IsNativeControlSupported( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
);
612 // bPaint: draw text also, else only update progress
615 DrawText( maPrgsTxtPos
, maPrgsTxt
);
618 DecorationView
aDecoView( this );
619 aDecoView
.DrawFrame( maPrgsFrameRect
, FRAME_DRAW_IN
);
623 Point
aPos( maPrgsFrameRect
.Left()+STATUSBAR_PRGS_OFFSET
,
624 maPrgsFrameRect
.Top()+STATUSBAR_PRGS_OFFSET
);
625 long nPrgsHeight
= mnPrgsSize
;
628 aPos
= maPrgsFrameRect
.TopLeft();
629 nPrgsHeight
= maPrgsFrameRect
.GetHeight();
631 DrawProgress( this, aPos
, mnPrgsSize
/2, mnPrgsSize
, nPrgsHeight
,
632 nPercent1
*100, nPercent2
*100, mnPercentCount
, maPrgsFrameRect
);
635 // -----------------------------------------------------------------------
637 void StatusBar::ImplCalcProgressRect()
639 // calculate text size
640 Size
aPrgsTxtSize( GetTextWidth( maPrgsTxt
), GetTextHeight() );
641 maPrgsTxtPos
.X() = STATUSBAR_OFFSET_X
+1;
643 // calculate progress frame
644 maPrgsFrameRect
.Left() = maPrgsTxtPos
.X()+aPrgsTxtSize
.Width()+STATUSBAR_OFFSET
;
645 maPrgsFrameRect
.Top() = mnItemY
;
646 maPrgsFrameRect
.Bottom() = mnCalcHeight
- STATUSBAR_OFFSET_Y
;
648 // calculate size of progress rects
649 mnPrgsSize
= maPrgsFrameRect
.Bottom()-maPrgsFrameRect
.Top()-(STATUSBAR_PRGS_OFFSET
*2);
650 sal_uInt16 nMaxPercent
= STATUSBAR_PRGS_COUNT
;
652 long nMaxWidth
= mnDX
-STATUSBAR_OFFSET
-1;
654 // make smaller if there are too many rects
655 while ( maPrgsFrameRect
.Left()+ImplCalcProgessWidth( nMaxPercent
, mnPrgsSize
) > nMaxWidth
)
658 if ( nMaxPercent
<= STATUSBAR_PRGS_MIN
)
661 maPrgsFrameRect
.Right() = maPrgsFrameRect
.Left() + ImplCalcProgessWidth( nMaxPercent
, mnPrgsSize
);
663 // save the divisor for later
664 mnPercentCount
= 10000 / nMaxPercent
;
665 sal_Bool bNativeOK
= sal_False
;
666 if( IsNativeControlSupported( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
) )
668 ImplControlValue aValue
;
669 Rectangle
aControlRegion( Rectangle( (const Point
&)Point(), maPrgsFrameRect
.GetSize() ) );
670 Rectangle aNativeControlRegion
, aNativeContentRegion
;
671 if( (bNativeOK
= GetNativeControlRegion( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
, aControlRegion
,
672 CTRL_STATE_ENABLED
, aValue
, OUString(),
673 aNativeControlRegion
, aNativeContentRegion
) ) != sal_False
)
675 long nProgressHeight
= aNativeControlRegion
.GetHeight();
676 if( nProgressHeight
> maPrgsFrameRect
.GetHeight() )
678 long nDelta
= nProgressHeight
- maPrgsFrameRect
.GetHeight();
679 maPrgsFrameRect
.Top() -= (nDelta
- nDelta
/2);
680 maPrgsFrameRect
.Bottom() += nDelta
/2;
682 maPrgsTxtPos
.Y() = maPrgsFrameRect
.Top() + (nProgressHeight
- GetTextHeight())/2;
686 maPrgsTxtPos
.Y() = mnTextY
;
689 // -----------------------------------------------------------------------
691 void StatusBar::MouseButtonDown( const MouseEvent
& rMEvt
)
693 // Nur bei linker Maustaste ToolBox ausloesen
694 if ( rMEvt
.IsLeft() )
696 if ( mbVisibleItems
)
698 Point aMousePos
= rMEvt
.GetPosPixel();
700 // Item suchen, das geklickt wurde
701 for ( size_t i
= 0; i
< mpItemList
->size(); ++i
)
703 ImplStatusItem
* pItem
= (*mpItemList
)[ i
];
704 // Ist es dieses Item
705 if ( ImplGetItemRectPos( sal_uInt16(i
) ).IsInside( aMousePos
) )
707 mnCurItemId
= pItem
->mnId
;
708 if ( rMEvt
.GetClicks() == 2 )
714 // Item wurde gefunden
720 // Kein Item, dann nur Click oder DoubleClick
721 if ( rMEvt
.GetClicks() == 2 )
728 // -----------------------------------------------------------------------
730 void StatusBar::Paint( const Rectangle
& )
735 sal_uInt16 nItemCount
= sal_uInt16( mpItemList
->size() );
737 if ( mbProgressMode
)
738 ImplDrawProgress( sal_True
, 0, mnPercent
);
742 if ( !mbVisibleItems
|| (GetStyle() & WB_RIGHT
) )
743 ImplDrawText( sal_False
, 0 );
746 if ( mbVisibleItems
)
749 for ( sal_uInt16 i
= 0; i
< nItemCount
; i
++ )
750 ImplDrawItem( sal_False
, i
, sal_True
, sal_True
);
754 // draw line at the top of the status bar (to visually distinguish it from
755 // shell / docking area)
756 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
757 SetLineColor( rStyleSettings
.GetShadowColor() );
758 DrawLine( Point( 0, 0 ), Point( mnDX
-1, 0 ) );
761 // -----------------------------------------------------------------------
763 void StatusBar::Move()
768 // -----------------------------------------------------------------------
770 void StatusBar::Resize()
772 // Breite und Hoehe abfragen und merken
773 Size aSize
= GetOutputSizePixel();
774 mnDX
= aSize
.Width() - ImplGetSVData()->maNWFData
.mnStatusBarLowerRightOffset
;
775 mnDY
= aSize
.Height();
778 mnItemY
= STATUSBAR_OFFSET_Y
;
779 mnTextY
= (mnCalcHeight
-GetTextHeight())/2;
781 // Formatierung neu ausloesen
784 if ( mbProgressMode
)
785 ImplCalcProgressRect();
790 // -----------------------------------------------------------------------
792 void StatusBar::RequestHelp( const HelpEvent
& rHEvt
)
794 // no keyboard help in status bar
795 if( rHEvt
.KeyboardActivated() )
798 sal_uInt16 nItemId
= GetItemId( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ) );
802 Rectangle aItemRect
= GetItemRect( nItemId
);
803 Point aPt
= OutputToScreenPixel( aItemRect
.TopLeft() );
804 aItemRect
.Left() = aPt
.X();
805 aItemRect
.Top() = aPt
.Y();
806 aPt
= OutputToScreenPixel( aItemRect
.BottomRight() );
807 aItemRect
.Right() = aPt
.X();
808 aItemRect
.Bottom() = aPt
.Y();
810 if ( rHEvt
.GetMode() & HELPMODE_BALLOON
)
812 OUString aStr
= GetHelpText( nItemId
);
813 Help::ShowBalloon( this, aItemRect
.Center(), aItemRect
, aStr
);
816 else if ( rHEvt
.GetMode() & HELPMODE_QUICK
)
818 OUString
aStr(GetQuickHelpText(nItemId
));
819 // Show quickhelp if available
822 Help::ShowQuickHelp( this, aItemRect
, aStr
);
825 aStr
= GetItemText( nItemId
);
826 // show a quick help if item text doesn't fit
827 if ( GetTextWidth( aStr
) > aItemRect
.GetWidth() )
829 Help::ShowQuickHelp( this, aItemRect
, aStr
);
833 else if ( rHEvt
.GetMode() & HELPMODE_EXTENDED
)
835 OUString aCommand
= GetItemCommand( nItemId
);
836 OString
aHelpId( GetHelpId( nItemId
) );
838 if ( !aCommand
.isEmpty() || !aHelpId
.isEmpty() )
840 // Wenn eine Hilfe existiert, dann ausloesen
841 Help
* pHelp
= Application::GetHelp();
844 if ( !aCommand
.isEmpty() )
845 pHelp
->Start( aCommand
, this );
846 else if ( !aHelpId
.isEmpty() )
847 pHelp
->Start( OStringToOUString( aHelpId
, RTL_TEXTENCODING_UTF8
), this );
854 Window::RequestHelp( rHEvt
);
857 // -----------------------------------------------------------------------
859 void StatusBar::StateChanged( StateChangedType nType
)
861 Window::StateChanged( nType
);
863 if ( nType
== STATE_CHANGE_INITSHOW
)
865 else if ( nType
== STATE_CHANGE_UPDATEMODE
)
867 else if ( (nType
== STATE_CHANGE_ZOOM
) ||
868 (nType
== STATE_CHANGE_CONTROLFONT
) )
871 ImplInitSettings( sal_True
, sal_False
, sal_False
);
874 else if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
876 ImplInitSettings( sal_False
, sal_True
, sal_False
);
879 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
881 ImplInitSettings( sal_False
, sal_False
, sal_True
);
886 // -----------------------------------------------------------------------
888 void StatusBar::DataChanged( const DataChangedEvent
& rDCEvt
)
890 Window::DataChanged( rDCEvt
);
892 if ( (rDCEvt
.GetType() == DATACHANGED_DISPLAY
)
893 || (rDCEvt
.GetType() == DATACHANGED_FONTS
)
894 || (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
)
895 || ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
)
896 && (rDCEvt
.GetFlags() & SETTINGS_STYLE
)
901 ImplInitSettings( sal_True
, sal_True
, sal_True
);
902 long nFudge
= GetTextHeight() / 4;
903 for ( size_t i
= 0, n
= mpItemList
->size(); i
< n
; ++i
)
905 ImplStatusItem
* pItem
= (*mpItemList
)[ i
];
906 long nWidth
= GetTextWidth( pItem
->maText
) + nFudge
;
907 if( nWidth
> pItem
->mnWidth
+ STATUSBAR_OFFSET
)
908 pItem
->mnWidth
= nWidth
+ STATUSBAR_OFFSET
;
910 Size aSize
= GetSizePixel();
911 // do not disturb current width, since
912 // CalcWindowSizePixel calculates a minimum width
913 aSize
.Height() = CalcWindowSizePixel().Height();
914 SetSizePixel( aSize
);
919 // -----------------------------------------------------------------------
921 void StatusBar::Click()
923 ImplCallEventListeners( VCLEVENT_STATUSBAR_CLICK
);
924 maClickHdl
.Call( this );
927 // -----------------------------------------------------------------------
929 void StatusBar::DoubleClick()
931 ImplCallEventListeners( VCLEVENT_STATUSBAR_DOUBLECLICK
);
932 maDoubleClickHdl
.Call( this );
935 // -----------------------------------------------------------------------
937 void StatusBar::UserDraw( const UserDrawEvent
& )
941 // -----------------------------------------------------------------------
943 void StatusBar::InsertItem( sal_uInt16 nItemId
, sal_uLong nWidth
,
944 StatusBarItemBits nBits
,
945 long nOffset
, sal_uInt16 nPos
)
947 DBG_ASSERT( nItemId
, "StatusBar::InsertItem(): ItemId == 0" );
948 DBG_ASSERT( GetItemPos( nItemId
) == STATUSBAR_ITEM_NOTFOUND
,
949 "StatusBar::InsertItem(): ItemId already exists" );
951 // IN und CENTER sind Default
952 if ( !(nBits
& (SIB_IN
| SIB_OUT
| SIB_FLAT
)) )
954 if ( !(nBits
& (SIB_LEFT
| SIB_RIGHT
| SIB_CENTER
)) )
958 long nFudge
= GetTextHeight()/4;
959 ImplStatusItem
* pItem
= new ImplStatusItem
;
960 pItem
->mnId
= nItemId
;
961 pItem
->mnBits
= nBits
;
962 pItem
->mnWidth
= (long)nWidth
+nFudge
+STATUSBAR_OFFSET
;
963 pItem
->mnOffset
= nOffset
;
964 pItem
->mpUserData
= 0;
965 pItem
->mbVisible
= sal_True
;
967 // Item in die Liste einfuegen
968 if ( nPos
< mpItemList
->size() ) {
969 mpItemList
->insert( mpItemList
->begin() + nPos
, pItem
);
971 mpItemList
->push_back( pItem
);
975 if ( ImplIsItemUpdate() )
978 ImplCallEventListeners( VCLEVENT_STATUSBAR_ITEMADDED
, (void*) sal_IntPtr(nItemId
) );
981 // -----------------------------------------------------------------------
983 void StatusBar::RemoveItem( sal_uInt16 nItemId
)
985 sal_uInt16 nPos
= GetItemPos( nItemId
);
986 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
988 delete (*mpItemList
)[ nPos
];
989 mpItemList
->erase( mpItemList
->begin() + nPos
);
992 if ( ImplIsItemUpdate() )
995 ImplCallEventListeners( VCLEVENT_STATUSBAR_ITEMREMOVED
, (void*) sal_IntPtr(nItemId
) );
999 // -----------------------------------------------------------------------
1001 void StatusBar::ShowItem( sal_uInt16 nItemId
)
1003 sal_uInt16 nPos
= GetItemPos( nItemId
);
1005 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1007 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1008 if ( !pItem
->mbVisible
)
1010 pItem
->mbVisible
= sal_True
;
1012 mbFormat
= sal_True
;
1013 if ( ImplIsItemUpdate() )
1016 ImplCallEventListeners( VCLEVENT_STATUSBAR_SHOWITEM
, (void*) sal_IntPtr(nItemId
) );
1021 // -----------------------------------------------------------------------
1023 void StatusBar::HideItem( sal_uInt16 nItemId
)
1025 sal_uInt16 nPos
= GetItemPos( nItemId
);
1027 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1029 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1030 if ( pItem
->mbVisible
)
1032 pItem
->mbVisible
= sal_False
;
1034 mbFormat
= sal_True
;
1035 if ( ImplIsItemUpdate() )
1038 ImplCallEventListeners( VCLEVENT_STATUSBAR_HIDEITEM
, (void*) sal_IntPtr(nItemId
) );
1043 // -----------------------------------------------------------------------
1045 sal_Bool
StatusBar::IsItemVisible( sal_uInt16 nItemId
) const
1047 sal_uInt16 nPos
= GetItemPos( nItemId
);
1049 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1050 return (*mpItemList
)[ nPos
]->mbVisible
;
1055 void StatusBar::Clear()
1057 // Alle Item loeschen
1058 for ( size_t i
= 0, n
= mpItemList
->size(); i
< n
; ++i
) {
1059 delete (*mpItemList
)[ i
];
1061 mpItemList
->clear();
1063 mbFormat
= sal_True
;
1064 if ( ImplIsItemUpdate() )
1067 ImplCallEventListeners( VCLEVENT_STATUSBAR_ALLITEMSREMOVED
);
1070 // -----------------------------------------------------------------------
1072 sal_uInt16
StatusBar::GetItemCount() const
1074 return (sal_uInt16
)mpItemList
->size();
1077 // -----------------------------------------------------------------------
1079 sal_uInt16
StatusBar::GetItemId( sal_uInt16 nPos
) const
1081 if ( nPos
< mpItemList
->size() )
1082 return (*mpItemList
)[ nPos
]->mnId
;
1086 // -----------------------------------------------------------------------
1088 sal_uInt16
StatusBar::GetItemPos( sal_uInt16 nItemId
) const
1090 for ( size_t i
= 0, n
= mpItemList
->size(); i
< n
; ++i
) {
1091 if ( (*mpItemList
)[ i
]->mnId
== nItemId
) {
1092 return sal_uInt16( i
);
1096 return STATUSBAR_ITEM_NOTFOUND
;
1099 // -----------------------------------------------------------------------
1101 sal_uInt16
StatusBar::GetItemId( const Point
& rPos
) const
1103 if ( AreItemsVisible() && !mbFormat
)
1105 sal_uInt16 nItemCount
= GetItemCount();
1107 for ( nPos
= 0; nPos
< nItemCount
; nPos
++ )
1110 Rectangle aRect
= ImplGetItemRectPos( nPos
);
1111 if ( aRect
.IsInside( rPos
) )
1112 return (*mpItemList
)[ nPos
]->mnId
;
1119 // -----------------------------------------------------------------------
1121 Rectangle
StatusBar::GetItemRect( sal_uInt16 nItemId
) const
1125 if ( AreItemsVisible() && !mbFormat
)
1127 sal_uInt16 nPos
= GetItemPos( nItemId
);
1128 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1130 // Rechteck holen und Rahmen abziehen
1131 aRect
= ImplGetItemRectPos( nPos
);
1132 long nW
= mpImplData
->mnItemBorderWidth
+1;
1133 aRect
.Top() += nW
-1;
1134 aRect
.Bottom() -= nW
-1;
1136 aRect
.Right() -= nW
;
1144 // -----------------------------------------------------------------------
1146 Point
StatusBar::GetItemTextPos( sal_uInt16 nItemId
) const
1150 sal_uInt16 nPos
= GetItemPos( nItemId
);
1151 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1154 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1155 Rectangle aRect
= ImplGetItemRectPos( nPos
);
1156 long nW
= mpImplData
->mnItemBorderWidth
+ 1;
1157 Rectangle
aTextRect( aRect
.Left()+nW
, aRect
.Top()+nW
,
1158 aRect
.Right()-nW
, aRect
.Bottom()-nW
);
1159 Point aPos
= ImplGetItemTextPos( aTextRect
.GetSize(),
1160 Size( GetTextWidth( pItem
->maText
), GetTextHeight() ),
1162 if ( !mbInUserDraw
)
1164 aPos
.X() += aTextRect
.Left();
1165 aPos
.Y() += aTextRect
.Top();
1174 // -----------------------------------------------------------------------
1176 sal_uLong
StatusBar::GetItemWidth( sal_uInt16 nItemId
) const
1178 sal_uInt16 nPos
= GetItemPos( nItemId
);
1180 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1181 return (*mpItemList
)[ nPos
]->mnWidth
;
1186 // -----------------------------------------------------------------------
1188 StatusBarItemBits
StatusBar::GetItemBits( sal_uInt16 nItemId
) const
1190 sal_uInt16 nPos
= GetItemPos( nItemId
);
1192 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1193 return (*mpItemList
)[ nPos
]->mnBits
;
1198 // -----------------------------------------------------------------------
1200 long StatusBar::GetItemOffset( sal_uInt16 nItemId
) const
1202 sal_uInt16 nPos
= GetItemPos( nItemId
);
1204 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1205 return (*mpItemList
)[ nPos
]->mnOffset
;
1210 // -----------------------------------------------------------------------
1212 void StatusBar::SetItemText( sal_uInt16 nItemId
, const OUString
& rText
)
1214 sal_uInt16 nPos
= GetItemPos( nItemId
);
1216 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1218 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1220 if ( pItem
->maText
!= rText
)
1222 pItem
->maText
= rText
;
1224 // adjust item width - see also DataChanged()
1225 long nFudge
= GetTextHeight()/4;
1226 long nWidth
= GetTextWidth( pItem
->maText
) + nFudge
;
1227 if( (nWidth
> pItem
->mnWidth
+ STATUSBAR_OFFSET
) ||
1228 ((nWidth
< pItem
->mnWidth
) && (mnDX
- STATUSBAR_OFFSET
) < mnItemsWidth
))
1230 pItem
->mnWidth
= nWidth
+ STATUSBAR_OFFSET
;
1235 // Item neu Zeichen, wenn StatusBar sichtbar und
1236 // UpdateMode gesetzt ist
1237 if ( pItem
->mbVisible
&& !mbFormat
&& ImplIsItemUpdate() )
1240 ImplDrawItem( sal_True
, nPos
, sal_True
, sal_False
);
1247 // -----------------------------------------------------------------------
1249 const OUString
& StatusBar::GetItemText( sal_uInt16 nItemId
) const
1251 sal_uInt16 nPos
= GetItemPos( nItemId
);
1253 assert( nPos
!= STATUSBAR_ITEM_NOTFOUND
);
1255 return (*mpItemList
)[ nPos
]->maText
;
1258 // -----------------------------------------------------------------------
1260 void StatusBar::SetItemCommand( sal_uInt16 nItemId
, const OUString
& rCommand
)
1262 sal_uInt16 nPos
= GetItemPos( nItemId
);
1264 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1266 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1268 if ( pItem
->maCommand
!= rCommand
)
1269 pItem
->maCommand
= rCommand
;
1273 // -----------------------------------------------------------------------
1275 const OUString
StatusBar::GetItemCommand( sal_uInt16 nItemId
)
1277 sal_uInt16 nPos
= GetItemPos( nItemId
);
1279 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1280 return (*mpItemList
)[ nPos
]->maCommand
;
1285 // -----------------------------------------------------------------------
1287 void StatusBar::SetItemData( sal_uInt16 nItemId
, void* pNewData
)
1289 sal_uInt16 nPos
= GetItemPos( nItemId
);
1291 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1293 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1294 pItem
->mpUserData
= pNewData
;
1296 // Wenn es ein User-Item ist, DrawItem-Aufrufen
1297 if ( (pItem
->mnBits
& SIB_USERDRAW
) && pItem
->mbVisible
&&
1298 !mbFormat
&& ImplIsItemUpdate() )
1301 ImplDrawItem( sal_True
, nPos
, sal_False
, sal_False
);
1307 void* StatusBar::GetItemData( sal_uInt16 nItemId
) const
1309 sal_uInt16 nPos
= GetItemPos( nItemId
);
1311 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1312 return (*mpItemList
)[ nPos
]->mpUserData
;
1317 void StatusBar::RedrawItem( sal_uInt16 nItemId
)
1322 sal_uInt16 nPos
= GetItemPos( nItemId
);
1323 if ( nPos
== STATUSBAR_ITEM_NOTFOUND
)
1326 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1327 if ( pItem
&& (pItem
->mnBits
& SIB_USERDRAW
) &&
1328 pItem
->mbVisible
&& ImplIsItemUpdate() )
1331 ImplDrawItem( sal_True
, nPos
, sal_False
, sal_False
);
1336 // -----------------------------------------------------------------------
1338 void StatusBar::SetHelpText( sal_uInt16 nItemId
, const OUString
& rText
)
1340 sal_uInt16 nPos
= GetItemPos( nItemId
);
1342 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1343 (*mpItemList
)[ nPos
]->maHelpText
= rText
;
1346 // -----------------------------------------------------------------------
1348 const OUString
& StatusBar::GetHelpText( sal_uInt16 nItemId
) const
1350 sal_uInt16 nPos
= GetItemPos( nItemId
);
1352 assert ( nPos
!= STATUSBAR_ITEM_NOTFOUND
);
1354 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1355 if ( pItem
->maHelpText
.isEmpty() && ( !pItem
->maHelpId
.isEmpty() || !pItem
->maCommand
.isEmpty() ))
1357 Help
* pHelp
= Application::GetHelp();
1360 if ( !pItem
->maCommand
.isEmpty() )
1361 pItem
->maHelpText
= pHelp
->GetHelpText( pItem
->maCommand
, this );
1362 if ( pItem
->maHelpText
.isEmpty() && !pItem
->maHelpId
.isEmpty() )
1363 pItem
->maHelpText
= pHelp
->GetHelpText( OStringToOUString( pItem
->maHelpId
, RTL_TEXTENCODING_UTF8
), this );
1367 return pItem
->maHelpText
;
1370 // -----------------------------------------------------------------------
1372 void StatusBar::SetQuickHelpText( sal_uInt16 nItemId
, const OUString
& rText
)
1374 sal_uInt16 nPos
= GetItemPos( nItemId
);
1376 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1377 (*mpItemList
)[ nPos
]->maQuickHelpText
= rText
;
1380 // -----------------------------------------------------------------------
1382 const OUString
& StatusBar::GetQuickHelpText( sal_uInt16 nItemId
) const
1384 sal_uInt16 nPos
= GetItemPos( nItemId
);
1386 assert ( nPos
!= STATUSBAR_ITEM_NOTFOUND
);
1388 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1389 return pItem
->maQuickHelpText
;
1392 // -----------------------------------------------------------------------
1394 void StatusBar::SetHelpId( sal_uInt16 nItemId
, const OString
& rHelpId
)
1396 sal_uInt16 nPos
= GetItemPos( nItemId
);
1398 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1399 (*mpItemList
)[ nPos
]->maHelpId
= rHelpId
;
1402 // -----------------------------------------------------------------------
1404 OString
StatusBar::GetHelpId( sal_uInt16 nItemId
) const
1406 sal_uInt16 nPos
= GetItemPos( nItemId
);
1409 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1411 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1412 if ( !pItem
->maHelpId
.isEmpty() )
1413 aRet
= pItem
->maHelpId
;
1415 aRet
= OUStringToOString( pItem
->maCommand
, RTL_TEXTENCODING_UTF8
);
1421 void StatusBar::StartProgressMode( const OUString
& rText
)
1423 DBG_ASSERT( !mbProgressMode
, "StatusBar::StartProgressMode(): progress mode is active" );
1425 mbProgressMode
= sal_True
;
1429 // Groessen berechnen
1430 ImplCalcProgressRect();
1432 // Paint ausloesen (dort wird der Text und der Frame gemalt)
1433 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1434 Color aPrgsColor
= rStyleSettings
.GetHighlightColor();
1435 if ( aPrgsColor
== rStyleSettings
.GetFaceColor() )
1436 aPrgsColor
= rStyleSettings
.GetDarkShadowColor();
1438 SetFillColor( aPrgsColor
);
1439 if ( IsReallyVisible() )
1447 // -----------------------------------------------------------------------
1449 void StatusBar::SetProgressValue( sal_uInt16 nNewPercent
)
1451 DBG_ASSERT( mbProgressMode
, "StatusBar::SetProgressValue(): no progrss mode" );
1452 DBG_ASSERTWARNING( nNewPercent
<= 100, "StatusBar::SetProgressValue(): nPercent > 100" );
1455 && IsReallyVisible()
1456 && (!mnPercent
|| (mnPercent
!= nNewPercent
)) )
1460 ImplDrawProgress( sal_False
, mnPercent
, nNewPercent
);
1463 mnPercent
= nNewPercent
;
1466 // -----------------------------------------------------------------------
1468 void StatusBar::EndProgressMode()
1470 DBG_ASSERT( mbProgressMode
, "StatusBar::EndProgressMode(): no progress mode" );
1472 mbProgressMode
= sal_False
;
1475 // Paint neu ausloesen um StatusBar wieder herzustellen
1476 SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
1477 if ( IsReallyVisible() )
1485 // -----------------------------------------------------------------------
1487 void StatusBar::SetText( const OUString
& rText
)
1489 if ( (!mbVisibleItems
|| (GetStyle() & WB_RIGHT
)) && !mbProgressMode
&&
1490 IsReallyVisible() && IsUpdateMode() )
1495 Window::SetText( rText
);
1500 long nOldTextWidth
= GetTextWidth( GetText() );
1501 Window::SetText( rText
);
1502 ImplDrawText( sal_True
, nOldTextWidth
);
1506 else if ( mbProgressMode
)
1509 if ( IsReallyVisible() )
1517 Window::SetText( rText
);
1520 // -----------------------------------------------------------------------
1522 Size
StatusBar::CalcWindowSizePixel() const
1525 size_t nCount
= mpItemList
->size();
1527 long nCalcWidth
= (STATUSBAR_OFFSET_X
*2);
1530 while ( i
< nCount
)
1532 ImplStatusItem
* pItem
= (*mpItemList
)[ i
];
1533 nCalcWidth
+= pItem
->mnWidth
+ nOffset
;
1534 nOffset
= pItem
->mnOffset
;
1538 long nMinHeight
= GetTextHeight();
1539 const long nBarTextOffset
= STATUSBAR_OFFSET_TEXTY
*2;
1540 long nProgressHeight
= nMinHeight
+ nBarTextOffset
;
1542 if( IsNativeControlSupported( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
) )
1544 ImplControlValue aValue
;
1545 Rectangle
aControlRegion( (const Point
&)Point(), Size( nCalcWidth
, nMinHeight
) );
1546 Rectangle aNativeControlRegion
, aNativeContentRegion
;
1547 if( GetNativeControlRegion( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
,
1548 aControlRegion
, CTRL_STATE_ENABLED
, aValue
, OUString(),
1549 aNativeControlRegion
, aNativeContentRegion
) )
1551 nProgressHeight
= aNativeControlRegion
.GetHeight();
1555 if( mpImplData
->mbDrawItemFrames
&&
1556 IsNativeControlSupported( CTRL_FRAME
, PART_BORDER
) )
1558 ImplControlValue
aControlValue( FRAME_DRAW_NODRAW
);
1559 Rectangle aBound
, aContent
;
1560 Rectangle
aNatRgn( Point( 0, 0 ), Size( 150, 50 ) );
1561 if( GetNativeControlRegion(CTRL_FRAME
, PART_BORDER
,
1562 aNatRgn
, 0, aControlValue
, OUString(), aBound
, aContent
) )
1564 mpImplData
->mnItemBorderWidth
=
1565 ( aBound
.GetHeight() - aContent
.GetHeight() ) / 2;
1569 nCalcHeight
= nMinHeight
+nBarTextOffset
+ 2*mpImplData
->mnItemBorderWidth
;
1570 if( nCalcHeight
< nProgressHeight
+2 )
1571 nCalcHeight
= nProgressHeight
+2;
1573 return Size( nCalcWidth
, nCalcHeight
);
1577 // -----------------------------------------------------------------------
1579 void StatusBar::SetAccessibleName( sal_uInt16 nItemId
, const OUString
& rName
)
1581 sal_uInt16 nPos
= GetItemPos( nItemId
);
1583 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1585 ImplStatusItem
* pItem
= (*mpItemList
)[ nPos
];
1587 if ( pItem
->maAccessibleName
!= rName
)
1589 pItem
->maAccessibleName
= rName
;
1590 ImplCallEventListeners( VCLEVENT_STATUSBAR_NAMECHANGED
, (void*) sal_IntPtr(pItem
->mnId
) );
1595 // -----------------------------------------------------------------------
1597 const OUString
& StatusBar::GetAccessibleName( sal_uInt16 nItemId
) const
1599 sal_uInt16 nPos
= GetItemPos( nItemId
);
1601 assert ( nPos
!= STATUSBAR_ITEM_NOTFOUND
);
1603 return (*mpItemList
)[ nPos
]->maAccessibleName
;
1606 // -----------------------------------------------------------------------
1608 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */