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