LCOV - code coverage report
Current view: top level - svtools/source/brwbox - datwin.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 18 21 85.7 %
Date: 2015-06-13 12:38:46 Functions: 11 13 84.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_SVTOOLS_SOURCE_BRWBOX_DATWIN_HXX
      21             : #define INCLUDED_SVTOOLS_SOURCE_BRWBOX_DATWIN_HXX
      22             : 
      23             : #include <svtools/brwbox.hxx>
      24             : #include <svtools/brwhead.hxx>
      25             : #include <vcl/timer.hxx>
      26             : #include <vcl/image.hxx>
      27             : #include <svtools/transfer.hxx>
      28             : #include <vector>
      29             : 
      30             : 
      31             : 
      32             : #define MIN_COLUMNWIDTH  2
      33             : 
      34             : typedef ::std::vector< Rectangle* > RectangleList;
      35             : 
      36             : 
      37             : 
      38          82 : class ButtonFrame
      39             : {
      40             :     Rectangle   aRect;
      41             :     Rectangle   aInnerRect;
      42             :     OUString    aText;
      43             :     bool        bPressed;
      44             :     bool        bCurs;
      45             :     bool        m_bDrawDisabled;
      46             : 
      47             : public:
      48          82 :                ButtonFrame( const Point& rPt, const Size& rSz,
      49             :                             const OUString &rText,
      50             :                             bool bPress,
      51             :                             bool bCursor,
      52             :                             bool _bDrawDisabled)
      53             :                 :aRect( rPt, rSz )
      54         164 :                 ,aInnerRect( Point( aRect.Left()+1, aRect.Top()+1 ),
      55         164 :                             Size( aRect.GetWidth()-2, aRect.GetHeight()-2 ) )
      56             :                 ,aText(rText)
      57             :                 ,bPressed(bPress)
      58             :                 ,bCurs(bCursor)
      59         410 :                 ,m_bDrawDisabled(_bDrawDisabled)
      60             :             {
      61          82 :             }
      62             : 
      63             :     void    Draw( OutputDevice& rDev );
      64             : };
      65             : 
      66             : 
      67             : 
      68             : class BrowserColumn
      69             : {
      70             :     sal_uInt16          _nId;
      71             :     sal_uLong           _nOriginalWidth;
      72             :     sal_uLong           _nWidth;
      73             :     Image               _aImage;
      74             :     OUString            _aTitle;
      75             :     bool                _bFrozen;
      76             : 
      77             : public:
      78             :                         BrowserColumn( sal_uInt16 nItemId, const Image &rImage,
      79             :                                         const OUString& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom );
      80             :     virtual            ~BrowserColumn();
      81             : 
      82        3619 :     sal_uInt16          GetId() const { return _nId; }
      83             : 
      84        4074 :     sal_uLong           Width() { return _nWidth; }
      85             :     Image&              GetImage() { return _aImage; }
      86          66 :     OUString&           Title() { return _aTitle; }
      87             : 
      88        4209 :     bool                IsFrozen() const { return _bFrozen; }
      89          33 :     void                Freeze( bool bFreeze = true ) { _bFrozen = bFreeze; }
      90             : 
      91             :     void                Draw( BrowseBox& rBox, OutputDevice& rDev,
      92             :                               const Point& rPos, bool bCurs  );
      93             : 
      94             :     void                SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom);
      95             :     void                ZoomChanged(const Fraction& rNewZoom);
      96             : };
      97             : 
      98             : 
      99             : 
     100             : class BrowserDataWin
     101             :             :public Control
     102             :             ,public DragSourceHelper
     103             :             ,public DropTargetHelper
     104             : {
     105             : public:
     106             :     VclPtr<BrowserHeader> pHeaderBar;     // only for BrowserMode::HEADERBAR_NEW
     107             :     VclPtr<vcl::Window>   pEventWin;      // Window of forwarded events
     108             :     VclPtr<ScrollBarBox>  pCornerWin;     // Window in the corner btw the ScrollBars
     109             :     bool            bInDtor;
     110             :     AutoTimer       aMouseTimer;    // recalls MouseMove on dragging out
     111             :     MouseEvent      aRepeatEvt;     // a MouseEvent to repeat
     112             :     Point           aLastMousePos;  // prevents pseudo-MouseMoves
     113             : 
     114             :     OUString        aRealRowCount;  // to show in VScrollBar
     115             : 
     116             :     RectangleList   aInvalidRegion; // invalidated Rectangles during !UpdateMode
     117             :     bool            bInPaint;       // TRUE while in Paint
     118             :     bool            bInCommand;     // TRUE while in Command
     119             :     bool            bNoScrollBack;  // only scroll forward
     120             :     bool            bNoHScroll;     // no horizontal scrollbar
     121             :     bool            bNoVScroll;     // no vertical scrollbar
     122             :     bool            bAutoHScroll;   // autohide horizontaler Scrollbar
     123             :     bool            bAutoVScroll;   // autohide horizontaler Scrollbar
     124             :     bool            bUpdateMode;    // not SV-UpdateMode because of Invalidate()
     125             :     bool            bAutoSizeLastCol; // last column always fills up window
     126             :     bool            bResizeOnPaint;   // outstanding resize-event
     127             :     bool            bUpdateOnUnlock;  // Update() while locked
     128             :     bool            bInUpdateScrollbars;  // prevents recursions
     129             :     bool            bHadRecursion;        // a recursion occurred
     130             :     bool            bOwnDataChangedHdl;   // dont change colors in DataChanged
     131             :     bool            bCallingDropCallback; // we're in a callback to AcceptDrop or ExecuteDrop currently
     132             :     sal_uInt16          nUpdateLock;    // lock count, dont call Control::Update()!
     133             :     short           nCursorHidden;  // new counter for DoHide/ShowCursor
     134             : 
     135             :     long            m_nDragRowDividerLimit;
     136             :     long            m_nDragRowDividerOffset;
     137             : 
     138             : public:
     139             :                     explicit BrowserDataWin( BrowseBox* pParent );
     140             :     virtual         ~BrowserDataWin();
     141             :     virtual void    dispose() SAL_OVERRIDE;
     142             : 
     143             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     144             :     virtual void    Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
     145             :     virtual void    RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     146             :     virtual void    Command( const CommandEvent& rEvt ) SAL_OVERRIDE;
     147             :     virtual void    MouseButtonDown( const MouseEvent& rEvt ) SAL_OVERRIDE;
     148             :     virtual void    MouseMove( const MouseEvent& rEvt ) SAL_OVERRIDE;
     149             :                     DECL_LINK_TYPED( RepeatedMouseMove, Timer *, void );
     150             : 
     151             :     virtual void    MouseButtonUp( const MouseEvent& rEvt ) SAL_OVERRIDE;
     152             :     virtual void    KeyInput( const KeyEvent& rEvt ) SAL_OVERRIDE;
     153             :     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     154             : 
     155             :     // DropTargetHelper overridables
     156             :     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     157             :     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     158             : 
     159             :     // DragSourceHelper overridables
     160             :     virtual void    StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) SAL_OVERRIDE;
     161             : 
     162             : 
     163             :     BrowseEvent     CreateBrowseEvent( const Point& rPosPixel );
     164             :     void            Repaint();
     165         468 :     BrowseBox*      GetParent() const
     166         468 :                          { return static_cast<BrowseBox*>( Window::GetParent() ); }
     167           0 :     const OUString& GetRealRowCount() const { return aRealRowCount; }
     168             : 
     169             :     void            SetUpdateMode( bool bMode );
     170         675 :     bool            GetUpdateMode() const { return bUpdateMode; }
     171           1 :     void            EnterUpdateLock() { ++nUpdateLock; }
     172             :     void            LeaveUpdateLock();
     173             :     void            Update();
     174             :     void            DoOutstandingInvalidations();
     175             :     void            Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE ) SAL_OVERRIDE;
     176             :     void            Invalidate( const Rectangle& rRect, InvalidateFlags nFlags = InvalidateFlags::NONE ) SAL_OVERRIDE;
     177           0 :     void            Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags = InvalidateFlags::NONE ) SAL_OVERRIDE
     178           0 :                     { Control::Invalidate( rRegion, nFlags ); }
     179             : 
     180             : protected:
     181             :     void            StartRowDividerDrag( const Point& _rStartPos );
     182             :     bool            ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent );
     183             : };
     184             : 
     185             : 
     186             : 
     187             : inline void BrowserDataWin::Repaint()
     188             : {
     189             :     if ( GetUpdateMode() )
     190             :         Update();
     191             :     Invalidate(Rectangle(Point(), GetOutputSizePixel()));
     192             : }
     193             : 
     194             : 
     195             : 
     196             : class BrowserScrollBar: public ScrollBar
     197             : {
     198             :     sal_uLong           _nTip;
     199             :     sal_uLong           _nLastPos;
     200             :     VclPtr<BrowserDataWin> _pDataWin;
     201             : 
     202             : public:
     203          60 :                     BrowserScrollBar( vcl::Window* pParent, WinBits nStyle,
     204             :                                       BrowserDataWin *pDataWin )
     205             :                     :   ScrollBar( pParent, nStyle ),
     206             :                         _nTip( 0 ),
     207             :                         _nLastPos( ULONG_MAX ),
     208          60 :                         _pDataWin( pDataWin )
     209          60 :                     {}
     210             :    virtual          ~BrowserScrollBar();
     211             :    virtual void     dispose() SAL_OVERRIDE;
     212             :                     //ScrollBar( vcl::Window* pParent, const ResId& rResId );
     213             : 
     214             :     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     215             :     virtual void    EndScroll() SAL_OVERRIDE;
     216             : };
     217             : 
     218             : 
     219             : 
     220             : void InitSettings_Impl( vcl::Window *pWin,
     221             :          bool bFont = true, bool bForeground = true, bool bBackground = true );
     222             : 
     223             : 
     224             : 
     225             : #endif
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11