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: headbar.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_svtools.hxx"
34 #define _SV_HEADBAR_CXX
35 #include <svtools/headbar.hxx>
36 #include <tools/debug.hxx>
37 #ifndef _TOOLS_LIST_HXX
38 #include <tools/list.hxx>
42 #include <vcl/svapp.hxx>
45 #include <vcl/help.hxx>
47 #ifndef _VCL_IMAGE_HXX
48 #include <vcl/image.hxx>
50 #include <com/sun/star/accessibility/XAccessible.hpp>
52 // =======================================================================
57 HeaderBarItemBits mnBits
;
67 DECLARE_LIST( ImplHeadItemList
, ImplHeadItem
* )
69 // =======================================================================
71 #define HEAD_ARROWSIZE1 4
72 #define HEAD_ARROWSIZE2 7
74 #define HEADERBAR_TEXTOFF 2
75 #define HEADERBAR_ARROWOFF 5
76 #define HEADERBAR_SPLITOFF 3
78 #define HEADERBAR_DRAGOFF 4
79 #define HEADERBAR_DRAGOUTOFF 15
81 #define HEAD_HITTEST_ITEM ((USHORT)0x0001)
82 #define HEAD_HITTEST_DIVIDER ((USHORT)0x0002)
84 // =======================================================================
86 void HeaderBar::ImplInit( WinBits nWinStyle
)
88 mpItemList
= new ImplHeadItemList
;
99 mnItemDragPos
= HEADERBAR_ITEM_NOTFOUND
;
105 // StyleBits auswerten
106 if ( nWinStyle
& WB_DRAG
)
110 if ( nWinStyle
& WB_BUTTONSTYLE
)
111 mbButtonStyle
= TRUE
;
113 mbButtonStyle
= FALSE
;
114 if ( nWinStyle
& WB_BORDER
)
121 if ( nWinStyle
& WB_BOTTOMBORDER
)
125 ImplInitSettings( TRUE
, TRUE
, TRUE
);
128 // -----------------------------------------------------------------------
130 HeaderBar::HeaderBar( Window
* pParent
, WinBits nWinStyle
) :
131 Window( pParent
, nWinStyle
& WB_3DLOOK
)
133 ImplInit( nWinStyle
);
134 SetSizePixel( CalcWindowSizePixel() );
137 // -----------------------------------------------------------------------
139 HeaderBar::HeaderBar( Window
* pParent
, const ResId
& rResId
) :
140 Window( pParent
, rResId
)
142 ImplInit( rResId
.GetWinBits() );
145 // -----------------------------------------------------------------------
147 HeaderBar::~HeaderBar()
149 // Alle Items loeschen
150 ImplHeadItem
* pItem
= mpItemList
->First();
154 pItem
= mpItemList
->Next();
160 // -----------------------------------------------------------------------
162 void HeaderBar::ImplInitSettings( BOOL bFont
,
163 BOOL bForeground
, BOOL bBackground
)
165 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
170 aFont
= rStyleSettings
.GetToolFont();
171 if ( IsControlFont() )
172 aFont
.Merge( GetControlFont() );
173 SetZoomedPointFont( aFont
);
176 if ( bForeground
|| bFont
)
179 if ( IsControlForeground() )
180 aColor
= GetControlForeground();
182 aColor
= rStyleSettings
.GetButtonTextColor();
183 SetTextColor( aColor
);
190 if ( IsControlBackground() )
191 aColor
= GetControlBackground();
193 aColor
= rStyleSettings
.GetFaceColor();
194 SetBackground( aColor
);
198 // -----------------------------------------------------------------------
200 long HeaderBar::ImplGetItemPos( USHORT nPos
) const
203 for ( USHORT i
= 0; i
< nPos
; i
++ )
204 nX
+= mpItemList
->GetObject( i
)->mnSize
;
208 // -----------------------------------------------------------------------
210 Rectangle
HeaderBar::ImplGetItemRect( USHORT nPos
) const
212 Rectangle
aRect( ImplGetItemPos( nPos
), 0, 0, mnDY
-1 );
213 aRect
.Right() = aRect
.Left() + mpItemList
->GetObject( nPos
)->mnSize
- 1;
214 // Gegen Ueberlauf auf einigen Systemen testen
215 if ( aRect
.Right() > 16000 )
216 aRect
.Right() = 16000;
220 // -----------------------------------------------------------------------
222 USHORT
HeaderBar::ImplHitTest( const Point
& rPos
,
223 long& nMouseOff
, USHORT
& nPos
) const
226 USHORT nCount
= (USHORT
)mpItemList
->Count();
227 BOOL bLastFixed
= TRUE
;
230 for ( USHORT i
= 0; i
< nCount
; i
++ )
232 pItem
= mpItemList
->GetObject( i
);
234 if ( rPos
.X() < (nX
+pItem
->mnSize
) )
238 if ( !bLastFixed
&& (rPos
.X() < (nX
+HEADERBAR_SPLITOFF
)) )
240 nMode
= HEAD_HITTEST_DIVIDER
;
242 nMouseOff
= rPos
.X()-nX
+1;
248 if ( !(pItem
->mnBits
& HIB_FIXED
) && (rPos
.X() >= (nX
+pItem
->mnSize
-HEADERBAR_SPLITOFF
)) )
250 nMode
= HEAD_HITTEST_DIVIDER
;
251 nMouseOff
= rPos
.X()-(nX
+pItem
->mnSize
);
255 nMode
= HEAD_HITTEST_ITEM
;
256 nMouseOff
= rPos
.X()-nX
;
263 if ( pItem
->mnBits
& HIB_FIXED
)
273 pItem
= mpItemList
->GetObject( nCount
-1 );
274 if ( (pItem
->mnSize
< 4) && (rPos
.X() < (nX
+HEADERBAR_SPLITOFF
)) )
277 nMouseOff
= rPos
.X()-nX
+1;
278 return HEAD_HITTEST_DIVIDER
;
285 // -----------------------------------------------------------------------
287 void HeaderBar::ImplInvertDrag( USHORT nStartPos
, USHORT nEndPos
)
289 Rectangle aRect1
= ImplGetItemRect( nStartPos
);
290 Rectangle aRect2
= ImplGetItemRect( nEndPos
);
291 Point aStartPos
= aRect1
.Center();
292 Point aEndPos
= aStartPos
;
293 Rectangle
aStartRect( aStartPos
.X()-2, aStartPos
.Y()-2,
294 aStartPos
.X()+2, aStartPos
.Y()+2 );
296 if ( nEndPos
> nStartPos
)
299 aEndPos
.X() = aRect2
.Right()-6;
304 aEndPos
.X() = aRect2
.Left()+6;
307 SetRasterOp( ROP_INVERT
);
308 DrawRect( aStartRect
);
309 DrawLine( aStartPos
, aEndPos
);
310 if ( nEndPos
> nStartPos
)
312 DrawLine( Point( aEndPos
.X()+1, aEndPos
.Y()-3 ),
313 Point( aEndPos
.X()+1, aEndPos
.Y()+3 ) );
314 DrawLine( Point( aEndPos
.X()+2, aEndPos
.Y()-2 ),
315 Point( aEndPos
.X()+2, aEndPos
.Y()+2 ) );
316 DrawLine( Point( aEndPos
.X()+3, aEndPos
.Y()-1 ),
317 Point( aEndPos
.X()+3, aEndPos
.Y()+1 ) );
318 DrawPixel( Point( aEndPos
.X()+4, aEndPos
.Y() ) );
322 DrawLine( Point( aEndPos
.X()-1, aEndPos
.Y()-3 ),
323 Point( aEndPos
.X()-1, aEndPos
.Y()+3 ) );
324 DrawLine( Point( aEndPos
.X()-2, aEndPos
.Y()-2 ),
325 Point( aEndPos
.X()-2, aEndPos
.Y()+2 ) );
326 DrawLine( Point( aEndPos
.X()-3, aEndPos
.Y()-1 ),
327 Point( aEndPos
.X()-3, aEndPos
.Y()+1 ) );
328 DrawPixel( Point( aEndPos
.X()-4, aEndPos
.Y() ) );
330 SetRasterOp( ROP_OVERPAINT
);
333 // -----------------------------------------------------------------------
335 void HeaderBar::ImplDrawItem( OutputDevice
* pDev
,
336 USHORT nPos
, BOOL bHigh
, BOOL bDrag
,
337 const Rectangle
& rItemRect
,
338 const Rectangle
* pRect
,
341 Rectangle aRect
= rItemRect
;
343 // Wenn kein Platz, dann brauchen wir auch nichts ausgeben
344 if ( aRect
.GetWidth() <= 1 )
347 // Feststellen, ob Rectangle ueberhaupt sichtbar
350 if ( aRect
.Right() < pRect
->Left() )
352 else if ( aRect
.Left() > pRect
->Right() )
357 if ( aRect
.Right() < 0 )
359 else if ( aRect
.Left() > mnDX
)
363 ImplHeadItem
* pItem
= mpItemList
->GetObject( nPos
);
364 HeaderBarItemBits nBits
= pItem
->mnBits
;
365 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
367 // Border muss nicht gemalt werden
368 aRect
.Top() += mnBorderOff1
;
369 aRect
.Bottom() -= mnBorderOff2
;
371 // Hintergrund loeschen
372 if ( !pRect
|| bDrag
)
376 pDev
->SetLineColor();
377 pDev
->SetFillColor( rStyleSettings
.GetCheckedColor() );
378 pDev
->DrawRect( aRect
);
381 pDev
->DrawWallpaper( aRect
, GetBackground() );
385 pDev
->SetLineColor( rStyleSettings
.GetDarkShadowColor() );
386 pDev
->DrawLine( Point( aRect
.Right(), aRect
.Top() ),
387 Point( aRect
.Right(), aRect
.Bottom() ) );
391 Color
aSelectionTextColor( COL_TRANSPARENT
);
393 DrawSelectionBackground( aRect
, 1, TRUE
, FALSE
, FALSE
, &aSelectionTextColor
);
394 else if ( !mbButtonStyle
|| (nBits
& HIB_FLAT
) )
395 DrawSelectionBackground( aRect
, 0, TRUE
, FALSE
, FALSE
, &aSelectionTextColor
);
397 // Wenn kein Platz, dann brauchen wir auch nichts ausgeben
398 if ( aRect
.GetWidth() < 1 )
401 // Positionen und Groessen berechnen und Inhalt ausgeben
402 pItem
->maOutText
= pItem
->maText
;
403 Size aImageSize
= pItem
->maImage
.GetSizePixel();
404 Size
aTxtSize( pDev
->GetTextWidth( pItem
->maOutText
), 0 );
405 if ( pItem
->maOutText
.Len() )
406 aTxtSize
.Height() = pDev
->GetTextHeight();
407 long nArrowWidth
= 0;
408 if ( nBits
& (HIB_UPARROW
| HIB_DOWNARROW
) )
409 nArrowWidth
= HEAD_ARROWSIZE2
+HEADERBAR_ARROWOFF
;
411 // Wenn kein Platz fuer Image, dann nicht ausgeben
412 long nTestHeight
= aImageSize
.Height();
413 if ( !(nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
)) )
414 nTestHeight
+= aTxtSize
.Height();
415 if ( (aImageSize
.Width() > aRect
.GetWidth()) || (nTestHeight
> aRect
.GetHeight()) )
417 aImageSize
.Width() = 0;
418 aImageSize
.Height() = 0;
421 // Text auf entsprechende Laenge kuerzen
422 BOOL bLeftText
= FALSE
;
423 long nMaxTxtWidth
= aRect
.GetWidth()-(HEADERBAR_TEXTOFF
*2)-nArrowWidth
;
424 if ( nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
) )
425 nMaxTxtWidth
-= aImageSize
.Width();
426 long nTxtWidth
= aTxtSize
.Width();
427 if ( nTxtWidth
> nMaxTxtWidth
)
431 pItem
->maOutText
.AppendAscii( "..." );
434 pItem
->maOutText
.Erase( pItem
->maOutText
.Len()-3-1, 1 );
435 nTxtWidth
= pDev
->GetTextWidth( pItem
->maOutText
);
437 while ( (nTxtWidth
> nMaxTxtWidth
) && (pItem
->maOutText
.Len() > 3) );
438 if ( pItem
->maOutText
.Len() == 3 )
441 pItem
->maOutText
.Erase();
445 // Text/Imageposition berechnen
447 if ( !bLeftText
&& (nBits
& HIB_RIGHT
) )
449 nTxtPos
= aRect
.Right()-nTxtWidth
-HEADERBAR_TEXTOFF
;
450 if ( nBits
& HIB_RIGHTIMAGE
)
451 nTxtPos
-= aImageSize
.Width();
453 else if ( !bLeftText
&& (nBits
& HIB_CENTER
) )
455 long nTempWidth
= nTxtWidth
;
456 if ( nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
) )
457 nTempWidth
+= aImageSize
.Width();
458 nTxtPos
= aRect
.Left()+(aRect
.GetWidth()-nTempWidth
)/2;
459 if ( nBits
& HIB_LEFTIMAGE
)
460 nTxtPos
+= aImageSize
.Width();
463 if ( nTxtPos
+nTxtWidth
+nArrowWidth
>= aRect
.Right() )
465 nTxtPos
= aRect
.Left()+HEADERBAR_TEXTOFF
;
466 if ( nBits
& HIB_LEFTIMAGE
)
467 nTxtPos
+= aImageSize
.Width();
473 nTxtPos
= aRect
.Left()+HEADERBAR_TEXTOFF
;
474 if ( nBits
& HIB_LEFTIMAGE
)
475 nTxtPos
+= aImageSize
.Width();
476 if ( nBits
& HIB_RIGHT
)
477 nTxtPos
+= nArrowWidth
;
480 // TextPosition berechnen
482 if ( pItem
->maOutText
.Len() || (nArrowWidth
&& aTxtSize
.Height()) )
484 if ( nBits
& HIB_TOP
)
486 nTxtPosY
= aRect
.Top();
487 if ( !(nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
)) )
488 nTxtPosY
+= aImageSize
.Height();
490 else if ( nBits
& HIB_BOTTOM
)
491 nTxtPosY
= aRect
.Bottom()-aTxtSize
.Height();
494 long nTempHeight
= aTxtSize
.Height();
495 if ( !(nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
)) )
496 nTempHeight
+= aImageSize
.Height();
497 nTxtPosY
= aRect
.Top()+((aRect
.GetHeight()-nTempHeight
)/2);
498 if ( !(nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
)) )
499 nTxtPosY
+= aImageSize
.Height();
504 if ( pItem
->maOutText
.Len() )
506 if( aSelectionTextColor
!= Color( COL_TRANSPARENT
) )
508 pDev
->Push( PUSH_TEXTCOLOR
);
509 pDev
->SetTextColor( aSelectionTextColor
);
512 pDev
->DrawText( Point( nTxtPos
, nTxtPosY
), pItem
->maOutText
);
514 pDev
->DrawCtrlText( Point( nTxtPos
, nTxtPosY
), pItem
->maOutText
, 0, STRING_LEN
, TEXT_DRAW_DISABLE
);
515 if( aSelectionTextColor
!= Color( COL_TRANSPARENT
) )
519 // Wenn Image vorhanden, Position berechnen und ausgeben
521 if ( aImageSize
.Width() && aImageSize
.Height() )
523 long nImagePos
= nTxtPos
;
524 if ( nBits
& HIB_LEFTIMAGE
)
526 nImagePos
-= aImageSize
.Width();
527 if ( nBits
& HIB_RIGHT
)
528 nImagePos
-= nArrowWidth
;
530 else if ( nBits
& HIB_RIGHTIMAGE
)
532 nImagePos
+= nTxtWidth
;
533 if ( !(nBits
& HIB_RIGHT
) )
534 nImagePos
+= nArrowWidth
;
538 if ( nBits
& HIB_RIGHT
)
539 nImagePos
= aRect
.Right()-aImageSize
.Width();
540 else if ( nBits
& HIB_CENTER
)
541 nImagePos
= aRect
.Left()+(aRect
.GetWidth()-aImageSize
.Width())/2;
543 nImagePos
= aRect
.Left()+HEADERBAR_TEXTOFF
;
546 if ( nBits
& HIB_TOP
)
547 nImagePosY
= aRect
.Top();
548 else if ( nBits
& HIB_BOTTOM
)
550 nImagePosY
= aRect
.Bottom()-aImageSize
.Height();
551 if ( !(nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
)) )
552 nImagePosY
-= aTxtSize
.Height();
556 long nTempHeight
= aImageSize
.Height();
557 if ( !(nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
)) )
558 nTempHeight
+= aTxtSize
.Height();
559 nImagePosY
= aRect
.Top()+((aRect
.GetHeight()-nTempHeight
)/2);
561 if ( nImagePos
+aImageSize
.Width() <= aRect
.Right() )
565 nStyle
|= IMAGE_DRAW_DISABLE
;
566 pDev
->DrawImage( Point( nImagePos
, nImagePosY
), pItem
->maImage
, nStyle
);
570 if ( nBits
& (HIB_UPARROW
| HIB_DOWNARROW
) )
572 long nArrowX
= nTxtPos
;
573 if ( nBits
& HIB_RIGHT
)
574 nArrowX
-= nArrowWidth
;
576 nArrowX
+= nTxtWidth
+HEADERBAR_ARROWOFF
;
577 if ( !(nBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
)) && !pItem
->maText
.Len() )
579 if ( nBits
& HIB_RIGHT
)
580 nArrowX
-= aImageSize
.Width();
582 nArrowX
+= aImageSize
.Width();
585 // Feststellen, ob Platz genug ist, das Item zu malen
587 if ( nArrowX
< aRect
.Left()+HEADERBAR_TEXTOFF
)
589 else if ( nArrowX
+HEAD_ARROWSIZE2
> aRect
.Right() )
595 if ( aTxtSize
.Height() )
596 nArrowY
= nTxtPosY
+(aTxtSize
.Height()/2);
597 else if ( aImageSize
.Width() && aImageSize
.Height() )
598 nArrowY
= nImagePosY
+(aImageSize
.Height()/2);
601 if ( nBits
& HIB_TOP
)
602 nArrowY
= aRect
.Top()+1;
603 else if ( nBits
& HIB_BOTTOM
)
604 nArrowY
= aRect
.Bottom()-HEAD_ARROWSIZE2
-1;
606 nArrowY
= aRect
.Top()+((aRect
.GetHeight()-HEAD_ARROWSIZE2
)/2);;
608 nArrowY
-= HEAD_ARROWSIZE1
-1;
609 if ( nBits
& HIB_DOWNARROW
)
611 pDev
->SetLineColor( rStyleSettings
.GetLightColor() );
612 pDev
->DrawLine( Point( nArrowX
, nArrowY
),
613 Point( nArrowX
+HEAD_ARROWSIZE2
, nArrowY
) );
614 pDev
->DrawLine( Point( nArrowX
, nArrowY
),
615 Point( nArrowX
+HEAD_ARROWSIZE1
, nArrowY
+HEAD_ARROWSIZE2
) );
616 pDev
->SetLineColor( rStyleSettings
.GetShadowColor() );
617 pDev
->DrawLine( Point( nArrowX
+HEAD_ARROWSIZE1
, nArrowY
+HEAD_ARROWSIZE2
),
618 Point( nArrowX
+HEAD_ARROWSIZE2
, nArrowY
) );
622 pDev
->SetLineColor( rStyleSettings
.GetLightColor() );
623 pDev
->DrawLine( Point( nArrowX
, nArrowY
+HEAD_ARROWSIZE2
),
624 Point( nArrowX
+HEAD_ARROWSIZE1
, nArrowY
) );
625 pDev
->SetLineColor( rStyleSettings
.GetShadowColor() );
626 pDev
->DrawLine( Point( nArrowX
, nArrowY
+HEAD_ARROWSIZE2
),
627 Point( nArrowX
+HEAD_ARROWSIZE2
, nArrowY
+HEAD_ARROWSIZE2
) );
628 pDev
->DrawLine( Point( nArrowX
+HEAD_ARROWSIZE2
, nArrowY
+HEAD_ARROWSIZE2
),
629 Point( nArrowX
+HEAD_ARROWSIZE1
, nArrowY
) );
634 // Gegebenenfalls auch UserDraw aufrufen
635 if ( nBits
& HIB_USERDRAW
)
637 Region
aRegion( aRect
);
639 aRegion
.Intersect( *pRect
);
640 pDev
->SetClipRegion( aRegion
);
641 UserDrawEvent
aODEvt( pDev
, aRect
, pItem
->mnId
);
643 pDev
->SetClipRegion();
647 // -----------------------------------------------------------------------
649 void HeaderBar::ImplDrawItem( USHORT nPos
, BOOL bHigh
, BOOL bDrag
,
650 const Rectangle
* pRect
)
652 Rectangle aRect
= ImplGetItemRect( nPos
);
653 ImplDrawItem( this, nPos
, bHigh
, bDrag
, aRect
, pRect
, 0 );
656 // -----------------------------------------------------------------------
658 void HeaderBar::ImplUpdate( USHORT nPos
, BOOL bEnd
, BOOL bDirect
)
660 if ( IsVisible() && IsUpdateMode() )
665 USHORT nItemCount
= (USHORT
)(mpItemList
->Count());
666 if ( nPos
< nItemCount
)
667 aRect
= ImplGetItemRect( nPos
);
670 aRect
.Bottom() = mnDY
-1;
672 aRect
.Left() = ImplGetItemRect( nItemCount
-1 ).Right();
675 aRect
.Right() = mnDX
-1;
676 aRect
.Top() += mnBorderOff1
;
677 aRect
.Bottom() -= mnBorderOff2
;
682 for ( USHORT i
= nPos
; i
< mpItemList
->Count(); i
++ )
686 Rectangle aRect
= ImplGetItemRect( (USHORT
)mpItemList
->Count() );
687 aRect
.Left() = aRect
.Right();
688 aRect
.Right() = mnDX
-1;
689 if ( aRect
.Left() < aRect
.Right() )
691 aRect
.Top() += mnBorderOff1
;
692 aRect
.Bottom() -= mnBorderOff2
;
700 // -----------------------------------------------------------------------
702 void HeaderBar::ImplStartDrag( const Point
& rMousePos
, BOOL bCommand
)
705 USHORT nHitTest
= ImplHitTest( rMousePos
, mnMouseOff
, nPos
);
709 ImplHeadItem
* pItem
= mpItemList
->GetObject( nPos
);
710 if ( nHitTest
& HEAD_HITTEST_DIVIDER
)
714 if ( ((pItem
->mnBits
& HIB_CLICKABLE
) && !(pItem
->mnBits
& HIB_FLAT
)) ||
715 (mbDragable
&& !(pItem
->mnBits
& HIB_FIXEDPOS
)) )
734 mnCurItemId
= pItem
->mnId
;
744 mnCurItemId
= pItem
->mnId
;
745 mnItemDragPos
= nPos
;
747 mnStartPos
= rMousePos
.X()-mnMouseOff
;
748 mnDragPos
= mnStartPos
;
751 ImplDrawItem( nPos
, TRUE
, mbItemDrag
);
754 Rectangle
aSizeRect( mnDragPos
, 0, mnDragPos
, mnDragSize
+mnDY
);
755 ShowTracking( aSizeRect
, SHOWTRACK_SPLIT
);
763 // -----------------------------------------------------------------------
765 void HeaderBar::ImplDrag( const Point
& rMousePos
)
768 USHORT nPos
= GetItemPos( mnCurItemId
);
770 mnDragPos
= rMousePos
.X()-mnMouseOff
;
773 Rectangle aItemRect
= ImplGetItemRect( nPos
);
774 if ( aItemRect
.IsInside( rMousePos
) )
779 // Evt. ItemDrag anschalten
780 if ( bNewOutDrag
&& mbDragable
&& !mbItemDrag
&&
781 !(mpItemList
->GetObject(nPos
)->mnBits
& HIB_FIXEDPOS
) )
783 if ( (rMousePos
.Y() >= aItemRect
.Top()) && (rMousePos
.Y() <= aItemRect
.Bottom()) )
786 ImplDrawItem( nPos
, TRUE
, mbItemDrag
);
790 USHORT nOldItemDragPos
= mnItemDragPos
;
793 if ( (rMousePos
.Y() < -HEADERBAR_DRAGOUTOFF
) || (rMousePos
.Y() > mnDY
+HEADERBAR_DRAGOUTOFF
) )
799 mnItemDragPos
= HEADERBAR_ITEM_NOTFOUND
;
802 USHORT nTempId
= GetItemId( Point( rMousePos
.X(), 2 ) );
804 mnItemDragPos
= GetItemPos( nTempId
);
807 if ( rMousePos
.X() <= 0 )
810 mnItemDragPos
= GetItemCount()-1;
813 // Nicht verschiebbare Items aussparen
814 if ( mnItemDragPos
< nPos
)
816 while ( (mpItemList
->GetObject(mnItemDragPos
)->mnBits
& HIB_FIXEDPOS
) &&
817 (mnItemDragPos
< nPos
) )
820 else if ( mnItemDragPos
> nPos
)
822 while ( (mpItemList
->GetObject(mnItemDragPos
)->mnBits
& HIB_FIXEDPOS
) &&
823 (mnItemDragPos
> nPos
) )
828 if ( (mnItemDragPos
!= nOldItemDragPos
) &&
829 (nOldItemDragPos
!= nPos
) &&
830 (nOldItemDragPos
!= HEADERBAR_ITEM_NOTFOUND
) )
832 ImplInvertDrag( nPos
, nOldItemDragPos
);
833 ImplDrawItem( nOldItemDragPos
);
837 if ( bNewOutDrag
!= mbOutDrag
)
838 ImplDrawItem( nPos
, !bNewOutDrag
, mbItemDrag
);
842 if ( (mnItemDragPos
!= nOldItemDragPos
) &&
843 (mnItemDragPos
!= nPos
) &&
844 (mnItemDragPos
!= HEADERBAR_ITEM_NOTFOUND
) )
846 ImplDrawItem( mnItemDragPos
, FALSE
, TRUE
);
847 ImplInvertDrag( nPos
, mnItemDragPos
);
851 mbOutDrag
= bNewOutDrag
;
855 Rectangle aItemRect
= ImplGetItemRect( nPos
);
856 if ( mnDragPos
< aItemRect
.Left() )
857 mnDragPos
= aItemRect
.Left();
858 if ( (mnDragPos
< 0) || (mnDragPos
> mnDX
-1) )
862 Rectangle
aSizeRect( mnDragPos
, 0, mnDragPos
, mnDragSize
+mnDY
);
863 ShowTracking( aSizeRect
, SHOWTRACK_SPLIT
);
870 // -----------------------------------------------------------------------
872 void HeaderBar::ImplEndDrag( BOOL bCancel
)
876 if ( bCancel
|| mbOutDrag
)
878 if ( mbItemMode
&& (!mbOutDrag
|| mbItemDrag
) )
880 USHORT nPos
= GetItemPos( mnCurItemId
);
881 ImplDrawItem( nPos
);
888 USHORT nPos
= GetItemPos( mnCurItemId
);
893 Pointer
aPointer( POINTER_ARROW
);
894 SetPointer( aPointer
);
895 if ( (mnItemDragPos
!= nPos
) &&
896 (mnItemDragPos
!= HEADERBAR_ITEM_NOTFOUND
) )
898 ImplInvertDrag( nPos
, mnItemDragPos
);
899 MoveItem( mnCurItemId
, mnItemDragPos
);
902 ImplDrawItem( nPos
);
912 long nDelta
= mnDragPos
- mnStartPos
;
915 ImplHeadItem
* pItem
= mpItemList
->GetObject( nPos
);
916 pItem
->mnSize
+= nDelta
;
917 ImplUpdate( nPos
, TRUE
);
925 mnItemDragPos
= HEADERBAR_ITEM_NOTFOUND
;
931 // -----------------------------------------------------------------------
933 void HeaderBar::MouseButtonDown( const MouseEvent
& rMEvt
)
935 if ( rMEvt
.IsLeft() )
937 if ( rMEvt
.GetClicks() == 2 )
941 USHORT nHitTest
= ImplHitTest( rMEvt
.GetPosPixel(), nTemp
, nPos
);
944 ImplHeadItem
* pItem
= mpItemList
->GetObject( nPos
);
945 if ( nHitTest
& HEAD_HITTEST_DIVIDER
)
949 mnCurItemId
= pItem
->mnId
;
956 ImplStartDrag( rMEvt
.GetPosPixel(), FALSE
);
960 // -----------------------------------------------------------------------
962 void HeaderBar::MouseMove( const MouseEvent
& rMEvt
)
966 PointerStyle eStyle
= POINTER_ARROW
;
967 USHORT nHitTest
= ImplHitTest( rMEvt
.GetPosPixel(), nTemp1
, nTemp2
);
969 if ( nHitTest
& HEAD_HITTEST_DIVIDER
)
970 eStyle
= POINTER_HSIZEBAR
;
971 Pointer
aPtr( eStyle
);
975 // -----------------------------------------------------------------------
977 void HeaderBar::Tracking( const TrackingEvent
& rTEvt
)
979 Point aMousePos
= rTEvt
.GetMouseEvent().GetPosPixel();
981 if ( rTEvt
.IsTrackingEnded() )
982 ImplEndDrag( rTEvt
.IsTrackingCanceled() );
984 ImplDrag( aMousePos
);
987 // -----------------------------------------------------------------------
989 void HeaderBar::Paint( const Rectangle
& rRect
)
991 if ( mnBorderOff1
|| mnBorderOff2
)
993 SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
995 DrawLine( Point( 0, 0 ), Point( mnDX
-1, 0 ) );
997 DrawLine( Point( 0, mnDY
-1 ), Point( mnDX
-1, mnDY
-1 ) );
998 // #i40393# draw left and right border, if WB_BORDER was set in ImplInit()
999 if ( mnBorderOff1
&& mnBorderOff2
)
1001 DrawLine( Point( 0, 0 ), Point( 0, mnDY
-1 ) );
1002 DrawLine( Point( mnDX
-1, 0 ), Point( mnDX
-1, mnDY
-1 ) );
1008 nCurItemPos
= GetItemPos( mnCurItemId
);
1010 nCurItemPos
= HEADERBAR_ITEM_NOTFOUND
;
1011 USHORT nItemCount
= (USHORT
)mpItemList
->Count();
1012 for ( USHORT i
= 0; i
< nItemCount
; i
++ )
1013 ImplDrawItem( i
, (i
== nCurItemPos
) ? TRUE
: FALSE
, FALSE
, &rRect
);
1016 // -----------------------------------------------------------------------
1018 void HeaderBar::Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
,
1021 Point aPos
= pDev
->LogicToPixel( rPos
);
1022 Size aSize
= pDev
->LogicToPixel( rSize
);
1023 Rectangle
aRect( aPos
, aSize
);
1024 Font aFont
= GetDrawPixelFont( pDev
);
1028 pDev
->SetFont( aFont
);
1029 if ( nFlags
& WINDOW_DRAW_MONO
)
1030 pDev
->SetTextColor( Color( COL_BLACK
) );
1032 pDev
->SetTextColor( GetTextColor() );
1033 pDev
->SetTextFillColor();
1035 if ( !(nFlags
& WINDOW_DRAW_NOBACKGROUND
) )
1037 pDev
->DrawWallpaper( aRect
, GetBackground() );
1038 if ( mnBorderOff1
|| mnBorderOff2
)
1040 pDev
->SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
1042 pDev
->DrawLine( aRect
.TopLeft(), Point( aRect
.Right(), aRect
.Top() ) );
1044 pDev
->DrawLine( Point( aRect
.Left(), aRect
.Bottom() ), Point( aRect
.Right(), aRect
.Bottom() ) );
1045 // #i40393# draw left and right border, if WB_BORDER was set in ImplInit()
1046 if ( mnBorderOff1
&& mnBorderOff2
)
1048 pDev
->DrawLine( aRect
.TopLeft(), Point( aRect
.Left(), aRect
.Bottom() ) );
1049 pDev
->DrawLine( Point( aRect
.Right(), aRect
.Top() ), Point( aRect
.Right(), aRect
.Bottom() ) );
1054 Rectangle
aItemRect( aRect
);
1055 // aItemRect.Bottom()--;
1056 USHORT nItemCount
= (USHORT
)mpItemList
->Count();
1057 for ( USHORT i
= 0; i
< nItemCount
; i
++ )
1059 aItemRect
.Left() = aRect
.Left()+ImplGetItemPos( i
);
1060 aItemRect
.Right() = aItemRect
.Left() + mpItemList
->GetObject( i
)->mnSize
- 1;
1061 // Gegen Ueberlauf auf einigen Systemen testen
1062 if ( aItemRect
.Right() > 16000 )
1063 aItemRect
.Right() = 16000;
1064 Region
aRegion( aRect
);
1065 pDev
->SetClipRegion( aRegion
);
1066 ImplDrawItem( pDev
, i
, FALSE
, FALSE
, aItemRect
, &aRect
, nFlags
);
1067 pDev
->SetClipRegion();
1073 // -----------------------------------------------------------------------
1075 void HeaderBar::Resize()
1077 Size aSize
= GetOutputSizePixel();
1078 if ( IsVisible() && (mnDY
!= aSize
.Height()) )
1080 mnDX
= aSize
.Width();
1081 mnDY
= aSize
.Height();
1084 // -----------------------------------------------------------------------
1086 void HeaderBar::Command( const CommandEvent
& rCEvt
)
1088 if ( rCEvt
.IsMouseEvent() && (rCEvt
.GetCommand() == COMMAND_STARTDRAG
) && !mbDrag
)
1090 ImplStartDrag( rCEvt
.GetMousePosPixel(), TRUE
);
1094 Window::Command( rCEvt
);
1097 // -----------------------------------------------------------------------
1099 void HeaderBar::RequestHelp( const HelpEvent
& rHEvt
)
1101 USHORT nItemId
= GetItemId( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ) );
1104 if ( rHEvt
.GetMode() & (HELPMODE_QUICK
| HELPMODE_BALLOON
) )
1106 Rectangle aItemRect
= GetItemRect( nItemId
);
1107 Point aPt
= OutputToScreenPixel( aItemRect
.TopLeft() );
1108 aItemRect
.Left() = aPt
.X();
1109 aItemRect
.Top() = aPt
.Y();
1110 aPt
= OutputToScreenPixel( aItemRect
.BottomRight() );
1111 aItemRect
.Right() = aPt
.X();
1112 aItemRect
.Bottom() = aPt
.Y();
1114 XubString aStr
= GetHelpText( nItemId
);
1115 if ( !aStr
.Len() || !(rHEvt
.GetMode() & HELPMODE_BALLOON
) )
1117 ImplHeadItem
* pItem
= mpItemList
->GetObject( GetItemPos( nItemId
) );
1118 // Wir zeigen die Quick-Hilfe nur an, wenn Text nicht
1119 // vollstaendig sichtbar, ansonsten zeigen wir den Hilfetext
1120 // an, wenn das Item keinen Text besitzt
1121 if ( pItem
->maOutText
!= pItem
->maText
)
1122 aStr
= pItem
->maText
;
1123 else if ( pItem
->maText
.Len() )
1129 if ( rHEvt
.GetMode() & HELPMODE_BALLOON
)
1130 Help::ShowBalloon( this, aItemRect
.Center(), aItemRect
, aStr
);
1132 Help::ShowQuickHelp( this, aItemRect
, aStr
);
1136 else if ( rHEvt
.GetMode() & HELPMODE_EXTENDED
)
1138 ULONG nHelpId
= GetHelpId( nItemId
);
1141 // Wenn eine Hilfe existiert, dann ausloesen
1142 Help
* pHelp
= Application::GetHelp();
1144 pHelp
->Start( nHelpId
, this );
1150 Window::RequestHelp( rHEvt
);
1153 // -----------------------------------------------------------------------
1155 void HeaderBar::StateChanged( StateChangedType nType
)
1157 Window::StateChanged( nType
);
1159 if ( nType
== STATE_CHANGE_ENABLE
)
1161 else if ( (nType
== STATE_CHANGE_ZOOM
) ||
1162 (nType
== STATE_CHANGE_CONTROLFONT
) )
1164 ImplInitSettings( TRUE
, FALSE
, FALSE
);
1167 else if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
1169 ImplInitSettings( FALSE
, TRUE
, FALSE
);
1172 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
1174 ImplInitSettings( FALSE
, FALSE
, TRUE
);
1179 // -----------------------------------------------------------------------
1181 void HeaderBar::DataChanged( const DataChangedEvent
& rDCEvt
)
1183 Window::DataChanged( rDCEvt
);
1185 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
1186 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
1187 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
1188 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
1190 ImplInitSettings( TRUE
, TRUE
, TRUE
);
1195 // -----------------------------------------------------------------------
1197 void HeaderBar::UserDraw( const UserDrawEvent
& )
1201 // -----------------------------------------------------------------------
1203 void HeaderBar::StartDrag()
1205 maStartDragHdl
.Call( this );
1208 // -----------------------------------------------------------------------
1210 void HeaderBar::Drag()
1212 maDragHdl
.Call( this );
1215 // -----------------------------------------------------------------------
1217 void HeaderBar::EndDrag()
1219 maEndDragHdl
.Call( this );
1222 // -----------------------------------------------------------------------
1224 void HeaderBar::Select()
1226 maSelectHdl
.Call( this );
1229 // -----------------------------------------------------------------------
1231 void HeaderBar::DoubleClick()
1233 maDoubleClickHdl
.Call( this );
1236 // -----------------------------------------------------------------------
1238 void HeaderBar::InsertItem( USHORT nItemId
, const Image
& rImage
,
1239 long nSize
, HeaderBarItemBits nBits
, USHORT nPos
)
1241 DBG_ASSERT( nItemId
, "HeaderBar::InsertItem(): ItemId == 0" );
1242 DBG_ASSERT( GetItemPos( nItemId
) == HEADERBAR_ITEM_NOTFOUND
,
1243 "HeaderBar::InsertItem(): ItemId already exists" );
1245 // Item anlegen und in die Liste einfuegen
1246 ImplHeadItem
* pItem
= new ImplHeadItem
;
1247 pItem
->mnId
= nItemId
;
1248 pItem
->mnBits
= nBits
;
1249 pItem
->mnSize
= nSize
;
1250 pItem
->maImage
= rImage
;
1251 pItem
->mpUserData
= 0;
1252 mpItemList
->Insert( pItem
, nPos
);
1255 ImplUpdate( nPos
, TRUE
);
1258 // -----------------------------------------------------------------------
1260 void HeaderBar::InsertItem( USHORT nItemId
, const XubString
& rText
,
1261 long nSize
, HeaderBarItemBits nBits
, USHORT nPos
)
1263 DBG_ASSERT( nItemId
, "HeaderBar::InsertItem(): ItemId == 0" );
1264 DBG_ASSERT( GetItemPos( nItemId
) == HEADERBAR_ITEM_NOTFOUND
,
1265 "HeaderBar::InsertItem(): ItemId already exists" );
1267 // Item anlegen und in die Liste einfuegen
1268 ImplHeadItem
* pItem
= new ImplHeadItem
;
1269 pItem
->mnId
= nItemId
;
1270 pItem
->mnBits
= nBits
;
1271 pItem
->mnSize
= nSize
;
1272 pItem
->mnHelpId
= 0;
1273 pItem
->maText
= rText
;
1274 pItem
->mpUserData
= 0;
1275 mpItemList
->Insert( pItem
, nPos
);
1278 ImplUpdate( nPos
, TRUE
);
1281 // -----------------------------------------------------------------------
1283 void HeaderBar::InsertItem( USHORT nItemId
,
1284 const Image
& rImage
, const XubString
& rText
,
1285 long nSize
, HeaderBarItemBits nBits
,
1288 DBG_ASSERT( nItemId
, "HeaderBar::InsertItem(): ItemId == 0" );
1289 DBG_ASSERT( GetItemPos( nItemId
) == HEADERBAR_ITEM_NOTFOUND
,
1290 "HeaderBar::InsertItem(): ItemId already exists" );
1292 // Item anlegen und in die Liste einfuegen
1293 ImplHeadItem
* pItem
= new ImplHeadItem
;
1294 pItem
->mnId
= nItemId
;
1295 pItem
->mnBits
= nBits
;
1296 pItem
->mnSize
= nSize
;
1297 pItem
->mnHelpId
= 0;
1298 pItem
->maImage
= rImage
;
1299 pItem
->maText
= rText
;
1300 pItem
->mpUserData
= 0;
1301 mpItemList
->Insert( pItem
, nPos
);
1304 ImplUpdate( nPos
, TRUE
);
1307 // -----------------------------------------------------------------------
1309 void HeaderBar::RemoveItem( USHORT nItemId
)
1311 USHORT nPos
= GetItemPos( nItemId
);
1312 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1314 ImplHeadItem
* pItem
= mpItemList
->Remove( nPos
);
1316 ImplUpdate( nPos
, TRUE
);
1320 // -----------------------------------------------------------------------
1322 void HeaderBar::MoveItem( USHORT nItemId
, USHORT nNewPos
)
1324 USHORT nPos
= GetItemPos( nItemId
);
1325 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1327 if ( nPos
!= nNewPos
)
1329 ImplHeadItem
* pItem
= mpItemList
->Remove( nPos
);
1330 if ( nNewPos
< nPos
)
1332 mpItemList
->Insert( pItem
, nNewPos
);
1333 ImplUpdate( nPos
, TRUE
);
1338 // -----------------------------------------------------------------------
1340 void HeaderBar::Clear()
1342 // Alle Items loeschen
1343 ImplHeadItem
* pItem
= mpItemList
->First();
1347 pItem
= mpItemList
->Next();
1349 mpItemList
->Clear();
1351 ImplUpdate( 0, TRUE
);
1354 // -----------------------------------------------------------------------
1356 void HeaderBar::SetOffset( long nNewOffset
)
1358 // Hier erstmal neu zeichnen, damit mit alten Offset noch das
1359 // richtige gemalt wird
1362 // Bereich verschieben
1363 Rectangle
aRect( 0, mnBorderOff1
, mnDX
-1, mnDY
-mnBorderOff1
-mnBorderOff2
-1 );
1364 long nDelta
= mnOffset
-nNewOffset
;
1365 mnOffset
= nNewOffset
;
1366 Scroll( nDelta
, 0, aRect
);
1369 // -----------------------------------------------------------------------
1371 USHORT
HeaderBar::GetItemCount() const
1373 return (USHORT
)mpItemList
->Count();
1376 // -----------------------------------------------------------------------
1378 USHORT
HeaderBar::GetItemPos( USHORT nItemId
) const
1380 ImplHeadItem
* pItem
= mpItemList
->First();
1383 if ( pItem
->mnId
== nItemId
)
1384 return (USHORT
)mpItemList
->GetCurPos();
1385 pItem
= mpItemList
->Next();
1388 return HEADERBAR_ITEM_NOTFOUND
;
1391 // -----------------------------------------------------------------------
1393 USHORT
HeaderBar::GetItemId( USHORT nPos
) const
1395 ImplHeadItem
* pItem
= mpItemList
->GetObject( nPos
);
1402 // -----------------------------------------------------------------------
1404 USHORT
HeaderBar::GetItemId( const Point
& rPos
) const
1407 while ( nPos
< mpItemList
->Count() )
1409 if ( ImplGetItemRect( nPos
).IsInside( rPos
) )
1410 return GetItemId( nPos
);
1418 // -----------------------------------------------------------------------
1420 Rectangle
HeaderBar::GetItemRect( USHORT nItemId
) const
1423 USHORT nPos
= GetItemPos( nItemId
);
1424 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1425 aRect
= ImplGetItemRect( nPos
);
1429 // -----------------------------------------------------------------------
1431 void HeaderBar::SetItemSize( USHORT nItemId
, long nNewSize
)
1433 USHORT nPos
= GetItemPos( nItemId
);
1434 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1436 ImplHeadItem
* pItem
= mpItemList
->GetObject( nPos
);
1437 if ( pItem
->mnSize
!= nNewSize
)
1439 pItem
->mnSize
= nNewSize
;
1440 ImplUpdate( nPos
, TRUE
);
1445 // -----------------------------------------------------------------------
1447 long HeaderBar::GetItemSize( USHORT nItemId
) const
1449 USHORT nPos
= GetItemPos( nItemId
);
1450 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1451 return mpItemList
->GetObject( nPos
)->mnSize
;
1456 // -----------------------------------------------------------------------
1458 void HeaderBar::SetItemBits( USHORT nItemId
, HeaderBarItemBits nNewBits
)
1460 USHORT nPos
= GetItemPos( nItemId
);
1461 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1463 ImplHeadItem
* pItem
= mpItemList
->GetObject( nPos
);
1464 if ( pItem
->mnBits
!= nNewBits
)
1466 pItem
->mnBits
= nNewBits
;
1472 // -----------------------------------------------------------------------
1474 HeaderBarItemBits
HeaderBar::GetItemBits( USHORT nItemId
) const
1476 USHORT nPos
= GetItemPos( nItemId
);
1477 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1478 return mpItemList
->GetObject( nPos
)->mnBits
;
1483 // -----------------------------------------------------------------------
1485 void HeaderBar::SetItemData( USHORT nItemId
, void* pNewData
)
1487 USHORT nPos
= GetItemPos( nItemId
);
1488 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1490 mpItemList
->GetObject( nPos
)->mpUserData
= pNewData
;
1495 // -----------------------------------------------------------------------
1497 void* HeaderBar::GetItemData( USHORT nItemId
) const
1499 USHORT nPos
= GetItemPos( nItemId
);
1500 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1501 return mpItemList
->GetObject( nPos
)->mpUserData
;
1506 // -----------------------------------------------------------------------
1508 void HeaderBar::SetItemImage( USHORT nItemId
, const Image
& rImage
)
1510 USHORT nPos
= GetItemPos( nItemId
);
1511 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1513 mpItemList
->GetObject( nPos
)->maImage
= rImage
;
1518 // -----------------------------------------------------------------------
1520 Image
HeaderBar::GetItemImage( USHORT nItemId
) const
1522 USHORT nPos
= GetItemPos( nItemId
);
1523 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1524 return mpItemList
->GetObject( nPos
)->maImage
;
1529 // -----------------------------------------------------------------------
1531 void HeaderBar::SetItemText( USHORT nItemId
, const XubString
& rText
)
1533 USHORT nPos
= GetItemPos( nItemId
);
1534 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1536 mpItemList
->GetObject( nPos
)->maText
= rText
;
1541 // -----------------------------------------------------------------------
1543 XubString
HeaderBar::GetItemText( USHORT nItemId
) const
1545 USHORT nPos
= GetItemPos( nItemId
);
1546 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1547 return mpItemList
->GetObject( nPos
)->maText
;
1552 // -----------------------------------------------------------------------
1554 void HeaderBar::SetHelpText( USHORT nItemId
, const XubString
& rText
)
1556 USHORT nPos
= GetItemPos( nItemId
);
1557 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1558 mpItemList
->GetObject( nPos
)->maHelpText
= rText
;
1561 // -----------------------------------------------------------------------
1563 XubString
HeaderBar::GetHelpText( USHORT nItemId
) const
1565 USHORT nPos
= GetItemPos( nItemId
);
1566 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1568 ImplHeadItem
* pItem
= mpItemList
->GetObject( nPos
);
1569 if ( !pItem
->maHelpText
.Len() && pItem
->mnHelpId
)
1571 Help
* pHelp
= Application::GetHelp();
1573 pItem
->maHelpText
= pHelp
->GetHelpText( pItem
->mnHelpId
, this );
1576 return pItem
->maHelpText
;
1582 // -----------------------------------------------------------------------
1584 void HeaderBar::SetHelpId( USHORT nItemId
, ULONG nHelpId
)
1586 USHORT nPos
= GetItemPos( nItemId
);
1587 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1588 mpItemList
->GetObject( nPos
)->mnHelpId
= nHelpId
;
1591 // -----------------------------------------------------------------------
1593 ULONG
HeaderBar::GetHelpId( USHORT nItemId
) const
1595 USHORT nPos
= GetItemPos( nItemId
);
1596 if ( nPos
!= HEADERBAR_ITEM_NOTFOUND
)
1597 return mpItemList
->GetObject( nPos
)->mnHelpId
;
1602 // -----------------------------------------------------------------------
1604 Size
HeaderBar::CalcWindowSizePixel() const
1606 long nMaxImageSize
= 0;
1607 Size
aSize( 0, GetTextHeight() );
1609 ImplHeadItem
* pItem
= mpItemList
->First();
1612 // Image-Groessen beruecksichtigen
1613 long nImageHeight
= pItem
->maImage
.GetSizePixel().Height();
1614 if ( !(pItem
->mnBits
& (HIB_LEFTIMAGE
| HIB_RIGHTIMAGE
)) && pItem
->maText
.Len() )
1615 nImageHeight
+= aSize
.Height();
1616 if ( nImageHeight
> nMaxImageSize
)
1617 nMaxImageSize
= nImageHeight
;
1619 // Breite aufaddieren
1620 aSize
.Width() += pItem
->mnSize
;
1622 pItem
= mpItemList
->Next();
1625 if ( nMaxImageSize
> aSize
.Height() )
1626 aSize
.Height() = nMaxImageSize
;
1628 // Border aufaddieren
1629 if ( mbButtonStyle
)
1630 aSize
.Height() += 4;
1632 aSize
.Height() += 2;
1633 aSize
.Height() += mnBorderOff1
+mnBorderOff2
;
1638 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> HeaderBar::CreateAccessible()
1640 if ( !mxAccessible
.is() )
1642 if ( maCreateAccessibleHdl
.IsSet() )
1643 maCreateAccessibleHdl
.Call( this );
1645 if ( !mxAccessible
.is() )
1646 mxAccessible
= Window::CreateAccessible();
1649 return mxAccessible
;
1652 void HeaderBar::SetAccessible( ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> _xAccessible
)
1654 mxAccessible
= _xAccessible
;