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