1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svtools.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define _SV_HEADBAR_CXX 32*cdf0e10cSrcweir #include <svtools/headbar.hxx> 33*cdf0e10cSrcweir #include <tools/debug.hxx> 34*cdf0e10cSrcweir #ifndef _TOOLS_LIST_HXX 35*cdf0e10cSrcweir #include <tools/list.hxx> 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #ifndef _VCL_APP_HXX 39*cdf0e10cSrcweir #include <vcl/svapp.hxx> 40*cdf0e10cSrcweir #endif 41*cdf0e10cSrcweir #ifndef _VCL_HELP_HXX 42*cdf0e10cSrcweir #include <vcl/help.hxx> 43*cdf0e10cSrcweir #endif 44*cdf0e10cSrcweir #ifndef _VCL_IMAGE_HXX 45*cdf0e10cSrcweir #include <vcl/image.hxx> 46*cdf0e10cSrcweir #endif 47*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir // ======================================================================= 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir struct ImplHeadItem 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir sal_uInt16 mnId; 54*cdf0e10cSrcweir HeaderBarItemBits mnBits; 55*cdf0e10cSrcweir long mnSize; 56*cdf0e10cSrcweir rtl::OString maHelpId; 57*cdf0e10cSrcweir Image maImage; 58*cdf0e10cSrcweir XubString maOutText; 59*cdf0e10cSrcweir XubString maText; 60*cdf0e10cSrcweir XubString maHelpText; 61*cdf0e10cSrcweir void* mpUserData; 62*cdf0e10cSrcweir }; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir DECLARE_LIST( ImplHeadItemList, ImplHeadItem* ) 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir // ======================================================================= 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir #define HEAD_ARROWSIZE1 4 69*cdf0e10cSrcweir #define HEAD_ARROWSIZE2 7 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir #define HEADERBAR_TEXTOFF 2 72*cdf0e10cSrcweir #define HEADERBAR_ARROWOFF 5 73*cdf0e10cSrcweir #define HEADERBAR_SPLITOFF 3 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir #define HEADERBAR_DRAGOFF 4 76*cdf0e10cSrcweir #define HEADERBAR_DRAGOUTOFF 15 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir #define HEAD_HITTEST_ITEM ((sal_uInt16)0x0001) 79*cdf0e10cSrcweir #define HEAD_HITTEST_DIVIDER ((sal_uInt16)0x0002) 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir // ======================================================================= 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir void HeaderBar::ImplInit( WinBits nWinStyle ) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir mpItemList = new ImplHeadItemList; 86*cdf0e10cSrcweir mnBorderOff1 = 0; 87*cdf0e10cSrcweir mnBorderOff2 = 0; 88*cdf0e10cSrcweir mnOffset = 0; 89*cdf0e10cSrcweir mnDX = 0; 90*cdf0e10cSrcweir mnDY = 0; 91*cdf0e10cSrcweir mnDragSize = 0; 92*cdf0e10cSrcweir mnStartPos = 0; 93*cdf0e10cSrcweir mnDragPos = 0; 94*cdf0e10cSrcweir mnMouseOff = 0; 95*cdf0e10cSrcweir mnCurItemId = 0; 96*cdf0e10cSrcweir mnItemDragPos = HEADERBAR_ITEM_NOTFOUND; 97*cdf0e10cSrcweir mbDrag = sal_False; 98*cdf0e10cSrcweir mbItemDrag = sal_False; 99*cdf0e10cSrcweir mbOutDrag = sal_False; 100*cdf0e10cSrcweir mbItemMode = sal_False; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir // StyleBits auswerten 103*cdf0e10cSrcweir if ( nWinStyle & WB_DRAG ) 104*cdf0e10cSrcweir mbDragable = sal_True; 105*cdf0e10cSrcweir else 106*cdf0e10cSrcweir mbDragable = sal_False; 107*cdf0e10cSrcweir if ( nWinStyle & WB_BUTTONSTYLE ) 108*cdf0e10cSrcweir mbButtonStyle = sal_True; 109*cdf0e10cSrcweir else 110*cdf0e10cSrcweir mbButtonStyle = sal_False; 111*cdf0e10cSrcweir if ( nWinStyle & WB_BORDER ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir mnBorderOff1 = 1; 114*cdf0e10cSrcweir mnBorderOff2 = 1; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir else 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir if ( nWinStyle & WB_BOTTOMBORDER ) 119*cdf0e10cSrcweir mnBorderOff2 = 1; 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // ----------------------------------------------------------------------- 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir HeaderBar::HeaderBar( Window* pParent, WinBits nWinStyle ) : 128*cdf0e10cSrcweir Window( pParent, nWinStyle & WB_3DLOOK ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir ImplInit( nWinStyle ); 131*cdf0e10cSrcweir SetSizePixel( CalcWindowSizePixel() ); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // ----------------------------------------------------------------------- 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir HeaderBar::HeaderBar( Window* pParent, const ResId& rResId ) : 137*cdf0e10cSrcweir Window( pParent, rResId ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir ImplInit( rResId.GetWinBits() ); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir // ----------------------------------------------------------------------- 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir HeaderBar::~HeaderBar() 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir // Alle Items loeschen 147*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->First(); 148*cdf0e10cSrcweir while ( pItem ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir delete pItem; 151*cdf0e10cSrcweir pItem = mpItemList->Next(); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir delete mpItemList; 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir // ----------------------------------------------------------------------- 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir void HeaderBar::ImplInitSettings( sal_Bool bFont, 160*cdf0e10cSrcweir sal_Bool bForeground, sal_Bool bBackground ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir if ( bFont ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir Font aFont; 167*cdf0e10cSrcweir aFont = rStyleSettings.GetToolFont(); 168*cdf0e10cSrcweir if ( IsControlFont() ) 169*cdf0e10cSrcweir aFont.Merge( GetControlFont() ); 170*cdf0e10cSrcweir SetZoomedPointFont( aFont ); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir if ( bForeground || bFont ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir Color aColor; 176*cdf0e10cSrcweir if ( IsControlForeground() ) 177*cdf0e10cSrcweir aColor = GetControlForeground(); 178*cdf0e10cSrcweir else 179*cdf0e10cSrcweir aColor = rStyleSettings.GetButtonTextColor(); 180*cdf0e10cSrcweir SetTextColor( aColor ); 181*cdf0e10cSrcweir SetTextFillColor(); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir if ( bBackground ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir Color aColor; 187*cdf0e10cSrcweir if ( IsControlBackground() ) 188*cdf0e10cSrcweir aColor = GetControlBackground(); 189*cdf0e10cSrcweir else 190*cdf0e10cSrcweir aColor = rStyleSettings.GetFaceColor(); 191*cdf0e10cSrcweir SetBackground( aColor ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir // ----------------------------------------------------------------------- 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir long HeaderBar::ImplGetItemPos( sal_uInt16 nPos ) const 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir long nX = -mnOffset; 200*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nPos; i++ ) 201*cdf0e10cSrcweir nX += mpItemList->GetObject( i )->mnSize; 202*cdf0e10cSrcweir return nX; 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir // ----------------------------------------------------------------------- 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir Rectangle HeaderBar::ImplGetItemRect( sal_uInt16 nPos ) const 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir Rectangle aRect( ImplGetItemPos( nPos ), 0, 0, mnDY-1 ); 210*cdf0e10cSrcweir aRect.Right() = aRect.Left() + mpItemList->GetObject( nPos )->mnSize - 1; 211*cdf0e10cSrcweir // Gegen Ueberlauf auf einigen Systemen testen 212*cdf0e10cSrcweir if ( aRect.Right() > 16000 ) 213*cdf0e10cSrcweir aRect.Right() = 16000; 214*cdf0e10cSrcweir return aRect; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir // ----------------------------------------------------------------------- 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir sal_uInt16 HeaderBar::ImplHitTest( const Point& rPos, 220*cdf0e10cSrcweir long& nMouseOff, sal_uInt16& nPos ) const 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir ImplHeadItem* pItem; 223*cdf0e10cSrcweir sal_uInt16 nCount = (sal_uInt16)mpItemList->Count(); 224*cdf0e10cSrcweir sal_Bool bLastFixed = sal_True; 225*cdf0e10cSrcweir long nX = -mnOffset; 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; i++ ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir pItem = mpItemList->GetObject( i ); 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir if ( rPos.X() < (nX+pItem->mnSize) ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir sal_uInt16 nMode; 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir if ( !bLastFixed && (rPos.X() < (nX+HEADERBAR_SPLITOFF)) ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir nMode = HEAD_HITTEST_DIVIDER; 238*cdf0e10cSrcweir nPos = i-1; 239*cdf0e10cSrcweir nMouseOff = rPos.X()-nX+1; 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir else 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir nPos = i; 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir if ( !(pItem->mnBits & HIB_FIXED) && (rPos.X() >= (nX+pItem->mnSize-HEADERBAR_SPLITOFF)) ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir nMode = HEAD_HITTEST_DIVIDER; 248*cdf0e10cSrcweir nMouseOff = rPos.X()-(nX+pItem->mnSize); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir nMode = HEAD_HITTEST_ITEM; 253*cdf0e10cSrcweir nMouseOff = rPos.X()-nX; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir return nMode; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir if ( pItem->mnBits & HIB_FIXED ) 261*cdf0e10cSrcweir bLastFixed = sal_True; 262*cdf0e10cSrcweir else 263*cdf0e10cSrcweir bLastFixed = sal_False; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir nX += pItem->mnSize; 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir if ( !bLastFixed ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir pItem = mpItemList->GetObject( nCount-1 ); 271*cdf0e10cSrcweir if ( (pItem->mnSize < 4) && (rPos.X() < (nX+HEADERBAR_SPLITOFF)) ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir nPos = nCount-1; 274*cdf0e10cSrcweir nMouseOff = rPos.X()-nX+1; 275*cdf0e10cSrcweir return HEAD_HITTEST_DIVIDER; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir return 0; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir // ----------------------------------------------------------------------- 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir void HeaderBar::ImplInvertDrag( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir Rectangle aRect1 = ImplGetItemRect( nStartPos ); 287*cdf0e10cSrcweir Rectangle aRect2 = ImplGetItemRect( nEndPos ); 288*cdf0e10cSrcweir Point aStartPos = aRect1.Center(); 289*cdf0e10cSrcweir Point aEndPos = aStartPos; 290*cdf0e10cSrcweir Rectangle aStartRect( aStartPos.X()-2, aStartPos.Y()-2, 291*cdf0e10cSrcweir aStartPos.X()+2, aStartPos.Y()+2 ); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir if ( nEndPos > nStartPos ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir aStartPos.X() += 3; 296*cdf0e10cSrcweir aEndPos.X() = aRect2.Right()-6; 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir else 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir aStartPos.X() -= 3; 301*cdf0e10cSrcweir aEndPos.X() = aRect2.Left()+6; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir SetRasterOp( ROP_INVERT ); 305*cdf0e10cSrcweir DrawRect( aStartRect ); 306*cdf0e10cSrcweir DrawLine( aStartPos, aEndPos ); 307*cdf0e10cSrcweir if ( nEndPos > nStartPos ) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir DrawLine( Point( aEndPos.X()+1, aEndPos.Y()-3 ), 310*cdf0e10cSrcweir Point( aEndPos.X()+1, aEndPos.Y()+3 ) ); 311*cdf0e10cSrcweir DrawLine( Point( aEndPos.X()+2, aEndPos.Y()-2 ), 312*cdf0e10cSrcweir Point( aEndPos.X()+2, aEndPos.Y()+2 ) ); 313*cdf0e10cSrcweir DrawLine( Point( aEndPos.X()+3, aEndPos.Y()-1 ), 314*cdf0e10cSrcweir Point( aEndPos.X()+3, aEndPos.Y()+1 ) ); 315*cdf0e10cSrcweir DrawPixel( Point( aEndPos.X()+4, aEndPos.Y() ) ); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir else 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir DrawLine( Point( aEndPos.X()-1, aEndPos.Y()-3 ), 320*cdf0e10cSrcweir Point( aEndPos.X()-1, aEndPos.Y()+3 ) ); 321*cdf0e10cSrcweir DrawLine( Point( aEndPos.X()-2, aEndPos.Y()-2 ), 322*cdf0e10cSrcweir Point( aEndPos.X()-2, aEndPos.Y()+2 ) ); 323*cdf0e10cSrcweir DrawLine( Point( aEndPos.X()-3, aEndPos.Y()-1 ), 324*cdf0e10cSrcweir Point( aEndPos.X()-3, aEndPos.Y()+1 ) ); 325*cdf0e10cSrcweir DrawPixel( Point( aEndPos.X()-4, aEndPos.Y() ) ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir SetRasterOp( ROP_OVERPAINT ); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir // ----------------------------------------------------------------------- 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir void HeaderBar::ImplDrawItem( OutputDevice* pDev, 333*cdf0e10cSrcweir sal_uInt16 nPos, sal_Bool bHigh, sal_Bool bDrag, 334*cdf0e10cSrcweir const Rectangle& rItemRect, 335*cdf0e10cSrcweir const Rectangle* pRect, 336*cdf0e10cSrcweir sal_uLong ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir Rectangle aRect = rItemRect; 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir // Wenn kein Platz, dann brauchen wir auch nichts ausgeben 341*cdf0e10cSrcweir if ( aRect.GetWidth() <= 1 ) 342*cdf0e10cSrcweir return; 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir // Feststellen, ob Rectangle ueberhaupt sichtbar 345*cdf0e10cSrcweir if ( pRect ) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir if ( aRect.Right() < pRect->Left() ) 348*cdf0e10cSrcweir return; 349*cdf0e10cSrcweir else if ( aRect.Left() > pRect->Right() ) 350*cdf0e10cSrcweir return; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir else 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir if ( aRect.Right() < 0 ) 355*cdf0e10cSrcweir return; 356*cdf0e10cSrcweir else if ( aRect.Left() > mnDX ) 357*cdf0e10cSrcweir return; 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( nPos ); 361*cdf0e10cSrcweir HeaderBarItemBits nBits = pItem->mnBits; 362*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir // Border muss nicht gemalt werden 365*cdf0e10cSrcweir aRect.Top() += mnBorderOff1; 366*cdf0e10cSrcweir aRect.Bottom() -= mnBorderOff2; 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir // Hintergrund loeschen 369*cdf0e10cSrcweir if ( !pRect || bDrag ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir if ( bDrag ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir pDev->SetLineColor(); 374*cdf0e10cSrcweir pDev->SetFillColor( rStyleSettings.GetCheckedColor() ); 375*cdf0e10cSrcweir pDev->DrawRect( aRect ); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir else 378*cdf0e10cSrcweir pDev->DrawWallpaper( aRect, GetBackground() ); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir // Trennlinie malen 382*cdf0e10cSrcweir pDev->SetLineColor( rStyleSettings.GetDarkShadowColor() ); 383*cdf0e10cSrcweir pDev->DrawLine( Point( aRect.Right(), aRect.Top() ), 384*cdf0e10cSrcweir Point( aRect.Right(), aRect.Bottom() ) ); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // ButtonStyle malen 387*cdf0e10cSrcweir // avoid 3D borders 388*cdf0e10cSrcweir Color aSelectionTextColor( COL_TRANSPARENT ); 389*cdf0e10cSrcweir if( bHigh ) 390*cdf0e10cSrcweir DrawSelectionBackground( aRect, 1, sal_True, sal_False, sal_False, &aSelectionTextColor ); 391*cdf0e10cSrcweir else if ( !mbButtonStyle || (nBits & HIB_FLAT) ) 392*cdf0e10cSrcweir DrawSelectionBackground( aRect, 0, sal_True, sal_False, sal_False, &aSelectionTextColor ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir // Wenn kein Platz, dann brauchen wir auch nichts ausgeben 395*cdf0e10cSrcweir if ( aRect.GetWidth() < 1 ) 396*cdf0e10cSrcweir return; 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir // Positionen und Groessen berechnen und Inhalt ausgeben 399*cdf0e10cSrcweir pItem->maOutText = pItem->maText; 400*cdf0e10cSrcweir Size aImageSize = pItem->maImage.GetSizePixel(); 401*cdf0e10cSrcweir Size aTxtSize( pDev->GetTextWidth( pItem->maOutText ), 0 ); 402*cdf0e10cSrcweir if ( pItem->maOutText.Len() ) 403*cdf0e10cSrcweir aTxtSize.Height() = pDev->GetTextHeight(); 404*cdf0e10cSrcweir long nArrowWidth = 0; 405*cdf0e10cSrcweir if ( nBits & (HIB_UPARROW | HIB_DOWNARROW) ) 406*cdf0e10cSrcweir nArrowWidth = HEAD_ARROWSIZE2+HEADERBAR_ARROWOFF; 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir // Wenn kein Platz fuer Image, dann nicht ausgeben 409*cdf0e10cSrcweir long nTestHeight = aImageSize.Height(); 410*cdf0e10cSrcweir if ( !(nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE)) ) 411*cdf0e10cSrcweir nTestHeight += aTxtSize.Height(); 412*cdf0e10cSrcweir if ( (aImageSize.Width() > aRect.GetWidth()) || (nTestHeight > aRect.GetHeight()) ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir aImageSize.Width() = 0; 415*cdf0e10cSrcweir aImageSize.Height() = 0; 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir // Text auf entsprechende Laenge kuerzen 419*cdf0e10cSrcweir sal_Bool bLeftText = sal_False; 420*cdf0e10cSrcweir long nMaxTxtWidth = aRect.GetWidth()-(HEADERBAR_TEXTOFF*2)-nArrowWidth; 421*cdf0e10cSrcweir if ( nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE) ) 422*cdf0e10cSrcweir nMaxTxtWidth -= aImageSize.Width(); 423*cdf0e10cSrcweir long nTxtWidth = aTxtSize.Width(); 424*cdf0e10cSrcweir if ( nTxtWidth > nMaxTxtWidth ) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir bLeftText = sal_True; 427*cdf0e10cSrcweir // 3 == Len of "..." 428*cdf0e10cSrcweir pItem->maOutText.AppendAscii( "..." ); 429*cdf0e10cSrcweir do 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir pItem->maOutText.Erase( pItem->maOutText.Len()-3-1, 1 ); 432*cdf0e10cSrcweir nTxtWidth = pDev->GetTextWidth( pItem->maOutText ); 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir while ( (nTxtWidth > nMaxTxtWidth) && (pItem->maOutText.Len() > 3) ); 435*cdf0e10cSrcweir if ( pItem->maOutText.Len() == 3 ) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir nTxtWidth = 0; 438*cdf0e10cSrcweir pItem->maOutText.Erase(); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir // Text/Imageposition berechnen 443*cdf0e10cSrcweir long nTxtPos; 444*cdf0e10cSrcweir if ( !bLeftText && (nBits & HIB_RIGHT) ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir nTxtPos = aRect.Right()-nTxtWidth-HEADERBAR_TEXTOFF; 447*cdf0e10cSrcweir if ( nBits & HIB_RIGHTIMAGE ) 448*cdf0e10cSrcweir nTxtPos -= aImageSize.Width(); 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir else if ( !bLeftText && (nBits & HIB_CENTER) ) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir long nTempWidth = nTxtWidth; 453*cdf0e10cSrcweir if ( nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE) ) 454*cdf0e10cSrcweir nTempWidth += aImageSize.Width(); 455*cdf0e10cSrcweir nTxtPos = aRect.Left()+(aRect.GetWidth()-nTempWidth)/2; 456*cdf0e10cSrcweir if ( nBits & HIB_LEFTIMAGE ) 457*cdf0e10cSrcweir nTxtPos += aImageSize.Width(); 458*cdf0e10cSrcweir if ( nArrowWidth ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir if ( nTxtPos+nTxtWidth+nArrowWidth >= aRect.Right() ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir nTxtPos = aRect.Left()+HEADERBAR_TEXTOFF; 463*cdf0e10cSrcweir if ( nBits & HIB_LEFTIMAGE ) 464*cdf0e10cSrcweir nTxtPos += aImageSize.Width(); 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir else 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir nTxtPos = aRect.Left()+HEADERBAR_TEXTOFF; 471*cdf0e10cSrcweir if ( nBits & HIB_LEFTIMAGE ) 472*cdf0e10cSrcweir nTxtPos += aImageSize.Width(); 473*cdf0e10cSrcweir if ( nBits & HIB_RIGHT ) 474*cdf0e10cSrcweir nTxtPos += nArrowWidth; 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir // TextPosition berechnen 478*cdf0e10cSrcweir long nTxtPosY = 0; 479*cdf0e10cSrcweir if ( pItem->maOutText.Len() || (nArrowWidth && aTxtSize.Height()) ) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir if ( nBits & HIB_TOP ) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir nTxtPosY = aRect.Top(); 484*cdf0e10cSrcweir if ( !(nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE)) ) 485*cdf0e10cSrcweir nTxtPosY += aImageSize.Height(); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir else if ( nBits & HIB_BOTTOM ) 488*cdf0e10cSrcweir nTxtPosY = aRect.Bottom()-aTxtSize.Height(); 489*cdf0e10cSrcweir else 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir long nTempHeight = aTxtSize.Height(); 492*cdf0e10cSrcweir if ( !(nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE)) ) 493*cdf0e10cSrcweir nTempHeight += aImageSize.Height(); 494*cdf0e10cSrcweir nTxtPosY = aRect.Top()+((aRect.GetHeight()-nTempHeight)/2); 495*cdf0e10cSrcweir if ( !(nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE)) ) 496*cdf0e10cSrcweir nTxtPosY += aImageSize.Height(); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir // Text ausgebeben 501*cdf0e10cSrcweir if ( pItem->maOutText.Len() ) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir if( aSelectionTextColor != Color( COL_TRANSPARENT ) ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir pDev->Push( PUSH_TEXTCOLOR ); 506*cdf0e10cSrcweir pDev->SetTextColor( aSelectionTextColor ); 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir if ( IsEnabled() ) 509*cdf0e10cSrcweir pDev->DrawText( Point( nTxtPos, nTxtPosY ), pItem->maOutText ); 510*cdf0e10cSrcweir else 511*cdf0e10cSrcweir pDev->DrawCtrlText( Point( nTxtPos, nTxtPosY ), pItem->maOutText, 0, STRING_LEN, TEXT_DRAW_DISABLE ); 512*cdf0e10cSrcweir if( aSelectionTextColor != Color( COL_TRANSPARENT ) ) 513*cdf0e10cSrcweir pDev->Pop(); 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir // Wenn Image vorhanden, Position berechnen und ausgeben 517*cdf0e10cSrcweir long nImagePosY = 0; 518*cdf0e10cSrcweir if ( aImageSize.Width() && aImageSize.Height() ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir long nImagePos = nTxtPos; 521*cdf0e10cSrcweir if ( nBits & HIB_LEFTIMAGE ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir nImagePos -= aImageSize.Width(); 524*cdf0e10cSrcweir if ( nBits & HIB_RIGHT ) 525*cdf0e10cSrcweir nImagePos -= nArrowWidth; 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir else if ( nBits & HIB_RIGHTIMAGE ) 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir nImagePos += nTxtWidth; 530*cdf0e10cSrcweir if ( !(nBits & HIB_RIGHT) ) 531*cdf0e10cSrcweir nImagePos += nArrowWidth; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir else 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir if ( nBits & HIB_RIGHT ) 536*cdf0e10cSrcweir nImagePos = aRect.Right()-aImageSize.Width(); 537*cdf0e10cSrcweir else if ( nBits & HIB_CENTER ) 538*cdf0e10cSrcweir nImagePos = aRect.Left()+(aRect.GetWidth()-aImageSize.Width())/2; 539*cdf0e10cSrcweir else 540*cdf0e10cSrcweir nImagePos = aRect.Left()+HEADERBAR_TEXTOFF; 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir if ( nBits & HIB_TOP ) 544*cdf0e10cSrcweir nImagePosY = aRect.Top(); 545*cdf0e10cSrcweir else if ( nBits & HIB_BOTTOM ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir nImagePosY = aRect.Bottom()-aImageSize.Height(); 548*cdf0e10cSrcweir if ( !(nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE)) ) 549*cdf0e10cSrcweir nImagePosY -= aTxtSize.Height(); 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir else 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir long nTempHeight = aImageSize.Height(); 554*cdf0e10cSrcweir if ( !(nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE)) ) 555*cdf0e10cSrcweir nTempHeight += aTxtSize.Height(); 556*cdf0e10cSrcweir nImagePosY = aRect.Top()+((aRect.GetHeight()-nTempHeight)/2); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir if ( nImagePos+aImageSize.Width() <= aRect.Right() ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir sal_uInt16 nStyle = 0; 561*cdf0e10cSrcweir if ( !IsEnabled() ) 562*cdf0e10cSrcweir nStyle |= IMAGE_DRAW_DISABLE; 563*cdf0e10cSrcweir pDev->DrawImage( Point( nImagePos, nImagePosY ), pItem->maImage, nStyle ); 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir if ( nBits & (HIB_UPARROW | HIB_DOWNARROW) ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir long nArrowX = nTxtPos; 570*cdf0e10cSrcweir if ( nBits & HIB_RIGHT ) 571*cdf0e10cSrcweir nArrowX -= nArrowWidth; 572*cdf0e10cSrcweir else 573*cdf0e10cSrcweir nArrowX += nTxtWidth+HEADERBAR_ARROWOFF; 574*cdf0e10cSrcweir if ( !(nBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE)) && !pItem->maText.Len() ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir if ( nBits & HIB_RIGHT ) 577*cdf0e10cSrcweir nArrowX -= aImageSize.Width(); 578*cdf0e10cSrcweir else 579*cdf0e10cSrcweir nArrowX += aImageSize.Width(); 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir // Feststellen, ob Platz genug ist, das Item zu malen 583*cdf0e10cSrcweir sal_Bool bDraw = sal_True; 584*cdf0e10cSrcweir if ( nArrowX < aRect.Left()+HEADERBAR_TEXTOFF ) 585*cdf0e10cSrcweir bDraw = sal_False; 586*cdf0e10cSrcweir else if ( nArrowX+HEAD_ARROWSIZE2 > aRect.Right() ) 587*cdf0e10cSrcweir bDraw = sal_False; 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir if ( bDraw ) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir long nArrowY; 592*cdf0e10cSrcweir if ( aTxtSize.Height() ) 593*cdf0e10cSrcweir nArrowY = nTxtPosY+(aTxtSize.Height()/2); 594*cdf0e10cSrcweir else if ( aImageSize.Width() && aImageSize.Height() ) 595*cdf0e10cSrcweir nArrowY = nImagePosY+(aImageSize.Height()/2); 596*cdf0e10cSrcweir else 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir if ( nBits & HIB_TOP ) 599*cdf0e10cSrcweir nArrowY = aRect.Top()+1; 600*cdf0e10cSrcweir else if ( nBits & HIB_BOTTOM ) 601*cdf0e10cSrcweir nArrowY = aRect.Bottom()-HEAD_ARROWSIZE2-1; 602*cdf0e10cSrcweir else 603*cdf0e10cSrcweir nArrowY = aRect.Top()+((aRect.GetHeight()-HEAD_ARROWSIZE2)/2);; 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir nArrowY -= HEAD_ARROWSIZE1-1; 606*cdf0e10cSrcweir if ( nBits & HIB_DOWNARROW ) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir pDev->SetLineColor( rStyleSettings.GetLightColor() ); 609*cdf0e10cSrcweir pDev->DrawLine( Point( nArrowX, nArrowY ), 610*cdf0e10cSrcweir Point( nArrowX+HEAD_ARROWSIZE2, nArrowY ) ); 611*cdf0e10cSrcweir pDev->DrawLine( Point( nArrowX, nArrowY ), 612*cdf0e10cSrcweir Point( nArrowX+HEAD_ARROWSIZE1, nArrowY+HEAD_ARROWSIZE2 ) ); 613*cdf0e10cSrcweir pDev->SetLineColor( rStyleSettings.GetShadowColor() ); 614*cdf0e10cSrcweir pDev->DrawLine( Point( nArrowX+HEAD_ARROWSIZE1, nArrowY+HEAD_ARROWSIZE2 ), 615*cdf0e10cSrcweir Point( nArrowX+HEAD_ARROWSIZE2, nArrowY ) ); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir else 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir pDev->SetLineColor( rStyleSettings.GetLightColor() ); 620*cdf0e10cSrcweir pDev->DrawLine( Point( nArrowX, nArrowY+HEAD_ARROWSIZE2 ), 621*cdf0e10cSrcweir Point( nArrowX+HEAD_ARROWSIZE1, nArrowY ) ); 622*cdf0e10cSrcweir pDev->SetLineColor( rStyleSettings.GetShadowColor() ); 623*cdf0e10cSrcweir pDev->DrawLine( Point( nArrowX, nArrowY+HEAD_ARROWSIZE2 ), 624*cdf0e10cSrcweir Point( nArrowX+HEAD_ARROWSIZE2, nArrowY+HEAD_ARROWSIZE2 ) ); 625*cdf0e10cSrcweir pDev->DrawLine( Point( nArrowX+HEAD_ARROWSIZE2, nArrowY+HEAD_ARROWSIZE2 ), 626*cdf0e10cSrcweir Point( nArrowX+HEAD_ARROWSIZE1, nArrowY ) ); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir // Gegebenenfalls auch UserDraw aufrufen 632*cdf0e10cSrcweir if ( nBits & HIB_USERDRAW ) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir Region aRegion( aRect ); 635*cdf0e10cSrcweir if ( pRect ) 636*cdf0e10cSrcweir aRegion.Intersect( *pRect ); 637*cdf0e10cSrcweir pDev->SetClipRegion( aRegion ); 638*cdf0e10cSrcweir UserDrawEvent aODEvt( pDev, aRect, pItem->mnId ); 639*cdf0e10cSrcweir UserDraw( aODEvt ); 640*cdf0e10cSrcweir pDev->SetClipRegion(); 641*cdf0e10cSrcweir } 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir // ----------------------------------------------------------------------- 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir void HeaderBar::ImplDrawItem( sal_uInt16 nPos, sal_Bool bHigh, sal_Bool bDrag, 647*cdf0e10cSrcweir const Rectangle* pRect ) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir Rectangle aRect = ImplGetItemRect( nPos ); 650*cdf0e10cSrcweir ImplDrawItem( this, nPos, bHigh, bDrag, aRect, pRect, 0 ); 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir // ----------------------------------------------------------------------- 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir void HeaderBar::ImplUpdate( sal_uInt16 nPos, sal_Bool bEnd, sal_Bool bDirect ) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir if ( IsVisible() && IsUpdateMode() ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir if ( !bDirect ) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir Rectangle aRect; 662*cdf0e10cSrcweir sal_uInt16 nItemCount = (sal_uInt16)(mpItemList->Count()); 663*cdf0e10cSrcweir if ( nPos < nItemCount ) 664*cdf0e10cSrcweir aRect = ImplGetItemRect( nPos ); 665*cdf0e10cSrcweir else 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir aRect.Bottom() = mnDY-1; 668*cdf0e10cSrcweir if ( nItemCount ) 669*cdf0e10cSrcweir aRect.Left() = ImplGetItemRect( nItemCount-1 ).Right(); 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir if ( bEnd ) 672*cdf0e10cSrcweir aRect.Right() = mnDX-1; 673*cdf0e10cSrcweir aRect.Top() += mnBorderOff1; 674*cdf0e10cSrcweir aRect.Bottom() -= mnBorderOff2; 675*cdf0e10cSrcweir Invalidate( aRect ); 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir else 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir for ( sal_uInt16 i = nPos; i < mpItemList->Count(); i++ ) 680*cdf0e10cSrcweir ImplDrawItem( i ); 681*cdf0e10cSrcweir if ( bEnd ) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir Rectangle aRect = ImplGetItemRect( (sal_uInt16)mpItemList->Count() ); 684*cdf0e10cSrcweir aRect.Left() = aRect.Right(); 685*cdf0e10cSrcweir aRect.Right() = mnDX-1; 686*cdf0e10cSrcweir if ( aRect.Left() < aRect.Right() ) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir aRect.Top() += mnBorderOff1; 689*cdf0e10cSrcweir aRect.Bottom() -= mnBorderOff2; 690*cdf0e10cSrcweir Erase( aRect ); 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir // ----------------------------------------------------------------------- 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir void HeaderBar::ImplStartDrag( const Point& rMousePos, sal_Bool bCommand ) 700*cdf0e10cSrcweir { 701*cdf0e10cSrcweir sal_uInt16 nPos; 702*cdf0e10cSrcweir sal_uInt16 nHitTest = ImplHitTest( rMousePos, mnMouseOff, nPos ); 703*cdf0e10cSrcweir if ( nHitTest ) 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir mbDrag = sal_False; 706*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( nPos ); 707*cdf0e10cSrcweir if ( nHitTest & HEAD_HITTEST_DIVIDER ) 708*cdf0e10cSrcweir mbDrag = sal_True; 709*cdf0e10cSrcweir else 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir if ( ((pItem->mnBits & HIB_CLICKABLE) && !(pItem->mnBits & HIB_FLAT)) || 712*cdf0e10cSrcweir (mbDragable && !(pItem->mnBits & HIB_FIXEDPOS)) ) 713*cdf0e10cSrcweir { 714*cdf0e10cSrcweir mbItemMode = sal_True; 715*cdf0e10cSrcweir mbDrag = sal_True; 716*cdf0e10cSrcweir if ( bCommand ) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir if ( mbDragable ) 719*cdf0e10cSrcweir mbItemDrag = sal_True; 720*cdf0e10cSrcweir else 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir mbItemMode = sal_False; 723*cdf0e10cSrcweir mbDrag = sal_False; 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir else 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir if ( !bCommand ) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir mnCurItemId = pItem->mnId; 732*cdf0e10cSrcweir Select(); 733*cdf0e10cSrcweir mnCurItemId = 0; 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir if ( mbDrag ) 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir mbOutDrag = sal_False; 741*cdf0e10cSrcweir mnCurItemId = pItem->mnId; 742*cdf0e10cSrcweir mnItemDragPos = nPos; 743*cdf0e10cSrcweir StartTracking(); 744*cdf0e10cSrcweir mnStartPos = rMousePos.X()-mnMouseOff; 745*cdf0e10cSrcweir mnDragPos = mnStartPos; 746*cdf0e10cSrcweir StartDrag(); 747*cdf0e10cSrcweir if ( mbItemMode ) 748*cdf0e10cSrcweir ImplDrawItem( nPos, sal_True, mbItemDrag ); 749*cdf0e10cSrcweir else 750*cdf0e10cSrcweir { 751*cdf0e10cSrcweir Rectangle aSizeRect( mnDragPos, 0, mnDragPos, mnDragSize+mnDY ); 752*cdf0e10cSrcweir ShowTracking( aSizeRect, SHOWTRACK_SPLIT ); 753*cdf0e10cSrcweir } 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir else 756*cdf0e10cSrcweir mnMouseOff = 0; 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir // ----------------------------------------------------------------------- 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir void HeaderBar::ImplDrag( const Point& rMousePos ) 763*cdf0e10cSrcweir { 764*cdf0e10cSrcweir sal_Bool bNewOutDrag; 765*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( mnCurItemId ); 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir mnDragPos = rMousePos.X()-mnMouseOff; 768*cdf0e10cSrcweir if ( mbItemMode ) 769*cdf0e10cSrcweir { 770*cdf0e10cSrcweir Rectangle aItemRect = ImplGetItemRect( nPos ); 771*cdf0e10cSrcweir if ( aItemRect.IsInside( rMousePos ) ) 772*cdf0e10cSrcweir bNewOutDrag = sal_False; 773*cdf0e10cSrcweir else 774*cdf0e10cSrcweir bNewOutDrag = sal_True; 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir // Evt. ItemDrag anschalten 777*cdf0e10cSrcweir if ( bNewOutDrag && mbDragable && !mbItemDrag && 778*cdf0e10cSrcweir !(mpItemList->GetObject(nPos)->mnBits & HIB_FIXEDPOS) ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir if ( (rMousePos.Y() >= aItemRect.Top()) && (rMousePos.Y() <= aItemRect.Bottom()) ) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir mbItemDrag = sal_True; 783*cdf0e10cSrcweir ImplDrawItem( nPos, sal_True, mbItemDrag ); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir sal_uInt16 nOldItemDragPos = mnItemDragPos; 788*cdf0e10cSrcweir if ( mbItemDrag ) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir if ( (rMousePos.Y() < -HEADERBAR_DRAGOUTOFF) || (rMousePos.Y() > mnDY+HEADERBAR_DRAGOUTOFF) ) 791*cdf0e10cSrcweir bNewOutDrag = sal_True; 792*cdf0e10cSrcweir else 793*cdf0e10cSrcweir bNewOutDrag = sal_False; 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir if ( bNewOutDrag ) 796*cdf0e10cSrcweir mnItemDragPos = HEADERBAR_ITEM_NOTFOUND; 797*cdf0e10cSrcweir else 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir sal_uInt16 nTempId = GetItemId( Point( rMousePos.X(), 2 ) ); 800*cdf0e10cSrcweir if ( nTempId ) 801*cdf0e10cSrcweir mnItemDragPos = GetItemPos( nTempId ); 802*cdf0e10cSrcweir else 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir if ( rMousePos.X() <= 0 ) 805*cdf0e10cSrcweir mnItemDragPos = 0; 806*cdf0e10cSrcweir else 807*cdf0e10cSrcweir mnItemDragPos = GetItemCount()-1; 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir // Nicht verschiebbare Items aussparen 811*cdf0e10cSrcweir if ( mnItemDragPos < nPos ) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir while ( (mpItemList->GetObject(mnItemDragPos)->mnBits & HIB_FIXEDPOS) && 814*cdf0e10cSrcweir (mnItemDragPos < nPos) ) 815*cdf0e10cSrcweir mnItemDragPos++; 816*cdf0e10cSrcweir } 817*cdf0e10cSrcweir else if ( mnItemDragPos > nPos ) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir while ( (mpItemList->GetObject(mnItemDragPos)->mnBits & HIB_FIXEDPOS) && 820*cdf0e10cSrcweir (mnItemDragPos > nPos) ) 821*cdf0e10cSrcweir mnItemDragPos--; 822*cdf0e10cSrcweir } 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir if ( (mnItemDragPos != nOldItemDragPos) && 826*cdf0e10cSrcweir (nOldItemDragPos != nPos) && 827*cdf0e10cSrcweir (nOldItemDragPos != HEADERBAR_ITEM_NOTFOUND) ) 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir ImplInvertDrag( nPos, nOldItemDragPos ); 830*cdf0e10cSrcweir ImplDrawItem( nOldItemDragPos ); 831*cdf0e10cSrcweir } 832*cdf0e10cSrcweir } 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir if ( bNewOutDrag != mbOutDrag ) 835*cdf0e10cSrcweir ImplDrawItem( nPos, !bNewOutDrag, mbItemDrag ); 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir if ( mbItemDrag ) 838*cdf0e10cSrcweir { 839*cdf0e10cSrcweir if ( (mnItemDragPos != nOldItemDragPos) && 840*cdf0e10cSrcweir (mnItemDragPos != nPos) && 841*cdf0e10cSrcweir (mnItemDragPos != HEADERBAR_ITEM_NOTFOUND) ) 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir ImplDrawItem( mnItemDragPos, sal_False, sal_True ); 844*cdf0e10cSrcweir ImplInvertDrag( nPos, mnItemDragPos ); 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir mbOutDrag = bNewOutDrag; 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir else 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir Rectangle aItemRect = ImplGetItemRect( nPos ); 853*cdf0e10cSrcweir if ( mnDragPos < aItemRect.Left() ) 854*cdf0e10cSrcweir mnDragPos = aItemRect.Left(); 855*cdf0e10cSrcweir if ( (mnDragPos < 0) || (mnDragPos > mnDX-1) ) 856*cdf0e10cSrcweir HideTracking(); 857*cdf0e10cSrcweir else 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir Rectangle aSizeRect( mnDragPos, 0, mnDragPos, mnDragSize+mnDY ); 860*cdf0e10cSrcweir ShowTracking( aSizeRect, SHOWTRACK_SPLIT ); 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir Drag(); 865*cdf0e10cSrcweir } 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir // ----------------------------------------------------------------------- 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir void HeaderBar::ImplEndDrag( sal_Bool bCancel ) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir HideTracking(); 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir if ( bCancel || mbOutDrag ) 874*cdf0e10cSrcweir { 875*cdf0e10cSrcweir if ( mbItemMode && (!mbOutDrag || mbItemDrag) ) 876*cdf0e10cSrcweir { 877*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( mnCurItemId ); 878*cdf0e10cSrcweir ImplDrawItem( nPos ); 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir mnCurItemId = 0; 882*cdf0e10cSrcweir } 883*cdf0e10cSrcweir else 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( mnCurItemId ); 886*cdf0e10cSrcweir if ( mbItemMode ) 887*cdf0e10cSrcweir { 888*cdf0e10cSrcweir if ( mbItemDrag ) 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir Pointer aPointer( POINTER_ARROW ); 891*cdf0e10cSrcweir SetPointer( aPointer ); 892*cdf0e10cSrcweir if ( (mnItemDragPos != nPos) && 893*cdf0e10cSrcweir (mnItemDragPos != HEADERBAR_ITEM_NOTFOUND) ) 894*cdf0e10cSrcweir { 895*cdf0e10cSrcweir ImplInvertDrag( nPos, mnItemDragPos ); 896*cdf0e10cSrcweir MoveItem( mnCurItemId, mnItemDragPos ); 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir else 899*cdf0e10cSrcweir ImplDrawItem( nPos ); 900*cdf0e10cSrcweir } 901*cdf0e10cSrcweir else 902*cdf0e10cSrcweir { 903*cdf0e10cSrcweir Select(); 904*cdf0e10cSrcweir ImplUpdate( nPos ); 905*cdf0e10cSrcweir } 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir else 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir long nDelta = mnDragPos - mnStartPos; 910*cdf0e10cSrcweir if ( nDelta ) 911*cdf0e10cSrcweir { 912*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( nPos ); 913*cdf0e10cSrcweir pItem->mnSize += nDelta; 914*cdf0e10cSrcweir ImplUpdate( nPos, sal_True ); 915*cdf0e10cSrcweir } 916*cdf0e10cSrcweir } 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir 919*cdf0e10cSrcweir mbDrag = sal_False; 920*cdf0e10cSrcweir EndDrag(); 921*cdf0e10cSrcweir mnCurItemId = 0; 922*cdf0e10cSrcweir mnItemDragPos = HEADERBAR_ITEM_NOTFOUND; 923*cdf0e10cSrcweir mbOutDrag = sal_False; 924*cdf0e10cSrcweir mbItemMode = sal_False; 925*cdf0e10cSrcweir mbItemDrag = sal_False; 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir // ----------------------------------------------------------------------- 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir void HeaderBar::MouseButtonDown( const MouseEvent& rMEvt ) 931*cdf0e10cSrcweir { 932*cdf0e10cSrcweir if ( rMEvt.IsLeft() ) 933*cdf0e10cSrcweir { 934*cdf0e10cSrcweir if ( rMEvt.GetClicks() == 2 ) 935*cdf0e10cSrcweir { 936*cdf0e10cSrcweir long nTemp; 937*cdf0e10cSrcweir sal_uInt16 nPos; 938*cdf0e10cSrcweir sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), nTemp, nPos ); 939*cdf0e10cSrcweir if ( nHitTest ) 940*cdf0e10cSrcweir { 941*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( nPos ); 942*cdf0e10cSrcweir if ( nHitTest & HEAD_HITTEST_DIVIDER ) 943*cdf0e10cSrcweir mbItemMode = sal_False; 944*cdf0e10cSrcweir else 945*cdf0e10cSrcweir mbItemMode = sal_True; 946*cdf0e10cSrcweir mnCurItemId = pItem->mnId; 947*cdf0e10cSrcweir DoubleClick(); 948*cdf0e10cSrcweir mbItemMode = sal_False; 949*cdf0e10cSrcweir mnCurItemId = 0; 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir } 952*cdf0e10cSrcweir else 953*cdf0e10cSrcweir ImplStartDrag( rMEvt.GetPosPixel(), sal_False ); 954*cdf0e10cSrcweir } 955*cdf0e10cSrcweir } 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir // ----------------------------------------------------------------------- 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir void HeaderBar::MouseMove( const MouseEvent& rMEvt ) 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir long nTemp1; 962*cdf0e10cSrcweir sal_uInt16 nTemp2; 963*cdf0e10cSrcweir PointerStyle eStyle = POINTER_ARROW; 964*cdf0e10cSrcweir sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), nTemp1, nTemp2 ); 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir if ( nHitTest & HEAD_HITTEST_DIVIDER ) 967*cdf0e10cSrcweir eStyle = POINTER_HSIZEBAR; 968*cdf0e10cSrcweir Pointer aPtr( eStyle ); 969*cdf0e10cSrcweir SetPointer( aPtr ); 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir // ----------------------------------------------------------------------- 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir void HeaderBar::Tracking( const TrackingEvent& rTEvt ) 975*cdf0e10cSrcweir { 976*cdf0e10cSrcweir Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel(); 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir if ( rTEvt.IsTrackingEnded() ) 979*cdf0e10cSrcweir ImplEndDrag( rTEvt.IsTrackingCanceled() ); 980*cdf0e10cSrcweir else 981*cdf0e10cSrcweir ImplDrag( aMousePos ); 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir // ----------------------------------------------------------------------- 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir void HeaderBar::Paint( const Rectangle& rRect ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir if ( mnBorderOff1 || mnBorderOff2 ) 989*cdf0e10cSrcweir { 990*cdf0e10cSrcweir SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() ); 991*cdf0e10cSrcweir if ( mnBorderOff1 ) 992*cdf0e10cSrcweir DrawLine( Point( 0, 0 ), Point( mnDX-1, 0 ) ); 993*cdf0e10cSrcweir if ( mnBorderOff2 ) 994*cdf0e10cSrcweir DrawLine( Point( 0, mnDY-1 ), Point( mnDX-1, mnDY-1 ) ); 995*cdf0e10cSrcweir // #i40393# draw left and right border, if WB_BORDER was set in ImplInit() 996*cdf0e10cSrcweir if ( mnBorderOff1 && mnBorderOff2 ) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir DrawLine( Point( 0, 0 ), Point( 0, mnDY-1 ) ); 999*cdf0e10cSrcweir DrawLine( Point( mnDX-1, 0 ), Point( mnDX-1, mnDY-1 ) ); 1000*cdf0e10cSrcweir } 1001*cdf0e10cSrcweir } 1002*cdf0e10cSrcweir 1003*cdf0e10cSrcweir sal_uInt16 nCurItemPos; 1004*cdf0e10cSrcweir if ( mbDrag ) 1005*cdf0e10cSrcweir nCurItemPos = GetItemPos( mnCurItemId ); 1006*cdf0e10cSrcweir else 1007*cdf0e10cSrcweir nCurItemPos = HEADERBAR_ITEM_NOTFOUND; 1008*cdf0e10cSrcweir sal_uInt16 nItemCount = (sal_uInt16)mpItemList->Count(); 1009*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nItemCount; i++ ) 1010*cdf0e10cSrcweir ImplDrawItem( i, (i == nCurItemPos) ? sal_True : sal_False, sal_False, &rRect ); 1011*cdf0e10cSrcweir } 1012*cdf0e10cSrcweir 1013*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir void HeaderBar::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, 1016*cdf0e10cSrcweir sal_uLong nFlags ) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir Point aPos = pDev->LogicToPixel( rPos ); 1019*cdf0e10cSrcweir Size aSize = pDev->LogicToPixel( rSize ); 1020*cdf0e10cSrcweir Rectangle aRect( aPos, aSize ); 1021*cdf0e10cSrcweir Font aFont = GetDrawPixelFont( pDev ); 1022*cdf0e10cSrcweir 1023*cdf0e10cSrcweir pDev->Push(); 1024*cdf0e10cSrcweir pDev->SetMapMode(); 1025*cdf0e10cSrcweir pDev->SetFont( aFont ); 1026*cdf0e10cSrcweir if ( nFlags & WINDOW_DRAW_MONO ) 1027*cdf0e10cSrcweir pDev->SetTextColor( Color( COL_BLACK ) ); 1028*cdf0e10cSrcweir else 1029*cdf0e10cSrcweir pDev->SetTextColor( GetTextColor() ); 1030*cdf0e10cSrcweir pDev->SetTextFillColor(); 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir if ( !(nFlags & WINDOW_DRAW_NOBACKGROUND) ) 1033*cdf0e10cSrcweir { 1034*cdf0e10cSrcweir pDev->DrawWallpaper( aRect, GetBackground() ); 1035*cdf0e10cSrcweir if ( mnBorderOff1 || mnBorderOff2 ) 1036*cdf0e10cSrcweir { 1037*cdf0e10cSrcweir pDev->SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() ); 1038*cdf0e10cSrcweir if ( mnBorderOff1 ) 1039*cdf0e10cSrcweir pDev->DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) ); 1040*cdf0e10cSrcweir if ( mnBorderOff2 ) 1041*cdf0e10cSrcweir pDev->DrawLine( Point( aRect.Left(), aRect.Bottom() ), Point( aRect.Right(), aRect.Bottom() ) ); 1042*cdf0e10cSrcweir // #i40393# draw left and right border, if WB_BORDER was set in ImplInit() 1043*cdf0e10cSrcweir if ( mnBorderOff1 && mnBorderOff2 ) 1044*cdf0e10cSrcweir { 1045*cdf0e10cSrcweir pDev->DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() ) ); 1046*cdf0e10cSrcweir pDev->DrawLine( Point( aRect.Right(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) ); 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir } 1049*cdf0e10cSrcweir } 1050*cdf0e10cSrcweir 1051*cdf0e10cSrcweir Rectangle aItemRect( aRect ); 1052*cdf0e10cSrcweir // aItemRect.Bottom()--; 1053*cdf0e10cSrcweir sal_uInt16 nItemCount = (sal_uInt16)mpItemList->Count(); 1054*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nItemCount; i++ ) 1055*cdf0e10cSrcweir { 1056*cdf0e10cSrcweir aItemRect.Left() = aRect.Left()+ImplGetItemPos( i ); 1057*cdf0e10cSrcweir aItemRect.Right() = aItemRect.Left() + mpItemList->GetObject( i )->mnSize - 1; 1058*cdf0e10cSrcweir // Gegen Ueberlauf auf einigen Systemen testen 1059*cdf0e10cSrcweir if ( aItemRect.Right() > 16000 ) 1060*cdf0e10cSrcweir aItemRect.Right() = 16000; 1061*cdf0e10cSrcweir Region aRegion( aRect ); 1062*cdf0e10cSrcweir pDev->SetClipRegion( aRegion ); 1063*cdf0e10cSrcweir ImplDrawItem( pDev, i, sal_False, sal_False, aItemRect, &aRect, nFlags ); 1064*cdf0e10cSrcweir pDev->SetClipRegion(); 1065*cdf0e10cSrcweir } 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir pDev->Pop(); 1068*cdf0e10cSrcweir } 1069*cdf0e10cSrcweir 1070*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1071*cdf0e10cSrcweir 1072*cdf0e10cSrcweir void HeaderBar::Resize() 1073*cdf0e10cSrcweir { 1074*cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 1075*cdf0e10cSrcweir if ( IsVisible() && (mnDY != aSize.Height()) ) 1076*cdf0e10cSrcweir Invalidate(); 1077*cdf0e10cSrcweir mnDX = aSize.Width(); 1078*cdf0e10cSrcweir mnDY = aSize.Height(); 1079*cdf0e10cSrcweir } 1080*cdf0e10cSrcweir 1081*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1082*cdf0e10cSrcweir 1083*cdf0e10cSrcweir void HeaderBar::Command( const CommandEvent& rCEvt ) 1084*cdf0e10cSrcweir { 1085*cdf0e10cSrcweir if ( rCEvt.IsMouseEvent() && (rCEvt.GetCommand() == COMMAND_STARTDRAG) && !mbDrag ) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir ImplStartDrag( rCEvt.GetMousePosPixel(), sal_True ); 1088*cdf0e10cSrcweir return; 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir Window::Command( rCEvt ); 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1095*cdf0e10cSrcweir 1096*cdf0e10cSrcweir void HeaderBar::RequestHelp( const HelpEvent& rHEvt ) 1097*cdf0e10cSrcweir { 1098*cdf0e10cSrcweir sal_uInt16 nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); 1099*cdf0e10cSrcweir if ( nItemId ) 1100*cdf0e10cSrcweir { 1101*cdf0e10cSrcweir if ( rHEvt.GetMode() & (HELPMODE_QUICK | HELPMODE_BALLOON) ) 1102*cdf0e10cSrcweir { 1103*cdf0e10cSrcweir Rectangle aItemRect = GetItemRect( nItemId ); 1104*cdf0e10cSrcweir Point aPt = OutputToScreenPixel( aItemRect.TopLeft() ); 1105*cdf0e10cSrcweir aItemRect.Left() = aPt.X(); 1106*cdf0e10cSrcweir aItemRect.Top() = aPt.Y(); 1107*cdf0e10cSrcweir aPt = OutputToScreenPixel( aItemRect.BottomRight() ); 1108*cdf0e10cSrcweir aItemRect.Right() = aPt.X(); 1109*cdf0e10cSrcweir aItemRect.Bottom() = aPt.Y(); 1110*cdf0e10cSrcweir 1111*cdf0e10cSrcweir XubString aStr = GetHelpText( nItemId ); 1112*cdf0e10cSrcweir if ( !aStr.Len() || !(rHEvt.GetMode() & HELPMODE_BALLOON) ) 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( GetItemPos( nItemId ) ); 1115*cdf0e10cSrcweir // Wir zeigen die Quick-Hilfe nur an, wenn Text nicht 1116*cdf0e10cSrcweir // vollstaendig sichtbar, ansonsten zeigen wir den Hilfetext 1117*cdf0e10cSrcweir // an, wenn das Item keinen Text besitzt 1118*cdf0e10cSrcweir if ( pItem->maOutText != pItem->maText ) 1119*cdf0e10cSrcweir aStr = pItem->maText; 1120*cdf0e10cSrcweir else if ( pItem->maText.Len() ) 1121*cdf0e10cSrcweir aStr.Erase(); 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir if ( aStr.Len() ) 1125*cdf0e10cSrcweir { 1126*cdf0e10cSrcweir if ( rHEvt.GetMode() & HELPMODE_BALLOON ) 1127*cdf0e10cSrcweir Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aStr ); 1128*cdf0e10cSrcweir else 1129*cdf0e10cSrcweir Help::ShowQuickHelp( this, aItemRect, aStr ); 1130*cdf0e10cSrcweir return; 1131*cdf0e10cSrcweir } 1132*cdf0e10cSrcweir } 1133*cdf0e10cSrcweir else if ( rHEvt.GetMode() & HELPMODE_EXTENDED ) 1134*cdf0e10cSrcweir { 1135*cdf0e10cSrcweir rtl::OUString aHelpId( rtl::OStringToOUString( GetHelpId( nItemId ), RTL_TEXTENCODING_UTF8 ) ); 1136*cdf0e10cSrcweir if ( aHelpId.getLength() ) 1137*cdf0e10cSrcweir { 1138*cdf0e10cSrcweir // Wenn eine Hilfe existiert, dann ausloesen 1139*cdf0e10cSrcweir Help* pHelp = Application::GetHelp(); 1140*cdf0e10cSrcweir if ( pHelp ) 1141*cdf0e10cSrcweir pHelp->Start( aHelpId, this ); 1142*cdf0e10cSrcweir return; 1143*cdf0e10cSrcweir } 1144*cdf0e10cSrcweir } 1145*cdf0e10cSrcweir } 1146*cdf0e10cSrcweir 1147*cdf0e10cSrcweir Window::RequestHelp( rHEvt ); 1148*cdf0e10cSrcweir } 1149*cdf0e10cSrcweir 1150*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1151*cdf0e10cSrcweir 1152*cdf0e10cSrcweir void HeaderBar::StateChanged( StateChangedType nType ) 1153*cdf0e10cSrcweir { 1154*cdf0e10cSrcweir Window::StateChanged( nType ); 1155*cdf0e10cSrcweir 1156*cdf0e10cSrcweir if ( nType == STATE_CHANGE_ENABLE ) 1157*cdf0e10cSrcweir Invalidate(); 1158*cdf0e10cSrcweir else if ( (nType == STATE_CHANGE_ZOOM) || 1159*cdf0e10cSrcweir (nType == STATE_CHANGE_CONTROLFONT) ) 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_False, sal_False ); 1162*cdf0e10cSrcweir Invalidate(); 1163*cdf0e10cSrcweir } 1164*cdf0e10cSrcweir else if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) 1165*cdf0e10cSrcweir { 1166*cdf0e10cSrcweir ImplInitSettings( sal_False, sal_True, sal_False ); 1167*cdf0e10cSrcweir Invalidate(); 1168*cdf0e10cSrcweir } 1169*cdf0e10cSrcweir else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 1170*cdf0e10cSrcweir { 1171*cdf0e10cSrcweir ImplInitSettings( sal_False, sal_False, sal_True ); 1172*cdf0e10cSrcweir Invalidate(); 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir } 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir void HeaderBar::DataChanged( const DataChangedEvent& rDCEvt ) 1179*cdf0e10cSrcweir { 1180*cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 1181*cdf0e10cSrcweir 1182*cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_FONTS) || 1183*cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || 1184*cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && 1185*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) 1186*cdf0e10cSrcweir { 1187*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 1188*cdf0e10cSrcweir Invalidate(); 1189*cdf0e10cSrcweir } 1190*cdf0e10cSrcweir } 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1193*cdf0e10cSrcweir 1194*cdf0e10cSrcweir void HeaderBar::UserDraw( const UserDrawEvent& ) 1195*cdf0e10cSrcweir { 1196*cdf0e10cSrcweir } 1197*cdf0e10cSrcweir 1198*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir void HeaderBar::StartDrag() 1201*cdf0e10cSrcweir { 1202*cdf0e10cSrcweir maStartDragHdl.Call( this ); 1203*cdf0e10cSrcweir } 1204*cdf0e10cSrcweir 1205*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1206*cdf0e10cSrcweir 1207*cdf0e10cSrcweir void HeaderBar::Drag() 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir maDragHdl.Call( this ); 1210*cdf0e10cSrcweir } 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1213*cdf0e10cSrcweir 1214*cdf0e10cSrcweir void HeaderBar::EndDrag() 1215*cdf0e10cSrcweir { 1216*cdf0e10cSrcweir maEndDragHdl.Call( this ); 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir 1219*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir void HeaderBar::Select() 1222*cdf0e10cSrcweir { 1223*cdf0e10cSrcweir maSelectHdl.Call( this ); 1224*cdf0e10cSrcweir } 1225*cdf0e10cSrcweir 1226*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir void HeaderBar::DoubleClick() 1229*cdf0e10cSrcweir { 1230*cdf0e10cSrcweir maDoubleClickHdl.Call( this ); 1231*cdf0e10cSrcweir } 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1234*cdf0e10cSrcweir 1235*cdf0e10cSrcweir void HeaderBar::InsertItem( sal_uInt16 nItemId, const Image& rImage, 1236*cdf0e10cSrcweir long nSize, HeaderBarItemBits nBits, sal_uInt16 nPos ) 1237*cdf0e10cSrcweir { 1238*cdf0e10cSrcweir DBG_ASSERT( nItemId, "HeaderBar::InsertItem(): ItemId == 0" ); 1239*cdf0e10cSrcweir DBG_ASSERT( GetItemPos( nItemId ) == HEADERBAR_ITEM_NOTFOUND, 1240*cdf0e10cSrcweir "HeaderBar::InsertItem(): ItemId already exists" ); 1241*cdf0e10cSrcweir 1242*cdf0e10cSrcweir // Item anlegen und in die Liste einfuegen 1243*cdf0e10cSrcweir ImplHeadItem* pItem = new ImplHeadItem; 1244*cdf0e10cSrcweir pItem->mnId = nItemId; 1245*cdf0e10cSrcweir pItem->mnBits = nBits; 1246*cdf0e10cSrcweir pItem->mnSize = nSize; 1247*cdf0e10cSrcweir pItem->maImage = rImage; 1248*cdf0e10cSrcweir pItem->mpUserData = 0; 1249*cdf0e10cSrcweir mpItemList->Insert( pItem, nPos ); 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir // Ausgabe updaten 1252*cdf0e10cSrcweir ImplUpdate( nPos, sal_True ); 1253*cdf0e10cSrcweir } 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1256*cdf0e10cSrcweir 1257*cdf0e10cSrcweir void HeaderBar::InsertItem( sal_uInt16 nItemId, const XubString& rText, 1258*cdf0e10cSrcweir long nSize, HeaderBarItemBits nBits, sal_uInt16 nPos ) 1259*cdf0e10cSrcweir { 1260*cdf0e10cSrcweir DBG_ASSERT( nItemId, "HeaderBar::InsertItem(): ItemId == 0" ); 1261*cdf0e10cSrcweir DBG_ASSERT( GetItemPos( nItemId ) == HEADERBAR_ITEM_NOTFOUND, 1262*cdf0e10cSrcweir "HeaderBar::InsertItem(): ItemId already exists" ); 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir // Item anlegen und in die Liste einfuegen 1265*cdf0e10cSrcweir ImplHeadItem* pItem = new ImplHeadItem; 1266*cdf0e10cSrcweir pItem->mnId = nItemId; 1267*cdf0e10cSrcweir pItem->mnBits = nBits; 1268*cdf0e10cSrcweir pItem->mnSize = nSize; 1269*cdf0e10cSrcweir pItem->maText = rText; 1270*cdf0e10cSrcweir pItem->mpUserData = 0; 1271*cdf0e10cSrcweir mpItemList->Insert( pItem, nPos ); 1272*cdf0e10cSrcweir 1273*cdf0e10cSrcweir // Ausgabe updaten 1274*cdf0e10cSrcweir ImplUpdate( nPos, sal_True ); 1275*cdf0e10cSrcweir } 1276*cdf0e10cSrcweir 1277*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1278*cdf0e10cSrcweir 1279*cdf0e10cSrcweir void HeaderBar::InsertItem( sal_uInt16 nItemId, 1280*cdf0e10cSrcweir const Image& rImage, const XubString& rText, 1281*cdf0e10cSrcweir long nSize, HeaderBarItemBits nBits, 1282*cdf0e10cSrcweir sal_uInt16 nPos ) 1283*cdf0e10cSrcweir { 1284*cdf0e10cSrcweir DBG_ASSERT( nItemId, "HeaderBar::InsertItem(): ItemId == 0" ); 1285*cdf0e10cSrcweir DBG_ASSERT( GetItemPos( nItemId ) == HEADERBAR_ITEM_NOTFOUND, 1286*cdf0e10cSrcweir "HeaderBar::InsertItem(): ItemId already exists" ); 1287*cdf0e10cSrcweir 1288*cdf0e10cSrcweir // Item anlegen und in die Liste einfuegen 1289*cdf0e10cSrcweir ImplHeadItem* pItem = new ImplHeadItem; 1290*cdf0e10cSrcweir pItem->mnId = nItemId; 1291*cdf0e10cSrcweir pItem->mnBits = nBits; 1292*cdf0e10cSrcweir pItem->mnSize = nSize; 1293*cdf0e10cSrcweir pItem->maImage = rImage; 1294*cdf0e10cSrcweir pItem->maText = rText; 1295*cdf0e10cSrcweir pItem->mpUserData = 0; 1296*cdf0e10cSrcweir mpItemList->Insert( pItem, nPos ); 1297*cdf0e10cSrcweir 1298*cdf0e10cSrcweir // Ausgabe updaten 1299*cdf0e10cSrcweir ImplUpdate( nPos, sal_True ); 1300*cdf0e10cSrcweir } 1301*cdf0e10cSrcweir 1302*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1303*cdf0e10cSrcweir 1304*cdf0e10cSrcweir void HeaderBar::RemoveItem( sal_uInt16 nItemId ) 1305*cdf0e10cSrcweir { 1306*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1307*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1308*cdf0e10cSrcweir { 1309*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->Remove( nPos ); 1310*cdf0e10cSrcweir delete pItem; 1311*cdf0e10cSrcweir ImplUpdate( nPos, sal_True ); 1312*cdf0e10cSrcweir } 1313*cdf0e10cSrcweir } 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1316*cdf0e10cSrcweir 1317*cdf0e10cSrcweir void HeaderBar::MoveItem( sal_uInt16 nItemId, sal_uInt16 nNewPos ) 1318*cdf0e10cSrcweir { 1319*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1320*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1321*cdf0e10cSrcweir { 1322*cdf0e10cSrcweir if ( nPos != nNewPos ) 1323*cdf0e10cSrcweir { 1324*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->Remove( nPos ); 1325*cdf0e10cSrcweir if ( nNewPos < nPos ) 1326*cdf0e10cSrcweir nPos = nNewPos; 1327*cdf0e10cSrcweir mpItemList->Insert( pItem, nNewPos ); 1328*cdf0e10cSrcweir ImplUpdate( nPos, sal_True ); 1329*cdf0e10cSrcweir } 1330*cdf0e10cSrcweir } 1331*cdf0e10cSrcweir } 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1334*cdf0e10cSrcweir 1335*cdf0e10cSrcweir void HeaderBar::Clear() 1336*cdf0e10cSrcweir { 1337*cdf0e10cSrcweir // Alle Items loeschen 1338*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->First(); 1339*cdf0e10cSrcweir while ( pItem ) 1340*cdf0e10cSrcweir { 1341*cdf0e10cSrcweir delete pItem; 1342*cdf0e10cSrcweir pItem = mpItemList->Next(); 1343*cdf0e10cSrcweir } 1344*cdf0e10cSrcweir mpItemList->Clear(); 1345*cdf0e10cSrcweir 1346*cdf0e10cSrcweir ImplUpdate( 0, sal_True ); 1347*cdf0e10cSrcweir } 1348*cdf0e10cSrcweir 1349*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1350*cdf0e10cSrcweir 1351*cdf0e10cSrcweir void HeaderBar::SetOffset( long nNewOffset ) 1352*cdf0e10cSrcweir { 1353*cdf0e10cSrcweir // Hier erstmal neu zeichnen, damit mit alten Offset noch das 1354*cdf0e10cSrcweir // richtige gemalt wird 1355*cdf0e10cSrcweir //Update(); 1356*cdf0e10cSrcweir 1357*cdf0e10cSrcweir // Bereich verschieben 1358*cdf0e10cSrcweir Rectangle aRect( 0, mnBorderOff1, mnDX-1, mnDY-mnBorderOff1-mnBorderOff2-1 ); 1359*cdf0e10cSrcweir long nDelta = mnOffset-nNewOffset; 1360*cdf0e10cSrcweir mnOffset = nNewOffset; 1361*cdf0e10cSrcweir Scroll( nDelta, 0, aRect ); 1362*cdf0e10cSrcweir } 1363*cdf0e10cSrcweir 1364*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1365*cdf0e10cSrcweir 1366*cdf0e10cSrcweir sal_uInt16 HeaderBar::GetItemCount() const 1367*cdf0e10cSrcweir { 1368*cdf0e10cSrcweir return (sal_uInt16)mpItemList->Count(); 1369*cdf0e10cSrcweir } 1370*cdf0e10cSrcweir 1371*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1372*cdf0e10cSrcweir 1373*cdf0e10cSrcweir sal_uInt16 HeaderBar::GetItemPos( sal_uInt16 nItemId ) const 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->First(); 1376*cdf0e10cSrcweir while ( pItem ) 1377*cdf0e10cSrcweir { 1378*cdf0e10cSrcweir if ( pItem->mnId == nItemId ) 1379*cdf0e10cSrcweir return (sal_uInt16)mpItemList->GetCurPos(); 1380*cdf0e10cSrcweir pItem = mpItemList->Next(); 1381*cdf0e10cSrcweir } 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir return HEADERBAR_ITEM_NOTFOUND; 1384*cdf0e10cSrcweir } 1385*cdf0e10cSrcweir 1386*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1387*cdf0e10cSrcweir 1388*cdf0e10cSrcweir sal_uInt16 HeaderBar::GetItemId( sal_uInt16 nPos ) const 1389*cdf0e10cSrcweir { 1390*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( nPos ); 1391*cdf0e10cSrcweir if ( pItem ) 1392*cdf0e10cSrcweir return pItem->mnId; 1393*cdf0e10cSrcweir else 1394*cdf0e10cSrcweir return 0; 1395*cdf0e10cSrcweir } 1396*cdf0e10cSrcweir 1397*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1398*cdf0e10cSrcweir 1399*cdf0e10cSrcweir sal_uInt16 HeaderBar::GetItemId( const Point& rPos ) const 1400*cdf0e10cSrcweir { 1401*cdf0e10cSrcweir sal_uInt16 nPos = 0; 1402*cdf0e10cSrcweir while ( nPos < mpItemList->Count() ) 1403*cdf0e10cSrcweir { 1404*cdf0e10cSrcweir if ( ImplGetItemRect( nPos ).IsInside( rPos ) ) 1405*cdf0e10cSrcweir return GetItemId( nPos ); 1406*cdf0e10cSrcweir 1407*cdf0e10cSrcweir nPos++; 1408*cdf0e10cSrcweir } 1409*cdf0e10cSrcweir 1410*cdf0e10cSrcweir return 0; 1411*cdf0e10cSrcweir } 1412*cdf0e10cSrcweir 1413*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1414*cdf0e10cSrcweir 1415*cdf0e10cSrcweir Rectangle HeaderBar::GetItemRect( sal_uInt16 nItemId ) const 1416*cdf0e10cSrcweir { 1417*cdf0e10cSrcweir Rectangle aRect; 1418*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1419*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1420*cdf0e10cSrcweir aRect = ImplGetItemRect( nPos ); 1421*cdf0e10cSrcweir return aRect; 1422*cdf0e10cSrcweir } 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1425*cdf0e10cSrcweir 1426*cdf0e10cSrcweir void HeaderBar::SetItemSize( sal_uInt16 nItemId, long nNewSize ) 1427*cdf0e10cSrcweir { 1428*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1429*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1430*cdf0e10cSrcweir { 1431*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( nPos ); 1432*cdf0e10cSrcweir if ( pItem->mnSize != nNewSize ) 1433*cdf0e10cSrcweir { 1434*cdf0e10cSrcweir pItem->mnSize = nNewSize; 1435*cdf0e10cSrcweir ImplUpdate( nPos, sal_True ); 1436*cdf0e10cSrcweir } 1437*cdf0e10cSrcweir } 1438*cdf0e10cSrcweir } 1439*cdf0e10cSrcweir 1440*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1441*cdf0e10cSrcweir 1442*cdf0e10cSrcweir long HeaderBar::GetItemSize( sal_uInt16 nItemId ) const 1443*cdf0e10cSrcweir { 1444*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1445*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1446*cdf0e10cSrcweir return mpItemList->GetObject( nPos )->mnSize; 1447*cdf0e10cSrcweir else 1448*cdf0e10cSrcweir return 0; 1449*cdf0e10cSrcweir } 1450*cdf0e10cSrcweir 1451*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1452*cdf0e10cSrcweir 1453*cdf0e10cSrcweir void HeaderBar::SetItemBits( sal_uInt16 nItemId, HeaderBarItemBits nNewBits ) 1454*cdf0e10cSrcweir { 1455*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1456*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1457*cdf0e10cSrcweir { 1458*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( nPos ); 1459*cdf0e10cSrcweir if ( pItem->mnBits != nNewBits ) 1460*cdf0e10cSrcweir { 1461*cdf0e10cSrcweir pItem->mnBits = nNewBits; 1462*cdf0e10cSrcweir ImplUpdate( nPos ); 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir } 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir 1467*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir HeaderBarItemBits HeaderBar::GetItemBits( sal_uInt16 nItemId ) const 1470*cdf0e10cSrcweir { 1471*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1472*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1473*cdf0e10cSrcweir return mpItemList->GetObject( nPos )->mnBits; 1474*cdf0e10cSrcweir else 1475*cdf0e10cSrcweir return 0; 1476*cdf0e10cSrcweir } 1477*cdf0e10cSrcweir 1478*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1479*cdf0e10cSrcweir 1480*cdf0e10cSrcweir void HeaderBar::SetItemData( sal_uInt16 nItemId, void* pNewData ) 1481*cdf0e10cSrcweir { 1482*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1483*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1484*cdf0e10cSrcweir { 1485*cdf0e10cSrcweir mpItemList->GetObject( nPos )->mpUserData = pNewData; 1486*cdf0e10cSrcweir ImplUpdate( nPos ); 1487*cdf0e10cSrcweir } 1488*cdf0e10cSrcweir } 1489*cdf0e10cSrcweir 1490*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1491*cdf0e10cSrcweir 1492*cdf0e10cSrcweir void* HeaderBar::GetItemData( sal_uInt16 nItemId ) const 1493*cdf0e10cSrcweir { 1494*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1495*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1496*cdf0e10cSrcweir return mpItemList->GetObject( nPos )->mpUserData; 1497*cdf0e10cSrcweir else 1498*cdf0e10cSrcweir return NULL; 1499*cdf0e10cSrcweir } 1500*cdf0e10cSrcweir 1501*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir void HeaderBar::SetItemImage( sal_uInt16 nItemId, const Image& rImage ) 1504*cdf0e10cSrcweir { 1505*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1506*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1507*cdf0e10cSrcweir { 1508*cdf0e10cSrcweir mpItemList->GetObject( nPos )->maImage = rImage; 1509*cdf0e10cSrcweir ImplUpdate( nPos ); 1510*cdf0e10cSrcweir } 1511*cdf0e10cSrcweir } 1512*cdf0e10cSrcweir 1513*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1514*cdf0e10cSrcweir 1515*cdf0e10cSrcweir Image HeaderBar::GetItemImage( sal_uInt16 nItemId ) const 1516*cdf0e10cSrcweir { 1517*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1518*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1519*cdf0e10cSrcweir return mpItemList->GetObject( nPos )->maImage; 1520*cdf0e10cSrcweir else 1521*cdf0e10cSrcweir return Image(); 1522*cdf0e10cSrcweir } 1523*cdf0e10cSrcweir 1524*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1525*cdf0e10cSrcweir 1526*cdf0e10cSrcweir void HeaderBar::SetItemText( sal_uInt16 nItemId, const XubString& rText ) 1527*cdf0e10cSrcweir { 1528*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1529*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1530*cdf0e10cSrcweir { 1531*cdf0e10cSrcweir mpItemList->GetObject( nPos )->maText = rText; 1532*cdf0e10cSrcweir ImplUpdate( nPos ); 1533*cdf0e10cSrcweir } 1534*cdf0e10cSrcweir } 1535*cdf0e10cSrcweir 1536*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1537*cdf0e10cSrcweir 1538*cdf0e10cSrcweir XubString HeaderBar::GetItemText( sal_uInt16 nItemId ) const 1539*cdf0e10cSrcweir { 1540*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1541*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1542*cdf0e10cSrcweir return mpItemList->GetObject( nPos )->maText; 1543*cdf0e10cSrcweir else 1544*cdf0e10cSrcweir return String(); 1545*cdf0e10cSrcweir } 1546*cdf0e10cSrcweir 1547*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1548*cdf0e10cSrcweir 1549*cdf0e10cSrcweir void HeaderBar::SetHelpText( sal_uInt16 nItemId, const XubString& rText ) 1550*cdf0e10cSrcweir { 1551*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1552*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1553*cdf0e10cSrcweir mpItemList->GetObject( nPos )->maHelpText = rText; 1554*cdf0e10cSrcweir } 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1557*cdf0e10cSrcweir 1558*cdf0e10cSrcweir XubString HeaderBar::GetHelpText( sal_uInt16 nItemId ) const 1559*cdf0e10cSrcweir { 1560*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1561*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1562*cdf0e10cSrcweir { 1563*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->GetObject( nPos ); 1564*cdf0e10cSrcweir if ( !pItem->maHelpText.Len() && pItem->maHelpId.getLength() ) 1565*cdf0e10cSrcweir { 1566*cdf0e10cSrcweir Help* pHelp = Application::GetHelp(); 1567*cdf0e10cSrcweir if ( pHelp ) 1568*cdf0e10cSrcweir pItem->maHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this ); 1569*cdf0e10cSrcweir } 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir return pItem->maHelpText; 1572*cdf0e10cSrcweir } 1573*cdf0e10cSrcweir else 1574*cdf0e10cSrcweir return XubString(); 1575*cdf0e10cSrcweir } 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1578*cdf0e10cSrcweir 1579*cdf0e10cSrcweir void HeaderBar::SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId ) 1580*cdf0e10cSrcweir { 1581*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1582*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1583*cdf0e10cSrcweir mpItemList->GetObject( nPos )->maHelpId = rHelpId; 1584*cdf0e10cSrcweir } 1585*cdf0e10cSrcweir 1586*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1587*cdf0e10cSrcweir 1588*cdf0e10cSrcweir rtl::OString HeaderBar::GetHelpId( sal_uInt16 nItemId ) const 1589*cdf0e10cSrcweir { 1590*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( nItemId ); 1591*cdf0e10cSrcweir rtl::OString aRet; 1592*cdf0e10cSrcweir if ( nPos != HEADERBAR_ITEM_NOTFOUND ) 1593*cdf0e10cSrcweir aRet = mpItemList->GetObject( nPos )->maHelpId; 1594*cdf0e10cSrcweir return aRet; 1595*cdf0e10cSrcweir } 1596*cdf0e10cSrcweir 1597*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1598*cdf0e10cSrcweir 1599*cdf0e10cSrcweir Size HeaderBar::CalcWindowSizePixel() const 1600*cdf0e10cSrcweir { 1601*cdf0e10cSrcweir long nMaxImageSize = 0; 1602*cdf0e10cSrcweir Size aSize( 0, GetTextHeight() ); 1603*cdf0e10cSrcweir 1604*cdf0e10cSrcweir ImplHeadItem* pItem = mpItemList->First(); 1605*cdf0e10cSrcweir while ( pItem ) 1606*cdf0e10cSrcweir { 1607*cdf0e10cSrcweir // Image-Groessen beruecksichtigen 1608*cdf0e10cSrcweir long nImageHeight = pItem->maImage.GetSizePixel().Height(); 1609*cdf0e10cSrcweir if ( !(pItem->mnBits & (HIB_LEFTIMAGE | HIB_RIGHTIMAGE)) && pItem->maText.Len() ) 1610*cdf0e10cSrcweir nImageHeight += aSize.Height(); 1611*cdf0e10cSrcweir if ( nImageHeight > nMaxImageSize ) 1612*cdf0e10cSrcweir nMaxImageSize = nImageHeight; 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir // Breite aufaddieren 1615*cdf0e10cSrcweir aSize.Width() += pItem->mnSize; 1616*cdf0e10cSrcweir 1617*cdf0e10cSrcweir pItem = mpItemList->Next(); 1618*cdf0e10cSrcweir } 1619*cdf0e10cSrcweir 1620*cdf0e10cSrcweir if ( nMaxImageSize > aSize.Height() ) 1621*cdf0e10cSrcweir aSize.Height() = nMaxImageSize; 1622*cdf0e10cSrcweir 1623*cdf0e10cSrcweir // Border aufaddieren 1624*cdf0e10cSrcweir if ( mbButtonStyle ) 1625*cdf0e10cSrcweir aSize.Height() += 4; 1626*cdf0e10cSrcweir else 1627*cdf0e10cSrcweir aSize.Height() += 2; 1628*cdf0e10cSrcweir aSize.Height() += mnBorderOff1+mnBorderOff2; 1629*cdf0e10cSrcweir 1630*cdf0e10cSrcweir return aSize; 1631*cdf0e10cSrcweir } 1632*cdf0e10cSrcweir 1633*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > HeaderBar::CreateAccessible() 1634*cdf0e10cSrcweir { 1635*cdf0e10cSrcweir if ( !mxAccessible.is() ) 1636*cdf0e10cSrcweir { 1637*cdf0e10cSrcweir if ( maCreateAccessibleHdl.IsSet() ) 1638*cdf0e10cSrcweir maCreateAccessibleHdl.Call( this ); 1639*cdf0e10cSrcweir 1640*cdf0e10cSrcweir if ( !mxAccessible.is() ) 1641*cdf0e10cSrcweir mxAccessible = Window::CreateAccessible(); 1642*cdf0e10cSrcweir } 1643*cdf0e10cSrcweir 1644*cdf0e10cSrcweir return mxAccessible; 1645*cdf0e10cSrcweir } 1646*cdf0e10cSrcweir 1647*cdf0e10cSrcweir void HeaderBar::SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > _xAccessible ) 1648*cdf0e10cSrcweir { 1649*cdf0e10cSrcweir mxAccessible = _xAccessible; 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir 1652