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

Generated by: LCOV version 1.10