LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/vcl - dockwin.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 46 28.3 %
Date: 2013-07-09 Functions: 6 21 28.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 _SV_DOCKWIN_HXX
      21             : #define _SV_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             :     sal_Bool        mbFloating;     // out
      34             :     sal_Bool        mbLivemode;     // in
      35             :     sal_Bool        mbInteractive;  // in
      36             : 
      37             :     DockingData() {};
      38           0 :     DockingData( const Point& rPt, const Rectangle& rRect, sal_Bool b) :
      39           0 :         maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b ), mbLivemode( sal_False ), mbInteractive( sal_True )
      40           0 :         {};
      41             : };
      42             : 
      43             : struct EndDockingData
      44             : {
      45             :     Rectangle   maWindowRect;    // in
      46             :     sal_Bool        mbFloating;      // in
      47             :     sal_Bool        mbCancelled;     // in
      48             : 
      49             :     EndDockingData() {};
      50           0 :     EndDockingData( const Rectangle& rRect, sal_Bool b, sal_Bool bCancelled ) :
      51           0 :         maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled )
      52           0 :         {};
      53             : };
      54             : 
      55             : struct EndPopupModeData
      56             : {
      57             :     Point       maFloatingPos;    // in
      58             :     sal_Bool        mbTearoff;        // in
      59             : 
      60             :     EndPopupModeData() {};
      61           0 :     EndPopupModeData( const Point& rPos, sal_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             :     sal_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             :                     mbPined: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( sal_Bool bEnable = sal_True )  { mbStartDockingEnabled = bEnable; }
     124           0 :     sal_Bool            ImplStartDockingEnabled()               { return mbStartDockingEnabled; }
     125             : 
     126             : public:
     127             :     ImplDockingWindowWrapper( const Window *pWindow );
     128             :     virtual ~ImplDockingWindowWrapper();
     129             : 
     130        2322 :     Window*         GetWindow()     { return mpDockingWindow; }
     131             :     sal_Bool            ImplStartDocking( const Point& rPos );
     132             : 
     133             :     // those methods actually call the corresponding handlers
     134             :     void            StartDocking( const Point& rPos, Rectangle& rRect );
     135             :     sal_Bool            Docking( const Point& rPos, Rectangle& rRect );
     136             :     void            EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
     137             :     sal_Bool            PrepareToggleFloatingMode();
     138             :     void            ToggleFloatingMode();
     139             : 
     140             :     void            SetDragArea( const Rectangle& rRect );
     141             :     Rectangle       GetDragArea() const;
     142             : 
     143             :     void            Lock();
     144             :     void            Unlock();
     145             :     sal_Bool            IsLocked() const;
     146             : 
     147             :     void            StartPopupMode( ToolBox* pParentToolBox, sal_uLong nPopupModeFlags );
     148             :     sal_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             :     sal_Bool            Close();
     156             :     void            Tracking( const TrackingEvent& rTEvt );
     157             :     long            Notify( NotifyEvent& rNEvt );
     158             : 
     159             :     void            ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible = sal_True );
     160             : 
     161             :     void            SetMinOutputSizePixel( const Size& rSize );
     162             : 
     163             :     void            SetMaxOutputSizePixel( const Size& rSize );
     164             : 
     165           0 :     sal_Bool            IsDocking() const { return mbDocking; }
     166           0 :     sal_Bool            IsDockable() const { return mbDockable; }
     167           0 :     sal_Bool            IsDockingCanceled() const { return mbDockCanceled; }
     168             :     sal_Bool            IsFloatingPrevented() const { return mbFloatPrevented; }
     169             : 
     170             :     void            SetFloatingMode( sal_Bool bFloatMode = sal_False );
     171             :     sal_Bool            IsFloatingMode() const;
     172       79327 :     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             :     sal_Bool IsDockable( const Window *pWin );
     201             : 
     202             :     sal_Bool IsFloating( const Window *pWin );
     203             :     void SetFloatingMode( const Window *pWin, sal_Bool bFloating );
     204             : 
     205             :     void Lock( const Window *pWin );
     206             :     void Unlock( const Window *pWin );
     207             :     sal_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             :     sal_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             :     sal_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             :                     mbPined: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 sal_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             :                     ~DockingWindow();
     285             : 
     286             :     virtual void    StartDocking();
     287             :     virtual sal_Bool    Docking( const Point& rPos, Rectangle& rRect );
     288             :     virtual void    EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
     289             :     virtual sal_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 sal_Bool    Close();
     298             :     virtual void    Tracking( const TrackingEvent& rTEvt );
     299             :     virtual long    Notify( NotifyEvent& rNEvt );
     300             :     virtual void    StateChanged( StateChangedType nType );
     301             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
     302             : 
     303             :     void            SetPin( sal_Bool bPin );
     304             :     sal_Bool            IsPined() const;
     305             : 
     306             :     void            RollUp();
     307             :     void            RollDown();
     308             :     sal_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 :     sal_Bool            IsDocking() const { return mbDocking; }
     319           0 :     sal_Bool            IsDockable() const { return mbDockable; }
     320           0 :     sal_Bool            IsDockingCanceled() const { return mbDockCanceled; }
     321           0 :     sal_Bool            IsDockingPrevented() const { return mbDockPrevented; }
     322             :     sal_Bool            IsFloatingPrevented() const { return mbFloatPrevented; }
     323             : 
     324             :     void            SetFloatingMode( sal_Bool bFloatMode = sal_False );
     325             :     sal_Bool            IsFloatingMode() const;
     326        1047 :     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 );
     337        7179 :     void            SetPosSizePixel( const Point& rNewPos,
     338             :                                      const Size& rNewSize )
     339        7179 :                         { Window::SetPosSizePixel( rNewPos, rNewSize ); }
     340             :     Point           GetPosPixel() const;
     341             :     Size            GetSizePixel() const;
     342             :     void            SetOutputSizePixel( const Size& rNewSize );
     343             :     Size            GetOutputSizePixel() const;
     344             : };
     345             : 
     346             : inline void DockingWindow::SetPin( sal_Bool bPin )
     347             : {
     348             :     if ( mpFloatWin )
     349             :         mpFloatWin->SetPin( bPin );
     350             :     mbPined = bPin;
     351             : }
     352             : 
     353             : inline sal_Bool DockingWindow::IsPined() const
     354             : {
     355             :     if ( mpFloatWin )
     356             :         return mpFloatWin->IsPined();
     357             :     return mbPined;
     358             : }
     359             : 
     360             : inline void DockingWindow::RollUp()
     361             : {
     362             :     if ( mpFloatWin )
     363             :         mpFloatWin->RollUp();
     364             :     mbRollUp = sal_True;
     365             : }
     366             : 
     367           0 : inline void DockingWindow::RollDown()
     368             : {
     369           0 :     if ( mpFloatWin )
     370           0 :         mpFloatWin->RollDown();
     371           0 :     mbRollUp = sal_False;
     372           0 : }
     373             : 
     374           0 : inline sal_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          60 : inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize )
     396             : {
     397          60 :     if ( mpFloatWin )
     398           0 :         mpFloatWin->SetMinOutputSizePixel( rSize );
     399          60 :     maMinOutSize = rSize;
     400          60 : }
     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         173 : inline void DockingWindow::SetFloatingPos( const Point& rNewPos )
     410             : {
     411         173 :     if ( mpFloatWin )
     412           0 :         mpFloatWin->SetPosPixel( rNewPos );
     413             :     else
     414         173 :         maFloatPos = rNewPos;
     415         173 : }
     416             : 
     417             : 
     418             : #endif  // _SV_DOCKWIN_HXX
     419             : 
     420             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10