LCOV - code coverage report
Current view: top level - include/vcl - dockwin.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 46 0.0 %
Date: 2014-04-14 Functions: 0 21 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 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 Window;
      76             :     friend class DockingManager;
      77             :     friend class DockingWindow;
      78             : 
      79             : private:
      80             : 
      81             :     // the original 'Docking'window
      82             :     Window *mpDockingWindow;
      83             : 
      84             :     // the original DockingWindow members
      85             :     FloatingWindow* mpFloatWin;
      86             :     Window*         mpOldBorderWin;
      87             :     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             :     void            ImplInitData();
     121             : 
     122             :                     DECL_LINK( PopupModeEnd, void* );
     123           0 :     void            ImplEnableStartDocking( bool bEnable = true )  { mbStartDockingEnabled = bEnable; }
     124           0 :     bool            ImplStartDockingEnabled()               { return mbStartDockingEnabled; }
     125             : 
     126             : public:
     127             :     ImplDockingWindowWrapper( const Window *pWindow );
     128             :     virtual ~ImplDockingWindowWrapper();
     129             : 
     130           0 :     Window*         GetWindow()     { return mpDockingWindow; }
     131             :     bool            ImplStartDocking( const Point& rPos );
     132             : 
     133             :     // those methods actually call the corresponding handlers
     134             :     void            StartDocking( const Point& rPos, Rectangle& rRect );
     135             :     bool            Docking( const Point& rPos, Rectangle& rRect );
     136             :     void            EndDocking( const Rectangle& rRect, bool bFloatMode );
     137             :     bool            PrepareToggleFloatingMode();
     138             :     void            ToggleFloatingMode();
     139             : 
     140             :     void            SetDragArea( const Rectangle& rRect );
     141             :     Rectangle       GetDragArea() const;
     142             : 
     143             :     void            Lock();
     144             :     void            Unlock();
     145             :     bool            IsLocked() const;
     146             : 
     147             :     void            StartPopupMode( ToolBox* pParentToolBox, sal_uLong nPopupModeFlags );
     148             :     bool            IsInPopupMode() const;
     149             : 
     150             :     void            TitleButtonClick( sal_uInt16 nButton );
     151             :     void            Pin();
     152             :     void            Roll();
     153             :     void            PopupModeEnd();
     154             :     void            Resizing( Size& rSize );
     155             :     bool            Close();
     156             :     void            Tracking( const TrackingEvent& rTEvt );
     157             :     long            Notify( NotifyEvent& rNEvt );
     158             : 
     159             :     void            ShowTitleButton( sal_uInt16 nButton, bool bVisible = true );
     160             : 
     161             :     void            SetMinOutputSizePixel( const Size& rSize );
     162             : 
     163             :     void            SetMaxOutputSizePixel( const Size& rSize );
     164             : 
     165           0 :     bool            IsDocking() const { return mbDocking; }
     166           0 :     bool            IsDockable() const { return mbDockable; }
     167           0 :     bool            IsDockingCanceled() const { return mbDockCanceled; }
     168             :     bool            IsFloatingPrevented() const { return mbFloatPrevented; }
     169             : 
     170             :     void            SetFloatingMode( bool bFloatMode = false );
     171             :     bool            IsFloatingMode() const;
     172           0 :     FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
     173             : 
     174             :     void            SetFloatStyle( WinBits nWinStyle );
     175             :     WinBits         GetFloatStyle() const;
     176             : 
     177             :     virtual void    setPosSizePixel( long nX, long nY,
     178             :                                      long nWidth, long nHeight,
     179             :                                      sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
     180             :     void            SetPosSizePixel( const Point& rNewPos,
     181             :                                      const Size& rNewSize )
     182             :                         { mpDockingWindow->SetPosSizePixel( rNewPos, rNewSize ); }
     183             :     Point           GetPosPixel() const;
     184             :     Size            GetSizePixel() const;
     185             : };
     186             : 
     187             : class VCL_DLLPUBLIC DockingManager
     188             : {
     189             : protected:
     190             :     ::std::vector<ImplDockingWindowWrapper *> mDockingWindows;
     191             : 
     192             : public:
     193             :     DockingManager();
     194             :     ~DockingManager();
     195             : 
     196             :     void AddWindow( const Window *pWin );
     197             :     void RemoveWindow( const Window *pWin );
     198             : 
     199             :     ImplDockingWindowWrapper*  GetDockingWindowWrapper( const Window *pWin );
     200             :     bool IsDockable( const Window *pWin );
     201             : 
     202             :     bool IsFloating( const Window *pWin );
     203             :     void SetFloatingMode( const Window *pWin, bool bFloating );
     204             : 
     205             :     void Lock( const Window *pWin );
     206             :     void Unlock( const Window *pWin );
     207             :     bool IsLocked( const Window *pWin );
     208             : 
     209             :     void    StartPopupMode( ToolBox *pParentToolBox, const Window *pWin );
     210             :     void    StartPopupMode( ToolBox *pParentToolBox, const Window *pWin, sal_uLong nPopupModeFlags );
     211             : 
     212             :     bool    IsInPopupMode( const Window *pWin );
     213             :     void    EndPopupMode( const Window *pWin );
     214             : 
     215             :     // required because those methods are not virtual in Window (!!!) and must
     216             :     // be availbale from the toolkit
     217             :     void        SetPosSizePixel( Window *pWin, long nX, long nY,
     218             :                                 long nWidth, long nHeight,
     219             :                                 sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
     220             :     Rectangle   GetPosSizePixel( const Window *pWin );
     221             : };
     222             : 
     223             : 
     224             : // - DockingWindow -
     225             : 
     226             : 
     227             : class VCL_DLLPUBLIC DockingWindow : public Window
     228             : {
     229             :     class   ImplData;
     230             : private:
     231             :     FloatingWindow* mpFloatWin;
     232             :     Window*         mpOldBorderWin;
     233             :     ImplData*       mpImplData;
     234             :     Point           maFloatPos;
     235             :     Point           maDockPos;
     236             :     Point           maMouseOff;
     237             :     Point           maMouseStart;
     238             :     Size            maRollUpOutSize;
     239             :     Size            maMinOutSize;
     240             :     long            mnTrackX;
     241             :     long            mnTrackY;
     242             :     long            mnTrackWidth;
     243             :     long            mnTrackHeight;
     244             :     sal_Int32           mnDockLeft;
     245             :     sal_Int32           mnDockTop;
     246             :     sal_Int32           mnDockRight;
     247             :     sal_Int32           mnDockBottom;
     248             :     WinBits         mnFloatBits;
     249             :     bool            mbDockCanceled:1,
     250             :                     mbDockPrevented:1,
     251             :                     mbFloatPrevented:1,
     252             :                     mbDockable:1,
     253             :                     mbDocking:1,
     254             :                     mbDragFull:1,
     255             :                     mbLastFloatMode:1,
     256             :                     mbStartFloat:1,
     257             :                     mbTrackDock:1,
     258             :                     mbPinned:1,
     259             :                     mbRollUp:1,
     260             :                     mbDockBtn:1,
     261             :                     mbHideBtn:1;
     262             : 
     263             :     SAL_DLLPRIVATE void    ImplInitDockingWindowData();
     264             : 
     265             :     // Copy assignment is forbidden and not implemented.
     266             :     SAL_DLLPRIVATE         DockingWindow (const DockingWindow &);
     267             :     SAL_DLLPRIVATE         DockingWindow & operator= (const DockingWindow &);
     268             : 
     269             : protected:
     270             :     using Window::ImplInit;
     271             :     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
     272             :     SAL_DLLPRIVATE void    ImplInitSettings();
     273             :     SAL_DLLPRIVATE void    ImplLoadRes( const ResId& rResId );
     274             : 
     275             : public:
     276             :     SAL_DLLPRIVATE bool    ImplStartDocking( const Point& rPos );
     277             : 
     278             : protected:
     279             :                     DockingWindow( WindowType nType );
     280             : 
     281             : public:
     282             :                     DockingWindow( Window* pParent, WinBits nStyle = WB_STDDOCKWIN );
     283             :                     DockingWindow( Window* pParent, const ResId& rResId );
     284             :                     virtual ~DockingWindow();
     285             : 
     286             :     virtual void    StartDocking();
     287             :     virtual bool    Docking( const Point& rPos, Rectangle& rRect );
     288             :     virtual void    EndDocking( const Rectangle& rRect, bool bFloatMode );
     289             :     virtual bool    PrepareToggleFloatingMode();
     290             :     virtual void    ToggleFloatingMode();
     291             : 
     292             :     virtual void    TitleButtonClick( sal_uInt16 nButton );
     293             :     virtual void    Pin();
     294             :     virtual void    Roll();
     295             :     virtual void    PopupModeEnd();
     296             :     virtual void    Resizing( Size& rSize );
     297             :     virtual bool    Close();
     298             :     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     299             :     virtual bool    Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     300             :     virtual void    StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     301             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     302             : 
     303             :     void            SetPin( bool bPin );
     304             :     bool            IsPinned() const;
     305             : 
     306             :     void            RollUp();
     307             :     void            RollDown();
     308             :     bool            IsRollUp() const;
     309             : 
     310             :     void            SetRollUpOutputSizePixel( const Size& rSize );
     311             :     Size            GetRollUpOutputSizePixel() const;
     312             : 
     313             :     void            SetMinOutputSizePixel( const Size& rSize );
     314             :     const Size&     GetMinOutputSizePixel() const;
     315             : 
     316             :     void            SetMaxOutputSizePixel( const Size& rSize );
     317             : 
     318           0 :     bool            IsDocking() const { return mbDocking; }
     319           0 :     bool            IsDockable() const { return mbDockable; }
     320           0 :     bool            IsDockingCanceled() const { return mbDockCanceled; }
     321           0 :     bool            IsDockingPrevented() const { return mbDockPrevented; }
     322             :     bool            IsFloatingPrevented() const { return mbFloatPrevented; }
     323             : 
     324             :     void            SetFloatingMode( bool bFloatMode = false );
     325             :     bool            IsFloatingMode() const;
     326           0 :     FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
     327             : 
     328             :     void            SetFloatingPos( const Point& rNewPos );
     329             :     Point           GetFloatingPos() const;
     330             : 
     331             :     void            SetFloatStyle( WinBits nWinStyle );
     332             :     WinBits         GetFloatStyle() const;
     333             : 
     334             :     virtual void    setPosSizePixel( long nX, long nY,
     335             :                                      long nWidth, long nHeight,
     336             :                                      sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ) SAL_OVERRIDE;
     337           0 :     void            SetPosSizePixel( const Point& rNewPos,
     338             :                                      const Size& rNewSize ) SAL_OVERRIDE
     339           0 :                         { Window::SetPosSizePixel( rNewPos, rNewSize ); }
     340             :     Point           GetPosPixel() const SAL_OVERRIDE;
     341             :     Size            GetSizePixel() const SAL_OVERRIDE;
     342             :     void            SetOutputSizePixel( const Size& rNewSize ) SAL_OVERRIDE;
     343             :     Size            GetOutputSizePixel() const;
     344             : };
     345             : 
     346             : inline void DockingWindow::SetPin( bool bPin )
     347             : {
     348             :     if ( mpFloatWin )
     349             :         mpFloatWin->SetPin( bPin );
     350             :     mbPinned = bPin;
     351             : }
     352             : 
     353             : inline bool DockingWindow::IsPinned() const
     354             : {
     355             :     if ( mpFloatWin )
     356             :         return mpFloatWin->IsPinned();
     357             :     return mbPinned;
     358             : }
     359             : 
     360             : inline void DockingWindow::RollUp()
     361             : {
     362             :     if ( mpFloatWin )
     363             :         mpFloatWin->RollUp();
     364             :     mbRollUp = true;
     365             : }
     366             : 
     367           0 : inline void DockingWindow::RollDown()
     368             : {
     369           0 :     if ( mpFloatWin )
     370           0 :         mpFloatWin->RollDown();
     371           0 :     mbRollUp = false;
     372           0 : }
     373             : 
     374           0 : inline bool DockingWindow::IsRollUp() const
     375             : {
     376           0 :     if ( mpFloatWin )
     377           0 :         return mpFloatWin->IsRollUp();
     378           0 :     return mbRollUp;
     379             : }
     380             : 
     381             : inline void DockingWindow::SetRollUpOutputSizePixel( const Size& rSize )
     382             : {
     383             :     if ( mpFloatWin )
     384             :         mpFloatWin->SetRollUpOutputSizePixel( rSize );
     385             :     maRollUpOutSize = rSize;
     386             : }
     387             : 
     388             : inline Size DockingWindow::GetRollUpOutputSizePixel() const
     389             : {
     390             :     if ( mpFloatWin )
     391             :         return mpFloatWin->GetRollUpOutputSizePixel();
     392             :     return maRollUpOutSize;
     393             : }
     394             : 
     395           0 : inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize )
     396             : {
     397           0 :     if ( mpFloatWin )
     398           0 :         mpFloatWin->SetMinOutputSizePixel( rSize );
     399           0 :     maMinOutSize = rSize;
     400           0 : }
     401             : 
     402           0 : inline const Size& DockingWindow::GetMinOutputSizePixel() const
     403             : {
     404           0 :     if ( mpFloatWin )
     405           0 :         return mpFloatWin->GetMinOutputSizePixel();
     406           0 :     return maMinOutSize;
     407             : }
     408             : 
     409           0 : inline void DockingWindow::SetFloatingPos( const Point& rNewPos )
     410             : {
     411           0 :     if ( mpFloatWin )
     412           0 :         mpFloatWin->SetPosPixel( rNewPos );
     413             :     else
     414           0 :         maFloatPos = rNewPos;
     415           0 : }
     416             : 
     417             : 
     418             : #endif // INCLUDED_VCL_DOCKWIN_HXX
     419             : 
     420             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10