LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/inc - svimpbox.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 53 0.0 %
Date: 2012-12-27 Functions: 0 26 0.0 %
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 _SVIMPLBOX_HXX
      21             : #define _SVIMPLBOX_HXX
      22             : 
      23             : #include <vcl/seleng.hxx>
      24             : #include <vcl/scrbar.hxx>
      25             : #include <vcl/vclevent.hxx>
      26             : // #102891# ----------------
      27             : #include <unotools/intlwrapper.hxx>
      28             : // #97680# -----------------
      29             : #include <vector>
      30             : #include "svtaccessiblefactory.hxx"
      31             : 
      32             : class SvTreeListBox;
      33             : class Point;
      34             : class SvTreeList;
      35             : class SvImpLBox;
      36             : class SvTreeListEntry;
      37             : class SvLBoxTab;
      38             : namespace comphelper
      39             : {
      40             :     namespace string
      41             :     {
      42             :         class NaturalStringSorter;
      43             :     }
      44             : }
      45             : 
      46             : class ImpLBSelEng : public FunctionSet
      47             : {
      48             :     SvImpLBox*          pImp;
      49             :     SelectionEngine*    pSelEng;
      50             :     SvTreeListBox*      pView;
      51             : 
      52             : public:
      53             :     ImpLBSelEng( SvImpLBox* pImp, SelectionEngine* pSelEng,
      54             :                  SvTreeListBox* pView );
      55             :     virtual ~ImpLBSelEng();
      56             :     void        BeginDrag();
      57             :     void        CreateAnchor();
      58             :     void        DestroyAnchor();
      59             :     sal_Bool        SetCursorAtPoint( const Point& rPoint,
      60             :                     sal_Bool bDontSelectAtCursor=sal_False );
      61             :     sal_Bool        IsSelectionAtPoint( const Point& rPoint );
      62             :     void        DeselectAtPoint( const Point& rPoint );
      63             :     void        DeselectAll();
      64             : };
      65             : 
      66             : // Flags fuer nFlag
      67             : #define F_VER_SBARSIZE_WITH_HBAR        0x0001
      68             : #define F_HOR_SBARSIZE_WITH_VBAR        0x0002
      69             : #define F_IGNORE_NEXT_MOUSEMOVE         0x0004  // OS/2 only
      70             : #define F_IN_SCROLLING                  0x0008
      71             : #define F_DESEL_ALL                     0x0010
      72             : #define F_START_EDITTIMER               0x0020  // MAC only
      73             : #define F_IGNORE_SELECT                 0x0040
      74             : #define F_IN_RESIZE                     0x0080
      75             : #define F_REMOVED_ENTRY_INVISIBLE       0x0100
      76             : #define F_REMOVED_RECALC_MOST_RIGHT     0x0200
      77             : #define F_IGNORE_CHANGED_TABS           0x0400
      78             : #define F_PAINTED                       0x0800
      79             : #define F_IN_PAINT                      0x1000
      80             : #define F_ENDSCROLL_SET_VIS_SIZE        0x2000
      81             : #define F_FILLING                       0x4000
      82             : 
      83             : 
      84             : class SvImpLBox
      85             : {
      86             : friend class ImpLBSelEng;
      87             : friend class SvTreeListBox;
      88             : private:
      89             :     SvTreeListBox*      pView;
      90             :     SvTreeList*     pTree;
      91             :     SvTreeListEntry*        pCursor;
      92             :     SvTreeListEntry*        pStartEntry;
      93             :     SvTreeListEntry*        pAnchor;
      94             :     SvTreeListEntry*        pMostRightEntry;
      95             :     SvLBoxButton*       pActiveButton;
      96             :     SvTreeListEntry*        pActiveEntry;
      97             :     SvLBoxTab*          pActiveTab;
      98             : 
      99             :     ScrollBar           aVerSBar;
     100             :     ScrollBar           aHorSBar;
     101             :     ScrollBarBox        aScrBarBox;
     102             : 
     103             :     ::svt::AccessibleFactoryAccess
     104             :                         m_aFactoryAccess;
     105             : 
     106             :     static Image*       s_pDefCollapsed;
     107             :     static Image*       s_pDefExpanded;
     108             :     static oslInterlockedCount  s_nImageRefCount; /// When 0 all static images will be destroyed
     109             : 
     110             :     // Node Bitmaps
     111             :     enum ImageType
     112             :     {
     113             :         itNodeExpanded = 0,     // node is expanded ( usually a bitmap showing a minus )
     114             :         itNodeCollapsed,        // node is collapsed ( usually a bitmap showing a plus )
     115             :         itNodeDontKnow,         // don't know the node state
     116             :         itEntryDefExpanded,     // default for expanded entries
     117             :         itEntryDefCollapsed,    // default for collapsed entries
     118             : 
     119             :         IT_IMAGE_COUNT
     120             :     };
     121             : 
     122             :     // all our images
     123             :     Image               m_aNodeAndEntryImages[ IT_IMAGE_COUNT ];
     124             : 
     125             :     // wg. kompat. hier
     126             :     Size                aOutputSize;
     127             :     SelectionEngine     aSelEng;
     128             :     ImpLBSelEng         aFctSet;
     129             :     Timer               aAsyncBeginDragTimer;
     130             :     Point               aAsyncBeginDragPos;
     131             : 
     132             :     long                nYoffsNodeBmp;
     133             :     long                nNodeBmpTabDistance; // typisch kleiner 0
     134             :     long                nNodeBmpWidth;
     135             :     long                nNextVerVisSize;
     136             :     long                nMostRight;
     137             :     sal_uLong               nVisibleCount;  // Anzahl Zeilen im Control
     138             :     sal_uLong               nCurUserEvent; //-1 == kein Userevent amn Laufen
     139             :     short               nHorSBarHeight, nVerSBarWidth;
     140             :     sal_uInt16              nFlags;
     141             :     sal_uInt16              nCurTabPos;
     142             : 
     143             :     WinBits             m_nStyle;
     144             :     ExtendedWinBits     nExtendedWinBits;
     145             :     bool                bSimpleTravel : 1; // ist true bei SINGLE_SELECTION
     146             :     bool                bUpdateMode : 1;
     147             :     bool                bInVScrollHdl : 1;
     148             :     bool                bAsyncBeginDrag : 1;
     149             :     bool                bSubLstOpRet : 1;   // open/close sublist with return/enter, defaulted with false
     150             :     bool                bSubLstOpLR : 1;    // open/close sublist with cursor left/right, defaulted with false
     151             :     bool                bContextMenuHandling : 1;
     152             :     bool                bIsCellFocusEnabled : 1;
     153             : 
     154             :     bool                bAreChildrenTransient;
     155             : 
     156             :     Point               aEditClickPos;
     157             :     Timer               aEditTimer;
     158             : 
     159             :     // #102891# -------------------
     160             :     comphelper::string::NaturalStringSorter *m_pStringSorter;
     161             : 
     162             :     // #97680# --------------------
     163             :     std::vector< short > aContextBmpWidthVector;
     164             : 
     165             :     DECL_LINK(EditTimerCall, void *);
     166             : 
     167             :     DECL_LINK( BeginDragHdl, void* );
     168             :     DECL_LINK( MyUserEvent,void*);
     169             :     void                StopUserEvent();
     170             : 
     171             :     void                InvalidateEntriesFrom( long nY ) const;
     172             :     void                InvalidateEntry( long nY ) const;
     173             :     void                ShowVerSBar();
     174             :     // setzt Thumb auf FirstEntryToDraw
     175             :     void                SyncVerThumb();
     176             :     bool                IsLineVisible( long nY ) const;
     177             :     long                GetEntryLine( SvTreeListEntry* pEntry ) const;
     178             :     void                FillView();
     179             :     void                CursorDown();
     180             :     void                CursorUp();
     181             :     void                KeyLeftRight( long nDiff );
     182             :     void                PageDown( sal_uInt16 nDelta );
     183             :     void                PageUp( sal_uInt16 nDelta );
     184             : 
     185             :     void                SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false );
     186             : 
     187             :     void                DrawNet();
     188             : 
     189             :     // ScrollBar-Handler
     190             :     DECL_LINK( ScrollUpDownHdl, ScrollBar * );
     191             :     DECL_LINK( ScrollLeftRightHdl, ScrollBar * );
     192             :     DECL_LINK( EndScrollHdl, void * );
     193             : 
     194             :     void                SetNodeBmpYOffset( const Image& );
     195             :     void                SetNodeBmpTabDistance();
     196             : 
     197             :     // Selection-Engine
     198             :     SvTreeListEntry* MakePointVisible( const Point& rPoint, bool bNotifyScroll=true );
     199             : 
     200             :     void                SetAnchorSelection( SvTreeListEntry* pOld,
     201             :                             SvTreeListEntry* pNewCursor );
     202             :     void                BeginDrag();
     203             :     bool ButtonDownCheckCtrl( const MouseEvent& rMEvt, SvTreeListEntry* pEntry, long nY );
     204             :     bool MouseMoveCheckCtrl( const MouseEvent& rMEvt, SvTreeListEntry* pEntry );
     205             :     bool ButtonUpCheckCtrl( const MouseEvent& rMEvt );
     206             :     bool ButtonDownCheckExpand( const MouseEvent&, SvTreeListEntry*,long nY );
     207             : 
     208             :     void                PositionScrollBars( Size& rOSize, sal_uInt16 nMask );
     209             :     sal_uInt16              AdjustScrollBars( Size& rSize );
     210             : 
     211             :     void                BeginScroll();
     212             :     void                EndScroll();
     213             :     bool InScroll() const { return (nFlags & F_IN_SCROLLING) != 0; }
     214             :     Rectangle           GetVisibleArea() const;
     215             :     bool EntryReallyHit(SvTreeListEntry* pEntry, const Point& rPos, long nLine);
     216             :     void                InitScrollBarBox();
     217             :     SvLBoxTab*          NextTab( SvLBoxTab* );
     218             : 
     219             :     bool SetMostRight( SvTreeListEntry* pEntry );
     220             :     void                FindMostRight( SvTreeListEntry* EntryToIgnore );
     221             :     void                FindMostRight( SvTreeListEntry* pParent, SvTreeListEntry* EntryToIgnore );
     222             :     void                FindMostRight_Impl( SvTreeListEntry* pParent,SvTreeListEntry* EntryToIgnore  );
     223             :     void                NotifyTabsChanged();
     224             : 
     225             :     // if element at cursor can be expanded in general
     226             :     bool IsExpandable() const;
     227             : 
     228             :     // if element at cursor can be expanded at this moment
     229             :     bool IsNowExpandable() const;
     230             : 
     231             :     static  void        implInitDefaultNodeImages();
     232             : 
     233             :     void UpdateStringSorter();
     234             : 
     235             :     // #97680# --------------------
     236             :     short               UpdateContextBmpWidthVector( SvTreeListEntry* pEntry, short nWidth );
     237             :     void                UpdateContextBmpWidthMax( SvTreeListEntry* pEntry );
     238             :     void                UpdateContextBmpWidthVectorFromMovedEntry( SvTreeListEntry* pEntry );
     239             : 
     240             :     void                CalcCellFocusRect( SvTreeListEntry* pEntry, Rectangle& rRect );
     241             : 
     242           0 :     bool AreChildrenTransient() const { return bAreChildrenTransient; }
     243           0 :     inline void         SetChildrenNotTransient() { bAreChildrenTransient = false; }
     244             : 
     245             : public:
     246             :     SvImpLBox( SvTreeListBox* pView, SvTreeList*, WinBits nWinStyle );
     247             :     ~SvImpLBox();
     248             : 
     249             :     void                Clear();
     250             :     void                SetStyle( WinBits i_nWinStyle );
     251             :     void                SetExtendedWindowBits( ExtendedWinBits _nBits );
     252             :     ExtendedWinBits     GetExtendedWindowBits() const { return nExtendedWinBits; }
     253           0 :     void                SetModel( SvTreeList* pModel ) { pTree = pModel;}
     254             : 
     255             :     void                EntryInserted( SvTreeListEntry*);
     256             :     void                RemovingEntry( SvTreeListEntry* pEntry );
     257             :     void                EntryRemoved();
     258             :     void                MovingEntry( SvTreeListEntry* pEntry );
     259             :     void                EntryMoved( SvTreeListEntry* pEntry );
     260             :     void                TreeInserted( SvTreeListEntry* pEntry );
     261             : 
     262             :     void                EntryExpanded( SvTreeListEntry* pEntry );
     263             :     void                EntryCollapsed( SvTreeListEntry* pEntry );
     264             :     void                CollapsingEntry( SvTreeListEntry* pEntry );
     265             :     void                EntrySelected( SvTreeListEntry* pEntry, bool bSelect );
     266             : 
     267             :     void                Paint( const Rectangle& rRect );
     268             :     void                MouseButtonDown( const MouseEvent& );
     269             :     void                MouseButtonUp( const MouseEvent& );
     270             :     void                MouseMove( const MouseEvent&);
     271             :     bool                KeyInput( const KeyEvent& );
     272             :     void                Resize();
     273             :     void                GetFocus();
     274             :     void                LoseFocus();
     275             :     void UpdateAll( bool bInvalidateCompleteView= true, bool bUpdateVerSBar = true );
     276             :     void                SetEntryHeight( short nHeight );
     277             :     void                PaintEntry( SvTreeListEntry* pEntry );
     278             :     void                InvalidateEntry( SvTreeListEntry* );
     279             :     void                RecalcFocusRect();
     280             : 
     281             :     void SelectEntry( SvTreeListEntry* pEntry, bool bSelect );
     282             :     void                SetDragDropMode( DragDropMode eDDMode );
     283             :     void                SetSelectionMode( SelectionMode eSelMode  );
     284             : 
     285             :     SvTreeListEntry*        GetCurrentEntry() const { return pCursor; }
     286             :     bool IsEntryInView( SvTreeListEntry* pEntry ) const;
     287             :     SvTreeListEntry*        GetEntry( const Point& rPos ) const;
     288             :     // gibt letzten Eintrag zurueck, falls Pos unter letztem Eintrag
     289             :     SvTreeListEntry*        GetClickedEntry( const Point& ) const;
     290           0 :     SvTreeListEntry*        GetCurEntry() const { return pCursor; }
     291             :     void                SetCurEntry( SvTreeListEntry* );
     292             :     Point               GetEntryPosition( SvTreeListEntry* ) const;
     293             :     void                MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop = false );
     294             :     void                ScrollToAbsPos( long nPos );
     295             : 
     296             :     void                PaintDDCursor( SvTreeListEntry* );
     297             : 
     298             :     // Images
     299             :     inline Image&       implGetImageLocation( const ImageType _eType );
     300             : 
     301             :     inline void         SetExpandedNodeBmp(  const Image& _rImg );
     302             :     inline void         SetCollapsedNodeBmp( const Image& _rImg );
     303             : 
     304             :     inline const Image& GetExpandedNodeBmp( );
     305             :     inline const Image& GetCollapsedNodeBmp( );
     306             :     inline const Image& GetDontKnowNodeBmp( );
     307             : 
     308             :     inline void         SetDefaultEntryExpBmp( const Image& _rImg );
     309             :     inline void         SetDefaultEntryColBmp( const Image& _rImg );
     310             :     inline const Image& GetDefaultEntryExpBmp( );
     311             :     inline const Image& GetDefaultEntryColBmp( );
     312             : 
     313             :     static const Image& GetDefaultExpandedNodeImage( );
     314             :     static const Image& GetDefaultCollapsedNodeImage( );
     315             : 
     316           0 :     const Size&         GetOutputSize() const { return aOutputSize;}
     317             :     void                KeyUp( bool bPageUp, bool bNotifyScroll = true );
     318             :     void                KeyDown( bool bPageDown, bool bNotifyScroll = true );
     319             :     void                Command( const CommandEvent& rCEvt );
     320             : 
     321             :     void                Invalidate();
     322           0 :     void                DestroyAnchor() { pAnchor=0; aSelEng.Reset(); }
     323             :     void SelAllDestrAnch( bool bSelect, bool bDestroyAnchor = true, bool bSingleSelToo = false );
     324             :     void ShowCursor( bool bShow );
     325             : 
     326             :     bool RequestHelp( const HelpEvent& rHEvt );
     327             :     void                EndSelection();
     328             :     bool IsNodeButton( const Point& rPosPixel, SvTreeListEntry* pEntry ) const;
     329             :     void                RepaintScrollBars();
     330           0 :     void EnableAsyncDrag( bool b ) { bAsyncBeginDrag = b; }
     331             :     void SetUpdateMode( bool bMode );
     332           0 :     bool GetUpdateMode() const { return bUpdateMode; }
     333             :     Rectangle           GetClipRegionRect() const;
     334           0 :     bool HasHorScrollBar() const { return aHorSBar.IsVisible(); }
     335             :     void                ShowFocusRect( const SvTreeListEntry* pEntry );
     336             :     void                CallEventListeners( sal_uLong nEvent, void* pData = NULL );
     337             : 
     338             :     /** Enables, that one cell of a tablistbox entry can be focused */
     339           0 :     bool IsCellFocusEnabled() const { return bIsCellFocusEnabled; }
     340           0 :     inline void         EnableCellFocus() { bIsCellFocusEnabled = true; }
     341             :     bool                SetCurrentTabPos( sal_uInt16 _nNewPos );
     342           0 :     inline sal_uInt16       GetCurrentTabPos() const { return nCurTabPos; }
     343             : 
     344             :     bool                IsSelectable( const SvTreeListEntry* pEntry );
     345             : };
     346             : 
     347           0 : inline Image& SvImpLBox::implGetImageLocation( const ImageType _eType )
     348             : {
     349             :     DBG_ASSERT( ( _eType >= 0 ) && ( _eType < IT_IMAGE_COUNT ),
     350             :         "SvImpLBox::implGetImageLocation: invalid image index (will crash)!" );
     351             : 
     352           0 :     Image* _pSet = m_aNodeAndEntryImages;
     353           0 :     return *( _pSet + (sal_Int32)_eType );
     354             : }
     355             : 
     356           0 : inline void SvImpLBox::SetExpandedNodeBmp( const Image& rImg )
     357             : {
     358           0 :     implGetImageLocation( itNodeExpanded ) = rImg;
     359           0 :     SetNodeBmpYOffset( rImg );
     360           0 : }
     361             : 
     362           0 : inline void SvImpLBox::SetCollapsedNodeBmp( const Image& rImg )
     363             : {
     364           0 :     implGetImageLocation( itNodeCollapsed ) = rImg;
     365           0 :     SetNodeBmpYOffset( rImg );
     366           0 : }
     367             : 
     368           0 : inline const Image& SvImpLBox::GetDontKnowNodeBmp( )
     369             : {
     370           0 :     return implGetImageLocation( itNodeDontKnow );
     371             : }
     372             : 
     373           0 : inline const Image& SvImpLBox::GetExpandedNodeBmp( )
     374             : {
     375           0 :     return implGetImageLocation( itNodeExpanded );
     376             : }
     377             : 
     378           0 : inline const Image& SvImpLBox::GetCollapsedNodeBmp( )
     379             : {
     380           0 :     return implGetImageLocation( itNodeCollapsed );
     381             : }
     382             : 
     383           0 : inline void SvImpLBox::SetDefaultEntryExpBmp( const Image& _rImg )
     384             : {
     385           0 :     implGetImageLocation( itEntryDefExpanded ) = _rImg;
     386           0 : }
     387             : 
     388           0 : inline void SvImpLBox::SetDefaultEntryColBmp( const Image& _rImg )
     389             : {
     390           0 :     implGetImageLocation( itEntryDefCollapsed ) = _rImg;
     391           0 : }
     392             : 
     393           0 : inline const Image& SvImpLBox::GetDefaultEntryExpBmp( )
     394             : {
     395           0 :     return implGetImageLocation( itEntryDefExpanded );
     396             : }
     397             : 
     398           0 : inline const Image& SvImpLBox::GetDefaultEntryColBmp( )
     399             : {
     400           0 :     return implGetImageLocation( itEntryDefCollapsed );
     401             : }
     402             : 
     403           0 : inline Point SvImpLBox::GetEntryPosition( SvTreeListEntry* pEntry ) const
     404             : {
     405           0 :     return Point( 0, GetEntryLine( pEntry ) );
     406             : }
     407             : 
     408           0 : inline void SvImpLBox::PaintEntry( SvTreeListEntry* pEntry )
     409             : {
     410           0 :     long nY = GetEntryLine( pEntry );
     411           0 :     pView->PaintEntry( pEntry, nY );
     412           0 : }
     413             : 
     414           0 : inline bool SvImpLBox::IsLineVisible( long nY ) const
     415             : {
     416           0 :     bool bRet = true;
     417           0 :     if ( nY < 0 || nY >= aOutputSize.Height() )
     418           0 :         bRet = false;
     419           0 :     return bRet;
     420             : }
     421             : 
     422           0 : inline void SvImpLBox::TreeInserted( SvTreeListEntry* pInsTree )
     423             : {
     424           0 :     EntryInserted( pInsTree );
     425           0 : }
     426             : 
     427             : #endif // #ifndef _SVIMPLBOX_HXX
     428             : 
     429             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10