1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: status.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include <tools/list.hxx>
34 #include <tools/debug.hxx>
39 #include <vcl/svdata.hxx>
40 #include <vcl/event.hxx>
41 #include <vcl/decoview.hxx>
42 #include <vcl/svapp.hxx>
43 #include <vcl/help.hxx>
44 #include <vcl/status.hxx>
45 #include <vcl/virdev.hxx>
46 #include <vcl/window.h>
48 // =======================================================================
50 #define STATUSBAR_OFFSET_X STATUSBAR_OFFSET
51 #define STATUSBAR_OFFSET_Y 2
52 #define STATUSBAR_OFFSET_TEXTY 3
54 #define STATUSBAR_PRGS_OFFSET 3
55 #define STATUSBAR_PRGS_COUNT 100
56 #define STATUSBAR_PRGS_MIN 5
58 // -----------------------------------------------------------------------
60 class StatusBar::ImplData
66 VirtualDevice
* mpVirDev
;
70 StatusBar::ImplData::ImplData()
76 StatusBar::ImplData::~ImplData()
83 StatusBarItemBits mnBits
;
90 XubString maQuickHelpText
;
94 XubString maAccessibleName
;
98 DECLARE_LIST( ImplStatusItemList
, ImplStatusItem
* )
100 // =======================================================================
102 inline long ImplCalcProgessWidth( USHORT nMax
, long nSize
)
104 return ((nMax
*(nSize
+(nSize
/2)))-(nSize
/2)+(STATUSBAR_PRGS_OFFSET
*2));
107 // -----------------------------------------------------------------------
109 static Point
ImplGetItemTextPos( const Size
& rRectSize
, const Size
& rTextSize
,
114 long delta
= (rTextSize
.Height()/4) + 1;
115 if( delta
+ rTextSize
.Width() > rRectSize
.Width() )
118 if ( nStyle
& SIB_LEFT
)
120 else if ( nStyle
& SIB_RIGHT
)
121 nX
= rRectSize
.Width()-rTextSize
.Width()-delta
;
123 nX
= (rRectSize
.Width()-rTextSize
.Width())/2;
124 nY
= (rRectSize
.Height()-rTextSize
.Height())/2 + 1;
125 return Point( nX
, nY
);
128 // -----------------------------------------------------------------------
130 BOOL
StatusBar::ImplIsItemUpdate()
132 if ( !mbProgressMode
&& mbVisibleItems
&& IsReallyVisible() && IsUpdateMode() )
138 // -----------------------------------------------------------------------
140 void StatusBar::ImplInit( Window
* pParent
, WinBits nStyle
)
142 mpImplData
= new ImplData
;
144 // Default ist RightAlign
145 if ( !(nStyle
& (WB_LEFT
| WB_RIGHT
)) )
148 Window::ImplInit( pParent
, nStyle
& ~WB_BORDER
, NULL
);
151 mpItemList
= new ImplStatusItemList
;
152 mpImplData
->mpVirDev
= new VirtualDevice( *this );
155 mbVisibleItems
= TRUE
;
156 mbProgressMode
= FALSE
;
157 mbInUserDraw
= FALSE
;
158 mbBottomBorder
= FALSE
;
162 mnItemY
= STATUSBAR_OFFSET_Y
;
163 mnTextY
= STATUSBAR_OFFSET_TEXTY
;
165 ImplInitSettings( TRUE
, TRUE
, TRUE
);
168 SetOutputSizePixel( CalcWindowSizePixel() );
171 // -----------------------------------------------------------------------
173 StatusBar::StatusBar( Window
* pParent
, WinBits nStyle
) :
174 Window( WINDOW_STATUSBAR
)
176 ImplInit( pParent
, nStyle
);
179 // -----------------------------------------------------------------------
181 StatusBar::StatusBar( Window
* pParent
, const ResId
& rResId
) :
182 Window( WINDOW_STATUSBAR
)
184 rResId
.SetRT( RSC_STATUSBAR
);
185 WinBits nStyle
= ImplInitRes( rResId
);
186 ImplInit( pParent
, nStyle
);
187 ImplLoadRes( rResId
);
189 if ( !(nStyle
& WB_HIDE
) )
193 // -----------------------------------------------------------------------
195 StatusBar::~StatusBar()
197 // Alle Items loeschen
198 ImplStatusItem
* pItem
= mpItemList
->First();
202 pItem
= mpItemList
->Next();
207 // VirtualDevice loeschen
208 delete mpImplData
->mpVirDev
;
213 // -----------------------------------------------------------------------
215 void StatusBar::ImplInitSettings( BOOL bFont
,
216 BOOL bForeground
, BOOL bBackground
)
218 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
222 Font aFont
= rStyleSettings
.GetToolFont();
223 if ( IsControlFont() )
224 aFont
.Merge( GetControlFont() );
225 SetZoomedPointFont( aFont
);
228 if ( bForeground
|| bFont
)
231 if ( IsControlForeground() )
232 aColor
= GetControlForeground();
233 else if ( GetStyle() & WB_3DLOOK
)
234 aColor
= rStyleSettings
.GetButtonTextColor();
236 aColor
= rStyleSettings
.GetWindowTextColor();
237 SetTextColor( aColor
);
240 mpImplData
->mpVirDev
->SetFont( GetFont() );
241 mpImplData
->mpVirDev
->SetTextColor( GetTextColor() );
242 mpImplData
->mpVirDev
->SetTextAlign( GetTextAlign() );
243 mpImplData
->mpVirDev
->SetTextFillColor();
249 if ( IsControlBackground() )
250 aColor
= GetControlBackground();
251 else if ( GetStyle() & WB_3DLOOK
)
252 aColor
= rStyleSettings
.GetFaceColor();
254 aColor
= rStyleSettings
.GetWindowColor();
255 SetBackground( aColor
);
256 mpImplData
->mpVirDev
->SetBackground( GetBackground() );
259 if( ! IsControlBackground() &&
260 IsNativeControlSupported( CTRL_WINDOW_BACKGROUND
, PART_BACKGROUND_WINDOW
) )
262 ImplGetWindowImpl()->mnNativeBackground
= PART_BACKGROUND_WINDOW
;
263 EnableChildTransparentMode( TRUE
);
268 // -----------------------------------------------------------------------
270 void StatusBar::ImplFormat()
272 ImplStatusItem
* pItem
;
276 USHORT nAutoSizeItems
= 0;
278 // Breiten zusammenrechnen
279 mnItemsWidth
= STATUSBAR_OFFSET_X
;
281 pItem
= mpItemList
->First();
284 if ( pItem
->mbVisible
)
286 if ( pItem
->mnBits
& SIB_AUTOSIZE
)
289 mnItemsWidth
+= pItem
->mnWidth
+ nOffset
;
290 nOffset
= pItem
->mnOffset
;
293 pItem
= mpItemList
->Next();
296 if ( GetStyle() & WB_RIGHT
)
298 // Bei rechtsbuendiger Ausrichtung wird kein AutoSize ausgewertet,
299 // da wir links den Text anzeigen, der mit SetText gesetzt wird
300 nX
= mnDX
- mnItemsWidth
;
306 mnItemsWidth
+= STATUSBAR_OFFSET_X
;
308 // Bei linksbuendiger Ausrichtung muessen wir gegebenenfalls noch
309 // AutoSize auswerten
310 if ( nAutoSizeItems
&& (mnDX
> (mnItemsWidth
- STATUSBAR_OFFSET
)) )
312 nExtraWidth
= (mnDX
- mnItemsWidth
- 1) / nAutoSizeItems
;
313 nExtraWidth2
= (mnDX
- mnItemsWidth
- 1) % nAutoSizeItems
;
320 nX
= STATUSBAR_OFFSET_X
;
323 pItem
= mpItemList
->First();
326 if ( pItem
->mbVisible
)
328 if ( pItem
->mnBits
& SIB_AUTOSIZE
)
330 pItem
->mnExtraWidth
= nExtraWidth
;
333 pItem
->mnExtraWidth
++;
338 pItem
->mnExtraWidth
= 0;
341 nX
+= pItem
->mnWidth
+ pItem
->mnExtraWidth
+ pItem
->mnOffset
;
344 pItem
= mpItemList
->Next();
350 // -----------------------------------------------------------------------
352 Rectangle
StatusBar::ImplGetItemRectPos( USHORT nPos
) const
355 ImplStatusItem
* pItem
;
357 pItem
= mpItemList
->GetObject( nPos
);
361 if ( pItem
->mbVisible
)
363 aRect
.Left() = pItem
->mnX
;
364 aRect
.Right() = aRect
.Left() + pItem
->mnWidth
+ pItem
->mnExtraWidth
;
365 aRect
.Top() = mnItemY
;
366 aRect
.Bottom() = mnCalcHeight
- STATUSBAR_OFFSET_Y
;
375 // -----------------------------------------------------------------------
377 void StatusBar::ImplDrawText( BOOL bOffScreen
, long nOldTextWidth
)
379 // Das ueberschreiben der Item-Box verhindern
381 aTextRect
.Left() = STATUSBAR_OFFSET_X
+1;
382 aTextRect
.Top() = mnTextY
;
383 if ( mbVisibleItems
&& (GetStyle() & WB_RIGHT
) )
384 aTextRect
.Right() = mnDX
- mnItemsWidth
- 1;
386 aTextRect
.Right() = mnDX
- 1;
387 if ( aTextRect
.Right() > aTextRect
.Left() )
389 // Position ermitteln
390 XubString aStr
= GetText();
391 USHORT nPos
= aStr
.Search( _LF
);
392 if ( nPos
!= STRING_NOTFOUND
)
395 aTextRect
.Bottom() = aTextRect
.Top()+GetTextHeight()+1;
399 long nMaxWidth
= Max( nOldTextWidth
, GetTextWidth( aStr
) );
400 Size
aVirDevSize( nMaxWidth
, aTextRect
.GetHeight() );
401 mpImplData
->mpVirDev
->SetOutputSizePixel( aVirDevSize
);
402 Rectangle aTempRect
= aTextRect
;
403 aTempRect
.SetPos( Point( 0, 0 ) );
404 mpImplData
->mpVirDev
->DrawText( aTempRect
, aStr
, TEXT_DRAW_LEFT
| TEXT_DRAW_TOP
| TEXT_DRAW_CLIP
| TEXT_DRAW_ENDELLIPSIS
);
405 DrawOutDev( aTextRect
.TopLeft(), aVirDevSize
, Point(), aVirDevSize
, *mpImplData
->mpVirDev
);
408 DrawText( aTextRect
, aStr
, TEXT_DRAW_LEFT
| TEXT_DRAW_TOP
| TEXT_DRAW_CLIP
| TEXT_DRAW_ENDELLIPSIS
);
412 // -----------------------------------------------------------------------
414 void StatusBar::ImplDrawItem( BOOL bOffScreen
, USHORT nPos
, BOOL bDrawText
, BOOL bDrawFrame
)
416 Rectangle aRect
= ImplGetItemRectPos( nPos
);
418 if ( aRect
.IsEmpty() )
421 // Ausgabebereich berechnen
422 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
423 Rectangle
aTextRect( aRect
.Left()+1, aRect
.Top()+1,
424 aRect
.Right()-1, aRect
.Bottom()-1 );
425 Size
aTextRectSize( aTextRect
.GetSize() );
428 mpImplData
->mpVirDev
->SetOutputSizePixel( aTextRectSize
);
431 Region
aRegion( aTextRect
);
432 SetClipRegion( aRegion
);
438 Size
aTextSize( GetTextWidth( pItem
->maText
), GetTextHeight() );
439 Point aTextPos
= ImplGetItemTextPos( aTextRectSize
, aTextSize
, pItem
->mnBits
);
441 mpImplData
->mpVirDev
->DrawText( aTextPos
, pItem
->maText
);
444 aTextPos
.X() += aTextRect
.Left();
445 aTextPos
.Y() += aTextRect
.Top();
446 DrawText( aTextPos
, pItem
->maText
);
450 // Gegebenenfalls auch DrawItem aufrufen
451 if ( pItem
->mnBits
& SIB_USERDRAW
)
456 mpImplData
->mpVirDev
->EnableRTL( IsRTLEnabled() );
457 UserDrawEvent
aODEvt( mpImplData
->mpVirDev
, Rectangle( Point(), aTextRectSize
), pItem
->mnId
);
459 mpImplData
->mpVirDev
->EnableRTL( FALSE
);
460 mbInUserDraw
= FALSE
;
464 UserDrawEvent
aODEvt( this, aTextRect
, pItem
->mnId
);
470 DrawOutDev( aTextRect
.TopLeft(), aTextRectSize
, Point(), aTextRectSize
, *mpImplData
->mpVirDev
);
475 if ( bDrawFrame
&& !(pItem
->mnBits
& SIB_FLAT
) )
479 if ( pItem
->mnBits
& SIB_IN
)
480 nStyle
= FRAME_DRAW_IN
;
482 nStyle
= FRAME_DRAW_OUT
;
484 DecorationView
aDecoView( this );
485 aDecoView
.DrawFrame( aRect
, nStyle
);
488 if ( !ImplIsRecordLayout() )
489 ImplCallEventListeners( VCLEVENT_STATUSBAR_DRAWITEM
, (void*) sal_IntPtr(pItem
->mnId
) );
492 // -----------------------------------------------------------------------
494 void DrawProgress( Window
* pWindow
, const Point
& rPos
,
495 long nOffset
, long nPrgsWidth
, long nPrgsHeight
,
496 USHORT nPercent1
, USHORT nPercent2
, USHORT nPercentCount
,
497 const Rectangle
& rFramePosSize
500 if( pWindow
->IsNativeControlSupported( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
) )
502 bool bNeedErase
= ImplGetSVData()->maNWFData
.mbProgressNeedsErase
;
504 long nFullWidth
= (nPrgsWidth
+ nOffset
) * (10000 / nPercentCount
);
505 long nPerc
= (nPercent2
> 10000) ? 10000 : nPercent2
;
506 ImplControlValue
aValue( nFullWidth
* (long)nPerc
/ 10000 );
507 Rectangle
aDrawRect( rPos
, Size( nFullWidth
, nPrgsHeight
) );
508 Region
aControlRegion( aDrawRect
);
511 Window
* pEraseWindow
= pWindow
;
512 while( pEraseWindow
->IsPaintTransparent() &&
513 ! pEraseWindow
->ImplGetWindowImpl()->mbFrame
)
515 pEraseWindow
= pEraseWindow
->ImplGetWindowImpl()->mpParent
;
517 if( pEraseWindow
== pWindow
)
518 // restore background of pWindow
519 pEraseWindow
->Erase( rFramePosSize
);
522 // restore transparent background
523 Point
aTL( pWindow
->OutputToAbsoluteScreenPixel( rFramePosSize
.TopLeft() ) );
524 aTL
= pEraseWindow
->AbsoluteScreenToOutputPixel( aTL
);
525 Rectangle
aRect( aTL
, rFramePosSize
.GetSize() );
526 pEraseWindow
->Invalidate( aRect
, INVALIDATE_NOCHILDREN
|
527 INVALIDATE_NOCLIPCHILDREN
|
528 INVALIDATE_TRANSPARENT
);
529 pEraseWindow
->Update();
531 pWindow
->Push( PUSH_CLIPREGION
);
532 pWindow
->IntersectClipRegion( rFramePosSize
);
534 BOOL bNativeOK
= pWindow
->DrawNativeControl( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
, aControlRegion
,
535 CTRL_STATE_ENABLED
, aValue
, rtl::OUString() );
545 // Werte vorberechnen
546 USHORT nPerc1
= nPercent1
/ nPercentCount
;
547 USHORT nPerc2
= nPercent2
/ nPercentCount
;
549 if ( nPerc1
> nPerc2
)
551 // Support progress that can also decrease
553 // Rechteck berechnen
554 long nDX
= nPrgsWidth
+ nOffset
;
555 long nLeft
= rPos
.X()+((nPerc1
-1)*nDX
);
556 Rectangle
aRect( nLeft
, rPos
.Y(), nLeft
+nPrgsWidth
, rPos
.Y()+nPrgsHeight
);
560 pWindow
->Erase( aRect
);
562 aRect
.Right() -= nDX
;
565 while ( nPerc1
> nPerc2
);
569 else if ( nPerc1
< nPerc2
)
571 // Percent-Rechtecke malen
572 // Wenn Percent2 ueber 100%, Werte anpassen
573 if ( nPercent2
> 10000 )
575 nPerc2
= 10000 / nPercentCount
;
576 if ( nPerc1
>= nPerc2
)
580 // Rechteck berechnen
581 long nDX
= nPrgsWidth
+ nOffset
;
582 long nLeft
= rPos
.X()+(nPerc1
*nDX
);
583 Rectangle
aRect( nLeft
, rPos
.Y(), nLeft
+nPrgsWidth
, rPos
.Y()+nPrgsHeight
);
587 pWindow
->DrawRect( aRect
);
589 aRect
.Right() += nDX
;
592 while ( nPerc1
< nPerc2
);
594 // Bei mehr als 100%, lassen wir das Rechteck blinken
595 if ( nPercent2
> 10000 )
597 // an/aus-Status festlegen
598 if ( ((nPercent2
/ nPercentCount
) & 0x01) == (nPercentCount
& 0x01) )
601 aRect
.Right() -= nDX
;
602 pWindow
->Erase( aRect
);
610 // -----------------------------------------------------------------------
612 void StatusBar::ImplDrawProgress( BOOL bPaint
,
613 USHORT nPercent1
, USHORT nPercent2
)
615 bool bNative
= IsNativeControlSupported( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
);
616 // bPaint: draw text also, else only update progress
619 DrawText( maPrgsTxtPos
, maPrgsTxt
);
622 DecorationView
aDecoView( this );
623 aDecoView
.DrawFrame( maPrgsFrameRect
, FRAME_DRAW_IN
);
627 Point
aPos( maPrgsFrameRect
.Left()+STATUSBAR_PRGS_OFFSET
,
628 maPrgsFrameRect
.Top()+STATUSBAR_PRGS_OFFSET
);
629 long nPrgsHeight
= mnPrgsSize
;
632 aPos
= maPrgsFrameRect
.TopLeft();
633 nPrgsHeight
= maPrgsFrameRect
.GetHeight();
635 DrawProgress( this, aPos
, mnPrgsSize
/2, mnPrgsSize
, nPrgsHeight
,
636 nPercent1
*100, nPercent2
*100, mnPercentCount
, maPrgsFrameRect
);
639 // -----------------------------------------------------------------------
641 void StatusBar::ImplCalcProgressRect()
643 // calculate text size
644 Size
aPrgsTxtSize( GetTextWidth( maPrgsTxt
), GetTextHeight() );
645 maPrgsTxtPos
.X() = STATUSBAR_OFFSET_X
+1;
647 // calculate progress frame
648 maPrgsFrameRect
.Left() = maPrgsTxtPos
.X()+aPrgsTxtSize
.Width()+STATUSBAR_OFFSET
;
649 maPrgsFrameRect
.Top() = mnItemY
;
650 maPrgsFrameRect
.Bottom() = mnCalcHeight
- STATUSBAR_OFFSET_Y
;
652 maPrgsFrameRect
.Bottom()+=2;
654 // calculate size of progress rects
655 mnPrgsSize
= maPrgsFrameRect
.Bottom()-maPrgsFrameRect
.Top()-(STATUSBAR_PRGS_OFFSET
*2);
656 USHORT nMaxPercent
= STATUSBAR_PRGS_COUNT
;
658 long nMaxWidth
= mnDX
-STATUSBAR_OFFSET
-1;
660 // make smaller if there are too many rects
661 while ( maPrgsFrameRect
.Left()+ImplCalcProgessWidth( nMaxPercent
, mnPrgsSize
) > nMaxWidth
)
664 if ( nMaxPercent
<= STATUSBAR_PRGS_MIN
)
667 maPrgsFrameRect
.Right() = maPrgsFrameRect
.Left() + ImplCalcProgessWidth( nMaxPercent
, mnPrgsSize
);
669 // save the divisor for later
670 mnPercentCount
= 10000 / nMaxPercent
;
671 BOOL bNativeOK
= FALSE
;
672 if( IsNativeControlSupported( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
) )
674 ImplControlValue aValue
;
675 Region
aControlRegion( Rectangle( (const Point
&)Point(), maPrgsFrameRect
.GetSize() ) );
676 Region aNativeControlRegion
, aNativeContentRegion
;
677 if( (bNativeOK
= GetNativeControlRegion( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
, aControlRegion
,
678 CTRL_STATE_ENABLED
, aValue
, rtl::OUString(),
679 aNativeControlRegion
, aNativeContentRegion
) ) != FALSE
)
681 long nProgressHeight
= aNativeControlRegion
.GetBoundRect().GetHeight();
682 if( nProgressHeight
> maPrgsFrameRect
.GetHeight() )
684 long nDelta
= nProgressHeight
- maPrgsFrameRect
.GetHeight();
685 maPrgsFrameRect
.Top() -= (nDelta
- nDelta
/2);
686 maPrgsFrameRect
.Bottom() += nDelta
/2;
688 maPrgsTxtPos
.Y() = maPrgsFrameRect
.Top() + (nProgressHeight
- GetTextHeight())/2;
692 maPrgsTxtPos
.Y() = mnTextY
;
697 // -----------------------------------------------------------------------
699 void StatusBar::MouseButtonDown( const MouseEvent
& rMEvt
)
701 // Nur bei linker Maustaste ToolBox ausloesen
702 if ( rMEvt
.IsLeft() )
704 if ( mbVisibleItems
)
706 Point aMousePos
= rMEvt
.GetPosPixel();
709 // Item suchen, das geklickt wurde
710 ImplStatusItem
* pItem
= mpItemList
->First();
713 // Ist es dieses Item
714 if ( ImplGetItemRectPos( i
).IsInside( aMousePos
) )
716 mnCurItemId
= pItem
->mnId
;
717 if ( rMEvt
.GetClicks() == 2 )
723 // Item wurde gefunden
728 pItem
= mpItemList
->Next();
732 // Kein Item, dann nur Click oder DoubleClick
733 if ( rMEvt
.GetClicks() == 2 )
740 // -----------------------------------------------------------------------
742 void StatusBar::Paint( const Rectangle
& )
747 USHORT nItemCount
= (USHORT
)mpItemList
->Count();
749 if ( mbProgressMode
)
750 ImplDrawProgress( TRUE
, 0, mnPercent
);
754 if ( !mbVisibleItems
|| (GetStyle() & WB_RIGHT
) )
755 ImplDrawText( FALSE
, 0 );
758 if ( mbVisibleItems
)
761 for ( USHORT i
= 0; i
< nItemCount
; i
++ )
762 ImplDrawItem( FALSE
, i
, TRUE
, TRUE
);
769 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
770 SetLineColor( rStyleSettings
.GetShadowColor() );
771 DrawLine( Point( 0, 0 ), Point( mnDX
-1, 0 ) );
772 SetLineColor( rStyleSettings
.GetLightColor() );
773 DrawLine( Point( 0, 1 ), Point( mnDX
-1, 1 ) );
776 if ( IsBottomBorder() )
778 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
779 SetLineColor( rStyleSettings
.GetShadowColor() );
780 DrawLine( Point( 0, mnDY
-2 ), Point( mnDX
-1, mnDY
-2 ) );
781 SetLineColor( rStyleSettings
.GetLightColor() );
782 DrawLine( Point( 0, mnDY
-1 ), Point( mnDX
-1, mnDY
-1 ) );
786 // -----------------------------------------------------------------------
788 void StatusBar::Move()
793 // -----------------------------------------------------------------------
795 void StatusBar::Resize()
797 // Breite und Hoehe abfragen und merken
798 Size aSize
= GetOutputSizePixel();
799 mnDX
= aSize
.Width();
800 mnDY
= aSize
.Height();
805 if ( IsBottomBorder() )
808 mnItemY
= STATUSBAR_OFFSET_Y
;
811 mnTextY
= (mnCalcHeight
-GetTextHeight())/2;
815 // Formatierung neu ausloesen
818 if ( mbProgressMode
)
819 ImplCalcProgressRect();
824 // -----------------------------------------------------------------------
826 void StatusBar::RequestHelp( const HelpEvent
& rHEvt
)
828 // no keyboard help in status bar
829 if( rHEvt
.KeyboardActivated() )
832 USHORT nItemId
= GetItemId( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ) );
836 Rectangle aItemRect
= GetItemRect( nItemId
);
837 Point aPt
= OutputToScreenPixel( aItemRect
.TopLeft() );
838 aItemRect
.Left() = aPt
.X();
839 aItemRect
.Top() = aPt
.Y();
840 aPt
= OutputToScreenPixel( aItemRect
.BottomRight() );
841 aItemRect
.Right() = aPt
.X();
842 aItemRect
.Bottom() = aPt
.Y();
844 if ( rHEvt
.GetMode() & HELPMODE_BALLOON
)
846 XubString aStr
= GetHelpText( nItemId
);
847 Help::ShowBalloon( this, aItemRect
.Center(), aItemRect
, aStr
);
850 else if ( rHEvt
.GetMode() & HELPMODE_QUICK
)
852 XubString aStr
= GetQuickHelpText( nItemId
);
853 // Show quickhelp if available
856 Help::ShowQuickHelp( this, aItemRect
, aStr
);
859 aStr
= GetItemText( nItemId
);
860 // show a quick help if item text doesn't fit
861 if ( GetTextWidth( aStr
) > aItemRect
.GetWidth() )
863 Help::ShowQuickHelp( this, aItemRect
, aStr
);
867 else if ( rHEvt
.GetMode() & HELPMODE_EXTENDED
)
869 String aCommand
= GetItemCommand( nItemId
);
870 ULONG nHelpId
= GetHelpId( nItemId
);
872 if ( aCommand
.Len() || nHelpId
)
874 // Wenn eine Hilfe existiert, dann ausloesen
875 Help
* pHelp
= Application::GetHelp();
878 if ( aCommand
.Len() )
879 pHelp
->Start( aCommand
, this );
881 pHelp
->Start( nHelpId
, this );
888 Window::RequestHelp( rHEvt
);
891 // -----------------------------------------------------------------------
893 void StatusBar::StateChanged( StateChangedType nType
)
895 Window::StateChanged( nType
);
897 if ( nType
== STATE_CHANGE_INITSHOW
)
899 else if ( nType
== STATE_CHANGE_UPDATEMODE
)
901 else if ( (nType
== STATE_CHANGE_ZOOM
) ||
902 (nType
== STATE_CHANGE_CONTROLFONT
) )
905 ImplInitSettings( TRUE
, FALSE
, FALSE
);
908 else if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
910 ImplInitSettings( FALSE
, TRUE
, FALSE
);
913 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
915 ImplInitSettings( FALSE
, FALSE
, TRUE
);
920 // -----------------------------------------------------------------------
922 void StatusBar::DataChanged( const DataChangedEvent
& rDCEvt
)
924 Window::DataChanged( rDCEvt
);
926 if ( (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
927 (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
928 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
929 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
930 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
933 ImplInitSettings( TRUE
, TRUE
, TRUE
);
934 ImplStatusItem
* pItem
= mpItemList
->First();
935 long nFudge
= GetTextHeight() / 4;
938 long nWidth
= GetTextWidth( pItem
->maText
) + nFudge
;
939 if( nWidth
> pItem
->mnWidth
+ STATUSBAR_OFFSET
)
940 pItem
->mnWidth
= nWidth
+ STATUSBAR_OFFSET
;
941 pItem
= mpItemList
->Next();
943 Size aSize
= GetSizePixel();
944 // do not disturb current width, since
945 // CalcWindowSizePixel calculates a minimum width
946 aSize
.Height() = CalcWindowSizePixel().Height();
947 SetSizePixel( aSize
);
952 // -----------------------------------------------------------------------
954 void StatusBar::Click()
956 ImplCallEventListeners( VCLEVENT_STATUSBAR_CLICK
);
957 maClickHdl
.Call( this );
960 // -----------------------------------------------------------------------
962 void StatusBar::DoubleClick()
964 ImplCallEventListeners( VCLEVENT_STATUSBAR_DOUBLECLICK
);
965 maDoubleClickHdl
.Call( this );
968 // -----------------------------------------------------------------------
970 void StatusBar::UserDraw( const UserDrawEvent
& )
974 // -----------------------------------------------------------------------
976 void StatusBar::InsertItem( USHORT nItemId
, ULONG nWidth
,
977 StatusBarItemBits nBits
,
978 long nOffset
, USHORT nPos
)
980 DBG_ASSERT( nItemId
, "StatusBar::InsertItem(): ItemId == 0" );
981 DBG_ASSERT( GetItemPos( nItemId
) == STATUSBAR_ITEM_NOTFOUND
,
982 "StatusBar::InsertItem(): ItemId already exists" );
984 // IN und CENTER sind Default
985 if ( !(nBits
& (SIB_IN
| SIB_OUT
| SIB_FLAT
)) )
987 if ( !(nBits
& (SIB_LEFT
| SIB_RIGHT
| SIB_CENTER
)) )
991 long nFudge
= GetTextHeight()/4;
992 ImplStatusItem
* pItem
= new ImplStatusItem
;
993 pItem
->mnId
= nItemId
;
994 pItem
->mnBits
= nBits
;
995 pItem
->mnWidth
= (long)nWidth
+nFudge
+STATUSBAR_OFFSET
;
996 pItem
->mnOffset
= nOffset
;
998 pItem
->mpUserData
= 0;
999 pItem
->mbVisible
= TRUE
;
1001 // Item in die Liste einfuegen
1002 mpItemList
->Insert( pItem
, nPos
);
1005 if ( ImplIsItemUpdate() )
1008 ImplCallEventListeners( VCLEVENT_STATUSBAR_ITEMADDED
, (void*) sal_IntPtr(nItemId
) );
1011 // -----------------------------------------------------------------------
1013 void StatusBar::RemoveItem( USHORT nItemId
)
1015 USHORT nPos
= GetItemPos( nItemId
);
1016 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1018 ImplStatusItem
* pItem
= mpItemList
->Remove( nPos
);
1022 if ( ImplIsItemUpdate() )
1025 ImplCallEventListeners( VCLEVENT_STATUSBAR_ITEMREMOVED
, (void*) sal_IntPtr(nItemId
) );
1029 // -----------------------------------------------------------------------
1031 void StatusBar::ShowItem( USHORT nItemId
)
1033 USHORT nPos
= GetItemPos( nItemId
);
1035 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1037 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1038 if ( !pItem
->mbVisible
)
1040 pItem
->mbVisible
= TRUE
;
1043 if ( ImplIsItemUpdate() )
1046 ImplCallEventListeners( VCLEVENT_STATUSBAR_SHOWITEM
, (void*) sal_IntPtr(nItemId
) );
1051 // -----------------------------------------------------------------------
1053 void StatusBar::HideItem( USHORT nItemId
)
1055 USHORT nPos
= GetItemPos( nItemId
);
1057 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1059 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1060 if ( pItem
->mbVisible
)
1062 pItem
->mbVisible
= FALSE
;
1065 if ( ImplIsItemUpdate() )
1068 ImplCallEventListeners( VCLEVENT_STATUSBAR_HIDEITEM
, (void*) sal_IntPtr(nItemId
) );
1073 // -----------------------------------------------------------------------
1075 BOOL
StatusBar::IsItemVisible( USHORT nItemId
) const
1077 USHORT nPos
= GetItemPos( nItemId
);
1079 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1080 return mpItemList
->GetObject( nPos
)->mbVisible
;
1085 // -----------------------------------------------------------------------
1087 void StatusBar::ShowItems()
1089 if ( !mbVisibleItems
)
1091 mbVisibleItems
= TRUE
;
1092 if ( !mbProgressMode
)
1095 ImplCallEventListeners( VCLEVENT_STATUSBAR_SHOWALLITEMS
);
1099 // -----------------------------------------------------------------------
1101 void StatusBar::HideItems()
1103 if ( mbVisibleItems
)
1105 mbVisibleItems
= FALSE
;
1106 if ( !mbProgressMode
)
1109 ImplCallEventListeners( VCLEVENT_STATUSBAR_HIDEALLITEMS
);
1113 // -----------------------------------------------------------------------
1115 void StatusBar::CopyItems( const StatusBar
& rStatusBar
)
1117 // Alle Items entfernen
1118 ImplStatusItem
* pItem
= mpItemList
->First();
1122 pItem
= mpItemList
->Next();
1125 // Items aus der Liste loeschen
1126 mpItemList
->Clear();
1130 pItem
= rStatusBar
.mpItemList
->GetObject( i
);
1133 mpItemList
->Insert( new ImplStatusItem( *pItem
), LIST_APPEND
);
1135 pItem
= rStatusBar
.mpItemList
->GetObject( i
);
1139 if ( ImplIsItemUpdate() )
1143 // -----------------------------------------------------------------------
1145 void StatusBar::Clear()
1147 // Alle Item loeschen
1148 ImplStatusItem
* pItem
= mpItemList
->First();
1152 pItem
= mpItemList
->Next();
1155 // Items aus der Liste loeschen
1156 mpItemList
->Clear();
1159 if ( ImplIsItemUpdate() )
1162 ImplCallEventListeners( VCLEVENT_STATUSBAR_ALLITEMSREMOVED
);
1165 // -----------------------------------------------------------------------
1167 USHORT
StatusBar::GetItemCount() const
1169 return (USHORT
)mpItemList
->Count();
1172 // -----------------------------------------------------------------------
1174 USHORT
StatusBar::GetItemId( USHORT nPos
) const
1176 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1183 // -----------------------------------------------------------------------
1185 USHORT
StatusBar::GetItemPos( USHORT nItemId
) const
1187 ImplStatusItem
* pItem
= mpItemList
->First();
1190 if ( pItem
->mnId
== nItemId
)
1191 return (USHORT
)mpItemList
->GetCurPos();
1193 pItem
= mpItemList
->Next();
1196 return STATUSBAR_ITEM_NOTFOUND
;
1199 // -----------------------------------------------------------------------
1201 USHORT
StatusBar::GetItemId( const Point
& rPos
) const
1203 if ( AreItemsVisible() && !mbFormat
)
1205 USHORT nItemCount
= GetItemCount();
1207 for ( nPos
= 0; nPos
< nItemCount
; nPos
++ )
1210 Rectangle aRect
= ImplGetItemRectPos( nPos
);
1211 if ( aRect
.IsInside( rPos
) )
1212 return mpItemList
->GetObject( nPos
)->mnId
;
1219 // -----------------------------------------------------------------------
1221 Rectangle
StatusBar::GetItemRect( USHORT nItemId
) const
1225 if ( AreItemsVisible() && !mbFormat
)
1227 USHORT nPos
= GetItemPos( nItemId
);
1228 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1230 // Rechteck holen und Rahmen abziehen
1231 aRect
= ImplGetItemRectPos( nPos
);
1241 // -----------------------------------------------------------------------
1243 Point
StatusBar::GetItemTextPos( USHORT nItemId
) const
1247 USHORT nPos
= GetItemPos( nItemId
);
1248 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1251 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1252 Rectangle aRect
= ImplGetItemRectPos( nPos
);
1253 Rectangle
aTextRect( aRect
.Left()+1, aRect
.Top()+1,
1254 aRect
.Right()-1, aRect
.Bottom()-1 );
1255 Point aPos
= ImplGetItemTextPos( aTextRect
.GetSize(),
1256 Size( GetTextWidth( pItem
->maText
), GetTextHeight() ),
1258 if ( !mbInUserDraw
)
1260 aPos
.X() += aTextRect
.Left();
1261 aPos
.Y() += aTextRect
.Top();
1270 // -----------------------------------------------------------------------
1272 ULONG
StatusBar::GetItemWidth( USHORT nItemId
) const
1274 USHORT nPos
= GetItemPos( nItemId
);
1276 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1277 return mpItemList
->GetObject( nPos
)->mnWidth
;
1282 // -----------------------------------------------------------------------
1284 StatusBarItemBits
StatusBar::GetItemBits( USHORT nItemId
) const
1286 USHORT nPos
= GetItemPos( nItemId
);
1288 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1289 return mpItemList
->GetObject( nPos
)->mnBits
;
1294 // -----------------------------------------------------------------------
1296 long StatusBar::GetItemOffset( USHORT nItemId
) const
1298 USHORT nPos
= GetItemPos( nItemId
);
1300 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1301 return mpItemList
->GetObject( nPos
)->mnOffset
;
1306 // -----------------------------------------------------------------------
1308 void StatusBar::SetItemText( USHORT nItemId
, const XubString
& rText
)
1310 USHORT nPos
= GetItemPos( nItemId
);
1312 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1314 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1316 if ( pItem
->maText
!= rText
)
1318 pItem
->maText
= rText
;
1320 // adjust item width - see also DataChanged()
1321 long nFudge
= GetTextHeight()/4;
1322 long nWidth
= GetTextWidth( pItem
->maText
) + nFudge
;
1323 if( nWidth
> pItem
->mnWidth
+ STATUSBAR_OFFSET
)
1324 pItem
->mnWidth
= nWidth
+ STATUSBAR_OFFSET
;
1326 // Item neu Zeichen, wenn StatusBar sichtbar und
1327 // UpdateMode gesetzt ist
1328 if ( pItem
->mbVisible
&& !mbFormat
&& ImplIsItemUpdate() )
1331 ImplDrawItem( TRUE
, nPos
, TRUE
, FALSE
);
1338 // -----------------------------------------------------------------------
1340 const XubString
& StatusBar::GetItemText( USHORT nItemId
) const
1342 USHORT nPos
= GetItemPos( nItemId
);
1344 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1345 return mpItemList
->GetObject( nPos
)->maText
;
1347 return ImplGetSVEmptyStr();
1350 // -----------------------------------------------------------------------
1352 void StatusBar::SetItemCommand( USHORT nItemId
, const XubString
& rCommand
)
1354 USHORT nPos
= GetItemPos( nItemId
);
1356 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1358 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1360 if ( pItem
->maCommand
!= rCommand
)
1361 pItem
->maCommand
= rCommand
;
1365 // -----------------------------------------------------------------------
1367 const XubString
& StatusBar::GetItemCommand( USHORT nItemId
)
1369 USHORT nPos
= GetItemPos( nItemId
);
1371 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1372 return mpItemList
->GetObject( nPos
)->maCommand
;
1374 return ImplGetSVEmptyStr();
1377 // -----------------------------------------------------------------------
1379 void StatusBar::SetItemData( USHORT nItemId
, void* pNewData
)
1381 USHORT nPos
= GetItemPos( nItemId
);
1383 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1385 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1386 pItem
->mpUserData
= pNewData
;
1388 // Wenn es ein User-Item ist, DrawItem-Aufrufen
1389 if ( (pItem
->mnBits
& SIB_USERDRAW
) && pItem
->mbVisible
&&
1390 !mbFormat
&& ImplIsItemUpdate() )
1393 ImplDrawItem( TRUE
, nPos
, FALSE
, FALSE
);
1399 // -----------------------------------------------------------------------
1401 void* StatusBar::GetItemData( USHORT nItemId
) const
1403 USHORT nPos
= GetItemPos( nItemId
);
1405 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1406 return mpItemList
->GetObject( nPos
)->mpUserData
;
1411 // -----------------------------------------------------------------------
1413 void StatusBar::SetHelpText( USHORT nItemId
, const XubString
& rText
)
1415 USHORT nPos
= GetItemPos( nItemId
);
1417 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1418 mpItemList
->GetObject( nPos
)->maHelpText
= rText
;
1421 // -----------------------------------------------------------------------
1423 const XubString
& StatusBar::GetHelpText( USHORT nItemId
) const
1425 USHORT nPos
= GetItemPos( nItemId
);
1427 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1429 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1430 if ( !pItem
->maHelpText
.Len() && ( pItem
->mnHelpId
|| pItem
->maCommand
.Len() ))
1432 Help
* pHelp
= Application::GetHelp();
1435 if ( pItem
->maCommand
.Len() )
1436 pItem
->maHelpText
= pHelp
->GetHelpText( pItem
->maCommand
, this );
1437 if ( !pItem
->maHelpText
.Len() && pItem
->mnHelpId
)
1438 pItem
->maHelpText
= pHelp
->GetHelpText( pItem
->mnHelpId
, this );
1442 return pItem
->maHelpText
;
1445 return ImplGetSVEmptyStr();
1448 // -----------------------------------------------------------------------
1450 void StatusBar::SetQuickHelpText( USHORT nItemId
, const XubString
& rText
)
1452 USHORT nPos
= GetItemPos( nItemId
);
1454 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1455 mpItemList
->GetObject( nPos
)->maQuickHelpText
= rText
;
1458 // -----------------------------------------------------------------------
1460 const XubString
& StatusBar::GetQuickHelpText( USHORT nItemId
) const
1462 USHORT nPos
= GetItemPos( nItemId
);
1464 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1466 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1467 return pItem
->maQuickHelpText
;
1470 return ImplGetSVEmptyStr();
1473 // -----------------------------------------------------------------------
1475 void StatusBar::SetHelpId( USHORT nItemId
, ULONG nHelpId
)
1477 USHORT nPos
= GetItemPos( nItemId
);
1479 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1480 mpItemList
->GetObject( nPos
)->mnHelpId
= nHelpId
;
1483 // -----------------------------------------------------------------------
1485 ULONG
StatusBar::GetHelpId( USHORT nItemId
) const
1487 USHORT nPos
= GetItemPos( nItemId
);
1489 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1490 return mpItemList
->GetObject( nPos
)->mnHelpId
;
1495 // -----------------------------------------------------------------------
1497 void StatusBar::ImplCalcBorder( )
1499 mnCalcHeight
= mnDY
;
1507 if ( IsBottomBorder() )
1513 void StatusBar::SetBottomBorder( BOOL bBottomBorder
)
1515 if ( mbBottomBorder
!= bBottomBorder
)
1517 mbBottomBorder
= bBottomBorder
;
1522 void StatusBar::SetTopBorder( BOOL bTopBorder
)
1524 if ( mpImplData
->mbTopBorder
!= bTopBorder
)
1526 mpImplData
->mbTopBorder
= bTopBorder
;
1531 BOOL
StatusBar::IsTopBorder() const
1533 return mpImplData
->mbTopBorder
;
1536 // -----------------------------------------------------------------------
1538 void StatusBar::StartProgressMode( const XubString
& rText
)
1540 DBG_ASSERT( !mbProgressMode
, "StatusBar::StartProgressMode(): progress mode is active" );
1542 mbProgressMode
= TRUE
;
1546 // Groessen berechnen
1547 ImplCalcProgressRect();
1549 // Paint ausloesen (dort wird der Text und der Frame gemalt)
1550 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1551 Color aPrgsColor
= rStyleSettings
.GetHighlightColor();
1552 if ( aPrgsColor
== rStyleSettings
.GetFaceColor() )
1553 aPrgsColor
= rStyleSettings
.GetDarkShadowColor();
1555 SetFillColor( aPrgsColor
);
1556 if ( IsReallyVisible() )
1564 // -----------------------------------------------------------------------
1566 void StatusBar::SetProgressValue( USHORT nNewPercent
)
1568 DBG_ASSERT( mbProgressMode
, "StatusBar::SetProgressValue(): no progrss mode" );
1569 DBG_ASSERTWARNING( nNewPercent
<= 100, "StatusBar::SetProgressValue(): nPercent > 100" );
1572 && IsReallyVisible()
1573 && (!mnPercent
|| (mnPercent
!= nNewPercent
)) )
1577 ImplDrawProgress( FALSE
, mnPercent
, nNewPercent
);
1580 mnPercent
= nNewPercent
;
1583 // -----------------------------------------------------------------------
1585 void StatusBar::EndProgressMode()
1587 DBG_ASSERT( mbProgressMode
, "StatusBar::EndProgressMode(): no progress mode" );
1589 mbProgressMode
= FALSE
;
1592 // Paint neu ausloesen um StatusBar wieder herzustellen
1593 SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
1594 if ( IsReallyVisible() )
1602 // -----------------------------------------------------------------------
1604 void StatusBar::ResetProgressMode()
1606 if ( mbProgressMode
)
1610 if ( IsReallyVisible() )
1619 // -----------------------------------------------------------------------
1621 void StatusBar::SetText( const XubString
& rText
)
1623 if ( (!mbVisibleItems
|| (GetStyle() & WB_RIGHT
)) && !mbProgressMode
&&
1624 IsReallyVisible() && IsUpdateMode() )
1629 Window::SetText( rText
);
1634 long nOldTextWidth
= GetTextWidth( GetText() );
1635 Window::SetText( rText
);
1636 ImplDrawText( TRUE
, nOldTextWidth
);
1640 else if ( mbProgressMode
)
1643 if ( IsReallyVisible() )
1651 Window::SetText( rText
);
1654 // -----------------------------------------------------------------------
1656 Size
StatusBar::CalcWindowSizePixel() const
1659 ULONG nCount
= mpItemList
->Count();
1661 long nCalcWidth
= (STATUSBAR_OFFSET_X
*2);
1664 while ( i
< nCount
)
1666 ImplStatusItem
* pItem
= mpItemList
->GetObject( i
);
1667 nCalcWidth
+= pItem
->mnWidth
+ nOffset
;
1668 nOffset
= pItem
->mnOffset
;
1672 long nMinHeight
= GetTextHeight();
1673 const long nBarTextOffset
= STATUSBAR_OFFSET_TEXTY
*2;
1674 long nProgressHeight
= nMinHeight
+ nBarTextOffset
;
1675 // FIXME: IsNativeControlSupported and GetNativeControlRegion should be const ?
1676 StatusBar
* pThis
= const_cast<StatusBar
*>( this );
1677 if( pThis
->IsNativeControlSupported( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
) )
1679 ImplControlValue aValue
;
1680 Region
aControlRegion( Rectangle( (const Point
&)Point(), Size( nCalcWidth
, nMinHeight
) ) );
1681 Region aNativeControlRegion
, aNativeContentRegion
;
1682 if( pThis
->GetNativeControlRegion( CTRL_PROGRESS
, PART_ENTIRE_CONTROL
, aControlRegion
,
1683 CTRL_STATE_ENABLED
, aValue
, rtl::OUString(),
1684 aNativeControlRegion
, aNativeContentRegion
) )
1686 nProgressHeight
= aNativeControlRegion
.GetBoundRect().GetHeight();
1690 nCalcHeight
= nMinHeight
+nBarTextOffset
;
1691 if( nCalcHeight
< nProgressHeight
+2 )
1692 nCalcHeight
= nProgressHeight
+2;
1697 if ( IsBottomBorder() )
1700 return Size( nCalcWidth
, nCalcHeight
);
1704 // -----------------------------------------------------------------------
1706 void StatusBar::SetAccessibleName( USHORT nItemId
, const XubString
& rName
)
1708 USHORT nPos
= GetItemPos( nItemId
);
1710 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1712 ImplStatusItem
* pItem
= mpItemList
->GetObject( nPos
);
1714 if ( pItem
->maAccessibleName
!= rName
)
1716 pItem
->maAccessibleName
= rName
;
1717 ImplCallEventListeners( VCLEVENT_STATUSBAR_NAMECHANGED
, (void*) sal_IntPtr(pItem
->mnId
) );
1722 // -----------------------------------------------------------------------
1724 const XubString
& StatusBar::GetAccessibleName( USHORT nItemId
) const
1726 USHORT nPos
= GetItemPos( nItemId
);
1728 if ( nPos
!= STATUSBAR_ITEM_NOTFOUND
)
1729 return mpItemList
->GetObject( nPos
)->maAccessibleName
;
1731 return ImplGetSVEmptyStr();
1734 // -----------------------------------------------------------------------