LCOV - code coverage report
Current view: top level - include/vcl - dockwin.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 19 52 36.5 %
Date: 2015-06-13 12:38:46 Functions: 12 27 44.4 %
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_DOCKWIN_HXX
      21             : #define INCLUDED_VCL_DOCKWIN_HXX
      22             : 
      23             : #include <tools/solar.h>
      24             : #include <vcl/dllapi.h>
      25             : #include <vcl/builder.hxx>
      26             : #include <vcl/floatwin.hxx>
      27             : #include <vector>
      28             : 
      29             : // data to be sent with docking events
      30             : struct DockingData
      31             : {
      32             :     Point       maMousePos;     // in
      33             :     Rectangle   maTrackRect;    // in/out
      34             :     bool        mbFloating;     // out
      35             :     bool        mbLivemode;     // in
      36             :     bool        mbInteractive;  // in
      37             : 
      38             :     DockingData() {};
      39           0 :     DockingData( const Point& rPt, const Rectangle& rRect, bool b) :
      40           0 :         maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b ), mbLivemode( false ), mbInteractive( true )
      41           0 :         {};
      42             : };
      43             : 
      44             : struct EndDockingData
      45             : {
      46             :     Rectangle   maWindowRect;    // in
      47             :     bool        mbFloating;      // in
      48             :     bool        mbCancelled;     // in
      49             : 
      50             :     EndDockingData() {};
      51           0 :     EndDockingData( const Rectangle& rRect, bool b, bool bCancelled ) :
      52           0 :         maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled )
      53           0 :         {};
      54             : };
      55             : 
      56             : struct EndPopupModeData
      57             : {
      58             :     Point       maFloatingPos;    // in
      59             :     bool        mbTearoff;        // in
      60             : 
      61             :     EndPopupModeData() {};
      62           0 :     EndPopupModeData( const Point& rPos, bool bTearoff ) :
      63           0 :         maFloatingPos( rPos ), mbTearoff( bTearoff )
      64           0 :         {};
      65             : };
      66             : 
      67             : /** ImplDockingWindowWrapper
      68             :  *
      69             :  *  ImplDockingWindowWrapper obsoletes the DockingWindow class.
      70             :  *  It is better because it can make a "normal window" dockable.
      71             :  *  All DockingWindows should be converted the new class.
      72             :  */
      73             : 
      74             : class ImplDockingWindowWrapper
      75             : {
      76             :     friend class ::vcl::Window;
      77             :     friend class DockingManager;
      78             :     friend class DockingWindow;
      79             : 
      80             : private:
      81             : 
      82             :     // the original 'Docking'window
      83             :     VclPtr<vcl::Window>    mpDockingWindow;
      84             : 
      85             :     // the original DockingWindow members
      86             :     VclPtr<FloatingWindow> mpFloatWin;
      87             :     VclPtr<vcl::Window>    mpOldBorderWin;
      88             :     VclPtr<vcl::Window>    mpParent;
      89             :     Point           maFloatPos;
      90             :     Point           maDockPos;
      91             :     Point           maMouseOff;
      92             :     Point           maMouseStart;
      93             :     Size            maRollUpOutSize;
      94             :     Size            maMinOutSize;
      95             :     Size            maMaxOutSize;
      96             :     Rectangle       maDragArea;
      97             :     long            mnTrackX;
      98             :     long            mnTrackY;
      99             :     long            mnTrackWidth;
     100             :     long            mnTrackHeight;
     101             :     sal_Int32       mnDockLeft;
     102             :     sal_Int32       mnDockTop;
     103             :     sal_Int32       mnDockRight;
     104             :     sal_Int32       mnDockBottom;
     105             :     WinBits         mnFloatBits;
     106             :     bool            mbDockCanceled:1,
     107             :                     mbFloatPrevented:1,
     108             :                     mbDockable:1,
     109             :                     mbDocking:1,
     110             :                     mbDragFull:1,
     111             :                     mbLastFloatMode:1,
     112             :                     mbStartFloat:1,
     113             :                     mbTrackDock:1,
     114             :                     mbPinned:1,
     115             :                     mbRollUp:1,
     116             :                     mbDockBtn:1,
     117             :                     mbHideBtn:1,
     118             :                     mbStartDockingEnabled:1,
     119             :                     mbLocked:1;
     120             : 
     121             :                     DECL_LINK( PopupModeEnd, void* );
     122           0 :     void            ImplEnableStartDocking( bool bEnable = true )  { mbStartDockingEnabled = bEnable; }
     123           0 :     bool            ImplStartDockingEnabled()               { return mbStartDockingEnabled; }
     124             : 
     125             : public:
     126             :     ImplDockingWindowWrapper( const vcl::Window *pWindow );
     127             :     virtual ~ImplDockingWindowWrapper();
     128             : 
     129        9522 :     vcl::Window*         GetWindow()     { return mpDockingWindow; }
     130             :     bool            ImplStartDocking( const Point& rPos );
     131             : 
     132             :     // those methods actually call the corresponding handlers
     133             :     void            StartDocking( const Point& rPos, Rectangle& rRect );
     134             :     bool            Docking( const Point& rPos, Rectangle& rRect );
     135             :     void            EndDocking( const Rectangle& rRect, bool bFloatMode );
     136             :     bool            PrepareToggleFloatingMode();
     137             :     void            ToggleFloatingMode();
     138             : 
     139             :     void            SetDragArea( const Rectangle& rRect );
     140       20836 :     Rectangle       GetDragArea() const { return maDragArea;}
     141             : 
     142             :     void            Lock();
     143             :     void            Unlock();
     144      141462 :     bool            IsLocked() const { return mbLocked;}
     145             : 
     146             :     void            StartPopupMode( ToolBox* pParentToolBox, FloatWinPopupFlags nPopupModeFlags );
     147             :     bool            IsInPopupMode() const;
     148             : 
     149             :     void            TitleButtonClick( TitleButton nButton );
     150             :     void            Resizing( Size& rSize );
     151             :     void            Tracking( const TrackingEvent& rTEvt );
     152             :     long            Notify( NotifyEvent& rNEvt );
     153             : 
     154             :     void            ShowTitleButton( TitleButton nButton, bool bVisible = true );
     155             : 
     156             :     void            SetMinOutputSizePixel( const Size& rSize );
     157             : 
     158             :     void            SetMaxOutputSizePixel( const Size& rSize );
     159             : 
     160           0 :     bool            IsDocking() const { return mbDocking; }
     161           0 :     bool            IsDockable() const { return mbDockable; }
     162           0 :     bool            IsDockingCanceled() const { return mbDockCanceled; }
     163             :     bool            IsFloatingPrevented() const { return mbFloatPrevented; }
     164             : 
     165             :     void            SetFloatingMode( bool bFloatMode = false );
     166             :     bool            IsFloatingMode() const;
     167       89111 :     FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
     168             : 
     169             :     void            SetFloatStyle( WinBits nWinStyle );
     170           9 :     WinBits         GetFloatStyle() const { return mnFloatBits;}
     171             : 
     172             :     void            setPosSizePixel( long nX, long nY,
     173             :                                      long nWidth, long nHeight,
     174             :                                      PosSizeFlags nFlags = PosSizeFlags::All );
     175             :     void            SetPosSizePixel( const Point& rNewPos,
     176             :                                      const Size& rNewSize )
     177             :                         { mpDockingWindow->SetPosSizePixel( rNewPos, rNewSize ); }
     178             :     Point           GetPosPixel() const;
     179             :     Size            GetSizePixel() const;
     180             : };
     181             : 
     182             : class VCL_DLLPUBLIC DockingManager
     183             : {
     184             : protected:
     185             :     ::std::vector<ImplDockingWindowWrapper *> mDockingWindows;
     186             : 
     187             : public:
     188             :     DockingManager();
     189             :     ~DockingManager();
     190             : 
     191             :     void AddWindow( const vcl::Window *pWin );
     192             :     void RemoveWindow( const vcl::Window *pWin );
     193             : 
     194             :     ImplDockingWindowWrapper*  GetDockingWindowWrapper( const vcl::Window *pWin );
     195             :     bool IsDockable( const vcl::Window *pWin );
     196             : 
     197             :     bool IsFloating( const vcl::Window *pWin );
     198             :     void SetFloatingMode( const vcl::Window *pWin, bool bFloating );
     199             : 
     200             :     void Lock( const vcl::Window *pWin );
     201             :     void Unlock( const vcl::Window *pWin );
     202             :     bool IsLocked( const vcl::Window *pWin );
     203             : 
     204             :     void    StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin );
     205             :     void    StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin, FloatWinPopupFlags nPopupModeFlags );
     206             : 
     207             :     bool    IsInPopupMode( const vcl::Window *pWin );
     208             :     void    EndPopupMode( const vcl::Window *pWin );
     209             : 
     210             :     // required because those methods are not virtual in Window (!!!) and must
     211             :     // be availbale from the toolkit
     212             :     void        SetPosSizePixel( vcl::Window *pWin, long nX, long nY,
     213             :                                 long nWidth, long nHeight,
     214             :                                 PosSizeFlags nFlags = PosSizeFlags::All );
     215             :     Rectangle   GetPosSizePixel( const vcl::Window *pWin );
     216             : };
     217             : 
     218             : 
     219             : // - DockingWindow -
     220             : 
     221             : 
     222             : class VCL_DLLPUBLIC DockingWindow
     223             :     : public vcl::Window
     224             :     , public VclBuilderContainer
     225             : {
     226             :     class   ImplData;
     227             : private:
     228             :     VclPtr<FloatingWindow> mpFloatWin;
     229             :     VclPtr<vcl::Window>    mpOldBorderWin;
     230             :     ImplData*       mpImplData;
     231             :     Point           maFloatPos;
     232             :     Point           maDockPos;
     233             :     Point           maMouseOff;
     234             :     Point           maMouseStart;
     235             :     Size            maRollUpOutSize;
     236             :     Size            maMinOutSize;
     237             :     long            mnTrackX;
     238             :     long            mnTrackY;
     239             :     long            mnTrackWidth;
     240             :     long            mnTrackHeight;
     241             :     sal_Int32           mnDockLeft;
     242             :     sal_Int32           mnDockTop;
     243             :     sal_Int32           mnDockRight;
     244             :     sal_Int32           mnDockBottom;
     245             :     WinBits         mnFloatBits;
     246             :     Idle            maLayoutIdle;
     247             :     bool            mbDockCanceled:1,
     248             :                     mbDockPrevented:1,
     249             :                     mbFloatPrevented:1,
     250             :                     mbDockable:1,
     251             :                     mbDocking:1,
     252             :                     mbDragFull:1,
     253             :                     mbLastFloatMode:1,
     254             :                     mbStartFloat:1,
     255             :                     mbTrackDock:1,
     256             :                     mbPinned:1,
     257             :                     mbRollUp:1,
     258             :                     mbDockBtn:1,
     259             :                     mbHideBtn:1,
     260             :                     mbIsDefferedInit:1,
     261             :                     mbIsCalculatingInitialLayoutSize:1,
     262             :                     mbInitialLayoutDone:1;
     263             : 
     264             :     VclPtr<vcl::Window>  mpDialogParent;
     265             : 
     266             :     SAL_DLLPRIVATE void    ImplInitDockingWindowData();
     267             :     SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox);
     268             :     DECL_DLLPRIVATE_LINK_TYPED( ImplHandleLayoutTimerHdl, Idle*, void );
     269             : 
     270             :                            DockingWindow (const DockingWindow &) SAL_DELETED_FUNCTION;
     271             :                            DockingWindow & operator= (const DockingWindow &) SAL_DELETED_FUNCTION;
     272             : 
     273             : protected:
     274             :     using Window::ImplInit;
     275             :     SAL_DLLPRIVATE void    ImplInit( vcl::Window* pParent, WinBits nStyle );
     276             :     SAL_DLLPRIVATE void    ImplInitSettings();
     277             :     SAL_DLLPRIVATE void    ImplLoadRes( const ResId& rResId );
     278             : 
     279             :     SAL_DLLPRIVATE void DoInitialLayout();
     280             : 
     281             :     void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
     282             :                 const css::uno::Reference<css::frame::XFrame> &rFrame);
     283             : 
     284             : public:
     285             :     bool            isLayoutEnabled() const;
     286             :     void            setOptimalLayoutSize();
     287      291536 :     bool            isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; }
     288             : 
     289             :     SAL_DLLPRIVATE bool    ImplStartDocking( const Point& rPos );
     290          17 :     SAL_DLLPRIVATE bool    isDeferredInit() const { return mbIsDefferedInit; }
     291      291897 :     SAL_DLLPRIVATE bool    hasPendingLayout() const { return maLayoutIdle.IsActive(); }
     292             :     void                   doDeferredInit(WinBits nBits);
     293             : protected:
     294             :                     DockingWindow( WindowType nType );
     295             : 
     296             : public:
     297             :     DockingWindow(vcl::Window* pParent, WinBits nStyle = WB_STDDOCKWIN);
     298             :     DockingWindow(vcl::Window* pParent, const ResId& rResId);
     299             :     DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
     300             :         const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
     301             :     virtual ~DockingWindow();
     302             :     virtual void dispose() SAL_OVERRIDE;
     303             : 
     304             :     virtual void    StartDocking();
     305             :     virtual bool    Docking( const Point& rPos, Rectangle& rRect );
     306             :     virtual void    EndDocking( const Rectangle& rRect, bool bFloatMode );
     307             :     virtual bool    PrepareToggleFloatingMode();
     308             :     virtual void    ToggleFloatingMode();
     309             : 
     310             :     virtual void    Resizing( Size& rSize );
     311             :     virtual bool    Close();
     312             :     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     313             :     virtual bool    Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     314             :     virtual void    StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     315             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     316             : 
     317             :     void            SetPin( bool bPin );
     318             :     bool            IsPinned() const;
     319             : 
     320             :     void            RollUp();
     321             :     void            RollDown();
     322             :     bool            IsRollUp() const;
     323             : 
     324             :     void            SetRollUpOutputSizePixel( const Size& rSize );
     325             :     Size            GetRollUpOutputSizePixel() const;
     326             : 
     327             :     void            SetMinOutputSizePixel( const Size& rSize );
     328             :     const Size&     GetMinOutputSizePixel() const;
     329             : 
     330             :     void            SetMaxOutputSizePixel( const Size& rSize );
     331             : 
     332           0 :     bool            IsDocking() const { return mbDocking; }
     333           0 :     bool            IsDockable() const { return mbDockable; }
     334           0 :     bool            IsDockingCanceled() const { return mbDockCanceled; }
     335           0 :     bool            IsDockingPrevented() const { return mbDockPrevented; }
     336             :     bool            IsFloatingPrevented() const { return mbFloatPrevented; }
     337             : 
     338             :     void            SetFloatingMode( bool bFloatMode = false );
     339             :     bool            IsFloatingMode() const;
     340       13254 :     FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
     341             : 
     342             :     void            SetFloatingPos( const Point& rNewPos );
     343             :     Point           GetFloatingPos() const;
     344             : 
     345             :     void            SetFloatStyle( WinBits nWinStyle );
     346             :     WinBits         GetFloatStyle() const;
     347             : 
     348             :     virtual void    setPosSizePixel( long nX, long nY,
     349             :                                      long nWidth, long nHeight,
     350             :                                      PosSizeFlags nFlags = PosSizeFlags::All ) SAL_OVERRIDE;
     351       58951 :     void            SetPosSizePixel( const Point& rNewPos,
     352             :                                      const Size& rNewSize ) SAL_OVERRIDE
     353       58951 :                         { Window::SetPosSizePixel( rNewPos, rNewSize ); }
     354             :     Point           GetPosPixel() const SAL_OVERRIDE;
     355             :     Size            GetSizePixel() const SAL_OVERRIDE;
     356             :     void            SetOutputSizePixel( const Size& rNewSize ) SAL_OVERRIDE;
     357             :     Size            GetOutputSizePixel() const;
     358             : 
     359             :     virtual void SetText( const OUString& rStr ) SAL_OVERRIDE;
     360             :     virtual OUString GetText() const SAL_OVERRIDE;
     361             :     virtual Size GetOptimalSize() const SAL_OVERRIDE;
     362             :     virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) SAL_OVERRIDE;
     363             : };
     364             : 
     365             : inline void DockingWindow::SetPin( bool bPin )
     366             : {
     367             :     if ( mpFloatWin )
     368             :         mpFloatWin->SetPin( bPin );
     369             :     mbPinned = bPin;
     370             : }
     371             : 
     372             : inline bool DockingWindow::IsPinned() const
     373             : {
     374             :     if ( mpFloatWin )
     375             :         return mpFloatWin->IsPinned();
     376             :     return mbPinned;
     377             : }
     378             : 
     379             : inline void DockingWindow::RollUp()
     380             : {
     381             :     if ( mpFloatWin )
     382             :         mpFloatWin->RollUp();
     383             :     mbRollUp = true;
     384             : }
     385             : 
     386           0 : inline void DockingWindow::RollDown()
     387             : {
     388           0 :     if ( mpFloatWin )
     389           0 :         mpFloatWin->RollDown();
     390           0 :     mbRollUp = false;
     391           0 : }
     392             : 
     393           0 : inline bool DockingWindow::IsRollUp() const
     394             : {
     395           0 :     if ( mpFloatWin )
     396           0 :         return mpFloatWin->IsRollUp();
     397           0 :     return mbRollUp;
     398             : }
     399             : 
     400             : inline void DockingWindow::SetRollUpOutputSizePixel( const Size& rSize )
     401             : {
     402             :     if ( mpFloatWin )
     403             :         mpFloatWin->SetRollUpOutputSizePixel( rSize );
     404             :     maRollUpOutSize = rSize;
     405             : }
     406             : 
     407             : inline Size DockingWindow::GetRollUpOutputSizePixel() const
     408             : {
     409             :     if ( mpFloatWin )
     410             :         return mpFloatWin->GetRollUpOutputSizePixel();
     411             :     return maRollUpOutSize;
     412             : }
     413             : 
     414          56 : inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize )
     415             : {
     416          56 :     if ( mpFloatWin )
     417           0 :         mpFloatWin->SetMinOutputSizePixel( rSize );
     418          56 :     maMinOutSize = rSize;
     419          56 : }
     420             : 
     421           0 : inline const Size& DockingWindow::GetMinOutputSizePixel() const
     422             : {
     423           0 :     if ( mpFloatWin )
     424           0 :         return mpFloatWin->GetMinOutputSizePixel();
     425           0 :     return maMinOutSize;
     426             : }
     427             : 
     428        3233 : inline void DockingWindow::SetFloatingPos( const Point& rNewPos )
     429             : {
     430        3233 :     if ( mpFloatWin )
     431           0 :         mpFloatWin->SetPosPixel( rNewPos );
     432             :     else
     433        3233 :         maFloatPos = rNewPos;
     434        3233 : }
     435             : 
     436             : 
     437             : #endif // INCLUDED_VCL_DOCKWIN_HXX
     438             : 
     439             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11