LCOV - code coverage report
Current view: top level - vcl/source/window - menubarwindow.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 4 7 57.1 %
Date: 2014-11-03 Functions: 4 8 50.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_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        5474 : 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             :     void    ImplInit();
      44             : 
      45             :     void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
      46             : 
      47             :     void    SetImages( long nMaxHeight = 0, bool bForce = false );
      48             : 
      49             :     void    calcMinSize();
      50       16792 :     const Size& getMinSize() { return maMinSize;}
      51             : 
      52             :     Image   maImage;
      53             : };
      54             : 
      55             : /** Class that implements the actual window of the menu bar.
      56             : */
      57             : class MenuBarWindow : public vcl::Window, public IMenuBarWindow
      58             : {
      59             :     friend class MenuBar;
      60             :     friend class Menu;
      61             : 
      62             : private:
      63             :     struct AddButtonEntry
      64             :     {
      65             :         sal_uInt16      m_nId;
      66             :         Link        m_aSelectLink;
      67             :         Link        m_aHighlightLink;
      68             : 
      69           0 :         AddButtonEntry() : m_nId( 0 ) {}
      70             :     };
      71             : 
      72             :     Menu*           pMenu;
      73             :     PopupMenu*      pActivePopup;
      74             :     sal_uInt16          nHighlightedItem;
      75             :     sal_uInt16          nRolloveredItem;
      76             :     sal_uLong           nSaveFocusId;
      77             :     bool            mbAutoPopup;
      78             :     bool            bIgnoreFirstMove;
      79             :     bool            bStayActive;
      80             : 
      81             :     DecoToolBox     aCloseBtn;
      82             :     PushButton      aFloatBtn;
      83             :     PushButton      aHideBtn;
      84             : 
      85             :     std::map< sal_uInt16, AddButtonEntry > m_aAddButtons;
      86             : 
      87             :     void            HighlightItem( sal_uInt16 nPos, bool bHighlight );
      88             :     virtual void    ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus = true, bool bDefaultToDocument = true) SAL_OVERRIDE;
      89             : 
      90             :     sal_uInt16          ImplFindEntry( const Point& rMousePos ) const;
      91             :     void            ImplCreatePopup( bool bPreSelectFirst );
      92             :     virtual bool    HandleKeyEvent(const KeyEvent& rKEvent, bool bFromMenu = true) SAL_OVERRIDE;
      93             :     Rectangle       ImplGetItemRect( sal_uInt16 nPos );
      94             : 
      95             :     void            ImplInitStyleSettings();
      96             : 
      97             :                     DECL_LINK(CloseHdl, void *);
      98             :                     DECL_LINK(FloatHdl, void *);
      99             :                     DECL_LINK(HideHdl, void *);
     100             :                     DECL_LINK( ToolboxEventHdl, VclWindowEvent* );
     101             :                     DECL_LINK( ShowHideListener, VclWindowEvent* );
     102             : 
     103             :     void            StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     104             :     void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     105             :     void            LoseFocus() SAL_OVERRIDE;
     106             :     void            GetFocus() SAL_OVERRIDE;
     107             : 
     108             : public:
     109             :                     MenuBarWindow( vcl::Window* pParent );
     110             :                     virtual ~MenuBarWindow();
     111             : 
     112             :     virtual void    ShowButtons(bool bClose, bool bFloat, bool bHide) SAL_OVERRIDE;
     113             : 
     114             :     virtual void    MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     115             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     116             :     virtual void    MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     117             :     virtual void    KeyInput( const KeyEvent& rKEvent ) SAL_OVERRIDE;
     118             :     virtual void    Paint( const Rectangle& rRect ) SAL_OVERRIDE;
     119             :     virtual void    Resize() SAL_OVERRIDE;
     120             :     virtual void    RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     121             : 
     122           0 :     virtual void    SetFocusId(sal_uLong nId) SAL_OVERRIDE { nSaveFocusId = nId; }
     123           0 :     virtual sal_uLong GetFocusId() const SAL_OVERRIDE { return nSaveFocusId; }
     124             : 
     125             :     virtual void    SetMenu(MenuBar* pMenu) SAL_OVERRIDE;
     126             :     virtual void    SetHeight(long nHeight) SAL_OVERRIDE;
     127             :     virtual void    KillActivePopup() SAL_OVERRIDE;
     128             :     virtual void    PopupClosed(Menu* pMenu) SAL_OVERRIDE;
     129         492 :     virtual sal_uInt16 GetHighlightedItem() const SAL_OVERRIDE { return nHighlightedItem; }
     130             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
     131             : 
     132          16 :     virtual void    SetAutoPopup(bool bAuto) SAL_OVERRIDE { mbAutoPopup = bAuto; }
     133             :     virtual void    LayoutChanged() SAL_OVERRIDE;
     134             :     Size            MinCloseButtonSize();
     135             : 
     136             :     /// Add an arbitrary button to the menubar that will appear next to the close button.
     137             :     virtual sal_uInt16 AddMenuBarButton(const Image&, const Link&, const OUString&, sal_uInt16 nPos) SAL_OVERRIDE;
     138             :     virtual void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link&) SAL_OVERRIDE;
     139             :     virtual Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId) SAL_OVERRIDE;
     140             :     virtual void RemoveMenuBarButton(sal_uInt16 nId) SAL_OVERRIDE;
     141             :     virtual bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId) SAL_OVERRIDE;
     142             : };
     143             : 
     144             : #endif // INCLUDED_VCL_SOURCE_WINDOW_MENUBARWINDOW_HXX
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10