1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_TOOLBOX_HXX
21 #define INCLUDED_VCL_TOOLBOX_HXX
23 #include <tools/solar.h>
24 #include <rsc/rsc-vcl-shared-types.hxx>
25 #include <vcl/dllapi.h>
26 #include <vcl/dockwin.hxx>
27 #include <vcl/image.hxx>
28 #include <vcl/timer.hxx>
31 #include <com/sun/star/frame/XFrame.hpp>
37 struct ImplToolBoxPrivateData
;
43 class IImageListProvider
;
46 // -------------------------
47 // - ToolBoxCustomizeEvent -
48 // -------------------------
50 #define TOOLBOX_CUSTOMIZE_RESIZE ((sal_uInt16)0xFFFE)
52 class VCL_DLLPUBLIC ToolBoxCustomizeEvent
61 ToolBoxCustomizeEvent();
62 ToolBoxCustomizeEvent( ToolBox
* pDropBox
,
63 sal_uInt16 nId
, sal_uInt16 nPos
= 0,
64 void* pUserData
= NULL
);
66 ToolBox
* GetTargetBox() const { return mpTargetBox
; }
67 sal_uInt16
GetTargetPos() const { return mnPosTo
; }
68 sal_uInt16
GetSourceId() const { return mnIdFrom
; }
69 void* GetData() const { return mpData
; }
70 sal_Bool
IsResized() const;
73 inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent()
81 inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent( ToolBox
* pDropBox
,
82 sal_uInt16 nId
, sal_uInt16 nPos
,
85 mpTargetBox
= pDropBox
;
91 inline sal_Bool
ToolBoxCustomizeEvent::IsResized() const
93 if ( mnPosTo
== TOOLBOX_CUSTOMIZE_RESIZE
)
103 #define TOOLBOX_STYLE_FLAT ((sal_uInt16)0x0004)
105 #define TOOLBOX_APPEND ((sal_uInt16)0xFFFF)
106 #define TOOLBOX_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
108 // item ids in the custom menu may not exceed this constant
109 #define TOOLBOX_MENUITEM_START ((sal_uInt16)0xE000)
111 // defines for the menubutton
112 #define TOOLBOX_MENUTYPE_NONE ((sal_uInt16)0x0000) // no menu at all, scrolling by spin buttons
113 #define TOOLBOX_MENUTYPE_CLIPPEDITEMS ((sal_uInt16)0x0001) // menu will contain "more" indicator
114 #define TOOLBOX_MENUTYPE_CUSTOMIZE ((sal_uInt16)0x0002) // menu will contain "customization" and "more" indicator
116 // small or large force an exact toolbox size for proper alignemnt
117 // dontcare will let the toolbox decide about its size
118 enum ToolBoxButtonSize
{ TOOLBOX_BUTTONSIZE_DONTCARE
, TOOLBOX_BUTTONSIZE_SMALL
, TOOLBOX_BUTTONSIZE_LARGE
};
120 // TBX_LAYOUT_NORMAL - traditional layout, items are centered in the toolbar
121 // TBX_LAYOUT_LOCKVERT - special mode (currently used for calc input/formula
122 // bar) where item's vertical position is locked, e.g.
123 // toolbox is prevented from centering the items
124 enum ToolBoxLayoutMode
{ TBX_LAYOUT_NORMAL
, TBX_LAYOUT_LOCKVERT
};
137 class VCL_DLLPUBLIC ToolBox
: public DockingWindow
139 friend class FloatingWindow
;
140 friend class ImplTBDragMgr
;
143 ImplToolBoxPrivateData
* mpData
;
144 std::vector
<ImplToolSize
> maFloatSizes
;
145 ImageList maImageList
;
147 Rectangle maUpperRect
;
148 Rectangle maLowerRect
;
149 Rectangle maOutDockRect
;
150 Rectangle maInDockRect
;
151 Rectangle maPaintRect
;
152 FloatingWindow
* mpFloatWin
;
153 sal_uInt16 mnKeyModifier
;
156 long mnMaxItemWidth
; // max item width
157 long mnMaxItemHeight
; // max item height (for standard items)
158 long mnWinHeight
; // max window height (for window items)
159 long mnLeftBorder
; // inner border
164 long mnActivateCount
;
165 sal_uInt16 mnLastFocusItemId
;
166 sal_uInt16 mnFocusPos
;
167 sal_uInt16 mnOutStyle
;
168 sal_uInt16 mnHighItemId
;
169 sal_uInt16 mnCurItemId
;
170 sal_uInt16 mnDownItemId
;
172 sal_uInt16 mnLines
; // total number of toolbox lines
173 sal_uInt16 mnCurLine
; // the currently visible line
174 sal_uInt16 mnCurLines
; // number of lines due to line breaking
175 sal_uInt16 mnVisLines
; // number of visible lines (for scrolling)
176 sal_uInt16 mnFloatLines
; // number of lines during floating mode
177 sal_uInt16 mnDockLines
;
178 sal_uInt16 mnConfigItem
;
179 sal_uInt16 mnMouseClicks
;
180 sal_uInt16 mnMouseModifier
;
181 unsigned int mbDrag
:1,
199 mbChangingHighlight
:1;
201 WindowAlign meDockAlign
;
202 ButtonType meButtonType
;
203 PointerStyle meLastStyle
;
205 ToolBoxLayoutMode meLayoutMode
;
207 Link maDoubleClickHdl
;
209 Link maDeactivateHdl
;
212 Link maCommandHandler
;
213 Link maStateChangedHandler
;
214 Link maDataChangedHandler
;
217 using Window::ImplInit
;
219 SAL_DLLPRIVATE
void ImplInit( Window
* pParent
, WinBits nStyle
);
220 using DockingWindow::ImplInitSettings
;
221 SAL_DLLPRIVATE
void ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
);
222 SAL_DLLPRIVATE
void ImplLoadRes( const ResId
& rResId
);
223 SAL_DLLPRIVATE ImplToolItem
* ImplGetItem( sal_uInt16 nId
) const;
224 SAL_DLLPRIVATE sal_Bool
ImplCalcItem();
225 SAL_DLLPRIVATE sal_uInt16
ImplCalcBreaks( long nWidth
, long* pMaxLineWidth
, sal_Bool bCalcHorz
);
226 SAL_DLLPRIVATE
void ImplFormat( sal_Bool bResize
= sal_False
);
227 SAL_DLLPRIVATE
void ImplDrawSpin( sal_Bool bUpperIn
, sal_Bool bLowerIn
);
228 SAL_DLLPRIVATE
void ImplDrawSeparator( sal_uInt16 nPos
, Rectangle rRect
);
229 SAL_DLLPRIVATE
void ImplDrawItem( sal_uInt16 nPos
, sal_uInt16 nHighlight
= 0, sal_Bool bPaint
= sal_False
, sal_Bool bLayout
= sal_False
);
230 using Window::ImplInvalidate
;
231 SAL_DLLPRIVATE
void ImplInvalidate( sal_Bool bNewCalc
= sal_False
, sal_Bool bFullPaint
= sal_False
);
232 SAL_DLLPRIVATE
void ImplUpdateItem( sal_uInt16 nIndex
= 0xFFFF );
233 SAL_DLLPRIVATE
const OUString
ImplConvertMenuString( const OUString
& rStr
);
234 SAL_DLLPRIVATE sal_Bool
ImplHandleMouseMove( const MouseEvent
& rMEvt
, sal_Bool bRepeat
= sal_False
);
235 SAL_DLLPRIVATE sal_Bool
ImplHandleMouseButtonUp( const MouseEvent
& rMEvt
, sal_Bool bCancel
= sal_False
);
236 SAL_DLLPRIVATE
void ImplChangeHighlight( ImplToolItem
* pItem
, sal_Bool bNoGrabFocus
= sal_False
);
237 SAL_DLLPRIVATE sal_Bool
ImplChangeHighlightUpDn( sal_Bool bUp
, sal_Bool bNoCycle
= sal_False
);
238 SAL_DLLPRIVATE sal_uInt16
ImplGetItemLine( ImplToolItem
* pCurrentItem
);
239 SAL_DLLPRIVATE ImplToolItem
* ImplGetFirstValidItem( sal_uInt16 nLine
);
240 SAL_DLLPRIVATE sal_Bool
ImplOpenItem( KeyCode aKeyCode
);
241 SAL_DLLPRIVATE sal_Bool
ImplActivateItem( KeyCode aKeyCode
);
242 SAL_DLLPRIVATE
void ImplShowFocus();
243 SAL_DLLPRIVATE
void ImplHideFocus();
244 SAL_DLLPRIVATE
void ImplUpdateInputEnable();
245 SAL_DLLPRIVATE
void ImplFillLayoutData() const;
246 SAL_DLLPRIVATE sal_Bool
ImplHasClippedItems();
247 SAL_DLLPRIVATE Point
ImplGetPopupPosition( const Rectangle
& rRect
, const Size
& rSize
) const;
248 SAL_DLLPRIVATE
void ImplExecuteCustomMenu();
249 SAL_DLLPRIVATE sal_Bool
ImplIsFloatingMode() const;
250 SAL_DLLPRIVATE sal_Bool
ImplIsInPopupMode() const;
251 SAL_DLLPRIVATE
const OUString
& ImplGetHelpText( sal_uInt16 nItemId
) const;
252 SAL_DLLPRIVATE Size
ImplGetOptimalFloatingSize();
253 SAL_DLLPRIVATE sal_Bool
ImplHasExternalMenubutton();
254 SAL_DLLPRIVATE
void ImplDrawFloatwinBorder( ImplToolItem
* pItem
);
256 DECL_DLLPRIVATE_LINK( ImplCallExecuteCustomMenu
, void* );
257 DECL_DLLPRIVATE_LINK( ImplUpdateHdl
, void* );
258 DECL_DLLPRIVATE_LINK( ImplResetAutoSizeTriesHdl
, void* );
259 DECL_DLLPRIVATE_LINK( ImplCustomMenuListener
, VclMenuEvent
* );
260 DECL_DLLPRIVATE_LINK( ImplDropdownLongClickHdl
, void* );
262 // Copy assignment is forbidden and not implemented.
263 SAL_DLLPRIVATE
ToolBox (const ToolBox
&);
264 SAL_DLLPRIVATE ToolBox
& operator= (const ToolBox
&);
266 SAL_DLLPRIVATE
void ImplUpdateImageList(); // called if StateChanged
268 SAL_DLLPRIVATE
void ImplFloatControl( sal_Bool bStart
, FloatingWindow
* pWindow
= NULL
);
269 SAL_DLLPRIVATE
void ImplDisableFlatButtons();
271 static SAL_DLLPRIVATE
int ImplGetDragWidth( ToolBox
* pThis
);
272 static SAL_DLLPRIVATE
void ImplUpdateDragArea( ToolBox
*pThis
);
273 static SAL_DLLPRIVATE
void ImplCalcBorder( WindowAlign eAlign
, long& rLeft
, long& rTop
,
274 long& rRight
, long& rBottom
, const ToolBox
*pThis
);
275 static SAL_DLLPRIVATE
void ImplDrawGrip( ToolBox
* pThis
);
276 static SAL_DLLPRIVATE
void ImplDrawGradientBackground( ToolBox
* pThis
, ImplDockingWindowWrapper
*pWrapper
);
277 static SAL_DLLPRIVATE sal_Bool
ImplDrawNativeBackground( ToolBox
* pThis
, const Region
&rRegion
);
278 static SAL_DLLPRIVATE
void ImplDrawTransparentBackground( ToolBox
* pThis
, const Region
&rRegion
);
279 static SAL_DLLPRIVATE
void ImplDrawConstantBackground( ToolBox
* pThis
, const Region
&rRegion
, sal_Bool bIsInPopupMode
);
280 static SAL_DLLPRIVATE
void ImplDrawBackground( ToolBox
* pThis
, const Rectangle
&rRect
);
281 static SAL_DLLPRIVATE
void ImplErase( ToolBox
* pThis
, const Rectangle
&rRect
, sal_Bool bHighlight
= sal_False
, sal_Bool bHasOpenPopup
= sal_False
);
282 static SAL_DLLPRIVATE
void ImplDrawBorder( ToolBox
* pWin
);
283 static SAL_DLLPRIVATE
const ImplToolItem
*ImplGetFirstClippedItem( const ToolBox
* pThis
);
284 static SAL_DLLPRIVATE Size
ImplCalcSize( const ToolBox
* pThis
, sal_uInt16 nCalcLines
, sal_uInt16 nCalcMode
= 0 );
285 static SAL_DLLPRIVATE
void ImplCalcFloatSizes( ToolBox
* pThis
);
286 static SAL_DLLPRIVATE Size
ImplCalcFloatSize( ToolBox
* pThis
, sal_uInt16
& rLines
);
287 static SAL_DLLPRIVATE
void ImplCalcMinMaxFloatSize( ToolBox
* pThis
, Size
& rMinSize
, Size
& rMaxSize
);
288 static SAL_DLLPRIVATE
void ImplSetMinMaxFloatSize( ToolBox
*pThis
);
289 static SAL_DLLPRIVATE sal_uInt16
ImplCalcLines( ToolBox
* pThis
, long nToolSize
);
290 static SAL_DLLPRIVATE sal_uInt16
ImplTestLineSize( ToolBox
* pThis
, const Point
& rPos
);
291 static SAL_DLLPRIVATE
void ImplLineSizing( ToolBox
* pThis
, const Point
& rPos
, Rectangle
& rRect
, sal_uInt16 nLineMode
);
292 static SAL_DLLPRIVATE sal_uInt16
ImplFindItemPos( ToolBox
* pBox
, const Point
& rPos
);
293 static SAL_DLLPRIVATE sal_uInt16
ImplFindItemPos( const ImplToolItem
* pItem
, const std::vector
< ImplToolItem
>& rList
);
294 static SAL_DLLPRIVATE
void ImplDrawMenubutton( ToolBox
*pThis
, sal_Bool bHighlight
);
295 static SAL_DLLPRIVATE sal_uInt16
ImplCountLineBreaks( const ToolBox
*pThis
);
296 SAL_DLLPRIVATE ImplToolBoxPrivateData
* ImplGetToolBoxPrivateData() const { return mpData
; }
299 void SetCurItemId(sal_uInt16 nSet
) { mnCurItemId
= nSet
; }
302 ToolBox( Window
* pParent
, WinBits nStyle
= 0 );
303 ToolBox( Window
* pParent
, const ResId
& rResId
);
306 virtual void Click();
307 virtual void DoubleClick();
308 virtual void Activate();
309 virtual void Deactivate();
310 virtual void Highlight();
311 virtual void Select();
312 virtual void Customize( const ToolBoxCustomizeEvent
& rCEvt
);
313 virtual void UserDraw( const UserDrawEvent
& rUDEvt
);
315 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
316 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
317 virtual void MouseMove( const MouseEvent
& rMEvt
);
318 virtual void Tracking( const TrackingEvent
& rTEvt
);
319 virtual void Paint( const Rectangle
& rRect
);
321 virtual void Resize();
322 virtual void RequestHelp( const HelpEvent
& rHEvt
);
323 virtual long Notify( NotifyEvent
& rNEvt
);
324 virtual void Command( const CommandEvent
& rCEvt
);
325 virtual void StateChanged( StateChangedType nType
);
326 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
328 virtual void GetFocus();
329 virtual void LoseFocus();
330 virtual void KeyInput( const KeyEvent
& rKEvt
);
332 virtual sal_Bool
PrepareToggleFloatingMode();
333 virtual void ToggleFloatingMode();
334 virtual void StartDocking();
335 virtual sal_Bool
Docking( const Point
& rPos
, Rectangle
& rRect
);
336 virtual void EndDocking( const Rectangle
& rRect
, sal_Bool bFloatMode
);
337 virtual void Resizing( Size
& rSize
);
338 virtual Size
GetOptimalSize() const;
340 void InsertItem( const ResId
& rResId
,
341 sal_uInt16 nPos
= TOOLBOX_APPEND
);
342 /// Insert a command (like '.uno:Save').
343 virtual void InsertItem( const OUString
& rCommand
,
344 const com::sun::star::uno::Reference
<com::sun::star::frame::XFrame
>& rFrame
,
345 ToolBoxItemBits nBits
= 0,
346 const Size
& rRequestedSize
= Size(),
347 sal_uInt16 nPos
= TOOLBOX_APPEND
);
348 void InsertItem( sal_uInt16 nItemId
, const Image
& rImage
,
349 ToolBoxItemBits nBits
= 0,
350 sal_uInt16 nPos
= TOOLBOX_APPEND
);
351 void InsertItem( sal_uInt16 nItemId
, const Image
& rImage
,
352 const OUString
& rText
,
353 ToolBoxItemBits nBits
= 0,
354 sal_uInt16 nPos
= TOOLBOX_APPEND
);
355 void InsertItem( sal_uInt16 nItemId
, const OUString
& rText
,
356 ToolBoxItemBits nBits
= 0,
357 sal_uInt16 nPos
= TOOLBOX_APPEND
);
358 void InsertWindow( sal_uInt16 nItemId
, Window
* pWindow
,
359 ToolBoxItemBits nBits
= 0,
360 sal_uInt16 nPos
= TOOLBOX_APPEND
);
361 void InsertSpace( sal_uInt16 nPos
= TOOLBOX_APPEND
);
362 void InsertSeparator( sal_uInt16 nPos
= TOOLBOX_APPEND
,
363 sal_uInt16 nPixSize
= 0 );
364 void InsertBreak( sal_uInt16 nPos
= TOOLBOX_APPEND
);
365 void RemoveItem( sal_uInt16 nPos
);
366 void CopyItem( const ToolBox
& rToolBox
, sal_uInt16 nItemId
,
367 sal_uInt16 nNewPos
= TOOLBOX_APPEND
);
370 const ImageList
& GetImageList() const { return maImageList
; }
371 void SetImageList( const ImageList
& rImageList
);
373 void SetButtonType( ButtonType eNewType
= BUTTON_SYMBOL
);
374 ButtonType
GetButtonType() const { return meButtonType
; }
376 // sets a fixed button size (small, large or dontcare (==autosize))
377 void SetToolboxButtonSize( ToolBoxButtonSize eSize
);
378 ToolBoxButtonSize
GetToolboxButtonSize() const;
380 void SetAlign( WindowAlign eNewAlign
= WINDOWALIGN_TOP
);
381 WindowAlign
GetAlign() const { return meAlign
; }
382 sal_Bool
IsHorizontal() const { return mbHorz
; }
384 void SetLineCount( sal_uInt16 nNewLines
);
385 sal_uInt16
GetLineCount() const { return mnLines
; }
386 sal_uInt16
GetCurLine() const { return mnCurLine
; }
387 void ShowLine( sal_Bool bNext
);
389 // Used to enable/disable scrolling one page at a time for toolbar
390 void SetPageScroll( sal_Bool b
);
392 sal_uInt16
GetItemCount() const;
393 ToolBoxItemType
GetItemType( sal_uInt16 nPos
) const;
394 sal_uInt16
GetItemPos( sal_uInt16 nItemId
) const;
395 sal_uInt16
GetItemPos( const Point
& rPos
) const;
396 sal_uInt16
GetItemId( sal_uInt16 nPos
) const;
397 sal_uInt16
GetItemId( const Point
& rPos
) const;
398 /// Map the command name (like .uno:Save) back to item id.
399 sal_uInt16
GetItemId( const OUString
& rCommand
) const;
400 Rectangle
GetItemRect( sal_uInt16 nItemId
) const;
401 Rectangle
GetItemPosRect( sal_uInt16 nPos
) const;
403 /// Returns size of the bitmap / text that is inside this toolbox item.
404 Size
GetItemContentSize( sal_uInt16 nItemId
) const;
406 /// Retrieves the optimal position to place a popup window for this item (subtoolbar or dropdown)
407 Point
GetItemPopupPosition( sal_uInt16 nItemId
, const Size
& rSize
) const;
409 Rectangle
GetScrollRect() const;
410 sal_uInt16
GetCurItemId() const { return mnCurItemId
; }
411 sal_uInt16
GetDownItemId() const { return mnDownItemId
; }
412 sal_uInt16
GetClicks() const { return mnMouseClicks
; }
413 sal_uInt16
GetModifier() const { return mnMouseModifier
; }
414 sal_uInt16
GetKeyModifier() const { return mnKeyModifier
; }
416 void SetItemBits( sal_uInt16 nItemId
, ToolBoxItemBits nBits
);
417 ToolBoxItemBits
GetItemBits( sal_uInt16 nItemId
) const;
419 void SetItemData( sal_uInt16 nItemId
, void* pNewData
);
420 void* GetItemData( sal_uInt16 nItemId
) const;
421 void SetItemImage( sal_uInt16 nItemId
, const Image
& rImage
);
422 Image
GetItemImage( sal_uInt16 nItemId
) const;
423 void SetItemImageAngle( sal_uInt16 nItemId
, long nAngle10
);
424 void SetItemImageMirrorMode( sal_uInt16 nItemId
, sal_Bool bMirror
);
425 void SetItemText( sal_uInt16 nItemId
, const OUString
& rText
);
426 const OUString
& GetItemText( sal_uInt16 nItemId
) const;
427 void SetItemWindow( sal_uInt16 nItemId
, Window
* pNewWindow
);
428 Window
* GetItemWindow( sal_uInt16 nItemId
) const;
429 sal_uInt16
GetHighlightItemId() const { return mnHighItemId
; }
431 void StartSelection();
434 void SetItemDown( sal_uInt16 nItemId
, sal_Bool bDown
, sal_Bool bRelease
= sal_True
);
436 void SetItemState( sal_uInt16 nItemId
, TriState eState
);
437 TriState
GetItemState( sal_uInt16 nItemId
) const;
439 void CheckItem( sal_uInt16 nItemId
, sal_Bool bCheck
= sal_True
);
440 sal_Bool
IsItemChecked( sal_uInt16 nItemId
) const;
442 void EnableItem( sal_uInt16 nItemId
, sal_Bool bEnable
= sal_True
);
443 sal_Bool
IsItemEnabled( sal_uInt16 nItemId
) const;
445 void TriggerItem( sal_uInt16 nItemId
, sal_Bool bShift
= sal_False
, sal_Bool bCtrl
= sal_False
);
446 void ShowItem( sal_uInt16 nItemId
, sal_Bool bVisible
= sal_True
);
447 void HideItem( sal_uInt16 nItemId
) { ShowItem( nItemId
, sal_False
); }
448 sal_Bool
IsItemVisible( sal_uInt16 nItemId
) const;
449 sal_Bool
IsItemReallyVisible( sal_uInt16 nItemId
) const;
451 void SetItemCommand( sal_uInt16 nItemId
, const OUString
& rCommand
);
452 const OUString
GetItemCommand( sal_uInt16 nItemId
) const;
454 using Window::SetQuickHelpText
;
455 void SetQuickHelpText( sal_uInt16 nItemId
, const OUString
& rText
);
456 using Window::GetQuickHelpText
;
457 const OUString
& GetQuickHelpText( sal_uInt16 nItemId
) const;
459 void SetHelpText( sal_uInt16 nItemId
, const OUString
& rText
);
460 const OUString
& GetHelpText( sal_uInt16 nItemId
) const;
462 void SetHelpId( sal_uInt16 nItemId
, const OString
& rHelpId
);
463 OString
GetHelpId( sal_uInt16 nItemId
) const;
465 // window size according to current alignment, floating state and number of lines
466 Size
CalcWindowSizePixel() const;
467 // window size according to current alignment, floating state and a given number of lines
468 Size
CalcWindowSizePixel( sal_uInt16 nCalcLines
) const;
469 // window size according to current floating state and a given number of lines and a given alignment
470 Size
CalcWindowSizePixel( sal_uInt16 nCalcLines
, WindowAlign eAlign
) const;
471 // floating window size according to number of lines (uses the number of line breaks)
472 Size
CalcFloatingWindowSizePixel() const;
473 // floating window size with a given number of lines
474 Size
CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines
) const;
475 // automatic window size for popoup mode
476 Size
CalcPopupWindowSizePixel() const;
478 // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button)
479 Size
CalcMinimumWindowSizePixel() const;
481 void SetDockingRects( const Rectangle
& rOutRect
,
482 const Rectangle
& rInRect
);
483 void SetFloatingLines( sal_uInt16 nFloatLines
);
484 sal_uInt16
GetFloatingLines() const;
486 void SetStyle( WinBits nNewStyle
) { mnWinStyle
= nNewStyle
; }
487 WinBits
GetStyle() const { return mnWinStyle
; }
489 // enable/disable undocking
490 void Lock( sal_Bool bLock
= sal_True
);
492 // read configuration to determine locking behaviour
493 static sal_Bool
AlwaysLocked();
495 void EnableMenuStrings( sal_Bool bEnable
= sal_True
) { mbMenuStrings
= (bEnable
!= 0); }
496 sal_Bool
IsMenuStringsEnabled() const { return mbMenuStrings
; }
498 void SetOutStyle( sal_uInt16 nNewStyle
);
499 sal_uInt16
GetOutStyle() const { return mnOutStyle
; }
501 void EnableCustomize( sal_Bool bEnable
= sal_True
);
502 sal_Bool
IsCustomize() { return mbCustomize
; }
503 sal_Bool
IsInCustomizeMode() const { return mbCustomizeMode
; }
505 void SetHelpText( const OUString
& rText
)
506 { DockingWindow::SetHelpText( rText
); }
507 const OUString
& GetHelpText() const
508 { return DockingWindow::GetHelpText(); }
510 void SetHelpId( const OString
& rId
)
511 { DockingWindow::SetHelpId( rId
); }
512 const OString
& GetHelpId() const
513 { return DockingWindow::GetHelpId(); }
515 void SetClickHdl( const Link
& rLink
) { maClickHdl
= rLink
; }
516 const Link
& GetClickHdl() const { return maClickHdl
; }
517 void SetDoubleClickHdl( const Link
& rLink
) { maDoubleClickHdl
= rLink
; }
518 const Link
& GetDoubleClickHdl() const { return maDoubleClickHdl
; }
519 void SetDropdownClickHdl( const Link
& rLink
);
520 const Link
& GetDropdownClickHdl() const;
521 void SetActivateHdl( const Link
& rLink
) { maActivateHdl
= rLink
; }
522 const Link
& GetActivateHdl() const { return maActivateHdl
; }
523 void SetDeactivateHdl( const Link
& rLink
) { maDeactivateHdl
= rLink
; }
524 const Link
& GetDeactivateHdl() const { return maDeactivateHdl
; }
525 void SetHighlightHdl( const Link
& rLink
) { maHighlightHdl
= rLink
; }
526 const Link
& GetHighlightHdl() const { return maHighlightHdl
; }
527 void SetSelectHdl( const Link
& rLink
) { maSelectHdl
= rLink
; }
528 const Link
& GetSelectHdl() const { return maSelectHdl
; }
529 void SetCommandHdl( const Link
& aLink
) { maCommandHandler
= aLink
; }
530 const Link
& GetCommandHdl() const { return maCommandHandler
; }
531 void SetStateChangedHdl( const Link
& aLink
) { maStateChangedHandler
= aLink
; }
532 const Link
& GetStateChangedHdl() const { return maStateChangedHandler
; }
533 void SetDataChangedHdl( const Link
& aLink
) { maDataChangedHandler
= aLink
; }
534 const Link
& GetDataChangedHdl() { return maDataChangedHandler
; }
536 // support for custom menu (eg for configuration)
537 // note: this menu will also be used to display currently
538 // clipped toolbox items, so you should only touch
539 // items that you added by yourself
540 // the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START
541 // to allow for customization of the menu the coresponding handler is called
542 // when the menu button was clicked and before the menu is executed
543 void SetMenuType( sal_uInt16 aType
= TOOLBOX_MENUTYPE_CUSTOMIZE
);
544 sal_uInt16
GetMenuType() const;
545 sal_Bool
IsMenuEnabled() const;
546 PopupMenu
* GetMenu() const;
547 void UpdateCustomMenu();
548 void SetMenuButtonHdl( const Link
& rLink
);
551 void ExecuteCustomMenu();
553 // allow Click Handler to detect special key
554 bool IsShift() const { return mbIsShift
; }
555 // allow Click Handler to distinguish between mouse and key input
556 sal_Bool
IsKeyEvent() const { return mbIsKeyEvent
; }
558 // allows framework to set/query the planned popupmode
559 sal_Bool
WillUsePopupMode() const;
560 void WillUsePopupMode( sal_Bool b
);
562 // accessibility helpers
564 // gets the displayed text
565 OUString
GetDisplayText() const;
566 // returns the bounding box for the character at index nIndex
567 // where nIndex is relative to the starting index of the item
568 // with id nItemId (in coordinates of the displaying window)
569 Rectangle
GetCharacterBounds( sal_uInt16 nItemId
, long nIndex
) const;
570 // -1 is returned if no character is at that point
571 // if an index is found the corresponding item id is filled in (else 0)
572 long GetIndexForPoint( const Point
& rPoint
, sal_uInt16
& rItemID
) const;
574 static const Size
& GetDefaultImageSize(bool bLarge
);
575 const Size
& GetDefaultImageSize() const;
576 void ChangeHighlight( sal_uInt16 nPos
);
578 void SetImageListProvider(vcl::IImageListProvider
* _pProvider
);
579 void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout
);
582 inline void ToolBox::CheckItem( sal_uInt16 nItemId
, sal_Bool bCheck
)
584 SetItemState( nItemId
, (bCheck
) ? STATE_CHECK
: STATE_NOCHECK
);
587 inline sal_Bool
ToolBox::IsItemChecked( sal_uInt16 nItemId
) const
589 return (GetItemState( nItemId
) == STATE_CHECK
);
592 inline Size
ToolBox::CalcWindowSizePixel() const
594 return CalcWindowSizePixel( mnLines
);
597 inline Rectangle
ToolBox::GetScrollRect() const
599 return maUpperRect
.GetUnion( maLowerRect
);
602 inline void ToolBox::SetDockingRects( const Rectangle
& rOutRect
,
603 const Rectangle
& rInRect
)
605 maOutDockRect
= rOutRect
;
606 maInDockRect
= rInRect
;
609 inline void ToolBox::SetFloatingLines( sal_uInt16 nNewLines
)
611 mnFloatLines
= nNewLines
;
614 inline sal_uInt16
ToolBox::GetFloatingLines() const
619 #endif // INCLUDED_VCL_TOOLBOX_HXX
621 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */