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_vcl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <rtl/logfile.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <tools/list.hxx> 34*cdf0e10cSrcweir #include <tools/debug.hxx> 35*cdf0e10cSrcweir #include <tools/rc.h> 36*cdf0e10cSrcweir #include <tools/poly.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <vcl/event.hxx> 39*cdf0e10cSrcweir #include <vcl/decoview.hxx> 40*cdf0e10cSrcweir #include <vcl/accel.hxx> 41*cdf0e10cSrcweir #include <vcl/svapp.hxx> 42*cdf0e10cSrcweir #include <vcl/help.hxx> 43*cdf0e10cSrcweir #include <vcl/sound.hxx> 44*cdf0e10cSrcweir #include <vcl/virdev.hxx> 45*cdf0e10cSrcweir #include <vcl/spin.h> 46*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 47*cdf0e10cSrcweir #include <vcl/bitmap.hxx> 48*cdf0e10cSrcweir #include <vcl/mnemonic.hxx> 49*cdf0e10cSrcweir #include <vcl/gradient.hxx> 50*cdf0e10cSrcweir #include <vcl/menu.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <svdata.hxx> 53*cdf0e10cSrcweir #include <window.h> 54*cdf0e10cSrcweir #include <toolbox.h> 55*cdf0e10cSrcweir #include <salframe.hxx> 56*cdf0e10cSrcweir #if defined WNT 57*cdf0e10cSrcweir #include <svsys.h> 58*cdf0e10cSrcweir #endif 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #include <string.h> 61*cdf0e10cSrcweir #include <vector> 62*cdf0e10cSrcweir #include <math.h> 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir // ======================================================================= 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir DBG_NAMEEX( Window ) 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // ======================================================================= 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir #define SMALLBUTTON_HSIZE 7 71*cdf0e10cSrcweir #define SMALLBUTTON_VSIZE 7 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir #define SMALLBUTTON_OFF_NORMAL_X 3 74*cdf0e10cSrcweir #define SMALLBUTTON_OFF_NORMAL_Y 3 75*cdf0e10cSrcweir #define SMALLBUTTON_OFF_CHECKED_X 4 76*cdf0e10cSrcweir #define SMALLBUTTON_OFF_CHECKED_Y 4 77*cdf0e10cSrcweir #define SMALLBUTTON_OFF_PRESSED_X 5 78*cdf0e10cSrcweir #define SMALLBUTTON_OFF_PRESSED_Y 5 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir #define OUTBUTTON_SIZE 6 81*cdf0e10cSrcweir #define OUTBUTTON_BORDER 4 82*cdf0e10cSrcweir #define OUTBUTTON_OFF_NORMAL_X 1 83*cdf0e10cSrcweir #define OUTBUTTON_OFF_NORMAL_Y 1 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir // ----------------------------------------------------------------------- 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir #define DEF_MIN_WIDTH 8 88*cdf0e10cSrcweir #define DEF_MIN_HEIGHT 8 89*cdf0e10cSrcweir #define DEF_TEXT_WIDTH 40 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir #define TB_TEXTOFFSET 2 92*cdf0e10cSrcweir #define TB_IMAGETEXTOFFSET 3 93*cdf0e10cSrcweir #define TB_LINESPACING 3 94*cdf0e10cSrcweir #define TB_SPIN_SIZE 14 95*cdf0e10cSrcweir #define TB_SPIN_OFFSET 2 96*cdf0e10cSrcweir #define TB_NEXT_SIZE 22 97*cdf0e10cSrcweir #define TB_NEXT_OFFSET 2 98*cdf0e10cSrcweir #define TB_BORDER_OFFSET1 4 99*cdf0e10cSrcweir #define TB_BORDER_OFFSET2 2 100*cdf0e10cSrcweir #define TB_CUSTOMIZE_OFFSET 2 101*cdf0e10cSrcweir #define TB_RESIZE_OFFSET 3 102*cdf0e10cSrcweir #define TB_MAXLINES 5 103*cdf0e10cSrcweir #define TB_MAXNOSCROLL 32765 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir #define TB_MIN_WIN_WIDTH 20 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir #define TB_CALCMODE_HORZ 1 108*cdf0e10cSrcweir #define TB_CALCMODE_VERT 2 109*cdf0e10cSrcweir #define TB_CALCMODE_FLOAT 3 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir #define TB_WBLINESIZING (WB_SIZEABLE | WB_DOCKABLE | WB_SCROLL) 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir #define TB_MAX_GROUPS 100 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir #define DOCK_LINEHSIZE ((sal_uInt16)0x0001) 116*cdf0e10cSrcweir #define DOCK_LINEVSIZE ((sal_uInt16)0x0002) 117*cdf0e10cSrcweir #define DOCK_LINERIGHT ((sal_uInt16)0x1000) 118*cdf0e10cSrcweir #define DOCK_LINEBOTTOM ((sal_uInt16)0x2000) 119*cdf0e10cSrcweir #define DOCK_LINELEFT ((sal_uInt16)0x4000) 120*cdf0e10cSrcweir #define DOCK_LINETOP ((sal_uInt16)0x8000) 121*cdf0e10cSrcweir #define DOCK_LINEOFFSET 3 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // ----------------------------------------------------------------------- 125*cdf0e10cSrcweir static void ImplDrawButton( ToolBox* pThis, const Rectangle &rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bEnabled, sal_Bool bIsWindow ); 126*cdf0e10cSrcweir // ----------------------------------------------------------------------- 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir struct ImplToolSize 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir long mnWidth; 131*cdf0e10cSrcweir long mnHeight; 132*cdf0e10cSrcweir sal_uInt16 mnLines; 133*cdf0e10cSrcweir }; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir struct ImplToolSizeArray 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir long mnLength; 138*cdf0e10cSrcweir long mnLastEntry; 139*cdf0e10cSrcweir ImplToolSize* mpSize; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir ImplToolSizeArray() { mpSize = NULL; mnLength = 0; mnLastEntry = 0; } 142*cdf0e10cSrcweir ~ImplToolSizeArray() { if( mpSize ) delete [] mpSize; mnLength = 0; } 143*cdf0e10cSrcweir }; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir // ----------------------------------------------------------------------- 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir DECLARE_LIST( ImplTBList, ToolBox* ) 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir class ImplTBDragMgr 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir private: 152*cdf0e10cSrcweir ImplTBList* mpBoxList; 153*cdf0e10cSrcweir ToolBox* mpDragBox; 154*cdf0e10cSrcweir Point maMouseOff; 155*cdf0e10cSrcweir Rectangle maRect; 156*cdf0e10cSrcweir Rectangle maStartRect; 157*cdf0e10cSrcweir Accelerator maAccel; 158*cdf0e10cSrcweir long mnMinWidth; 159*cdf0e10cSrcweir long mnMaxWidth; 160*cdf0e10cSrcweir sal_uInt16 mnLineMode; 161*cdf0e10cSrcweir sal_uInt16 mnStartLines; 162*cdf0e10cSrcweir void* mpCustomizeData; 163*cdf0e10cSrcweir sal_Bool mbCustomizeMode; 164*cdf0e10cSrcweir sal_Bool mbResizeMode; 165*cdf0e10cSrcweir sal_Bool mbShowDragRect; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir public: 168*cdf0e10cSrcweir ImplTBDragMgr(); 169*cdf0e10cSrcweir ~ImplTBDragMgr(); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir void Insert( ToolBox* pBox ) 172*cdf0e10cSrcweir { mpBoxList->Insert( pBox ); } 173*cdf0e10cSrcweir void Remove( ToolBox* pBox ) 174*cdf0e10cSrcweir { mpBoxList->Remove( pBox ); } 175*cdf0e10cSrcweir sal_uLong Count() const 176*cdf0e10cSrcweir { return mpBoxList->Count(); } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir ToolBox* FindToolBox( const Rectangle& rRect ); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir void StartDragging( ToolBox* pDragBox, 181*cdf0e10cSrcweir const Point& rPos, const Rectangle& rRect, 182*cdf0e10cSrcweir sal_uInt16 nLineMode, sal_Bool bResizeItem, 183*cdf0e10cSrcweir void* pData = NULL ); 184*cdf0e10cSrcweir void Dragging( const Point& rPos ); 185*cdf0e10cSrcweir void EndDragging( sal_Bool bOK = sal_True ); 186*cdf0e10cSrcweir void HideDragRect() { if ( mbShowDragRect ) mpDragBox->HideTracking(); } 187*cdf0e10cSrcweir void UpdateDragRect(); 188*cdf0e10cSrcweir DECL_LINK( SelectHdl, Accelerator* ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir void StartCustomizeMode(); 191*cdf0e10cSrcweir void EndCustomizeMode(); 192*cdf0e10cSrcweir sal_Bool IsCustomizeMode() { return mbCustomizeMode; } 193*cdf0e10cSrcweir sal_Bool IsResizeMode() { return mbResizeMode; } 194*cdf0e10cSrcweir }; 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir // ----------------------------------------------------------------------- 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir static ImplTBDragMgr* ImplGetTBDragMgr() 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 201*cdf0e10cSrcweir if ( !pSVData->maCtrlData.mpTBDragMgr ) 202*cdf0e10cSrcweir pSVData->maCtrlData.mpTBDragMgr = new ImplTBDragMgr; 203*cdf0e10cSrcweir return pSVData->maCtrlData.mpTBDragMgr; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir // ----------------------------------------------------------------------- 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir int ToolBox::ImplGetDragWidth( ToolBox* pThis ) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir #define TB_DRAGWIDTH 8 // the default width of the grip 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir int width = TB_DRAGWIDTH; 213*cdf0e10cSrcweir if( pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir ImplControlValue aControlValue; 217*cdf0e10cSrcweir Point aPoint; 218*cdf0e10cSrcweir Rectangle aContent, aBound; 219*cdf0e10cSrcweir Rectangle aArea( aPoint, pThis->GetOutputSizePixel() ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir if ( pThis->GetNativeControlRegion(CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_VERT : PART_THUMB_HORZ, 222*cdf0e10cSrcweir aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir width = pThis->mbHorz ? aContent.GetWidth() : aContent.GetHeight(); 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir return width; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir ButtonType determineButtonType( ImplToolItem* pItem, ButtonType defaultType ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir ButtonType tmpButtonType = defaultType; 233*cdf0e10cSrcweir ToolBoxItemBits nBits( pItem->mnBits & 0x300 ); 234*cdf0e10cSrcweir if ( nBits & TIB_TEXTICON ) // item has custom setting 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir tmpButtonType = BUTTON_SYMBOLTEXT; 237*cdf0e10cSrcweir if ( nBits == TIB_TEXT_ONLY ) 238*cdf0e10cSrcweir tmpButtonType = BUTTON_TEXT; 239*cdf0e10cSrcweir else if ( nBits == TIB_ICON_ONLY ) 240*cdf0e10cSrcweir tmpButtonType = BUTTON_SYMBOL; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir return tmpButtonType; 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir // ----------------------------------------------------------------------- 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir void ToolBox::ImplUpdateDragArea( ToolBox *pThis ) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis ); 250*cdf0e10cSrcweir if( pWrapper ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir if ( pThis->ImplIsFloatingMode() || pWrapper->IsLocked() ) 253*cdf0e10cSrcweir pWrapper->SetDragArea( Rectangle() ); 254*cdf0e10cSrcweir else 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir if( pThis->meAlign == WINDOWALIGN_TOP || pThis->meAlign == WINDOWALIGN_BOTTOM ) 257*cdf0e10cSrcweir pWrapper->SetDragArea( Rectangle( 0, 0, ImplGetDragWidth( pThis ), pThis->GetOutputSizePixel().Height() ) ); 258*cdf0e10cSrcweir else 259*cdf0e10cSrcweir pWrapper->SetDragArea( Rectangle( 0, 0, pThis->GetOutputSizePixel().Width(), ImplGetDragWidth( pThis ) ) ); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir // ----------------------------------------------------------------------- 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir void ToolBox::ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop, 267*cdf0e10cSrcweir long& rRight, long& rBottom, const ToolBox *pThis ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir if( pThis->ImplIsFloatingMode() || !(pThis->mnWinStyle & WB_BORDER) ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir // no border in floating mode 272*cdf0e10cSrcweir rLeft = rTop = rRight = rBottom = 0; 273*cdf0e10cSrcweir return; 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir // reserve dragarea only for dockable toolbars 279*cdf0e10cSrcweir int dragwidth = ( pWrapper && !pWrapper->IsLocked() ) ? ImplGetDragWidth( (ToolBox*)pThis ) : 0; 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir // no shadow border for dockable toolbars 282*cdf0e10cSrcweir int borderwidth = pWrapper ? 0: 2; 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir if ( eAlign == WINDOWALIGN_TOP ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir rLeft = borderwidth+dragwidth; 287*cdf0e10cSrcweir rTop = borderwidth; 288*cdf0e10cSrcweir rRight = borderwidth; 289*cdf0e10cSrcweir rBottom = 0; 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir else if ( eAlign == WINDOWALIGN_LEFT ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir rLeft = borderwidth; 294*cdf0e10cSrcweir rTop = borderwidth+dragwidth; 295*cdf0e10cSrcweir rRight = 0; 296*cdf0e10cSrcweir rBottom = borderwidth; 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir else if ( eAlign == WINDOWALIGN_BOTTOM ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir rLeft = borderwidth+dragwidth; 301*cdf0e10cSrcweir rTop = 0; 302*cdf0e10cSrcweir rRight = borderwidth; 303*cdf0e10cSrcweir rBottom = borderwidth; 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir else 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir rLeft = 0; 308*cdf0e10cSrcweir rTop = borderwidth+dragwidth; 309*cdf0e10cSrcweir rRight = borderwidth; 310*cdf0e10cSrcweir rBottom = borderwidth; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir // ----------------------------------------------------------------------- 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir static void ImplCheckUpdate( ToolBox *pThis ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir // remove any pending invalidates to avoid 319*cdf0e10cSrcweir // have them triggered when paint is locked (see mpData->mbIsPaintLocked) 320*cdf0e10cSrcweir // which would result in erasing the background only and not painting any items 321*cdf0e10cSrcweir // this must not be done when we're already in Paint() 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // this is only required for transparent toolbars (see ImplDrawTransparentBackground() ) 324*cdf0e10cSrcweir if( !pThis->IsBackground() && pThis->HasPaintEvent() && !pThis->IsInPaint() ) 325*cdf0e10cSrcweir pThis->Update(); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir // ----------------------------------------------------------------------- 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir void ToolBox::ImplDrawGrip( ToolBox* pThis ) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis ); 333*cdf0e10cSrcweir if( pWrapper && !pWrapper->GetDragArea().IsEmpty() ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir // execute pending paint requests 336*cdf0e10cSrcweir ImplCheckUpdate( pThis ); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir sal_Bool bNativeOk = sal_False; 339*cdf0e10cSrcweir if( pThis->IsNativeControlSupported( CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_HORZ : PART_THUMB_VERT ) ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir ToolbarValue aToolbarValue; 342*cdf0e10cSrcweir aToolbarValue.maGripRect = pWrapper->GetDragArea(); 343*cdf0e10cSrcweir Point aPt; 344*cdf0e10cSrcweir Rectangle aCtrlRegion( aPt, pThis->GetOutputSizePixel() ); 345*cdf0e10cSrcweir ControlState nState = CTRL_STATE_ENABLED; 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir bNativeOk = pThis->DrawNativeControl( CTRL_TOOLBAR, pThis->mbHorz ? PART_THUMB_VERT : PART_THUMB_HORZ, 348*cdf0e10cSrcweir aCtrlRegion, nState, aToolbarValue, rtl::OUString() ); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir if( bNativeOk ) 352*cdf0e10cSrcweir return; 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir const StyleSettings& rStyleSettings = pThis->GetSettings().GetStyleSettings(); 355*cdf0e10cSrcweir pThis->SetLineColor( rStyleSettings.GetShadowColor() ); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir Size aSz ( pThis->GetOutputSizePixel() ); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir if ( pThis->meAlign == WINDOWALIGN_TOP || pThis->meAlign == WINDOWALIGN_BOTTOM ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir int height = (int) (0.6 * aSz.Height() + 0.5); 362*cdf0e10cSrcweir int i = (aSz.Height() - height) / 2; 363*cdf0e10cSrcweir height += i; 364*cdf0e10cSrcweir while( i <= height ) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir int x = ImplGetDragWidth( pThis ) / 2; 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir pThis->DrawPixel( Point(x, i), rStyleSettings.GetDarkShadowColor() ); 369*cdf0e10cSrcweir pThis->DrawPixel( Point(x+1, i), rStyleSettings.GetShadowColor() ); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir pThis->DrawPixel( Point(x, i+1), rStyleSettings.GetShadowColor() ); 372*cdf0e10cSrcweir pThis->DrawPixel( Point(x+1, i+1), rStyleSettings.GetFaceColor() ); 373*cdf0e10cSrcweir pThis->DrawPixel( Point(x+2, i+1), Color(COL_WHITE) ); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir pThis->DrawPixel( Point(x+1, i+2), Color(COL_WHITE) ); 376*cdf0e10cSrcweir pThis->DrawPixel( Point(x+2, i+2), Color(COL_WHITE) ); 377*cdf0e10cSrcweir i+=4; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir else 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir int width = (int) (0.6 * aSz.Width() + 0.5); 383*cdf0e10cSrcweir int i = (aSz.Width() - width) / 2; 384*cdf0e10cSrcweir width += i; 385*cdf0e10cSrcweir while( i <= width ) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir int y = ImplGetDragWidth(pThis) / 2; 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir pThis->DrawPixel( Point(i, y), rStyleSettings.GetDarkShadowColor() ); 390*cdf0e10cSrcweir pThis->DrawPixel( Point(i+1, y), rStyleSettings.GetShadowColor() ); 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir pThis->DrawPixel( Point(i, y+1), rStyleSettings.GetShadowColor() ); 393*cdf0e10cSrcweir pThis->DrawPixel( Point(i+1, y+1), rStyleSettings.GetFaceColor() ); 394*cdf0e10cSrcweir pThis->DrawPixel( Point(i+2, y+1), Color(COL_WHITE) ); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir pThis->DrawPixel( Point(i+1, y+2), Color(COL_WHITE) ); 397*cdf0e10cSrcweir pThis->DrawPixel( Point(i+2, y+2), Color(COL_WHITE) ); 398*cdf0e10cSrcweir i+=4; 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir void ToolBox::ImplDrawGradientBackground( ToolBox* pThis, ImplDockingWindowWrapper * ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir // draw a nice gradient 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir Color startCol, endCol; 409*cdf0e10cSrcweir startCol = pThis->GetSettings().GetStyleSettings().GetFaceGradientColor(); 410*cdf0e10cSrcweir endCol = pThis->GetSettings().GetStyleSettings().GetFaceColor(); 411*cdf0e10cSrcweir if( pThis->GetSettings().GetStyleSettings().GetHighContrastMode() ) 412*cdf0e10cSrcweir // no 'extreme' gradient when high contrast 413*cdf0e10cSrcweir startCol = endCol; 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir Gradient g; 416*cdf0e10cSrcweir g.SetAngle( pThis->mbHorz ? 0 : 900 ); 417*cdf0e10cSrcweir g.SetStyle( GRADIENT_LINEAR ); 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir g.SetStartColor( startCol ); 420*cdf0e10cSrcweir g.SetEndColor( endCol ); 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir sal_Bool bLineColor = pThis->IsLineColor(); 423*cdf0e10cSrcweir Color aOldCol = pThis->GetLineColor(); 424*cdf0e10cSrcweir pThis->SetLineColor( pThis->GetSettings().GetStyleSettings().GetShadowColor() ); 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir Size aFullSz( pThis->GetOutputSizePixel() ); 427*cdf0e10cSrcweir Size aLineSz( aFullSz ); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir // use the linesize only when floating 430*cdf0e10cSrcweir // full window height is used when docked (single line) 431*cdf0e10cSrcweir if( pThis->ImplIsFloatingMode() ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir long nLineSize; 434*cdf0e10cSrcweir if( pThis->mbHorz ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir nLineSize = pThis->mnMaxItemHeight; 437*cdf0e10cSrcweir if ( pThis->mnWinHeight > pThis->mnMaxItemHeight ) 438*cdf0e10cSrcweir nLineSize = pThis->mnWinHeight; 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir aLineSz.Height() = nLineSize; 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir else 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir nLineSize = pThis->mnMaxItemWidth; 445*cdf0e10cSrcweir aLineSz.Width() = nLineSize; 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir long nLeft, nTop, nRight, nBottom; 450*cdf0e10cSrcweir ImplCalcBorder( pThis->meAlign, nLeft, nTop, nRight, nBottom, pThis ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir Size aTopLineSz( aLineSz ); 453*cdf0e10cSrcweir Size aBottomLineSz( aLineSz ); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_BORDER ) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir if( pThis->mbHorz ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir aTopLineSz.Height() += TB_BORDER_OFFSET2 + nTop; 460*cdf0e10cSrcweir aBottomLineSz.Height() += TB_BORDER_OFFSET2 + nBottom; 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir if( pThis->mnCurLines == 1 ) 463*cdf0e10cSrcweir aTopLineSz.Height() += TB_BORDER_OFFSET2 + nBottom; 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir else 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir aTopLineSz.Width() += TB_BORDER_OFFSET1 + nLeft; 468*cdf0e10cSrcweir aBottomLineSz.Width() += TB_BORDER_OFFSET1 + nRight; 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir if( pThis->mnCurLines == 1 ) 471*cdf0e10cSrcweir aTopLineSz.Width() += TB_BORDER_OFFSET1 + nLeft; 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir if( pThis->mbHorz ) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir aTopLineSz.Height() += pThis->mnBorderY; 478*cdf0e10cSrcweir if( pThis->mnCurLines == 1 ) 479*cdf0e10cSrcweir aTopLineSz.Height() += pThis->mnBorderY; 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir aBottomLineSz.Height() += pThis->mnBorderY; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir else 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir aTopLineSz.Width() += pThis->mnBorderX; 486*cdf0e10cSrcweir if( pThis->mnCurLines == 1 ) 487*cdf0e10cSrcweir aTopLineSz.Width() += pThis->mnBorderX; 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir aBottomLineSz.Width() += pThis->mnBorderX; 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_LINESPACING ) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir if( pThis->mbHorz ) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir aLineSz.Height() += TB_LINESPACING; 498*cdf0e10cSrcweir if( pThis->mnCurLines > 1 ) 499*cdf0e10cSrcweir aTopLineSz.Height() += TB_LINESPACING; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir else 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir aLineSz.Width() += TB_LINESPACING; 504*cdf0e10cSrcweir if( pThis->mnCurLines > 1 ) 505*cdf0e10cSrcweir aTopLineSz.Width() += TB_LINESPACING; 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir if( pThis->mbHorz ) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir long y = 0; 512*cdf0e10cSrcweir sal_Bool bDrawSep = sal_False; // pThis->ImplIsFloatingMode() && ( pThis->mnWinStyle & WB_LINESPACING ); 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir pThis->DrawGradient( Rectangle( 0, y, aTopLineSz.Width(), y+aTopLineSz.Height()), g ); 515*cdf0e10cSrcweir y += aTopLineSz.Height(); 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir if ( bDrawSep ) 518*cdf0e10cSrcweir pThis->DrawLine( Point(0, y-2), Point(aTopLineSz.Width(), y-2) ); 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir while( y < (pThis->mnDY - aBottomLineSz.Height()) ) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir pThis->DrawGradient( Rectangle( 0, y, aLineSz.Width(), y+aLineSz.Height()), g); 523*cdf0e10cSrcweir y += aLineSz.Height(); 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir if ( bDrawSep ) 526*cdf0e10cSrcweir pThis->DrawLine( Point(0, y-2), Point(aLineSz.Width(), y-2) ); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir pThis->DrawGradient( Rectangle( 0, y, aBottomLineSz.Width(), y+aBottomLineSz.Height()), g ); 530*cdf0e10cSrcweir if ( bDrawSep ) 531*cdf0e10cSrcweir pThis->DrawLine( Point(0, y-2), Point(aBottomLineSz.Width(), y-2) ); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir else 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir long x = 0; 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir pThis->DrawGradient( Rectangle( x, 0, x+aTopLineSz.Width(), aTopLineSz.Height()), g ); 538*cdf0e10cSrcweir x += aTopLineSz.Width(); 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir while( x < (pThis->mnDX - aBottomLineSz.Width()) ) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir pThis->DrawGradient( Rectangle( x, 0, x+aLineSz.Width(), aLineSz.Height()), g); 543*cdf0e10cSrcweir x += aLineSz.Width(); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir pThis->DrawGradient( Rectangle( x, 0, x+aBottomLineSz.Width(), aBottomLineSz.Height()), g ); 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir if( bLineColor ) 550*cdf0e10cSrcweir pThis->SetLineColor( aOldCol ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir sal_Bool ToolBox::ImplDrawNativeBackground( ToolBox* pThis, const Region & ) 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir // use NWF 557*cdf0e10cSrcweir Point aPt; 558*cdf0e10cSrcweir Rectangle aCtrlRegion( aPt, pThis->GetOutputSizePixel() ); 559*cdf0e10cSrcweir ControlState nState = CTRL_STATE_ENABLED; 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir return pThis->DrawNativeControl( CTRL_TOOLBAR, pThis->mbHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT, 562*cdf0e10cSrcweir aCtrlRegion, nState, ImplControlValue(), rtl::OUString() ); 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir void ToolBox::ImplDrawTransparentBackground( ToolBox* pThis, const Region &rRegion ) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir // just invalidate to trigger paint of the parent 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir const bool bOldPaintLock = pThis->mpData->mbIsPaintLocked; 570*cdf0e10cSrcweir pThis->mpData->mbIsPaintLocked = true; 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir // send an invalidate to the first opaque parent and invalidate the whole hierarchy from there (noclipchildren) 573*cdf0e10cSrcweir pThis->Invalidate( rRegion, INVALIDATE_UPDATE|INVALIDATE_NOCLIPCHILDREN ); 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir pThis->mpData->mbIsPaintLocked = bOldPaintLock; 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir void ToolBox::ImplDrawConstantBackground( ToolBox* pThis, const Region &rRegion, sal_Bool bIsInPopupMode ) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir // draw a constant color 581*cdf0e10cSrcweir if( !bIsInPopupMode ) 582*cdf0e10cSrcweir // default background 583*cdf0e10cSrcweir pThis->Erase( rRegion.GetBoundRect() ); 584*cdf0e10cSrcweir else 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir // use different color in popupmode 587*cdf0e10cSrcweir pThis->DrawWallpaper( rRegion.GetBoundRect(), 588*cdf0e10cSrcweir Wallpaper( pThis->GetSettings().GetStyleSettings().GetFaceGradientColor() ) ); 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir void ToolBox::ImplDrawBackground( ToolBox* pThis, const Rectangle &rRect ) 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir // execute pending paint requests 596*cdf0e10cSrcweir ImplCheckUpdate( pThis ); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis ); 599*cdf0e10cSrcweir sal_Bool bIsInPopupMode = pThis->ImplIsInPopupMode(); 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir Region aPaintRegion( rRect ); 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir // make sure we do not invalidate/erase too much 604*cdf0e10cSrcweir if( pThis->IsInPaint() ) 605*cdf0e10cSrcweir aPaintRegion.Intersect( pThis->GetActiveClipRegion() ); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir pThis->Push( PUSH_CLIPREGION ); 608*cdf0e10cSrcweir pThis->IntersectClipRegion( aPaintRegion ); 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir if( !pWrapper /*|| bIsInPopupMode*/ ) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir // no gradient for ordinary toolbars (not dockable) 614*cdf0e10cSrcweir if( !pThis->IsBackground() && !pThis->IsInPaint() ) 615*cdf0e10cSrcweir ImplDrawTransparentBackground( pThis, aPaintRegion ); 616*cdf0e10cSrcweir else 617*cdf0e10cSrcweir ImplDrawConstantBackground( pThis, aPaintRegion, bIsInPopupMode ); 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir else 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir // toolbars known to the dockingmanager will be drawn using NWF or a gradient 622*cdf0e10cSrcweir // docked toolbars are transparent and NWF is already used in the docking area which is their common background 623*cdf0e10cSrcweir // so NWF is used here for floating toolbars only 624*cdf0e10cSrcweir sal_Bool bNativeOk = sal_False; 625*cdf0e10cSrcweir if( pThis->ImplIsFloatingMode() && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL) ) 626*cdf0e10cSrcweir bNativeOk = ImplDrawNativeBackground( pThis, aPaintRegion ); 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir if( !bNativeOk ) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir if( !pThis->IsBackground() ) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir if( !pThis->IsInPaint() ) 633*cdf0e10cSrcweir ImplDrawTransparentBackground( pThis, aPaintRegion ); 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir else 636*cdf0e10cSrcweir ImplDrawGradientBackground( pThis, pWrapper ); 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir } 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir // restore clip region 641*cdf0e10cSrcweir pThis->Pop(); 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir void ToolBox::ImplErase( ToolBox* pThis, const Rectangle &rRect, sal_Bool bHighlight, sal_Bool bHasOpenPopup ) 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir // the background of non NWF buttons is painted in a constant color 647*cdf0e10cSrcweir // to have the same highlight color (transparency in DrawSelectionBackground()) 648*cdf0e10cSrcweir // items with open popups will also painted using a constant color 649*cdf0e10cSrcweir if( !pThis->mpData->mbNativeButtons && 650*cdf0e10cSrcweir (bHighlight || ! (((Window*) pThis)->GetStyle() & WB_3DLOOK ) ) ) 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir if( (((Window*) pThis)->GetStyle() & WB_3DLOOK ) ) 653*cdf0e10cSrcweir { 654*cdf0e10cSrcweir pThis->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); 655*cdf0e10cSrcweir pThis->SetLineColor(); 656*cdf0e10cSrcweir if( bHasOpenPopup ) 657*cdf0e10cSrcweir // choose the same color as the popup will use 658*cdf0e10cSrcweir pThis->SetFillColor( pThis->GetSettings().GetStyleSettings().GetFaceGradientColor() ); 659*cdf0e10cSrcweir else 660*cdf0e10cSrcweir pThis->SetFillColor( Color( COL_WHITE ) ); 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir pThis->DrawRect( rRect ); 663*cdf0e10cSrcweir pThis->Pop(); 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir else 666*cdf0e10cSrcweir ImplDrawBackground( pThis, rRect ); 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir else 669*cdf0e10cSrcweir ImplDrawBackground( pThis, rRect ); 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir void ToolBox::ImplDrawBorder( ToolBox* pWin ) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings(); 675*cdf0e10cSrcweir long nDX = pWin->mnDX; 676*cdf0e10cSrcweir long nDY = pWin->mnDY; 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pWin ); 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir // draw borders for ordinary toolbars only (not dockable) 681*cdf0e10cSrcweir if( pWrapper ) 682*cdf0e10cSrcweir return; 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir if ( pWin->meAlign == WINDOWALIGN_BOTTOM ) 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir // draw bottom border 687*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetShadowColor() ); 688*cdf0e10cSrcweir pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) ); 689*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetLightColor() ); 690*cdf0e10cSrcweir pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) ); 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir else 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir // draw top border 695*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetShadowColor() ); 696*cdf0e10cSrcweir pWin->DrawLine( Point( 0, 0 ), Point( nDX-1, 0 ) ); 697*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetLightColor() ); 698*cdf0e10cSrcweir pWin->DrawLine( Point( 0, 1 ), Point( nDX-1, 1 ) ); 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir if ( (pWin->meAlign == WINDOWALIGN_LEFT) || (pWin->meAlign == WINDOWALIGN_RIGHT) ) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir if ( pWin->meAlign == WINDOWALIGN_LEFT ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir // draw left-bottom border 705*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetShadowColor() ); 706*cdf0e10cSrcweir pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) ); 707*cdf0e10cSrcweir pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) ); 708*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetLightColor() ); 709*cdf0e10cSrcweir pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-3 ) ); 710*cdf0e10cSrcweir pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) ); 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir else 713*cdf0e10cSrcweir { 714*cdf0e10cSrcweir // draw right-bottom border 715*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetShadowColor() ); 716*cdf0e10cSrcweir pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-3 ) ); 717*cdf0e10cSrcweir pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-2, nDY-2 ) ); 718*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetLightColor() ); 719*cdf0e10cSrcweir pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) ); 720*cdf0e10cSrcweir pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) ); 721*cdf0e10cSrcweir } 722*cdf0e10cSrcweir } 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir if ( pWin->meAlign == WINDOWALIGN_BOTTOM || pWin->meAlign == WINDOWALIGN_TOP ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir // draw right border 729*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetShadowColor() ); 730*cdf0e10cSrcweir pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-1 ) ); 731*cdf0e10cSrcweir pWin->SetLineColor( rStyleSettings.GetLightColor() ); 732*cdf0e10cSrcweir pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) ); 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir // ----------------------------------------------------------------------- 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir static bool ImplIsFixedControl( const ImplToolItem *pItem ) 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir return ( pItem->mpWindow && 741*cdf0e10cSrcweir (pItem->mpWindow->GetType() == WINDOW_FIXEDTEXT || 742*cdf0e10cSrcweir pItem->mpWindow->GetType() == WINDOW_FIXEDLINE || 743*cdf0e10cSrcweir pItem->mpWindow->GetType() == WINDOW_GROUPBOX) ); 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir // ----------------------------------------------------------------------- 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir const ImplToolItem *ToolBox::ImplGetFirstClippedItem( const ToolBox* pThis ) 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it; 751*cdf0e10cSrcweir it = pThis->mpData->m_aItems.begin(); 752*cdf0e10cSrcweir while ( it != pThis->mpData->m_aItems.end() ) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir if( it->IsClipped() ) 755*cdf0e10cSrcweir return &(*it); 756*cdf0e10cSrcweir ++it; 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir return NULL; 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir // ----------------------------------------------------------------------- 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir Size ToolBox::ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uInt16 nCalcMode ) 764*cdf0e10cSrcweir { 765*cdf0e10cSrcweir long nMax; 766*cdf0e10cSrcweir long nLeft = 0; 767*cdf0e10cSrcweir long nTop = 0; 768*cdf0e10cSrcweir long nRight = 0; 769*cdf0e10cSrcweir long nBottom = 0; 770*cdf0e10cSrcweir Size aSize; 771*cdf0e10cSrcweir WindowAlign eOldAlign = pThis->meAlign; 772*cdf0e10cSrcweir sal_Bool bOldHorz = pThis->mbHorz; 773*cdf0e10cSrcweir sal_Bool bOldAssumeDocked = pThis->mpData->mbAssumeDocked; 774*cdf0e10cSrcweir sal_Bool bOldAssumeFloating = pThis->mpData->mbAssumeFloating; 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir if ( nCalcMode ) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir sal_Bool bOldFloatingMode = pThis->ImplIsFloatingMode(); 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir pThis->mpData->mbAssumeDocked = sal_False; 781*cdf0e10cSrcweir pThis->mpData->mbAssumeFloating = sal_False; 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir if ( nCalcMode == TB_CALCMODE_HORZ ) 784*cdf0e10cSrcweir { 785*cdf0e10cSrcweir pThis->mpData->mbAssumeDocked = sal_True; // force non-floating mode during calculation 786*cdf0e10cSrcweir ImplCalcBorder( WINDOWALIGN_TOP, nLeft, nTop, nRight, nBottom, pThis ); 787*cdf0e10cSrcweir ((ToolBox*)pThis)->mbHorz = sal_True; 788*cdf0e10cSrcweir if ( pThis->mbHorz != bOldHorz ) 789*cdf0e10cSrcweir ((ToolBox*)pThis)->meAlign = WINDOWALIGN_TOP; 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir else if ( nCalcMode == TB_CALCMODE_VERT ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir pThis->mpData->mbAssumeDocked = sal_True; // force non-floating mode during calculation 794*cdf0e10cSrcweir ImplCalcBorder( WINDOWALIGN_LEFT, nLeft, nTop, nRight, nBottom, pThis ); 795*cdf0e10cSrcweir ((ToolBox*)pThis)->mbHorz = sal_False; 796*cdf0e10cSrcweir if ( pThis->mbHorz != bOldHorz ) 797*cdf0e10cSrcweir ((ToolBox*)pThis)->meAlign = WINDOWALIGN_LEFT; 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir else if ( nCalcMode == TB_CALCMODE_FLOAT ) 800*cdf0e10cSrcweir { 801*cdf0e10cSrcweir pThis->mpData->mbAssumeFloating = sal_True; // force non-floating mode during calculation 802*cdf0e10cSrcweir nLeft = nTop = nRight = nBottom = 0; 803*cdf0e10cSrcweir ((ToolBox*)pThis)->mbHorz = sal_True; 804*cdf0e10cSrcweir if ( pThis->mbHorz != bOldHorz ) 805*cdf0e10cSrcweir ((ToolBox*)pThis)->meAlign = WINDOWALIGN_TOP; 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir if ( (pThis->meAlign != eOldAlign) || (pThis->mbHorz != bOldHorz) || 809*cdf0e10cSrcweir (pThis->ImplIsFloatingMode() != bOldFloatingMode ) ) 810*cdf0e10cSrcweir ((ToolBox*)pThis)->mbCalc = sal_True; 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir else 813*cdf0e10cSrcweir ImplCalcBorder( pThis->meAlign, nLeft, nTop, nRight, nBottom, pThis ); 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir ((ToolBox*)pThis)->ImplCalcItem(); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir if( !nCalcMode && pThis->ImplIsFloatingMode() ) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir aSize = ImplCalcFloatSize( ((ToolBox*)pThis), nCalcLines ); 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir else 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir if ( pThis->mbHorz ) 824*cdf0e10cSrcweir { 825*cdf0e10cSrcweir if ( pThis->mnWinHeight > pThis->mnMaxItemHeight ) 826*cdf0e10cSrcweir aSize.Height() = nCalcLines * pThis->mnWinHeight; 827*cdf0e10cSrcweir else 828*cdf0e10cSrcweir aSize.Height() = nCalcLines * pThis->mnMaxItemHeight; 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_LINESPACING ) 831*cdf0e10cSrcweir aSize.Height() += (nCalcLines-1)*TB_LINESPACING; 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_BORDER ) 834*cdf0e10cSrcweir aSize.Height() += (TB_BORDER_OFFSET2*2) + nTop + nBottom; 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir nMax = 0; 837*cdf0e10cSrcweir ((ToolBox*)pThis)->ImplCalcBreaks( TB_MAXNOSCROLL, &nMax, pThis->mbHorz ); 838*cdf0e10cSrcweir if ( nMax ) 839*cdf0e10cSrcweir aSize.Width() += nMax; 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_BORDER ) 842*cdf0e10cSrcweir aSize.Width() += (TB_BORDER_OFFSET1*2) + nLeft + nRight; 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir else 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir aSize.Width() = nCalcLines * pThis->mnMaxItemWidth; 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_LINESPACING ) 849*cdf0e10cSrcweir aSize.Width() += (nCalcLines-1)*TB_LINESPACING; 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_BORDER ) 852*cdf0e10cSrcweir aSize.Width() += (TB_BORDER_OFFSET2*2) + nLeft + nRight; 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir nMax = 0; 855*cdf0e10cSrcweir ((ToolBox*)pThis)->ImplCalcBreaks( TB_MAXNOSCROLL, &nMax, pThis->mbHorz ); 856*cdf0e10cSrcweir if ( nMax ) 857*cdf0e10cSrcweir aSize.Height() += nMax; 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_BORDER ) 860*cdf0e10cSrcweir aSize.Height() += (TB_BORDER_OFFSET1*2) + nTop + nBottom; 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir // restore previous values 864*cdf0e10cSrcweir if ( nCalcMode ) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir pThis->mpData->mbAssumeDocked = bOldAssumeDocked; 867*cdf0e10cSrcweir pThis->mpData->mbAssumeFloating = bOldAssumeFloating; 868*cdf0e10cSrcweir if ( (pThis->meAlign != eOldAlign) || (pThis->mbHorz != bOldHorz) ) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir ((ToolBox*)pThis)->meAlign = eOldAlign; 871*cdf0e10cSrcweir ((ToolBox*)pThis)->mbHorz = bOldHorz; 872*cdf0e10cSrcweir ((ToolBox*)pThis)->mbCalc = sal_True; 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir if ( aSize.Width() ) 877*cdf0e10cSrcweir aSize.Width() += pThis->mnBorderX*2; 878*cdf0e10cSrcweir if ( aSize.Height() ) 879*cdf0e10cSrcweir aSize.Height() += pThis->mnBorderY*2; 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir return aSize; 882*cdf0e10cSrcweir } 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir // ----------------------------------------------------------------------- 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir void ToolBox::ImplCalcFloatSizes( ToolBox* pThis ) 887*cdf0e10cSrcweir { 888*cdf0e10cSrcweir if ( pThis->mpFloatSizeAry ) 889*cdf0e10cSrcweir return; 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir // calculate the minimal size, i.e. where the biggest item just fits 892*cdf0e10cSrcweir long nCalcSize = 0; 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it; 895*cdf0e10cSrcweir it = pThis->mpData->m_aItems.begin(); 896*cdf0e10cSrcweir while ( it != pThis->mpData->m_aItems.end() ) 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir if ( it->mbVisible ) 899*cdf0e10cSrcweir { 900*cdf0e10cSrcweir if ( it->mpWindow ) 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir long nTempSize = it->mpWindow->GetSizePixel().Width(); 903*cdf0e10cSrcweir if ( nTempSize > nCalcSize ) 904*cdf0e10cSrcweir nCalcSize = nTempSize; 905*cdf0e10cSrcweir } 906*cdf0e10cSrcweir else 907*cdf0e10cSrcweir { 908*cdf0e10cSrcweir if( it->maItemSize.Width() > nCalcSize ) 909*cdf0e10cSrcweir nCalcSize = it->maItemSize.Width(); 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir ++it; 913*cdf0e10cSrcweir } 914*cdf0e10cSrcweir 915*cdf0e10cSrcweir // calc an upper bound for ImplCalcBreaks below 916*cdf0e10cSrcweir long upperBoundWidth = nCalcSize * pThis->mpData->m_aItems.size(); 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir sal_uInt16 i; 919*cdf0e10cSrcweir sal_uInt16 nLines; 920*cdf0e10cSrcweir sal_uInt16 nCalcLines; 921*cdf0e10cSrcweir sal_uInt16 nTempLines; 922*cdf0e10cSrcweir long nHeight; 923*cdf0e10cSrcweir long nMaxLineWidth; 924*cdf0e10cSrcweir nCalcLines = pThis->ImplCalcBreaks( nCalcSize, &nMaxLineWidth, sal_True ); 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir pThis->mpFloatSizeAry = new ImplToolSizeArray; 927*cdf0e10cSrcweir pThis->mpFloatSizeAry->mpSize = new ImplToolSize[nCalcLines]; 928*cdf0e10cSrcweir pThis->mpFloatSizeAry->mnLength = nCalcLines; 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir memset( pThis->mpFloatSizeAry->mpSize, 0, sizeof( ImplToolSize )*nCalcLines ); 931*cdf0e10cSrcweir i = 0; 932*cdf0e10cSrcweir nTempLines = nLines = nCalcLines; 933*cdf0e10cSrcweir while ( nLines ) 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir nHeight = ImplCalcSize( pThis, nTempLines, TB_CALCMODE_FLOAT ).Height(); 936*cdf0e10cSrcweir pThis->mpFloatSizeAry->mnLastEntry = i; 937*cdf0e10cSrcweir pThis->mpFloatSizeAry->mpSize[i].mnHeight = nHeight; 938*cdf0e10cSrcweir pThis->mpFloatSizeAry->mpSize[i].mnLines = nTempLines; 939*cdf0e10cSrcweir pThis->mpFloatSizeAry->mpSize[i].mnWidth = nMaxLineWidth+(TB_BORDER_OFFSET1*2); 940*cdf0e10cSrcweir nLines--; 941*cdf0e10cSrcweir if ( nLines ) 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir do 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir nCalcSize += pThis->mnMaxItemWidth; 946*cdf0e10cSrcweir nTempLines = pThis->ImplCalcBreaks( nCalcSize, &nMaxLineWidth, sal_True ); 947*cdf0e10cSrcweir } 948*cdf0e10cSrcweir while ( (nCalcSize < upperBoundWidth) && (nLines < nTempLines) && (nTempLines != 1) ); 949*cdf0e10cSrcweir if ( nTempLines < nLines ) 950*cdf0e10cSrcweir nLines = nTempLines; 951*cdf0e10cSrcweir } 952*cdf0e10cSrcweir i++; 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir } 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir // ----------------------------------------------------------------------- 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir Size ToolBox::ImplCalcFloatSize( ToolBox* pThis, sal_uInt16& rLines ) 959*cdf0e10cSrcweir { 960*cdf0e10cSrcweir ImplCalcFloatSizes( pThis ); 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir if ( !rLines ) 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir rLines = pThis->mnFloatLines; 965*cdf0e10cSrcweir if ( !rLines ) 966*cdf0e10cSrcweir rLines = pThis->mnLines; 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir sal_uInt16 i = 0; 970*cdf0e10cSrcweir while ( i < pThis->mpFloatSizeAry->mnLastEntry && 971*cdf0e10cSrcweir rLines < pThis->mpFloatSizeAry->mpSize[i].mnLines ) 972*cdf0e10cSrcweir i++; 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir Size aSize( pThis->mpFloatSizeAry->mpSize[i].mnWidth, 975*cdf0e10cSrcweir pThis->mpFloatSizeAry->mpSize[i].mnHeight ); 976*cdf0e10cSrcweir rLines = pThis->mpFloatSizeAry->mpSize[i].mnLines; 977*cdf0e10cSrcweir if ( pThis->maNextToolBoxStr.Len() && pThis->mbScroll ) 978*cdf0e10cSrcweir aSize.Width() += TB_NEXT_SIZE-TB_NEXT_OFFSET; 979*cdf0e10cSrcweir return aSize; 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir // ----------------------------------------------------------------------- 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir void ToolBox::ImplCalcMinMaxFloatSize( ToolBox* pThis, Size& rMinSize, Size& rMaxSize ) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir ImplCalcFloatSizes( pThis ); 987*cdf0e10cSrcweir 988*cdf0e10cSrcweir sal_uInt16 i = 0; 989*cdf0e10cSrcweir rMinSize = Size( pThis->mpFloatSizeAry->mpSize[i].mnWidth, pThis->mpFloatSizeAry->mpSize[i].mnHeight ); 990*cdf0e10cSrcweir rMaxSize = Size( pThis->mpFloatSizeAry->mpSize[i].mnWidth, pThis->mpFloatSizeAry->mpSize[i].mnHeight ); 991*cdf0e10cSrcweir while ( ++i <= pThis->mpFloatSizeAry->mnLastEntry ) 992*cdf0e10cSrcweir { 993*cdf0e10cSrcweir if( pThis->mpFloatSizeAry->mpSize[i].mnWidth < rMinSize.Width() ) 994*cdf0e10cSrcweir rMinSize.Width() = pThis->mpFloatSizeAry->mpSize[i].mnWidth; 995*cdf0e10cSrcweir if( pThis->mpFloatSizeAry->mpSize[i].mnHeight < rMinSize.Height() ) 996*cdf0e10cSrcweir rMinSize.Height() = pThis->mpFloatSizeAry->mpSize[i].mnHeight; 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir if( pThis->mpFloatSizeAry->mpSize[i].mnWidth > rMaxSize.Width() ) 999*cdf0e10cSrcweir rMaxSize.Width() = pThis->mpFloatSizeAry->mpSize[i].mnWidth; 1000*cdf0e10cSrcweir if( pThis->mpFloatSizeAry->mpSize[i].mnHeight > rMaxSize.Height() ) 1001*cdf0e10cSrcweir rMaxSize.Height() = pThis->mpFloatSizeAry->mpSize[i].mnHeight; 1002*cdf0e10cSrcweir } 1003*cdf0e10cSrcweir } 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir void ToolBox::ImplSetMinMaxFloatSize( ToolBox *pThis ) 1006*cdf0e10cSrcweir { 1007*cdf0e10cSrcweir ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis ); 1008*cdf0e10cSrcweir Size aMinSize, aMaxSize; 1009*cdf0e10cSrcweir ImplCalcMinMaxFloatSize( pThis, aMinSize, aMaxSize ); 1010*cdf0e10cSrcweir if( pWrapper ) 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir pWrapper->SetMinOutputSizePixel( aMinSize ); 1013*cdf0e10cSrcweir pWrapper->SetMaxOutputSizePixel( aMaxSize ); 1014*cdf0e10cSrcweir pWrapper->ShowTitleButton( TITLE_BUTTON_MENU, ( pThis->GetMenuType() & TOOLBOX_MENUTYPE_CUSTOMIZE) ? sal_True : sal_False ); 1015*cdf0e10cSrcweir } 1016*cdf0e10cSrcweir else 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir // TODO: change SetMinOutputSizePixel to be not inline 1019*cdf0e10cSrcweir pThis->SetMinOutputSizePixel( aMinSize ); 1020*cdf0e10cSrcweir pThis->SetMaxOutputSizePixel( aMaxSize ); 1021*cdf0e10cSrcweir } 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir sal_uInt16 ToolBox::ImplCalcLines( ToolBox* pThis, long nToolSize ) 1028*cdf0e10cSrcweir { 1029*cdf0e10cSrcweir long nLineHeight; 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir if ( pThis->mbHorz ) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir if ( pThis->mnWinHeight > pThis->mnMaxItemHeight ) 1034*cdf0e10cSrcweir nLineHeight = pThis->mnWinHeight; 1035*cdf0e10cSrcweir else 1036*cdf0e10cSrcweir nLineHeight = pThis->mnMaxItemHeight; 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir else 1039*cdf0e10cSrcweir nLineHeight = pThis->mnMaxItemWidth; 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_BORDER ) 1042*cdf0e10cSrcweir nToolSize -= TB_BORDER_OFFSET2*2; 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir if ( pThis->mnWinStyle & WB_LINESPACING ) 1045*cdf0e10cSrcweir { 1046*cdf0e10cSrcweir nLineHeight += TB_LINESPACING; 1047*cdf0e10cSrcweir nToolSize += TB_LINESPACING; 1048*cdf0e10cSrcweir } 1049*cdf0e10cSrcweir 1050*cdf0e10cSrcweir // #i91917# always report at least one line 1051*cdf0e10cSrcweir long nLines = nToolSize/nLineHeight; 1052*cdf0e10cSrcweir if( nLines < 1 ) 1053*cdf0e10cSrcweir nLines = 1; 1054*cdf0e10cSrcweir 1055*cdf0e10cSrcweir return static_cast<sal_uInt16>(nLines); 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1059*cdf0e10cSrcweir 1060*cdf0e10cSrcweir sal_uInt16 ToolBox::ImplTestLineSize( ToolBox* pThis, const Point& rPos ) 1061*cdf0e10cSrcweir { 1062*cdf0e10cSrcweir if ( !pThis->ImplIsFloatingMode() && 1063*cdf0e10cSrcweir (!pThis->mbScroll || (pThis->mnLines > 1) || (pThis->mnCurLines > pThis->mnVisLines)) ) 1064*cdf0e10cSrcweir { 1065*cdf0e10cSrcweir WindowAlign eAlign = pThis->GetAlign(); 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir if ( eAlign == WINDOWALIGN_LEFT ) 1068*cdf0e10cSrcweir { 1069*cdf0e10cSrcweir if ( rPos.X() > pThis->mnDX-DOCK_LINEOFFSET ) 1070*cdf0e10cSrcweir return DOCK_LINEHSIZE | DOCK_LINERIGHT; 1071*cdf0e10cSrcweir } 1072*cdf0e10cSrcweir else if ( eAlign == WINDOWALIGN_TOP ) 1073*cdf0e10cSrcweir { 1074*cdf0e10cSrcweir if ( rPos.Y() > pThis->mnDY-DOCK_LINEOFFSET ) 1075*cdf0e10cSrcweir return DOCK_LINEVSIZE | DOCK_LINEBOTTOM; 1076*cdf0e10cSrcweir } 1077*cdf0e10cSrcweir else if ( eAlign == WINDOWALIGN_RIGHT ) 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir if ( rPos.X() < DOCK_LINEOFFSET ) 1080*cdf0e10cSrcweir return DOCK_LINEHSIZE | DOCK_LINELEFT; 1081*cdf0e10cSrcweir } 1082*cdf0e10cSrcweir else if ( eAlign == WINDOWALIGN_BOTTOM ) 1083*cdf0e10cSrcweir { 1084*cdf0e10cSrcweir if ( rPos.Y() < DOCK_LINEOFFSET ) 1085*cdf0e10cSrcweir return DOCK_LINEVSIZE | DOCK_LINETOP; 1086*cdf0e10cSrcweir } 1087*cdf0e10cSrcweir } 1088*cdf0e10cSrcweir 1089*cdf0e10cSrcweir return 0; 1090*cdf0e10cSrcweir } 1091*cdf0e10cSrcweir 1092*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir void ToolBox::ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRect, 1095*cdf0e10cSrcweir sal_uInt16 nLineMode ) 1096*cdf0e10cSrcweir { 1097*cdf0e10cSrcweir sal_Bool mbHorz; 1098*cdf0e10cSrcweir long nOneLineSize; 1099*cdf0e10cSrcweir long nCurSize; 1100*cdf0e10cSrcweir long nMaxSize; 1101*cdf0e10cSrcweir long nSize; 1102*cdf0e10cSrcweir Size aSize; 1103*cdf0e10cSrcweir 1104*cdf0e10cSrcweir if ( nLineMode & DOCK_LINERIGHT ) 1105*cdf0e10cSrcweir { 1106*cdf0e10cSrcweir nCurSize = rPos.X() - rRect.Left(); 1107*cdf0e10cSrcweir mbHorz = sal_False; 1108*cdf0e10cSrcweir } 1109*cdf0e10cSrcweir else if ( nLineMode & DOCK_LINEBOTTOM ) 1110*cdf0e10cSrcweir { 1111*cdf0e10cSrcweir nCurSize = rPos.Y() - rRect.Top(); 1112*cdf0e10cSrcweir mbHorz = sal_True; 1113*cdf0e10cSrcweir } 1114*cdf0e10cSrcweir else if ( nLineMode & DOCK_LINELEFT ) 1115*cdf0e10cSrcweir { 1116*cdf0e10cSrcweir nCurSize = rRect.Right() - rPos.X(); 1117*cdf0e10cSrcweir mbHorz = sal_False; 1118*cdf0e10cSrcweir } 1119*cdf0e10cSrcweir else if ( nLineMode & DOCK_LINETOP ) 1120*cdf0e10cSrcweir { 1121*cdf0e10cSrcweir nCurSize = rRect.Bottom() - rPos.Y(); 1122*cdf0e10cSrcweir mbHorz = sal_True; 1123*cdf0e10cSrcweir } 1124*cdf0e10cSrcweir else { 1125*cdf0e10cSrcweir DBG_ERROR( "ImplLineSizing: Trailing else" ); 1126*cdf0e10cSrcweir nCurSize = 0; 1127*cdf0e10cSrcweir mbHorz = sal_False; 1128*cdf0e10cSrcweir } 1129*cdf0e10cSrcweir 1130*cdf0e10cSrcweir Size aWinSize = pThis->GetSizePixel(); 1131*cdf0e10cSrcweir sal_uInt16 nMaxLines = (pThis->mnLines > pThis->mnCurLines) ? pThis->mnLines : pThis->mnCurLines; 1132*cdf0e10cSrcweir if ( nMaxLines > TB_MAXLINES ) 1133*cdf0e10cSrcweir nMaxLines = TB_MAXLINES; 1134*cdf0e10cSrcweir if ( mbHorz ) 1135*cdf0e10cSrcweir { 1136*cdf0e10cSrcweir nOneLineSize = ImplCalcSize( pThis, 1 ).Height(); 1137*cdf0e10cSrcweir nMaxSize = pThis->maOutDockRect.GetHeight() - 20; 1138*cdf0e10cSrcweir if ( nMaxSize < aWinSize.Height() ) 1139*cdf0e10cSrcweir nMaxSize = aWinSize.Height(); 1140*cdf0e10cSrcweir } 1141*cdf0e10cSrcweir else 1142*cdf0e10cSrcweir { 1143*cdf0e10cSrcweir nOneLineSize = ImplCalcSize( pThis, 1 ).Width(); 1144*cdf0e10cSrcweir nMaxSize = pThis->maOutDockRect.GetWidth() - 20; 1145*cdf0e10cSrcweir if ( nMaxSize < aWinSize.Width() ) 1146*cdf0e10cSrcweir nMaxSize = aWinSize.Width(); 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir sal_uInt16 i = 1; 1150*cdf0e10cSrcweir if ( nCurSize <= nOneLineSize ) 1151*cdf0e10cSrcweir nSize = nOneLineSize; 1152*cdf0e10cSrcweir else 1153*cdf0e10cSrcweir { 1154*cdf0e10cSrcweir nSize = 0; 1155*cdf0e10cSrcweir while ( (nSize < nCurSize) && (i < nMaxLines) ) 1156*cdf0e10cSrcweir { 1157*cdf0e10cSrcweir i++; 1158*cdf0e10cSrcweir aSize = ImplCalcSize( pThis, i ); 1159*cdf0e10cSrcweir if ( mbHorz ) 1160*cdf0e10cSrcweir nSize = aSize.Height(); 1161*cdf0e10cSrcweir else 1162*cdf0e10cSrcweir nSize = aSize.Width(); 1163*cdf0e10cSrcweir if ( nSize > nMaxSize ) 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir i--; 1166*cdf0e10cSrcweir aSize = ImplCalcSize( pThis, i ); 1167*cdf0e10cSrcweir if ( mbHorz ) 1168*cdf0e10cSrcweir nSize = aSize.Height(); 1169*cdf0e10cSrcweir else 1170*cdf0e10cSrcweir nSize = aSize.Width(); 1171*cdf0e10cSrcweir break; 1172*cdf0e10cSrcweir } 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir } 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir if ( nLineMode & DOCK_LINERIGHT ) 1177*cdf0e10cSrcweir rRect.Right() = rRect.Left()+nSize-1; 1178*cdf0e10cSrcweir else if ( nLineMode & DOCK_LINEBOTTOM ) 1179*cdf0e10cSrcweir rRect.Bottom() = rRect.Top()+nSize-1; 1180*cdf0e10cSrcweir else if ( nLineMode & DOCK_LINELEFT ) 1181*cdf0e10cSrcweir rRect.Left() = rRect.Right()-nSize; 1182*cdf0e10cSrcweir else //if ( nLineMode & DOCK_LINETOP ) 1183*cdf0e10cSrcweir rRect.Top() = rRect.Bottom()-nSize; 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir pThis->mnDockLines = i; 1186*cdf0e10cSrcweir } 1187*cdf0e10cSrcweir 1188*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1189*cdf0e10cSrcweir 1190*cdf0e10cSrcweir sal_uInt16 ToolBox::ImplFindItemPos( ToolBox* pBox, const Point& rPos ) 1191*cdf0e10cSrcweir { 1192*cdf0e10cSrcweir sal_uInt16 nPos = 0; 1193*cdf0e10cSrcweir long nLast = 0; 1194*cdf0e10cSrcweir Point aPos = rPos; 1195*cdf0e10cSrcweir Size aSize( pBox->mnDX, pBox->mnDY ); 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir if ( aPos.X() > aSize.Width()-TB_BORDER_OFFSET1 ) 1198*cdf0e10cSrcweir aPos.X() = aSize.Width()-TB_BORDER_OFFSET1; 1199*cdf0e10cSrcweir if ( aPos.Y() > aSize.Height()-TB_BORDER_OFFSET1 ) 1200*cdf0e10cSrcweir aPos.Y() = aSize.Height()-TB_BORDER_OFFSET1; 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir // Item suchen, das geklickt wurde 1203*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = pBox->mpData->m_aItems.begin(); 1204*cdf0e10cSrcweir while ( it != pBox->mpData->m_aItems.end() ) 1205*cdf0e10cSrcweir { 1206*cdf0e10cSrcweir if ( it->mbVisible ) 1207*cdf0e10cSrcweir { 1208*cdf0e10cSrcweir if ( nLast || !it->maRect.IsEmpty() ) 1209*cdf0e10cSrcweir { 1210*cdf0e10cSrcweir if ( pBox->mbHorz ) 1211*cdf0e10cSrcweir { 1212*cdf0e10cSrcweir if ( nLast && 1213*cdf0e10cSrcweir ((nLast < it->maRect.Top()) || it->maRect.IsEmpty()) ) 1214*cdf0e10cSrcweir return nPos; 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir if ( aPos.Y() <= it->maRect.Bottom() ) 1217*cdf0e10cSrcweir { 1218*cdf0e10cSrcweir if ( aPos.X() < it->maRect.Left() ) 1219*cdf0e10cSrcweir return nPos; 1220*cdf0e10cSrcweir else if ( aPos.X() < it->maRect.Right() ) 1221*cdf0e10cSrcweir return nPos+1; 1222*cdf0e10cSrcweir else if ( !nLast ) 1223*cdf0e10cSrcweir nLast = it->maRect.Bottom(); 1224*cdf0e10cSrcweir } 1225*cdf0e10cSrcweir } 1226*cdf0e10cSrcweir else 1227*cdf0e10cSrcweir { 1228*cdf0e10cSrcweir if ( nLast && 1229*cdf0e10cSrcweir ((nLast < it->maRect.Left()) || it->maRect.IsEmpty()) ) 1230*cdf0e10cSrcweir return nPos; 1231*cdf0e10cSrcweir 1232*cdf0e10cSrcweir if ( aPos.X() <= it->maRect.Right() ) 1233*cdf0e10cSrcweir { 1234*cdf0e10cSrcweir if ( aPos.Y() < it->maRect.Top() ) 1235*cdf0e10cSrcweir return nPos; 1236*cdf0e10cSrcweir else if ( aPos.Y() < it->maRect.Bottom() ) 1237*cdf0e10cSrcweir return nPos+1; 1238*cdf0e10cSrcweir else if ( !nLast ) 1239*cdf0e10cSrcweir nLast = it->maRect.Right(); 1240*cdf0e10cSrcweir } 1241*cdf0e10cSrcweir } 1242*cdf0e10cSrcweir } 1243*cdf0e10cSrcweir } 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir nPos++; 1246*cdf0e10cSrcweir ++it; 1247*cdf0e10cSrcweir } 1248*cdf0e10cSrcweir 1249*cdf0e10cSrcweir return nPos; 1250*cdf0e10cSrcweir } 1251*cdf0e10cSrcweir 1252*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1253*cdf0e10cSrcweir 1254*cdf0e10cSrcweir ImplTBDragMgr::ImplTBDragMgr() 1255*cdf0e10cSrcweir { 1256*cdf0e10cSrcweir mpBoxList = new ImplTBList( 4, 4 ); 1257*cdf0e10cSrcweir mnLineMode = 0; 1258*cdf0e10cSrcweir mnStartLines = 0; 1259*cdf0e10cSrcweir mbCustomizeMode = sal_False; 1260*cdf0e10cSrcweir mbResizeMode = sal_False; 1261*cdf0e10cSrcweir mbShowDragRect = sal_False; 1262*cdf0e10cSrcweir mpDragBox = NULL; 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir maAccel.InsertItem( KEY_RETURN, KeyCode( KEY_RETURN ) ); 1265*cdf0e10cSrcweir maAccel.InsertItem( KEY_ESCAPE, KeyCode( KEY_ESCAPE ) ); 1266*cdf0e10cSrcweir maAccel.SetSelectHdl( LINK( this, ImplTBDragMgr, SelectHdl ) ); 1267*cdf0e10cSrcweir } 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1270*cdf0e10cSrcweir 1271*cdf0e10cSrcweir ImplTBDragMgr::~ImplTBDragMgr() 1272*cdf0e10cSrcweir { 1273*cdf0e10cSrcweir delete mpBoxList; 1274*cdf0e10cSrcweir } 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1277*cdf0e10cSrcweir 1278*cdf0e10cSrcweir ToolBox* ImplTBDragMgr::FindToolBox( const Rectangle& rRect ) 1279*cdf0e10cSrcweir { 1280*cdf0e10cSrcweir ToolBox* pBox = mpBoxList->First(); 1281*cdf0e10cSrcweir while ( pBox ) 1282*cdf0e10cSrcweir { 1283*cdf0e10cSrcweir /* 1284*cdf0e10cSrcweir * FIXME: since we can have multiple frames now we cannot 1285*cdf0e10cSrcweir * find the drag target by its position alone. 1286*cdf0e10cSrcweir * As long as the toolbar config dialogue is not a system window 1287*cdf0e10cSrcweir * this works in one frame only anyway. If the dialogue 1288*cdf0e10cSrcweir * changes to a system window, we need a new implementation here 1289*cdf0e10cSrcweir */ 1290*cdf0e10cSrcweir if ( pBox->IsReallyVisible() && pBox->ImplGetWindowImpl()->mpFrame == mpDragBox->ImplGetWindowImpl()->mpFrame ) 1291*cdf0e10cSrcweir { 1292*cdf0e10cSrcweir if ( !pBox->ImplIsFloatingMode() ) 1293*cdf0e10cSrcweir { 1294*cdf0e10cSrcweir Point aPos = pBox->GetPosPixel(); 1295*cdf0e10cSrcweir aPos = pBox->GetParent()->OutputToScreenPixel( aPos ); 1296*cdf0e10cSrcweir Rectangle aTempRect( aPos, pBox->GetSizePixel() ); 1297*cdf0e10cSrcweir if ( aTempRect.IsOver( rRect ) ) 1298*cdf0e10cSrcweir return pBox; 1299*cdf0e10cSrcweir } 1300*cdf0e10cSrcweir } 1301*cdf0e10cSrcweir 1302*cdf0e10cSrcweir pBox = mpBoxList->Next(); 1303*cdf0e10cSrcweir } 1304*cdf0e10cSrcweir 1305*cdf0e10cSrcweir return pBox; 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1309*cdf0e10cSrcweir 1310*cdf0e10cSrcweir void ImplTBDragMgr::StartDragging( ToolBox* pToolBox, 1311*cdf0e10cSrcweir const Point& rPos, const Rectangle& rRect, 1312*cdf0e10cSrcweir sal_uInt16 nDragLineMode, sal_Bool bResizeItem, 1313*cdf0e10cSrcweir void* pData ) 1314*cdf0e10cSrcweir { 1315*cdf0e10cSrcweir mpDragBox = pToolBox; 1316*cdf0e10cSrcweir pToolBox->CaptureMouse(); 1317*cdf0e10cSrcweir pToolBox->mbDragging = sal_True; 1318*cdf0e10cSrcweir Application::InsertAccel( &maAccel ); 1319*cdf0e10cSrcweir 1320*cdf0e10cSrcweir if ( nDragLineMode ) 1321*cdf0e10cSrcweir { 1322*cdf0e10cSrcweir mnLineMode = nDragLineMode; 1323*cdf0e10cSrcweir mnStartLines = pToolBox->mnDockLines; 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir else 1326*cdf0e10cSrcweir { 1327*cdf0e10cSrcweir mpCustomizeData = pData; 1328*cdf0e10cSrcweir mbResizeMode = bResizeItem; 1329*cdf0e10cSrcweir pToolBox->Activate(); 1330*cdf0e10cSrcweir pToolBox->mnCurItemId = pToolBox->mnConfigItem; 1331*cdf0e10cSrcweir pToolBox->Highlight(); 1332*cdf0e10cSrcweir pToolBox->mnCurItemId = 0; 1333*cdf0e10cSrcweir if ( mbResizeMode ) 1334*cdf0e10cSrcweir { 1335*cdf0e10cSrcweir if ( rRect.GetWidth() < TB_MIN_WIN_WIDTH ) 1336*cdf0e10cSrcweir mnMinWidth = rRect.GetWidth(); 1337*cdf0e10cSrcweir else 1338*cdf0e10cSrcweir mnMinWidth = TB_MIN_WIN_WIDTH; 1339*cdf0e10cSrcweir mnMaxWidth = pToolBox->GetSizePixel().Width()-rRect.Left()- 1340*cdf0e10cSrcweir TB_SPIN_SIZE-TB_BORDER_OFFSET1-(TB_SPIN_OFFSET*2); 1341*cdf0e10cSrcweir } 1342*cdf0e10cSrcweir } 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir // MouseOffset berechnen 1345*cdf0e10cSrcweir maMouseOff.X() = rRect.Left() - rPos.X(); 1346*cdf0e10cSrcweir maMouseOff.Y() = rRect.Top() - rPos.Y(); 1347*cdf0e10cSrcweir maRect = rRect; 1348*cdf0e10cSrcweir maStartRect = rRect; 1349*cdf0e10cSrcweir mbShowDragRect = sal_True; 1350*cdf0e10cSrcweir pToolBox->ShowTracking( maRect ); 1351*cdf0e10cSrcweir } 1352*cdf0e10cSrcweir 1353*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1354*cdf0e10cSrcweir 1355*cdf0e10cSrcweir void ImplTBDragMgr::Dragging( const Point& rPos ) 1356*cdf0e10cSrcweir { 1357*cdf0e10cSrcweir if ( mnLineMode ) 1358*cdf0e10cSrcweir { 1359*cdf0e10cSrcweir ToolBox::ImplLineSizing( mpDragBox, rPos, maRect, mnLineMode ); 1360*cdf0e10cSrcweir Point aOff = mpDragBox->OutputToScreenPixel( Point() ); 1361*cdf0e10cSrcweir maRect.Move( aOff.X(), aOff.Y() ); 1362*cdf0e10cSrcweir mpDragBox->Docking( rPos, maRect ); 1363*cdf0e10cSrcweir maRect.Move( -aOff.X(), -aOff.Y() ); 1364*cdf0e10cSrcweir mpDragBox->ShowTracking( maRect ); 1365*cdf0e10cSrcweir } 1366*cdf0e10cSrcweir else 1367*cdf0e10cSrcweir { 1368*cdf0e10cSrcweir if ( mbResizeMode ) 1369*cdf0e10cSrcweir { 1370*cdf0e10cSrcweir long nXOff = rPos.X()-maStartRect.Left(); 1371*cdf0e10cSrcweir nXOff += maMouseOff.X()+(maStartRect.Right()-maStartRect.Left()); 1372*cdf0e10cSrcweir if ( nXOff < mnMinWidth ) 1373*cdf0e10cSrcweir nXOff = mnMinWidth; 1374*cdf0e10cSrcweir if ( nXOff > mnMaxWidth ) 1375*cdf0e10cSrcweir nXOff = mnMaxWidth; 1376*cdf0e10cSrcweir maRect.Right() = maStartRect.Left()+nXOff; 1377*cdf0e10cSrcweir } 1378*cdf0e10cSrcweir else 1379*cdf0e10cSrcweir { 1380*cdf0e10cSrcweir maRect.SetPos( rPos ); 1381*cdf0e10cSrcweir maRect.Move( maMouseOff.X(), maMouseOff.Y() ); 1382*cdf0e10cSrcweir } 1383*cdf0e10cSrcweir mpDragBox->ShowTracking( maRect ); 1384*cdf0e10cSrcweir } 1385*cdf0e10cSrcweir } 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1388*cdf0e10cSrcweir 1389*cdf0e10cSrcweir void ImplTBDragMgr::EndDragging( sal_Bool bOK ) 1390*cdf0e10cSrcweir { 1391*cdf0e10cSrcweir mpDragBox->HideTracking(); 1392*cdf0e10cSrcweir mpDragBox->ReleaseMouse(); 1393*cdf0e10cSrcweir mpDragBox->mbDragging = sal_False; 1394*cdf0e10cSrcweir mbShowDragRect = sal_False; 1395*cdf0e10cSrcweir Application::RemoveAccel( &maAccel ); 1396*cdf0e10cSrcweir 1397*cdf0e10cSrcweir if ( mnLineMode ) 1398*cdf0e10cSrcweir { 1399*cdf0e10cSrcweir if ( !bOK ) 1400*cdf0e10cSrcweir { 1401*cdf0e10cSrcweir mpDragBox->mnDockLines = mnStartLines; 1402*cdf0e10cSrcweir mpDragBox->EndDocking( maStartRect, sal_False ); 1403*cdf0e10cSrcweir } 1404*cdf0e10cSrcweir else 1405*cdf0e10cSrcweir mpDragBox->EndDocking( maRect, sal_False ); 1406*cdf0e10cSrcweir mnLineMode = 0; 1407*cdf0e10cSrcweir mnStartLines = 0; 1408*cdf0e10cSrcweir } 1409*cdf0e10cSrcweir else 1410*cdf0e10cSrcweir { 1411*cdf0e10cSrcweir sal_uInt16 nTempItem = mpDragBox->mnConfigItem; 1412*cdf0e10cSrcweir if ( nTempItem ) 1413*cdf0e10cSrcweir { 1414*cdf0e10cSrcweir mpDragBox->mnConfigItem = 0; 1415*cdf0e10cSrcweir if ( !mbResizeMode ) 1416*cdf0e10cSrcweir mpDragBox->Invalidate( mpDragBox->GetItemRect( nTempItem ) ); 1417*cdf0e10cSrcweir } 1418*cdf0e10cSrcweir 1419*cdf0e10cSrcweir if ( bOK && (maRect != maStartRect) ) 1420*cdf0e10cSrcweir { 1421*cdf0e10cSrcweir if ( mbResizeMode ) 1422*cdf0e10cSrcweir { 1423*cdf0e10cSrcweir ImplToolItem* pItem = mpDragBox->ImplGetItem( nTempItem ); 1424*cdf0e10cSrcweir Size aSize = pItem->mpWindow->GetSizePixel(); 1425*cdf0e10cSrcweir aSize.Width() = maRect.GetWidth(); 1426*cdf0e10cSrcweir pItem->mpWindow->SetSizePixel( aSize ); 1427*cdf0e10cSrcweir 1428*cdf0e10cSrcweir // ToolBox neu brechnen und neu ausgeben 1429*cdf0e10cSrcweir mpDragBox->ImplInvalidate( sal_True ); 1430*cdf0e10cSrcweir mpDragBox->Customize( ToolBoxCustomizeEvent( mpDragBox, nTempItem, 1431*cdf0e10cSrcweir TOOLBOX_CUSTOMIZE_RESIZE, 1432*cdf0e10cSrcweir mpCustomizeData ) ); 1433*cdf0e10cSrcweir } 1434*cdf0e10cSrcweir else 1435*cdf0e10cSrcweir { 1436*cdf0e10cSrcweir Point aOff = mpDragBox->OutputToScreenPixel( Point() ); 1437*cdf0e10cSrcweir Rectangle aScreenRect( maRect ); 1438*cdf0e10cSrcweir aScreenRect.Move( aOff.X(), aOff.Y() ); 1439*cdf0e10cSrcweir ToolBox* pDropBox = FindToolBox( aScreenRect ); 1440*cdf0e10cSrcweir if ( pDropBox ) 1441*cdf0e10cSrcweir { 1442*cdf0e10cSrcweir // Such-Position bestimmen 1443*cdf0e10cSrcweir Point aPos; 1444*cdf0e10cSrcweir if ( pDropBox->mbHorz ) 1445*cdf0e10cSrcweir { 1446*cdf0e10cSrcweir aPos.X() = aScreenRect.Left()-TB_CUSTOMIZE_OFFSET; 1447*cdf0e10cSrcweir aPos.Y() = aScreenRect.Center().Y(); 1448*cdf0e10cSrcweir } 1449*cdf0e10cSrcweir else 1450*cdf0e10cSrcweir { 1451*cdf0e10cSrcweir aPos.X() = aScreenRect.Center().X(); 1452*cdf0e10cSrcweir aPos.Y() = aScreenRect.Top()-TB_CUSTOMIZE_OFFSET; 1453*cdf0e10cSrcweir } 1454*cdf0e10cSrcweir 1455*cdf0e10cSrcweir aPos = pDropBox->ScreenToOutputPixel( aPos ); 1456*cdf0e10cSrcweir sal_uInt16 nPos = ToolBox::ImplFindItemPos( pDropBox, aPos ); 1457*cdf0e10cSrcweir mpDragBox->Customize( ToolBoxCustomizeEvent( pDropBox, nTempItem, 1458*cdf0e10cSrcweir nPos, mpCustomizeData ) ); 1459*cdf0e10cSrcweir } 1460*cdf0e10cSrcweir else 1461*cdf0e10cSrcweir { 1462*cdf0e10cSrcweir mpDragBox->Customize( ToolBoxCustomizeEvent( NULL, nTempItem, 1463*cdf0e10cSrcweir 0, mpCustomizeData ) ); 1464*cdf0e10cSrcweir } 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir } 1467*cdf0e10cSrcweir mpCustomizeData = NULL; 1468*cdf0e10cSrcweir mbResizeMode = sal_False; 1469*cdf0e10cSrcweir mpDragBox->Deactivate(); 1470*cdf0e10cSrcweir } 1471*cdf0e10cSrcweir 1472*cdf0e10cSrcweir mpDragBox = NULL; 1473*cdf0e10cSrcweir } 1474*cdf0e10cSrcweir 1475*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1476*cdf0e10cSrcweir 1477*cdf0e10cSrcweir void ImplTBDragMgr::UpdateDragRect() 1478*cdf0e10cSrcweir { 1479*cdf0e10cSrcweir // Nur Updaten, wenn wir schon im Dragging sind 1480*cdf0e10cSrcweir if ( !mbShowDragRect ) 1481*cdf0e10cSrcweir return; 1482*cdf0e10cSrcweir 1483*cdf0e10cSrcweir mpDragBox->ShowTracking( maRect ); 1484*cdf0e10cSrcweir } 1485*cdf0e10cSrcweir 1486*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1487*cdf0e10cSrcweir 1488*cdf0e10cSrcweir IMPL_LINK( ImplTBDragMgr, SelectHdl, Accelerator*, pAccel ) 1489*cdf0e10cSrcweir { 1490*cdf0e10cSrcweir if ( pAccel->GetCurItemId() == KEY_ESCAPE ) 1491*cdf0e10cSrcweir EndDragging( sal_False ); 1492*cdf0e10cSrcweir else 1493*cdf0e10cSrcweir EndDragging( sal_True ); 1494*cdf0e10cSrcweir 1495*cdf0e10cSrcweir return sal_True; 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir 1498*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1499*cdf0e10cSrcweir 1500*cdf0e10cSrcweir void ImplTBDragMgr::StartCustomizeMode() 1501*cdf0e10cSrcweir { 1502*cdf0e10cSrcweir mbCustomizeMode = sal_True; 1503*cdf0e10cSrcweir 1504*cdf0e10cSrcweir ToolBox* pBox = mpBoxList->First(); 1505*cdf0e10cSrcweir while ( pBox ) 1506*cdf0e10cSrcweir { 1507*cdf0e10cSrcweir pBox->ImplStartCustomizeMode(); 1508*cdf0e10cSrcweir pBox = mpBoxList->Next(); 1509*cdf0e10cSrcweir } 1510*cdf0e10cSrcweir } 1511*cdf0e10cSrcweir 1512*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1513*cdf0e10cSrcweir 1514*cdf0e10cSrcweir void ImplTBDragMgr::EndCustomizeMode() 1515*cdf0e10cSrcweir { 1516*cdf0e10cSrcweir mbCustomizeMode = sal_False; 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir ToolBox* pBox = mpBoxList->First(); 1519*cdf0e10cSrcweir while ( pBox ) 1520*cdf0e10cSrcweir { 1521*cdf0e10cSrcweir pBox->ImplEndCustomizeMode(); 1522*cdf0e10cSrcweir pBox = mpBoxList->Next(); 1523*cdf0e10cSrcweir } 1524*cdf0e10cSrcweir } 1525*cdf0e10cSrcweir 1526*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1527*cdf0e10cSrcweir 1528*cdf0e10cSrcweir 1529*cdf0e10cSrcweir static void ImplDrawOutButton( OutputDevice* pOutDev, const Rectangle& rRect, 1530*cdf0e10cSrcweir sal_uInt16 nStyle ) 1531*cdf0e10cSrcweir { 1532*cdf0e10cSrcweir const StyleSettings& rStyleSettings = pOutDev->GetSettings().GetStyleSettings(); 1533*cdf0e10cSrcweir Color aShadowColor = rStyleSettings.GetShadowColor(); 1534*cdf0e10cSrcweir Point aPos( rRect.TopLeft() ); 1535*cdf0e10cSrcweir Size aSize( rRect.GetSize() ); 1536*cdf0e10cSrcweir long nOffset = 0; 1537*cdf0e10cSrcweir 1538*cdf0e10cSrcweir if ( pOutDev->GetBackground().GetColor() == aShadowColor ) 1539*cdf0e10cSrcweir aShadowColor = rStyleSettings.GetDarkShadowColor(); 1540*cdf0e10cSrcweir 1541*cdf0e10cSrcweir if ( nStyle & BUTTON_DRAW_PRESSED ) 1542*cdf0e10cSrcweir { 1543*cdf0e10cSrcweir aPos.X()++; 1544*cdf0e10cSrcweir aPos.Y()++; 1545*cdf0e10cSrcweir nOffset++; 1546*cdf0e10cSrcweir } 1547*cdf0e10cSrcweir 1548*cdf0e10cSrcweir // Hintergrund loeschen 1549*cdf0e10cSrcweir pOutDev->Erase( rRect ); 1550*cdf0e10cSrcweir 1551*cdf0e10cSrcweir // Button zeichnen 1552*cdf0e10cSrcweir pOutDev->SetLineColor( rStyleSettings.GetLightColor() ); 1553*cdf0e10cSrcweir pOutDev->DrawLine( aPos, 1554*cdf0e10cSrcweir Point( aPos.X()+aSize.Width()-OUTBUTTON_BORDER, aPos.Y() ) ); 1555*cdf0e10cSrcweir pOutDev->DrawLine( aPos, 1556*cdf0e10cSrcweir Point( aPos.X(), aPos.Y()+aSize.Height()-OUTBUTTON_BORDER ) ); 1557*cdf0e10cSrcweir pOutDev->SetLineColor( aShadowColor ); 1558*cdf0e10cSrcweir pOutDev->DrawLine( Point( aPos.X()+aSize.Width()-OUTBUTTON_BORDER, aPos.Y() ), 1559*cdf0e10cSrcweir Point( aPos.X()+aSize.Width()-OUTBUTTON_BORDER, aPos.Y()+aSize.Height()-OUTBUTTON_BORDER ) ); 1560*cdf0e10cSrcweir pOutDev->DrawLine( Point( aPos.X(), aPos.Y()+aSize.Height()-OUTBUTTON_BORDER ), 1561*cdf0e10cSrcweir Point( aPos.X()+aSize.Width()-OUTBUTTON_BORDER, aPos.Y()+aSize.Height()-OUTBUTTON_BORDER ) ); 1562*cdf0e10cSrcweir for ( long i = 0; i < OUTBUTTON_BORDER-1-nOffset; i++ ) 1563*cdf0e10cSrcweir { 1564*cdf0e10cSrcweir pOutDev->DrawLine( Point( aPos.X()+aSize.Width()-(OUTBUTTON_BORDER-i-1), aPos.Y()+OUTBUTTON_BORDER ), 1565*cdf0e10cSrcweir Point( aPos.X()+aSize.Width()-(OUTBUTTON_BORDER-i-1), aPos.Y()+aSize.Height()-1 ) ); 1566*cdf0e10cSrcweir pOutDev->DrawLine( Point( aPos.X()+OUTBUTTON_BORDER, aPos.Y()+aSize.Height()-(OUTBUTTON_BORDER-i-1) ), 1567*cdf0e10cSrcweir Point( aPos.X()+aSize.Width()-1, aPos.Y()+aSize.Height()-(OUTBUTTON_BORDER-i-1) ) ); 1568*cdf0e10cSrcweir } 1569*cdf0e10cSrcweir } 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir 1572*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1573*cdf0e10cSrcweir 1574*cdf0e10cSrcweir void ToolBox::ImplInit( Window* pParent, WinBits nStyle ) 1575*cdf0e10cSrcweir { 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir // Variablen initialisieren 1578*cdf0e10cSrcweir ImplGetWindowImpl()->mbToolBox = sal_True; 1579*cdf0e10cSrcweir mpBtnDev = NULL; 1580*cdf0e10cSrcweir mpFloatSizeAry = NULL; 1581*cdf0e10cSrcweir mpData = new ImplToolBoxPrivateData; 1582*cdf0e10cSrcweir mpFloatWin = NULL; 1583*cdf0e10cSrcweir mnDX = 0; 1584*cdf0e10cSrcweir mnDY = 0; 1585*cdf0e10cSrcweir mnMaxItemWidth = 0; 1586*cdf0e10cSrcweir mnMaxItemHeight = 0; 1587*cdf0e10cSrcweir mnWinHeight = 0; 1588*cdf0e10cSrcweir mnBorderX = 0; 1589*cdf0e10cSrcweir mnBorderY = 0; 1590*cdf0e10cSrcweir mnLeftBorder = 0; 1591*cdf0e10cSrcweir mnTopBorder = 0; 1592*cdf0e10cSrcweir mnRightBorder = 0; 1593*cdf0e10cSrcweir mnBottomBorder = 0; 1594*cdf0e10cSrcweir mnLastResizeDY = 0; 1595*cdf0e10cSrcweir mnOutStyle = TOOLBOX_STYLE_FLAT; // force flat buttons since NWF 1596*cdf0e10cSrcweir mnHighItemId = 0; 1597*cdf0e10cSrcweir mnCurItemId = 0; 1598*cdf0e10cSrcweir mnDownItemId = 0; 1599*cdf0e10cSrcweir mnCurPos = TOOLBOX_ITEM_NOTFOUND; 1600*cdf0e10cSrcweir mnFocusPos = TOOLBOX_ITEM_NOTFOUND; // current position during keyboard access 1601*cdf0e10cSrcweir mnLines = 1; 1602*cdf0e10cSrcweir mnCurLine = 1; 1603*cdf0e10cSrcweir mnCurLines = 1; 1604*cdf0e10cSrcweir mnVisLines = 1; 1605*cdf0e10cSrcweir mnFloatLines = 0; 1606*cdf0e10cSrcweir mnConfigItem = 0; 1607*cdf0e10cSrcweir mnMouseClicks = 0; 1608*cdf0e10cSrcweir mnMouseModifier = 0; 1609*cdf0e10cSrcweir mbDrag = sal_False; 1610*cdf0e10cSrcweir mbSelection = sal_False; 1611*cdf0e10cSrcweir mbCommandDrag = sal_False; 1612*cdf0e10cSrcweir mbUpper = sal_False; 1613*cdf0e10cSrcweir mbLower = sal_False; 1614*cdf0e10cSrcweir mbNextTool = sal_False; 1615*cdf0e10cSrcweir mbIn = sal_False; 1616*cdf0e10cSrcweir mbCalc = sal_True; 1617*cdf0e10cSrcweir mbFormat = sal_False; 1618*cdf0e10cSrcweir mbFullPaint = sal_False; 1619*cdf0e10cSrcweir mbHorz = sal_True; 1620*cdf0e10cSrcweir mbScroll = (nStyle & WB_SCROLL) != 0; 1621*cdf0e10cSrcweir mbCustomize = sal_False; 1622*cdf0e10cSrcweir mbCustomizeMode = sal_False; 1623*cdf0e10cSrcweir mbDragging = sal_False; 1624*cdf0e10cSrcweir mbHideStatusText = sal_False; 1625*cdf0e10cSrcweir mbMenuStrings = sal_False; 1626*cdf0e10cSrcweir mbIsShift = sal_False; 1627*cdf0e10cSrcweir mbIsKeyEvent = sal_False; 1628*cdf0e10cSrcweir mbChangingHighlight = sal_False; 1629*cdf0e10cSrcweir meButtonType = BUTTON_SYMBOL; 1630*cdf0e10cSrcweir meAlign = WINDOWALIGN_TOP; 1631*cdf0e10cSrcweir meLastStyle = POINTER_ARROW; 1632*cdf0e10cSrcweir mnWinStyle = nStyle; 1633*cdf0e10cSrcweir mnLastFocusItemId = 0; 1634*cdf0e10cSrcweir mnKeyModifier = 0; 1635*cdf0e10cSrcweir mnActivateCount = 0; 1636*cdf0e10cSrcweir 1637*cdf0e10cSrcweir maTimer.SetTimeout( 50 ); 1638*cdf0e10cSrcweir maTimer.SetTimeoutHdl( LINK( this, ToolBox, ImplUpdateHdl ) ); 1639*cdf0e10cSrcweir 1640*cdf0e10cSrcweir // set timeout and handler for dropdown items 1641*cdf0e10cSrcweir mpData->maDropdownTimer.SetTimeout( 250 ); 1642*cdf0e10cSrcweir mpData->maDropdownTimer.SetTimeoutHdl( LINK( this, ToolBox, ImplDropdownLongClickHdl ) ); 1643*cdf0e10cSrcweir 1644*cdf0e10cSrcweir DockingWindow::ImplInit( pParent, nStyle & ~(WB_BORDER) ); 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir 1647*cdf0e10cSrcweir // always set WB_TABSTOP for ToolBars !!! if( mnWinStyle & WB_TABSTOP ) 1648*cdf0e10cSrcweir { 1649*cdf0e10cSrcweir // dockingwindow's ImplInit removes some bits, so restore them here 1650*cdf0e10cSrcweir // to allow keyboard handling for toolbars 1651*cdf0e10cSrcweir ImplGetWindowImpl()->mnStyle |= WB_TABSTOP|WB_NODIALOGCONTROL; 1652*cdf0e10cSrcweir ImplGetWindowImpl()->mnStyle &= ~WB_DIALOGCONTROL; 1653*cdf0e10cSrcweir } 1654*cdf0e10cSrcweir 1655*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 1656*cdf0e10cSrcweir } 1657*cdf0e10cSrcweir 1658*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1659*cdf0e10cSrcweir 1660*cdf0e10cSrcweir void ToolBox::ImplInitSettings( sal_Bool bFont, 1661*cdf0e10cSrcweir sal_Bool bForeground, sal_Bool bBackground ) 1662*cdf0e10cSrcweir { 1663*cdf0e10cSrcweir mpData->mbNativeButtons = IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ); 1664*cdf0e10cSrcweir 1665*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 1666*cdf0e10cSrcweir 1667*cdf0e10cSrcweir if ( bFont ) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir Font aFont = rStyleSettings.GetToolFont(); 1670*cdf0e10cSrcweir if ( IsControlFont() ) 1671*cdf0e10cSrcweir aFont.Merge( GetControlFont() ); 1672*cdf0e10cSrcweir SetZoomedPointFont( aFont ); 1673*cdf0e10cSrcweir } 1674*cdf0e10cSrcweir 1675*cdf0e10cSrcweir if ( bForeground || bFont ) 1676*cdf0e10cSrcweir { 1677*cdf0e10cSrcweir Color aColor; 1678*cdf0e10cSrcweir if ( IsControlForeground() ) 1679*cdf0e10cSrcweir aColor = GetControlForeground(); 1680*cdf0e10cSrcweir else if ( Window::GetStyle() & WB_3DLOOK ) 1681*cdf0e10cSrcweir aColor = rStyleSettings.GetButtonTextColor(); 1682*cdf0e10cSrcweir else 1683*cdf0e10cSrcweir aColor = rStyleSettings.GetWindowTextColor(); 1684*cdf0e10cSrcweir SetTextColor( aColor ); 1685*cdf0e10cSrcweir SetTextFillColor(); 1686*cdf0e10cSrcweir } 1687*cdf0e10cSrcweir 1688*cdf0e10cSrcweir if ( bBackground ) 1689*cdf0e10cSrcweir { 1690*cdf0e10cSrcweir Color aColor; 1691*cdf0e10cSrcweir if ( IsControlBackground() ) 1692*cdf0e10cSrcweir { 1693*cdf0e10cSrcweir aColor = GetControlBackground(); 1694*cdf0e10cSrcweir SetBackground( aColor ); 1695*cdf0e10cSrcweir SetPaintTransparent( sal_False ); 1696*cdf0e10cSrcweir SetParentClipMode( 0 ); 1697*cdf0e10cSrcweir } 1698*cdf0e10cSrcweir else 1699*cdf0e10cSrcweir { 1700*cdf0e10cSrcweir if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) ) 1701*cdf0e10cSrcweir { 1702*cdf0e10cSrcweir SetBackground(); 1703*cdf0e10cSrcweir SetPaintTransparent( sal_True ); 1704*cdf0e10cSrcweir SetParentClipMode( PARENTCLIPMODE_NOCLIP ); 1705*cdf0e10cSrcweir mpData->maDisplayBackground = Wallpaper( rStyleSettings.GetFaceColor() ); 1706*cdf0e10cSrcweir } 1707*cdf0e10cSrcweir else 1708*cdf0e10cSrcweir { 1709*cdf0e10cSrcweir if ( Window::GetStyle() & WB_3DLOOK ) 1710*cdf0e10cSrcweir aColor = rStyleSettings.GetFaceColor(); 1711*cdf0e10cSrcweir else 1712*cdf0e10cSrcweir aColor = rStyleSettings.GetWindowColor(); 1713*cdf0e10cSrcweir 1714*cdf0e10cSrcweir SetBackground( aColor ); 1715*cdf0e10cSrcweir SetPaintTransparent( sal_False ); 1716*cdf0e10cSrcweir SetParentClipMode( 0 ); 1717*cdf0e10cSrcweir 1718*cdf0e10cSrcweir ImplUpdateImageList(); 1719*cdf0e10cSrcweir } 1720*cdf0e10cSrcweir } 1721*cdf0e10cSrcweir } 1722*cdf0e10cSrcweir } 1723*cdf0e10cSrcweir 1724*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1725*cdf0e10cSrcweir 1726*cdf0e10cSrcweir void ToolBox::ImplLoadRes( const ResId& rResId ) 1727*cdf0e10cSrcweir { 1728*cdf0e10cSrcweir ResMgr* pMgr = rResId.GetResMgr(); 1729*cdf0e10cSrcweir if( ! pMgr ) 1730*cdf0e10cSrcweir return; 1731*cdf0e10cSrcweir 1732*cdf0e10cSrcweir DockingWindow::ImplLoadRes( rResId ); 1733*cdf0e10cSrcweir 1734*cdf0e10cSrcweir sal_uLong nObjMask; 1735*cdf0e10cSrcweir 1736*cdf0e10cSrcweir nObjMask = ReadLongRes(); 1737*cdf0e10cSrcweir 1738*cdf0e10cSrcweir if ( nObjMask & RSC_TOOLBOX_BUTTONTYPE ) 1739*cdf0e10cSrcweir SetButtonType( (ButtonType)ReadLongRes() ); 1740*cdf0e10cSrcweir 1741*cdf0e10cSrcweir if ( nObjMask & RSC_TOOLBOX_ALIGN ) 1742*cdf0e10cSrcweir SetAlign( (WindowAlign)ReadLongRes() ); 1743*cdf0e10cSrcweir 1744*cdf0e10cSrcweir if ( nObjMask & RSC_TOOLBOX_LINECOUNT ) 1745*cdf0e10cSrcweir SetLineCount( sal::static_int_cast<sal_uInt16>(ReadLongRes()) ); 1746*cdf0e10cSrcweir 1747*cdf0e10cSrcweir if ( nObjMask & RSC_TOOLBOX_CUSTOMIZE ) 1748*cdf0e10cSrcweir { 1749*cdf0e10cSrcweir sal_Bool bCust = (sal_Bool)ReadShortRes(); 1750*cdf0e10cSrcweir EnableCustomize( bCust ); 1751*cdf0e10cSrcweir } 1752*cdf0e10cSrcweir 1753*cdf0e10cSrcweir if ( nObjMask & RSC_TOOLBOX_MENUSTRINGS ) 1754*cdf0e10cSrcweir { 1755*cdf0e10cSrcweir sal_Bool bCust = (sal_Bool)ReadShortRes(); 1756*cdf0e10cSrcweir EnableMenuStrings( bCust ); 1757*cdf0e10cSrcweir } 1758*cdf0e10cSrcweir 1759*cdf0e10cSrcweir if ( nObjMask & RSC_TOOLBOX_FLOATLINES ) 1760*cdf0e10cSrcweir SetFloatingLines( ReadShortRes() ); 1761*cdf0e10cSrcweir 1762*cdf0e10cSrcweir if ( nObjMask & RSC_TOOLBOX_ITEMIMAGELIST ) 1763*cdf0e10cSrcweir { 1764*cdf0e10cSrcweir maImageList = ImageList( ResId( (RSHEADER_TYPE*)GetClassRes(), *pMgr ) ); 1765*cdf0e10cSrcweir IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) ); 1766*cdf0e10cSrcweir } 1767*cdf0e10cSrcweir 1768*cdf0e10cSrcweir if ( nObjMask & RSC_TOOLBOX_ITEMLIST ) 1769*cdf0e10cSrcweir { 1770*cdf0e10cSrcweir sal_uLong nEle = ReadLongRes(); 1771*cdf0e10cSrcweir 1772*cdf0e10cSrcweir // Item hinzufuegen 1773*cdf0e10cSrcweir for ( sal_uLong i = 0; i < nEle; i++ ) 1774*cdf0e10cSrcweir { 1775*cdf0e10cSrcweir InsertItem( ResId( (RSHEADER_TYPE *)GetClassRes(), *pMgr ) ); 1776*cdf0e10cSrcweir IncrementRes( GetObjSizeRes( (RSHEADER_TYPE *)GetClassRes() ) ); 1777*cdf0e10cSrcweir } 1778*cdf0e10cSrcweir } 1779*cdf0e10cSrcweir } 1780*cdf0e10cSrcweir 1781*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1782*cdf0e10cSrcweir 1783*cdf0e10cSrcweir ToolBox::ToolBox( Window* pParent, WinBits nStyle ) : 1784*cdf0e10cSrcweir DockingWindow( WINDOW_TOOLBOX ) 1785*cdf0e10cSrcweir { 1786*cdf0e10cSrcweir ImplInit( pParent, nStyle ); 1787*cdf0e10cSrcweir } 1788*cdf0e10cSrcweir 1789*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1790*cdf0e10cSrcweir 1791*cdf0e10cSrcweir ToolBox::ToolBox( Window* pParent, const ResId& rResId ) : 1792*cdf0e10cSrcweir DockingWindow( WINDOW_TOOLBOX ) 1793*cdf0e10cSrcweir { 1794*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "vcl: ToolBox::ToolBox( Window* pParent, const ResId& rResId )" ); 1795*cdf0e10cSrcweir 1796*cdf0e10cSrcweir rResId.SetRT( RSC_TOOLBOX ); 1797*cdf0e10cSrcweir WinBits nStyle = ImplInitRes( rResId ); 1798*cdf0e10cSrcweir ImplInit( pParent, nStyle ); 1799*cdf0e10cSrcweir ImplLoadRes( rResId ); 1800*cdf0e10cSrcweir 1801*cdf0e10cSrcweir // Groesse des FloatingWindows berechnen und umschalten, wenn die 1802*cdf0e10cSrcweir // ToolBox initial im FloatingModus ist 1803*cdf0e10cSrcweir if ( ImplIsFloatingMode() ) 1804*cdf0e10cSrcweir mbHorz = sal_True; 1805*cdf0e10cSrcweir else 1806*cdf0e10cSrcweir Resize(); 1807*cdf0e10cSrcweir 1808*cdf0e10cSrcweir if ( !(nStyle & WB_HIDE) ) 1809*cdf0e10cSrcweir Show(); 1810*cdf0e10cSrcweir } 1811*cdf0e10cSrcweir 1812*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1813*cdf0e10cSrcweir 1814*cdf0e10cSrcweir ToolBox::~ToolBox() 1815*cdf0e10cSrcweir { 1816*cdf0e10cSrcweir // custom menu event still running? 1817*cdf0e10cSrcweir if( mpData->mnEventId ) 1818*cdf0e10cSrcweir Application::RemoveUserEvent( mpData->mnEventId ); 1819*cdf0e10cSrcweir 1820*cdf0e10cSrcweir // #103005# make sure our activate/deactivate balance is right 1821*cdf0e10cSrcweir while( mnActivateCount > 0 ) 1822*cdf0e10cSrcweir Deactivate(); 1823*cdf0e10cSrcweir 1824*cdf0e10cSrcweir // Falls noch ein Floating-Window connected ist, dann den 1825*cdf0e10cSrcweir // PopupModus beenden 1826*cdf0e10cSrcweir if ( mpFloatWin ) 1827*cdf0e10cSrcweir mpFloatWin->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL ); 1828*cdf0e10cSrcweir 1829*cdf0e10cSrcweir // delete private data 1830*cdf0e10cSrcweir delete mpData; 1831*cdf0e10cSrcweir 1832*cdf0e10cSrcweir // FloatSizeAry gegebenenfalls loeschen 1833*cdf0e10cSrcweir if ( mpFloatSizeAry ) 1834*cdf0e10cSrcweir delete mpFloatSizeAry; 1835*cdf0e10cSrcweir 1836*cdf0e10cSrcweir // Wenn keine ToolBox-Referenzen mehr auf die Listen bestehen, dann 1837*cdf0e10cSrcweir // Listen mit wegloeschen 1838*cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1839*cdf0e10cSrcweir if ( pSVData->maCtrlData.mpTBDragMgr ) 1840*cdf0e10cSrcweir { 1841*cdf0e10cSrcweir // Wenn im TBDrag-Manager, dann wieder rausnehmen 1842*cdf0e10cSrcweir if ( mbCustomize ) 1843*cdf0e10cSrcweir pSVData->maCtrlData.mpTBDragMgr->Remove( this ); 1844*cdf0e10cSrcweir 1845*cdf0e10cSrcweir if ( !pSVData->maCtrlData.mpTBDragMgr->Count() ) 1846*cdf0e10cSrcweir { 1847*cdf0e10cSrcweir delete pSVData->maCtrlData.mpTBDragMgr; 1848*cdf0e10cSrcweir pSVData->maCtrlData.mpTBDragMgr = NULL; 1849*cdf0e10cSrcweir } 1850*cdf0e10cSrcweir } 1851*cdf0e10cSrcweir } 1852*cdf0e10cSrcweir 1853*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1854*cdf0e10cSrcweir 1855*cdf0e10cSrcweir ImplToolItem* ToolBox::ImplGetItem( sal_uInt16 nItemId ) const 1856*cdf0e10cSrcweir { 1857*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin(); 1858*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 1859*cdf0e10cSrcweir { 1860*cdf0e10cSrcweir if ( it->mnId == nItemId ) 1861*cdf0e10cSrcweir return &(*it); 1862*cdf0e10cSrcweir ++it; 1863*cdf0e10cSrcweir } 1864*cdf0e10cSrcweir 1865*cdf0e10cSrcweir return NULL; 1866*cdf0e10cSrcweir } 1867*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1868*cdf0e10cSrcweir 1869*cdf0e10cSrcweir static void ImplAddButtonBorder( long &rWidth, long& rHeight, sal_uInt16 aOutStyle, sal_Bool bNativeButtons ) 1870*cdf0e10cSrcweir { 1871*cdf0e10cSrcweir if ( aOutStyle & TOOLBOX_STYLE_OUTBUTTON ) 1872*cdf0e10cSrcweir { 1873*cdf0e10cSrcweir rWidth += OUTBUTTON_SIZE; 1874*cdf0e10cSrcweir rHeight += OUTBUTTON_SIZE; 1875*cdf0e10cSrcweir } 1876*cdf0e10cSrcweir else 1877*cdf0e10cSrcweir { 1878*cdf0e10cSrcweir rWidth += SMALLBUTTON_HSIZE; 1879*cdf0e10cSrcweir rHeight += SMALLBUTTON_VSIZE; 1880*cdf0e10cSrcweir } 1881*cdf0e10cSrcweir 1882*cdf0e10cSrcweir if( bNativeButtons ) 1883*cdf0e10cSrcweir { 1884*cdf0e10cSrcweir // give more border space for rounded buttons 1885*cdf0e10cSrcweir rWidth += 2; 1886*cdf0e10cSrcweir rHeight += 4; 1887*cdf0e10cSrcweir } 1888*cdf0e10cSrcweir } 1889*cdf0e10cSrcweir 1890*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1891*cdf0e10cSrcweir 1892*cdf0e10cSrcweir sal_Bool ToolBox::ImplCalcItem() 1893*cdf0e10cSrcweir { 1894*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1895*cdf0e10cSrcweir 1896*cdf0e10cSrcweir // recalc required ? 1897*cdf0e10cSrcweir if ( !mbCalc ) 1898*cdf0e10cSrcweir return sal_False; 1899*cdf0e10cSrcweir 1900*cdf0e10cSrcweir ImplDisableFlatButtons(); 1901*cdf0e10cSrcweir 1902*cdf0e10cSrcweir long nDefWidth; 1903*cdf0e10cSrcweir long nDefHeight; 1904*cdf0e10cSrcweir long nMaxWidth = 0; 1905*cdf0e10cSrcweir long nMaxHeight = 0; 1906*cdf0e10cSrcweir long nHeight; 1907*cdf0e10cSrcweir long nMinWidth = 6; 1908*cdf0e10cSrcweir long nMinHeight = 6; 1909*cdf0e10cSrcweir long nDropDownArrowWidth = TB_DROPDOWNARROWWIDTH; 1910*cdf0e10cSrcweir 1911*cdf0e10cSrcweir // set defaults if image or text is needed but empty 1912*cdf0e10cSrcweir nDefWidth = GetDefaultImageSize().Width(); 1913*cdf0e10cSrcweir nDefHeight = GetDefaultImageSize().Height(); 1914*cdf0e10cSrcweir 1915*cdf0e10cSrcweir mnWinHeight = 0; 1916*cdf0e10cSrcweir // determine minimum size necessary in NWF 1917*cdf0e10cSrcweir { 1918*cdf0e10cSrcweir Rectangle aRect( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) ); 1919*cdf0e10cSrcweir Rectangle aReg( aRect ); 1920*cdf0e10cSrcweir ImplControlValue aVal; 1921*cdf0e10cSrcweir Rectangle aNativeBounds, aNativeContent; 1922*cdf0e10cSrcweir if( IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) 1923*cdf0e10cSrcweir { 1924*cdf0e10cSrcweir if( GetNativeControlRegion( CTRL_TOOLBAR, PART_BUTTON, 1925*cdf0e10cSrcweir aReg, 1926*cdf0e10cSrcweir CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER, 1927*cdf0e10cSrcweir aVal, OUString(), 1928*cdf0e10cSrcweir aNativeBounds, aNativeContent ) ) 1929*cdf0e10cSrcweir { 1930*cdf0e10cSrcweir aRect = aNativeBounds; 1931*cdf0e10cSrcweir if( aRect.GetWidth() > nMinWidth ) 1932*cdf0e10cSrcweir nMinWidth = aRect.GetWidth(); 1933*cdf0e10cSrcweir if( aRect.GetHeight() > nMinHeight ) 1934*cdf0e10cSrcweir nMinHeight = aRect.GetHeight(); 1935*cdf0e10cSrcweir if( nDropDownArrowWidth < nMinWidth ) 1936*cdf0e10cSrcweir nDropDownArrowWidth = nMinWidth; 1937*cdf0e10cSrcweir if( nMinWidth > mpData->mnMenuButtonWidth ) 1938*cdf0e10cSrcweir mpData->mnMenuButtonWidth = nMinWidth; 1939*cdf0e10cSrcweir else if( nMinWidth < TB_MENUBUTTON_SIZE ) 1940*cdf0e10cSrcweir mpData->mnMenuButtonWidth = TB_MENUBUTTON_SIZE; 1941*cdf0e10cSrcweir } 1942*cdf0e10cSrcweir } 1943*cdf0e10cSrcweir 1944*cdf0e10cSrcweir // also calculate the area for comboboxes, drop down list boxes and spinfields 1945*cdf0e10cSrcweir // as these are often inserted into toolboxes; set mnWinHeight to the 1946*cdf0e10cSrcweir // greater of those values to prevent toolbar flickering (#i103385#) 1947*cdf0e10cSrcweir aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) ); 1948*cdf0e10cSrcweir aReg = aRect; 1949*cdf0e10cSrcweir if( GetNativeControlRegion( CTRL_COMBOBOX, PART_ENTIRE_CONTROL, 1950*cdf0e10cSrcweir aReg, 1951*cdf0e10cSrcweir CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER, 1952*cdf0e10cSrcweir aVal, OUString(), 1953*cdf0e10cSrcweir aNativeBounds, aNativeContent ) ) 1954*cdf0e10cSrcweir { 1955*cdf0e10cSrcweir aRect = aNativeBounds; 1956*cdf0e10cSrcweir if( aRect.GetHeight() > mnWinHeight ) 1957*cdf0e10cSrcweir mnWinHeight = aRect.GetHeight(); 1958*cdf0e10cSrcweir } 1959*cdf0e10cSrcweir aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) ); 1960*cdf0e10cSrcweir aReg = aRect; 1961*cdf0e10cSrcweir if( GetNativeControlRegion( CTRL_LISTBOX, PART_ENTIRE_CONTROL, 1962*cdf0e10cSrcweir aReg, 1963*cdf0e10cSrcweir CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER, 1964*cdf0e10cSrcweir aVal, OUString(), 1965*cdf0e10cSrcweir aNativeBounds, aNativeContent ) ) 1966*cdf0e10cSrcweir { 1967*cdf0e10cSrcweir aRect = aNativeBounds; 1968*cdf0e10cSrcweir if( aRect.GetHeight() > mnWinHeight ) 1969*cdf0e10cSrcweir mnWinHeight = aRect.GetHeight(); 1970*cdf0e10cSrcweir } 1971*cdf0e10cSrcweir aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) ); 1972*cdf0e10cSrcweir aReg = aRect; 1973*cdf0e10cSrcweir if( GetNativeControlRegion( CTRL_SPINBOX, PART_ENTIRE_CONTROL, 1974*cdf0e10cSrcweir aReg, 1975*cdf0e10cSrcweir CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER, 1976*cdf0e10cSrcweir aVal, OUString(), 1977*cdf0e10cSrcweir aNativeBounds, aNativeContent ) ) 1978*cdf0e10cSrcweir { 1979*cdf0e10cSrcweir aRect = aNativeBounds; 1980*cdf0e10cSrcweir if( aRect.GetHeight() > mnWinHeight ) 1981*cdf0e10cSrcweir mnWinHeight = aRect.GetHeight(); 1982*cdf0e10cSrcweir } 1983*cdf0e10cSrcweir } 1984*cdf0e10cSrcweir 1985*cdf0e10cSrcweir if ( ! mpData->m_aItems.empty() ) 1986*cdf0e10cSrcweir { 1987*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin(); 1988*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 1989*cdf0e10cSrcweir { 1990*cdf0e10cSrcweir sal_Bool bImage; 1991*cdf0e10cSrcweir sal_Bool bText; 1992*cdf0e10cSrcweir 1993*cdf0e10cSrcweir it->mbVisibleText = sal_False; // indicates if text will definitely be drawn, influences dropdown pos 1994*cdf0e10cSrcweir 1995*cdf0e10cSrcweir if ( it->meType == TOOLBOXITEM_BUTTON ) 1996*cdf0e10cSrcweir { 1997*cdf0e10cSrcweir // check if image and/or text exists 1998*cdf0e10cSrcweir if ( !(it->maImage) ) 1999*cdf0e10cSrcweir bImage = sal_False; 2000*cdf0e10cSrcweir else 2001*cdf0e10cSrcweir bImage = sal_True; 2002*cdf0e10cSrcweir if ( !it->maText.Len() ) 2003*cdf0e10cSrcweir bText = sal_False; 2004*cdf0e10cSrcweir else 2005*cdf0e10cSrcweir bText = sal_True; 2006*cdf0e10cSrcweir ButtonType tmpButtonType = determineButtonType( &(*it), meButtonType ); // default to toolbox setting 2007*cdf0e10cSrcweir if ( bImage || bText ) 2008*cdf0e10cSrcweir { 2009*cdf0e10cSrcweir 2010*cdf0e10cSrcweir it->mbEmptyBtn = sal_False; 2011*cdf0e10cSrcweir 2012*cdf0e10cSrcweir if ( tmpButtonType == BUTTON_SYMBOL ) 2013*cdf0e10cSrcweir { 2014*cdf0e10cSrcweir // we're drawing images only 2015*cdf0e10cSrcweir if ( bImage || !bText ) 2016*cdf0e10cSrcweir { 2017*cdf0e10cSrcweir it->maItemSize = it->maImage.GetSizePixel(); 2018*cdf0e10cSrcweir } 2019*cdf0e10cSrcweir else 2020*cdf0e10cSrcweir { 2021*cdf0e10cSrcweir it->maItemSize = Size( GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET, 2022*cdf0e10cSrcweir GetTextHeight() ); 2023*cdf0e10cSrcweir it->mbVisibleText = sal_True; 2024*cdf0e10cSrcweir } 2025*cdf0e10cSrcweir } 2026*cdf0e10cSrcweir else if ( tmpButtonType == BUTTON_TEXT ) 2027*cdf0e10cSrcweir { 2028*cdf0e10cSrcweir // we're drawing text only 2029*cdf0e10cSrcweir if ( bText || !bImage ) 2030*cdf0e10cSrcweir { 2031*cdf0e10cSrcweir it->maItemSize = Size( GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET, 2032*cdf0e10cSrcweir GetTextHeight() ); 2033*cdf0e10cSrcweir it->mbVisibleText = sal_True; 2034*cdf0e10cSrcweir } 2035*cdf0e10cSrcweir else 2036*cdf0e10cSrcweir { 2037*cdf0e10cSrcweir it->maItemSize = it->maImage.GetSizePixel(); 2038*cdf0e10cSrcweir } 2039*cdf0e10cSrcweir } 2040*cdf0e10cSrcweir else 2041*cdf0e10cSrcweir { 2042*cdf0e10cSrcweir // we're drawing images and text 2043*cdf0e10cSrcweir it->maItemSize.Width() = bText ? GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET : 0; 2044*cdf0e10cSrcweir it->maItemSize.Height() = bText ? GetTextHeight() : 0; 2045*cdf0e10cSrcweir 2046*cdf0e10cSrcweir // leave space between image and text 2047*cdf0e10cSrcweir if( bText ) 2048*cdf0e10cSrcweir it->maItemSize.Width() += TB_IMAGETEXTOFFSET; 2049*cdf0e10cSrcweir 2050*cdf0e10cSrcweir // image and text side by side 2051*cdf0e10cSrcweir it->maItemSize.Width() += it->maImage.GetSizePixel().Width(); 2052*cdf0e10cSrcweir if ( it->maImage.GetSizePixel().Height() > it->maItemSize.Height() ) 2053*cdf0e10cSrcweir it->maItemSize.Height() = it->maImage.GetSizePixel().Height(); 2054*cdf0e10cSrcweir 2055*cdf0e10cSrcweir it->mbVisibleText = bText; 2056*cdf0e10cSrcweir } 2057*cdf0e10cSrcweir } 2058*cdf0e10cSrcweir else 2059*cdf0e10cSrcweir { // no image and no text 2060*cdf0e10cSrcweir it->maItemSize = Size( nDefWidth, nDefHeight ); 2061*cdf0e10cSrcweir it->mbEmptyBtn = sal_True; 2062*cdf0e10cSrcweir } 2063*cdf0e10cSrcweir 2064*cdf0e10cSrcweir // Gegebenenfalls die Fensterhoehe mit beruecksichtigen 2065*cdf0e10cSrcweir if ( it->mpWindow ) 2066*cdf0e10cSrcweir { 2067*cdf0e10cSrcweir nHeight = it->mpWindow->GetSizePixel().Height(); 2068*cdf0e10cSrcweir if ( nHeight > mnWinHeight ) 2069*cdf0e10cSrcweir mnWinHeight = nHeight; 2070*cdf0e10cSrcweir } 2071*cdf0e10cSrcweir 2072*cdf0e10cSrcweir // add in drop down arrow 2073*cdf0e10cSrcweir if( it->mnBits & TIB_DROPDOWN ) 2074*cdf0e10cSrcweir { 2075*cdf0e10cSrcweir it->maItemSize.Width() += nDropDownArrowWidth; 2076*cdf0e10cSrcweir it->mnDropDownArrowWidth = nDropDownArrowWidth; 2077*cdf0e10cSrcweir } 2078*cdf0e10cSrcweir 2079*cdf0e10cSrcweir // text items will be rotated in vertical mode 2080*cdf0e10cSrcweir // -> swap width and height 2081*cdf0e10cSrcweir if( it->mbVisibleText && !mbHorz ) 2082*cdf0e10cSrcweir { 2083*cdf0e10cSrcweir long tmp = it->maItemSize.Width(); 2084*cdf0e10cSrcweir it->maItemSize.Width() = it->maItemSize.Height(); 2085*cdf0e10cSrcweir it->maItemSize.Height() = tmp; 2086*cdf0e10cSrcweir } 2087*cdf0e10cSrcweir } 2088*cdf0e10cSrcweir else if ( it->meType == TOOLBOXITEM_SPACE ) 2089*cdf0e10cSrcweir { 2090*cdf0e10cSrcweir it->maItemSize = Size( nDefWidth, nDefHeight ); 2091*cdf0e10cSrcweir } 2092*cdf0e10cSrcweir 2093*cdf0e10cSrcweir if ( it->meType == TOOLBOXITEM_BUTTON || it->meType == TOOLBOXITEM_SPACE ) 2094*cdf0e10cSrcweir { 2095*cdf0e10cSrcweir // add borders 2096*cdf0e10cSrcweir ImplAddButtonBorder( it->maItemSize.Width(), it->maItemSize.Height(), mnOutStyle, mpData->mbNativeButtons ); 2097*cdf0e10cSrcweir 2098*cdf0e10cSrcweir if( it->meType == TOOLBOXITEM_BUTTON ) 2099*cdf0e10cSrcweir { 2100*cdf0e10cSrcweir if( it->maItemSize.Width() < nMinWidth ) 2101*cdf0e10cSrcweir it->maItemSize.Width() = nMinWidth; 2102*cdf0e10cSrcweir if( it->maItemSize.Height() < nMinHeight ) 2103*cdf0e10cSrcweir it->maItemSize.Height() = nMinHeight; 2104*cdf0e10cSrcweir } 2105*cdf0e10cSrcweir 2106*cdf0e10cSrcweir // keep track of max item size 2107*cdf0e10cSrcweir if ( it->maItemSize.Width() > nMaxWidth ) 2108*cdf0e10cSrcweir nMaxWidth = it->maItemSize.Width(); 2109*cdf0e10cSrcweir if ( it->maItemSize.Height() > nMaxHeight ) 2110*cdf0e10cSrcweir nMaxHeight = it->maItemSize.Height(); 2111*cdf0e10cSrcweir } 2112*cdf0e10cSrcweir 2113*cdf0e10cSrcweir ++it; 2114*cdf0e10cSrcweir } 2115*cdf0e10cSrcweir } 2116*cdf0e10cSrcweir else 2117*cdf0e10cSrcweir { 2118*cdf0e10cSrcweir nMaxWidth = nDefWidth; 2119*cdf0e10cSrcweir nMaxHeight = nDefHeight; 2120*cdf0e10cSrcweir 2121*cdf0e10cSrcweir ImplAddButtonBorder( nMaxWidth, nMaxHeight, mnOutStyle, mpData->mbNativeButtons ); 2122*cdf0e10cSrcweir } 2123*cdf0e10cSrcweir 2124*cdf0e10cSrcweir if( !ImplIsFloatingMode() && GetToolboxButtonSize() != TOOLBOX_BUTTONSIZE_DONTCARE ) 2125*cdf0e10cSrcweir { 2126*cdf0e10cSrcweir // make sure all vertical toolbars have the same width and horizontal have the same height 2127*cdf0e10cSrcweir // this depends on the used button sizes 2128*cdf0e10cSrcweir // as this is used for alignement of multiple toolbars 2129*cdf0e10cSrcweir // it is only required for docked toolbars 2130*cdf0e10cSrcweir 2131*cdf0e10cSrcweir long nFixedWidth = nDefWidth+nDropDownArrowWidth; 2132*cdf0e10cSrcweir long nFixedHeight = nDefHeight; 2133*cdf0e10cSrcweir ImplAddButtonBorder( nFixedWidth, nFixedHeight, mnOutStyle, mpData->mbNativeButtons ); 2134*cdf0e10cSrcweir 2135*cdf0e10cSrcweir if( mbHorz ) 2136*cdf0e10cSrcweir nMaxHeight = nFixedHeight; 2137*cdf0e10cSrcweir else 2138*cdf0e10cSrcweir nMaxWidth = nFixedWidth; 2139*cdf0e10cSrcweir } 2140*cdf0e10cSrcweir 2141*cdf0e10cSrcweir mbCalc = sal_False; 2142*cdf0e10cSrcweir mbFormat = sal_True; 2143*cdf0e10cSrcweir 2144*cdf0e10cSrcweir // do we have to recalc the sizes ? 2145*cdf0e10cSrcweir if ( (nMaxWidth != mnMaxItemWidth) || (nMaxHeight != mnMaxItemHeight) ) 2146*cdf0e10cSrcweir { 2147*cdf0e10cSrcweir mnMaxItemWidth = nMaxWidth; 2148*cdf0e10cSrcweir mnMaxItemHeight = nMaxHeight; 2149*cdf0e10cSrcweir 2150*cdf0e10cSrcweir return sal_True; 2151*cdf0e10cSrcweir } 2152*cdf0e10cSrcweir else 2153*cdf0e10cSrcweir return sal_False; 2154*cdf0e10cSrcweir } 2155*cdf0e10cSrcweir 2156*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2157*cdf0e10cSrcweir 2158*cdf0e10cSrcweir sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, sal_Bool bCalcHorz ) 2159*cdf0e10cSrcweir { 2160*cdf0e10cSrcweir sal_uLong nLineStart = 0; 2161*cdf0e10cSrcweir sal_uLong nGroupStart = 0; 2162*cdf0e10cSrcweir long nLineWidth = 0; 2163*cdf0e10cSrcweir long nCurWidth; 2164*cdf0e10cSrcweir long nLastGroupLineWidth = 0; 2165*cdf0e10cSrcweir long nMaxLineWidth = 0; 2166*cdf0e10cSrcweir sal_uInt16 nLines = 1; 2167*cdf0e10cSrcweir sal_Bool bWindow; 2168*cdf0e10cSrcweir sal_Bool bBreak = sal_False; 2169*cdf0e10cSrcweir long nWidthTotal = nWidth; 2170*cdf0e10cSrcweir 2171*cdf0e10cSrcweir // when docked the menubutton will be in the first line 2172*cdf0e10cSrcweir // ->initialize first linewidth with button 2173*cdf0e10cSrcweir if( IsMenuEnabled() && !ImplIsFloatingMode() ) 2174*cdf0e10cSrcweir nLineWidth = mpData->maMenubuttonItem.maItemSize.Width(); 2175*cdf0e10cSrcweir 2176*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin(); 2177*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 2178*cdf0e10cSrcweir { 2179*cdf0e10cSrcweir it->mbBreak = bBreak; 2180*cdf0e10cSrcweir bBreak = sal_False; 2181*cdf0e10cSrcweir 2182*cdf0e10cSrcweir if ( it->mbVisible ) 2183*cdf0e10cSrcweir { 2184*cdf0e10cSrcweir bWindow = sal_False; 2185*cdf0e10cSrcweir bBreak = sal_False; 2186*cdf0e10cSrcweir nCurWidth = 0; 2187*cdf0e10cSrcweir 2188*cdf0e10cSrcweir if ( it->meType == TOOLBOXITEM_BUTTON || it->meType == TOOLBOXITEM_SPACE ) 2189*cdf0e10cSrcweir { 2190*cdf0e10cSrcweir if ( bCalcHorz ) 2191*cdf0e10cSrcweir nCurWidth = it->maItemSize.Width(); 2192*cdf0e10cSrcweir else 2193*cdf0e10cSrcweir nCurWidth = it->maItemSize.Height(); 2194*cdf0e10cSrcweir 2195*cdf0e10cSrcweir if ( it->mpWindow && bCalcHorz ) 2196*cdf0e10cSrcweir { 2197*cdf0e10cSrcweir long nWinItemWidth = it->mpWindow->GetSizePixel().Width(); 2198*cdf0e10cSrcweir if ( !mbScroll || (nWinItemWidth <= nWidthTotal) ) 2199*cdf0e10cSrcweir { 2200*cdf0e10cSrcweir nCurWidth = nWinItemWidth; 2201*cdf0e10cSrcweir bWindow = sal_True; 2202*cdf0e10cSrcweir } 2203*cdf0e10cSrcweir else 2204*cdf0e10cSrcweir { 2205*cdf0e10cSrcweir if ( it->mbEmptyBtn ) 2206*cdf0e10cSrcweir { 2207*cdf0e10cSrcweir nCurWidth = 0; 2208*cdf0e10cSrcweir } 2209*cdf0e10cSrcweir } 2210*cdf0e10cSrcweir } 2211*cdf0e10cSrcweir 2212*cdf0e10cSrcweir // check for line break 2213*cdf0e10cSrcweir if ( (nLineWidth+nCurWidth > nWidthTotal) && mbScroll ) 2214*cdf0e10cSrcweir bBreak = sal_True; 2215*cdf0e10cSrcweir } 2216*cdf0e10cSrcweir else if ( it->meType == TOOLBOXITEM_SEPARATOR ) 2217*cdf0e10cSrcweir nCurWidth = it->mnSepSize; 2218*cdf0e10cSrcweir // treat breaks as separators, except when using old style toolbars (ie. no menu button) 2219*cdf0e10cSrcweir else if ( (it->meType == TOOLBOXITEM_BREAK) && !IsMenuEnabled() ) 2220*cdf0e10cSrcweir bBreak = sal_True; 2221*cdf0e10cSrcweir 2222*cdf0e10cSrcweir if ( bBreak ) 2223*cdf0e10cSrcweir { 2224*cdf0e10cSrcweir nLines++; 2225*cdf0e10cSrcweir 2226*cdf0e10cSrcweir // Gruppe auseinanderbrechen oder ganze Gruppe umbrechen? 2227*cdf0e10cSrcweir if ( (it->meType == TOOLBOXITEM_BREAK) || 2228*cdf0e10cSrcweir (nLineStart == nGroupStart) ) 2229*cdf0e10cSrcweir { 2230*cdf0e10cSrcweir if ( nLineWidth > nMaxLineWidth ) 2231*cdf0e10cSrcweir nMaxLineWidth = nLineWidth; 2232*cdf0e10cSrcweir 2233*cdf0e10cSrcweir nLineWidth = 0; 2234*cdf0e10cSrcweir nLineStart = it - mpData->m_aItems.begin(); 2235*cdf0e10cSrcweir nGroupStart = nLineStart; 2236*cdf0e10cSrcweir it->mbBreak = sal_True; 2237*cdf0e10cSrcweir bBreak = sal_False; 2238*cdf0e10cSrcweir } 2239*cdf0e10cSrcweir else 2240*cdf0e10cSrcweir { 2241*cdf0e10cSrcweir if ( nLastGroupLineWidth > nMaxLineWidth ) 2242*cdf0e10cSrcweir nMaxLineWidth = nLastGroupLineWidth; 2243*cdf0e10cSrcweir 2244*cdf0e10cSrcweir // Wenn ganze Gruppe umgebrochen wird, diese auf 2245*cdf0e10cSrcweir // Zeilenanfang setzen und wieder neu berechnen 2246*cdf0e10cSrcweir nLineWidth = 0; 2247*cdf0e10cSrcweir nLineStart = nGroupStart; 2248*cdf0e10cSrcweir it = mpData->m_aItems.begin() + nGroupStart; 2249*cdf0e10cSrcweir continue; 2250*cdf0e10cSrcweir } 2251*cdf0e10cSrcweir } 2252*cdf0e10cSrcweir else 2253*cdf0e10cSrcweir { 2254*cdf0e10cSrcweir if( ImplIsFloatingMode() || !IsMenuEnabled() ) // no group breaking when being docked single-line 2255*cdf0e10cSrcweir { 2256*cdf0e10cSrcweir if ( (it->meType != TOOLBOXITEM_BUTTON) || bWindow ) 2257*cdf0e10cSrcweir { 2258*cdf0e10cSrcweir // found separator or break 2259*cdf0e10cSrcweir nLastGroupLineWidth = nLineWidth; 2260*cdf0e10cSrcweir nGroupStart = it - mpData->m_aItems.begin(); 2261*cdf0e10cSrcweir if ( !bWindow ) 2262*cdf0e10cSrcweir nGroupStart++; 2263*cdf0e10cSrcweir } 2264*cdf0e10cSrcweir } 2265*cdf0e10cSrcweir } 2266*cdf0e10cSrcweir 2267*cdf0e10cSrcweir nLineWidth += nCurWidth; 2268*cdf0e10cSrcweir } 2269*cdf0e10cSrcweir 2270*cdf0e10cSrcweir ++it; 2271*cdf0e10cSrcweir } 2272*cdf0e10cSrcweir 2273*cdf0e10cSrcweir 2274*cdf0e10cSrcweir if ( pMaxLineWidth ) 2275*cdf0e10cSrcweir { 2276*cdf0e10cSrcweir if ( nLineWidth > nMaxLineWidth ) 2277*cdf0e10cSrcweir nMaxLineWidth = nLineWidth; 2278*cdf0e10cSrcweir 2279*cdf0e10cSrcweir if( ImplIsFloatingMode() && !ImplIsInPopupMode() ) 2280*cdf0e10cSrcweir { 2281*cdf0e10cSrcweir // leave enough space to display buttons in the decoration 2282*cdf0e10cSrcweir long aMinWidth = 2 * GetSettings().GetStyleSettings().GetFloatTitleHeight(); 2283*cdf0e10cSrcweir if( nMaxLineWidth < aMinWidth ) 2284*cdf0e10cSrcweir nMaxLineWidth = aMinWidth; 2285*cdf0e10cSrcweir } 2286*cdf0e10cSrcweir 2287*cdf0e10cSrcweir // Wegen Separatoren kann MaxLineWidth > Width werden, hat aber 2288*cdf0e10cSrcweir // auf die Umbrueche keine Auswirkung 2289*cdf0e10cSrcweir //if ( nMaxLineWidth > nWidth ) 2290*cdf0e10cSrcweir // nMaxLineWidth = nWidth; 2291*cdf0e10cSrcweir 2292*cdf0e10cSrcweir *pMaxLineWidth = nMaxLineWidth; 2293*cdf0e10cSrcweir } 2294*cdf0e10cSrcweir 2295*cdf0e10cSrcweir return nLines; 2296*cdf0e10cSrcweir } 2297*cdf0e10cSrcweir 2298*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2299*cdf0e10cSrcweir namespace 2300*cdf0e10cSrcweir { 2301*cdf0e10cSrcweir sal_Bool ImplFollowedByVisibleButton( std::vector< ImplToolItem >::iterator _aSeparator, std::vector< ImplToolItem >::iterator _aEnd ) 2302*cdf0e10cSrcweir { 2303*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator aLookup = _aSeparator; 2304*cdf0e10cSrcweir while ( ++aLookup != _aEnd ) 2305*cdf0e10cSrcweir { 2306*cdf0e10cSrcweir if ( aLookup->meType == TOOLBOXITEM_SEPARATOR ) 2307*cdf0e10cSrcweir return ImplFollowedByVisibleButton( aLookup, _aEnd ); 2308*cdf0e10cSrcweir 2309*cdf0e10cSrcweir if ( ( aLookup->meType == TOOLBOXITEM_BUTTON ) && aLookup->mbVisible ) 2310*cdf0e10cSrcweir return sal_True; 2311*cdf0e10cSrcweir } 2312*cdf0e10cSrcweir return sal_False; 2313*cdf0e10cSrcweir } 2314*cdf0e10cSrcweir } 2315*cdf0e10cSrcweir 2316*cdf0e10cSrcweir 2317*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2318*cdf0e10cSrcweir 2319*cdf0e10cSrcweir Size ToolBox::ImplGetOptimalFloatingSize( FloatingSizeMode eMode ) 2320*cdf0e10cSrcweir { 2321*cdf0e10cSrcweir if( !ImplIsFloatingMode() ) 2322*cdf0e10cSrcweir return Size(); 2323*cdf0e10cSrcweir 2324*cdf0e10cSrcweir Size aCurrentSize( mnDX, mnDY ); 2325*cdf0e10cSrcweir Size aSize1( aCurrentSize ); 2326*cdf0e10cSrcweir Size aSize2( aCurrentSize ); 2327*cdf0e10cSrcweir 2328*cdf0e10cSrcweir // try to preserve current height 2329*cdf0e10cSrcweir if( eMode == FSMODE_AUTO || eMode == FSMODE_FAVOURHEIGHT ) 2330*cdf0e10cSrcweir { 2331*cdf0e10cSrcweir // calc number of floating lines for current window height 2332*cdf0e10cSrcweir sal_uInt16 nFloatLinesHeight = ImplCalcLines( this, mnDY ); 2333*cdf0e10cSrcweir // calc window size according to this number 2334*cdf0e10cSrcweir aSize1 = ImplCalcFloatSize( this, nFloatLinesHeight ); 2335*cdf0e10cSrcweir 2336*cdf0e10cSrcweir if( eMode == FSMODE_FAVOURHEIGHT || aCurrentSize == aSize1 ) 2337*cdf0e10cSrcweir return aSize1; 2338*cdf0e10cSrcweir } 2339*cdf0e10cSrcweir 2340*cdf0e10cSrcweir if( eMode == FSMODE_AUTO || eMode == FSMODE_FAVOURWIDTH ) 2341*cdf0e10cSrcweir { 2342*cdf0e10cSrcweir // try to preserve current width 2343*cdf0e10cSrcweir long nLineHeight = ( mnWinHeight > mnMaxItemHeight ) ? mnWinHeight : mnMaxItemHeight; 2344*cdf0e10cSrcweir int nBorderX = 2*TB_BORDER_OFFSET1 + mnLeftBorder + mnRightBorder + 2*mnBorderX; 2345*cdf0e10cSrcweir int nBorderY = 2*TB_BORDER_OFFSET2 + mnTopBorder + mnBottomBorder + 2*mnBorderY; 2346*cdf0e10cSrcweir Size aSz( aCurrentSize ); 2347*cdf0e10cSrcweir long maxX; 2348*cdf0e10cSrcweir sal_uInt16 nLines = ImplCalcBreaks( aSz.Width()-nBorderX, &maxX, mbHorz ); 2349*cdf0e10cSrcweir 2350*cdf0e10cSrcweir sal_uInt16 manyLines = 1000; 2351*cdf0e10cSrcweir Size aMinimalFloatSize = ImplCalcFloatSize( this, manyLines ); 2352*cdf0e10cSrcweir 2353*cdf0e10cSrcweir aSz.Height() = nBorderY + nLineHeight * nLines; 2354*cdf0e10cSrcweir // line space when more than one line 2355*cdf0e10cSrcweir if ( mnWinStyle & WB_LINESPACING ) 2356*cdf0e10cSrcweir aSz.Height() += (nLines-1)*TB_LINESPACING; 2357*cdf0e10cSrcweir 2358*cdf0e10cSrcweir aSz.Width() = nBorderX + maxX; 2359*cdf0e10cSrcweir 2360*cdf0e10cSrcweir // avoid clipping of any items 2361*cdf0e10cSrcweir if( aSz.Width() < aMinimalFloatSize.Width() ) 2362*cdf0e10cSrcweir aSize2 = ImplCalcFloatSize( this, nLines ); 2363*cdf0e10cSrcweir else 2364*cdf0e10cSrcweir aSize2 = aSz; 2365*cdf0e10cSrcweir 2366*cdf0e10cSrcweir if( eMode == FSMODE_FAVOURWIDTH || aCurrentSize == aSize2 ) 2367*cdf0e10cSrcweir return aSize2; 2368*cdf0e10cSrcweir else 2369*cdf0e10cSrcweir { 2370*cdf0e10cSrcweir // set the size with the smallest delta as the current size 2371*cdf0e10cSrcweir long dx1 = abs( mnDX - aSize1.Width() ); 2372*cdf0e10cSrcweir long dy1 = abs( mnDY - aSize1.Height() ); 2373*cdf0e10cSrcweir 2374*cdf0e10cSrcweir long dx2 = abs( mnDX - aSize2.Width() ); 2375*cdf0e10cSrcweir long dy2 = abs( mnDY - aSize2.Height() ); 2376*cdf0e10cSrcweir 2377*cdf0e10cSrcweir if( dx1*dy1 < dx2*dy2 ) 2378*cdf0e10cSrcweir aCurrentSize = aSize1; 2379*cdf0e10cSrcweir else 2380*cdf0e10cSrcweir aCurrentSize = aSize2; 2381*cdf0e10cSrcweir } 2382*cdf0e10cSrcweir } 2383*cdf0e10cSrcweir return aCurrentSize; 2384*cdf0e10cSrcweir } 2385*cdf0e10cSrcweir 2386*cdf0e10cSrcweir 2387*cdf0e10cSrcweir void ToolBox::ImplFormat( sal_Bool bResize ) 2388*cdf0e10cSrcweir { 2389*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 2390*cdf0e10cSrcweir 2391*cdf0e10cSrcweir // Muss ueberhaupt neu formatiert werden 2392*cdf0e10cSrcweir if ( !mbFormat ) 2393*cdf0e10cSrcweir return; 2394*cdf0e10cSrcweir 2395*cdf0e10cSrcweir mpData->ImplClearLayoutData(); 2396*cdf0e10cSrcweir 2397*cdf0e10cSrcweir // Positionen/Groessen berechnen 2398*cdf0e10cSrcweir Rectangle aEmptyRect; 2399*cdf0e10cSrcweir long nLineSize; 2400*cdf0e10cSrcweir long nLeft; 2401*cdf0e10cSrcweir long nRight; 2402*cdf0e10cSrcweir long nTop; 2403*cdf0e10cSrcweir long nBottom; 2404*cdf0e10cSrcweir long nMax; // width of layoutarea in pixels 2405*cdf0e10cSrcweir long nX; 2406*cdf0e10cSrcweir long nY; 2407*cdf0e10cSrcweir sal_uInt16 nFormatLine; 2408*cdf0e10cSrcweir sal_Bool bMustFullPaint; 2409*cdf0e10cSrcweir sal_Bool bLastSep; 2410*cdf0e10cSrcweir 2411*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it; 2412*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator temp_it; 2413*cdf0e10cSrcweir 2414*cdf0e10cSrcweir ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); 2415*cdf0e10cSrcweir sal_Bool bIsInPopupMode = ImplIsInPopupMode(); 2416*cdf0e10cSrcweir 2417*cdf0e10cSrcweir // FloatSizeAry gegebenenfalls loeschen 2418*cdf0e10cSrcweir if ( mpFloatSizeAry ) 2419*cdf0e10cSrcweir { 2420*cdf0e10cSrcweir delete mpFloatSizeAry; 2421*cdf0e10cSrcweir mpFloatSizeAry = NULL; 2422*cdf0e10cSrcweir } 2423*cdf0e10cSrcweir 2424*cdf0e10cSrcweir // compute border sizes 2425*cdf0e10cSrcweir ImplCalcBorder( meAlign, mnLeftBorder, mnTopBorder, mnRightBorder, mnBottomBorder, this ); 2426*cdf0e10cSrcweir 2427*cdf0e10cSrcweir // update drag area (where the 'grip' will be placed) 2428*cdf0e10cSrcweir Rectangle aOldDragRect; 2429*cdf0e10cSrcweir if( pWrapper ) 2430*cdf0e10cSrcweir aOldDragRect = pWrapper->GetDragArea(); 2431*cdf0e10cSrcweir ImplUpdateDragArea( this ); 2432*cdf0e10cSrcweir 2433*cdf0e10cSrcweir if ( ImplCalcItem() ) 2434*cdf0e10cSrcweir bMustFullPaint = sal_True; 2435*cdf0e10cSrcweir else 2436*cdf0e10cSrcweir bMustFullPaint = sal_False; 2437*cdf0e10cSrcweir 2438*cdf0e10cSrcweir 2439*cdf0e10cSrcweir // calculate new size during interactive resize or 2440*cdf0e10cSrcweir // set computed size when formatting only 2441*cdf0e10cSrcweir if ( ImplIsFloatingMode() ) 2442*cdf0e10cSrcweir { 2443*cdf0e10cSrcweir if ( bResize ) 2444*cdf0e10cSrcweir mnFloatLines = ImplCalcLines( this, mnDY ); 2445*cdf0e10cSrcweir else 2446*cdf0e10cSrcweir SetOutputSizePixel( ImplGetOptimalFloatingSize( FSMODE_AUTO ) ); 2447*cdf0e10cSrcweir } 2448*cdf0e10cSrcweir 2449*cdf0e10cSrcweir // Horizontal 2450*cdf0e10cSrcweir if ( mbHorz ) 2451*cdf0e10cSrcweir { 2452*cdf0e10cSrcweir // nLineSize: height of a single line, will fit highest item 2453*cdf0e10cSrcweir nLineSize = mnMaxItemHeight; 2454*cdf0e10cSrcweir 2455*cdf0e10cSrcweir if ( mnWinHeight > mnMaxItemHeight ) 2456*cdf0e10cSrcweir nLineSize = mnWinHeight; 2457*cdf0e10cSrcweir 2458*cdf0e10cSrcweir if ( mbScroll ) 2459*cdf0e10cSrcweir { 2460*cdf0e10cSrcweir nMax = mnDX; 2461*cdf0e10cSrcweir mnVisLines = ImplCalcLines( this, mnDY ); 2462*cdf0e10cSrcweir } 2463*cdf0e10cSrcweir else 2464*cdf0e10cSrcweir { 2465*cdf0e10cSrcweir // layout over all lines 2466*cdf0e10cSrcweir mnVisLines = mnLines; 2467*cdf0e10cSrcweir nMax = TB_MAXNOSCROLL; 2468*cdf0e10cSrcweir } 2469*cdf0e10cSrcweir 2470*cdf0e10cSrcweir // add in all border offsets 2471*cdf0e10cSrcweir // inner border as well as custom border (mnBorderX, mnBorderY) 2472*cdf0e10cSrcweir if ( mnWinStyle & WB_BORDER ) 2473*cdf0e10cSrcweir { 2474*cdf0e10cSrcweir nLeft = TB_BORDER_OFFSET1 + mnLeftBorder; 2475*cdf0e10cSrcweir nTop = TB_BORDER_OFFSET2 + mnTopBorder; 2476*cdf0e10cSrcweir nBottom = TB_BORDER_OFFSET1 + mnBottomBorder; 2477*cdf0e10cSrcweir nMax -= nLeft + TB_BORDER_OFFSET1 + mnRightBorder; 2478*cdf0e10cSrcweir } 2479*cdf0e10cSrcweir else 2480*cdf0e10cSrcweir { 2481*cdf0e10cSrcweir nLeft = 0; 2482*cdf0e10cSrcweir nTop = 0; 2483*cdf0e10cSrcweir nBottom = 0; 2484*cdf0e10cSrcweir } 2485*cdf0e10cSrcweir 2486*cdf0e10cSrcweir nLeft += mnBorderX; 2487*cdf0e10cSrcweir nTop += mnBorderY; 2488*cdf0e10cSrcweir nBottom += mnBorderY; 2489*cdf0e10cSrcweir nMax -= mnBorderX*2; 2490*cdf0e10cSrcweir 2491*cdf0e10cSrcweir // adjust linesize if docked in single-line mode (i.e. when using a clipped item menu) 2492*cdf0e10cSrcweir // we have to center all items in the window height 2493*cdf0e10cSrcweir if( IsMenuEnabled() && !ImplIsFloatingMode() ) 2494*cdf0e10cSrcweir { 2495*cdf0e10cSrcweir long nWinHeight = mnDY - nTop - nBottom; 2496*cdf0e10cSrcweir if( nWinHeight > nLineSize ) 2497*cdf0e10cSrcweir nLineSize = nWinHeight; 2498*cdf0e10cSrcweir } 2499*cdf0e10cSrcweir } 2500*cdf0e10cSrcweir else 2501*cdf0e10cSrcweir { 2502*cdf0e10cSrcweir nLineSize = mnMaxItemWidth; 2503*cdf0e10cSrcweir 2504*cdf0e10cSrcweir if ( mbScroll ) 2505*cdf0e10cSrcweir { 2506*cdf0e10cSrcweir mnVisLines = ImplCalcLines( this, mnDX ); 2507*cdf0e10cSrcweir nMax = mnDY; 2508*cdf0e10cSrcweir } 2509*cdf0e10cSrcweir else 2510*cdf0e10cSrcweir { 2511*cdf0e10cSrcweir mnVisLines = mnLines; 2512*cdf0e10cSrcweir nMax = TB_MAXNOSCROLL; 2513*cdf0e10cSrcweir } 2514*cdf0e10cSrcweir 2515*cdf0e10cSrcweir if ( mnWinStyle & WB_BORDER ) 2516*cdf0e10cSrcweir { 2517*cdf0e10cSrcweir nTop = TB_BORDER_OFFSET1 + mnTopBorder; 2518*cdf0e10cSrcweir nLeft = TB_BORDER_OFFSET2 + mnLeftBorder; 2519*cdf0e10cSrcweir nRight = TB_BORDER_OFFSET2 + mnRightBorder; 2520*cdf0e10cSrcweir nMax -= nTop + TB_BORDER_OFFSET1 + mnBottomBorder; 2521*cdf0e10cSrcweir } 2522*cdf0e10cSrcweir else 2523*cdf0e10cSrcweir { 2524*cdf0e10cSrcweir nLeft = 0; 2525*cdf0e10cSrcweir nTop = 0; 2526*cdf0e10cSrcweir nRight = 0; 2527*cdf0e10cSrcweir } 2528*cdf0e10cSrcweir 2529*cdf0e10cSrcweir nLeft += mnBorderX; 2530*cdf0e10cSrcweir nRight+= mnBorderX; 2531*cdf0e10cSrcweir nTop += mnBorderY; 2532*cdf0e10cSrcweir nMax -= mnBorderY*2; 2533*cdf0e10cSrcweir 2534*cdf0e10cSrcweir // adjust linesize if docked in single-line mode (i.e. when using a clipped item menu) 2535*cdf0e10cSrcweir // we have to center all items in the window height 2536*cdf0e10cSrcweir if( !ImplIsFloatingMode() && IsMenuEnabled() ) 2537*cdf0e10cSrcweir { 2538*cdf0e10cSrcweir long nWinWidth = mnDX - nLeft - nRight; 2539*cdf0e10cSrcweir if( nWinWidth > nLineSize ) 2540*cdf0e10cSrcweir nLineSize = nWinWidth; 2541*cdf0e10cSrcweir } 2542*cdf0e10cSrcweir } 2543*cdf0e10cSrcweir 2544*cdf0e10cSrcweir // no calculation if the window has no size (nMax=0) 2545*cdf0e10cSrcweir // non scrolling toolboxes must be computed though 2546*cdf0e10cSrcweir if ( (nMax <= 0) && mbScroll ) 2547*cdf0e10cSrcweir { 2548*cdf0e10cSrcweir mnVisLines = 1; 2549*cdf0e10cSrcweir mnCurLine = 1; 2550*cdf0e10cSrcweir mnCurLines = 1; 2551*cdf0e10cSrcweir 2552*cdf0e10cSrcweir it = mpData->m_aItems.begin(); 2553*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 2554*cdf0e10cSrcweir { 2555*cdf0e10cSrcweir it->maRect = aEmptyRect; 2556*cdf0e10cSrcweir 2557*cdf0e10cSrcweir // For items not visible, release resources only needed during 2558*cdf0e10cSrcweir // painting the items (on Win98, for example, these are system-wide 2559*cdf0e10cSrcweir // resources that are easily exhausted, so be nice): 2560*cdf0e10cSrcweir 2561*cdf0e10cSrcweir /* !!! 2562*cdf0e10cSrcweir it->maImage.ClearCaches(); 2563*cdf0e10cSrcweir it->maHighImage.ClearCaches(); 2564*cdf0e10cSrcweir */ 2565*cdf0e10cSrcweir 2566*cdf0e10cSrcweir ++it; 2567*cdf0e10cSrcweir } 2568*cdf0e10cSrcweir 2569*cdf0e10cSrcweir maLowerRect = aEmptyRect; 2570*cdf0e10cSrcweir maUpperRect = aEmptyRect; 2571*cdf0e10cSrcweir maNextToolRect = aEmptyRect; 2572*cdf0e10cSrcweir } 2573*cdf0e10cSrcweir else 2574*cdf0e10cSrcweir { 2575*cdf0e10cSrcweir // init start values 2576*cdf0e10cSrcweir nX = nLeft; // top-left offset 2577*cdf0e10cSrcweir nY = nTop; 2578*cdf0e10cSrcweir nFormatLine = 1; 2579*cdf0e10cSrcweir bLastSep = sal_True; 2580*cdf0e10cSrcweir 2581*cdf0e10cSrcweir // save old scroll rectangles and reset them 2582*cdf0e10cSrcweir Rectangle aOldLowerRect = maLowerRect; 2583*cdf0e10cSrcweir Rectangle aOldUpperRect = maUpperRect; 2584*cdf0e10cSrcweir Rectangle aOldNextToolRect = maNextToolRect; 2585*cdf0e10cSrcweir Rectangle aOldMenubuttonRect = mpData->maMenubuttonItem.maRect; 2586*cdf0e10cSrcweir maUpperRect = aEmptyRect; 2587*cdf0e10cSrcweir maLowerRect = aEmptyRect; 2588*cdf0e10cSrcweir maNextToolRect = aEmptyRect; 2589*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect = aEmptyRect; 2590*cdf0e10cSrcweir 2591*cdf0e10cSrcweir // additional toolboxes require a toggle button (maNextToolRect) 2592*cdf0e10cSrcweir if ( maNextToolBoxStr.Len() && mbScroll ) 2593*cdf0e10cSrcweir { 2594*cdf0e10cSrcweir nMax -= TB_NEXT_SIZE-TB_NEXT_OFFSET; 2595*cdf0e10cSrcweir if ( mbHorz ) 2596*cdf0e10cSrcweir { 2597*cdf0e10cSrcweir maNextToolRect.Left() = nLeft+nMax; 2598*cdf0e10cSrcweir maNextToolRect.Right() = maNextToolRect.Left()+TB_NEXT_SIZE-1; 2599*cdf0e10cSrcweir maNextToolRect.Top() = nTop; 2600*cdf0e10cSrcweir maNextToolRect.Bottom() = mnDY-mnBottomBorder-mnBorderY-TB_BORDER_OFFSET2-1; 2601*cdf0e10cSrcweir } 2602*cdf0e10cSrcweir else 2603*cdf0e10cSrcweir { 2604*cdf0e10cSrcweir maNextToolRect.Top() = nTop+nMax; 2605*cdf0e10cSrcweir maNextToolRect.Bottom() = maNextToolRect.Top()+TB_NEXT_SIZE-1; 2606*cdf0e10cSrcweir maNextToolRect.Left() = nLeft; 2607*cdf0e10cSrcweir maNextToolRect.Right() = mnDX-mnRightBorder-mnBorderX-TB_BORDER_OFFSET2-1; 2608*cdf0e10cSrcweir } 2609*cdf0e10cSrcweir } 2610*cdf0e10cSrcweir 2611*cdf0e10cSrcweir // do we have any toolbox items at all ? 2612*cdf0e10cSrcweir if ( !mpData->m_aItems.empty() || IsMenuEnabled() ) 2613*cdf0e10cSrcweir { 2614*cdf0e10cSrcweir // compute line breaks and visible lines give the current window width (nMax) 2615*cdf0e10cSrcweir // the break indicators will be stored within each item (it->mbBreak) 2616*cdf0e10cSrcweir mnCurLines = ImplCalcBreaks( nMax, NULL, mbHorz ); 2617*cdf0e10cSrcweir 2618*cdf0e10cSrcweir // check for scrollbar buttons or dropdown menu 2619*cdf0e10cSrcweir // (if a menu is enabled, this will be used to store clipped 2620*cdf0e10cSrcweir // items and no scroll buttons will appear) 2621*cdf0e10cSrcweir if ( (!ImplIsFloatingMode() && (mnCurLines > mnVisLines) && mbScroll ) || 2622*cdf0e10cSrcweir IsMenuEnabled() ) 2623*cdf0e10cSrcweir { 2624*cdf0e10cSrcweir // compute linebreaks again, incorporating scrollbar buttons 2625*cdf0e10cSrcweir if( !IsMenuEnabled() ) 2626*cdf0e10cSrcweir { 2627*cdf0e10cSrcweir nMax -= TB_SPIN_SIZE+TB_SPIN_OFFSET; 2628*cdf0e10cSrcweir mnCurLines = ImplCalcBreaks( nMax, NULL, mbHorz ); 2629*cdf0e10cSrcweir } 2630*cdf0e10cSrcweir 2631*cdf0e10cSrcweir // compute scroll rectangles or menu button 2632*cdf0e10cSrcweir if ( mbHorz ) 2633*cdf0e10cSrcweir { 2634*cdf0e10cSrcweir if( IsMenuEnabled() && !ImplHasExternalMenubutton() && !bIsInPopupMode ) 2635*cdf0e10cSrcweir { 2636*cdf0e10cSrcweir if( !ImplIsFloatingMode() ) 2637*cdf0e10cSrcweir { 2638*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Right() = mnDX - 2; 2639*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Top() = nTop; 2640*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Bottom() = mnDY-mnBottomBorder-mnBorderY-TB_BORDER_OFFSET2-1; 2641*cdf0e10cSrcweir } 2642*cdf0e10cSrcweir else 2643*cdf0e10cSrcweir { 2644*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Right() = mnDX - mnRightBorder-mnBorderX-TB_BORDER_OFFSET1-1; 2645*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Top() = nTop; 2646*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Bottom() = mnDY-mnBottomBorder-mnBorderY-TB_BORDER_OFFSET2-1; 2647*cdf0e10cSrcweir } 2648*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Left() = mpData->maMenubuttonItem.maRect.Right() - mpData->mnMenuButtonWidth; 2649*cdf0e10cSrcweir } 2650*cdf0e10cSrcweir else 2651*cdf0e10cSrcweir { 2652*cdf0e10cSrcweir maUpperRect.Left() = nLeft+nMax+TB_SPIN_OFFSET; 2653*cdf0e10cSrcweir maUpperRect.Right() = maUpperRect.Left()+TB_SPIN_SIZE-1; 2654*cdf0e10cSrcweir maUpperRect.Top() = nTop; 2655*cdf0e10cSrcweir maLowerRect.Bottom() = mnDY-mnBottomBorder-mnBorderY-TB_BORDER_OFFSET2-1; 2656*cdf0e10cSrcweir maLowerRect.Left() = maUpperRect.Left(); 2657*cdf0e10cSrcweir maLowerRect.Right() = maUpperRect.Right(); 2658*cdf0e10cSrcweir maUpperRect.Bottom() = maUpperRect.Top() + 2659*cdf0e10cSrcweir (maLowerRect.Bottom()-maUpperRect.Top())/2; 2660*cdf0e10cSrcweir maLowerRect.Top() = maUpperRect.Bottom(); 2661*cdf0e10cSrcweir } 2662*cdf0e10cSrcweir } 2663*cdf0e10cSrcweir else 2664*cdf0e10cSrcweir { 2665*cdf0e10cSrcweir if( IsMenuEnabled() && !ImplHasExternalMenubutton() && !bIsInPopupMode ) 2666*cdf0e10cSrcweir { 2667*cdf0e10cSrcweir if( !ImplIsFloatingMode() ) 2668*cdf0e10cSrcweir { 2669*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Bottom() = mnDY - 2; 2670*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Left() = nLeft; 2671*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Right() = mnDX-mnRightBorder-mnBorderX-TB_BORDER_OFFSET2-1; 2672*cdf0e10cSrcweir } 2673*cdf0e10cSrcweir else 2674*cdf0e10cSrcweir { 2675*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Bottom() = mnDY - mnBottomBorder-mnBorderY-TB_BORDER_OFFSET1-1; 2676*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Left() = nLeft; 2677*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Right() = mnDX-mnRightBorder-mnBorderX-TB_BORDER_OFFSET2-1; 2678*cdf0e10cSrcweir } 2679*cdf0e10cSrcweir mpData->maMenubuttonItem.maRect.Top() = mpData->maMenubuttonItem.maRect.Bottom() - mpData->mnMenuButtonWidth; 2680*cdf0e10cSrcweir } 2681*cdf0e10cSrcweir else 2682*cdf0e10cSrcweir { 2683*cdf0e10cSrcweir maUpperRect.Top() = nTop+nMax+TB_SPIN_OFFSET;; 2684*cdf0e10cSrcweir maUpperRect.Bottom() = maUpperRect.Top()+TB_SPIN_SIZE-1; 2685*cdf0e10cSrcweir maUpperRect.Left() = nLeft; 2686*cdf0e10cSrcweir maLowerRect.Right() = mnDX-mnRightBorder-mnBorderX-TB_BORDER_OFFSET2-1; 2687*cdf0e10cSrcweir maLowerRect.Top() = maUpperRect.Top(); 2688*cdf0e10cSrcweir maLowerRect.Bottom() = maUpperRect.Bottom(); 2689*cdf0e10cSrcweir maUpperRect.Right() = maUpperRect.Left() + 2690*cdf0e10cSrcweir (maLowerRect.Right()-maUpperRect.Left())/2; 2691*cdf0e10cSrcweir maLowerRect.Left() = maUpperRect.Right(); 2692*cdf0e10cSrcweir } 2693*cdf0e10cSrcweir } 2694*cdf0e10cSrcweir } 2695*cdf0e10cSrcweir 2696*cdf0e10cSrcweir // no scrolling when there is a "more"-menu 2697*cdf0e10cSrcweir // anything will "fit" in a single line then 2698*cdf0e10cSrcweir if( IsMenuEnabled() ) 2699*cdf0e10cSrcweir mnCurLines = 1; 2700*cdf0e10cSrcweir 2701*cdf0e10cSrcweir // determine the currently visible line 2702*cdf0e10cSrcweir if ( mnVisLines >= mnCurLines ) 2703*cdf0e10cSrcweir mnCurLine = 1; 2704*cdf0e10cSrcweir else if ( mnCurLine+mnVisLines-1 > mnCurLines ) 2705*cdf0e10cSrcweir mnCurLine = mnCurLines - (mnVisLines-1); 2706*cdf0e10cSrcweir 2707*cdf0e10cSrcweir it = mpData->m_aItems.begin(); 2708*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 2709*cdf0e10cSrcweir { 2710*cdf0e10cSrcweir // hide double separators 2711*cdf0e10cSrcweir if ( it->meType == TOOLBOXITEM_SEPARATOR ) 2712*cdf0e10cSrcweir { 2713*cdf0e10cSrcweir it->mbVisible = sal_False; 2714*cdf0e10cSrcweir if ( !bLastSep ) 2715*cdf0e10cSrcweir { 2716*cdf0e10cSrcweir // check if any visible items have to appear behind it 2717*cdf0e10cSrcweir temp_it = it+1; 2718*cdf0e10cSrcweir while ( temp_it != mpData->m_aItems.end() ) 2719*cdf0e10cSrcweir { 2720*cdf0e10cSrcweir if ( (temp_it->meType == TOOLBOXITEM_SEPARATOR) || 2721*cdf0e10cSrcweir ((temp_it->meType == TOOLBOXITEM_BUTTON) && 2722*cdf0e10cSrcweir temp_it->mbVisible) ) 2723*cdf0e10cSrcweir { 2724*cdf0e10cSrcweir it->mbVisible = sal_True; 2725*cdf0e10cSrcweir break; 2726*cdf0e10cSrcweir } 2727*cdf0e10cSrcweir ++temp_it; 2728*cdf0e10cSrcweir } 2729*cdf0e10cSrcweir } 2730*cdf0e10cSrcweir bLastSep = sal_True; 2731*cdf0e10cSrcweir } 2732*cdf0e10cSrcweir else if ( it->mbVisible ) 2733*cdf0e10cSrcweir bLastSep = sal_False; 2734*cdf0e10cSrcweir 2735*cdf0e10cSrcweir it->mbShowWindow = sal_False; 2736*cdf0e10cSrcweir 2737*cdf0e10cSrcweir // check for line break and advance nX/nY accordingly 2738*cdf0e10cSrcweir if ( it->mbBreak ) 2739*cdf0e10cSrcweir { 2740*cdf0e10cSrcweir nFormatLine++; 2741*cdf0e10cSrcweir 2742*cdf0e10cSrcweir // increment starting with the second line 2743*cdf0e10cSrcweir if ( nFormatLine > mnCurLine ) 2744*cdf0e10cSrcweir { 2745*cdf0e10cSrcweir if ( mbHorz ) 2746*cdf0e10cSrcweir { 2747*cdf0e10cSrcweir nX = nLeft; 2748*cdf0e10cSrcweir if ( mnWinStyle & WB_LINESPACING ) 2749*cdf0e10cSrcweir nY += nLineSize+TB_LINESPACING; 2750*cdf0e10cSrcweir else 2751*cdf0e10cSrcweir nY += nLineSize; 2752*cdf0e10cSrcweir } 2753*cdf0e10cSrcweir else 2754*cdf0e10cSrcweir { 2755*cdf0e10cSrcweir nY = nTop; 2756*cdf0e10cSrcweir if ( mnWinStyle & WB_LINESPACING ) 2757*cdf0e10cSrcweir nX += nLineSize+TB_LINESPACING; 2758*cdf0e10cSrcweir else 2759*cdf0e10cSrcweir nX += nLineSize; 2760*cdf0e10cSrcweir } 2761*cdf0e10cSrcweir } 2762*cdf0e10cSrcweir } 2763*cdf0e10cSrcweir 2764*cdf0e10cSrcweir if ( !it->mbVisible || (nFormatLine < mnCurLine) || 2765*cdf0e10cSrcweir (nFormatLine > mnCurLine+mnVisLines-1) ) 2766*cdf0e10cSrcweir // item is not visible 2767*cdf0e10cSrcweir it->maCalcRect = aEmptyRect; 2768*cdf0e10cSrcweir else 2769*cdf0e10cSrcweir { 2770*cdf0e10cSrcweir // 1. determine current item width/height 2771*cdf0e10cSrcweir // take window size and orientation into account, because this affects the size of item windows 2772*cdf0e10cSrcweir 2773*cdf0e10cSrcweir Size aCurrentItemSize( it->GetSize( mbHorz, mbScroll, nMax, Size(mnMaxItemWidth, mnMaxItemHeight) ) ); 2774*cdf0e10cSrcweir 2775*cdf0e10cSrcweir // 2. position item rect and use size from step 1 2776*cdf0e10cSrcweir // items will be centered horizontally (if mbHorz) or vertically 2777*cdf0e10cSrcweir // advance nX and nY accordingly 2778*cdf0e10cSrcweir if ( mbHorz ) 2779*cdf0e10cSrcweir { 2780*cdf0e10cSrcweir it->maCalcRect.Left() = nX; 2781*cdf0e10cSrcweir it->maCalcRect.Top() = nY+(nLineSize-aCurrentItemSize.Height())/2; 2782*cdf0e10cSrcweir it->maCalcRect.Right() = nX+aCurrentItemSize.Width()-1; 2783*cdf0e10cSrcweir it->maCalcRect.Bottom() = it->maCalcRect.Top()+aCurrentItemSize.Height()-1; 2784*cdf0e10cSrcweir nX += aCurrentItemSize.Width(); 2785*cdf0e10cSrcweir } 2786*cdf0e10cSrcweir else 2787*cdf0e10cSrcweir { 2788*cdf0e10cSrcweir it->maCalcRect.Left() = nX+(nLineSize-aCurrentItemSize.Width())/2; 2789*cdf0e10cSrcweir it->maCalcRect.Top() = nY; 2790*cdf0e10cSrcweir it->maCalcRect.Right() = it->maCalcRect.Left()+aCurrentItemSize.Width()-1; 2791*cdf0e10cSrcweir it->maCalcRect.Bottom() = nY+aCurrentItemSize.Height()-1; 2792*cdf0e10cSrcweir nY += aCurrentItemSize.Height(); 2793*cdf0e10cSrcweir } 2794*cdf0e10cSrcweir } 2795*cdf0e10cSrcweir 2796*cdf0e10cSrcweir // position window items into calculated item rect 2797*cdf0e10cSrcweir if ( it->mpWindow ) 2798*cdf0e10cSrcweir { 2799*cdf0e10cSrcweir if ( it->mbShowWindow ) 2800*cdf0e10cSrcweir { 2801*cdf0e10cSrcweir Point aPos( it->maCalcRect.Left(), it->maCalcRect.Top() ); 2802*cdf0e10cSrcweir it->mpWindow->SetPosPixel( aPos ); 2803*cdf0e10cSrcweir if ( !mbCustomizeMode ) 2804*cdf0e10cSrcweir it->mpWindow->Show(); 2805*cdf0e10cSrcweir } 2806*cdf0e10cSrcweir else 2807*cdf0e10cSrcweir it->mpWindow->Hide(); 2808*cdf0e10cSrcweir } 2809*cdf0e10cSrcweir 2810*cdf0e10cSrcweir ++it; 2811*cdf0e10cSrcweir } // end of loop over all items 2812*cdf0e10cSrcweir } 2813*cdf0e10cSrcweir else 2814*cdf0e10cSrcweir // we have no toolbox items 2815*cdf0e10cSrcweir mnCurLines = 1; 2816*cdf0e10cSrcweir 2817*cdf0e10cSrcweir 2818*cdf0e10cSrcweir if( IsMenuEnabled() && ImplIsFloatingMode() && !ImplHasExternalMenubutton() && !bIsInPopupMode ) 2819*cdf0e10cSrcweir { 2820*cdf0e10cSrcweir // custom menu will be the last button in floating mode 2821*cdf0e10cSrcweir ImplToolItem &rIt = mpData->maMenubuttonItem; 2822*cdf0e10cSrcweir 2823*cdf0e10cSrcweir if ( mbHorz ) 2824*cdf0e10cSrcweir { 2825*cdf0e10cSrcweir rIt.maRect.Left() = nX+TB_MENUBUTTON_OFFSET; 2826*cdf0e10cSrcweir rIt.maRect.Top() = nY; 2827*cdf0e10cSrcweir rIt.maRect.Right() = rIt.maRect.Left() + mpData->mnMenuButtonWidth; 2828*cdf0e10cSrcweir rIt.maRect.Bottom() = nY+nLineSize-1; 2829*cdf0e10cSrcweir nX += rIt.maItemSize.Width(); 2830*cdf0e10cSrcweir } 2831*cdf0e10cSrcweir else 2832*cdf0e10cSrcweir { 2833*cdf0e10cSrcweir rIt.maRect.Left() = nX; 2834*cdf0e10cSrcweir rIt.maRect.Top() = nY+TB_MENUBUTTON_OFFSET; 2835*cdf0e10cSrcweir rIt.maRect.Right() = nX+nLineSize-1; 2836*cdf0e10cSrcweir rIt.maRect.Bottom() = rIt.maRect.Top() + mpData->mnMenuButtonWidth; 2837*cdf0e10cSrcweir nY += rIt.maItemSize.Height(); 2838*cdf0e10cSrcweir } 2839*cdf0e10cSrcweir } 2840*cdf0e10cSrcweir 2841*cdf0e10cSrcweir 2842*cdf0e10cSrcweir // if toolbox visible trigger paint for changed regions 2843*cdf0e10cSrcweir if ( IsVisible() && !mbFullPaint ) 2844*cdf0e10cSrcweir { 2845*cdf0e10cSrcweir if ( bMustFullPaint ) 2846*cdf0e10cSrcweir { 2847*cdf0e10cSrcweir maPaintRect = Rectangle( mnLeftBorder, mnTopBorder, 2848*cdf0e10cSrcweir mnDX-mnRightBorder, mnDY-mnBottomBorder ); 2849*cdf0e10cSrcweir } 2850*cdf0e10cSrcweir else 2851*cdf0e10cSrcweir { 2852*cdf0e10cSrcweir if ( aOldLowerRect != maLowerRect ) 2853*cdf0e10cSrcweir { 2854*cdf0e10cSrcweir maPaintRect.Union( maLowerRect ); 2855*cdf0e10cSrcweir maPaintRect.Union( aOldLowerRect ); 2856*cdf0e10cSrcweir } 2857*cdf0e10cSrcweir if ( aOldUpperRect != maUpperRect ) 2858*cdf0e10cSrcweir { 2859*cdf0e10cSrcweir maPaintRect.Union( maUpperRect ); 2860*cdf0e10cSrcweir maPaintRect.Union( aOldUpperRect ); 2861*cdf0e10cSrcweir } 2862*cdf0e10cSrcweir if ( aOldNextToolRect != maNextToolRect ) 2863*cdf0e10cSrcweir { 2864*cdf0e10cSrcweir maPaintRect.Union( maNextToolRect ); 2865*cdf0e10cSrcweir maPaintRect.Union( aOldNextToolRect ); 2866*cdf0e10cSrcweir } 2867*cdf0e10cSrcweir if ( aOldMenubuttonRect != mpData->maMenubuttonItem.maRect ) 2868*cdf0e10cSrcweir { 2869*cdf0e10cSrcweir maPaintRect.Union( mpData->maMenubuttonItem.maRect ); 2870*cdf0e10cSrcweir maPaintRect.Union( aOldMenubuttonRect ); 2871*cdf0e10cSrcweir } 2872*cdf0e10cSrcweir if ( pWrapper && aOldDragRect != pWrapper->GetDragArea() ) 2873*cdf0e10cSrcweir { 2874*cdf0e10cSrcweir maPaintRect.Union( pWrapper->GetDragArea() ); 2875*cdf0e10cSrcweir maPaintRect.Union( aOldDragRect ); 2876*cdf0e10cSrcweir } 2877*cdf0e10cSrcweir 2878*cdf0e10cSrcweir it = mpData->m_aItems.begin(); 2879*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 2880*cdf0e10cSrcweir { 2881*cdf0e10cSrcweir if ( it->maRect != it->maCalcRect ) 2882*cdf0e10cSrcweir { 2883*cdf0e10cSrcweir maPaintRect.Union( it->maRect ); 2884*cdf0e10cSrcweir maPaintRect.Union( it->maCalcRect ); 2885*cdf0e10cSrcweir } 2886*cdf0e10cSrcweir ++it; 2887*cdf0e10cSrcweir } 2888*cdf0e10cSrcweir } 2889*cdf0e10cSrcweir 2890*cdf0e10cSrcweir Invalidate( maPaintRect ); 2891*cdf0e10cSrcweir } 2892*cdf0e10cSrcweir 2893*cdf0e10cSrcweir // store the new calculated item rects 2894*cdf0e10cSrcweir maPaintRect = aEmptyRect; 2895*cdf0e10cSrcweir Rectangle aVisibleRect(Point(0, 0), GetOutputSizePixel()); 2896*cdf0e10cSrcweir it = mpData->m_aItems.begin(); 2897*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 2898*cdf0e10cSrcweir { 2899*cdf0e10cSrcweir it->maRect = it->maCalcRect; 2900*cdf0e10cSrcweir if (!it->maRect.IsOver(aVisibleRect)) 2901*cdf0e10cSrcweir { 2902*cdf0e10cSrcweir // For items not visible, release resources only needed during 2903*cdf0e10cSrcweir // painting the items (on Win98, for example, these are system- 2904*cdf0e10cSrcweir // wide resources that are easily exhausted, so be nice): 2905*cdf0e10cSrcweir 2906*cdf0e10cSrcweir /* !!! 2907*cdf0e10cSrcweir it->maImage.ClearCaches(); 2908*cdf0e10cSrcweir it->maHighImage.ClearCaches(); 2909*cdf0e10cSrcweir */ 2910*cdf0e10cSrcweir } 2911*cdf0e10cSrcweir ++it; 2912*cdf0e10cSrcweir } 2913*cdf0e10cSrcweir } 2914*cdf0e10cSrcweir 2915*cdf0e10cSrcweir // indicate formatting is done 2916*cdf0e10cSrcweir mbFormat = sal_False; 2917*cdf0e10cSrcweir } 2918*cdf0e10cSrcweir 2919*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2920*cdf0e10cSrcweir 2921*cdf0e10cSrcweir IMPL_LINK( ToolBox, ImplDropdownLongClickHdl, ToolBox*, EMPTYARG ) 2922*cdf0e10cSrcweir { 2923*cdf0e10cSrcweir if( mnCurPos != TOOLBOX_ITEM_NOTFOUND && 2924*cdf0e10cSrcweir (mpData->m_aItems[ mnCurPos ].mnBits & TIB_DROPDOWN) 2925*cdf0e10cSrcweir ) 2926*cdf0e10cSrcweir { 2927*cdf0e10cSrcweir mpData->mbDropDownByKeyboard = sal_False; 2928*cdf0e10cSrcweir GetDropdownClickHdl().Call( this ); 2929*cdf0e10cSrcweir 2930*cdf0e10cSrcweir // do not reset data if the dropdown handler opened a floating window 2931*cdf0e10cSrcweir // see ImplFloatControl() 2932*cdf0e10cSrcweir if( mpFloatWin == NULL ) 2933*cdf0e10cSrcweir { 2934*cdf0e10cSrcweir // no floater was opened 2935*cdf0e10cSrcweir Deactivate(); 2936*cdf0e10cSrcweir ImplDrawItem( mnCurPos, sal_False ); 2937*cdf0e10cSrcweir 2938*cdf0e10cSrcweir mnCurPos = TOOLBOX_ITEM_NOTFOUND; 2939*cdf0e10cSrcweir mnCurItemId = 0; 2940*cdf0e10cSrcweir mnDownItemId = 0; 2941*cdf0e10cSrcweir mnMouseClicks = 0; 2942*cdf0e10cSrcweir mnMouseModifier = 0; 2943*cdf0e10cSrcweir mnHighItemId = 0; 2944*cdf0e10cSrcweir } 2945*cdf0e10cSrcweir } 2946*cdf0e10cSrcweir 2947*cdf0e10cSrcweir return 0; 2948*cdf0e10cSrcweir } 2949*cdf0e10cSrcweir 2950*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2951*cdf0e10cSrcweir 2952*cdf0e10cSrcweir IMPL_LINK( ToolBox, ImplUpdateHdl, void*, EMPTYARG ) 2953*cdf0e10cSrcweir { 2954*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 2955*cdf0e10cSrcweir 2956*cdf0e10cSrcweir if( mbFormat ) 2957*cdf0e10cSrcweir ImplFormat(); 2958*cdf0e10cSrcweir 2959*cdf0e10cSrcweir return 0; 2960*cdf0e10cSrcweir } 2961*cdf0e10cSrcweir 2962*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2963*cdf0e10cSrcweir 2964*cdf0e10cSrcweir static void ImplDrawMoreIndicator( ToolBox *pBox, const Rectangle& rRect, sal_Bool bSetColor, sal_Bool bRotate ) 2965*cdf0e10cSrcweir { 2966*cdf0e10cSrcweir Color aOldFillColor = pBox->GetFillColor(); 2967*cdf0e10cSrcweir Color aOldLineColor = pBox->GetLineColor(); 2968*cdf0e10cSrcweir pBox->SetLineColor(); 2969*cdf0e10cSrcweir 2970*cdf0e10cSrcweir if ( bSetColor ) 2971*cdf0e10cSrcweir { 2972*cdf0e10cSrcweir if ( pBox->GetSettings().GetStyleSettings().GetFaceColor().IsDark() ) 2973*cdf0e10cSrcweir pBox->SetFillColor( Color( COL_WHITE ) ); 2974*cdf0e10cSrcweir else 2975*cdf0e10cSrcweir pBox->SetFillColor( Color( COL_BLACK ) ); 2976*cdf0e10cSrcweir } 2977*cdf0e10cSrcweir 2978*cdf0e10cSrcweir if( !bRotate ) 2979*cdf0e10cSrcweir { 2980*cdf0e10cSrcweir long width = 8; 2981*cdf0e10cSrcweir long height = 5; 2982*cdf0e10cSrcweir long x = rRect.Left() + (rRect.getWidth() - width)/2 + 1; 2983*cdf0e10cSrcweir long y = rRect.Top() + (rRect.getHeight() - height)/2 + 1; 2984*cdf0e10cSrcweir while( height >= 1) 2985*cdf0e10cSrcweir { 2986*cdf0e10cSrcweir pBox->DrawRect( Rectangle( x, y, x+1, y ) ); 2987*cdf0e10cSrcweir x+=4; 2988*cdf0e10cSrcweir pBox->DrawRect( Rectangle( x, y, x+1, y ) ); 2989*cdf0e10cSrcweir x-=4; 2990*cdf0e10cSrcweir y++; 2991*cdf0e10cSrcweir if( height <= 3) x--; 2992*cdf0e10cSrcweir else x++; 2993*cdf0e10cSrcweir height--; 2994*cdf0e10cSrcweir } 2995*cdf0e10cSrcweir } 2996*cdf0e10cSrcweir else 2997*cdf0e10cSrcweir { 2998*cdf0e10cSrcweir long width = 5; 2999*cdf0e10cSrcweir long height = 8; 3000*cdf0e10cSrcweir long x = rRect.Left() + (rRect.getWidth() - width)/2 + 1; 3001*cdf0e10cSrcweir long y = rRect.Top() + (rRect.getHeight() - height)/2 + 1; 3002*cdf0e10cSrcweir while( width >= 1) 3003*cdf0e10cSrcweir { 3004*cdf0e10cSrcweir pBox->DrawRect( Rectangle( x, y, x, y+1 ) ); 3005*cdf0e10cSrcweir y+=4; 3006*cdf0e10cSrcweir pBox->DrawRect( Rectangle( x, y, x, y+1 ) ); 3007*cdf0e10cSrcweir y-=4; 3008*cdf0e10cSrcweir x++; 3009*cdf0e10cSrcweir if( width <= 3) y--; 3010*cdf0e10cSrcweir else y++; 3011*cdf0e10cSrcweir width--; 3012*cdf0e10cSrcweir } 3013*cdf0e10cSrcweir } 3014*cdf0e10cSrcweir 3015*cdf0e10cSrcweir pBox->SetFillColor( aOldFillColor ); 3016*cdf0e10cSrcweir pBox->SetLineColor( aOldLineColor ); 3017*cdf0e10cSrcweir } 3018*cdf0e10cSrcweir 3019*cdf0e10cSrcweir static void ImplDrawDropdownArrow( ToolBox *pBox, const Rectangle& rDropDownRect, sal_Bool bSetColor, sal_Bool bRotate ) 3020*cdf0e10cSrcweir { 3021*cdf0e10cSrcweir sal_Bool bLineColor = pBox->IsLineColor(); 3022*cdf0e10cSrcweir sal_Bool bFillColor = pBox->IsFillColor(); 3023*cdf0e10cSrcweir Color aOldFillColor = pBox->GetFillColor(); 3024*cdf0e10cSrcweir Color aOldLineColor = pBox->GetLineColor(); 3025*cdf0e10cSrcweir pBox->SetLineColor(); 3026*cdf0e10cSrcweir 3027*cdf0e10cSrcweir if ( bSetColor ) 3028*cdf0e10cSrcweir { 3029*cdf0e10cSrcweir if ( pBox->GetSettings().GetStyleSettings().GetFaceColor().IsDark() ) 3030*cdf0e10cSrcweir pBox->SetFillColor( Color( COL_WHITE ) ); 3031*cdf0e10cSrcweir else 3032*cdf0e10cSrcweir pBox->SetFillColor( Color( COL_BLACK ) ); 3033*cdf0e10cSrcweir } 3034*cdf0e10cSrcweir 3035*cdf0e10cSrcweir if( !bRotate ) 3036*cdf0e10cSrcweir { 3037*cdf0e10cSrcweir long width = 5; 3038*cdf0e10cSrcweir long height = 3; 3039*cdf0e10cSrcweir long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2; 3040*cdf0e10cSrcweir long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2; 3041*cdf0e10cSrcweir while( width >= 1) 3042*cdf0e10cSrcweir { 3043*cdf0e10cSrcweir pBox->DrawRect( Rectangle( x, y, x+width-1, y ) ); 3044*cdf0e10cSrcweir y++; x++; 3045*cdf0e10cSrcweir width -= 2; 3046*cdf0e10cSrcweir } 3047*cdf0e10cSrcweir } 3048*cdf0e10cSrcweir else 3049*cdf0e10cSrcweir { 3050*cdf0e10cSrcweir long width = 3; 3051*cdf0e10cSrcweir long height = 5; 3052*cdf0e10cSrcweir long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2; 3053*cdf0e10cSrcweir long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2; 3054*cdf0e10cSrcweir while( height >= 1) 3055*cdf0e10cSrcweir { 3056*cdf0e10cSrcweir pBox->DrawRect( Rectangle( x, y, x, y+height-1 ) ); 3057*cdf0e10cSrcweir y++; x++; 3058*cdf0e10cSrcweir height -= 2; 3059*cdf0e10cSrcweir } 3060*cdf0e10cSrcweir } 3061*cdf0e10cSrcweir 3062*cdf0e10cSrcweir if( bFillColor ) 3063*cdf0e10cSrcweir pBox->SetFillColor( aOldFillColor ); 3064*cdf0e10cSrcweir else 3065*cdf0e10cSrcweir pBox->SetFillColor(); 3066*cdf0e10cSrcweir if( bLineColor ) 3067*cdf0e10cSrcweir pBox->SetLineColor( aOldLineColor ); 3068*cdf0e10cSrcweir else 3069*cdf0e10cSrcweir pBox->SetLineColor( ); 3070*cdf0e10cSrcweir } 3071*cdf0e10cSrcweir 3072*cdf0e10cSrcweir void ToolBox::ImplDrawToolArrow( ToolBox* pBox, long nX, long nY, sal_Bool bBlack, sal_Bool bColTransform, 3073*cdf0e10cSrcweir sal_Bool bLeft, sal_Bool bTop, long nSize ) 3074*cdf0e10cSrcweir { 3075*cdf0e10cSrcweir Color aOldFillColor = pBox->GetFillColor(); 3076*cdf0e10cSrcweir WindowAlign eAlign = pBox->meAlign; 3077*cdf0e10cSrcweir long n = 0; 3078*cdf0e10cSrcweir long nHalfSize; 3079*cdf0e10cSrcweir if ( bLeft ) 3080*cdf0e10cSrcweir eAlign = WINDOWALIGN_RIGHT; 3081*cdf0e10cSrcweir else if ( bTop ) 3082*cdf0e10cSrcweir eAlign = WINDOWALIGN_BOTTOM; 3083*cdf0e10cSrcweir 3084*cdf0e10cSrcweir nHalfSize = nSize/2; 3085*cdf0e10cSrcweir 3086*cdf0e10cSrcweir switch ( eAlign ) 3087*cdf0e10cSrcweir { 3088*cdf0e10cSrcweir case WINDOWALIGN_LEFT: 3089*cdf0e10cSrcweir if ( bBlack ) 3090*cdf0e10cSrcweir pBox->SetFillColor( Color( bColTransform ? COL_WHITE : COL_BLACK ) ); 3091*cdf0e10cSrcweir while ( n <= nHalfSize ) 3092*cdf0e10cSrcweir { 3093*cdf0e10cSrcweir pBox->DrawRect( Rectangle( nX+n, nY+n, nX+n, nY+nSize-n ) ); 3094*cdf0e10cSrcweir n++; 3095*cdf0e10cSrcweir } 3096*cdf0e10cSrcweir if ( bBlack ) 3097*cdf0e10cSrcweir { 3098*cdf0e10cSrcweir pBox->SetFillColor( aOldFillColor ); 3099*cdf0e10cSrcweir n = 1; 3100*cdf0e10cSrcweir while ( n < nHalfSize ) 3101*cdf0e10cSrcweir { 3102*cdf0e10cSrcweir pBox->DrawRect( Rectangle( nX+n, nY+1+n, nX+n, nY+nSize-1-n ) ); 3103*cdf0e10cSrcweir n++; 3104*cdf0e10cSrcweir } 3105*cdf0e10cSrcweir } 3106*cdf0e10cSrcweir break; 3107*cdf0e10cSrcweir case WINDOWALIGN_TOP: 3108*cdf0e10cSrcweir if ( bBlack ) 3109*cdf0e10cSrcweir pBox->SetFillColor( Color( bColTransform ? COL_WHITE : COL_BLACK ) ); 3110*cdf0e10cSrcweir while ( n <= nHalfSize ) 3111*cdf0e10cSrcweir { 3112*cdf0e10cSrcweir pBox->DrawRect( Rectangle( nX+n, nY+n, nX+nSize-n, nY+n ) ); 3113*cdf0e10cSrcweir n++; 3114*cdf0e10cSrcweir } 3115*cdf0e10cSrcweir if ( bBlack ) 3116*cdf0e10cSrcweir { 3117*cdf0e10cSrcweir pBox->SetFillColor( aOldFillColor ); 3118*cdf0e10cSrcweir n = 1; 3119*cdf0e10cSrcweir while ( n < nHalfSize ) 3120*cdf0e10cSrcweir { 3121*cdf0e10cSrcweir pBox->DrawRect( Rectangle( nX+1+n, nY+n, nX+nSize-1-n, nY+n ) ); 3122*cdf0e10cSrcweir n++; 3123*cdf0e10cSrcweir } 3124*cdf0e10cSrcweir } 3125*cdf0e10cSrcweir break; 3126*cdf0e10cSrcweir case WINDOWALIGN_RIGHT: 3127*cdf0e10cSrcweir if ( bBlack ) 3128*cdf0e10cSrcweir pBox->SetFillColor( Color( bColTransform ? COL_WHITE : COL_BLACK ) ); 3129*cdf0e10cSrcweir while ( n <= nHalfSize ) 3130*cdf0e10cSrcweir { 3131*cdf0e10cSrcweir pBox->DrawRect( Rectangle( nX+nHalfSize-n, nY+n, nX+nHalfSize-n, nY+nSize-n ) ); 3132*cdf0e10cSrcweir n++; 3133*cdf0e10cSrcweir } 3134*cdf0e10cSrcweir if ( bBlack ) 3135*cdf0e10cSrcweir { 3136*cdf0e10cSrcweir pBox->SetFillColor( aOldFillColor ); 3137*cdf0e10cSrcweir n = 1; 3138*cdf0e10cSrcweir while ( n < nHalfSize ) 3139*cdf0e10cSrcweir { 3140*cdf0e10cSrcweir pBox->DrawRect( Rectangle( nX+nHalfSize-n, nY+1+n, nX+nHalfSize-n, nY+nSize-1-n ) ); 3141*cdf0e10cSrcweir n++; 3142*cdf0e10cSrcweir } 3143*cdf0e10cSrcweir } 3144*cdf0e10cSrcweir break; 3145*cdf0e10cSrcweir case WINDOWALIGN_BOTTOM: 3146*cdf0e10cSrcweir if ( bBlack ) 3147*cdf0e10cSrcweir pBox->SetFillColor( Color( bColTransform ? COL_WHITE : COL_BLACK ) ); 3148*cdf0e10cSrcweir while ( n <= nHalfSize ) 3149*cdf0e10cSrcweir { 3150*cdf0e10cSrcweir pBox->DrawRect( Rectangle( nX+n, nY+nHalfSize-n, nX+nSize-n, nY+nHalfSize-n ) ); 3151*cdf0e10cSrcweir n++; 3152*cdf0e10cSrcweir } 3153*cdf0e10cSrcweir if ( bBlack ) 3154*cdf0e10cSrcweir { 3155*cdf0e10cSrcweir pBox->SetFillColor( aOldFillColor ); 3156*cdf0e10cSrcweir n = 1; 3157*cdf0e10cSrcweir while ( n < nHalfSize ) 3158*cdf0e10cSrcweir { 3159*cdf0e10cSrcweir pBox->DrawRect( Rectangle( nX+1+n, nY+nHalfSize-n, nX+nSize-1-n, nY+nHalfSize-n ) ); 3160*cdf0e10cSrcweir n++; 3161*cdf0e10cSrcweir } 3162*cdf0e10cSrcweir } 3163*cdf0e10cSrcweir break; 3164*cdf0e10cSrcweir } 3165*cdf0e10cSrcweir } 3166*cdf0e10cSrcweir 3167*cdf0e10cSrcweir void ToolBox::SetToolArrowClipregion( ToolBox* pBox, long nX, long nY, 3168*cdf0e10cSrcweir sal_Bool bLeft, sal_Bool bTop, long nSize ) 3169*cdf0e10cSrcweir { 3170*cdf0e10cSrcweir WindowAlign eAlign = pBox->meAlign; 3171*cdf0e10cSrcweir long nHalfSize; 3172*cdf0e10cSrcweir if ( bLeft ) 3173*cdf0e10cSrcweir eAlign = WINDOWALIGN_RIGHT; 3174*cdf0e10cSrcweir else if ( bTop ) 3175*cdf0e10cSrcweir eAlign = WINDOWALIGN_BOTTOM; 3176*cdf0e10cSrcweir 3177*cdf0e10cSrcweir nHalfSize = nSize/2; 3178*cdf0e10cSrcweir 3179*cdf0e10cSrcweir Point p[6]; 3180*cdf0e10cSrcweir 3181*cdf0e10cSrcweir switch ( eAlign ) 3182*cdf0e10cSrcweir { 3183*cdf0e10cSrcweir case WINDOWALIGN_LEFT: 3184*cdf0e10cSrcweir p[0].X() = nX-1; p[0].Y() = nY-1; 3185*cdf0e10cSrcweir p[1].X() = nX-1; p[1].Y() = nY+nSize+1; 3186*cdf0e10cSrcweir p[2].X() = nX+1; p[2].Y() = nY+nSize+1; 3187*cdf0e10cSrcweir p[3].X() = nX+nHalfSize+1; p[3].Y() = nY+nHalfSize+1; 3188*cdf0e10cSrcweir p[4].X() = nX+nHalfSize+1; p[4].Y() = nY+nHalfSize-1; 3189*cdf0e10cSrcweir p[5].X() = nX+1; p[5].Y() = nY-1; 3190*cdf0e10cSrcweir break; 3191*cdf0e10cSrcweir case WINDOWALIGN_TOP: 3192*cdf0e10cSrcweir p[0].X() = nX-1; p[0].Y() = nY-1; 3193*cdf0e10cSrcweir p[1].X() = nX-1; p[1].Y() = nY+1; 3194*cdf0e10cSrcweir p[2].X() = nX+nHalfSize-1; p[2].Y() = nY+nHalfSize+1; 3195*cdf0e10cSrcweir p[3].X() = nX+nHalfSize+1; p[3].Y() = nY+nHalfSize+1; 3196*cdf0e10cSrcweir p[4].X() = nX+nSize+1; p[4].Y() = nY+1; 3197*cdf0e10cSrcweir p[5].X() = nX+nSize+1; p[5].Y() = nY-1; 3198*cdf0e10cSrcweir break; 3199*cdf0e10cSrcweir case WINDOWALIGN_RIGHT: 3200*cdf0e10cSrcweir p[0].X() = nX+nHalfSize-1; p[0].Y() = nY-1; 3201*cdf0e10cSrcweir p[1].X() = nX-1; p[1].Y() = nY+nHalfSize-1; 3202*cdf0e10cSrcweir p[2].X() = nX-1; p[2].Y() = nY+nHalfSize+1; 3203*cdf0e10cSrcweir p[3].X() = nX+nHalfSize-1; p[3].Y() = nY+nSize+1; 3204*cdf0e10cSrcweir p[4].X() = nX+nHalfSize+1; p[4].Y() = nY+nSize+1; 3205*cdf0e10cSrcweir p[5].X() = nX+nHalfSize+1; p[5].Y() = nY-1; 3206*cdf0e10cSrcweir break; 3207*cdf0e10cSrcweir case WINDOWALIGN_BOTTOM: 3208*cdf0e10cSrcweir p[0].X() = nX-1; p[0].Y() = nY+nHalfSize-1; 3209*cdf0e10cSrcweir p[1].X() = nX-1; p[1].Y() = nY+nHalfSize+1; 3210*cdf0e10cSrcweir p[2].X() = nX+nSize+1; p[2].Y() = nY+nHalfSize+1; 3211*cdf0e10cSrcweir p[3].X() = nX+nSize+1; p[3].Y() = nY+nHalfSize-1; 3212*cdf0e10cSrcweir p[4].X() = nX+nHalfSize+1; p[4].Y() = nY-1; 3213*cdf0e10cSrcweir p[5].X() = nX+nHalfSize-1; p[5].Y() = nY-1; 3214*cdf0e10cSrcweir break; 3215*cdf0e10cSrcweir } 3216*cdf0e10cSrcweir Polygon aPoly(6,p); 3217*cdf0e10cSrcweir Region aRgn( aPoly ); 3218*cdf0e10cSrcweir pBox->SetClipRegion( aRgn ); 3219*cdf0e10cSrcweir } 3220*cdf0e10cSrcweir 3221*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3222*cdf0e10cSrcweir 3223*cdf0e10cSrcweir void ToolBox::ImplDrawMenubutton( ToolBox *pThis, sal_Bool bHighlight ) 3224*cdf0e10cSrcweir { 3225*cdf0e10cSrcweir if( !pThis->mpData->maMenubuttonItem.maRect.IsEmpty() ) 3226*cdf0e10cSrcweir { 3227*cdf0e10cSrcweir // #i53937# paint menu button only if necessary 3228*cdf0e10cSrcweir if( !(pThis->GetMenuType() & TOOLBOX_MENUTYPE_CUSTOMIZE) && !pThis->ImplHasClippedItems() ) 3229*cdf0e10cSrcweir return; 3230*cdf0e10cSrcweir 3231*cdf0e10cSrcweir // execute pending paint requests 3232*cdf0e10cSrcweir ImplCheckUpdate( pThis ); 3233*cdf0e10cSrcweir 3234*cdf0e10cSrcweir sal_Bool bFillColor = pThis->IsFillColor(); 3235*cdf0e10cSrcweir sal_Bool bLineColor = pThis->IsLineColor(); 3236*cdf0e10cSrcweir Color aOldFillCol = pThis->GetFillColor(); 3237*cdf0e10cSrcweir Color aOldLineCol = pThis->GetLineColor(); 3238*cdf0e10cSrcweir sal_Bool bNativeButtons = pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ); 3239*cdf0e10cSrcweir 3240*cdf0e10cSrcweir Rectangle aInnerRect( pThis->mpData->maMenubuttonItem.maRect ); 3241*cdf0e10cSrcweir if( pThis->mpData->mnMenuButtonWidth > TB_MENUBUTTON_SIZE ) 3242*cdf0e10cSrcweir { 3243*cdf0e10cSrcweir long nDiff = pThis->mpData->mnMenuButtonWidth - TB_MENUBUTTON_SIZE; 3244*cdf0e10cSrcweir long nDiff1 = nDiff/2; 3245*cdf0e10cSrcweir long nDiff2 = nDiff - nDiff1; 3246*cdf0e10cSrcweir if( pThis->IsHorizontal() ) 3247*cdf0e10cSrcweir { 3248*cdf0e10cSrcweir aInnerRect.Left() += nDiff1; 3249*cdf0e10cSrcweir aInnerRect.Right() -= nDiff2; 3250*cdf0e10cSrcweir } 3251*cdf0e10cSrcweir else 3252*cdf0e10cSrcweir { 3253*cdf0e10cSrcweir aInnerRect.Top() += nDiff1; 3254*cdf0e10cSrcweir aInnerRect.Bottom() -= nDiff2; 3255*cdf0e10cSrcweir } 3256*cdf0e10cSrcweir } 3257*cdf0e10cSrcweir 3258*cdf0e10cSrcweir if( pThis->IsHorizontal() ) 3259*cdf0e10cSrcweir { 3260*cdf0e10cSrcweir aInnerRect.nLeft+=2; 3261*cdf0e10cSrcweir aInnerRect.nRight-=1; 3262*cdf0e10cSrcweir aInnerRect.nTop+=1; 3263*cdf0e10cSrcweir aInnerRect.nBottom-=1; 3264*cdf0e10cSrcweir } 3265*cdf0e10cSrcweir else 3266*cdf0e10cSrcweir { 3267*cdf0e10cSrcweir aInnerRect.nLeft+=1; 3268*cdf0e10cSrcweir aInnerRect.nRight-=1; 3269*cdf0e10cSrcweir aInnerRect.nTop+=2; 3270*cdf0e10cSrcweir aInnerRect.nBottom-=1; 3271*cdf0e10cSrcweir } 3272*cdf0e10cSrcweir 3273*cdf0e10cSrcweir ImplErase( pThis, bNativeButtons ? pThis->mpData->maMenubuttonItem.maRect : aInnerRect, bHighlight ); 3274*cdf0e10cSrcweir 3275*cdf0e10cSrcweir if( bHighlight ) 3276*cdf0e10cSrcweir { 3277*cdf0e10cSrcweir if( bNativeButtons ) 3278*cdf0e10cSrcweir ImplDrawButton( pThis, pThis->mpData->maMenubuttonItem.maRect, 2, sal_False, sal_True, sal_False ); 3279*cdf0e10cSrcweir else 3280*cdf0e10cSrcweir pThis->DrawSelectionBackground( aInnerRect, 2, sal_False, sal_False, sal_False ); 3281*cdf0e10cSrcweir } 3282*cdf0e10cSrcweir else 3283*cdf0e10cSrcweir { 3284*cdf0e10cSrcweir // improve visibility by using a dark gradient 3285*cdf0e10cSrcweir Gradient g; 3286*cdf0e10cSrcweir g.SetAngle( pThis->mbHorz ? 0 : 900 ); 3287*cdf0e10cSrcweir g.SetStyle( GRADIENT_LINEAR ); 3288*cdf0e10cSrcweir 3289*cdf0e10cSrcweir g.SetStartColor( pThis->GetSettings().GetStyleSettings().GetFaceColor() ); 3290*cdf0e10cSrcweir g.SetEndColor( pThis->GetSettings().GetStyleSettings().GetShadowColor() ); 3291*cdf0e10cSrcweir 3292*cdf0e10cSrcweir pThis->DrawGradient( aInnerRect, g ); 3293*cdf0e10cSrcweir } 3294*cdf0e10cSrcweir 3295*cdf0e10cSrcweir Rectangle aRect( aInnerRect ); 3296*cdf0e10cSrcweir if( pThis->mbHorz ) 3297*cdf0e10cSrcweir aRect.Top() = aRect.Bottom() - aRect.getHeight()/3; 3298*cdf0e10cSrcweir else 3299*cdf0e10cSrcweir aRect.Left() = aRect.Right() - aRect.getWidth()/3; 3300*cdf0e10cSrcweir 3301*cdf0e10cSrcweir if( pThis->mpData->maMenuType & TOOLBOX_MENUTYPE_CUSTOMIZE ) 3302*cdf0e10cSrcweir ImplDrawDropdownArrow( pThis, aRect, sal_True, !pThis->mbHorz ); 3303*cdf0e10cSrcweir 3304*cdf0e10cSrcweir if( pThis->ImplHasClippedItems() ) 3305*cdf0e10cSrcweir { 3306*cdf0e10cSrcweir aRect = aInnerRect; 3307*cdf0e10cSrcweir if( pThis->mbHorz ) 3308*cdf0e10cSrcweir aRect.Bottom() = aRect.Top() + aRect.getHeight()/3; 3309*cdf0e10cSrcweir else 3310*cdf0e10cSrcweir aRect.Right() = aRect.Left() + aRect.getWidth()/3; 3311*cdf0e10cSrcweir 3312*cdf0e10cSrcweir ImplDrawMoreIndicator( pThis, aRect, sal_True, !pThis->mbHorz ); 3313*cdf0e10cSrcweir } 3314*cdf0e10cSrcweir 3315*cdf0e10cSrcweir // store highlight state 3316*cdf0e10cSrcweir pThis->mpData->mbMenubuttonSelected = bHighlight; 3317*cdf0e10cSrcweir 3318*cdf0e10cSrcweir // restore colors 3319*cdf0e10cSrcweir if( bFillColor ) 3320*cdf0e10cSrcweir pThis->SetFillColor( aOldFillCol ); 3321*cdf0e10cSrcweir else 3322*cdf0e10cSrcweir pThis->SetFillColor(); 3323*cdf0e10cSrcweir if( bLineColor ) 3324*cdf0e10cSrcweir pThis->SetLineColor( aOldLineCol ); 3325*cdf0e10cSrcweir else 3326*cdf0e10cSrcweir pThis->SetLineColor(); 3327*cdf0e10cSrcweir } 3328*cdf0e10cSrcweir } 3329*cdf0e10cSrcweir 3330*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3331*cdf0e10cSrcweir 3332*cdf0e10cSrcweir void ToolBox::ImplDrawSpin( sal_Bool bUpperIn, sal_Bool bLowerIn ) 3333*cdf0e10cSrcweir { 3334*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 3335*cdf0e10cSrcweir 3336*cdf0e10cSrcweir sal_Bool bTmpUpper; 3337*cdf0e10cSrcweir sal_Bool bTmpLower; 3338*cdf0e10cSrcweir 3339*cdf0e10cSrcweir if ( maUpperRect.IsEmpty() || maLowerRect.IsEmpty() ) 3340*cdf0e10cSrcweir return; 3341*cdf0e10cSrcweir 3342*cdf0e10cSrcweir if ( mnCurLine > 1 ) 3343*cdf0e10cSrcweir bTmpUpper = sal_True; 3344*cdf0e10cSrcweir else 3345*cdf0e10cSrcweir bTmpUpper = sal_False; 3346*cdf0e10cSrcweir 3347*cdf0e10cSrcweir if ( mnCurLine+mnVisLines-1 < mnCurLines ) 3348*cdf0e10cSrcweir bTmpLower = sal_True; 3349*cdf0e10cSrcweir else 3350*cdf0e10cSrcweir bTmpLower = sal_False; 3351*cdf0e10cSrcweir 3352*cdf0e10cSrcweir if ( !IsEnabled() ) 3353*cdf0e10cSrcweir { 3354*cdf0e10cSrcweir bTmpUpper = sal_False; 3355*cdf0e10cSrcweir bTmpLower = sal_False; 3356*cdf0e10cSrcweir } 3357*cdf0e10cSrcweir 3358*cdf0e10cSrcweir ImplDrawSpinButton( this, maUpperRect, maLowerRect, 3359*cdf0e10cSrcweir bUpperIn, bLowerIn, bTmpUpper, bTmpLower, !mbHorz ); 3360*cdf0e10cSrcweir } 3361*cdf0e10cSrcweir 3362*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3363*cdf0e10cSrcweir 3364*cdf0e10cSrcweir void ToolBox::ImplDrawNext( sal_Bool bIn ) 3365*cdf0e10cSrcweir { 3366*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 3367*cdf0e10cSrcweir 3368*cdf0e10cSrcweir if ( maNextToolRect.IsEmpty() ) 3369*cdf0e10cSrcweir return; 3370*cdf0e10cSrcweir 3371*cdf0e10cSrcweir DecorationView aDecoView( this ); 3372*cdf0e10cSrcweir 3373*cdf0e10cSrcweir // Button malen 3374*cdf0e10cSrcweir long nX = SMALLBUTTON_OFF_NORMAL_X; 3375*cdf0e10cSrcweir long nY = SMALLBUTTON_OFF_NORMAL_Y; 3376*cdf0e10cSrcweir sal_uInt16 nStyle = 0; 3377*cdf0e10cSrcweir if ( bIn == 1 ) 3378*cdf0e10cSrcweir { 3379*cdf0e10cSrcweir nStyle |= BUTTON_DRAW_PRESSED; 3380*cdf0e10cSrcweir nX = SMALLBUTTON_OFF_PRESSED_X; 3381*cdf0e10cSrcweir nY = SMALLBUTTON_OFF_PRESSED_Y; 3382*cdf0e10cSrcweir } 3383*cdf0e10cSrcweir aDecoView.DrawButton( maNextToolRect, nStyle ); 3384*cdf0e10cSrcweir 3385*cdf0e10cSrcweir // Inhalt ausgeben 3386*cdf0e10cSrcweir sal_Bool bLeft = sal_False; 3387*cdf0e10cSrcweir sal_Bool bTop = sal_False; 3388*cdf0e10cSrcweir if ( mbHorz ) 3389*cdf0e10cSrcweir { 3390*cdf0e10cSrcweir bLeft = sal_True; 3391*cdf0e10cSrcweir nX += (maNextToolRect.GetWidth()-6)/2-4; 3392*cdf0e10cSrcweir nY += (maNextToolRect.GetHeight()-6)/2-6; 3393*cdf0e10cSrcweir } 3394*cdf0e10cSrcweir else 3395*cdf0e10cSrcweir { 3396*cdf0e10cSrcweir bTop = sal_True; 3397*cdf0e10cSrcweir nY += (maNextToolRect.GetHeight()-6)/2-4; 3398*cdf0e10cSrcweir nX += (maNextToolRect.GetWidth()-6)/2-6; 3399*cdf0e10cSrcweir } 3400*cdf0e10cSrcweir 3401*cdf0e10cSrcweir nX += maNextToolRect.Left(); 3402*cdf0e10cSrcweir nY += maNextToolRect.Top(); 3403*cdf0e10cSrcweir SetLineColor(); 3404*cdf0e10cSrcweir SetFillColor( COL_LIGHTBLUE ); 3405*cdf0e10cSrcweir ImplDrawToolArrow( this, nX, nY, sal_True, sal_False, bLeft, bTop, 10 ); 3406*cdf0e10cSrcweir } 3407*cdf0e10cSrcweir 3408*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3409*cdf0e10cSrcweir 3410*cdf0e10cSrcweir static void ImplDrawButton( ToolBox* pThis, const Rectangle &rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bEnabled, sal_Bool bIsWindow ) 3411*cdf0e10cSrcweir { 3412*cdf0e10cSrcweir // draws toolbar button background either native or using a coloured selection 3413*cdf0e10cSrcweir // if bIsWindow is sal_True, the corresponding item is a control and only a selection border will be drawn 3414*cdf0e10cSrcweir 3415*cdf0e10cSrcweir sal_Bool bNativeOk = sal_False; 3416*cdf0e10cSrcweir if( !bIsWindow && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) 3417*cdf0e10cSrcweir { 3418*cdf0e10cSrcweir ImplControlValue aControlValue; 3419*cdf0e10cSrcweir ControlState nState = 0; 3420*cdf0e10cSrcweir 3421*cdf0e10cSrcweir if ( highlight == 1 ) nState |= CTRL_STATE_PRESSED; 3422*cdf0e10cSrcweir if ( highlight == 2 ) nState |= CTRL_STATE_ROLLOVER; 3423*cdf0e10cSrcweir if ( bEnabled ) nState |= CTRL_STATE_ENABLED; 3424*cdf0e10cSrcweir 3425*cdf0e10cSrcweir aControlValue.setTristateVal( bChecked ? BUTTONVALUE_ON : BUTTONVALUE_OFF ); 3426*cdf0e10cSrcweir 3427*cdf0e10cSrcweir 3428*cdf0e10cSrcweir bNativeOk = pThis->DrawNativeControl( CTRL_TOOLBAR, PART_BUTTON, 3429*cdf0e10cSrcweir rRect, nState, aControlValue, rtl::OUString() ); 3430*cdf0e10cSrcweir } 3431*cdf0e10cSrcweir 3432*cdf0e10cSrcweir if( !bNativeOk ) 3433*cdf0e10cSrcweir pThis->DrawSelectionBackground( rRect, bIsWindow ? 3 : highlight, bChecked, sal_True, bIsWindow, 2, NULL, NULL ); 3434*cdf0e10cSrcweir } 3435*cdf0e10cSrcweir 3436*cdf0e10cSrcweir void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_Bool bHighlight, sal_Bool bPaint, sal_Bool bLayout ) 3437*cdf0e10cSrcweir { 3438*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 3439*cdf0e10cSrcweir 3440*cdf0e10cSrcweir if( nPos >= mpData->m_aItems.size() ) 3441*cdf0e10cSrcweir return; 3442*cdf0e10cSrcweir 3443*cdf0e10cSrcweir // execute pending paint requests 3444*cdf0e10cSrcweir ImplCheckUpdate( this ); 3445*cdf0e10cSrcweir 3446*cdf0e10cSrcweir ImplDisableFlatButtons(); 3447*cdf0e10cSrcweir 3448*cdf0e10cSrcweir SetFillColor(); 3449*cdf0e10cSrcweir 3450*cdf0e10cSrcweir ImplToolItem* pItem = &mpData->m_aItems[nPos]; 3451*cdf0e10cSrcweir MetricVector* pVector = bLayout ? &mpData->m_pLayoutData->m_aUnicodeBoundRects : NULL; 3452*cdf0e10cSrcweir String* pDisplayText = bLayout ? &mpData->m_pLayoutData->m_aDisplayText : NULL; 3453*cdf0e10cSrcweir 3454*cdf0e10cSrcweir bHighlight = bHighlight && pItem->mbEnabled; 3455*cdf0e10cSrcweir 3456*cdf0e10cSrcweir // Falls Rechteck ausserhalb des sichbaren Bereichs liegt 3457*cdf0e10cSrcweir if ( pItem->maRect.IsEmpty() ) 3458*cdf0e10cSrcweir return; 3459*cdf0e10cSrcweir 3460*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 3461*cdf0e10cSrcweir 3462*cdf0e10cSrcweir // no gradient background for items that have a popup open 3463*cdf0e10cSrcweir sal_Bool bHasOpenPopup = (mpFloatWin != NULL) && (mnDownItemId==pItem->mnId); 3464*cdf0e10cSrcweir 3465*cdf0e10cSrcweir sal_Bool bHighContrastWhite = sal_False; 3466*cdf0e10cSrcweir // check the face color as highcontrast indicator 3467*cdf0e10cSrcweir // because the toolbox itself might have a gradient 3468*cdf0e10cSrcweir if( rStyleSettings.GetFaceColor() == Color( COL_WHITE ) ) 3469*cdf0e10cSrcweir bHighContrastWhite = sal_True; 3470*cdf0e10cSrcweir 3471*cdf0e10cSrcweir // draw separators in flat style only 3472*cdf0e10cSrcweir if ( !bLayout && 3473*cdf0e10cSrcweir (mnOutStyle & TOOLBOX_STYLE_FLAT) && 3474*cdf0e10cSrcweir (pItem->meType == TOOLBOXITEM_SEPARATOR) && 3475*cdf0e10cSrcweir nPos > 0 3476*cdf0e10cSrcweir ) 3477*cdf0e10cSrcweir { 3478*cdf0e10cSrcweir // no separator before or after windows or at breaks 3479*cdf0e10cSrcweir ImplToolItem* pTempItem = &mpData->m_aItems[nPos-1]; 3480*cdf0e10cSrcweir if ( pTempItem && !pTempItem->mbShowWindow && nPos < mpData->m_aItems.size()-1 ) 3481*cdf0e10cSrcweir { 3482*cdf0e10cSrcweir pTempItem = &mpData->m_aItems[nPos+1]; 3483*cdf0e10cSrcweir if ( !pTempItem->mbShowWindow && !pTempItem->mbBreak ) 3484*cdf0e10cSrcweir { 3485*cdf0e10cSrcweir long nCenterPos, nSlim; 3486*cdf0e10cSrcweir SetLineColor( rStyleSettings.GetSeparatorColor() ); 3487*cdf0e10cSrcweir if ( IsHorizontal() ) 3488*cdf0e10cSrcweir { 3489*cdf0e10cSrcweir nSlim = (pItem->maRect.Bottom() - pItem->maRect.Top ()) / 4; 3490*cdf0e10cSrcweir nCenterPos = pItem->maRect.Center().X(); 3491*cdf0e10cSrcweir DrawLine( Point( nCenterPos, pItem->maRect.Top() + nSlim ), 3492*cdf0e10cSrcweir Point( nCenterPos, pItem->maRect.Bottom() - nSlim ) ); 3493*cdf0e10cSrcweir } 3494*cdf0e10cSrcweir else 3495*cdf0e10cSrcweir { 3496*cdf0e10cSrcweir nSlim = (pItem->maRect.Right() - pItem->maRect.Left ()) / 4; 3497*cdf0e10cSrcweir nCenterPos = pItem->maRect.Center().Y(); 3498*cdf0e10cSrcweir DrawLine( Point( pItem->maRect.Left() + nSlim, nCenterPos ), 3499*cdf0e10cSrcweir Point( pItem->maRect.Right() - nSlim, nCenterPos ) ); 3500*cdf0e10cSrcweir } 3501*cdf0e10cSrcweir } 3502*cdf0e10cSrcweir } 3503*cdf0e10cSrcweir } 3504*cdf0e10cSrcweir 3505*cdf0e10cSrcweir // do nothing if item is no button or will be displayed as window 3506*cdf0e10cSrcweir if ( (pItem->meType != TOOLBOXITEM_BUTTON) || 3507*cdf0e10cSrcweir (pItem->mbShowWindow && !mbCustomizeMode) ) 3508*cdf0e10cSrcweir return; 3509*cdf0e10cSrcweir 3510*cdf0e10cSrcweir // we need a TBDragMananger to draw the configuration item 3511*cdf0e10cSrcweir ImplTBDragMgr* pMgr; 3512*cdf0e10cSrcweir if ( pItem->mnId == mnConfigItem ) 3513*cdf0e10cSrcweir { 3514*cdf0e10cSrcweir pMgr = ImplGetTBDragMgr(); 3515*cdf0e10cSrcweir pMgr->HideDragRect(); 3516*cdf0e10cSrcweir } 3517*cdf0e10cSrcweir else 3518*cdf0e10cSrcweir pMgr = NULL; 3519*cdf0e10cSrcweir 3520*cdf0e10cSrcweir // during configuration mode visible windows will be drawn in a special way 3521*cdf0e10cSrcweir if ( mbCustomizeMode && pItem->mbShowWindow ) 3522*cdf0e10cSrcweir { 3523*cdf0e10cSrcweir Font aOldFont = GetFont(); 3524*cdf0e10cSrcweir Color aOldTextColor = GetTextColor(); 3525*cdf0e10cSrcweir 3526*cdf0e10cSrcweir SetZoomedPointFont( rStyleSettings.GetAppFont() ); 3527*cdf0e10cSrcweir SetLineColor( Color( COL_BLACK ) ); 3528*cdf0e10cSrcweir SetFillColor( rStyleSettings.GetFieldColor() ); 3529*cdf0e10cSrcweir SetTextColor( rStyleSettings.GetFieldTextColor() ); 3530*cdf0e10cSrcweir if( !bLayout ) 3531*cdf0e10cSrcweir DrawRect( pItem->maRect ); 3532*cdf0e10cSrcweir 3533*cdf0e10cSrcweir Size aSize( GetCtrlTextWidth( pItem->maText ), GetTextHeight() ); 3534*cdf0e10cSrcweir Point aPos( pItem->maRect.Left()+2, pItem->maRect.Top() ); 3535*cdf0e10cSrcweir aPos.Y() += (pItem->maRect.GetHeight()-aSize.Height())/2; 3536*cdf0e10cSrcweir sal_Bool bClip; 3537*cdf0e10cSrcweir if ( (aSize.Width() > pItem->maRect.GetWidth()-2) || 3538*cdf0e10cSrcweir (aSize.Height() > pItem->maRect.GetHeight()-2) ) 3539*cdf0e10cSrcweir { 3540*cdf0e10cSrcweir bClip = sal_True; 3541*cdf0e10cSrcweir Rectangle aTempRect( pItem->maRect.Left()+1, pItem->maRect.Top()+1, 3542*cdf0e10cSrcweir pItem->maRect.Right()-1, pItem->maRect.Bottom()-1 ); 3543*cdf0e10cSrcweir Region aTempRegion( aTempRect ); 3544*cdf0e10cSrcweir SetClipRegion( aTempRegion ); 3545*cdf0e10cSrcweir } 3546*cdf0e10cSrcweir else 3547*cdf0e10cSrcweir bClip = sal_False; 3548*cdf0e10cSrcweir if( bLayout ) 3549*cdf0e10cSrcweir { 3550*cdf0e10cSrcweir mpData->m_pLayoutData->m_aLineIndices.push_back( mpData->m_pLayoutData->m_aDisplayText.Len() ); 3551*cdf0e10cSrcweir mpData->m_pLayoutData->m_aLineItemIds.push_back( pItem->mnId ); 3552*cdf0e10cSrcweir mpData->m_pLayoutData->m_aLineItemPositions.push_back( nPos ); 3553*cdf0e10cSrcweir } 3554*cdf0e10cSrcweir DrawCtrlText( aPos, pItem->maText, 0, STRING_LEN, TEXT_DRAW_MNEMONIC, pVector, pDisplayText ); 3555*cdf0e10cSrcweir if ( bClip ) 3556*cdf0e10cSrcweir SetClipRegion(); 3557*cdf0e10cSrcweir SetFont( aOldFont ); 3558*cdf0e10cSrcweir SetTextColor( aOldTextColor ); 3559*cdf0e10cSrcweir 3560*cdf0e10cSrcweir // Gegebenenfalls noch Config-Frame zeichnen 3561*cdf0e10cSrcweir if ( pMgr && !bLayout) 3562*cdf0e10cSrcweir pMgr->UpdateDragRect(); 3563*cdf0e10cSrcweir return; 3564*cdf0e10cSrcweir } 3565*cdf0e10cSrcweir 3566*cdf0e10cSrcweir // draw button 3567*cdf0e10cSrcweir Size aBtnSize = pItem->maRect.GetSize(); 3568*cdf0e10cSrcweir if( ImplGetSVData()->maNWFData.mbToolboxDropDownSeparate ) 3569*cdf0e10cSrcweir { 3570*cdf0e10cSrcweir // separate button not for dropdown only where the whole button is painted 3571*cdf0e10cSrcweir if ( pItem->mnBits & TIB_DROPDOWN && 3572*cdf0e10cSrcweir ((pItem->mnBits & TIB_DROPDOWNONLY) != TIB_DROPDOWNONLY) ) 3573*cdf0e10cSrcweir { 3574*cdf0e10cSrcweir Rectangle aArrowRect = pItem->GetDropDownRect( mbHorz ); 3575*cdf0e10cSrcweir if( aArrowRect.Top() == pItem->maRect.Top() ) // dropdown arrow on right side 3576*cdf0e10cSrcweir aBtnSize.Width() -= aArrowRect.GetWidth(); 3577*cdf0e10cSrcweir else // dropdown arrow on bottom side 3578*cdf0e10cSrcweir aBtnSize.Height() -= aArrowRect.GetHeight(); 3579*cdf0e10cSrcweir } 3580*cdf0e10cSrcweir } 3581*cdf0e10cSrcweir Rectangle aButtonRect( pItem->maRect.TopLeft(), aBtnSize ); 3582*cdf0e10cSrcweir long nOffX = SMALLBUTTON_OFF_NORMAL_X; 3583*cdf0e10cSrcweir long nOffY = SMALLBUTTON_OFF_NORMAL_Y; 3584*cdf0e10cSrcweir long nImageOffX=0; 3585*cdf0e10cSrcweir long nImageOffY=0; 3586*cdf0e10cSrcweir long nTextOffX=0; 3587*cdf0e10cSrcweir long nTextOffY=0; 3588*cdf0e10cSrcweir sal_uInt16 nStyle = 0; 3589*cdf0e10cSrcweir 3590*cdf0e10cSrcweir if ( pItem->meState == STATE_CHECK ) 3591*cdf0e10cSrcweir { 3592*cdf0e10cSrcweir nStyle |= BUTTON_DRAW_CHECKED; 3593*cdf0e10cSrcweir } 3594*cdf0e10cSrcweir else if ( pItem->meState == STATE_DONTKNOW ) 3595*cdf0e10cSrcweir { 3596*cdf0e10cSrcweir nStyle |= BUTTON_DRAW_DONTKNOW; 3597*cdf0e10cSrcweir } 3598*cdf0e10cSrcweir if ( bHighlight == 1 ) 3599*cdf0e10cSrcweir { 3600*cdf0e10cSrcweir nStyle |= BUTTON_DRAW_PRESSED; 3601*cdf0e10cSrcweir } 3602*cdf0e10cSrcweir 3603*cdf0e10cSrcweir if ( mnOutStyle & TOOLBOX_STYLE_OUTBUTTON ) 3604*cdf0e10cSrcweir { 3605*cdf0e10cSrcweir nOffX = OUTBUTTON_OFF_NORMAL_X; 3606*cdf0e10cSrcweir nOffY = OUTBUTTON_OFF_NORMAL_Y; 3607*cdf0e10cSrcweir if ( bHighlight ) 3608*cdf0e10cSrcweir { 3609*cdf0e10cSrcweir nOffX++; 3610*cdf0e10cSrcweir nOffY++; 3611*cdf0e10cSrcweir } 3612*cdf0e10cSrcweir } 3613*cdf0e10cSrcweir 3614*cdf0e10cSrcweir if( ! bLayout ) 3615*cdf0e10cSrcweir { 3616*cdf0e10cSrcweir if ( mnOutStyle & TOOLBOX_STYLE_FLAT ) 3617*cdf0e10cSrcweir { 3618*cdf0e10cSrcweir if ( (pItem->meState != STATE_NOCHECK) || !bPaint ) 3619*cdf0e10cSrcweir { 3620*cdf0e10cSrcweir ImplErase( this, pItem->maRect, bHighlight, bHasOpenPopup ); 3621*cdf0e10cSrcweir } 3622*cdf0e10cSrcweir } 3623*cdf0e10cSrcweir else 3624*cdf0e10cSrcweir { 3625*cdf0e10cSrcweir if ( mnOutStyle & TOOLBOX_STYLE_OUTBUTTON ) 3626*cdf0e10cSrcweir ImplDrawOutButton( this, aButtonRect, nStyle ); 3627*cdf0e10cSrcweir else 3628*cdf0e10cSrcweir { 3629*cdf0e10cSrcweir DecorationView aDecoView( this ); 3630*cdf0e10cSrcweir aDecoView.DrawButton( aButtonRect, nStyle ); 3631*cdf0e10cSrcweir } 3632*cdf0e10cSrcweir } 3633*cdf0e10cSrcweir } 3634*cdf0e10cSrcweir 3635*cdf0e10cSrcweir nOffX += pItem->maRect.Left(); 3636*cdf0e10cSrcweir nOffY += pItem->maRect.Top(); 3637*cdf0e10cSrcweir 3638*cdf0e10cSrcweir // determine what has to be drawn on the button: image, text or both 3639*cdf0e10cSrcweir sal_Bool bImage; 3640*cdf0e10cSrcweir sal_Bool bText; 3641*cdf0e10cSrcweir ButtonType tmpButtonType = determineButtonType( pItem, meButtonType ); // default to toolbox setting 3642*cdf0e10cSrcweir pItem->DetermineButtonDrawStyle( tmpButtonType, bImage, bText ); 3643*cdf0e10cSrcweir 3644*cdf0e10cSrcweir // compute output values 3645*cdf0e10cSrcweir long nBtnWidth = aBtnSize.Width()-SMALLBUTTON_HSIZE; 3646*cdf0e10cSrcweir long nBtnHeight = aBtnSize.Height()-SMALLBUTTON_VSIZE; 3647*cdf0e10cSrcweir Size aImageSize; 3648*cdf0e10cSrcweir Size aTxtSize; 3649*cdf0e10cSrcweir 3650*cdf0e10cSrcweir if ( bText ) 3651*cdf0e10cSrcweir { 3652*cdf0e10cSrcweir aTxtSize.Width() = GetCtrlTextWidth( pItem->maText ); 3653*cdf0e10cSrcweir aTxtSize.Height() = GetTextHeight(); 3654*cdf0e10cSrcweir } 3655*cdf0e10cSrcweir 3656*cdf0e10cSrcweir if ( bImage && ! bLayout ) 3657*cdf0e10cSrcweir { 3658*cdf0e10cSrcweir const Image* pImage; 3659*cdf0e10cSrcweir if ( bHighlight && (!(pItem->maHighImage)) == sal_False ) 3660*cdf0e10cSrcweir pImage = &(pItem->maHighImage); 3661*cdf0e10cSrcweir else 3662*cdf0e10cSrcweir pImage = &(pItem->maImage); 3663*cdf0e10cSrcweir 3664*cdf0e10cSrcweir aImageSize = pImage->GetSizePixel(); 3665*cdf0e10cSrcweir 3666*cdf0e10cSrcweir // determine drawing flags 3667*cdf0e10cSrcweir sal_uInt16 nImageStyle = 0; 3668*cdf0e10cSrcweir 3669*cdf0e10cSrcweir if ( !pItem->mbEnabled || !IsEnabled() ) 3670*cdf0e10cSrcweir nImageStyle |= IMAGE_DRAW_DISABLE; 3671*cdf0e10cSrcweir 3672*cdf0e10cSrcweir // #i35563# the dontknow state indicates different states at the same time 3673*cdf0e10cSrcweir // which should not be rendered disabled but normal 3674*cdf0e10cSrcweir //if ( pItem->meState == STATE_DONTKNOW ) 3675*cdf0e10cSrcweir // nImageStyle |= IMAGE_DRAW_DISABLE; 3676*cdf0e10cSrcweir 3677*cdf0e10cSrcweir // draw the image 3678*cdf0e10cSrcweir nImageOffX = nOffX; 3679*cdf0e10cSrcweir nImageOffY = nOffY; 3680*cdf0e10cSrcweir if ( (pItem->mnBits & (TIB_LEFT|TIB_DROPDOWN)) || bText ) 3681*cdf0e10cSrcweir { 3682*cdf0e10cSrcweir // left align also to leave space for drop down arrow 3683*cdf0e10cSrcweir // and when drawing text+image 3684*cdf0e10cSrcweir // just center in y, except for vertical (ie rotated text) 3685*cdf0e10cSrcweir if( mbHorz || !bText ) 3686*cdf0e10cSrcweir nImageOffY += (nBtnHeight-aImageSize.Height())/2; 3687*cdf0e10cSrcweir } 3688*cdf0e10cSrcweir else 3689*cdf0e10cSrcweir { 3690*cdf0e10cSrcweir nImageOffX += (nBtnWidth-aImageSize.Width())/2; 3691*cdf0e10cSrcweir nImageOffY += (nBtnHeight-aImageSize.Height())/2; 3692*cdf0e10cSrcweir } 3693*cdf0e10cSrcweir if ( bHighlight || (pItem->meState == STATE_CHECK) ) 3694*cdf0e10cSrcweir { 3695*cdf0e10cSrcweir if( bHasOpenPopup ) 3696*cdf0e10cSrcweir ImplDrawFloatwinBorder( pItem ); 3697*cdf0e10cSrcweir else 3698*cdf0e10cSrcweir ImplDrawButton( this, aButtonRect, bHighlight, pItem->meState == STATE_CHECK, pItem->mbEnabled && IsEnabled(), pItem->mbShowWindow ? sal_True : sal_False ); 3699*cdf0e10cSrcweir 3700*cdf0e10cSrcweir if( bHighlight ) 3701*cdf0e10cSrcweir { 3702*cdf0e10cSrcweir if( bHighContrastWhite ) 3703*cdf0e10cSrcweir nImageStyle |= IMAGE_DRAW_COLORTRANSFORM; 3704*cdf0e10cSrcweir } 3705*cdf0e10cSrcweir } 3706*cdf0e10cSrcweir DrawImage( Point( nImageOffX, nImageOffY ), *pImage, nImageStyle ); 3707*cdf0e10cSrcweir } 3708*cdf0e10cSrcweir 3709*cdf0e10cSrcweir // draw the text 3710*cdf0e10cSrcweir sal_Bool bRotate = sal_False; 3711*cdf0e10cSrcweir if ( bText ) 3712*cdf0e10cSrcweir { 3713*cdf0e10cSrcweir nTextOffX = nOffX; 3714*cdf0e10cSrcweir nTextOffY = nOffY; 3715*cdf0e10cSrcweir 3716*cdf0e10cSrcweir // rotate text when vertically docked 3717*cdf0e10cSrcweir Font aOldFont = GetFont(); 3718*cdf0e10cSrcweir if( pItem->mbVisibleText && !ImplIsFloatingMode() && 3719*cdf0e10cSrcweir ((meAlign == WINDOWALIGN_LEFT) || (meAlign == WINDOWALIGN_RIGHT)) ) 3720*cdf0e10cSrcweir { 3721*cdf0e10cSrcweir bRotate = sal_True; 3722*cdf0e10cSrcweir 3723*cdf0e10cSrcweir Font aRotateFont = aOldFont; 3724*cdf0e10cSrcweir /* 3725*cdf0e10cSrcweir if ( meAlign == WINDOWALIGN_LEFT ) 3726*cdf0e10cSrcweir { 3727*cdf0e10cSrcweir aRotateFont.SetOrientation( 900 ); 3728*cdf0e10cSrcweir nTextOffX += (nBtnWidth-aTxtSize.Height())/2; 3729*cdf0e10cSrcweir nTextOffY += aTxtSize.Width(); 3730*cdf0e10cSrcweir nTextOffY += (nBtnHeight-aTxtSize.Width())/2; 3731*cdf0e10cSrcweir } 3732*cdf0e10cSrcweir else*/ 3733*cdf0e10cSrcweir { 3734*cdf0e10cSrcweir aRotateFont.SetOrientation( 2700 ); 3735*cdf0e10cSrcweir 3736*cdf0e10cSrcweir // center horizontally 3737*cdf0e10cSrcweir nTextOffX += aTxtSize.Height(); 3738*cdf0e10cSrcweir nTextOffX += (nBtnWidth-aTxtSize.Height())/2; 3739*cdf0e10cSrcweir 3740*cdf0e10cSrcweir // add in image offset 3741*cdf0e10cSrcweir if( bImage ) 3742*cdf0e10cSrcweir nTextOffY = nImageOffY + aImageSize.Height() + TB_IMAGETEXTOFFSET; 3743*cdf0e10cSrcweir } 3744*cdf0e10cSrcweir 3745*cdf0e10cSrcweir SetFont( aRotateFont ); 3746*cdf0e10cSrcweir } 3747*cdf0e10cSrcweir else 3748*cdf0e10cSrcweir { 3749*cdf0e10cSrcweir // center vertically 3750*cdf0e10cSrcweir nTextOffY += (nBtnHeight-aTxtSize.Height())/2; 3751*cdf0e10cSrcweir 3752*cdf0e10cSrcweir // add in image offset 3753*cdf0e10cSrcweir if( bImage ) 3754*cdf0e10cSrcweir nTextOffX = nImageOffX + aImageSize.Width() + TB_IMAGETEXTOFFSET; 3755*cdf0e10cSrcweir //nTextOffX += TB_TEXTOFFSET/2; 3756*cdf0e10cSrcweir } 3757*cdf0e10cSrcweir 3758*cdf0e10cSrcweir // draw selection only if not already drawn during image output (see above) 3759*cdf0e10cSrcweir if ( !bLayout && !bImage && (bHighlight || (pItem->meState == STATE_CHECK) ) ) 3760*cdf0e10cSrcweir { 3761*cdf0e10cSrcweir if( bHasOpenPopup ) 3762*cdf0e10cSrcweir ImplDrawFloatwinBorder( pItem ); 3763*cdf0e10cSrcweir else 3764*cdf0e10cSrcweir ImplDrawButton( this, pItem->maRect, bHighlight, pItem->meState == STATE_CHECK, pItem->mbEnabled && IsEnabled(), pItem->mbShowWindow ? sal_True : sal_False ); 3765*cdf0e10cSrcweir } 3766*cdf0e10cSrcweir 3767*cdf0e10cSrcweir sal_uInt16 nTextStyle = 0; 3768*cdf0e10cSrcweir if ( !pItem->mbEnabled ) 3769*cdf0e10cSrcweir nTextStyle |= TEXT_DRAW_DISABLE; 3770*cdf0e10cSrcweir if( bLayout ) 3771*cdf0e10cSrcweir { 3772*cdf0e10cSrcweir mpData->m_pLayoutData->m_aLineIndices.push_back( mpData->m_pLayoutData->m_aDisplayText.Len() ); 3773*cdf0e10cSrcweir mpData->m_pLayoutData->m_aLineItemIds.push_back( pItem->mnId ); 3774*cdf0e10cSrcweir mpData->m_pLayoutData->m_aLineItemPositions.push_back( nPos ); 3775*cdf0e10cSrcweir } 3776*cdf0e10cSrcweir DrawCtrlText( Point( nTextOffX, nTextOffY ), pItem->maText, 3777*cdf0e10cSrcweir 0, STRING_LEN, nTextStyle, pVector, pDisplayText ); 3778*cdf0e10cSrcweir if ( bRotate ) 3779*cdf0e10cSrcweir SetFont( aOldFont ); 3780*cdf0e10cSrcweir } 3781*cdf0e10cSrcweir 3782*cdf0e10cSrcweir if( bLayout ) 3783*cdf0e10cSrcweir return; 3784*cdf0e10cSrcweir 3785*cdf0e10cSrcweir // paint optional drop down arrow 3786*cdf0e10cSrcweir if ( pItem->mnBits & TIB_DROPDOWN ) 3787*cdf0e10cSrcweir { 3788*cdf0e10cSrcweir Rectangle aDropDownRect( pItem->GetDropDownRect( mbHorz ) ); 3789*cdf0e10cSrcweir sal_Bool bSetColor = sal_True; 3790*cdf0e10cSrcweir if ( !pItem->mbEnabled || !IsEnabled() ) 3791*cdf0e10cSrcweir { 3792*cdf0e10cSrcweir bSetColor = sal_False; 3793*cdf0e10cSrcweir SetFillColor( rStyleSettings.GetShadowColor() ); 3794*cdf0e10cSrcweir } 3795*cdf0e10cSrcweir 3796*cdf0e10cSrcweir // dropdown only will be painted without inner border 3797*cdf0e10cSrcweir if( (pItem->mnBits & TIB_DROPDOWNONLY) != TIB_DROPDOWNONLY ) 3798*cdf0e10cSrcweir { 3799*cdf0e10cSrcweir ImplErase( this, aDropDownRect, bHighlight, bHasOpenPopup ); 3800*cdf0e10cSrcweir 3801*cdf0e10cSrcweir if( bHighlight || (pItem->meState == STATE_CHECK) ) 3802*cdf0e10cSrcweir { 3803*cdf0e10cSrcweir if( bHasOpenPopup ) 3804*cdf0e10cSrcweir ImplDrawFloatwinBorder( pItem ); 3805*cdf0e10cSrcweir else 3806*cdf0e10cSrcweir ImplDrawButton( this, aDropDownRect, bHighlight, pItem->meState == STATE_CHECK, pItem->mbEnabled && IsEnabled(), sal_False ); 3807*cdf0e10cSrcweir } 3808*cdf0e10cSrcweir } 3809*cdf0e10cSrcweir ImplDrawDropdownArrow( this, aDropDownRect, bSetColor, bRotate ); 3810*cdf0e10cSrcweir } 3811*cdf0e10cSrcweir 3812*cdf0e10cSrcweir // Gegebenenfalls noch Config-Frame zeichnen 3813*cdf0e10cSrcweir if ( pMgr ) 3814*cdf0e10cSrcweir pMgr->UpdateDragRect(); 3815*cdf0e10cSrcweir } 3816*cdf0e10cSrcweir 3817*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3818*cdf0e10cSrcweir 3819*cdf0e10cSrcweir void ToolBox::ImplStartCustomizeMode() 3820*cdf0e10cSrcweir { 3821*cdf0e10cSrcweir mbCustomizeMode = sal_True; 3822*cdf0e10cSrcweir 3823*cdf0e10cSrcweir mpData->ImplClearLayoutData(); 3824*cdf0e10cSrcweir 3825*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 3826*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 3827*cdf0e10cSrcweir { 3828*cdf0e10cSrcweir if ( it->mbShowWindow ) 3829*cdf0e10cSrcweir { 3830*cdf0e10cSrcweir it->mpWindow->Hide(); 3831*cdf0e10cSrcweir 3832*cdf0e10cSrcweir if ( !(it->maRect.IsEmpty()) ) 3833*cdf0e10cSrcweir Invalidate( it->maRect ); 3834*cdf0e10cSrcweir } 3835*cdf0e10cSrcweir 3836*cdf0e10cSrcweir ++it; 3837*cdf0e10cSrcweir } 3838*cdf0e10cSrcweir } 3839*cdf0e10cSrcweir 3840*cdf0e10cSrcweir void ToolBox::SetCustomizeMode( sal_Bool bSet ) 3841*cdf0e10cSrcweir { 3842*cdf0e10cSrcweir if ( bSet ) 3843*cdf0e10cSrcweir ImplStartCustomizeMode(); 3844*cdf0e10cSrcweir else 3845*cdf0e10cSrcweir ImplEndCustomizeMode(); 3846*cdf0e10cSrcweir } 3847*cdf0e10cSrcweir 3848*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3849*cdf0e10cSrcweir 3850*cdf0e10cSrcweir void ToolBox::ImplEndCustomizeMode() 3851*cdf0e10cSrcweir { 3852*cdf0e10cSrcweir mbCustomizeMode = sal_False; 3853*cdf0e10cSrcweir 3854*cdf0e10cSrcweir mpData->ImplClearLayoutData(); 3855*cdf0e10cSrcweir 3856*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 3857*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 3858*cdf0e10cSrcweir { 3859*cdf0e10cSrcweir if ( it->mbShowWindow ) 3860*cdf0e10cSrcweir { 3861*cdf0e10cSrcweir if ( !(it->maRect.IsEmpty()) ) 3862*cdf0e10cSrcweir Invalidate( it->maRect ); 3863*cdf0e10cSrcweir 3864*cdf0e10cSrcweir it->mpWindow->Show(); 3865*cdf0e10cSrcweir } 3866*cdf0e10cSrcweir 3867*cdf0e10cSrcweir ++it; 3868*cdf0e10cSrcweir } 3869*cdf0e10cSrcweir } 3870*cdf0e10cSrcweir 3871*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3872*cdf0e10cSrcweir 3873*cdf0e10cSrcweir void ToolBox::ImplDrawFloatwinBorder( ImplToolItem* pItem ) 3874*cdf0e10cSrcweir { 3875*cdf0e10cSrcweir if ( !pItem->maRect.IsEmpty() ) 3876*cdf0e10cSrcweir { 3877*cdf0e10cSrcweir Rectangle aRect( mpFloatWin->ImplGetItemEdgeClipRect() ); 3878*cdf0e10cSrcweir aRect.SetPos( AbsoluteScreenToOutputPixel( aRect.TopLeft() ) ); 3879*cdf0e10cSrcweir SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() ); 3880*cdf0e10cSrcweir Point p1, p2; 3881*cdf0e10cSrcweir 3882*cdf0e10cSrcweir p1 = pItem->maRect.TopLeft(); 3883*cdf0e10cSrcweir p1.X()++; 3884*cdf0e10cSrcweir p2 = pItem->maRect.TopRight(); 3885*cdf0e10cSrcweir p2.X()--; 3886*cdf0e10cSrcweir DrawLine( p1, p2); 3887*cdf0e10cSrcweir p1 = pItem->maRect.BottomLeft(); 3888*cdf0e10cSrcweir p1.X()++; 3889*cdf0e10cSrcweir p2 = pItem->maRect.BottomRight(); 3890*cdf0e10cSrcweir p2.X()--; 3891*cdf0e10cSrcweir DrawLine( p1, p2); 3892*cdf0e10cSrcweir 3893*cdf0e10cSrcweir p1 = pItem->maRect.TopLeft(); 3894*cdf0e10cSrcweir p1.Y()++; 3895*cdf0e10cSrcweir p2 = pItem->maRect.BottomLeft(); 3896*cdf0e10cSrcweir p2.Y()--; 3897*cdf0e10cSrcweir DrawLine( p1, p2); 3898*cdf0e10cSrcweir p1 = pItem->maRect.TopRight(); 3899*cdf0e10cSrcweir p1.Y()++; 3900*cdf0e10cSrcweir p2 = pItem->maRect.BottomRight(); 3901*cdf0e10cSrcweir p2.Y()--; 3902*cdf0e10cSrcweir DrawLine( p1, p2); 3903*cdf0e10cSrcweir 3904*cdf0e10cSrcweir //DrawRect( pItem->maRect ); 3905*cdf0e10cSrcweir } 3906*cdf0e10cSrcweir } 3907*cdf0e10cSrcweir 3908*cdf0e10cSrcweir void ToolBox::ImplFloatControl( sal_Bool bStart, FloatingWindow* pFloatWindow ) 3909*cdf0e10cSrcweir { 3910*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 3911*cdf0e10cSrcweir 3912*cdf0e10cSrcweir if ( bStart ) 3913*cdf0e10cSrcweir { 3914*cdf0e10cSrcweir mpFloatWin = pFloatWindow; 3915*cdf0e10cSrcweir 3916*cdf0e10cSrcweir // redraw item, to trigger drawing of a special border 3917*cdf0e10cSrcweir ImplDrawItem( mnCurPos, sal_True ); 3918*cdf0e10cSrcweir 3919*cdf0e10cSrcweir mbDrag = sal_False; 3920*cdf0e10cSrcweir EndTracking(); 3921*cdf0e10cSrcweir ReleaseMouse(); 3922*cdf0e10cSrcweir } 3923*cdf0e10cSrcweir else 3924*cdf0e10cSrcweir { 3925*cdf0e10cSrcweir mpFloatWin = NULL; 3926*cdf0e10cSrcweir 3927*cdf0e10cSrcweir // if focus is still in this toolbox, then the floater was opened by keyboard 3928*cdf0e10cSrcweir // draw current item with highlight and keep old state 3929*cdf0e10cSrcweir sal_Bool bWasKeyboardActivate = mpData->mbDropDownByKeyboard; 3930*cdf0e10cSrcweir 3931*cdf0e10cSrcweir 3932*cdf0e10cSrcweir if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND ) 3933*cdf0e10cSrcweir ImplDrawItem( mnCurPos, bWasKeyboardActivate ? 2 : 0 ); 3934*cdf0e10cSrcweir Deactivate(); 3935*cdf0e10cSrcweir 3936*cdf0e10cSrcweir if( !bWasKeyboardActivate ) 3937*cdf0e10cSrcweir { 3938*cdf0e10cSrcweir mnCurPos = TOOLBOX_ITEM_NOTFOUND; 3939*cdf0e10cSrcweir mnCurItemId = 0; 3940*cdf0e10cSrcweir mnHighItemId = 0; 3941*cdf0e10cSrcweir } 3942*cdf0e10cSrcweir mnDownItemId = 0; 3943*cdf0e10cSrcweir 3944*cdf0e10cSrcweir } 3945*cdf0e10cSrcweir } 3946*cdf0e10cSrcweir 3947*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3948*cdf0e10cSrcweir 3949*cdf0e10cSrcweir void ToolBox::ShowLine( sal_Bool bNext ) 3950*cdf0e10cSrcweir { 3951*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 3952*cdf0e10cSrcweir 3953*cdf0e10cSrcweir mbFormat = sal_True; 3954*cdf0e10cSrcweir 3955*cdf0e10cSrcweir if ( mpData->mbPageScroll ) 3956*cdf0e10cSrcweir { 3957*cdf0e10cSrcweir sal_uInt16 delta = mnVisLines; 3958*cdf0e10cSrcweir if ( bNext ) 3959*cdf0e10cSrcweir { 3960*cdf0e10cSrcweir mnCurLine = mnCurLine + delta; 3961*cdf0e10cSrcweir if ( mnCurLine+mnVisLines-1 > mnCurLines ) 3962*cdf0e10cSrcweir mnCurLine = mnCurLines - mnVisLines+1; 3963*cdf0e10cSrcweir } 3964*cdf0e10cSrcweir else 3965*cdf0e10cSrcweir { 3966*cdf0e10cSrcweir if( mnCurLine >= delta+1 ) 3967*cdf0e10cSrcweir mnCurLine = mnCurLine - delta; 3968*cdf0e10cSrcweir else 3969*cdf0e10cSrcweir mnCurLine = 1; 3970*cdf0e10cSrcweir } 3971*cdf0e10cSrcweir } 3972*cdf0e10cSrcweir else 3973*cdf0e10cSrcweir { 3974*cdf0e10cSrcweir if ( bNext ) 3975*cdf0e10cSrcweir mnCurLine++; 3976*cdf0e10cSrcweir else 3977*cdf0e10cSrcweir mnCurLine--; 3978*cdf0e10cSrcweir } 3979*cdf0e10cSrcweir 3980*cdf0e10cSrcweir ImplFormat(); 3981*cdf0e10cSrcweir } 3982*cdf0e10cSrcweir 3983*cdf0e10cSrcweir // ----------------------------------------------------------------------- 3984*cdf0e10cSrcweir 3985*cdf0e10cSrcweir sal_Bool ToolBox::ImplHandleMouseMove( const MouseEvent& rMEvt, sal_Bool bRepeat ) 3986*cdf0e10cSrcweir { 3987*cdf0e10cSrcweir Point aMousePos = rMEvt.GetPosPixel(); 3988*cdf0e10cSrcweir 3989*cdf0e10cSrcweir // Ist ToolBox aktiv 3990*cdf0e10cSrcweir if ( mbDrag && mnCurPos != TOOLBOX_ITEM_NOTFOUND ) 3991*cdf0e10cSrcweir { 3992*cdf0e10cSrcweir // Befindet sich Maus ueber dem Item 3993*cdf0e10cSrcweir ImplToolItem* pItem = &mpData->m_aItems[mnCurPos]; 3994*cdf0e10cSrcweir if ( pItem->maRect.IsInside( aMousePos ) ) 3995*cdf0e10cSrcweir { 3996*cdf0e10cSrcweir if ( !mnCurItemId ) 3997*cdf0e10cSrcweir { 3998*cdf0e10cSrcweir ImplDrawItem( mnCurPos, sal_True ); 3999*cdf0e10cSrcweir mnCurItemId = pItem->mnId; 4000*cdf0e10cSrcweir Highlight(); 4001*cdf0e10cSrcweir } 4002*cdf0e10cSrcweir 4003*cdf0e10cSrcweir if ( (pItem->mnBits & TIB_REPEAT) && bRepeat ) 4004*cdf0e10cSrcweir Select(); 4005*cdf0e10cSrcweir } 4006*cdf0e10cSrcweir else 4007*cdf0e10cSrcweir { 4008*cdf0e10cSrcweir if ( mnCurItemId ) 4009*cdf0e10cSrcweir { 4010*cdf0e10cSrcweir ImplDrawItem( mnCurPos ); 4011*cdf0e10cSrcweir mnCurItemId = 0; 4012*cdf0e10cSrcweir ImplDrawItem( mnCurPos ); 4013*cdf0e10cSrcweir Highlight(); 4014*cdf0e10cSrcweir } 4015*cdf0e10cSrcweir } 4016*cdf0e10cSrcweir 4017*cdf0e10cSrcweir return sal_True; 4018*cdf0e10cSrcweir } 4019*cdf0e10cSrcweir 4020*cdf0e10cSrcweir if ( mbUpper ) 4021*cdf0e10cSrcweir { 4022*cdf0e10cSrcweir sal_Bool bNewIn = maUpperRect.IsInside( aMousePos ); 4023*cdf0e10cSrcweir if ( bNewIn != mbIn ) 4024*cdf0e10cSrcweir { 4025*cdf0e10cSrcweir mbIn = bNewIn; 4026*cdf0e10cSrcweir ImplDrawSpin( mbIn, sal_False ); 4027*cdf0e10cSrcweir } 4028*cdf0e10cSrcweir return sal_True; 4029*cdf0e10cSrcweir } 4030*cdf0e10cSrcweir 4031*cdf0e10cSrcweir if ( mbLower ) 4032*cdf0e10cSrcweir { 4033*cdf0e10cSrcweir sal_Bool bNewIn = maLowerRect.IsInside( aMousePos ); 4034*cdf0e10cSrcweir if ( bNewIn != mbIn ) 4035*cdf0e10cSrcweir { 4036*cdf0e10cSrcweir mbIn = bNewIn; 4037*cdf0e10cSrcweir ImplDrawSpin( sal_False, mbIn ); 4038*cdf0e10cSrcweir } 4039*cdf0e10cSrcweir return sal_True; 4040*cdf0e10cSrcweir } 4041*cdf0e10cSrcweir 4042*cdf0e10cSrcweir if ( mbNextTool ) 4043*cdf0e10cSrcweir { 4044*cdf0e10cSrcweir sal_Bool bNewIn = maNextToolRect.IsInside( aMousePos ); 4045*cdf0e10cSrcweir if ( bNewIn != mbIn ) 4046*cdf0e10cSrcweir { 4047*cdf0e10cSrcweir mbIn = bNewIn; 4048*cdf0e10cSrcweir ImplDrawNext( mbIn ); 4049*cdf0e10cSrcweir } 4050*cdf0e10cSrcweir return sal_True; 4051*cdf0e10cSrcweir } 4052*cdf0e10cSrcweir 4053*cdf0e10cSrcweir return sal_False; 4054*cdf0e10cSrcweir } 4055*cdf0e10cSrcweir 4056*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4057*cdf0e10cSrcweir 4058*cdf0e10cSrcweir sal_Bool ToolBox::ImplHandleMouseButtonUp( const MouseEvent& rMEvt, sal_Bool bCancel ) 4059*cdf0e10cSrcweir { 4060*cdf0e10cSrcweir ImplDisableFlatButtons(); 4061*cdf0e10cSrcweir 4062*cdf0e10cSrcweir // stop eventual running dropdown timer 4063*cdf0e10cSrcweir if( mnCurPos < mpData->m_aItems.size() && 4064*cdf0e10cSrcweir (mpData->m_aItems[mnCurPos].mnBits & TIB_DROPDOWN ) ) 4065*cdf0e10cSrcweir { 4066*cdf0e10cSrcweir mpData->maDropdownTimer.Stop(); 4067*cdf0e10cSrcweir } 4068*cdf0e10cSrcweir 4069*cdf0e10cSrcweir if ( mbDrag || mbSelection ) 4070*cdf0e10cSrcweir { 4071*cdf0e10cSrcweir // Hier die MouseDaten setzen, wenn Selection-Modus, da dann kein 4072*cdf0e10cSrcweir // MouseButtonDown-Handler gerufen wird 4073*cdf0e10cSrcweir if ( mbSelection ) 4074*cdf0e10cSrcweir { 4075*cdf0e10cSrcweir mnMouseClicks = rMEvt.GetClicks(); 4076*cdf0e10cSrcweir mnMouseModifier = rMEvt.GetModifier(); 4077*cdf0e10cSrcweir } 4078*cdf0e10cSrcweir 4079*cdf0e10cSrcweir Deactivate(); 4080*cdf0e10cSrcweir 4081*cdf0e10cSrcweir if ( mbDrag ) 4082*cdf0e10cSrcweir mbDrag = sal_False; 4083*cdf0e10cSrcweir else 4084*cdf0e10cSrcweir { 4085*cdf0e10cSrcweir mbSelection = sal_False; 4086*cdf0e10cSrcweir if ( mnCurPos == TOOLBOX_ITEM_NOTFOUND ) 4087*cdf0e10cSrcweir return sal_True; 4088*cdf0e10cSrcweir } 4089*cdf0e10cSrcweir 4090*cdf0e10cSrcweir // Wurde Maus ueber dem Item losgelassen 4091*cdf0e10cSrcweir if( mnCurPos < mpData->m_aItems.size() ) 4092*cdf0e10cSrcweir { 4093*cdf0e10cSrcweir ImplToolItem* pItem = &mpData->m_aItems[mnCurPos]; 4094*cdf0e10cSrcweir if ( pItem->maRect.IsInside( rMEvt.GetPosPixel() ) ) 4095*cdf0e10cSrcweir { 4096*cdf0e10cSrcweir mnCurItemId = pItem->mnId; 4097*cdf0e10cSrcweir if ( !bCancel ) 4098*cdf0e10cSrcweir { 4099*cdf0e10cSrcweir // Gegebenenfalls ein AutoCheck durchfuehren 4100*cdf0e10cSrcweir if ( pItem->mnBits & TIB_AUTOCHECK ) 4101*cdf0e10cSrcweir { 4102*cdf0e10cSrcweir if ( pItem->mnBits & TIB_RADIOCHECK ) 4103*cdf0e10cSrcweir { 4104*cdf0e10cSrcweir if ( pItem->meState != STATE_CHECK ) 4105*cdf0e10cSrcweir SetItemState( pItem->mnId, STATE_CHECK ); 4106*cdf0e10cSrcweir } 4107*cdf0e10cSrcweir else 4108*cdf0e10cSrcweir { 4109*cdf0e10cSrcweir if ( pItem->meState != STATE_CHECK ) 4110*cdf0e10cSrcweir pItem->meState = STATE_CHECK; 4111*cdf0e10cSrcweir else 4112*cdf0e10cSrcweir pItem->meState = STATE_NOCHECK; 4113*cdf0e10cSrcweir } 4114*cdf0e10cSrcweir } 4115*cdf0e10cSrcweir 4116*cdf0e10cSrcweir // Select nicht bei Repeat ausloesen, da dies schon im 4117*cdf0e10cSrcweir // MouseButtonDown ausgeloest wurde 4118*cdf0e10cSrcweir if ( !(pItem->mnBits & TIB_REPEAT) ) 4119*cdf0e10cSrcweir { 4120*cdf0e10cSrcweir // Gegen zerstoeren im Select-Handler sichern 4121*cdf0e10cSrcweir ImplDelData aDelData; 4122*cdf0e10cSrcweir ImplAddDel( &aDelData ); 4123*cdf0e10cSrcweir Select(); 4124*cdf0e10cSrcweir if ( aDelData.IsDelete() ) 4125*cdf0e10cSrcweir return sal_True; 4126*cdf0e10cSrcweir ImplRemoveDel( &aDelData ); 4127*cdf0e10cSrcweir } 4128*cdf0e10cSrcweir } 4129*cdf0e10cSrcweir 4130*cdf0e10cSrcweir { 4131*cdf0e10cSrcweir DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4132*cdf0e10cSrcweir } 4133*cdf0e10cSrcweir 4134*cdf0e10cSrcweir // Items nicht geloescht, im Select-Handler 4135*cdf0e10cSrcweir if ( mnCurItemId ) 4136*cdf0e10cSrcweir { 4137*cdf0e10cSrcweir sal_Bool bHighlight; 4138*cdf0e10cSrcweir if ( (mnCurItemId == mnHighItemId) && (mnOutStyle & TOOLBOX_STYLE_FLAT) ) 4139*cdf0e10cSrcweir bHighlight = 2; 4140*cdf0e10cSrcweir else 4141*cdf0e10cSrcweir bHighlight = sal_False; 4142*cdf0e10cSrcweir // Get current pos for the case that items are inserted/removed 4143*cdf0e10cSrcweir // in the toolBox 4144*cdf0e10cSrcweir mnCurPos = GetItemPos( mnCurItemId ); 4145*cdf0e10cSrcweir if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND ) 4146*cdf0e10cSrcweir { 4147*cdf0e10cSrcweir ImplDrawItem( mnCurPos, bHighlight ); 4148*cdf0e10cSrcweir Flush(); 4149*cdf0e10cSrcweir } 4150*cdf0e10cSrcweir } 4151*cdf0e10cSrcweir } 4152*cdf0e10cSrcweir } 4153*cdf0e10cSrcweir 4154*cdf0e10cSrcweir mnCurPos = TOOLBOX_ITEM_NOTFOUND; 4155*cdf0e10cSrcweir mnCurItemId = 0; 4156*cdf0e10cSrcweir mnDownItemId = 0; 4157*cdf0e10cSrcweir mnMouseClicks = 0; 4158*cdf0e10cSrcweir mnMouseModifier = 0; 4159*cdf0e10cSrcweir return sal_True; 4160*cdf0e10cSrcweir } 4161*cdf0e10cSrcweir else if ( mbUpper || mbLower ) 4162*cdf0e10cSrcweir { 4163*cdf0e10cSrcweir if ( mbIn ) 4164*cdf0e10cSrcweir ShowLine( !mbUpper ); 4165*cdf0e10cSrcweir mbUpper = sal_False; 4166*cdf0e10cSrcweir mbLower = sal_False; 4167*cdf0e10cSrcweir mbIn = sal_False; 4168*cdf0e10cSrcweir ImplDrawSpin( sal_False, sal_False ); 4169*cdf0e10cSrcweir return sal_True; 4170*cdf0e10cSrcweir } 4171*cdf0e10cSrcweir else if ( mbNextTool ) 4172*cdf0e10cSrcweir { 4173*cdf0e10cSrcweir mbNextTool = sal_False; 4174*cdf0e10cSrcweir mbIn = sal_False; 4175*cdf0e10cSrcweir ImplDrawNext( sal_False ); 4176*cdf0e10cSrcweir NextToolBox(); 4177*cdf0e10cSrcweir return sal_True; 4178*cdf0e10cSrcweir } 4179*cdf0e10cSrcweir 4180*cdf0e10cSrcweir return sal_False; 4181*cdf0e10cSrcweir } 4182*cdf0e10cSrcweir 4183*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4184*cdf0e10cSrcweir 4185*cdf0e10cSrcweir void ToolBox::MouseMove( const MouseEvent& rMEvt ) 4186*cdf0e10cSrcweir { 4187*cdf0e10cSrcweir // pressing a modifier generates synthetic mouse moves 4188*cdf0e10cSrcweir // ignore it if keyboard selection is acive 4189*cdf0e10cSrcweir if( HasFocus() && ( rMEvt.GetMode() & MOUSE_MODIFIERCHANGED ) ) 4190*cdf0e10cSrcweir return; 4191*cdf0e10cSrcweir 4192*cdf0e10cSrcweir if ( ImplHandleMouseMove( rMEvt ) ) 4193*cdf0e10cSrcweir return; 4194*cdf0e10cSrcweir 4195*cdf0e10cSrcweir ImplDisableFlatButtons(); 4196*cdf0e10cSrcweir 4197*cdf0e10cSrcweir Point aMousePos = rMEvt.GetPosPixel(); 4198*cdf0e10cSrcweir 4199*cdf0e10cSrcweir // only highlight when the focus is not inside a child window of a toolbox 4200*cdf0e10cSrcweir // eg, in a edit control 4201*cdf0e10cSrcweir // and do not hilight when focus is in a different toolbox 4202*cdf0e10cSrcweir sal_Bool bDrawHotSpot = sal_True; 4203*cdf0e10cSrcweir Window *pWin = Application::GetFocusWindow(); 4204*cdf0e10cSrcweir if( pWin && pWin->ImplGetWindowImpl()->mbToolBox && pWin != this ) 4205*cdf0e10cSrcweir bDrawHotSpot = sal_False; 4206*cdf0e10cSrcweir /* 4207*cdf0e10cSrcweir else 4208*cdf0e10cSrcweir if( pWin && !pWin->ImplGetWindowImpl()->mbToolBox ) 4209*cdf0e10cSrcweir while( pWin ) 4210*cdf0e10cSrcweir { 4211*cdf0e10cSrcweir pWin = pWin->GetParent(); 4212*cdf0e10cSrcweir if( pWin && pWin->ImplGetWindowImpl()->mbToolBox ) 4213*cdf0e10cSrcweir { 4214*cdf0e10cSrcweir bDrawHotSpot = sal_False; 4215*cdf0e10cSrcweir break; 4216*cdf0e10cSrcweir } 4217*cdf0e10cSrcweir } 4218*cdf0e10cSrcweir */ 4219*cdf0e10cSrcweir 4220*cdf0e10cSrcweir if ( mbSelection && bDrawHotSpot ) 4221*cdf0e10cSrcweir { 4222*cdf0e10cSrcweir sal_uInt16 i = 0; 4223*cdf0e10cSrcweir sal_uInt16 nNewPos = TOOLBOX_ITEM_NOTFOUND; 4224*cdf0e10cSrcweir 4225*cdf0e10cSrcweir // Item suchen, das geklickt wurde 4226*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 4227*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 4228*cdf0e10cSrcweir { 4229*cdf0e10cSrcweir // Wenn Mausposition in diesem Item vorhanden, kann die 4230*cdf0e10cSrcweir // Suche abgebrochen werden 4231*cdf0e10cSrcweir if ( it->maRect.IsInside( aMousePos ) ) 4232*cdf0e10cSrcweir { 4233*cdf0e10cSrcweir // Wenn es ein Button ist, dann wird er selektiert 4234*cdf0e10cSrcweir if ( it->meType == TOOLBOXITEM_BUTTON ) 4235*cdf0e10cSrcweir { 4236*cdf0e10cSrcweir // Wenn er disablet ist, findet keine Aenderung 4237*cdf0e10cSrcweir // statt 4238*cdf0e10cSrcweir if ( !it->mbEnabled || it->mbShowWindow ) 4239*cdf0e10cSrcweir nNewPos = mnCurPos; 4240*cdf0e10cSrcweir else 4241*cdf0e10cSrcweir nNewPos = i; 4242*cdf0e10cSrcweir } 4243*cdf0e10cSrcweir 4244*cdf0e10cSrcweir break; 4245*cdf0e10cSrcweir } 4246*cdf0e10cSrcweir 4247*cdf0e10cSrcweir i++; 4248*cdf0e10cSrcweir ++it; 4249*cdf0e10cSrcweir } 4250*cdf0e10cSrcweir 4251*cdf0e10cSrcweir // was a new entery selected ? 4252*cdf0e10cSrcweir // don't change selection if keyboard selection is active and 4253*cdf0e10cSrcweir // mouse leaves the toolbox 4254*cdf0e10cSrcweir if ( nNewPos != mnCurPos && !( HasFocus() && nNewPos == TOOLBOX_ITEM_NOTFOUND ) ) 4255*cdf0e10cSrcweir { 4256*cdf0e10cSrcweir if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND ) 4257*cdf0e10cSrcweir { 4258*cdf0e10cSrcweir ImplDrawItem( mnCurPos ); 4259*cdf0e10cSrcweir ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHTOFF, reinterpret_cast< void* >( mnCurPos ) ); 4260*cdf0e10cSrcweir } 4261*cdf0e10cSrcweir 4262*cdf0e10cSrcweir mnCurPos = nNewPos; 4263*cdf0e10cSrcweir if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND ) 4264*cdf0e10cSrcweir { 4265*cdf0e10cSrcweir mnCurItemId = mnHighItemId = it->mnId; 4266*cdf0e10cSrcweir ImplDrawItem( mnCurPos, 2 /*sal_True*/ ); // always use shadow effect (2) 4267*cdf0e10cSrcweir } 4268*cdf0e10cSrcweir else 4269*cdf0e10cSrcweir mnCurItemId = mnHighItemId = 0; 4270*cdf0e10cSrcweir 4271*cdf0e10cSrcweir Highlight(); 4272*cdf0e10cSrcweir } 4273*cdf0e10cSrcweir return; 4274*cdf0e10cSrcweir } 4275*cdf0e10cSrcweir 4276*cdf0e10cSrcweir if ( mbDragging ) 4277*cdf0e10cSrcweir { 4278*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 4279*cdf0e10cSrcweir pMgr->Dragging( aMousePos ); 4280*cdf0e10cSrcweir return; 4281*cdf0e10cSrcweir } 4282*cdf0e10cSrcweir 4283*cdf0e10cSrcweir PointerStyle eStyle = POINTER_ARROW; 4284*cdf0e10cSrcweir 4285*cdf0e10cSrcweir // change mouse cursor over drag area 4286*cdf0e10cSrcweir ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); 4287*cdf0e10cSrcweir if( pWrapper && pWrapper->GetDragArea().IsInside( rMEvt.GetPosPixel() ) ) 4288*cdf0e10cSrcweir eStyle = POINTER_MOVE; 4289*cdf0e10cSrcweir 4290*cdf0e10cSrcweir if ( (mnWinStyle & TB_WBLINESIZING) == TB_WBLINESIZING ) 4291*cdf0e10cSrcweir { 4292*cdf0e10cSrcweir if ( rMEvt.GetMode() & MOUSE_SIMPLEMOVE ) 4293*cdf0e10cSrcweir { 4294*cdf0e10cSrcweir sal_uInt16 nLinePtr = ImplTestLineSize( this, rMEvt.GetPosPixel() ); 4295*cdf0e10cSrcweir if ( nLinePtr & DOCK_LINEHSIZE ) 4296*cdf0e10cSrcweir { 4297*cdf0e10cSrcweir if ( meAlign == WINDOWALIGN_LEFT ) 4298*cdf0e10cSrcweir eStyle = POINTER_WINDOW_ESIZE; 4299*cdf0e10cSrcweir else 4300*cdf0e10cSrcweir eStyle = POINTER_WINDOW_WSIZE; 4301*cdf0e10cSrcweir } 4302*cdf0e10cSrcweir else if ( nLinePtr & DOCK_LINEVSIZE ) 4303*cdf0e10cSrcweir { 4304*cdf0e10cSrcweir if ( meAlign == WINDOWALIGN_TOP ) 4305*cdf0e10cSrcweir eStyle = POINTER_WINDOW_SSIZE; 4306*cdf0e10cSrcweir else 4307*cdf0e10cSrcweir eStyle = POINTER_WINDOW_NSIZE; 4308*cdf0e10cSrcweir } 4309*cdf0e10cSrcweir } 4310*cdf0e10cSrcweir } 4311*cdf0e10cSrcweir 4312*cdf0e10cSrcweir if ( (eStyle == POINTER_ARROW) && mbCustomizeMode ) 4313*cdf0e10cSrcweir { 4314*cdf0e10cSrcweir // Item suchen, das geklickt wurde 4315*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 4316*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 4317*cdf0e10cSrcweir { 4318*cdf0e10cSrcweir // Wenn es ein Customize-Window ist, gegebenenfalls den 4319*cdf0e10cSrcweir // Resize-Pointer anzeigen 4320*cdf0e10cSrcweir if ( it->mbShowWindow ) 4321*cdf0e10cSrcweir { 4322*cdf0e10cSrcweir if ( it->maRect.IsInside( aMousePos ) ) 4323*cdf0e10cSrcweir { 4324*cdf0e10cSrcweir if ( it->maRect.Right()-TB_RESIZE_OFFSET <= aMousePos.X() ) 4325*cdf0e10cSrcweir eStyle = POINTER_HSIZEBAR; 4326*cdf0e10cSrcweir break; 4327*cdf0e10cSrcweir } 4328*cdf0e10cSrcweir } 4329*cdf0e10cSrcweir 4330*cdf0e10cSrcweir ++it; 4331*cdf0e10cSrcweir } 4332*cdf0e10cSrcweir } 4333*cdf0e10cSrcweir 4334*cdf0e10cSrcweir if ( bDrawHotSpot && ( ((eStyle == POINTER_ARROW) && (mnOutStyle & TOOLBOX_STYLE_HANDPOINTER)) || 4335*cdf0e10cSrcweir (mnOutStyle & TOOLBOX_STYLE_FLAT) || !mnOutStyle ) ) 4336*cdf0e10cSrcweir { 4337*cdf0e10cSrcweir sal_Bool bClearHigh = sal_True; 4338*cdf0e10cSrcweir if ( !rMEvt.IsLeaveWindow() && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) ) 4339*cdf0e10cSrcweir { 4340*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 4341*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 4342*cdf0e10cSrcweir { 4343*cdf0e10cSrcweir if ( it->maRect.IsInside( aMousePos ) ) 4344*cdf0e10cSrcweir { 4345*cdf0e10cSrcweir if ( (it->meType == TOOLBOXITEM_BUTTON) && it->mbEnabled ) 4346*cdf0e10cSrcweir { 4347*cdf0e10cSrcweir if ( !mnOutStyle || (mnOutStyle & TOOLBOX_STYLE_FLAT) ) 4348*cdf0e10cSrcweir { 4349*cdf0e10cSrcweir bClearHigh = sal_False; 4350*cdf0e10cSrcweir if ( mnHighItemId != it->mnId ) 4351*cdf0e10cSrcweir { 4352*cdf0e10cSrcweir sal_uInt16 nTempPos = sal::static_int_cast<sal_uInt16>(it - mpData->m_aItems.begin()); 4353*cdf0e10cSrcweir if ( mnHighItemId ) 4354*cdf0e10cSrcweir { 4355*cdf0e10cSrcweir ImplHideFocus(); 4356*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( mnHighItemId ); 4357*cdf0e10cSrcweir ImplDrawItem( nPos ); 4358*cdf0e10cSrcweir ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHTOFF, reinterpret_cast< void* >( nPos ) ); 4359*cdf0e10cSrcweir } 4360*cdf0e10cSrcweir if ( mpData->mbMenubuttonSelected ) 4361*cdf0e10cSrcweir { 4362*cdf0e10cSrcweir // remove highlight from menubutton 4363*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_False ); 4364*cdf0e10cSrcweir } 4365*cdf0e10cSrcweir mnHighItemId = it->mnId; 4366*cdf0e10cSrcweir ImplDrawItem( nTempPos, 2 ); 4367*cdf0e10cSrcweir ImplShowFocus(); 4368*cdf0e10cSrcweir ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHT ); 4369*cdf0e10cSrcweir } 4370*cdf0e10cSrcweir } 4371*cdf0e10cSrcweir if ( mnOutStyle & TOOLBOX_STYLE_HANDPOINTER ) 4372*cdf0e10cSrcweir eStyle = POINTER_REFHAND; 4373*cdf0e10cSrcweir } 4374*cdf0e10cSrcweir break; 4375*cdf0e10cSrcweir } 4376*cdf0e10cSrcweir 4377*cdf0e10cSrcweir ++it; 4378*cdf0e10cSrcweir } 4379*cdf0e10cSrcweir } 4380*cdf0e10cSrcweir 4381*cdf0e10cSrcweir // only clear highlight when focus is not in toolbar 4382*cdf0e10cSrcweir sal_Bool bMenuButtonHit = mpData->maMenubuttonItem.maRect.IsInside( aMousePos ); 4383*cdf0e10cSrcweir if ( bClearHigh || bMenuButtonHit ) 4384*cdf0e10cSrcweir { 4385*cdf0e10cSrcweir if ( !bMenuButtonHit && mpData->mbMenubuttonSelected ) 4386*cdf0e10cSrcweir { 4387*cdf0e10cSrcweir // remove highlight from menubutton 4388*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_False ); 4389*cdf0e10cSrcweir } 4390*cdf0e10cSrcweir 4391*cdf0e10cSrcweir if( mnHighItemId ) 4392*cdf0e10cSrcweir { 4393*cdf0e10cSrcweir sal_uInt16 nClearPos = GetItemPos( mnHighItemId ); 4394*cdf0e10cSrcweir if ( nClearPos != TOOLBOX_ITEM_NOTFOUND ) 4395*cdf0e10cSrcweir { 4396*cdf0e10cSrcweir ImplDrawItem( nClearPos, (nClearPos == mnCurPos) ? sal_True : sal_False ); 4397*cdf0e10cSrcweir if( nClearPos != mnCurPos ) 4398*cdf0e10cSrcweir ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHTOFF, reinterpret_cast< void* >( nClearPos ) ); 4399*cdf0e10cSrcweir } 4400*cdf0e10cSrcweir ImplHideFocus(); 4401*cdf0e10cSrcweir mnHighItemId = 0; 4402*cdf0e10cSrcweir } 4403*cdf0e10cSrcweir 4404*cdf0e10cSrcweir if( bMenuButtonHit ) 4405*cdf0e10cSrcweir { 4406*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_True ); 4407*cdf0e10cSrcweir } 4408*cdf0e10cSrcweir } 4409*cdf0e10cSrcweir } 4410*cdf0e10cSrcweir 4411*cdf0e10cSrcweir if ( meLastStyle != eStyle ) 4412*cdf0e10cSrcweir { 4413*cdf0e10cSrcweir meLastStyle = eStyle; 4414*cdf0e10cSrcweir Pointer aPtr( eStyle ); 4415*cdf0e10cSrcweir SetPointer( aPtr ); 4416*cdf0e10cSrcweir } 4417*cdf0e10cSrcweir 4418*cdf0e10cSrcweir DockingWindow::MouseMove( rMEvt ); 4419*cdf0e10cSrcweir } 4420*cdf0e10cSrcweir 4421*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4422*cdf0e10cSrcweir 4423*cdf0e10cSrcweir void ToolBox::MouseButtonDown( const MouseEvent& rMEvt ) 4424*cdf0e10cSrcweir { 4425*cdf0e10cSrcweir // Nur bei linker Maustaste ToolBox ausloesen und wenn wir uns nicht 4426*cdf0e10cSrcweir // noch in der normalen Bearbeitung befinden 4427*cdf0e10cSrcweir if ( rMEvt.IsLeft() && !mbDrag && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) ) 4428*cdf0e10cSrcweir { 4429*cdf0e10cSrcweir // Activate schon hier rufen, da gegebenenfalls noch Items 4430*cdf0e10cSrcweir // ausgetauscht werden 4431*cdf0e10cSrcweir Activate(); 4432*cdf0e10cSrcweir 4433*cdf0e10cSrcweir // ToolBox hier updaten, damit der Anwender weiss, was Sache ist 4434*cdf0e10cSrcweir if ( mbFormat ) 4435*cdf0e10cSrcweir { 4436*cdf0e10cSrcweir ImplFormat(); 4437*cdf0e10cSrcweir Update(); 4438*cdf0e10cSrcweir } 4439*cdf0e10cSrcweir 4440*cdf0e10cSrcweir Point aMousePos = rMEvt.GetPosPixel(); 4441*cdf0e10cSrcweir sal_uInt16 i = 0; 4442*cdf0e10cSrcweir sal_uInt16 nNewPos = TOOLBOX_ITEM_NOTFOUND; 4443*cdf0e10cSrcweir 4444*cdf0e10cSrcweir // Item suchen, das geklickt wurde 4445*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 4446*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 4447*cdf0e10cSrcweir { 4448*cdf0e10cSrcweir // Ist es dieses Item 4449*cdf0e10cSrcweir if ( it->maRect.IsInside( aMousePos ) ) 4450*cdf0e10cSrcweir { 4451*cdf0e10cSrcweir // Ist es ein Separator oder ist das Item disabled, 4452*cdf0e10cSrcweir // dann mache nichts 4453*cdf0e10cSrcweir if ( (it->meType == TOOLBOXITEM_BUTTON) && 4454*cdf0e10cSrcweir (!it->mbShowWindow || mbCustomizeMode) ) 4455*cdf0e10cSrcweir nNewPos = i; 4456*cdf0e10cSrcweir 4457*cdf0e10cSrcweir break; 4458*cdf0e10cSrcweir } 4459*cdf0e10cSrcweir 4460*cdf0e10cSrcweir i++; 4461*cdf0e10cSrcweir ++it; 4462*cdf0e10cSrcweir } 4463*cdf0e10cSrcweir 4464*cdf0e10cSrcweir // Item gefunden 4465*cdf0e10cSrcweir if ( nNewPos != TOOLBOX_ITEM_NOTFOUND ) 4466*cdf0e10cSrcweir { 4467*cdf0e10cSrcweir if ( mbCustomize ) 4468*cdf0e10cSrcweir { 4469*cdf0e10cSrcweir if ( rMEvt.IsMod2() || mbCustomizeMode ) 4470*cdf0e10cSrcweir { 4471*cdf0e10cSrcweir Deactivate(); 4472*cdf0e10cSrcweir 4473*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 4474*cdf0e10cSrcweir Rectangle aItemRect = GetItemRect( it->mnId ); 4475*cdf0e10cSrcweir mnConfigItem = it->mnId; 4476*cdf0e10cSrcweir 4477*cdf0e10cSrcweir sal_Bool bResizeItem; 4478*cdf0e10cSrcweir if ( mbCustomizeMode && it->mbShowWindow && 4479*cdf0e10cSrcweir (it->maRect.Right()-TB_RESIZE_OFFSET <= aMousePos.X()) ) 4480*cdf0e10cSrcweir bResizeItem = sal_True; 4481*cdf0e10cSrcweir else 4482*cdf0e10cSrcweir bResizeItem = sal_False; 4483*cdf0e10cSrcweir pMgr->StartDragging( this, aMousePos, aItemRect, 0, bResizeItem ); 4484*cdf0e10cSrcweir return; 4485*cdf0e10cSrcweir } 4486*cdf0e10cSrcweir } 4487*cdf0e10cSrcweir 4488*cdf0e10cSrcweir if ( !it->mbEnabled ) 4489*cdf0e10cSrcweir { 4490*cdf0e10cSrcweir Deactivate(); 4491*cdf0e10cSrcweir return; 4492*cdf0e10cSrcweir } 4493*cdf0e10cSrcweir 4494*cdf0e10cSrcweir 4495*cdf0e10cSrcweir // Aktuelle Daten setzen 4496*cdf0e10cSrcweir sal_uInt16 nTrackFlags = 0; 4497*cdf0e10cSrcweir mnCurPos = i; 4498*cdf0e10cSrcweir mnCurItemId = it->mnId; 4499*cdf0e10cSrcweir mnDownItemId = mnCurItemId; 4500*cdf0e10cSrcweir mnMouseClicks = rMEvt.GetClicks(); 4501*cdf0e10cSrcweir mnMouseModifier = rMEvt.GetModifier(); 4502*cdf0e10cSrcweir if ( it->mnBits & TIB_REPEAT ) 4503*cdf0e10cSrcweir nTrackFlags |= STARTTRACK_BUTTONREPEAT; 4504*cdf0e10cSrcweir 4505*cdf0e10cSrcweir 4506*cdf0e10cSrcweir if ( mbSelection ) 4507*cdf0e10cSrcweir { 4508*cdf0e10cSrcweir ImplDrawItem( mnCurPos, sal_True ); 4509*cdf0e10cSrcweir Highlight(); 4510*cdf0e10cSrcweir } 4511*cdf0e10cSrcweir else 4512*cdf0e10cSrcweir { 4513*cdf0e10cSrcweir // Hier schon bDrag setzen, da in EndSelection ausgewertet wird 4514*cdf0e10cSrcweir mbDrag = sal_True; 4515*cdf0e10cSrcweir 4516*cdf0e10cSrcweir // Bei Doppelklick nur den Handler rufen, aber bevor der 4517*cdf0e10cSrcweir // Button gehiltet wird, da evt. in diesem Handler der 4518*cdf0e10cSrcweir // Drag-Vorgang abgebrochen wird 4519*cdf0e10cSrcweir if ( rMEvt.GetClicks() == 2 ) 4520*cdf0e10cSrcweir DoubleClick(); 4521*cdf0e10cSrcweir 4522*cdf0e10cSrcweir 4523*cdf0e10cSrcweir if ( mbDrag ) 4524*cdf0e10cSrcweir { 4525*cdf0e10cSrcweir ImplDrawItem( mnCurPos, sal_True ); 4526*cdf0e10cSrcweir Highlight(); 4527*cdf0e10cSrcweir } 4528*cdf0e10cSrcweir 4529*cdf0e10cSrcweir // was dropdown arrow pressed 4530*cdf0e10cSrcweir if( (it->mnBits & TIB_DROPDOWN) ) 4531*cdf0e10cSrcweir { 4532*cdf0e10cSrcweir if( ( (it->mnBits & TIB_DROPDOWNONLY) == TIB_DROPDOWNONLY) || it->GetDropDownRect( mbHorz ).IsInside( aMousePos )) 4533*cdf0e10cSrcweir { 4534*cdf0e10cSrcweir // dropdownonly always triggers the dropdown handler, over the whole button area 4535*cdf0e10cSrcweir 4536*cdf0e10cSrcweir // the drop down arrow should not trigger the item action 4537*cdf0e10cSrcweir mpData->mbDropDownByKeyboard = sal_False; 4538*cdf0e10cSrcweir GetDropdownClickHdl().Call( this ); 4539*cdf0e10cSrcweir 4540*cdf0e10cSrcweir // do not reset data if the dropdown handler opened a floating window 4541*cdf0e10cSrcweir // see ImplFloatControl() 4542*cdf0e10cSrcweir if( mpFloatWin == NULL ) 4543*cdf0e10cSrcweir { 4544*cdf0e10cSrcweir // no floater was opened 4545*cdf0e10cSrcweir Deactivate(); 4546*cdf0e10cSrcweir ImplDrawItem( mnCurPos, sal_False ); 4547*cdf0e10cSrcweir 4548*cdf0e10cSrcweir mnCurPos = TOOLBOX_ITEM_NOTFOUND; 4549*cdf0e10cSrcweir mnCurItemId = 0; 4550*cdf0e10cSrcweir mnDownItemId = 0; 4551*cdf0e10cSrcweir mnMouseClicks = 0; 4552*cdf0e10cSrcweir mnMouseModifier = 0; 4553*cdf0e10cSrcweir mnHighItemId = 0; 4554*cdf0e10cSrcweir } 4555*cdf0e10cSrcweir return; 4556*cdf0e10cSrcweir } 4557*cdf0e10cSrcweir else // activate long click timer 4558*cdf0e10cSrcweir mpData->maDropdownTimer.Start(); 4559*cdf0e10cSrcweir } 4560*cdf0e10cSrcweir 4561*cdf0e10cSrcweir 4562*cdf0e10cSrcweir // Click-Handler aufrufen 4563*cdf0e10cSrcweir if ( rMEvt.GetClicks() != 2 ) 4564*cdf0e10cSrcweir Click(); 4565*cdf0e10cSrcweir 4566*cdf0e10cSrcweir // Bei Repeat auch den Select-Handler rufen 4567*cdf0e10cSrcweir if ( nTrackFlags & STARTTRACK_BUTTONREPEAT ) 4568*cdf0e10cSrcweir Select(); 4569*cdf0e10cSrcweir 4570*cdf0e10cSrcweir // Wenn die Aktion nicht im Click-Handler abgebrochen wurde 4571*cdf0e10cSrcweir if ( mbDrag ) 4572*cdf0e10cSrcweir StartTracking( nTrackFlags ); 4573*cdf0e10cSrcweir } 4574*cdf0e10cSrcweir 4575*cdf0e10cSrcweir // Wenn Maus ueber einem Item gedrueckt wurde, koennen wir 4576*cdf0e10cSrcweir // die Bearbeitung abbrechen 4577*cdf0e10cSrcweir return; 4578*cdf0e10cSrcweir } 4579*cdf0e10cSrcweir 4580*cdf0e10cSrcweir Deactivate(); 4581*cdf0e10cSrcweir 4582*cdf0e10cSrcweir // menu button hit ? 4583*cdf0e10cSrcweir if( mpData->maMenubuttonItem.maRect.IsInside( aMousePos ) ) 4584*cdf0e10cSrcweir { 4585*cdf0e10cSrcweir ExecuteCustomMenu(); 4586*cdf0e10cSrcweir return; 4587*cdf0e10cSrcweir } 4588*cdf0e10cSrcweir 4589*cdf0e10cSrcweir 4590*cdf0e10cSrcweir // Gegebenenfalls noch Scroll- und Next-Buttons ueberpruefen 4591*cdf0e10cSrcweir if ( maUpperRect.IsInside( aMousePos ) ) 4592*cdf0e10cSrcweir { 4593*cdf0e10cSrcweir if ( mnCurLine > 1 ) 4594*cdf0e10cSrcweir { 4595*cdf0e10cSrcweir StartTracking(); 4596*cdf0e10cSrcweir mbUpper = sal_True; 4597*cdf0e10cSrcweir mbIn = sal_True; 4598*cdf0e10cSrcweir ImplDrawSpin( sal_True, sal_False ); 4599*cdf0e10cSrcweir } 4600*cdf0e10cSrcweir return; 4601*cdf0e10cSrcweir } 4602*cdf0e10cSrcweir if ( maLowerRect.IsInside( aMousePos ) ) 4603*cdf0e10cSrcweir { 4604*cdf0e10cSrcweir if ( mnCurLine+mnVisLines-1 < mnCurLines ) 4605*cdf0e10cSrcweir { 4606*cdf0e10cSrcweir StartTracking(); 4607*cdf0e10cSrcweir mbLower = sal_True; 4608*cdf0e10cSrcweir mbIn = sal_True; 4609*cdf0e10cSrcweir ImplDrawSpin( sal_False, sal_True ); 4610*cdf0e10cSrcweir } 4611*cdf0e10cSrcweir return; 4612*cdf0e10cSrcweir } 4613*cdf0e10cSrcweir if ( maNextToolRect.IsInside( aMousePos ) ) 4614*cdf0e10cSrcweir { 4615*cdf0e10cSrcweir StartTracking(); 4616*cdf0e10cSrcweir mbNextTool = sal_True; 4617*cdf0e10cSrcweir mbIn = sal_True; 4618*cdf0e10cSrcweir ImplDrawNext( sal_True ); 4619*cdf0e10cSrcweir return; 4620*cdf0e10cSrcweir } 4621*cdf0e10cSrcweir 4622*cdf0e10cSrcweir // Linesizing testen 4623*cdf0e10cSrcweir if ( (mnWinStyle & TB_WBLINESIZING) == TB_WBLINESIZING ) 4624*cdf0e10cSrcweir { 4625*cdf0e10cSrcweir sal_uInt16 nLineMode = ImplTestLineSize( this, aMousePos ); 4626*cdf0e10cSrcweir if ( nLineMode ) 4627*cdf0e10cSrcweir { 4628*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 4629*cdf0e10cSrcweir 4630*cdf0e10cSrcweir // Handler rufen, damit die Dock-Rectangles gesetzt werden 4631*cdf0e10cSrcweir // koenen 4632*cdf0e10cSrcweir StartDocking(); 4633*cdf0e10cSrcweir 4634*cdf0e10cSrcweir Point aPos = GetParent()->OutputToScreenPixel( GetPosPixel() ); 4635*cdf0e10cSrcweir Size aSize = GetSizePixel(); 4636*cdf0e10cSrcweir aPos = ScreenToOutputPixel( aPos ); 4637*cdf0e10cSrcweir 4638*cdf0e10cSrcweir // Dragging starten 4639*cdf0e10cSrcweir pMgr->StartDragging( this, aMousePos, Rectangle( aPos, aSize ), 4640*cdf0e10cSrcweir nLineMode, sal_False ); 4641*cdf0e10cSrcweir return; 4642*cdf0e10cSrcweir } 4643*cdf0e10cSrcweir } 4644*cdf0e10cSrcweir 4645*cdf0e10cSrcweir // Kein Item, dann nur Click oder DoubleClick 4646*cdf0e10cSrcweir if ( rMEvt.GetClicks() == 2 ) 4647*cdf0e10cSrcweir DoubleClick(); 4648*cdf0e10cSrcweir else 4649*cdf0e10cSrcweir Click(); 4650*cdf0e10cSrcweir } 4651*cdf0e10cSrcweir 4652*cdf0e10cSrcweir if ( !mbDrag && !mbSelection && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) ) 4653*cdf0e10cSrcweir DockingWindow::MouseButtonDown( rMEvt ); 4654*cdf0e10cSrcweir } 4655*cdf0e10cSrcweir 4656*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4657*cdf0e10cSrcweir 4658*cdf0e10cSrcweir void ToolBox::MouseButtonUp( const MouseEvent& rMEvt ) 4659*cdf0e10cSrcweir { 4660*cdf0e10cSrcweir if ( ImplHandleMouseButtonUp( rMEvt ) ) 4661*cdf0e10cSrcweir return; 4662*cdf0e10cSrcweir 4663*cdf0e10cSrcweir if ( mbDragging && (rMEvt.IsLeft() || mbCommandDrag) ) 4664*cdf0e10cSrcweir { 4665*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 4666*cdf0e10cSrcweir pMgr->EndDragging(); 4667*cdf0e10cSrcweir return; 4668*cdf0e10cSrcweir } 4669*cdf0e10cSrcweir mbCommandDrag = sal_False; 4670*cdf0e10cSrcweir 4671*cdf0e10cSrcweir DockingWindow::MouseButtonUp( rMEvt ); 4672*cdf0e10cSrcweir } 4673*cdf0e10cSrcweir 4674*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4675*cdf0e10cSrcweir 4676*cdf0e10cSrcweir void ToolBox::Tracking( const TrackingEvent& rTEvt ) 4677*cdf0e10cSrcweir { 4678*cdf0e10cSrcweir ImplDelData aDelData; 4679*cdf0e10cSrcweir ImplAddDel( &aDelData ); 4680*cdf0e10cSrcweir 4681*cdf0e10cSrcweir if ( rTEvt.IsTrackingEnded() ) 4682*cdf0e10cSrcweir ImplHandleMouseButtonUp( rTEvt.GetMouseEvent(), rTEvt.IsTrackingCanceled() ); 4683*cdf0e10cSrcweir else 4684*cdf0e10cSrcweir ImplHandleMouseMove( rTEvt.GetMouseEvent(), rTEvt.IsTrackingRepeat() ); 4685*cdf0e10cSrcweir 4686*cdf0e10cSrcweir if ( aDelData.IsDelete() ) 4687*cdf0e10cSrcweir // toolbox was deleted 4688*cdf0e10cSrcweir return; 4689*cdf0e10cSrcweir ImplRemoveDel( &aDelData ); 4690*cdf0e10cSrcweir DockingWindow::Tracking( rTEvt ); 4691*cdf0e10cSrcweir } 4692*cdf0e10cSrcweir 4693*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4694*cdf0e10cSrcweir 4695*cdf0e10cSrcweir void ToolBox::Paint( const Rectangle& rPaintRect ) 4696*cdf0e10cSrcweir { 4697*cdf0e10cSrcweir if( mpData->mbIsPaintLocked ) 4698*cdf0e10cSrcweir return; 4699*cdf0e10cSrcweir if ( rPaintRect == Rectangle( 0, 0, mnDX-1, mnDY-1 ) ) 4700*cdf0e10cSrcweir mbFullPaint = sal_True; 4701*cdf0e10cSrcweir ImplFormat(); 4702*cdf0e10cSrcweir mbFullPaint = sal_False; 4703*cdf0e10cSrcweir 4704*cdf0e10cSrcweir 4705*cdf0e10cSrcweir ImplDrawBackground( this, rPaintRect ); 4706*cdf0e10cSrcweir 4707*cdf0e10cSrcweir if ( (mnWinStyle & WB_BORDER) && !ImplIsFloatingMode() ) 4708*cdf0e10cSrcweir ImplDrawBorder( this ); 4709*cdf0e10cSrcweir 4710*cdf0e10cSrcweir if( !ImplIsFloatingMode() ) 4711*cdf0e10cSrcweir ImplDrawGrip( this ); 4712*cdf0e10cSrcweir 4713*cdf0e10cSrcweir ImplDrawMenubutton( this, mpData->mbMenubuttonSelected ); 4714*cdf0e10cSrcweir 4715*cdf0e10cSrcweir // SpinButtons zeichnen 4716*cdf0e10cSrcweir if ( mnWinStyle & WB_SCROLL ) 4717*cdf0e10cSrcweir { 4718*cdf0e10cSrcweir if ( mnCurLines > mnLines ) 4719*cdf0e10cSrcweir ImplDrawSpin( sal_False, sal_False ); 4720*cdf0e10cSrcweir } 4721*cdf0e10cSrcweir 4722*cdf0e10cSrcweir // NextButton zeichnen 4723*cdf0e10cSrcweir ImplDrawNext( sal_False ); 4724*cdf0e10cSrcweir 4725*cdf0e10cSrcweir // Buttons zeichnen 4726*cdf0e10cSrcweir sal_uInt16 nHighPos; 4727*cdf0e10cSrcweir if ( mnHighItemId ) 4728*cdf0e10cSrcweir nHighPos = GetItemPos( mnHighItemId ); 4729*cdf0e10cSrcweir else 4730*cdf0e10cSrcweir nHighPos = TOOLBOX_ITEM_NOTFOUND; 4731*cdf0e10cSrcweir 4732*cdf0e10cSrcweir sal_uInt16 nCount = (sal_uInt16)mpData->m_aItems.size(); 4733*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nCount; i++ ) 4734*cdf0e10cSrcweir { 4735*cdf0e10cSrcweir ImplToolItem* pItem = &mpData->m_aItems[i]; 4736*cdf0e10cSrcweir 4737*cdf0e10cSrcweir // Nur malen, wenn Rechteck im PaintRectangle liegt 4738*cdf0e10cSrcweir if ( !pItem->maRect.IsEmpty() && rPaintRect.IsOver( pItem->maRect ) ) 4739*cdf0e10cSrcweir { 4740*cdf0e10cSrcweir sal_Bool bHighlight = sal_False; 4741*cdf0e10cSrcweir if ( i == mnCurPos ) 4742*cdf0e10cSrcweir bHighlight = 1; 4743*cdf0e10cSrcweir else if ( i == nHighPos ) 4744*cdf0e10cSrcweir bHighlight = 2; 4745*cdf0e10cSrcweir ImplDrawItem( i, bHighlight ); 4746*cdf0e10cSrcweir } 4747*cdf0e10cSrcweir } 4748*cdf0e10cSrcweir ImplShowFocus(); 4749*cdf0e10cSrcweir } 4750*cdf0e10cSrcweir 4751*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4752*cdf0e10cSrcweir 4753*cdf0e10cSrcweir void ToolBox::Move() 4754*cdf0e10cSrcweir { 4755*cdf0e10cSrcweir DockingWindow::Move(); 4756*cdf0e10cSrcweir } 4757*cdf0e10cSrcweir 4758*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4759*cdf0e10cSrcweir 4760*cdf0e10cSrcweir void ToolBox::Resize() 4761*cdf0e10cSrcweir { 4762*cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 4763*cdf0e10cSrcweir // #i31422# some WindowManagers send (0,0) sizes when 4764*cdf0e10cSrcweir // switching virtual desktops - ignore this and avoid reformatting 4765*cdf0e10cSrcweir if( !aSize.Width() && !aSize.Height() ) 4766*cdf0e10cSrcweir return; 4767*cdf0e10cSrcweir 4768*cdf0e10cSrcweir long nOldDX = mnDX; 4769*cdf0e10cSrcweir long nOldDY = mnDY; 4770*cdf0e10cSrcweir mnDX = aSize.Width(); 4771*cdf0e10cSrcweir mnDY = aSize.Height(); 4772*cdf0e10cSrcweir 4773*cdf0e10cSrcweir mnLastResizeDY = 0; 4774*cdf0e10cSrcweir 4775*cdf0e10cSrcweir // invalidate everything to have gradient backgrounds properly drawn 4776*cdf0e10cSrcweir Invalidate(); 4777*cdf0e10cSrcweir 4778*cdf0e10cSrcweir // Evt. neu formatieren oder neu painten 4779*cdf0e10cSrcweir if ( mbScroll ) 4780*cdf0e10cSrcweir { 4781*cdf0e10cSrcweir if ( !mbFormat ) 4782*cdf0e10cSrcweir { 4783*cdf0e10cSrcweir mbFormat = sal_True; 4784*cdf0e10cSrcweir if( IsReallyVisible() ) 4785*cdf0e10cSrcweir ImplFormat( sal_True ); 4786*cdf0e10cSrcweir } 4787*cdf0e10cSrcweir } 4788*cdf0e10cSrcweir 4789*cdf0e10cSrcweir // Border muss neu ausgegeben werden 4790*cdf0e10cSrcweir if ( mnWinStyle & WB_BORDER ) 4791*cdf0e10cSrcweir { 4792*cdf0e10cSrcweir // Da wir sonst beim Paint denken, das alles neu gepaintet wird 4793*cdf0e10cSrcweir if ( mbFormat && IsReallyVisible() ) 4794*cdf0e10cSrcweir Invalidate(); 4795*cdf0e10cSrcweir else 4796*cdf0e10cSrcweir { 4797*cdf0e10cSrcweir if ( mnRightBorder ) 4798*cdf0e10cSrcweir { 4799*cdf0e10cSrcweir if ( nOldDX > mnDX ) 4800*cdf0e10cSrcweir Invalidate( Rectangle( mnDX-mnRightBorder-1, 0, mnDX, mnDY ) ); 4801*cdf0e10cSrcweir else 4802*cdf0e10cSrcweir Invalidate( Rectangle( nOldDX-mnRightBorder-1, 0, nOldDX, nOldDY ) ); 4803*cdf0e10cSrcweir } 4804*cdf0e10cSrcweir 4805*cdf0e10cSrcweir if ( mnBottomBorder ) 4806*cdf0e10cSrcweir { 4807*cdf0e10cSrcweir if ( nOldDY > mnDY ) 4808*cdf0e10cSrcweir Invalidate( Rectangle( 0, mnDY-mnBottomBorder-1, mnDX, mnDY ) ); 4809*cdf0e10cSrcweir else 4810*cdf0e10cSrcweir Invalidate( Rectangle( 0, nOldDY-mnBottomBorder-1, nOldDX, nOldDY ) ); 4811*cdf0e10cSrcweir } 4812*cdf0e10cSrcweir } 4813*cdf0e10cSrcweir } 4814*cdf0e10cSrcweir } 4815*cdf0e10cSrcweir 4816*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4817*cdf0e10cSrcweir const XubString& ToolBox::ImplGetHelpText( sal_uInt16 nItemId ) const 4818*cdf0e10cSrcweir { 4819*cdf0e10cSrcweir ImplToolItem* pItem = ImplGetItem( nItemId ); 4820*cdf0e10cSrcweir 4821*cdf0e10cSrcweir if ( pItem ) 4822*cdf0e10cSrcweir { 4823*cdf0e10cSrcweir if ( !pItem->maHelpText.Len() && ( pItem->maHelpId.getLength() || pItem->maCommandStr.Len() )) 4824*cdf0e10cSrcweir { 4825*cdf0e10cSrcweir Help* pHelp = Application::GetHelp(); 4826*cdf0e10cSrcweir if ( pHelp ) 4827*cdf0e10cSrcweir { 4828*cdf0e10cSrcweir if ( pItem->maCommandStr.Len() ) 4829*cdf0e10cSrcweir pItem->maHelpText = pHelp->GetHelpText( pItem->maCommandStr, this ); 4830*cdf0e10cSrcweir if ( !pItem->maHelpText.Len() && pItem->maHelpId.getLength() ) 4831*cdf0e10cSrcweir pItem->maHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this ); 4832*cdf0e10cSrcweir } 4833*cdf0e10cSrcweir } 4834*cdf0e10cSrcweir 4835*cdf0e10cSrcweir return pItem->maHelpText; 4836*cdf0e10cSrcweir } 4837*cdf0e10cSrcweir else 4838*cdf0e10cSrcweir return ImplGetSVEmptyStr(); 4839*cdf0e10cSrcweir } 4840*cdf0e10cSrcweir 4841*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4842*cdf0e10cSrcweir 4843*cdf0e10cSrcweir void ToolBox::RequestHelp( const HelpEvent& rHEvt ) 4844*cdf0e10cSrcweir { 4845*cdf0e10cSrcweir sal_uInt16 nItemId; 4846*cdf0e10cSrcweir Point aHelpPos; 4847*cdf0e10cSrcweir 4848*cdf0e10cSrcweir if( !rHEvt.KeyboardActivated() ) 4849*cdf0e10cSrcweir { 4850*cdf0e10cSrcweir nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); 4851*cdf0e10cSrcweir aHelpPos = rHEvt.GetMousePosPixel(); 4852*cdf0e10cSrcweir } 4853*cdf0e10cSrcweir else 4854*cdf0e10cSrcweir { 4855*cdf0e10cSrcweir if( !mnHighItemId ) 4856*cdf0e10cSrcweir return; 4857*cdf0e10cSrcweir else 4858*cdf0e10cSrcweir nItemId = mnHighItemId; 4859*cdf0e10cSrcweir Rectangle aRect( GetItemRect( nItemId ) ); 4860*cdf0e10cSrcweir if( aRect.IsEmpty() ) 4861*cdf0e10cSrcweir return; 4862*cdf0e10cSrcweir else 4863*cdf0e10cSrcweir aHelpPos = OutputToScreenPixel( aRect.Center() ); 4864*cdf0e10cSrcweir } 4865*cdf0e10cSrcweir 4866*cdf0e10cSrcweir if ( nItemId ) 4867*cdf0e10cSrcweir { 4868*cdf0e10cSrcweir if ( rHEvt.GetMode() & (HELPMODE_BALLOON | HELPMODE_QUICK) ) 4869*cdf0e10cSrcweir { 4870*cdf0e10cSrcweir // Rechteck ermitteln 4871*cdf0e10cSrcweir Rectangle aTempRect = GetItemRect( nItemId ); 4872*cdf0e10cSrcweir Point aPt = OutputToScreenPixel( aTempRect.TopLeft() ); 4873*cdf0e10cSrcweir aTempRect.Left() = aPt.X(); 4874*cdf0e10cSrcweir aTempRect.Top() = aPt.Y(); 4875*cdf0e10cSrcweir aPt = OutputToScreenPixel( aTempRect.BottomRight() ); 4876*cdf0e10cSrcweir aTempRect.Right() = aPt.X(); 4877*cdf0e10cSrcweir aTempRect.Bottom() = aPt.Y(); 4878*cdf0e10cSrcweir 4879*cdf0e10cSrcweir // Text ermitteln und anzeigen 4880*cdf0e10cSrcweir XubString aStr = GetQuickHelpText( nItemId ); 4881*cdf0e10cSrcweir const XubString& rHelpStr = GetHelpText( nItemId ); 4882*cdf0e10cSrcweir if ( !aStr.Len() ) 4883*cdf0e10cSrcweir aStr = MnemonicGenerator::EraseAllMnemonicChars( GetItemText( nItemId ) ); 4884*cdf0e10cSrcweir if ( rHEvt.GetMode() & HELPMODE_BALLOON ) 4885*cdf0e10cSrcweir { 4886*cdf0e10cSrcweir if ( rHelpStr.Len() ) 4887*cdf0e10cSrcweir aStr = rHelpStr; 4888*cdf0e10cSrcweir Help::ShowBalloon( this, aHelpPos, aTempRect, aStr ); 4889*cdf0e10cSrcweir } 4890*cdf0e10cSrcweir else 4891*cdf0e10cSrcweir Help::ShowQuickHelp( this, aTempRect, aStr, rHelpStr, QUICKHELP_CTRLTEXT ); 4892*cdf0e10cSrcweir return; 4893*cdf0e10cSrcweir } 4894*cdf0e10cSrcweir else if ( rHEvt.GetMode() & HELPMODE_EXTENDED ) 4895*cdf0e10cSrcweir { 4896*cdf0e10cSrcweir String aCommand = GetItemCommand( nItemId ); 4897*cdf0e10cSrcweir rtl::OString aHelpId( GetHelpId( nItemId ) ); 4898*cdf0e10cSrcweir 4899*cdf0e10cSrcweir if ( aCommand.Len() || aHelpId.getLength() ) 4900*cdf0e10cSrcweir { 4901*cdf0e10cSrcweir // Wenn eine Hilfe existiert, dann ausloesen 4902*cdf0e10cSrcweir Help* pHelp = Application::GetHelp(); 4903*cdf0e10cSrcweir if ( pHelp ) 4904*cdf0e10cSrcweir { 4905*cdf0e10cSrcweir if ( aCommand.Len() ) 4906*cdf0e10cSrcweir pHelp->Start( aCommand, this ); 4907*cdf0e10cSrcweir else if ( aHelpId.getLength() ) 4908*cdf0e10cSrcweir pHelp->Start( rtl::OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), this ); 4909*cdf0e10cSrcweir } 4910*cdf0e10cSrcweir return; 4911*cdf0e10cSrcweir } 4912*cdf0e10cSrcweir } 4913*cdf0e10cSrcweir } 4914*cdf0e10cSrcweir else if ( maNextToolRect.IsInside( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ) ) 4915*cdf0e10cSrcweir { 4916*cdf0e10cSrcweir if ( rHEvt.GetMode() & (HELPMODE_BALLOON | HELPMODE_QUICK) ) 4917*cdf0e10cSrcweir { 4918*cdf0e10cSrcweir // Rechteck ermitteln 4919*cdf0e10cSrcweir Rectangle aTempRect = maNextToolRect; 4920*cdf0e10cSrcweir Point aPt = OutputToScreenPixel( aTempRect.TopLeft() ); 4921*cdf0e10cSrcweir aTempRect.Left() = aPt.X(); 4922*cdf0e10cSrcweir aTempRect.Top() = aPt.Y(); 4923*cdf0e10cSrcweir aPt = OutputToScreenPixel( aTempRect.BottomRight() ); 4924*cdf0e10cSrcweir aTempRect.Right() = aPt.X(); 4925*cdf0e10cSrcweir aTempRect.Bottom() = aPt.Y(); 4926*cdf0e10cSrcweir 4927*cdf0e10cSrcweir if ( rHEvt.GetMode() & HELPMODE_BALLOON ) 4928*cdf0e10cSrcweir Help::ShowBalloon( this, aTempRect.Center(), aTempRect, maNextToolBoxStr ); 4929*cdf0e10cSrcweir else 4930*cdf0e10cSrcweir Help::ShowQuickHelp( this, aTempRect, maNextToolBoxStr ); 4931*cdf0e10cSrcweir return; 4932*cdf0e10cSrcweir } 4933*cdf0e10cSrcweir } 4934*cdf0e10cSrcweir 4935*cdf0e10cSrcweir DockingWindow::RequestHelp( rHEvt ); 4936*cdf0e10cSrcweir } 4937*cdf0e10cSrcweir 4938*cdf0e10cSrcweir // ----------------------------------------------------------------------- 4939*cdf0e10cSrcweir 4940*cdf0e10cSrcweir long ToolBox::Notify( NotifyEvent& rNEvt ) 4941*cdf0e10cSrcweir { 4942*cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_KEYINPUT ) 4943*cdf0e10cSrcweir { 4944*cdf0e10cSrcweir KeyEvent aKEvt = *rNEvt.GetKeyEvent(); 4945*cdf0e10cSrcweir KeyCode aKeyCode = aKEvt.GetKeyCode(); 4946*cdf0e10cSrcweir sal_uInt16 nKeyCode = aKeyCode.GetCode(); 4947*cdf0e10cSrcweir switch( nKeyCode ) 4948*cdf0e10cSrcweir { 4949*cdf0e10cSrcweir case KEY_TAB: 4950*cdf0e10cSrcweir { 4951*cdf0e10cSrcweir // internal TAB cycling only if parent is not a dialog or if we are the ony child 4952*cdf0e10cSrcweir // otherwise the dialog control will take over 4953*cdf0e10cSrcweir sal_Bool bNoTabCycling = ( ( ImplGetParent()->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL) ) == WB_DIALOGCONTROL && 4954*cdf0e10cSrcweir ImplGetParent()->GetChildCount() != 1 ); 4955*cdf0e10cSrcweir 4956*cdf0e10cSrcweir if( bNoTabCycling && ! (GetStyle() & WB_FORCETABCYCLE) ) 4957*cdf0e10cSrcweir return DockingWindow::Notify( rNEvt ); 4958*cdf0e10cSrcweir else if( ImplChangeHighlightUpDn( aKeyCode.IsShift() ? sal_True : sal_False , bNoTabCycling ) ) 4959*cdf0e10cSrcweir return sal_False; 4960*cdf0e10cSrcweir else 4961*cdf0e10cSrcweir return DockingWindow::Notify( rNEvt ); 4962*cdf0e10cSrcweir } 4963*cdf0e10cSrcweir default: 4964*cdf0e10cSrcweir break; 4965*cdf0e10cSrcweir }; 4966*cdf0e10cSrcweir } 4967*cdf0e10cSrcweir else if( rNEvt.GetType() == EVENT_GETFOCUS ) 4968*cdf0e10cSrcweir { 4969*cdf0e10cSrcweir if( rNEvt.GetWindow() == this ) 4970*cdf0e10cSrcweir { 4971*cdf0e10cSrcweir // the toolbar itself got the focus 4972*cdf0e10cSrcweir if( mnLastFocusItemId != 0 ) 4973*cdf0e10cSrcweir { 4974*cdf0e10cSrcweir // restore last item 4975*cdf0e10cSrcweir ImplChangeHighlight( ImplGetItem( mnLastFocusItemId ) ); 4976*cdf0e10cSrcweir mnLastFocusItemId = 0; 4977*cdf0e10cSrcweir } 4978*cdf0e10cSrcweir else if( (GetGetFocusFlags() & (GETFOCUS_BACKWARD|GETFOCUS_TAB) ) == (GETFOCUS_BACKWARD|GETFOCUS_TAB)) 4979*cdf0e10cSrcweir // Shift-TAB was pressed in the parent 4980*cdf0e10cSrcweir ImplChangeHighlightUpDn( sal_False ); 4981*cdf0e10cSrcweir else 4982*cdf0e10cSrcweir ImplChangeHighlightUpDn( sal_True ); 4983*cdf0e10cSrcweir 4984*cdf0e10cSrcweir mnLastFocusItemId = 0; 4985*cdf0e10cSrcweir 4986*cdf0e10cSrcweir return true; 4987*cdf0e10cSrcweir } 4988*cdf0e10cSrcweir else 4989*cdf0e10cSrcweir { 4990*cdf0e10cSrcweir // a child window got the focus so update current item to 4991*cdf0e10cSrcweir // allow for proper lose focus handling in keyboard navigation 4992*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 4993*cdf0e10cSrcweir while( it != mpData->m_aItems.end() ) 4994*cdf0e10cSrcweir { 4995*cdf0e10cSrcweir if ( it->mbVisible ) 4996*cdf0e10cSrcweir { 4997*cdf0e10cSrcweir if ( it->mpWindow && it->mpWindow->ImplIsWindowOrChild( rNEvt.GetWindow() ) ) 4998*cdf0e10cSrcweir { 4999*cdf0e10cSrcweir mnHighItemId = it->mnId; 5000*cdf0e10cSrcweir break; 5001*cdf0e10cSrcweir } 5002*cdf0e10cSrcweir } 5003*cdf0e10cSrcweir 5004*cdf0e10cSrcweir ++it; 5005*cdf0e10cSrcweir } 5006*cdf0e10cSrcweir return DockingWindow::Notify( rNEvt ); 5007*cdf0e10cSrcweir } 5008*cdf0e10cSrcweir } 5009*cdf0e10cSrcweir else if( rNEvt.GetType() == EVENT_LOSEFOCUS ) 5010*cdf0e10cSrcweir { 5011*cdf0e10cSrcweir // deselect 5012*cdf0e10cSrcweir ImplHideFocus(); 5013*cdf0e10cSrcweir mnHighItemId = 0; 5014*cdf0e10cSrcweir mnCurPos = TOOLBOX_ITEM_NOTFOUND; 5015*cdf0e10cSrcweir } 5016*cdf0e10cSrcweir 5017*cdf0e10cSrcweir return DockingWindow::Notify( rNEvt ); 5018*cdf0e10cSrcweir } 5019*cdf0e10cSrcweir 5020*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5021*cdf0e10cSrcweir 5022*cdf0e10cSrcweir void ToolBox::Command( const CommandEvent& rCEvt ) 5023*cdf0e10cSrcweir { 5024*cdf0e10cSrcweir // StartDrag auf MouseButton/Left/Alt abbilden 5025*cdf0e10cSrcweir if ( (rCEvt.GetCommand() == COMMAND_STARTDRAG) && rCEvt.IsMouseEvent() && 5026*cdf0e10cSrcweir mbCustomize && !mbDragging && !mbDrag && !mbSelection && 5027*cdf0e10cSrcweir (mnCurPos == TOOLBOX_ITEM_NOTFOUND) ) 5028*cdf0e10cSrcweir { 5029*cdf0e10cSrcweir // Wir erlauben nur das Draggen von Items. Deshalb muessen wir 5030*cdf0e10cSrcweir // testen, ob auch ein Item angeklickt wurde, ansonsten wuerden 5031*cdf0e10cSrcweir // wir evt. das Fenster verschieben, was nicht gewollt waere. 5032*cdf0e10cSrcweir // Wir machen dieses jedoch nur im Customize-Mode, da ansonsten 5033*cdf0e10cSrcweir // Items zuhaeufig ausversehen verschoben werden. 5034*cdf0e10cSrcweir if ( mbCustomizeMode ) 5035*cdf0e10cSrcweir { 5036*cdf0e10cSrcweir Point aMousePos = rCEvt.GetMousePosPixel(); 5037*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 5038*cdf0e10cSrcweir while ( it != mpData->m_aItems.end() ) 5039*cdf0e10cSrcweir { 5040*cdf0e10cSrcweir // Ist es dieses Item 5041*cdf0e10cSrcweir if ( it->maRect.IsInside( aMousePos ) ) 5042*cdf0e10cSrcweir { 5043*cdf0e10cSrcweir // Ist es ein Separator oder ist das Item disabled, 5044*cdf0e10cSrcweir // dann mache nichts 5045*cdf0e10cSrcweir if ( (it->meType == TOOLBOXITEM_BUTTON) && 5046*cdf0e10cSrcweir !it->mbShowWindow ) 5047*cdf0e10cSrcweir mbCommandDrag = sal_True; 5048*cdf0e10cSrcweir break; 5049*cdf0e10cSrcweir } 5050*cdf0e10cSrcweir 5051*cdf0e10cSrcweir ++it; 5052*cdf0e10cSrcweir } 5053*cdf0e10cSrcweir 5054*cdf0e10cSrcweir if ( mbCommandDrag ) 5055*cdf0e10cSrcweir { 5056*cdf0e10cSrcweir MouseEvent aMEvt( aMousePos, 1, MOUSE_SIMPLECLICK, 5057*cdf0e10cSrcweir MOUSE_LEFT, KEY_MOD2 ); 5058*cdf0e10cSrcweir ToolBox::MouseButtonDown( aMEvt ); 5059*cdf0e10cSrcweir return; 5060*cdf0e10cSrcweir } 5061*cdf0e10cSrcweir } 5062*cdf0e10cSrcweir } 5063*cdf0e10cSrcweir else if ( rCEvt.GetCommand() == COMMAND_WHEEL ) 5064*cdf0e10cSrcweir { 5065*cdf0e10cSrcweir if ( (mnCurLine > 1) || (mnCurLine+mnVisLines-1 < mnCurLines) ) 5066*cdf0e10cSrcweir { 5067*cdf0e10cSrcweir const CommandWheelData* pData = rCEvt.GetWheelData(); 5068*cdf0e10cSrcweir if ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) 5069*cdf0e10cSrcweir { 5070*cdf0e10cSrcweir if ( (mnCurLine > 1) && (pData->GetDelta() > 0) ) 5071*cdf0e10cSrcweir ShowLine( sal_False ); 5072*cdf0e10cSrcweir else if ( (mnCurLine+mnVisLines-1 < mnCurLines) && (pData->GetDelta() < 0) ) 5073*cdf0e10cSrcweir ShowLine( sal_True ); 5074*cdf0e10cSrcweir ImplDrawSpin( sal_False, sal_False ); 5075*cdf0e10cSrcweir return; 5076*cdf0e10cSrcweir } 5077*cdf0e10cSrcweir } 5078*cdf0e10cSrcweir } 5079*cdf0e10cSrcweir 5080*cdf0e10cSrcweir DockingWindow::Command( rCEvt ); 5081*cdf0e10cSrcweir } 5082*cdf0e10cSrcweir 5083*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5084*cdf0e10cSrcweir 5085*cdf0e10cSrcweir void ToolBox::StateChanged( StateChangedType nType ) 5086*cdf0e10cSrcweir { 5087*cdf0e10cSrcweir DockingWindow::StateChanged( nType ); 5088*cdf0e10cSrcweir 5089*cdf0e10cSrcweir if ( nType == STATE_CHANGE_INITSHOW ) 5090*cdf0e10cSrcweir ImplFormat(); 5091*cdf0e10cSrcweir else if ( nType == STATE_CHANGE_ENABLE ) 5092*cdf0e10cSrcweir ImplUpdateItem(); 5093*cdf0e10cSrcweir else if ( nType == STATE_CHANGE_UPDATEMODE ) 5094*cdf0e10cSrcweir { 5095*cdf0e10cSrcweir if ( IsUpdateMode() ) 5096*cdf0e10cSrcweir Invalidate(); 5097*cdf0e10cSrcweir } 5098*cdf0e10cSrcweir else if ( (nType == STATE_CHANGE_ZOOM) || 5099*cdf0e10cSrcweir (nType == STATE_CHANGE_CONTROLFONT) ) 5100*cdf0e10cSrcweir { 5101*cdf0e10cSrcweir mbCalc = sal_True; 5102*cdf0e10cSrcweir mbFormat = sal_True; 5103*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_False, sal_False ); 5104*cdf0e10cSrcweir Invalidate(); 5105*cdf0e10cSrcweir } 5106*cdf0e10cSrcweir else if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) 5107*cdf0e10cSrcweir { 5108*cdf0e10cSrcweir ImplInitSettings( sal_False, sal_True, sal_False ); 5109*cdf0e10cSrcweir Invalidate(); 5110*cdf0e10cSrcweir } 5111*cdf0e10cSrcweir else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 5112*cdf0e10cSrcweir { 5113*cdf0e10cSrcweir ImplInitSettings( sal_False, sal_False, sal_True ); // font, foreground, background 5114*cdf0e10cSrcweir Invalidate(); 5115*cdf0e10cSrcweir } 5116*cdf0e10cSrcweir } 5117*cdf0e10cSrcweir 5118*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5119*cdf0e10cSrcweir 5120*cdf0e10cSrcweir void ToolBox::DataChanged( const DataChangedEvent& rDCEvt ) 5121*cdf0e10cSrcweir { 5122*cdf0e10cSrcweir DockingWindow::DataChanged( rDCEvt ); 5123*cdf0e10cSrcweir 5124*cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY) || 5125*cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTS) || 5126*cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || 5127*cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && 5128*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) 5129*cdf0e10cSrcweir { 5130*cdf0e10cSrcweir mbCalc = sal_True; 5131*cdf0e10cSrcweir mbFormat = sal_True; 5132*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 5133*cdf0e10cSrcweir Invalidate(); 5134*cdf0e10cSrcweir } 5135*cdf0e10cSrcweir } 5136*cdf0e10cSrcweir 5137*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5138*cdf0e10cSrcweir 5139*cdf0e10cSrcweir sal_Bool ToolBox::PrepareToggleFloatingMode() 5140*cdf0e10cSrcweir { 5141*cdf0e10cSrcweir return DockingWindow::PrepareToggleFloatingMode(); 5142*cdf0e10cSrcweir } 5143*cdf0e10cSrcweir 5144*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5145*cdf0e10cSrcweir 5146*cdf0e10cSrcweir void ToolBox::ToggleFloatingMode() 5147*cdf0e10cSrcweir { 5148*cdf0e10cSrcweir DockingWindow::ToggleFloatingMode(); 5149*cdf0e10cSrcweir 5150*cdf0e10cSrcweir sal_Bool mbOldHorz = mbHorz; 5151*cdf0e10cSrcweir 5152*cdf0e10cSrcweir if ( ImplIsFloatingMode() ) 5153*cdf0e10cSrcweir { 5154*cdf0e10cSrcweir mbHorz = sal_True; 5155*cdf0e10cSrcweir meAlign = WINDOWALIGN_TOP; 5156*cdf0e10cSrcweir mbScroll = sal_True; 5157*cdf0e10cSrcweir 5158*cdf0e10cSrcweir if( mbOldHorz != mbHorz ) 5159*cdf0e10cSrcweir mbCalc = sal_True; // orientation was changed ! 5160*cdf0e10cSrcweir 5161*cdf0e10cSrcweir ImplSetMinMaxFloatSize( this ); 5162*cdf0e10cSrcweir SetOutputSizePixel( ImplCalcFloatSize( this, mnFloatLines ) ); 5163*cdf0e10cSrcweir } 5164*cdf0e10cSrcweir else 5165*cdf0e10cSrcweir { 5166*cdf0e10cSrcweir mbScroll = (mnWinStyle & WB_SCROLL) ? sal_True : sal_False; 5167*cdf0e10cSrcweir if ( (meAlign == WINDOWALIGN_TOP) || (meAlign == WINDOWALIGN_BOTTOM) ) 5168*cdf0e10cSrcweir mbHorz = sal_True; 5169*cdf0e10cSrcweir else 5170*cdf0e10cSrcweir mbHorz = sal_False; 5171*cdf0e10cSrcweir 5172*cdf0e10cSrcweir // set focus back to document 5173*cdf0e10cSrcweir ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->GrabFocus(); 5174*cdf0e10cSrcweir } 5175*cdf0e10cSrcweir 5176*cdf0e10cSrcweir if( mbOldHorz != mbHorz ) 5177*cdf0e10cSrcweir { 5178*cdf0e10cSrcweir // if orientation changes, the toolbox has to be initialized again 5179*cdf0e10cSrcweir // to update the direction of the gradient 5180*cdf0e10cSrcweir mbCalc = sal_True; 5181*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 5182*cdf0e10cSrcweir } 5183*cdf0e10cSrcweir 5184*cdf0e10cSrcweir mbFormat = sal_True; 5185*cdf0e10cSrcweir ImplFormat(); 5186*cdf0e10cSrcweir } 5187*cdf0e10cSrcweir 5188*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5189*cdf0e10cSrcweir 5190*cdf0e10cSrcweir void ToolBox::StartDocking() 5191*cdf0e10cSrcweir { 5192*cdf0e10cSrcweir meDockAlign = meAlign; 5193*cdf0e10cSrcweir mnDockLines = mnLines; 5194*cdf0e10cSrcweir mbLastFloatMode = ImplIsFloatingMode(); 5195*cdf0e10cSrcweir DockingWindow::StartDocking(); 5196*cdf0e10cSrcweir } 5197*cdf0e10cSrcweir 5198*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5199*cdf0e10cSrcweir 5200*cdf0e10cSrcweir sal_Bool ToolBox::Docking( const Point& rPos, Rectangle& rRect ) 5201*cdf0e10cSrcweir { 5202*cdf0e10cSrcweir // Wenn Dragging, dann nicht machen, da vorher schon berechnet 5203*cdf0e10cSrcweir if ( mbDragging ) 5204*cdf0e10cSrcweir return sal_False; 5205*cdf0e10cSrcweir 5206*cdf0e10cSrcweir sal_Bool bFloatMode = sal_False; 5207*cdf0e10cSrcweir 5208*cdf0e10cSrcweir DockingWindow::Docking( rPos, rRect ); 5209*cdf0e10cSrcweir 5210*cdf0e10cSrcweir // Befindet sich die Maus ausserhalb des Bereichs befindet, kann es nur ein 5211*cdf0e10cSrcweir // FloatWindow werden 5212*cdf0e10cSrcweir Rectangle aDockingRect( rRect ); 5213*cdf0e10cSrcweir if ( !ImplIsFloatingMode() ) 5214*cdf0e10cSrcweir { 5215*cdf0e10cSrcweir // don't use tracking rectangle for alignment check, because it will be too large 5216*cdf0e10cSrcweir // to get a floating mode as result - switch to floating size 5217*cdf0e10cSrcweir // so the calculation only depends on the position of the rectangle, not the current 5218*cdf0e10cSrcweir // docking state of the window 5219*cdf0e10cSrcweir sal_uInt16 nTemp = 0; 5220*cdf0e10cSrcweir aDockingRect.SetSize( ImplCalcFloatSize( this, nTemp ) ); 5221*cdf0e10cSrcweir 5222*cdf0e10cSrcweir // in this mode docking is never done by keyboard, so it's OK to use the mouse position 5223*cdf0e10cSrcweir aDockingRect.SetPos( ImplGetFrameWindow()->GetPointerPosPixel() ); 5224*cdf0e10cSrcweir } 5225*cdf0e10cSrcweir 5226*cdf0e10cSrcweir Rectangle aIntersection = maOutDockRect.GetIntersection( aDockingRect ); 5227*cdf0e10cSrcweir if ( !aIntersection.IsEmpty() && !IsDockingPrevented() ) 5228*cdf0e10cSrcweir { 5229*cdf0e10cSrcweir Rectangle aInRect = maInDockRect; 5230*cdf0e10cSrcweir Size aDockSize; 5231*cdf0e10cSrcweir aDockSize.Width() = ImplCalcSize( this, mnLines, TB_CALCMODE_VERT ).Width(); 5232*cdf0e10cSrcweir aDockSize.Height() = ImplCalcSize( this, mnLines, TB_CALCMODE_HORZ ).Height(); 5233*cdf0e10cSrcweir aInRect.Left() += aDockSize.Width()/2; 5234*cdf0e10cSrcweir aInRect.Top() += aDockSize.Height()/2; 5235*cdf0e10cSrcweir aInRect.Right() -= aDockSize.Width()/2; 5236*cdf0e10cSrcweir aInRect.Bottom() -= aDockSize.Height()/2; 5237*cdf0e10cSrcweir 5238*cdf0e10cSrcweir // Wenn Fenster zu klein, wird das gesammte InDock-Rect genommen 5239*cdf0e10cSrcweir if ( aInRect.Left() >= aInRect.Right() ) 5240*cdf0e10cSrcweir { 5241*cdf0e10cSrcweir aInRect.Left() = maInDockRect.Left(); 5242*cdf0e10cSrcweir aInRect.Right() = maInDockRect.Right(); 5243*cdf0e10cSrcweir } 5244*cdf0e10cSrcweir if ( aInRect.Top() >= aInRect.Bottom() ) 5245*cdf0e10cSrcweir { 5246*cdf0e10cSrcweir aInRect.Top() = maInDockRect.Top(); 5247*cdf0e10cSrcweir aInRect.Bottom() = maInDockRect.Bottom(); 5248*cdf0e10cSrcweir } 5249*cdf0e10cSrcweir 5250*cdf0e10cSrcweir // Wenn Maus nicht im Dock-Bereich, dann kann es nur zum 5251*cdf0e10cSrcweir // FloatWindow werden 5252*cdf0e10cSrcweir Rectangle aIntersect = aInRect.GetIntersection( aDockingRect ); 5253*cdf0e10cSrcweir if ( aIntersect == aDockingRect ) 5254*cdf0e10cSrcweir bFloatMode = sal_True; 5255*cdf0e10cSrcweir else 5256*cdf0e10cSrcweir { 5257*cdf0e10cSrcweir // docking rectangle is in the "sensible area" 5258*cdf0e10cSrcweir Point aPos = aDockingRect.TopLeft(); 5259*cdf0e10cSrcweir Point aInPosTL( aPos.X()-aInRect.Left(), aPos.Y()-aInRect.Top() ); 5260*cdf0e10cSrcweir Point aInPosBR( aPos.X()-aInRect.Left() + aDockingRect.GetWidth(), aPos.Y()-aInRect.Top() + aDockingRect.GetHeight() ); 5261*cdf0e10cSrcweir Size aInSize = aInRect.GetSize(); 5262*cdf0e10cSrcweir 5263*cdf0e10cSrcweir if ( aInPosTL.X() <= 0 ) 5264*cdf0e10cSrcweir meDockAlign = WINDOWALIGN_LEFT; 5265*cdf0e10cSrcweir else if ( aInPosTL.Y() <= 0) 5266*cdf0e10cSrcweir meDockAlign = WINDOWALIGN_TOP; 5267*cdf0e10cSrcweir else if ( aInPosBR.X() >= aInSize.Width() ) 5268*cdf0e10cSrcweir meDockAlign = WINDOWALIGN_RIGHT; 5269*cdf0e10cSrcweir else if ( aInPosBR.Y() >= aInSize.Height() ) 5270*cdf0e10cSrcweir meDockAlign = WINDOWALIGN_BOTTOM; 5271*cdf0e10cSrcweir 5272*cdf0e10cSrcweir // Wenn sich Dock-Align geaendert hat, muessen wir die 5273*cdf0e10cSrcweir // neue Dock-Groesse setzen 5274*cdf0e10cSrcweir if ( (meDockAlign == WINDOWALIGN_TOP) || (meDockAlign == WINDOWALIGN_BOTTOM) ) 5275*cdf0e10cSrcweir aDockSize.Width() = maInDockRect.GetWidth(); 5276*cdf0e10cSrcweir else 5277*cdf0e10cSrcweir aDockSize.Height() = maInDockRect.GetHeight(); 5278*cdf0e10cSrcweir 5279*cdf0e10cSrcweir aDockingRect.SetSize( aDockSize ); 5280*cdf0e10cSrcweir 5281*cdf0e10cSrcweir Point aPosTL( maInDockRect.TopLeft() ); 5282*cdf0e10cSrcweir switch ( meDockAlign ) 5283*cdf0e10cSrcweir { 5284*cdf0e10cSrcweir case WINDOWALIGN_TOP : 5285*cdf0e10cSrcweir aDockingRect.SetPos( aPosTL ); 5286*cdf0e10cSrcweir break; 5287*cdf0e10cSrcweir case WINDOWALIGN_LEFT : 5288*cdf0e10cSrcweir aDockingRect.SetPos( aPosTL ); 5289*cdf0e10cSrcweir break; 5290*cdf0e10cSrcweir case WINDOWALIGN_BOTTOM : 5291*cdf0e10cSrcweir { 5292*cdf0e10cSrcweir Point aPosBL( maInDockRect.BottomLeft() ); 5293*cdf0e10cSrcweir aPosBL.Y() -= aDockingRect.GetHeight(); 5294*cdf0e10cSrcweir aDockingRect.SetPos( aPosBL ); 5295*cdf0e10cSrcweir break; 5296*cdf0e10cSrcweir } 5297*cdf0e10cSrcweir case WINDOWALIGN_RIGHT : 5298*cdf0e10cSrcweir { 5299*cdf0e10cSrcweir Point aPosTR( maInDockRect.TopRight() ); 5300*cdf0e10cSrcweir aPosTR.X() -= aDockingRect.GetWidth(); 5301*cdf0e10cSrcweir aDockingRect.SetPos( aPosTR ); 5302*cdf0e10cSrcweir break; 5303*cdf0e10cSrcweir } 5304*cdf0e10cSrcweir } 5305*cdf0e10cSrcweir } 5306*cdf0e10cSrcweir } 5307*cdf0e10cSrcweir else 5308*cdf0e10cSrcweir bFloatMode = sal_True; 5309*cdf0e10cSrcweir 5310*cdf0e10cSrcweir if ( bFloatMode ) 5311*cdf0e10cSrcweir { 5312*cdf0e10cSrcweir meDockAlign = meAlign; 5313*cdf0e10cSrcweir if ( !mbLastFloatMode ) 5314*cdf0e10cSrcweir { 5315*cdf0e10cSrcweir sal_uInt16 nTemp = 0; 5316*cdf0e10cSrcweir aDockingRect.SetSize( ImplCalcFloatSize( this, nTemp ) ); 5317*cdf0e10cSrcweir } 5318*cdf0e10cSrcweir } 5319*cdf0e10cSrcweir 5320*cdf0e10cSrcweir rRect = aDockingRect; 5321*cdf0e10cSrcweir mbLastFloatMode = bFloatMode; 5322*cdf0e10cSrcweir 5323*cdf0e10cSrcweir return bFloatMode; 5324*cdf0e10cSrcweir } 5325*cdf0e10cSrcweir 5326*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5327*cdf0e10cSrcweir 5328*cdf0e10cSrcweir void ToolBox::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode ) 5329*cdf0e10cSrcweir { 5330*cdf0e10cSrcweir if ( !IsDockingCanceled() ) 5331*cdf0e10cSrcweir { 5332*cdf0e10cSrcweir if ( mnLines != mnDockLines ) 5333*cdf0e10cSrcweir SetLineCount( mnDockLines ); 5334*cdf0e10cSrcweir if ( meAlign != meDockAlign ) 5335*cdf0e10cSrcweir SetAlign( meDockAlign ); 5336*cdf0e10cSrcweir } 5337*cdf0e10cSrcweir if ( bFloatMode || (bFloatMode != ImplIsFloatingMode()) ) 5338*cdf0e10cSrcweir DockingWindow::EndDocking( rRect, bFloatMode ); 5339*cdf0e10cSrcweir } 5340*cdf0e10cSrcweir 5341*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5342*cdf0e10cSrcweir 5343*cdf0e10cSrcweir void ToolBox::Resizing( Size& rSize ) 5344*cdf0e10cSrcweir { 5345*cdf0e10cSrcweir sal_uInt16 nCalcLines; 5346*cdf0e10cSrcweir sal_uInt16 nTemp; 5347*cdf0e10cSrcweir 5348*cdf0e10cSrcweir // Alle Floatinggroessen berechnen 5349*cdf0e10cSrcweir ImplCalcFloatSizes( this ); 5350*cdf0e10cSrcweir 5351*cdf0e10cSrcweir if ( !mnLastResizeDY ) 5352*cdf0e10cSrcweir mnLastResizeDY = mnDY; 5353*cdf0e10cSrcweir 5354*cdf0e10cSrcweir // Ist vertikales Resizing angesagt 5355*cdf0e10cSrcweir if ( (mnLastResizeDY != rSize.Height()) && (mnDY != rSize.Height()) ) 5356*cdf0e10cSrcweir { 5357*cdf0e10cSrcweir nCalcLines = ImplCalcLines( this, rSize.Height() ); 5358*cdf0e10cSrcweir if ( nCalcLines < 1 ) 5359*cdf0e10cSrcweir nCalcLines = 1; 5360*cdf0e10cSrcweir rSize = ImplCalcFloatSize( this, nCalcLines ); 5361*cdf0e10cSrcweir } 5362*cdf0e10cSrcweir else 5363*cdf0e10cSrcweir { 5364*cdf0e10cSrcweir nCalcLines = 1; 5365*cdf0e10cSrcweir nTemp = nCalcLines; 5366*cdf0e10cSrcweir Size aTempSize = ImplCalcFloatSize( this, nTemp ); 5367*cdf0e10cSrcweir while ( (aTempSize.Width() > rSize.Width()) && 5368*cdf0e10cSrcweir (nCalcLines <= mpFloatSizeAry->mpSize[0].mnLines) ) 5369*cdf0e10cSrcweir { 5370*cdf0e10cSrcweir nCalcLines++; 5371*cdf0e10cSrcweir nTemp = nCalcLines; 5372*cdf0e10cSrcweir aTempSize = ImplCalcFloatSize( this, nTemp ); 5373*cdf0e10cSrcweir } 5374*cdf0e10cSrcweir rSize = aTempSize; 5375*cdf0e10cSrcweir } 5376*cdf0e10cSrcweir 5377*cdf0e10cSrcweir mnLastResizeDY = rSize.Height(); 5378*cdf0e10cSrcweir } 5379*cdf0e10cSrcweir 5380*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5381*cdf0e10cSrcweir 5382*cdf0e10cSrcweir Size ToolBox::CalcWindowSizePixel( sal_uInt16 nCalcLines ) const 5383*cdf0e10cSrcweir { 5384*cdf0e10cSrcweir return ImplCalcSize( this, nCalcLines ); 5385*cdf0e10cSrcweir } 5386*cdf0e10cSrcweir 5387*cdf0e10cSrcweir Size ToolBox::CalcWindowSizePixel( sal_uInt16 nCalcLines, WindowAlign eAlign ) const 5388*cdf0e10cSrcweir { 5389*cdf0e10cSrcweir return ImplCalcSize( this, nCalcLines, 5390*cdf0e10cSrcweir (eAlign == WINDOWALIGN_TOP || eAlign == WINDOWALIGN_BOTTOM) ? TB_CALCMODE_HORZ : TB_CALCMODE_VERT ); 5391*cdf0e10cSrcweir } 5392*cdf0e10cSrcweir 5393*cdf0e10cSrcweir sal_uInt16 ToolBox::ImplCountLineBreaks( const ToolBox *pThis ) 5394*cdf0e10cSrcweir { 5395*cdf0e10cSrcweir sal_uInt16 nLines = 0; 5396*cdf0e10cSrcweir 5397*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = ((ToolBox*)pThis)->mpData->m_aItems.begin(); 5398*cdf0e10cSrcweir while ( it != ((ToolBox*)pThis)->mpData->m_aItems.end() ) 5399*cdf0e10cSrcweir { 5400*cdf0e10cSrcweir if( it->meType == TOOLBOXITEM_BREAK ) 5401*cdf0e10cSrcweir nLines++; 5402*cdf0e10cSrcweir it++; 5403*cdf0e10cSrcweir } 5404*cdf0e10cSrcweir return nLines; 5405*cdf0e10cSrcweir } 5406*cdf0e10cSrcweir 5407*cdf0e10cSrcweir Size ToolBox::CalcPopupWindowSizePixel() const 5408*cdf0e10cSrcweir { 5409*cdf0e10cSrcweir // count number of breaks and calc corresponding floating window size 5410*cdf0e10cSrcweir sal_uInt16 nLines = ImplCountLineBreaks( this ); 5411*cdf0e10cSrcweir 5412*cdf0e10cSrcweir if( nLines ) 5413*cdf0e10cSrcweir nLines++; // add the first line 5414*cdf0e10cSrcweir else 5415*cdf0e10cSrcweir { 5416*cdf0e10cSrcweir // no breaks found: use quadratic layout 5417*cdf0e10cSrcweir nLines = (sal_uInt16) ceil( sqrt( (double) GetItemCount() ) ); 5418*cdf0e10cSrcweir } 5419*cdf0e10cSrcweir 5420*cdf0e10cSrcweir sal_Bool bPopup = mpData->mbAssumePopupMode; 5421*cdf0e10cSrcweir ToolBox *pThis = (ToolBox*) this; 5422*cdf0e10cSrcweir pThis->mpData->mbAssumePopupMode = sal_True; 5423*cdf0e10cSrcweir 5424*cdf0e10cSrcweir Size aSize = CalcFloatingWindowSizePixel( nLines ); 5425*cdf0e10cSrcweir 5426*cdf0e10cSrcweir pThis->mpData->mbAssumePopupMode = bPopup; 5427*cdf0e10cSrcweir return aSize; 5428*cdf0e10cSrcweir } 5429*cdf0e10cSrcweir 5430*cdf0e10cSrcweir Size ToolBox::CalcFloatingWindowSizePixel() const 5431*cdf0e10cSrcweir { 5432*cdf0e10cSrcweir sal_uInt16 nLines = ImplCountLineBreaks( this ); 5433*cdf0e10cSrcweir nLines++; // add the first line 5434*cdf0e10cSrcweir return CalcFloatingWindowSizePixel( nLines ); 5435*cdf0e10cSrcweir } 5436*cdf0e10cSrcweir 5437*cdf0e10cSrcweir Size ToolBox::CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines ) const 5438*cdf0e10cSrcweir { 5439*cdf0e10cSrcweir sal_Bool bFloat = mpData->mbAssumeFloating; 5440*cdf0e10cSrcweir sal_Bool bDocking = mpData->mbAssumeDocked; 5441*cdf0e10cSrcweir 5442*cdf0e10cSrcweir // simulate floating mode and force reformat before calculating 5443*cdf0e10cSrcweir ToolBox *pThis = (ToolBox*) this; 5444*cdf0e10cSrcweir pThis->mpData->mbAssumeFloating = sal_True; 5445*cdf0e10cSrcweir pThis->mpData->mbAssumeDocked = sal_False; 5446*cdf0e10cSrcweir 5447*cdf0e10cSrcweir Size aSize = ImplCalcFloatSize( (ToolBox*) this, nCalcLines ); 5448*cdf0e10cSrcweir 5449*cdf0e10cSrcweir pThis->mbFormat = sal_True; 5450*cdf0e10cSrcweir pThis->mpData->mbAssumeFloating = bFloat; 5451*cdf0e10cSrcweir pThis->mpData->mbAssumeDocked = bDocking; 5452*cdf0e10cSrcweir 5453*cdf0e10cSrcweir return aSize; 5454*cdf0e10cSrcweir } 5455*cdf0e10cSrcweir 5456*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5457*cdf0e10cSrcweir 5458*cdf0e10cSrcweir Size ToolBox::CalcMinimumWindowSizePixel() const 5459*cdf0e10cSrcweir { 5460*cdf0e10cSrcweir if( ImplIsFloatingMode() ) 5461*cdf0e10cSrcweir return ImplCalcSize( this, mnFloatLines ); 5462*cdf0e10cSrcweir else 5463*cdf0e10cSrcweir { 5464*cdf0e10cSrcweir // create dummy toolbox for measurements 5465*cdf0e10cSrcweir ToolBox *pToolBox = new ToolBox( GetParent(), GetStyle() ); 5466*cdf0e10cSrcweir 5467*cdf0e10cSrcweir // copy until first useful item 5468*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin(); 5469*cdf0e10cSrcweir while( it != mpData->m_aItems.end() ) 5470*cdf0e10cSrcweir { 5471*cdf0e10cSrcweir pToolBox->CopyItem( *this, it->mnId ); 5472*cdf0e10cSrcweir if( (it->meType != TOOLBOXITEM_BUTTON) || 5473*cdf0e10cSrcweir !it->mbVisible || ImplIsFixedControl( &(*it) ) ) 5474*cdf0e10cSrcweir it++; 5475*cdf0e10cSrcweir else 5476*cdf0e10cSrcweir break; 5477*cdf0e10cSrcweir } 5478*cdf0e10cSrcweir 5479*cdf0e10cSrcweir // add to docking manager if required to obtain a drag area 5480*cdf0e10cSrcweir // (which is accounted for in calcwindowsizepixel) 5481*cdf0e10cSrcweir if( ImplGetDockingManager()->GetDockingWindowWrapper( this ) ) 5482*cdf0e10cSrcweir ImplGetDockingManager()->AddWindow( pToolBox ); 5483*cdf0e10cSrcweir 5484*cdf0e10cSrcweir // account for menu 5485*cdf0e10cSrcweir if( IsMenuEnabled() ) 5486*cdf0e10cSrcweir pToolBox->SetMenuType( GetMenuType() ); 5487*cdf0e10cSrcweir 5488*cdf0e10cSrcweir pToolBox->SetAlign( GetAlign() ); 5489*cdf0e10cSrcweir Size aSize = pToolBox->CalcWindowSizePixel( 1 ); 5490*cdf0e10cSrcweir 5491*cdf0e10cSrcweir ImplGetDockingManager()->RemoveWindow( pToolBox ); 5492*cdf0e10cSrcweir pToolBox->Clear(); 5493*cdf0e10cSrcweir delete pToolBox; 5494*cdf0e10cSrcweir 5495*cdf0e10cSrcweir return aSize; 5496*cdf0e10cSrcweir } 5497*cdf0e10cSrcweir } 5498*cdf0e10cSrcweir 5499*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5500*cdf0e10cSrcweir 5501*cdf0e10cSrcweir void ToolBox::EnableCustomize( sal_Bool bEnable ) 5502*cdf0e10cSrcweir { 5503*cdf0e10cSrcweir if ( bEnable != mbCustomize ) 5504*cdf0e10cSrcweir { 5505*cdf0e10cSrcweir mbCustomize = bEnable; 5506*cdf0e10cSrcweir 5507*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 5508*cdf0e10cSrcweir if ( bEnable ) 5509*cdf0e10cSrcweir pMgr->Insert( this ); 5510*cdf0e10cSrcweir else 5511*cdf0e10cSrcweir pMgr->Remove( this ); 5512*cdf0e10cSrcweir } 5513*cdf0e10cSrcweir } 5514*cdf0e10cSrcweir 5515*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5516*cdf0e10cSrcweir 5517*cdf0e10cSrcweir void ToolBox::StartCustomize( const Rectangle& rRect, void* pData ) 5518*cdf0e10cSrcweir { 5519*cdf0e10cSrcweir DBG_ASSERT( mbCustomize, 5520*cdf0e10cSrcweir "ToolBox::StartCustomize(): ToolBox must be customized" ); 5521*cdf0e10cSrcweir 5522*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 5523*cdf0e10cSrcweir Point aMousePos = GetPointerPosPixel(); 5524*cdf0e10cSrcweir Point aPos = ScreenToOutputPixel( rRect.TopLeft() ); 5525*cdf0e10cSrcweir Rectangle aRect( aPos.X(), aPos.Y(), 5526*cdf0e10cSrcweir aPos.X()+rRect.GetWidth()+SMALLBUTTON_HSIZE, 5527*cdf0e10cSrcweir aPos.Y()+rRect.GetHeight()+SMALLBUTTON_VSIZE ); 5528*cdf0e10cSrcweir aMousePos = ScreenToOutputPixel( aPos ); 5529*cdf0e10cSrcweir Pointer aPtr; 5530*cdf0e10cSrcweir SetPointer( aPtr ); 5531*cdf0e10cSrcweir pMgr->StartDragging( this, aMousePos, aRect, 0, sal_False, pData ); 5532*cdf0e10cSrcweir } 5533*cdf0e10cSrcweir 5534*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5535*cdf0e10cSrcweir 5536*cdf0e10cSrcweir void ToolBox::StartCustomizeMode() 5537*cdf0e10cSrcweir { 5538*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 5539*cdf0e10cSrcweir pMgr->StartCustomizeMode(); 5540*cdf0e10cSrcweir } 5541*cdf0e10cSrcweir 5542*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5543*cdf0e10cSrcweir 5544*cdf0e10cSrcweir void ToolBox::EndCustomizeMode() 5545*cdf0e10cSrcweir { 5546*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 5547*cdf0e10cSrcweir pMgr->EndCustomizeMode(); 5548*cdf0e10cSrcweir } 5549*cdf0e10cSrcweir 5550*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5551*cdf0e10cSrcweir 5552*cdf0e10cSrcweir sal_Bool ToolBox::IsCustomizeMode() 5553*cdf0e10cSrcweir { 5554*cdf0e10cSrcweir ImplTBDragMgr* pMgr = ImplGetTBDragMgr(); 5555*cdf0e10cSrcweir return pMgr->IsCustomizeMode(); 5556*cdf0e10cSrcweir } 5557*cdf0e10cSrcweir 5558*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5559*cdf0e10cSrcweir 5560*cdf0e10cSrcweir void ToolBox::GetFocus() 5561*cdf0e10cSrcweir { 5562*cdf0e10cSrcweir DockingWindow::GetFocus(); 5563*cdf0e10cSrcweir } 5564*cdf0e10cSrcweir 5565*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5566*cdf0e10cSrcweir 5567*cdf0e10cSrcweir void ToolBox::LoseFocus() 5568*cdf0e10cSrcweir { 5569*cdf0e10cSrcweir ImplChangeHighlight( NULL, sal_True ); 5570*cdf0e10cSrcweir 5571*cdf0e10cSrcweir DockingWindow::LoseFocus(); 5572*cdf0e10cSrcweir } 5573*cdf0e10cSrcweir 5574*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5575*cdf0e10cSrcweir 5576*cdf0e10cSrcweir // performs the action associated with an item, ie simulates clicking the item 5577*cdf0e10cSrcweir void ToolBox::TriggerItem( sal_uInt16 nItemId, sal_Bool bShift, sal_Bool bCtrl ) 5578*cdf0e10cSrcweir { 5579*cdf0e10cSrcweir mnHighItemId = nItemId; 5580*cdf0e10cSrcweir sal_uInt16 nModifier = 0; 5581*cdf0e10cSrcweir if( bShift ) 5582*cdf0e10cSrcweir nModifier |= KEY_SHIFT; 5583*cdf0e10cSrcweir if( bCtrl ) 5584*cdf0e10cSrcweir nModifier |= KEY_MOD1; 5585*cdf0e10cSrcweir KeyCode aKeyCode( 0, nModifier ); 5586*cdf0e10cSrcweir ImplActivateItem( aKeyCode ); 5587*cdf0e10cSrcweir } 5588*cdf0e10cSrcweir 5589*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5590*cdf0e10cSrcweir 5591*cdf0e10cSrcweir // calls the button's action handler 5592*cdf0e10cSrcweir // returns sal_True if action was called 5593*cdf0e10cSrcweir sal_Bool ToolBox::ImplActivateItem( KeyCode aKeyCode ) 5594*cdf0e10cSrcweir { 5595*cdf0e10cSrcweir sal_Bool bRet = sal_True; 5596*cdf0e10cSrcweir if( mnHighItemId ) 5597*cdf0e10cSrcweir { 5598*cdf0e10cSrcweir ImplToolItem *pToolItem = ImplGetItem( mnHighItemId ); 5599*cdf0e10cSrcweir 5600*cdf0e10cSrcweir // #107712#, activate can also be called for disabled entries 5601*cdf0e10cSrcweir if( pToolItem && !pToolItem->mbEnabled ) 5602*cdf0e10cSrcweir return sal_True; 5603*cdf0e10cSrcweir 5604*cdf0e10cSrcweir if( pToolItem && pToolItem->mpWindow && HasFocus() ) 5605*cdf0e10cSrcweir { 5606*cdf0e10cSrcweir ImplHideFocus(); 5607*cdf0e10cSrcweir mbChangingHighlight = sal_True; // avoid focus change due to loose focus 5608*cdf0e10cSrcweir pToolItem->mpWindow->ImplControlFocus( GETFOCUS_TAB ); 5609*cdf0e10cSrcweir mbChangingHighlight = sal_False; 5610*cdf0e10cSrcweir } 5611*cdf0e10cSrcweir else 5612*cdf0e10cSrcweir { 5613*cdf0e10cSrcweir mnDownItemId = mnCurItemId = mnHighItemId; 5614*cdf0e10cSrcweir ImplToolItem* pItem = ImplGetItem( mnHighItemId ); 5615*cdf0e10cSrcweir if ( pItem->mnBits & TIB_AUTOCHECK ) 5616*cdf0e10cSrcweir { 5617*cdf0e10cSrcweir if ( pItem->mnBits & TIB_RADIOCHECK ) 5618*cdf0e10cSrcweir { 5619*cdf0e10cSrcweir if ( pItem->meState != STATE_CHECK ) 5620*cdf0e10cSrcweir SetItemState( pItem->mnId, STATE_CHECK ); 5621*cdf0e10cSrcweir } 5622*cdf0e10cSrcweir else 5623*cdf0e10cSrcweir { 5624*cdf0e10cSrcweir if ( pItem->meState != STATE_CHECK ) 5625*cdf0e10cSrcweir pItem->meState = STATE_CHECK; 5626*cdf0e10cSrcweir else 5627*cdf0e10cSrcweir pItem->meState = STATE_NOCHECK; 5628*cdf0e10cSrcweir } 5629*cdf0e10cSrcweir } 5630*cdf0e10cSrcweir mnMouseModifier = aKeyCode.GetModifier(); 5631*cdf0e10cSrcweir mbIsKeyEvent = sal_True; 5632*cdf0e10cSrcweir Activate(); 5633*cdf0e10cSrcweir Click(); 5634*cdf0e10cSrcweir 5635*cdf0e10cSrcweir // #107776# we might be destroyed in the selecthandler 5636*cdf0e10cSrcweir ImplDelData aDelData; 5637*cdf0e10cSrcweir ImplAddDel( &aDelData ); 5638*cdf0e10cSrcweir Select(); 5639*cdf0e10cSrcweir if ( aDelData.IsDelete() ) 5640*cdf0e10cSrcweir return bRet; 5641*cdf0e10cSrcweir ImplRemoveDel( &aDelData ); 5642*cdf0e10cSrcweir 5643*cdf0e10cSrcweir Deactivate(); 5644*cdf0e10cSrcweir mbIsKeyEvent = sal_False; 5645*cdf0e10cSrcweir mnMouseModifier = 0; 5646*cdf0e10cSrcweir } 5647*cdf0e10cSrcweir } 5648*cdf0e10cSrcweir else 5649*cdf0e10cSrcweir bRet = sal_False; 5650*cdf0e10cSrcweir return bRet; 5651*cdf0e10cSrcweir } 5652*cdf0e10cSrcweir 5653*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5654*cdf0e10cSrcweir 5655*cdf0e10cSrcweir sal_Bool ImplCloseLastPopup( Window *pParent ) 5656*cdf0e10cSrcweir { 5657*cdf0e10cSrcweir // close last popup toolbox (see also: 5658*cdf0e10cSrcweir // ImplHandleMouseFloatMode(...) in winproc.cxx ) 5659*cdf0e10cSrcweir 5660*cdf0e10cSrcweir if( ImplGetSVData()->maWinData.mpFirstFloat ) 5661*cdf0e10cSrcweir { 5662*cdf0e10cSrcweir FloatingWindow* pLastLevelFloat = ImplGetSVData()->maWinData.mpFirstFloat->ImplFindLastLevelFloat(); 5663*cdf0e10cSrcweir // only close the floater if it is not our direct parent, which would kill ourself 5664*cdf0e10cSrcweir if( pLastLevelFloat && pLastLevelFloat != pParent ) 5665*cdf0e10cSrcweir { 5666*cdf0e10cSrcweir pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL ); 5667*cdf0e10cSrcweir return sal_True; 5668*cdf0e10cSrcweir } 5669*cdf0e10cSrcweir } 5670*cdf0e10cSrcweir return sal_False; 5671*cdf0e10cSrcweir } 5672*cdf0e10cSrcweir 5673*cdf0e10cSrcweir // opens a drop down toolbox item 5674*cdf0e10cSrcweir // returns sal_True if item was opened 5675*cdf0e10cSrcweir sal_Bool ToolBox::ImplOpenItem( KeyCode aKeyCode ) 5676*cdf0e10cSrcweir { 5677*cdf0e10cSrcweir sal_uInt16 nCode = aKeyCode.GetCode(); 5678*cdf0e10cSrcweir sal_Bool bRet = sal_True; 5679*cdf0e10cSrcweir 5680*cdf0e10cSrcweir // arrow keys should work only in the opposite direction of alignment (to not break cursor travelling) 5681*cdf0e10cSrcweir if ( ((nCode == KEY_LEFT || nCode == KEY_RIGHT) && IsHorizontal()) 5682*cdf0e10cSrcweir || ((nCode == KEY_UP || nCode == KEY_DOWN) && !IsHorizontal()) ) 5683*cdf0e10cSrcweir return sal_False; 5684*cdf0e10cSrcweir 5685*cdf0e10cSrcweir if( IsMenuEnabled() && mpData->mbMenubuttonSelected ) 5686*cdf0e10cSrcweir { 5687*cdf0e10cSrcweir if( ImplCloseLastPopup( GetParent() ) ) 5688*cdf0e10cSrcweir return bRet; 5689*cdf0e10cSrcweir 5690*cdf0e10cSrcweir ImplUpdateCustomMenu(); 5691*cdf0e10cSrcweir Application::PostUserEvent( mpData->mnEventId, LINK( this, ToolBox, ImplCallExecuteCustomMenu ) ); 5692*cdf0e10cSrcweir } 5693*cdf0e10cSrcweir else if( mnHighItemId && ImplGetItem( mnHighItemId ) && 5694*cdf0e10cSrcweir (ImplGetItem( mnHighItemId )->mnBits & TIB_DROPDOWN) ) 5695*cdf0e10cSrcweir { 5696*cdf0e10cSrcweir if( ImplCloseLastPopup( GetParent() ) ) 5697*cdf0e10cSrcweir return bRet; 5698*cdf0e10cSrcweir 5699*cdf0e10cSrcweir mnDownItemId = mnCurItemId = mnHighItemId; 5700*cdf0e10cSrcweir mnCurPos = GetItemPos( mnCurItemId ); 5701*cdf0e10cSrcweir mnLastFocusItemId = mnCurItemId; // save item id for possible later focus restore 5702*cdf0e10cSrcweir mnMouseModifier = aKeyCode.GetModifier(); 5703*cdf0e10cSrcweir mbIsShift = sal_True; 5704*cdf0e10cSrcweir mbIsKeyEvent = sal_True; 5705*cdf0e10cSrcweir Activate(); 5706*cdf0e10cSrcweir 5707*cdf0e10cSrcweir mpData->mbDropDownByKeyboard = sal_True; 5708*cdf0e10cSrcweir GetDropdownClickHdl().Call( this ); 5709*cdf0e10cSrcweir 5710*cdf0e10cSrcweir mbIsKeyEvent = sal_False; 5711*cdf0e10cSrcweir mbIsShift = sal_False; 5712*cdf0e10cSrcweir mnMouseModifier = 0; 5713*cdf0e10cSrcweir } 5714*cdf0e10cSrcweir else 5715*cdf0e10cSrcweir bRet = sal_False; 5716*cdf0e10cSrcweir 5717*cdf0e10cSrcweir return bRet; 5718*cdf0e10cSrcweir } 5719*cdf0e10cSrcweir 5720*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5721*cdf0e10cSrcweir 5722*cdf0e10cSrcweir void ToolBox::KeyInput( const KeyEvent& rKEvt ) 5723*cdf0e10cSrcweir { 5724*cdf0e10cSrcweir KeyCode aKeyCode = rKEvt.GetKeyCode(); 5725*cdf0e10cSrcweir mnKeyModifier = aKeyCode.GetModifier(); 5726*cdf0e10cSrcweir sal_uInt16 nCode = aKeyCode.GetCode(); 5727*cdf0e10cSrcweir sal_Bool bParentIsDialog = ( ( ImplGetParent()->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL) ) == WB_DIALOGCONTROL ); 5728*cdf0e10cSrcweir sal_Bool bForwardKey = sal_False; 5729*cdf0e10cSrcweir sal_Bool bGrabFocusToDocument = sal_False; 5730*cdf0e10cSrcweir 5731*cdf0e10cSrcweir // #107776# we might be destroyed in the keyhandler 5732*cdf0e10cSrcweir ImplDelData aDelData; 5733*cdf0e10cSrcweir ImplAddDel( &aDelData ); 5734*cdf0e10cSrcweir 5735*cdf0e10cSrcweir switch ( nCode ) 5736*cdf0e10cSrcweir { 5737*cdf0e10cSrcweir case KEY_UP: 5738*cdf0e10cSrcweir { 5739*cdf0e10cSrcweir // Ctrl-Cursor activates next toolbox, indicated by a blue arrow pointing to the left/up 5740*cdf0e10cSrcweir if( aKeyCode.GetModifier() ) // allow only pure cursor keys 5741*cdf0e10cSrcweir break; 5742*cdf0e10cSrcweir if( !IsHorizontal() ) 5743*cdf0e10cSrcweir ImplChangeHighlightUpDn( sal_True ); 5744*cdf0e10cSrcweir else 5745*cdf0e10cSrcweir ImplOpenItem( aKeyCode ); 5746*cdf0e10cSrcweir } 5747*cdf0e10cSrcweir break; 5748*cdf0e10cSrcweir case KEY_LEFT: 5749*cdf0e10cSrcweir { 5750*cdf0e10cSrcweir if( aKeyCode.GetModifier() ) // allow only pure cursor keys 5751*cdf0e10cSrcweir break; 5752*cdf0e10cSrcweir if( IsHorizontal() ) 5753*cdf0e10cSrcweir ImplChangeHighlightUpDn( sal_True ); 5754*cdf0e10cSrcweir else 5755*cdf0e10cSrcweir ImplOpenItem( aKeyCode ); 5756*cdf0e10cSrcweir } 5757*cdf0e10cSrcweir break; 5758*cdf0e10cSrcweir case KEY_DOWN: 5759*cdf0e10cSrcweir { 5760*cdf0e10cSrcweir if( aKeyCode.GetModifier() ) // allow only pure cursor keys 5761*cdf0e10cSrcweir break; 5762*cdf0e10cSrcweir if( !IsHorizontal() ) 5763*cdf0e10cSrcweir ImplChangeHighlightUpDn( sal_False ); 5764*cdf0e10cSrcweir else 5765*cdf0e10cSrcweir ImplOpenItem( aKeyCode ); 5766*cdf0e10cSrcweir } 5767*cdf0e10cSrcweir break; 5768*cdf0e10cSrcweir case KEY_RIGHT: 5769*cdf0e10cSrcweir { 5770*cdf0e10cSrcweir if( aKeyCode.GetModifier() ) // allow only pure cursor keys 5771*cdf0e10cSrcweir break; 5772*cdf0e10cSrcweir if( IsHorizontal() ) 5773*cdf0e10cSrcweir ImplChangeHighlightUpDn( sal_False ); 5774*cdf0e10cSrcweir else 5775*cdf0e10cSrcweir ImplOpenItem( aKeyCode ); 5776*cdf0e10cSrcweir } 5777*cdf0e10cSrcweir break; 5778*cdf0e10cSrcweir case KEY_PAGEUP: 5779*cdf0e10cSrcweir if ( mnCurLine > 1 ) 5780*cdf0e10cSrcweir { 5781*cdf0e10cSrcweir if( mnCurLine > mnVisLines ) 5782*cdf0e10cSrcweir mnCurLine = mnCurLine - mnVisLines; 5783*cdf0e10cSrcweir else 5784*cdf0e10cSrcweir mnCurLine = 1; 5785*cdf0e10cSrcweir mbFormat = sal_True; 5786*cdf0e10cSrcweir ImplFormat(); 5787*cdf0e10cSrcweir ImplDrawSpin( sal_False, sal_False ); 5788*cdf0e10cSrcweir ImplChangeHighlight( ImplGetFirstValidItem( mnCurLine ) ); 5789*cdf0e10cSrcweir } 5790*cdf0e10cSrcweir break; 5791*cdf0e10cSrcweir case KEY_PAGEDOWN: 5792*cdf0e10cSrcweir if ( mnCurLine+mnVisLines-1 < mnCurLines ) 5793*cdf0e10cSrcweir { 5794*cdf0e10cSrcweir if( mnCurLine + 2*mnVisLines-1 < mnCurLines ) 5795*cdf0e10cSrcweir mnCurLine = mnCurLine + mnVisLines; 5796*cdf0e10cSrcweir else 5797*cdf0e10cSrcweir mnCurLine = mnCurLines; 5798*cdf0e10cSrcweir mbFormat = sal_True; 5799*cdf0e10cSrcweir ImplFormat(); 5800*cdf0e10cSrcweir ImplDrawSpin( sal_False, sal_False ); 5801*cdf0e10cSrcweir ImplChangeHighlight( ImplGetFirstValidItem( mnCurLine ) ); 5802*cdf0e10cSrcweir } 5803*cdf0e10cSrcweir break; 5804*cdf0e10cSrcweir case KEY_END: 5805*cdf0e10cSrcweir { 5806*cdf0e10cSrcweir ImplChangeHighlight( NULL ); 5807*cdf0e10cSrcweir ImplChangeHighlightUpDn( sal_False ); 5808*cdf0e10cSrcweir } 5809*cdf0e10cSrcweir break; 5810*cdf0e10cSrcweir case KEY_HOME: 5811*cdf0e10cSrcweir { 5812*cdf0e10cSrcweir ImplChangeHighlight( NULL ); 5813*cdf0e10cSrcweir ImplChangeHighlightUpDn( sal_True ); 5814*cdf0e10cSrcweir } 5815*cdf0e10cSrcweir break; 5816*cdf0e10cSrcweir case KEY_ESCAPE: 5817*cdf0e10cSrcweir { 5818*cdf0e10cSrcweir if( !ImplIsFloatingMode() && bParentIsDialog ) 5819*cdf0e10cSrcweir DockingWindow::KeyInput( rKEvt ); 5820*cdf0e10cSrcweir else 5821*cdf0e10cSrcweir { 5822*cdf0e10cSrcweir // send focus to document pane 5823*cdf0e10cSrcweir Window *pWin = this; 5824*cdf0e10cSrcweir while( pWin ) 5825*cdf0e10cSrcweir { 5826*cdf0e10cSrcweir if( !pWin->GetParent() ) 5827*cdf0e10cSrcweir { 5828*cdf0e10cSrcweir pWin->ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->GrabFocus(); 5829*cdf0e10cSrcweir break; 5830*cdf0e10cSrcweir } 5831*cdf0e10cSrcweir pWin = pWin->GetParent(); 5832*cdf0e10cSrcweir } 5833*cdf0e10cSrcweir } 5834*cdf0e10cSrcweir } 5835*cdf0e10cSrcweir break; 5836*cdf0e10cSrcweir case KEY_RETURN: 5837*cdf0e10cSrcweir { 5838*cdf0e10cSrcweir // #107712#, disabled entries are selectable now 5839*cdf0e10cSrcweir // leave toolbox and move focus to document 5840*cdf0e10cSrcweir if( mnHighItemId ) 5841*cdf0e10cSrcweir { 5842*cdf0e10cSrcweir ImplToolItem *pItem = ImplGetItem( mnHighItemId ); 5843*cdf0e10cSrcweir if( !pItem->mbEnabled ) 5844*cdf0e10cSrcweir { 5845*cdf0e10cSrcweir Sound::Beep( SOUND_DISABLE, this ); 5846*cdf0e10cSrcweir bGrabFocusToDocument = sal_True; 5847*cdf0e10cSrcweir } 5848*cdf0e10cSrcweir } 5849*cdf0e10cSrcweir if( !bGrabFocusToDocument ) 5850*cdf0e10cSrcweir bForwardKey = !ImplActivateItem( aKeyCode ); 5851*cdf0e10cSrcweir } 5852*cdf0e10cSrcweir break; 5853*cdf0e10cSrcweir default: 5854*cdf0e10cSrcweir { 5855*cdf0e10cSrcweir sal_uInt16 aKeyGroup = aKeyCode.GetGroup(); 5856*cdf0e10cSrcweir ImplToolItem *pItem = NULL; 5857*cdf0e10cSrcweir if( mnHighItemId ) 5858*cdf0e10cSrcweir pItem = ImplGetItem( mnHighItemId ); 5859*cdf0e10cSrcweir // #i13931# forward alphanum keyinput into embedded control 5860*cdf0e10cSrcweir if( (aKeyGroup == KEYGROUP_NUM || aKeyGroup == KEYGROUP_ALPHA ) && pItem && pItem->mpWindow && pItem->mbEnabled ) 5861*cdf0e10cSrcweir { 5862*cdf0e10cSrcweir Window *pFocusWindow = Application::GetFocusWindow(); 5863*cdf0e10cSrcweir ImplHideFocus(); 5864*cdf0e10cSrcweir mbChangingHighlight = sal_True; // avoid focus change due to loose focus 5865*cdf0e10cSrcweir pItem->mpWindow->ImplControlFocus( GETFOCUS_TAB ); 5866*cdf0e10cSrcweir mbChangingHighlight = sal_False; 5867*cdf0e10cSrcweir if( pFocusWindow != Application::GetFocusWindow() ) 5868*cdf0e10cSrcweir Application::GetFocusWindow()->KeyInput( rKEvt ); 5869*cdf0e10cSrcweir } 5870*cdf0e10cSrcweir else 5871*cdf0e10cSrcweir { 5872*cdf0e10cSrcweir // do nothing to avoid key presses going into the document 5873*cdf0e10cSrcweir // while the toolbox has the focus 5874*cdf0e10cSrcweir // just forward function and special keys and combinations with Alt-key 5875*cdf0e10cSrcweir if( aKeyGroup == KEYGROUP_FKEYS || aKeyGroup == KEYGROUP_MISC || aKeyCode.IsMod2() ) 5876*cdf0e10cSrcweir bForwardKey = sal_True; 5877*cdf0e10cSrcweir } 5878*cdf0e10cSrcweir } 5879*cdf0e10cSrcweir } 5880*cdf0e10cSrcweir 5881*cdf0e10cSrcweir if ( aDelData.IsDelete() ) 5882*cdf0e10cSrcweir return; 5883*cdf0e10cSrcweir ImplRemoveDel( &aDelData ); 5884*cdf0e10cSrcweir 5885*cdf0e10cSrcweir // #107251# move focus away if this toolbox was disabled during keyinput 5886*cdf0e10cSrcweir if( HasFocus() && mpData->mbKeyInputDisabled && (ImplGetParent()->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL) ) == WB_DIALOGCONTROL) 5887*cdf0e10cSrcweir { 5888*cdf0e10cSrcweir sal_uInt16 n = 0; 5889*cdf0e10cSrcweir Window *pFocusControl = ImplGetParent()->ImplGetDlgWindow( n, DLGWINDOW_FIRST ); 5890*cdf0e10cSrcweir if ( pFocusControl && pFocusControl != this ) 5891*cdf0e10cSrcweir pFocusControl->ImplControlFocus( GETFOCUS_INIT ); 5892*cdf0e10cSrcweir } 5893*cdf0e10cSrcweir 5894*cdf0e10cSrcweir mnKeyModifier = 0; 5895*cdf0e10cSrcweir 5896*cdf0e10cSrcweir // #107712#, leave toolbox 5897*cdf0e10cSrcweir if( bGrabFocusToDocument ) 5898*cdf0e10cSrcweir { 5899*cdf0e10cSrcweir GrabFocusToDocument(); 5900*cdf0e10cSrcweir return; 5901*cdf0e10cSrcweir } 5902*cdf0e10cSrcweir 5903*cdf0e10cSrcweir if( bForwardKey ) 5904*cdf0e10cSrcweir DockingWindow::KeyInput( rKEvt ); 5905*cdf0e10cSrcweir } 5906*cdf0e10cSrcweir 5907*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5908*cdf0e10cSrcweir 5909*cdf0e10cSrcweir // returns the current toolbox line of the item 5910*cdf0e10cSrcweir sal_uInt16 ToolBox::ImplGetItemLine( ImplToolItem* pCurrentItem ) 5911*cdf0e10cSrcweir { 5912*cdf0e10cSrcweir std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin(); 5913*cdf0e10cSrcweir sal_uInt16 nLine = 1; 5914*cdf0e10cSrcweir while( it != mpData->m_aItems.end() ) 5915*cdf0e10cSrcweir { 5916*cdf0e10cSrcweir if ( it->mbBreak ) 5917*cdf0e10cSrcweir nLine++; 5918*cdf0e10cSrcweir if( &(*it) == pCurrentItem) 5919*cdf0e10cSrcweir break; 5920*cdf0e10cSrcweir ++it; 5921*cdf0e10cSrcweir } 5922*cdf0e10cSrcweir return nLine; 5923*cdf0e10cSrcweir } 5924*cdf0e10cSrcweir 5925*cdf0e10cSrcweir // returns the first displayable item in the given line 5926*cdf0e10cSrcweir ImplToolItem* ToolBox::ImplGetFirstValidItem( sal_uInt16 nLine ) 5927*cdf0e10cSrcweir { 5928*cdf0e10cSrcweir if( !nLine || nLine > mnCurLines ) 5929*cdf0e10cSrcweir return NULL; 5930*cdf0e10cSrcweir 5931*cdf0e10cSrcweir nLine--; 5932*cdf0e10cSrcweir 5933*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin(); 5934*cdf0e10cSrcweir while( it != mpData->m_aItems.end() ) 5935*cdf0e10cSrcweir { 5936*cdf0e10cSrcweir // find correct line 5937*cdf0e10cSrcweir if ( it->mbBreak ) 5938*cdf0e10cSrcweir nLine--; 5939*cdf0e10cSrcweir if( !nLine ) 5940*cdf0e10cSrcweir { 5941*cdf0e10cSrcweir // find first useful item 5942*cdf0e10cSrcweir while( it != mpData->m_aItems.end() && ((it->meType != TOOLBOXITEM_BUTTON) || 5943*cdf0e10cSrcweir /*!it->mbEnabled ||*/ !it->mbVisible || ImplIsFixedControl( &(*it) )) ) 5944*cdf0e10cSrcweir { 5945*cdf0e10cSrcweir ++it; 5946*cdf0e10cSrcweir if( it == mpData->m_aItems.end() || it->mbBreak ) 5947*cdf0e10cSrcweir return NULL; // no valid items in this line 5948*cdf0e10cSrcweir } 5949*cdf0e10cSrcweir return &(*it); 5950*cdf0e10cSrcweir } 5951*cdf0e10cSrcweir ++it; 5952*cdf0e10cSrcweir } 5953*cdf0e10cSrcweir 5954*cdf0e10cSrcweir return (it == mpData->m_aItems.end()) ? NULL : &(*it); 5955*cdf0e10cSrcweir } 5956*cdf0e10cSrcweir 5957*cdf0e10cSrcweir // returns the last displayable item in the given line 5958*cdf0e10cSrcweir ImplToolItem* ToolBox::ImplGetLastValidItem( sal_uInt16 nLine ) 5959*cdf0e10cSrcweir { 5960*cdf0e10cSrcweir if( !nLine || nLine > mnCurLines ) 5961*cdf0e10cSrcweir return NULL; 5962*cdf0e10cSrcweir 5963*cdf0e10cSrcweir nLine--; 5964*cdf0e10cSrcweir ImplToolItem *pFound = NULL; 5965*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin(); 5966*cdf0e10cSrcweir while( it != mpData->m_aItems.end() ) 5967*cdf0e10cSrcweir { 5968*cdf0e10cSrcweir // find correct line 5969*cdf0e10cSrcweir if ( it->mbBreak ) 5970*cdf0e10cSrcweir nLine--; 5971*cdf0e10cSrcweir if( !nLine ) 5972*cdf0e10cSrcweir { 5973*cdf0e10cSrcweir // find last useful item 5974*cdf0e10cSrcweir while( it != mpData->m_aItems.end() && ((it->meType == TOOLBOXITEM_BUTTON) && 5975*cdf0e10cSrcweir /*it->mbEnabled &&*/ it->mbVisible && !ImplIsFixedControl( &(*it) )) ) 5976*cdf0e10cSrcweir { 5977*cdf0e10cSrcweir pFound = &(*it); 5978*cdf0e10cSrcweir ++it; 5979*cdf0e10cSrcweir if( it == mpData->m_aItems.end() || it->mbBreak ) 5980*cdf0e10cSrcweir return pFound; // end of line: return last useful item 5981*cdf0e10cSrcweir } 5982*cdf0e10cSrcweir return pFound; 5983*cdf0e10cSrcweir } 5984*cdf0e10cSrcweir ++it; 5985*cdf0e10cSrcweir } 5986*cdf0e10cSrcweir 5987*cdf0e10cSrcweir return pFound; 5988*cdf0e10cSrcweir } 5989*cdf0e10cSrcweir 5990*cdf0e10cSrcweir // ----------------------------------------------------------------------- 5991*cdf0e10cSrcweir 5992*cdf0e10cSrcweir sal_uInt16 ToolBox::ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList ) 5993*cdf0e10cSrcweir { 5994*cdf0e10cSrcweir if( pItem ) 5995*cdf0e10cSrcweir { 5996*cdf0e10cSrcweir sal_uInt16 nPos; 5997*cdf0e10cSrcweir for( nPos = 0; nPos < rList.size(); nPos++ ) 5998*cdf0e10cSrcweir if( &rList[ nPos ] == pItem ) 5999*cdf0e10cSrcweir return nPos; 6000*cdf0e10cSrcweir } 6001*cdf0e10cSrcweir return TOOLBOX_ITEM_NOTFOUND; 6002*cdf0e10cSrcweir } 6003*cdf0e10cSrcweir 6004*cdf0e10cSrcweir void ToolBox::ChangeHighlight( sal_uInt16 nPos ) 6005*cdf0e10cSrcweir { 6006*cdf0e10cSrcweir if ( nPos < GetItemCount() ) { 6007*cdf0e10cSrcweir ImplGrabFocus( 0 ); 6008*cdf0e10cSrcweir ImplChangeHighlight ( ImplGetItem ( GetItemId ( (sal_uInt16) nPos ) ), sal_False ); 6009*cdf0e10cSrcweir } 6010*cdf0e10cSrcweir } 6011*cdf0e10cSrcweir 6012*cdf0e10cSrcweir void ToolBox::ImplChangeHighlight( ImplToolItem* pItem, sal_Bool bNoGrabFocus ) 6013*cdf0e10cSrcweir { 6014*cdf0e10cSrcweir // avoid recursion due to focus change 6015*cdf0e10cSrcweir if( mbChangingHighlight ) 6016*cdf0e10cSrcweir return; 6017*cdf0e10cSrcweir 6018*cdf0e10cSrcweir mbChangingHighlight = sal_True; 6019*cdf0e10cSrcweir 6020*cdf0e10cSrcweir ImplToolItem* pOldItem = NULL; 6021*cdf0e10cSrcweir 6022*cdf0e10cSrcweir if ( mnHighItemId ) 6023*cdf0e10cSrcweir { 6024*cdf0e10cSrcweir ImplHideFocus(); 6025*cdf0e10cSrcweir sal_uInt16 nPos = GetItemPos( mnHighItemId ); 6026*cdf0e10cSrcweir pOldItem = ImplGetItem( mnHighItemId ); 6027*cdf0e10cSrcweir // #i89962# ImplDrawItem can cause Invalidate/Update 6028*cdf0e10cSrcweir // which will in turn ImplShowFocus again 6029*cdf0e10cSrcweir // set mnHighItemId to 0 already to prevent this hen/egg problem 6030*cdf0e10cSrcweir mnHighItemId = 0; 6031*cdf0e10cSrcweir ImplDrawItem( nPos, sal_False ); 6032*cdf0e10cSrcweir ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHTOFF, reinterpret_cast< void* >( nPos ) ); 6033*cdf0e10cSrcweir } 6034*cdf0e10cSrcweir 6035*cdf0e10cSrcweir if( !bNoGrabFocus && pItem != pOldItem && pOldItem && pOldItem->mpWindow ) 6036*cdf0e10cSrcweir { 6037*cdf0e10cSrcweir // move focus into toolbox 6038*cdf0e10cSrcweir GrabFocus(); 6039*cdf0e10cSrcweir } 6040*cdf0e10cSrcweir 6041*cdf0e10cSrcweir if( pItem ) 6042*cdf0e10cSrcweir { 6043*cdf0e10cSrcweir sal_uInt16 aPos = ToolBox::ImplFindItemPos( pItem, mpData->m_aItems ); 6044*cdf0e10cSrcweir if( aPos != TOOLBOX_ITEM_NOTFOUND) 6045*cdf0e10cSrcweir { 6046*cdf0e10cSrcweir // check for line breaks 6047*cdf0e10cSrcweir sal_uInt16 nLine = ImplGetItemLine( pItem ); 6048*cdf0e10cSrcweir 6049*cdf0e10cSrcweir if( nLine >= mnCurLine + mnVisLines ) 6050*cdf0e10cSrcweir { 6051*cdf0e10cSrcweir mnCurLine = nLine - mnVisLines + 1; 6052*cdf0e10cSrcweir mbFormat = sal_True; 6053*cdf0e10cSrcweir } 6054*cdf0e10cSrcweir else if ( nLine < mnCurLine ) 6055*cdf0e10cSrcweir { 6056*cdf0e10cSrcweir mnCurLine = nLine; 6057*cdf0e10cSrcweir mbFormat = sal_True; 6058*cdf0e10cSrcweir } 6059*cdf0e10cSrcweir 6060*cdf0e10cSrcweir if( mbFormat ) 6061*cdf0e10cSrcweir { 6062*cdf0e10cSrcweir ImplFormat(); 6063*cdf0e10cSrcweir } 6064*cdf0e10cSrcweir 6065*cdf0e10cSrcweir mnHighItemId = pItem->mnId; 6066*cdf0e10cSrcweir ImplDrawItem( aPos, 2 ); // always use shadow effect (2) 6067*cdf0e10cSrcweir 6068*cdf0e10cSrcweir if( mbSelection ) 6069*cdf0e10cSrcweir mnCurPos = aPos; 6070*cdf0e10cSrcweir ImplShowFocus(); 6071*cdf0e10cSrcweir 6072*cdf0e10cSrcweir ImplCallEventListeners( VCLEVENT_TOOLBOX_HIGHLIGHT ); 6073*cdf0e10cSrcweir } 6074*cdf0e10cSrcweir } 6075*cdf0e10cSrcweir else 6076*cdf0e10cSrcweir { 6077*cdf0e10cSrcweir ImplHideFocus(); 6078*cdf0e10cSrcweir mnHighItemId = 0; 6079*cdf0e10cSrcweir mnCurPos = TOOLBOX_ITEM_NOTFOUND; 6080*cdf0e10cSrcweir } 6081*cdf0e10cSrcweir 6082*cdf0e10cSrcweir mbChangingHighlight = sal_False; 6083*cdf0e10cSrcweir } 6084*cdf0e10cSrcweir 6085*cdf0e10cSrcweir // ----------------------------------------------------------------------- 6086*cdf0e10cSrcweir 6087*cdf0e10cSrcweir // check for keyboard accessible items 6088*cdf0e10cSrcweir static sal_Bool ImplIsValidItem( const ImplToolItem* pItem, sal_Bool bNotClipped ) 6089*cdf0e10cSrcweir { 6090*cdf0e10cSrcweir sal_Bool bValid = (pItem && pItem->meType == TOOLBOXITEM_BUTTON && pItem->mbVisible && !ImplIsFixedControl( pItem )); 6091*cdf0e10cSrcweir if( bValid && bNotClipped && pItem->IsClipped() ) 6092*cdf0e10cSrcweir bValid = sal_False; 6093*cdf0e10cSrcweir return bValid; 6094*cdf0e10cSrcweir } 6095*cdf0e10cSrcweir 6096*cdf0e10cSrcweir // ----------------------------------------------------------------------- 6097*cdf0e10cSrcweir 6098*cdf0e10cSrcweir sal_Bool ToolBox::ImplChangeHighlightUpDn( sal_Bool bUp, sal_Bool bNoCycle ) 6099*cdf0e10cSrcweir { 6100*cdf0e10cSrcweir ImplToolItem* pToolItem = ImplGetItem( mnHighItemId ); 6101*cdf0e10cSrcweir 6102*cdf0e10cSrcweir if( !pToolItem || !mnHighItemId ) 6103*cdf0e10cSrcweir { 6104*cdf0e10cSrcweir // menubutton highlighted ? 6105*cdf0e10cSrcweir if( mpData->mbMenubuttonSelected ) 6106*cdf0e10cSrcweir { 6107*cdf0e10cSrcweir if( bUp ) 6108*cdf0e10cSrcweir { 6109*cdf0e10cSrcweir // select last valid non-clipped item 6110*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.end(); 6111*cdf0e10cSrcweir ImplToolItem* pItem = NULL; 6112*cdf0e10cSrcweir while( it != mpData->m_aItems.begin() ) 6113*cdf0e10cSrcweir { 6114*cdf0e10cSrcweir --it; 6115*cdf0e10cSrcweir if ( ImplIsValidItem( &(*it), sal_True ) ) 6116*cdf0e10cSrcweir { 6117*cdf0e10cSrcweir pItem = &(*it); 6118*cdf0e10cSrcweir break; 6119*cdf0e10cSrcweir } 6120*cdf0e10cSrcweir } 6121*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_False ); 6122*cdf0e10cSrcweir ImplChangeHighlight( pItem ); 6123*cdf0e10cSrcweir } 6124*cdf0e10cSrcweir else 6125*cdf0e10cSrcweir { 6126*cdf0e10cSrcweir // select first valid non-clipped item 6127*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin(); 6128*cdf0e10cSrcweir while( it != mpData->m_aItems.end() ) 6129*cdf0e10cSrcweir { 6130*cdf0e10cSrcweir if ( ImplIsValidItem( &(*it), sal_True ) ) 6131*cdf0e10cSrcweir break; 6132*cdf0e10cSrcweir ++it; 6133*cdf0e10cSrcweir } 6134*cdf0e10cSrcweir if( it != mpData->m_aItems.end() ) 6135*cdf0e10cSrcweir { 6136*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_False ); 6137*cdf0e10cSrcweir ImplChangeHighlight( &(*it) ); 6138*cdf0e10cSrcweir } 6139*cdf0e10cSrcweir } 6140*cdf0e10cSrcweir return sal_True; 6141*cdf0e10cSrcweir } 6142*cdf0e10cSrcweir 6143*cdf0e10cSrcweir if( bUp ) 6144*cdf0e10cSrcweir { 6145*cdf0e10cSrcweir // Select first valid item 6146*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin(); 6147*cdf0e10cSrcweir while( it != mpData->m_aItems.end() ) 6148*cdf0e10cSrcweir { 6149*cdf0e10cSrcweir if ( ImplIsValidItem( &(*it), sal_False ) ) 6150*cdf0e10cSrcweir break; 6151*cdf0e10cSrcweir ++it; 6152*cdf0e10cSrcweir } 6153*cdf0e10cSrcweir 6154*cdf0e10cSrcweir // select the menu button if a clipped item would be selected 6155*cdf0e10cSrcweir if( (it != mpData->m_aItems.end() && &(*it) == ImplGetFirstClippedItem( this )) && IsMenuEnabled() ) 6156*cdf0e10cSrcweir { 6157*cdf0e10cSrcweir ImplChangeHighlight( NULL ); 6158*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_True ); 6159*cdf0e10cSrcweir } 6160*cdf0e10cSrcweir else 6161*cdf0e10cSrcweir ImplChangeHighlight( (it != mpData->m_aItems.end()) ? &(*it) : NULL ); 6162*cdf0e10cSrcweir return sal_True; 6163*cdf0e10cSrcweir } 6164*cdf0e10cSrcweir else 6165*cdf0e10cSrcweir { 6166*cdf0e10cSrcweir // Select last valid item 6167*cdf0e10cSrcweir 6168*cdf0e10cSrcweir // docked toolbars have the menubutton as last item - if this button is enabled 6169*cdf0e10cSrcweir if( IsMenuEnabled() && !ImplIsFloatingMode() ) 6170*cdf0e10cSrcweir { 6171*cdf0e10cSrcweir ImplChangeHighlight( NULL ); 6172*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_True ); 6173*cdf0e10cSrcweir } 6174*cdf0e10cSrcweir else 6175*cdf0e10cSrcweir { 6176*cdf0e10cSrcweir std::vector< ImplToolItem >::iterator it = mpData->m_aItems.end(); 6177*cdf0e10cSrcweir ImplToolItem* pItem = NULL; 6178*cdf0e10cSrcweir while( it != mpData->m_aItems.begin() ) 6179*cdf0e10cSrcweir { 6180*cdf0e10cSrcweir --it; 6181*cdf0e10cSrcweir if ( ImplIsValidItem( &(*it), sal_False ) ) 6182*cdf0e10cSrcweir { 6183*cdf0e10cSrcweir pItem = &(*it); 6184*cdf0e10cSrcweir break; 6185*cdf0e10cSrcweir } 6186*cdf0e10cSrcweir } 6187*cdf0e10cSrcweir ImplChangeHighlight( pItem ); 6188*cdf0e10cSrcweir } 6189*cdf0e10cSrcweir return sal_True; 6190*cdf0e10cSrcweir } 6191*cdf0e10cSrcweir } 6192*cdf0e10cSrcweir 6193*cdf0e10cSrcweir if( pToolItem ) 6194*cdf0e10cSrcweir { 6195*cdf0e10cSrcweir sal_uLong pos = ToolBox::ImplFindItemPos( pToolItem, mpData->m_aItems ); 6196*cdf0e10cSrcweir sal_uLong nCount = mpData->m_aItems.size(); 6197*cdf0e10cSrcweir 6198*cdf0e10cSrcweir sal_uLong i=0; 6199*cdf0e10cSrcweir do 6200*cdf0e10cSrcweir { 6201*cdf0e10cSrcweir if( bUp ) 6202*cdf0e10cSrcweir { 6203*cdf0e10cSrcweir if( !pos-- ) 6204*cdf0e10cSrcweir { 6205*cdf0e10cSrcweir if( bNoCycle ) 6206*cdf0e10cSrcweir return sal_False; 6207*cdf0e10cSrcweir 6208*cdf0e10cSrcweir // highlight the menu button if it is the last item 6209*cdf0e10cSrcweir if( IsMenuEnabled() && !ImplIsFloatingMode() ) 6210*cdf0e10cSrcweir { 6211*cdf0e10cSrcweir ImplChangeHighlight( NULL ); 6212*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_True ); 6213*cdf0e10cSrcweir return sal_True; 6214*cdf0e10cSrcweir } 6215*cdf0e10cSrcweir else 6216*cdf0e10cSrcweir pos = nCount-1; 6217*cdf0e10cSrcweir } 6218*cdf0e10cSrcweir } 6219*cdf0e10cSrcweir else 6220*cdf0e10cSrcweir { 6221*cdf0e10cSrcweir if( ++pos >= nCount ) 6222*cdf0e10cSrcweir { 6223*cdf0e10cSrcweir if( bNoCycle ) 6224*cdf0e10cSrcweir return sal_False; 6225*cdf0e10cSrcweir 6226*cdf0e10cSrcweir // highlight the menu button if it is the last item 6227*cdf0e10cSrcweir if( IsMenuEnabled() && !ImplIsFloatingMode() ) 6228*cdf0e10cSrcweir { 6229*cdf0e10cSrcweir ImplChangeHighlight( NULL ); 6230*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_True ); 6231*cdf0e10cSrcweir return sal_True; 6232*cdf0e10cSrcweir } 6233*cdf0e10cSrcweir else 6234*cdf0e10cSrcweir pos = 0; 6235*cdf0e10cSrcweir } 6236*cdf0e10cSrcweir } 6237*cdf0e10cSrcweir 6238*cdf0e10cSrcweir pToolItem = &mpData->m_aItems[pos]; 6239*cdf0e10cSrcweir 6240*cdf0e10cSrcweir if ( ImplIsValidItem( pToolItem, sal_False ) ) 6241*cdf0e10cSrcweir break; 6242*cdf0e10cSrcweir 6243*cdf0e10cSrcweir } while( ++i < nCount); 6244*cdf0e10cSrcweir 6245*cdf0e10cSrcweir if( pToolItem->IsClipped() && IsMenuEnabled() ) 6246*cdf0e10cSrcweir { 6247*cdf0e10cSrcweir // select the menu button if a clipped item would be selected 6248*cdf0e10cSrcweir ImplChangeHighlight( NULL ); 6249*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_True ); 6250*cdf0e10cSrcweir } 6251*cdf0e10cSrcweir else if( i != nCount ) 6252*cdf0e10cSrcweir ImplChangeHighlight( pToolItem ); 6253*cdf0e10cSrcweir else 6254*cdf0e10cSrcweir return sal_False; 6255*cdf0e10cSrcweir } 6256*cdf0e10cSrcweir return sal_True; 6257*cdf0e10cSrcweir } 6258*cdf0e10cSrcweir 6259*cdf0e10cSrcweir // ----------------------------------------------------------------------- 6260*cdf0e10cSrcweir 6261*cdf0e10cSrcweir void ToolBox::ImplShowFocus() 6262*cdf0e10cSrcweir { 6263*cdf0e10cSrcweir if( mnHighItemId && HasFocus() ) 6264*cdf0e10cSrcweir { 6265*cdf0e10cSrcweir ImplToolItem* pItem = ImplGetItem( mnHighItemId ); 6266*cdf0e10cSrcweir if( pItem->mpWindow ) 6267*cdf0e10cSrcweir { 6268*cdf0e10cSrcweir Window *pWin = pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow ? pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow : pItem->mpWindow; 6269*cdf0e10cSrcweir pWin->ImplGetWindowImpl()->mbDrawSelectionBackground = sal_True; 6270*cdf0e10cSrcweir pWin->Invalidate( 0 ); 6271*cdf0e10cSrcweir } 6272*cdf0e10cSrcweir } 6273*cdf0e10cSrcweir } 6274*cdf0e10cSrcweir 6275*cdf0e10cSrcweir // ----------------------------------------------------------------------- 6276*cdf0e10cSrcweir 6277*cdf0e10cSrcweir void ToolBox::ImplHideFocus() 6278*cdf0e10cSrcweir { 6279*cdf0e10cSrcweir if( mnHighItemId ) 6280*cdf0e10cSrcweir { 6281*cdf0e10cSrcweir ImplToolItem* pItem = ImplGetItem( mnHighItemId ); 6282*cdf0e10cSrcweir if( pItem->mpWindow ) 6283*cdf0e10cSrcweir { 6284*cdf0e10cSrcweir Window *pWin = pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow ? pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow : pItem->mpWindow; 6285*cdf0e10cSrcweir pWin->ImplGetWindowImpl()->mbDrawSelectionBackground = sal_False; 6286*cdf0e10cSrcweir pWin->Invalidate( 0 ); 6287*cdf0e10cSrcweir } 6288*cdf0e10cSrcweir } 6289*cdf0e10cSrcweir 6290*cdf0e10cSrcweir if ( mpData->mbMenubuttonSelected ) 6291*cdf0e10cSrcweir { 6292*cdf0e10cSrcweir // remove highlight from menubutton 6293*cdf0e10cSrcweir ImplDrawMenubutton( this, sal_False ); 6294*cdf0e10cSrcweir } 6295*cdf0e10cSrcweir } 6296*cdf0e10cSrcweir 6297*cdf0e10cSrcweir // ----------------------------------------------------------------------- 6298*cdf0e10cSrcweir 6299*cdf0e10cSrcweir void ToolBox::ImplDisableFlatButtons() 6300*cdf0e10cSrcweir { 6301*cdf0e10cSrcweir #ifdef WNT // Check in the Windows registry if an AT tool wants no flat toolboxes 6302*cdf0e10cSrcweir static bool bInit = false, bValue = false; 6303*cdf0e10cSrcweir if( ! bInit ) 6304*cdf0e10cSrcweir { 6305*cdf0e10cSrcweir bInit = true; 6306*cdf0e10cSrcweir HKEY hkey; 6307*cdf0e10cSrcweir 6308*cdf0e10cSrcweir if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, 6309*cdf0e10cSrcweir "Software\\OpenOffice.org\\Accessibility\\AtToolSupport", 6310*cdf0e10cSrcweir &hkey) ) 6311*cdf0e10cSrcweir { 6312*cdf0e10cSrcweir DWORD dwType = 0; 6313*cdf0e10cSrcweir sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD 6314*cdf0e10cSrcweir DWORD cbData = sizeof(Data); 6315*cdf0e10cSrcweir 6316*cdf0e10cSrcweir if( ERROR_SUCCESS == RegQueryValueEx(hkey, "DisableFlatToolboxButtons", 6317*cdf0e10cSrcweir NULL, &dwType, Data, &cbData) ) 6318*cdf0e10cSrcweir { 6319*cdf0e10cSrcweir switch (dwType) 6320*cdf0e10cSrcweir { 6321*cdf0e10cSrcweir case REG_SZ: 6322*cdf0e10cSrcweir bValue = ((0 == stricmp((const char *) Data, "1")) || (0 == stricmp((const char *) Data, "true"))); 6323*cdf0e10cSrcweir break; 6324*cdf0e10cSrcweir case REG_DWORD: 6325*cdf0e10cSrcweir bValue = (bool)(((DWORD *) Data)[0]); 6326*cdf0e10cSrcweir break; 6327*cdf0e10cSrcweir } 6328*cdf0e10cSrcweir } 6329*cdf0e10cSrcweir RegCloseKey(hkey); 6330*cdf0e10cSrcweir } 6331*cdf0e10cSrcweir } 6332*cdf0e10cSrcweir if( bValue ) 6333*cdf0e10cSrcweir mnOutStyle &= ~TOOLBOX_STYLE_FLAT; 6334*cdf0e10cSrcweir #endif 6335*cdf0e10cSrcweir } 6336