LCOV - code coverage report
Current view: top level - include/vcl - toolbox.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 25 42 59.5 %
Date: 2015-06-13 12:38:46 Functions: 21 33 63.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_TOOLBOX_HXX
      21             : #define INCLUDED_VCL_TOOLBOX_HXX
      22             : 
      23             : #include <com/sun/star/frame/XFrame.hpp>
      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>
      29             : #include <vcl/idle.hxx>
      30             : #include <vector>
      31             : 
      32             : class UserDrawEvent;
      33             : 
      34             : struct ImplToolItem;
      35             : struct ImplToolSize;
      36             : struct ImplToolBoxPrivateData;
      37             : class  ImplTrackRect;
      38             : class  PopupMenu;
      39             : 
      40             : #define TOOLBOX_CUSTOMIZE_RESIZE        ((sal_uInt16)0xFFFE)
      41             : 
      42             : class VCL_DLLPUBLIC ToolBoxCustomizeEvent
      43             : {
      44             : private:
      45             :     VclPtr<ToolBox> mpTargetBox;
      46             :     void*       mpData;
      47             :     sal_uInt16      mnIdFrom;
      48             :     sal_uInt16      mnPosTo;
      49             : 
      50             : public:
      51             :                 ToolBoxCustomizeEvent();
      52             :                 ToolBoxCustomizeEvent( ToolBox* pDropBox,
      53             :                                        sal_uInt16 nId, sal_uInt16 nPos = 0,
      54             :                                        void* pUserData = NULL );
      55             : 
      56             :     ToolBox*    GetTargetBox() const { return mpTargetBox; }
      57             :     sal_uInt16      GetTargetPos() const { return mnPosTo; }
      58             :     sal_uInt16      GetSourceId() const { return mnIdFrom; }
      59             :     void*       GetData() const { return mpData; }
      60             :     bool        IsResized() const;
      61             : };
      62             : 
      63             : inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent()
      64             : {
      65             :     mpTargetBox = NULL;
      66             :     mnIdFrom    = 0;
      67             :     mnPosTo     = 0;
      68             :     mpData      = NULL;
      69             : }
      70             : 
      71             : inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent( ToolBox* pDropBox,
      72             :                                                      sal_uInt16 nId, sal_uInt16 nPos,
      73             :                                                      void* pUserData )
      74             : {
      75             :     mpTargetBox = pDropBox;
      76             :     mnIdFrom    = nId;
      77             :     mnPosTo     = nPos;
      78             :     mpData      = pUserData;
      79             : }
      80             : 
      81             : inline bool ToolBoxCustomizeEvent::IsResized() const
      82             : {
      83             :     if ( mnPosTo == TOOLBOX_CUSTOMIZE_RESIZE )
      84             :         return true;
      85             :     else
      86             :         return false;
      87             : }
      88             : 
      89             : #define TOOLBOX_STYLE_FLAT          ((sal_uInt16)0x0004)
      90             : 
      91             : #define TOOLBOX_APPEND              ((sal_uInt16)0xFFFF)
      92             : #define TOOLBOX_ITEM_NOTFOUND       ((sal_uInt16)0xFFFF)
      93             : 
      94             : // item ids in the custom menu may not exceed this constant
      95             : #define TOOLBOX_MENUITEM_START      ((sal_uInt16)0xE000)
      96             : 
      97             : // defines for the menubutton
      98             : #define TOOLBOX_MENUTYPE_NONE           ((sal_uInt16)0x0000)    // no menu at all, scrolling by spin buttons
      99             : #define TOOLBOX_MENUTYPE_CLIPPEDITEMS   ((sal_uInt16)0x0001)    // menu will contain "more" indicator
     100             : #define TOOLBOX_MENUTYPE_CUSTOMIZE      ((sal_uInt16)0x0002)    // menu will contain "customization" and "more" indicator
     101             : 
     102             : // small or large force an exact toolbox size for proper alignemnt
     103             : // dontcare will let the toolbox decide about its size
     104             : enum ToolBoxButtonSize { TOOLBOX_BUTTONSIZE_DONTCARE, TOOLBOX_BUTTONSIZE_SMALL, TOOLBOX_BUTTONSIZE_LARGE };
     105             : 
     106             : // TBX_LAYOUT_NORMAL   - traditional layout, items are centered in the toolbar
     107             : // TBX_LAYOUT_LOCKVERT - special mode (currently used for calc input/formula
     108             : //                       bar) where item's vertical position is locked, e.g.
     109             : //                       toolbox is prevented from centering the items
     110             : enum ToolBoxLayoutMode { TBX_LAYOUT_NORMAL, TBX_LAYOUT_LOCKVERT };
     111             : 
     112             : struct ImplToolSize
     113             : {
     114             :     long mnWidth;
     115             :     long mnHeight;
     116             :     sal_uInt16 mnLines;
     117             : };
     118             : 
     119             : class VCL_DLLPUBLIC ToolBox : public DockingWindow
     120             : {
     121             :     friend class FloatingWindow;
     122             :     friend class ImplTBDragMgr;
     123             : 
     124             : private:
     125             :     ImplToolBoxPrivateData*     mpData;
     126             :     std::vector<ImplToolSize> maFloatSizes;
     127             :     ImageList           maImageList;
     128             :     Idle                maIdle;
     129             :     Rectangle           maUpperRect;
     130             :     Rectangle           maLowerRect;
     131             :     Rectangle           maOutDockRect;
     132             :     Rectangle           maInDockRect;
     133             :     Rectangle           maPaintRect;
     134             :     VclPtr<FloatingWindow>  mpFloatWin;
     135             :     sal_uInt16              mnKeyModifier;
     136             :     long                mnDX;
     137             :     long                mnDY;
     138             :     long                mnMaxItemWidth;    // max item width
     139             :     long                mnMaxItemHeight;   // max item height (for standard items)
     140             :     long                mnWinHeight;    // max window height (for window items)
     141             :     long                mnLeftBorder;   // inner border
     142             :     long                mnTopBorder;
     143             :     long                mnRightBorder;
     144             :     long                mnBottomBorder;
     145             :     long                mnLastResizeDY;
     146             :     long                mnActivateCount;
     147             :     sal_uInt16              mnLastFocusItemId;
     148             :     sal_uInt16              mnFocusPos;
     149             :     sal_uInt16              mnOutStyle;
     150             :     sal_uInt16              mnHighItemId;
     151             :     sal_uInt16              mnCurItemId;
     152             :     sal_uInt16              mnDownItemId;
     153             :     sal_uInt16              mnCurPos;
     154             :     sal_uInt16              mnLines;        // total number of toolbox lines
     155             :     sal_uInt16              mnCurLine;      // the currently visible line
     156             :     sal_uInt16              mnCurLines;     // number of lines due to line breaking
     157             :     sal_uInt16              mnVisLines;     // number of visible lines (for scrolling)
     158             :     sal_uInt16              mnFloatLines;   // number of lines during floating mode
     159             :     sal_uInt16              mnDockLines;
     160             :     sal_uInt16              mnConfigItem;
     161             :     sal_uInt16              mnMouseClicks;
     162             :     sal_uInt16              mnMouseModifier;
     163             :     bool                mbDrag:1,
     164             :                         mbSelection:1,
     165             :                         mbCommandDrag:1,
     166             :                         mbUpper:1,
     167             :                         mbLower:1,
     168             :                         mbIn:1,
     169             :                         mbCalc:1,
     170             :                         mbFormat:1,
     171             :                         mbFullPaint:1,
     172             :                         mbHorz:1,
     173             :                         mbScroll:1,
     174             :                         mbLastFloatMode:1,
     175             :                         mbCustomize:1,
     176             :                         mbCustomizeMode:1,
     177             :                         mbDragging:1,
     178             :                         mbMenuStrings:1,
     179             :                         mbIsShift:1,
     180             :                         mbIsKeyEvent:1,
     181             :                         mbChangingHighlight:1;
     182             :     WindowAlign         meAlign;
     183             :     WindowAlign         meDockAlign;
     184             :     ButtonType          meButtonType;
     185             :     PointerStyle        meLastStyle;
     186             :     WinBits             mnWinStyle;
     187             :     ToolBoxLayoutMode   meLayoutMode;
     188             :     Link<ToolBox *, void> maClickHdl;
     189             :     Link<ToolBox *, void> maDoubleClickHdl;
     190             :     Link<ToolBox *, void> maActivateHdl;
     191             :     Link<ToolBox *, void> maDeactivateHdl;
     192             :     Link<ToolBox *, void> maSelectHdl;
     193             :     Link<CommandEvent const *, void> maCommandHandler;
     194             :     Link<StateChangedType const *, void> maStateChangedHandler;
     195             :     Link<DataChangedEvent const *, void> maDataChangedHandler;
     196             : 
     197             : public:
     198             :     using Window::ImplInit;
     199             : private:
     200             :     SAL_DLLPRIVATE void InvalidateItem(sal_uInt16 nPosition);
     201             :     SAL_DLLPRIVATE void InvalidateSpin(bool bUpperIn, bool bLowerIn);
     202             :     SAL_DLLPRIVATE void InvalidateMenuButton();
     203             : 
     204             :     SAL_DLLPRIVATE void            ImplInit( vcl::Window* pParent, WinBits nStyle );
     205             :     using DockingWindow::ImplInitSettings;
     206             :     SAL_DLLPRIVATE void            ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
     207             :     SAL_DLLPRIVATE void            ImplLoadRes( const ResId& rResId );
     208             :     SAL_DLLPRIVATE ImplToolItem*   ImplGetItem( sal_uInt16 nId ) const;
     209             :     SAL_DLLPRIVATE bool            ImplCalcItem();
     210             :     SAL_DLLPRIVATE sal_uInt16          ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalcHorz );
     211             :     SAL_DLLPRIVATE void            ImplFormat( bool bResize = false );
     212             :     SAL_DLLPRIVATE void            ImplDrawSpin(vcl::RenderContext& rRenderContext, bool bUpperIn, bool bLowerIn);
     213             :     SAL_DLLPRIVATE void            ImplDrawSeparator(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, const Rectangle& rRect);
     214             :     SAL_DLLPRIVATE void            ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, sal_uInt16 nHighlight = 0, bool bPaint = false, bool bLayout = false );
     215             :     using Window::ImplInvalidate;
     216             :     SAL_DLLPRIVATE void            ImplInvalidate( bool bNewCalc = false, bool bFullPaint = false );
     217             :     SAL_DLLPRIVATE void            ImplUpdateItem( sal_uInt16 nIndex = 0xFFFF );
     218             :     SAL_DLLPRIVATE const OUString ImplConvertMenuString( const OUString& rStr );
     219             :     SAL_DLLPRIVATE bool            ImplHandleMouseMove( const MouseEvent& rMEvt, bool bRepeat = false );
     220             :     SAL_DLLPRIVATE bool            ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel = false );
     221             :     SAL_DLLPRIVATE void            ImplChangeHighlight( ImplToolItem* pItem, bool bNoGrabFocus = false );
     222             :     SAL_DLLPRIVATE bool            ImplChangeHighlightUpDn( bool bUp, bool bNoCycle = false );
     223             :     SAL_DLLPRIVATE sal_uInt16          ImplGetItemLine( ImplToolItem* pCurrentItem );
     224             :     SAL_DLLPRIVATE ImplToolItem*   ImplGetFirstValidItem( sal_uInt16 nLine );
     225             :     SAL_DLLPRIVATE bool            ImplOpenItem( vcl::KeyCode aKeyCode );
     226             :     SAL_DLLPRIVATE bool            ImplActivateItem( vcl::KeyCode aKeyCode );
     227             :     SAL_DLLPRIVATE void            ImplShowFocus();
     228             :     SAL_DLLPRIVATE void            ImplHideFocus();
     229             :     SAL_DLLPRIVATE void            ImplUpdateInputEnable();
     230             :     SAL_DLLPRIVATE void            ImplFillLayoutData() const;
     231             :     SAL_DLLPRIVATE bool            ImplHasClippedItems();
     232             :     SAL_DLLPRIVATE Point           ImplGetPopupPosition( const Rectangle& rRect, const Size& rSize ) const;
     233             :     SAL_DLLPRIVATE void            ImplExecuteCustomMenu();
     234             :     SAL_DLLPRIVATE bool            ImplIsFloatingMode() const;
     235             :     SAL_DLLPRIVATE bool            ImplIsInPopupMode() const;
     236             :     SAL_DLLPRIVATE const OUString& ImplGetHelpText( sal_uInt16 nItemId ) const;
     237             :     SAL_DLLPRIVATE Size            ImplGetOptimalFloatingSize();
     238             :     SAL_DLLPRIVATE bool            ImplHasExternalMenubutton();
     239             :     SAL_DLLPRIVATE void            ImplDrawFloatwinBorder(vcl::RenderContext& rRenderContext, ImplToolItem* pItem );
     240             : 
     241             :     DECL_DLLPRIVATE_LINK(          ImplCallExecuteCustomMenu, void* );
     242             :     DECL_DLLPRIVATE_LINK_TYPED(    ImplUpdateHdl, Idle*, void );
     243             :     DECL_DLLPRIVATE_LINK(          ImplResetAutoSizeTriesHdl, void* );
     244             :     DECL_DLLPRIVATE_LINK(          ImplCustomMenuListener, VclMenuEvent* );
     245             :     DECL_DLLPRIVATE_LINK_TYPED(    ImplDropdownLongClickHdl, Timer*, void );
     246             : 
     247             :                                    ToolBox (const ToolBox &) SAL_DELETED_FUNCTION;
     248             :                           ToolBox& operator= (const ToolBox &) SAL_DELETED_FUNCTION;
     249             : 
     250             : public:
     251             :     SAL_DLLPRIVATE void            ImplFloatControl( bool bStart, FloatingWindow* pWindow = NULL );
     252             :     SAL_DLLPRIVATE void            ImplDisableFlatButtons();
     253             : 
     254             :     static SAL_DLLPRIVATE int ImplGetDragWidth( ToolBox* pThis );
     255             :     static SAL_DLLPRIVATE void ImplUpdateDragArea( ToolBox *pThis );
     256             :     static SAL_DLLPRIVATE void ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop,
     257             :                                                long& rRight, long& rBottom, const ToolBox *pThis );
     258             : 
     259             :     SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext);
     260             :     SAL_DLLPRIVATE void ImplDrawGradientBackground(vcl::RenderContext& rRenderContext, ImplDockingWindowWrapper *pWrapper);
     261             :     SAL_DLLPRIVATE bool ImplDrawNativeBackground(vcl::RenderContext& rRenderContext, const vcl::Region &rRegion);
     262             :     SAL_DLLPRIVATE void ImplDrawTransparentBackground(vcl::RenderContext& rRenderContext, const vcl::Region &rRegion);
     263             :     SAL_DLLPRIVATE void ImplDrawConstantBackground(vcl::RenderContext& rRenderContext, const vcl::Region &rRegion, bool bIsInPopupMode);
     264             :     SAL_DLLPRIVATE void ImplDrawBackground(vcl::RenderContext& rRenderContext, const Rectangle &rRect);
     265             : 
     266             :     SAL_DLLPRIVATE void ImplErase(vcl::RenderContext& rRenderContext, const Rectangle &rRect, bool bHighlight = false, bool bHasOpenPopup = false );
     267             : 
     268             :     SAL_DLLPRIVATE void ImplDrawBorder(vcl::RenderContext& rRenderContext);
     269             :     static SAL_DLLPRIVATE const ImplToolItem *ImplGetFirstClippedItem( const ToolBox* pThis );
     270             :     static SAL_DLLPRIVATE Size ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uInt16 nCalcMode = 0 );
     271             :     static SAL_DLLPRIVATE void ImplCalcFloatSizes( ToolBox* pThis );
     272             :     static SAL_DLLPRIVATE Size ImplCalcFloatSize( ToolBox* pThis, sal_uInt16& rLines );
     273             :     static SAL_DLLPRIVATE void ImplCalcMinMaxFloatSize( ToolBox* pThis, Size& rMinSize, Size& rMaxSize );
     274             :     static SAL_DLLPRIVATE void ImplSetMinMaxFloatSize( ToolBox *pThis );
     275             :     static SAL_DLLPRIVATE sal_uInt16 ImplCalcLines( ToolBox* pThis, long nToolSize );
     276             :     static SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( ToolBox* pThis, const Point& rPos );
     277             :     static SAL_DLLPRIVATE void ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRect, sal_uInt16 nLineMode );
     278             :     static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( ToolBox* pBox, const Point& rPos );
     279             :     static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList );
     280             :     SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight);
     281             :     SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow);
     282             :     static SAL_DLLPRIVATE sal_uInt16 ImplCountLineBreaks( const ToolBox *pThis );
     283        1031 :     SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData; }
     284             : 
     285             : protected:
     286             :     virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
     287           0 :     void SetCurItemId(sal_uInt16 nSet)
     288             :     {
     289           0 :         mnCurItemId = nSet;
     290           0 :     }
     291             : 
     292             : public:
     293             :                         ToolBox( vcl::Window* pParent, WinBits nStyle = 0 );
     294             :                         ToolBox( vcl::Window* pParent, const ResId& rResId );
     295             :     virtual             ~ToolBox();
     296             :     virtual void        dispose() SAL_OVERRIDE;
     297             : 
     298             :     virtual void        Click();
     299             :     void                DoubleClick();
     300             :     virtual void        Activate() SAL_OVERRIDE;
     301             :     virtual void        Deactivate() SAL_OVERRIDE;
     302             :     void                Highlight();
     303             :     virtual void        Select();
     304             : 
     305             :     virtual void        MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     306             :     virtual void        MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     307             :     virtual void        MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     308             :     virtual void        Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     309             :     virtual void        Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
     310             :     virtual void        Move() SAL_OVERRIDE;
     311             :     virtual void        Resize() SAL_OVERRIDE;
     312             :     virtual void        RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     313             :     virtual bool        Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     314             :     virtual void        Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
     315             :     virtual void        StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     316             :     virtual void        DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     317             : 
     318             :     virtual void        GetFocus() SAL_OVERRIDE;
     319             :     virtual void        LoseFocus() SAL_OVERRIDE;
     320             :     virtual void        KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     321             : 
     322             :     virtual bool        PrepareToggleFloatingMode() SAL_OVERRIDE;
     323             :     virtual void        ToggleFloatingMode() SAL_OVERRIDE;
     324             :     virtual void        StartDocking() SAL_OVERRIDE;
     325             :     virtual bool        Docking( const Point& rPos, Rectangle& rRect ) SAL_OVERRIDE;
     326             :     virtual void        EndDocking( const Rectangle& rRect, bool bFloatMode ) SAL_OVERRIDE;
     327             :     virtual void        Resizing( Size& rSize ) SAL_OVERRIDE;
     328             :     virtual Size        GetOptimalSize() const SAL_OVERRIDE;
     329             : 
     330             :     void                InsertItem( const ResId& rResId,
     331             :                                     sal_uInt16 nPos = TOOLBOX_APPEND );
     332             :     /// Insert a command (like '.uno:Save').
     333             :     virtual void        InsertItem( const OUString& rCommand,
     334             :                                     const css::uno::Reference<css::frame::XFrame>& rFrame,
     335             :                                     ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
     336             :                                     const Size& rRequestedSize = Size(),
     337             :                                     sal_uInt16 nPos = TOOLBOX_APPEND );
     338             :     void                InsertItem( sal_uInt16 nItemId, const Image& rImage,
     339             :                                     ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
     340             :                                     sal_uInt16 nPos = TOOLBOX_APPEND );
     341             :     void                InsertItem( sal_uInt16 nItemId, const Image& rImage,
     342             :                                     const OUString& rText,
     343             :                                     ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
     344             :                                     sal_uInt16 nPos = TOOLBOX_APPEND );
     345             :     void                InsertItem( sal_uInt16 nItemId, const OUString& rText,
     346             :                                     ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
     347             :                                     sal_uInt16 nPos = TOOLBOX_APPEND );
     348             :     void                InsertWindow( sal_uInt16 nItemId, vcl::Window* pWindow,
     349             :                                       ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
     350             :                                       sal_uInt16 nPos = TOOLBOX_APPEND );
     351             :     void                InsertSpace( sal_uInt16 nPos = TOOLBOX_APPEND );
     352             :     void                InsertSeparator( sal_uInt16 nPos = TOOLBOX_APPEND,
     353             :                                          sal_uInt16 nPixSize = 0 );
     354             :     void                InsertBreak( sal_uInt16 nPos = TOOLBOX_APPEND );
     355             :     void                RemoveItem( sal_uInt16 nPos );
     356             :     void                CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId,
     357             :                                   sal_uInt16 nNewPos = TOOLBOX_APPEND );
     358             :     void                Clear();
     359             : 
     360           1 :     const ImageList&    GetImageList() const { return maImageList; }
     361             :     void                SetImageList( const ImageList& rImageList );
     362             : 
     363             :     void                SetButtonType( ButtonType eNewType = ButtonType::SYMBOLONLY );
     364           0 :     ButtonType          GetButtonType() const { return meButtonType; }
     365             : 
     366             :     // sets a fixed button size (small, large or dontcare (==autosize))
     367             :     void                SetToolboxButtonSize( ToolBoxButtonSize eSize );
     368             :     ToolBoxButtonSize   GetToolboxButtonSize() const;
     369             : 
     370             :     void                SetAlign( WindowAlign eNewAlign = WINDOWALIGN_TOP );
     371      269778 :     WindowAlign         GetAlign() const { return meAlign; }
     372       36677 :     bool                IsHorizontal() const { return mbHorz; }
     373             : 
     374             :     void                SetLineCount( sal_uInt16 nNewLines );
     375             :     sal_uInt16          GetLineCount() const { return mnLines; }
     376             :     sal_uInt16          GetCurLine() const { return mnCurLine; }
     377             :     void                ShowLine( bool bNext );
     378             : 
     379             :     // Used to enable/disable scrolling one page at a time for toolbar
     380             :     void                SetPageScroll( bool b );
     381             : 
     382             :     sal_uInt16          GetItemCount() const;
     383             :     ToolBoxItemType     GetItemType( sal_uInt16 nPos ) const;
     384             :     sal_uInt16          GetItemPos( sal_uInt16 nItemId ) const;
     385             :     sal_uInt16          GetItemPos( const Point& rPos ) const;
     386             :     sal_uInt16          GetItemId( sal_uInt16 nPos ) const;
     387             :     sal_uInt16          GetItemId( const Point& rPos ) const;
     388             :     /// Map the command name (like .uno:Save) back to item id.
     389             :     sal_uInt16          GetItemId( const OUString& rCommand ) const;
     390             :     Rectangle           GetItemRect( sal_uInt16 nItemId ) const;
     391             :     Rectangle           GetItemPosRect( sal_uInt16 nPos ) const;
     392             : 
     393             :     /// Returns size of the bitmap / text that is inside this toolbox item.
     394             :     Size                GetItemContentSize( sal_uInt16 nItemId ) const;
     395             : 
     396             :     /// Retrieves the optimal position to place a popup window for this item (subtoolbar or dropdown)
     397             :     Point               GetItemPopupPosition( sal_uInt16 nItemId, const Size& rSize ) const;
     398             : 
     399             :     Rectangle           GetScrollRect() const;
     400          18 :     sal_uInt16          GetCurItemId() const { return mnCurItemId; }
     401           0 :     sal_uInt16          GetDownItemId() const { return mnDownItemId; }
     402             :     sal_uInt16          GetClicks() const { return mnMouseClicks; }
     403           2 :     sal_uInt16          GetModifier() const { return mnMouseModifier; }
     404           0 :     sal_uInt16          GetKeyModifier() const { return mnKeyModifier; }
     405             : 
     406             :     void                SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits );
     407             :     ToolBoxItemBits     GetItemBits( sal_uInt16 nItemId ) const;
     408             : 
     409             :     void                SetItemExpand( sal_uInt16 nItemId, bool bExpand );
     410             : 
     411             :     void                SetItemData( sal_uInt16 nItemId, void* pNewData );
     412             :     void*               GetItemData( sal_uInt16 nItemId ) const;
     413             :     void                SetItemImage( sal_uInt16 nItemId, const Image& rImage );
     414             :     Image               GetItemImage( sal_uInt16 nItemId ) const;
     415             :     Image               GetItemImageOriginal( sal_uInt16 nItemId ) const;
     416             :     void                SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 );
     417             :     void                SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror );
     418             :     void                SetItemText( sal_uInt16 nItemId, const OUString& rText );
     419             :     const OUString&     GetItemText( sal_uInt16 nItemId ) const;
     420             :     void                SetItemWindow( sal_uInt16 nItemId, vcl::Window* pNewWindow );
     421             :     vcl::Window*        GetItemWindow( sal_uInt16 nItemId ) const;
     422         797 :     sal_uInt16          GetHighlightItemId() const { return mnHighItemId; }
     423             : 
     424             :     void                StartSelection();
     425             :     void                EndSelection();
     426             : 
     427             :     void                SetItemDown( sal_uInt16 nItemId, bool bDown, bool bRelease = true );
     428             : 
     429             :     void                SetItemState( sal_uInt16 nItemId, TriState eState );
     430             :     TriState            GetItemState( sal_uInt16 nItemId ) const;
     431             : 
     432             :     void                CheckItem( sal_uInt16 nItemId, bool bCheck = true );
     433             :     bool                IsItemChecked( sal_uInt16 nItemId ) const;
     434             : 
     435             :     void                EnableItem( sal_uInt16 nItemId, bool bEnable = true );
     436             :     bool                IsItemEnabled( sal_uInt16 nItemId ) const;
     437             : 
     438             :     void                TriggerItem( sal_uInt16 nItemId, bool bShift = false, bool bCtrl = false );
     439             : 
     440             :     /// Shows or hides items.
     441             :     void                ShowItem(sal_uInt16 nItemId, bool bVisible = true);
     442             :     /// Overload to provide ShowItem via command id.
     443           0 :     void                ShowItem(const OUString& rCommand, bool bVisible = true) { ShowItem(GetItemId(rCommand), bVisible); }
     444             : 
     445             :     /// Convenience method to hide items (via ShowItem).
     446       18474 :     void                HideItem(sal_uInt16 nItemId) { ShowItem( nItemId, false ); }
     447             :     /// Overload to provide HideItem via command id.
     448           0 :     void                HideItem(const OUString& rCommand) { ShowItem(rCommand, false); }
     449             : 
     450             :     bool                IsItemVisible( sal_uInt16 nItemId ) const;
     451             :     bool                IsItemReallyVisible( sal_uInt16 nItemId ) const;
     452             : 
     453             :     void                SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand );
     454             :     const OUString      GetItemCommand( sal_uInt16 nItemId ) const;
     455             : 
     456             :     using Window::SetQuickHelpText;
     457             :     void                SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText );
     458             :     using Window::GetQuickHelpText;
     459             :     const OUString&     GetQuickHelpText( sal_uInt16 nItemId ) const;
     460             : 
     461             :     void                SetHelpText( sal_uInt16 nItemId, const OUString& rText );
     462             :     const OUString&     GetHelpText( sal_uInt16 nItemId ) const;
     463             : 
     464             :     void                SetHelpId( sal_uInt16 nItemId, const OString& rHelpId );
     465             :     OString             GetHelpId( sal_uInt16 nItemId ) const;
     466             : 
     467             :     //  window size according to current alignment, floating state and number of lines
     468             :     Size                CalcWindowSizePixel() const;
     469             :     //  window size according to current alignment, floating state and a given number of lines
     470             :     Size                CalcWindowSizePixel( sal_uInt16 nCalcLines ) const;
     471             :     //  window size according to current floating state and a given number of lines and a given alignment
     472             :     Size                CalcWindowSizePixel( sal_uInt16 nCalcLines, WindowAlign eAlign ) const;
     473             :     // floating window size according to number of lines (uses the number of line breaks)
     474             :     Size                CalcFloatingWindowSizePixel() const;
     475             :     // floating window size with a given number of lines
     476             :     Size                CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines ) const;
     477             :     // automatic window size for popoup mode
     478             :     Size                CalcPopupWindowSizePixel() const;
     479             : 
     480             :     // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button)
     481             :     Size                CalcMinimumWindowSizePixel() const;
     482             : 
     483             :     void                SetDockingRects( const Rectangle& rOutRect,
     484             :                                          const Rectangle& rInRect );
     485             :     void                SetFloatingLines( sal_uInt16 nFloatLines );
     486             :     sal_uInt16          GetFloatingLines() const;
     487             : 
     488             :     void                SetStyle( WinBits nNewStyle );
     489       78509 :     WinBits             GetStyle() const { return mnWinStyle; }
     490             : 
     491             :     // enable/disable undocking
     492             :     void                Lock( bool bLock = true );
     493             : 
     494             :     // read configuration to determine locking behaviour
     495             :     static bool         AlwaysLocked();
     496             : 
     497           7 :     void                EnableMenuStrings( bool bEnable = true ) { mbMenuStrings = bEnable; }
     498             :     bool                IsMenuStringsEnabled() const { return mbMenuStrings; }
     499             : 
     500             :     void                SetOutStyle( sal_uInt16 nNewStyle );
     501           0 :     sal_uInt16          GetOutStyle() const { return mnOutStyle; }
     502             : 
     503             :     void                EnableCustomize( bool bEnable = true );
     504           0 :     bool                IsCustomize() { return mbCustomize; }
     505             :     bool                IsInCustomizeMode() const { return mbCustomizeMode; }
     506             : 
     507             :     using DockingWindow::SetHelpText;
     508             :     using DockingWindow::GetHelpText;
     509             :     using DockingWindow::SetHelpId;
     510             :     using DockingWindow::GetHelpId;
     511             : 
     512       41171 :     void                SetClickHdl( const Link<ToolBox *, void>& rLink ) { maClickHdl = rLink; }
     513       41155 :     void                SetDoubleClickHdl( const Link<ToolBox *, void>& rLink ) { maDoubleClickHdl = rLink; }
     514             :     void                SetDropdownClickHdl( const Link<ToolBox *, void>& rLink );
     515       19192 :     void                SetActivateHdl( const Link<ToolBox *, void>& rLink ) { maActivateHdl = rLink; }
     516       19192 :     void                SetDeactivateHdl( const Link<ToolBox *, void>& rLink ) { maDeactivateHdl = rLink; }
     517       55151 :     void                SetSelectHdl( const Link<ToolBox *, void>& rLink ) { maSelectHdl = rLink; }
     518           0 :     const Link<ToolBox *, void>& GetSelectHdl() const { return maSelectHdl; }
     519       21789 :     void                SetCommandHdl( const Link<CommandEvent const *, void>& aLink ) { maCommandHandler = aLink; }
     520       21789 :     void                SetStateChangedHdl( const Link<StateChangedType const *, void>& aLink ) { maStateChangedHandler = aLink; }
     521       21789 :     void                SetDataChangedHdl( const Link<DataChangedEvent const *, void>& aLink ) { maDataChangedHandler = aLink; }
     522             : 
     523             :     // support for custom menu (eg for configuration)
     524             :     // note: this menu will also be used to display currently
     525             :     //       clipped toolbox items, so you should only touch
     526             :     //       items that you added by yourself
     527             :     //       the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START
     528             :     // to allow for customization of the menu the coresponding handler is called
     529             :     // when the menu button was clicked and before the menu is executed
     530             :     void                SetMenuType( sal_uInt16 aType = TOOLBOX_MENUTYPE_CUSTOMIZE );
     531             :     sal_uInt16          GetMenuType() const;
     532             :     bool                IsMenuEnabled() const;
     533             :     PopupMenu*          GetMenu() const;
     534             :     void                UpdateCustomMenu();
     535             :     void                SetMenuButtonHdl( const Link<ToolBox *, void>& rLink );
     536             : 
     537             :     // open custommenu
     538             :     void                ExecuteCustomMenu();
     539             : 
     540             :     // allow Click Handler to detect special key
     541             :     bool                IsShift() const { return mbIsShift; }
     542             :     // allow Click Handler to distinguish between mouse and key input
     543           0 :     bool                IsKeyEvent() const { return mbIsKeyEvent; }
     544             : 
     545             :     // allows framework to set/query the planned popupmode
     546             :     bool                WillUsePopupMode() const;
     547             :     void                WillUsePopupMode( bool b);
     548             : 
     549             :     // accessibility helpers
     550             : 
     551             :     // gets the displayed text
     552             :     OUString GetDisplayText() const SAL_OVERRIDE;
     553             :     // returns the bounding box for the character at index nIndex
     554             :     // where nIndex is relative to the starting index of the item
     555             :     // with id nItemId (in coordinates of the displaying window)
     556             :     Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ) const;
     557             :     // -1 is returned if no character is at that point
     558             :     // if an index is found the corresponding item id is filled in (else 0)
     559             :     long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const;
     560             : 
     561             :     static Size         GetDefaultImageSize(bool bLarge);
     562             :     Size                GetDefaultImageSize() const;
     563             :     void                ChangeHighlight( sal_uInt16 nPos );
     564             : 
     565             :     void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout );
     566             : };
     567             : 
     568       39782 : inline void ToolBox::CheckItem( sal_uInt16 nItemId, bool bCheck )
     569             : {
     570       39782 :     SetItemState( nItemId, (bCheck) ? TRISTATE_TRUE : TRISTATE_FALSE );
     571       39782 : }
     572             : 
     573        2089 : inline bool ToolBox::IsItemChecked( sal_uInt16 nItemId ) const
     574             : {
     575        2089 :     return (GetItemState( nItemId ) == TRISTATE_TRUE);
     576             : }
     577             : 
     578       28148 : inline Size ToolBox::CalcWindowSizePixel() const
     579             : {
     580       28148 :     return CalcWindowSizePixel( mnLines );
     581             : }
     582             : 
     583             : inline Rectangle ToolBox::GetScrollRect() const
     584             : {
     585             :     return maUpperRect.GetUnion( maLowerRect );
     586             : }
     587             : 
     588             : inline void ToolBox::SetDockingRects( const Rectangle& rOutRect,
     589             :                                       const Rectangle& rInRect )
     590             : {
     591             :     maOutDockRect = rOutRect;
     592             :     maInDockRect = rInRect;
     593             : }
     594             : 
     595           0 : inline void ToolBox::SetFloatingLines( sal_uInt16 nNewLines )
     596             : {
     597           0 :     mnFloatLines = nNewLines;
     598           0 : }
     599             : 
     600           0 : inline sal_uInt16 ToolBox::GetFloatingLines() const
     601             : {
     602           0 :     return mnFloatLines;
     603             : }
     604             : 
     605             : #endif // INCLUDED_VCL_TOOLBOX_HXX
     606             : 
     607             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11