LCOV - code coverage report
Current view: top level - vcl/source/window - menubarwindow.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 7 57.1 %
Date: 2015-06-13 12:38:46 Functions: 5 8 62.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_SOURCE_WINDOW_MENUBARWINDOW_HXX
      21             : #define INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
      22             : 
      23             : #include "menuwindow.hxx"
      24             : 
      25             : #include <vcl/button.hxx>
      26             : #include <vcl/menu.hxx>
      27             : #include <vcl/toolbox.hxx>
      28             : #include <vcl/window.hxx>
      29             : 
      30             : /** Toolbox that holds the close button (right hand side of the menubar).
      31             : 
      32             : This is also used by the online update check; when an update is available, it
      33             : inserts here the button that leads to the download of the update.
      34             : */
      35             : class DecoToolBox : public ToolBox
      36             : {
      37             :     long lastSize;
      38             :     Size maMinSize;
      39             : 
      40             :     using Window::ImplInit;
      41             : public:
      42             :              DecoToolBox( vcl::Window* pParent, WinBits nStyle = 0 );
      43        6386 :     virtual ~DecoToolBox() {}
      44             : 
      45             :     void    ImplInit();
      46             : 
      47             :     void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
      48             : 
      49             :     void    SetImages( long nMaxHeight = 0, bool bForce = false );
      50             : 
      51             :     void    calcMinSize();
      52        9737 :     const Size& getMinSize() { return maMinSize;}
      53             : 
      54             :     Image   maImage;
      55             : };
      56             : 
      57             : 
      58             : /** Class that implements the actual window of the menu bar.
      59             : */
      60             : class MenuBarWindow : public vcl::Window, public IMenuBarWindow
      61             : {
      62             :     friend class MenuBar;
      63             :     friend class Menu;
      64             : 
      65             : private:
      66             :     struct AddButtonEntry
      67             :     {
      68             :         sal_uInt16    m_nId;
      69             :         Link<>        m_aSelectLink;
      70             :         Link<>        m_aHighlightLink;
      71             : 
      72           0 :         AddButtonEntry() : m_nId( 0 ) {}
      73             :     };
      74             : 
      75             :     Menu*           pMenu;
      76             :     PopupMenu*      pActivePopup;
      77             :     sal_uInt16      nHighlightedItem;
      78             :     sal_uInt16      nRolloveredItem;
      79             :     sal_uLong       nSaveFocusId;
      80             :     bool            mbAutoPopup;
      81             :     bool            bIgnoreFirstMove;
      82             :     bool            bStayActive;
      83             : 
      84             :     VclPtr<DecoToolBox>  aCloseBtn;
      85             :     VclPtr<PushButton>   aFloatBtn;
      86             :     VclPtr<PushButton>   aHideBtn;
      87             : 
      88             :     std::map< sal_uInt16, AddButtonEntry > m_aAddButtons;
      89             : 
      90             :     void            HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight);
      91             :     virtual void    ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus = true, bool bDefaultToDocument = true) SAL_OVERRIDE;
      92             : 
      93             :     sal_uInt16      ImplFindEntry( const Point& rMousePos ) const;
      94             :     void            ImplCreatePopup( bool bPreSelectFirst );
      95             :     virtual bool    HandleKeyEvent(const KeyEvent& rKEvent, bool bFromMenu = true) SAL_OVERRIDE;
      96             :     Rectangle       ImplGetItemRect( sal_uInt16 nPos );
      97             : 
      98             :     void            ImplInitStyleSettings();
      99             : 
     100             :     virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
     101             : 
     102             :     DECL_LINK_TYPED(CloseHdl, ToolBox *, void);
     103             :     DECL_LINK(FloatHdl, void *);
     104             :     DECL_LINK(HideHdl, void *);
     105             :     DECL_LINK( ToolboxEventHdl, VclWindowEvent* );
     106             :     DECL_LINK( ShowHideListener, VclWindowEvent* );
     107             : 
     108             :     void            StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     109             :     void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     110             :     void            LoseFocus() SAL_OVERRIDE;
     111             :     void            GetFocus() SAL_OVERRIDE;
     112             : 
     113             : public:
     114             :     explicit        MenuBarWindow( vcl::Window* pParent );
     115             :     virtual         ~MenuBarWindow();
     116             :     virtual void    dispose() SAL_OVERRIDE;
     117             : 
     118             :     virtual void    ShowButtons(bool bClose, bool bFloat, bool bHide) SAL_OVERRIDE;
     119             : 
     120             :     virtual void    MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     121             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     122             :     virtual void    MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     123             :     virtual void    KeyInput( const KeyEvent& rKEvent ) SAL_OVERRIDE;
     124             :     virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
     125             :     virtual void    Resize() SAL_OVERRIDE;
     126             :     virtual void    RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     127             : 
     128           0 :     virtual void    SetFocusId(sal_uLong nId) SAL_OVERRIDE { nSaveFocusId = nId; }
     129           0 :     virtual sal_uLong GetFocusId() const SAL_OVERRIDE { return nSaveFocusId; }
     130             : 
     131             :     virtual void    SetMenu(MenuBar* pMenu) SAL_OVERRIDE;
     132             :     virtual void    SetHeight(long nHeight) SAL_OVERRIDE;
     133             :     virtual void    KillActivePopup() SAL_OVERRIDE;
     134             :     virtual void    PopupClosed(Menu* pMenu) SAL_OVERRIDE;
     135         256 :     virtual sal_uInt16 GetHighlightedItem() const SAL_OVERRIDE { return nHighlightedItem; }
     136             :     virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
     137             : 
     138           8 :     virtual void    SetAutoPopup(bool bAuto) SAL_OVERRIDE { mbAutoPopup = bAuto; }
     139             :     virtual void    LayoutChanged() SAL_OVERRIDE;
     140             :     Size            MinCloseButtonSize();
     141             : 
     142             :     /// Add an arbitrary button to the menubar that will appear next to the close button.
     143             :     virtual sal_uInt16 AddMenuBarButton(const Image&, const Link<>&, const OUString&, sal_uInt16 nPos) SAL_OVERRIDE;
     144             :     virtual void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link<>&) SAL_OVERRIDE;
     145             :     virtual Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId) SAL_OVERRIDE;
     146             :     virtual void RemoveMenuBarButton(sal_uInt16 nId) SAL_OVERRIDE;
     147             :     virtual bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId) SAL_OVERRIDE;
     148             : };
     149             : 
     150             : #endif // INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11