LCOV - code coverage report
Current view: top level - include/svtools - ivctrl.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 19 39 48.7 %
Date: 2014-11-03 Functions: 19 28 67.9 %
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_SVTOOLS_IVCTRL_HXX
      21             : #define INCLUDED_SVTOOLS_IVCTRL_HXX
      22             : 
      23             : #include <svtools/svtdllapi.h>
      24             : #include <vcl/ctrl.hxx>
      25             : #include <tools/link.hxx>
      26             : #include <tools/contnr.hxx>
      27             : #include <vcl/image.hxx>
      28             : #include <vcl/seleng.hxx>
      29             : 
      30             : class ResId;
      31             : class Point;
      32             : class SvxIconChoiceCtrl_Impl;
      33             : class Image;
      34             : 
      35             : #define ICNVIEW_FLAG_POS_LOCKED     0x0001
      36             : #define ICNVIEW_FLAG_SELECTED       0x0002
      37             : #define ICNVIEW_FLAG_FOCUSED        0x0004
      38             : #define ICNVIEW_FLAG_IN_USE         0x0008
      39             : #define ICNVIEW_FLAG_CURSORED       0x0010 // Border around image
      40             : #define ICNVIEW_FLAG_POS_MOVED      0x0020 // Moved by Drag and Drop, but not logged
      41             : #define ICNVIEW_FLAG_DROP_TARGET    0x0040 // Set in QueryDrop
      42             : #define ICNVIEW_FLAG_BLOCK_EMPHASIS 0x0080 // Do not paint Emphasis
      43             : #define ICNVIEW_FLAG_USER1          0x0100
      44             : #define ICNVIEW_FLAG_USER2          0x0200
      45             : #define ICNVIEW_FLAG_PRED_SET       0x0400 // Predecessor moved
      46             : 
      47             : enum SvxIconChoiceCtrlTextMode
      48             : {
      49             :     IcnShowTextFull = 1,        //  Enlarge BoundRect southwards
      50             :     IcnShowTextShort,           // Shorten with "..."
      51             :     IcnShowTextSmart,           // Show all text (not implemented)
      52             :     IcnShowTextDontKnow         // Settings of the View
      53             : };
      54             : 
      55             : enum SvxIconChoiceCtrlPositionMode
      56             : {
      57             :     IcnViewPositionModeFree = 0,                // Free pixel-perfekt positioning
      58             :     IcnViewPositionModeAutoArrange = 1,         // Auto arrange
      59             :     IcnViewPositionModeAutoAdjust = 2,          // Auto adjust
      60             :     IcnViewPositionModeLast = IcnViewPositionModeAutoAdjust
      61             : };
      62             : 
      63             : class SvxIconChoiceCtrlEntry
      64             : {
      65             :     Image aImage;
      66             : 
      67             :     OUString aText;
      68             :     OUString aQuickHelpText;
      69             :     void*  pUserData;
      70             : 
      71             :     friend class SvxIconChoiceCtrl_Impl;
      72             :     friend class IcnCursor_Impl;
      73             :     friend class EntryList_Impl;
      74             :     friend class IcnGridMap_Impl;
      75             : 
      76             :     Rectangle               aRect;              // Bounding-Rect of the entry
      77             :     Rectangle               aGridRect;          // Only valid in Grid-mode
      78             :     sal_uLong                   nPos;
      79             : 
      80             :     /*
      81             :         The insert position in the Insertlist is equal to the (sort) order stated at the Insert
      82             :         (-> Order of the anchors in the anchors-list!). In "AutoArrange" mode the visible order
      83             :         can differ. The entries will be linked because of this.
      84             :     */
      85             :     SvxIconChoiceCtrlEntry*         pblink;     // backward (linker neighbour)
      86             :     SvxIconChoiceCtrlEntry*         pflink;     // forward  (rechter neighbour)
      87             : 
      88             :     SvxIconChoiceCtrlTextMode       eTextMode;
      89             :     sal_uInt16                  nX,nY;      // for keyboard control
      90             :     sal_uInt16                  nFlags;
      91             : 
      92         534 :     void                    ClearFlags( sal_uInt16 nMask ) { nFlags &= (~nMask); }
      93          18 :     void                    SetFlags( sal_uInt16 nMask ) { nFlags |= nMask; }
      94           6 :     void                    AssignFlags( sal_uInt16 _nFlags ) { nFlags = _nFlags; }
      95             : 
      96             :     // set left neighbour (A <-> B  ==>  A <-> this <-> B)
      97           0 :     void                    SetBacklink( SvxIconChoiceCtrlEntry* pA )
      98             :                             {
      99           0 :                                 pA->pflink->pblink = this;      // X <- B
     100           0 :                                 this->pflink = pA->pflink;      // X -> B
     101           0 :                                 this->pblink = pA;              // A <- X
     102           0 :                                 pA->pflink = this;              // A -> X
     103           0 :                             }
     104             :     // Unlink (A <-> this <-> B  ==>  A <-> B)
     105           0 :     void                    Unlink()
     106             :                             {
     107           0 :                                 this->pblink->pflink = this->pflink;
     108           0 :                                 this->pflink->pblink = this->pblink;
     109           0 :                                 this->pflink = 0;
     110           0 :                                 this->pblink = 0;
     111           0 :                             }
     112             : 
     113             : public:
     114             :                             SvxIconChoiceCtrlEntry( const OUString& rText, const Image& rImage, sal_uInt16 nFlags = 0 );
     115          48 :                             ~SvxIconChoiceCtrlEntry () {}
     116             : 
     117             :     void                    SetImage ( const Image& rImage ) { aImage = rImage; }
     118          54 :     Image                   GetImage () const { return aImage; }
     119          64 :     void                    SetText ( const OUString& rText ) { aText = rText; }
     120         320 :     OUString                GetText () const { return aText; }
     121             :     OUString SVT_DLLPUBLIC  GetDisplayText() const;
     122           0 :     void                    SetQuickHelpText( const OUString& rText ) { aQuickHelpText = rText; }
     123           0 :     OUString                GetQuickHelpText() const { return aQuickHelpText; }
     124         112 :     void                    SetUserData ( void* _pUserData ) { pUserData = _pUserData; }
     125         408 :     void*                   GetUserData () { return pUserData; }
     126             : 
     127             :     const Rectangle &       GetBoundRect() const { return aRect; }
     128             : 
     129             :     void                    SetFocus ( bool bSet )
     130             :                                      { nFlags = ( bSet ? nFlags | ICNVIEW_FLAG_FOCUSED : nFlags & ~ICNVIEW_FLAG_FOCUSED ); }
     131             : 
     132         138 :     SvxIconChoiceCtrlTextMode   GetTextMode() const { return eTextMode; }
     133         222 :     sal_uInt16              GetFlags() const { return nFlags; }
     134        1146 :     bool                    IsSelected() const { return ((nFlags & ICNVIEW_FLAG_SELECTED) !=0); }
     135          78 :     bool                    IsFocused() const { return ((nFlags & ICNVIEW_FLAG_FOCUSED) !=0); }
     136             :     bool                    IsInUse() const { return ((nFlags & ICNVIEW_FLAG_IN_USE) !=0); }
     137          54 :     bool                    IsCursored() const { return ((nFlags & ICNVIEW_FLAG_CURSORED) !=0); }
     138          54 :     bool                    IsDropTarget() const { return ((nFlags & ICNVIEW_FLAG_DROP_TARGET) !=0); }
     139          54 :     bool                    IsBlockingEmphasis() const { return ((nFlags & ICNVIEW_FLAG_BLOCK_EMPHASIS) !=0); }
     140        1120 :     bool                    IsPosLocked() const { return ((nFlags & ICNVIEW_FLAG_POS_LOCKED) !=0); }
     141             :     // Only set at AutoArrange. The head of the list is accessible via SvxIconChoiceCtrl::GetPredecessorHead
     142             :     SvxIconChoiceCtrlEntry*         GetSuccessor() const { return pflink; }
     143             :     SvxIconChoiceCtrlEntry*         GetPredecessor() const { return pblink; }
     144             : 
     145             : //  sal_Unicode             GetMnemonicChar() const;
     146             : };
     147             : 
     148             : enum SvxIconChoiceCtrlColumnAlign
     149             : {
     150             :     IcnViewAlignLeft = 1,
     151             :     IcnViewAlignRight,
     152             :     IcnViewAlignCenter
     153             : };
     154             : 
     155           0 : class SvxIconChoiceCtrlColumnInfo
     156             : {
     157             :     OUString                aColText;
     158             :     Image                   aColImage;
     159             :     long                    nWidth;
     160             :     SvxIconChoiceCtrlColumnAlign    eAlignment;
     161             :     sal_uInt16                  nSubItem;
     162             : 
     163             : public:
     164           0 :                             SvxIconChoiceCtrlColumnInfo( sal_uInt16 nSub, long nWd,
     165             :                                 SvxIconChoiceCtrlColumnAlign eAlign ) :
     166           0 :                                 nWidth( nWd ), eAlignment( eAlign ), nSubItem( nSub ) {}
     167             :                             SvxIconChoiceCtrlColumnInfo( const SvxIconChoiceCtrlColumnInfo& );
     168             : 
     169             :     void                    SetText( const OUString& rText ) { aColText = rText; }
     170             :     void                    SetImage( const Image& rImg ) { aColImage = rImg; }
     171           0 :     void                    SetWidth( long nWd ) { nWidth = nWd; }
     172             :     void                    SetAlignment( SvxIconChoiceCtrlColumnAlign eAlign ) { eAlignment = eAlign; }
     173             :     void                    SetSubItem( sal_uInt16 nSub) { nSubItem = nSub; }
     174             : 
     175             :     const OUString&         GetText() const { return aColText; }
     176             :     const Image&            GetImage() const { return aColImage; }
     177           0 :     long                    GetWidth() const { return nWidth; }
     178             :     SvxIconChoiceCtrlColumnAlign    GetAlignment() const { return eAlignment; }
     179             :     sal_uInt16                  GetSubItem() const { return nSubItem; }
     180             : };
     181             : 
     182             : 
     183             : /*
     184             :     Window-Bits:
     185             :         WB_ICON             // Text beneth the icon
     186             :         WB_SMALL_ICON       // Text right to the icon, position does not mind
     187             :         WB_DETAILS          // Text right to the icon, limited positioning
     188             :         WB_BORDER
     189             :         WB_NOHIDESELECTION  // Draw selection inaktively, if not focused.
     190             :         WB_NOHSCROLL
     191             :         WB_NOVSCROLL
     192             :         WB_NOSELECTION
     193             :         WB_SMART_ARRANGE    // Keep Vis-Area at arrange
     194             :         WB_ALIGN_TOP        // Align line vy line LTR
     195             :         WB_ALIGN_LEFT       // Align columns from top to bottom
     196             :         WB_NODRAGSELECTION  // No selection with tracking rectangle
     197             :         WB_NOCOLUMNHEADER   // No Headerbar in Details view (Headerbar not implemented)
     198             :         WB_NOPOINTERFOCUS   // No GrabFocus at MouseButtonDown
     199             :         WB_HIGHLIGHTFRAME   // The entry beneth the mouse willbe highlighted
     200             :         WB_NOASYNCSELECTHDL // Do not collect events -> Selection handlers will be called synchronously
     201             : */
     202             : 
     203             : #define WB_ICON                 WB_RECTSTYLE
     204             : #define WB_SMALLICON            WB_SMALLSTYLE
     205             : #define WB_DETAILS              WB_VCENTER
     206             : #define WB_NOHSCROLL            WB_SPIN
     207             : #define WB_NOVSCROLL            WB_DRAG
     208             : #define WB_NOSELECTION          WB_REPEAT
     209             : #define WB_NODRAGSELECTION      WB_PATHELLIPSIS
     210             : #define WB_SMART_ARRANGE        WB_PASSWORD
     211             : #define WB_ALIGN_TOP            WB_TOP
     212             : #define WB_ALIGN_LEFT           WB_LEFT
     213             : #define WB_NOCOLUMNHEADER       WB_CENTER
     214             : #define WB_HIGHLIGHTFRAME       WB_INFO
     215             : #define WB_NOASYNCSELECTHDL     WB_NOLABEL
     216             : 
     217             : class MnemonicGenerator;
     218             : 
     219             : class SVT_DLLPUBLIC SvtIconChoiceCtrl : public Control
     220             : {
     221             :     friend class SvxIconChoiceCtrl_Impl;
     222             : 
     223             :     Link                    _aClickIconHdl;
     224             :     Link                    _aDocRectChangedHdl;
     225             :     Link                    _aVisRectChangedHdl;
     226             :     KeyEvent*               _pCurKeyEvent;
     227             :     SvxIconChoiceCtrl_Impl* _pImp;
     228             :     bool                    _bAutoFontColor;
     229             : 
     230             : protected:
     231             : 
     232             :     virtual void        KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     233             :     virtual bool        EditedEntry( SvxIconChoiceCtrlEntry*, const OUString& rNewText, bool bCancelled );
     234             :     virtual void        DocumentRectChanged();
     235             :     virtual void        VisibleRectChanged();
     236             :     virtual bool        EditingEntry( SvxIconChoiceCtrlEntry* pEntry );
     237             :     virtual void        Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
     238             :     virtual void        Paint( const Rectangle& rRect ) SAL_OVERRIDE;
     239             :     virtual void        MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     240             :     virtual void        MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     241             :     virtual void        MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     242             :     virtual void        Resize() SAL_OVERRIDE;
     243             :     virtual void        GetFocus() SAL_OVERRIDE;
     244             :     virtual void        LoseFocus() SAL_OVERRIDE;
     245             :     virtual void        ClickIcon();
     246             :     virtual void        StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     247             :     virtual void        DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     248             :     virtual void        RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     249             :     virtual void        DrawEntryImage(
     250             :                             SvxIconChoiceCtrlEntry* pEntry,
     251             :                             const Point& rPos,
     252             :                             OutputDevice& rDev );
     253             : 
     254             :     OUString            GetEntryText(
     255             :                             SvxIconChoiceCtrlEntry* pEntry,
     256             :                             bool bInplaceEdit );
     257             : 
     258             :     virtual void        FillLayoutData() const SAL_OVERRIDE;
     259             : 
     260             :     void                CallImplEventListeners(sal_uLong nEvent, void* pData);
     261             : 
     262             : public:
     263             : 
     264             :                         SvtIconChoiceCtrl( vcl::Window* pParent, WinBits nWinStyle = WB_ICON | WB_BORDER );
     265             :     virtual             ~SvtIconChoiceCtrl();
     266             : 
     267             :     void                SetStyle( WinBits nWinStyle );
     268             :     WinBits             GetStyle() const;
     269             : 
     270             :     bool                SetChoiceWithCursor ( bool bDo = true );
     271             : 
     272             :     void                SetFont( const vcl::Font& rFont );
     273             :     void                SetPointFont( const vcl::Font& rFont );
     274             : 
     275          16 :     void                SetClickHdl( const Link& rLink ) { _aClickIconHdl = rLink; }
     276           0 :     const Link&         GetClickHdl() const { return _aClickIconHdl; }
     277             : 
     278             :     using OutputDevice::SetBackground;
     279             :     void                SetBackground( const Wallpaper& rWallpaper );
     280             : 
     281             :     void                ArrangeIcons();
     282             : 
     283             : 
     284             :     SvxIconChoiceCtrlEntry* InsertEntry( const OUString& rText,
     285             :                                          const Image& rImage,
     286             :                                          sal_uLong nPos = CONTAINER_APPEND,
     287             :                                          const Point* pPos = 0,
     288             :                                          sal_uInt16 nFlags = 0
     289             :                                        );
     290             : 
     291             :     /** creates automatic mnemonics for all icon texts in the control
     292             : 
     293             :     @param _rUsedMnemonics
     294             :         a MnemonicGenerator at which some other mnemonics are already registered.
     295             :         This can be used if the control needs to share the "mnemonic space" with other elements,
     296             :         such as a menu bar.
     297             :     */
     298             :     void                CreateAutoMnemonics( MnemonicGenerator& _rUsedMnemonics );
     299             : 
     300             :     bool                DoKeyInput( const KeyEvent& rKEvt );
     301             : 
     302             :     bool                IsEntryEditing() const;
     303             : 
     304             :     sal_uLong                   GetEntryCount() const;
     305             :     SvxIconChoiceCtrlEntry* GetEntry( sal_uLong nPos ) const;
     306             :     sal_uLong                   GetEntryListPos( SvxIconChoiceCtrlEntry* pEntry ) const;
     307             :     using Window::SetCursor;
     308             :     void                    SetCursor( SvxIconChoiceCtrlEntry* pEntry );
     309             :     SvxIconChoiceCtrlEntry* GetCursor() const;
     310             : 
     311             :     // Re-calculation of cached view-data and invalidatiopn of those in the view
     312             :     void                    InvalidateEntry( SvxIconChoiceCtrlEntry* pEntry );
     313             : 
     314             :     // bHit == false: Entry is selectd, if the BoundRect is selected
     315             :     //      == true : Bitmap or Text must be selected
     316             :     SvxIconChoiceCtrlEntry* GetEntry( const Point& rPosPixel, bool bHit = false ) const;
     317             : 
     318             :     // sal_uLong is the position of the selected element in the list
     319             :     SvxIconChoiceCtrlEntry* GetSelectedEntry( sal_uLong& rPos ) const;
     320             : 
     321             : #ifdef DBG_UTIL
     322             :     void                        SetEntryTextMode( SvxIconChoiceCtrlTextMode eMode, SvxIconChoiceCtrlEntry* pEntry = 0 );
     323             : #endif
     324             : 
     325             :     virtual bool        HasBackground() const;
     326             :     virtual bool        HasFont() const;
     327             :     virtual bool        HasFontTextColor() const;
     328             :     virtual bool        HasFontFillColor() const;
     329             : 
     330             :     void                SetFontColorToBackground ( bool bDo = true ) { _bAutoFontColor = bDo; }
     331         108 :     bool                AutoFontColor () { return _bAutoFontColor; }
     332             : 
     333             :     Point               GetPixelPos( const Point& rPosLogic ) const;
     334             :     void                SetSelectionMode( SelectionMode eMode );
     335             : 
     336             :     Rectangle           GetBoundingBox( SvxIconChoiceCtrlEntry* pEntry ) const;
     337             :     Rectangle           GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const;
     338             : 
     339             :     void                SetNoSelection();
     340             : 
     341             :     // ACCESSIBILITY ==========================================================
     342             : 
     343             :     /** Creates and returns the accessible object of the Box. */
     344             :     virtual ::com::sun::star::uno::Reference<
     345             :         ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
     346             : };
     347             : 
     348             : #endif // INCLUDED_SVTOOLS_IVCTRL_HXX
     349             : 
     350             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10