LCOV - code coverage report
Current view: top level - vcl/inc - brdwin.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 9 66.7 %
Date: 2015-06-13 12:38:46 Functions: 7 10 70.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_INC_BRDWIN_HXX
      21             : #define INCLUDED_VCL_INC_BRDWIN_HXX
      22             : 
      23             : #include <vcl/window.hxx>
      24             : 
      25             : class ImplBorderWindowView;
      26             : enum class DrawButtonFlags;
      27             : 
      28             : #define BORDERWINDOW_STYLE_OVERLAP          ((sal_uInt16)0x0001)
      29             : #define BORDERWINDOW_STYLE_BORDER           ((sal_uInt16)0x0002)
      30             : #define BORDERWINDOW_STYLE_FLOAT            ((sal_uInt16)0x0004)
      31             : #define BORDERWINDOW_STYLE_FRAME            ((sal_uInt16)0x0008)
      32             : #define BORDERWINDOW_STYLE_APP              ((sal_uInt16)0x0010)
      33             : 
      34             : #define BORDERWINDOW_HITTEST_TITLE          ((sal_uInt16)0x0001)
      35             : #define BORDERWINDOW_HITTEST_LEFT           ((sal_uInt16)0x0002)
      36             : #define BORDERWINDOW_HITTEST_MENU           ((sal_uInt16)0x0004)
      37             : #define BORDERWINDOW_HITTEST_TOP            ((sal_uInt16)0x0008)
      38             : #define BORDERWINDOW_HITTEST_RIGHT          ((sal_uInt16)0x0010)
      39             : #define BORDERWINDOW_HITTEST_BOTTOM         ((sal_uInt16)0x0020)
      40             : #define BORDERWINDOW_HITTEST_TOPLEFT        ((sal_uInt16)0x0040)
      41             : #define BORDERWINDOW_HITTEST_TOPRIGHT       ((sal_uInt16)0x0080)
      42             : #define BORDERWINDOW_HITTEST_BOTTOMLEFT     ((sal_uInt16)0x0100)
      43             : #define BORDERWINDOW_HITTEST_BOTTOMRIGHT    ((sal_uInt16)0x0200)
      44             : #define BORDERWINDOW_HITTEST_CLOSE          ((sal_uInt16)0x0400)
      45             : #define BORDERWINDOW_HITTEST_ROLL           ((sal_uInt16)0x0800)
      46             : #define BORDERWINDOW_HITTEST_DOCK           ((sal_uInt16)0x1000)
      47             : #define BORDERWINDOW_HITTEST_HIDE           ((sal_uInt16)0x2000)
      48             : #define BORDERWINDOW_HITTEST_HELP           ((sal_uInt16)0x4000)
      49             : #define BORDERWINDOW_HITTEST_PIN            ((sal_uInt16)0x8000)
      50             : 
      51             : #define BORDERWINDOW_DRAW_TITLE             ((sal_uInt16)0x0001)
      52             : #define BORDERWINDOW_DRAW_BORDER            ((sal_uInt16)0x0002)
      53             : #define BORDERWINDOW_DRAW_FRAME             ((sal_uInt16)0x0004)
      54             : #define BORDERWINDOW_DRAW_CLOSE             ((sal_uInt16)0x0008)
      55             : #define BORDERWINDOW_DRAW_ROLL              ((sal_uInt16)0x0010)
      56             : #define BORDERWINDOW_DRAW_DOCK              ((sal_uInt16)0x0020)
      57             : #define BORDERWINDOW_DRAW_HIDE              ((sal_uInt16)0x0040)
      58             : #define BORDERWINDOW_DRAW_HELP              ((sal_uInt16)0x0080)
      59             : #define BORDERWINDOW_DRAW_PIN               ((sal_uInt16)0x0100)
      60             : #define BORDERWINDOW_DRAW_MENU              ((sal_uInt16)0x0200)
      61             : #define BORDERWINDOW_DRAW_ALL               (BORDERWINDOW_DRAW_TITLE |      \
      62             :                                              BORDERWINDOW_DRAW_BORDER |     \
      63             :                                              BORDERWINDOW_DRAW_FRAME |      \
      64             :                                              BORDERWINDOW_DRAW_CLOSE |      \
      65             :                                              BORDERWINDOW_DRAW_ROLL |       \
      66             :                                              BORDERWINDOW_DRAW_DOCK |       \
      67             :                                              BORDERWINDOW_DRAW_HIDE |       \
      68             :                                              BORDERWINDOW_DRAW_HELP |       \
      69             :                                              BORDERWINDOW_DRAW_PIN  |       \
      70             :                                              BORDERWINDOW_DRAW_MENU)
      71             : 
      72             : #define BORDERWINDOW_TITLE_NORMAL           ((sal_uInt16)0x0001)
      73             : #define BORDERWINDOW_TITLE_SMALL            ((sal_uInt16)0x0002)
      74             : #define BORDERWINDOW_TITLE_TEAROFF          ((sal_uInt16)0x0004)
      75             : #define BORDERWINDOW_TITLE_POPUP            ((sal_uInt16)0x0008)
      76             : #define BORDERWINDOW_TITLE_NONE             ((sal_uInt16)0x0010)
      77             : 
      78             : class ImplBorderWindow : public vcl::Window
      79             : {
      80             :     friend class vcl::Window;
      81             :     friend class ImplBorderWindowView;
      82             :     friend class ImplSmallBorderWindowView;
      83             :     friend class ImplStdBorderWindowView;
      84             : 
      85             : private:
      86             :     ImplBorderWindowView*   mpBorderView;
      87             :     VclPtr<vcl::Window>     mpMenuBarWindow;
      88             :     long                    mnMinWidth;
      89             :     long                    mnMinHeight;
      90             :     long                    mnMaxWidth;
      91             :     long                    mnMaxHeight;
      92             :     long                    mnRollHeight;
      93             :     long                    mnOrgMenuHeight;
      94             :     sal_uInt16              mnTitleType;
      95             :     WindowBorderStyle       mnBorderStyle;
      96             :     bool                    mbFloatWindow;
      97             :     bool                    mbSmallOutBorder;
      98             :     bool                    mbFrameBorder;
      99             :     bool                    mbPinned;
     100             :     bool                    mbRollUp;
     101             :     bool                    mbMenuHide;
     102             :     bool                    mbDockBtn;
     103             :     bool                    mbHideBtn;
     104             :     bool                    mbMenuBtn;
     105             :     bool                    mbDisplayActive;
     106             : 
     107             :     using Window::ImplInit;
     108             :     void                    ImplInit( vcl::Window* pParent,
     109             :                                       WinBits nStyle, sal_uInt16 nTypeStyle,
     110             :                                       SystemParentData* pParentData );
     111             :     void                    ImplInit( vcl::Window* pParent,
     112             :                                       WinBits nStyle, sal_uInt16 nTypeStyle,
     113             :                                       const ::com::sun::star::uno::Any& );
     114             : 
     115             :                             ImplBorderWindow (const ImplBorderWindow &) SAL_DELETED_FUNCTION;
     116             :                             ImplBorderWindow& operator= (const ImplBorderWindow &) SAL_DELETED_FUNCTION;
     117             : 
     118             : public:
     119             :                             ImplBorderWindow( vcl::Window* pParent,
     120             :                                               SystemParentData* pParentData,
     121             :                                               WinBits nStyle = 0,
     122             :                                               sal_uInt16 nTypeStyle = 0 );
     123             :                             ImplBorderWindow( vcl::Window* pParent, WinBits nStyle = 0,
     124             :                                               sal_uInt16 nTypeStyle = 0 );
     125             :     virtual                 ~ImplBorderWindow();
     126             :     virtual void            dispose() SAL_OVERRIDE;
     127             : 
     128             :     virtual void            MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     129             :     virtual void            MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     130             :     virtual void            Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     131             :     virtual void            Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
     132             :     virtual void            Activate() SAL_OVERRIDE;
     133             :     virtual void            Deactivate() SAL_OVERRIDE;
     134             :     virtual void            Resize() SAL_OVERRIDE;
     135             :     virtual void            RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     136             :     virtual void            StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     137             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     138             : 
     139             :     void                    InitView();
     140             :     void                    UpdateView( bool bNewView, const Size& rNewOutSize );
     141             :     void                    InvalidateBorder();
     142             : 
     143             :     using Window::Draw;
     144             :     void                    Draw( const Rectangle& rRect, OutputDevice* pDev, const Point& rPos );
     145             : 
     146             :     void                    SetDisplayActive( bool bActive );
     147             :     bool                    IsDisplayActive() const { return mbDisplayActive; }
     148             :     void                    SetTitleType( sal_uInt16 nTitleType, const Size& rSize );
     149             :     void                    SetBorderStyle( WindowBorderStyle nStyle );
     150       78212 :     WindowBorderStyle       GetBorderStyle() const { return mnBorderStyle; }
     151             :     void                    SetPin( bool bPin );
     152             :     void                    SetRollUp( bool bRollUp, const Size& rSize );
     153             :     void                    SetCloseButton();
     154             :     void                    SetDockButton( bool bDockButton );
     155             :     void                    SetHideButton( bool bHideButton );
     156             :     void                    SetMenuButton( bool bMenuButton );
     157             : 
     158             :     void                    UpdateMenuHeight();
     159             :     void                    SetMenuBarWindow( vcl::Window* pWindow );
     160             :     void                    SetMenuBarMode( bool bHide );
     161             : 
     162           1 :     void                    SetMinOutputSize( long nWidth, long nHeight )
     163           1 :                                 { mnMinWidth = nWidth; mnMinHeight = nHeight; }
     164           0 :     void                    SetMaxOutputSize( long nWidth, long nHeight )
     165           0 :                                 { mnMaxWidth = nWidth; mnMaxHeight = nHeight; }
     166             : 
     167             :     void                    GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
     168             :                                        sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
     169             :     long                    CalcTitleWidth() const;
     170             : 
     171             :     Rectangle               GetMenuRect() const;
     172             : 
     173             :     virtual Size            GetOptimalSize() const SAL_OVERRIDE;
     174             : };
     175             : 
     176           0 : struct ImplBorderFrameData
     177             : {
     178             :     VclPtr<ImplBorderWindow> mpBorderWindow;
     179             :     VclPtr<OutputDevice>     mpOutDev;
     180             :     Rectangle                maTitleRect;
     181             :     Rectangle                maPinRect;
     182             :     Rectangle                maCloseRect;
     183             :     Rectangle                maRollRect;
     184             :     Rectangle                maDockRect;
     185             :     Rectangle                maMenuRect;
     186             :     Rectangle                maHideRect;
     187             :     Rectangle                maHelpRect;
     188             :     Point                    maMouseOff;
     189             :     long                     mnWidth;
     190             :     long                     mnHeight;
     191             :     long                     mnTrackX;
     192             :     long                     mnTrackY;
     193             :     long                     mnTrackWidth;
     194             :     long                     mnTrackHeight;
     195             :     sal_Int32                mnLeftBorder;
     196             :     sal_Int32                mnTopBorder;
     197             :     sal_Int32                mnRightBorder;
     198             :     sal_Int32                mnBottomBorder;
     199             :     long                     mnNoTitleTop;
     200             :     long                     mnBorderSize;
     201             :     long                     mnTitleHeight;
     202             :     long                     mnTitleOff;
     203             :     sal_uInt16               mnHitTest;
     204             :     DrawButtonFlags          mnPinState;
     205             :     DrawButtonFlags          mnCloseState;
     206             :     DrawButtonFlags          mnRollState;
     207             :     DrawButtonFlags          mnDockState;
     208             :     DrawButtonFlags          mnMenuState;
     209             :     DrawButtonFlags          mnHideState;
     210             :     DrawButtonFlags          mnHelpState;
     211             :     sal_uInt16               mnTitleType;
     212             :     bool                     mbFloatWindow;
     213             :     bool                     mbDragFull;
     214             :     bool                     mbTitleClipped;
     215             : };
     216             : 
     217       19966 : class ImplBorderWindowView
     218             : {
     219             : public:
     220             :     virtual                 ~ImplBorderWindowView();
     221             : 
     222             :     virtual bool            MouseMove( const MouseEvent& rMEvt );
     223             :     virtual bool            MouseButtonDown( const MouseEvent& rMEvt );
     224             :     virtual bool            Tracking( const TrackingEvent& rTEvt );
     225             :     virtual OUString        RequestHelp( const Point& rPos, Rectangle& rHelpRect );
     226             : 
     227             :     virtual void            Init( OutputDevice* pDev, long nWidth, long nHeight ) = 0;
     228             :     virtual void            GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
     229             :                                        sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0;
     230             :     virtual long            CalcTitleWidth() const = 0;
     231             :     virtual void            DrawWindow(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags, const Point* pOffset = NULL) = 0;
     232             :     virtual Rectangle       GetMenuRect() const;
     233             : 
     234             :     static void             ImplInitTitle( ImplBorderFrameData* pData );
     235             :     static sal_uInt16       ImplHitTest( ImplBorderFrameData* pData, const Point& rPos );
     236             :     static bool             ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
     237             :     bool                    ImplMouseButtonDown( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
     238             :     static OUString         ImplRequestHelp( ImplBorderFrameData* pData, const Point& rPos, Rectangle& rHelpRect );
     239             :     static long             ImplCalcTitleWidth( const ImplBorderFrameData* pData );
     240             : };
     241             : 
     242        7230 : class ImplNoBorderWindowView : public ImplBorderWindowView
     243             : {
     244             : public:
     245             :                             ImplNoBorderWindowView( ImplBorderWindow* pBorderWindow );
     246             : 
     247             :     virtual void            Init( OutputDevice* pDev, long nWidth, long nHeight ) SAL_OVERRIDE;
     248             :     virtual void            GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
     249             :                                        sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const SAL_OVERRIDE;
     250             :     virtual long            CalcTitleWidth() const SAL_OVERRIDE;
     251             :     virtual void            DrawWindow(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags, const Point* pOffset) SAL_OVERRIDE;
     252             : };
     253             : 
     254       32622 : class ImplSmallBorderWindowView : public ImplBorderWindowView
     255             : {
     256             :     VclPtr<ImplBorderWindow> mpBorderWindow;
     257             :     VclPtr<OutputDevice>     mpOutDev;
     258             :     long                    mnWidth;
     259             :     long                    mnHeight;
     260             :     sal_Int32               mnLeftBorder;
     261             :     sal_Int32               mnTopBorder;
     262             :     sal_Int32               mnRightBorder;
     263             :     sal_Int32               mnBottomBorder;
     264             :     bool                    mbNWFBorder;
     265             : 
     266             : public:
     267             :                             ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow );
     268             : 
     269             :     virtual void            Init( OutputDevice* pOutDev, long nWidth, long nHeight ) SAL_OVERRIDE;
     270             :     virtual void            GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
     271             :                                        sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const SAL_OVERRIDE;
     272             :     virtual long            CalcTitleWidth() const SAL_OVERRIDE;
     273             :     virtual void            DrawWindow(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags, const Point* pOffset) SAL_OVERRIDE;
     274             : };
     275             : 
     276             : class ImplStdBorderWindowView : public ImplBorderWindowView
     277             : {
     278             :     ImplBorderFrameData     maFrameData;
     279             :     VclPtr<VirtualDevice>   mpATitleVirDev;
     280             :     VclPtr<VirtualDevice>   mpDTitleVirDev;
     281             : 
     282             : public:
     283             :                             ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow );
     284             :                             virtual ~ImplStdBorderWindowView();
     285             : 
     286             :     virtual bool        MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     287             :     virtual bool        MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     288             :     virtual bool        Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     289             :     virtual OUString        RequestHelp( const Point& rPos, Rectangle& rHelpRect ) SAL_OVERRIDE;
     290             :     virtual Rectangle       GetMenuRect() const SAL_OVERRIDE;
     291             : 
     292             :     virtual void            Init( OutputDevice* pDev, long nWidth, long nHeight ) SAL_OVERRIDE;
     293             :     virtual void            GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
     294             :                                        sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const SAL_OVERRIDE;
     295             :     virtual long            CalcTitleWidth() const SAL_OVERRIDE;
     296             :     virtual void            DrawWindow(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags, const Point* pOffset) SAL_OVERRIDE;
     297             : };
     298             : 
     299             : #endif // INCLUDED_VCL_INC_BRDWIN_HXX
     300             : 
     301             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11