LCOV - code coverage report
Current view: top level - include/vcl - button.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 49 44.9 %
Date: 2015-06-13 12:38:46 Functions: 26 53 49.1 %
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_BUTTON_HXX
      21             : #define INCLUDED_VCL_BUTTON_HXX
      22             : 
      23             : #include <tools/solar.h>
      24             : #include <tools/color.hxx>
      25             : #include <vcl/dllapi.h>
      26             : #include <vcl/image.hxx>
      27             : #include <vcl/ctrl.hxx>
      28             : #include <vcl/bitmap.hxx>
      29             : #include <vcl/salnativewidgets.hxx>
      30             : #include <rsc/rsc-vcl-shared-types.hxx>
      31             : #include <vcl/vclptr.hxx>
      32             : #include <vector>
      33             : 
      34             : class UserDrawEvent;
      35             : class ImplCommonButtonData;
      36             : enum class DrawButtonFlags;
      37             : 
      38             : class VCL_DLLPUBLIC Button : public Control
      39             : {
      40             : private:
      41             :     std::unique_ptr<ImplCommonButtonData> mpButtonData;
      42             :     Link<> maClickHdl;
      43             : 
      44             :     /// Command URL (like .uno:Save) in case the button should handle it.
      45             :     OUString maCommand;
      46             : 
      47             :                                     Button (const Button &) SAL_DELETED_FUNCTION;
      48             :                                     Button & operator= (const Button &) SAL_DELETED_FUNCTION;
      49             : public:
      50             :     SAL_DLLPRIVATE DrawButtonFlags  ImplGetButtonState() const;
      51             :     SAL_DLLPRIVATE DrawButtonFlags& ImplGetButtonState();
      52             :     SAL_DLLPRIVATE DrawTextFlags    ImplGetTextStyle( OUString& rText, WinBits nWinStyle, DrawFlags nDrawFlags );
      53             :     SAL_DLLPRIVATE void             ImplDrawAlignedImage(OutputDevice* pDev, Point& rPos, Size& rSize,
      54             :                                               bool bLayout, sal_uLong nImageSep, DrawFlags nDrawFlags,
      55             :                                               DrawTextFlags nTextStyle, Rectangle *pSymbolRect=NULL, bool bAddImageSep = false );
      56             :     SAL_DLLPRIVATE void             ImplSetFocusRect( const Rectangle &rFocusRect );
      57             :     SAL_DLLPRIVATE const Rectangle& ImplGetFocusRect() const;
      58             :     SAL_DLLPRIVATE void             ImplSetSymbolAlign( SymbolAlign eAlign );
      59             :     /// The x-coordinate of the vertical separator line, use in MenuButton subclass only.
      60             :     SAL_DLLPRIVATE long             ImplGetSeparatorX() const;
      61             :     SAL_DLLPRIVATE void             ImplSetSeparatorX( long nX );
      62             : 
      63             : protected:
      64             :     explicit            Button( WindowType nType );
      65             : 
      66             : public:
      67             :     virtual            ~Button();
      68             :     virtual void        dispose() SAL_OVERRIDE;
      69             : 
      70             :     virtual void        Click();
      71             : 
      72       15559 :     void                SetClickHdl( const Link<>& rLink ) { maClickHdl = rLink; }
      73           0 :     const Link<>&       GetClickHdl() const { return maClickHdl; }
      74             : 
      75             :     /// Setup handler for UNO commands so that commands like .uno:Something are handled automagically by this button.
      76             :     void                SetCommandHandler(const OUString& aCommand);
      77             : 
      78             :     static OUString     GetStandardText( StandardButtonType eButton );
      79             : 
      80             :     bool                SetModeImage( const Image& rImage );
      81             :     const Image         GetModeImage( ) const;
      82             :     bool                HasImage() const;
      83             :     void                SetImageAlign( ImageAlign eAlign );
      84             :     ImageAlign          GetImageAlign() const;
      85             : 
      86             :     void                EnableImageDisplay( bool bEnable );
      87             :     void                EnableTextDisplay( bool bEnable );
      88             : 
      89             :     void                SetFocusRect( const Rectangle& rFocusRect );
      90             :     bool                IsSmallSymbol() const;
      91             :     void                SetSmallSymbol(bool bSmall = true);
      92             :     virtual bool        set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
      93             : 
      94             : protected:
      95             : 
      96             :     /// Handler for click, in case we want the button to handle uno commands (.uno:Something).
      97             :     static sal_IntPtr   dispatchCommandHandler(void *, void *pCaller);
      98             : };
      99             : 
     100             : 
     101             : // - PushButton-Types -
     102             : 
     103             : 
     104             : enum class PushButtonDropdownStyle
     105             : {
     106             :     NONE            = 0x0000,
     107             :     Toolbox         = 0x0001,
     108             :     MenuButton      = 0x0002,
     109             : };
     110             : 
     111             : 
     112             : // - PushButton -
     113             : 
     114             : 
     115       18885 : class VCL_DLLPUBLIC PushButton : public Button
     116             : {
     117             : protected:
     118             :     SymbolType      meSymbol;
     119             :     TriState        meState;
     120             :     TriState        meSaveValue;
     121             :     PushButtonDropdownStyle mnDDStyle;
     122             :     bool            mbPressed;
     123             :     bool            mbInUserDraw;
     124             :     Link<>          maToggleHdl;
     125             : 
     126             :     SAL_DLLPRIVATE void            ImplInitPushButtonData();
     127             :     SAL_DLLPRIVATE WinBits         ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle );
     128             :     SAL_DLLPRIVATE void            ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
     129             :     SAL_DLLPRIVATE void            ImplDrawPushButtonContent(OutputDevice* pDev, DrawFlags nDrawFlags,
     130             :                                                              const Rectangle& rRect, bool bLayout, bool bMenuBtnSep);
     131             :     SAL_DLLPRIVATE void            ImplDrawPushButton(vcl::RenderContext& rRenderContext, bool bLayout = false);
     132             :     using Button::ImplGetTextStyle;
     133             :     SAL_DLLPRIVATE DrawTextFlags   ImplGetTextStyle( DrawFlags nDrawFlags ) const;
     134       20411 :     SAL_DLLPRIVATE bool            IsSymbol() const { return ( (meSymbol != SymbolType::DONTKNOW) && (meSymbol != SymbolType::IMAGE) ); }
     135          27 :     SAL_DLLPRIVATE bool            IsImage() const { return Button::HasImage(); }
     136             : 
     137             :     // Copy assignment is forbidden and not implemented.
     138             :     SAL_DLLPRIVATE                 PushButton( const PushButton & );
     139             :     SAL_DLLPRIVATE                 PushButton& operator=( const PushButton & );
     140             : 
     141             :     SAL_DLLPRIVATE void            ImplInit( vcl::Window* pParent, WinBits nStyle );
     142             : 
     143             :     using Control::ImplInitSettings;
     144             :     using Window::ImplInit;
     145             : public:
     146             :     SAL_DLLPRIVATE void            ImplSetDefButton( bool bSet );
     147             :     SAL_DLLPRIVATE void            ImplDrawPushButtonFrame(vcl::RenderContext& rRenderContext, Rectangle& rRect, DrawButtonFlags nStyle);
     148             :     SAL_DLLPRIVATE static bool     ImplHitTestPushButton(vcl::Window* pDev, const Point& rPos);
     149             :     SAL_DLLPRIVATE bool            ImplIsDefButton() const;
     150             : 
     151             : protected:
     152             :     explicit        PushButton( WindowType nType );
     153             : 
     154             :     virtual void    FillLayoutData() const SAL_OVERRIDE;
     155             :     virtual const vcl::Font&
     156             :                     GetCanonicalFont( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
     157             :     virtual const Color&
     158             :                     GetCanonicalTextColor( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
     159             : public:
     160             :     explicit        PushButton( vcl::Window* pParent, WinBits nStyle = 0 );
     161             :     explicit        PushButton( vcl::Window* pParent, const ResId& );
     162             : 
     163             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     164             :     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     165             :     virtual void    KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     166             :     virtual void    KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     167             :     virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
     168             :     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) SAL_OVERRIDE;
     169             :     virtual void    Resize() SAL_OVERRIDE;
     170             :     virtual void    GetFocus() SAL_OVERRIDE;
     171             :     virtual void    LoseFocus() SAL_OVERRIDE;
     172             :     virtual void    StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     173             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     174             :     virtual bool    PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     175             : 
     176             :     void            Toggle();
     177             : 
     178             :     void            SetSymbol( SymbolType eSymbol );
     179        4583 :     SymbolType      GetSymbol() const { return meSymbol; }
     180             :     void            SetSymbolAlign( SymbolAlign eAlign );
     181             : 
     182             :     void            SetDropDown( PushButtonDropdownStyle nStyle );
     183             :     PushButtonDropdownStyle GetDropDown() const { return mnDDStyle; }
     184             : 
     185             :     void            SetState( TriState eState );
     186           0 :     TriState        GetState() const { return meState; }
     187             : 
     188             :     void            Check( bool bCheck = true );
     189             :     bool            IsChecked() const;
     190             : 
     191             :     void            SetPressed( bool bPressed );
     192           0 :     bool            IsPressed() const { return mbPressed; }
     193             : 
     194             :     void            EndSelection();
     195             : 
     196           0 :     void            SaveValue() { meSaveValue = GetState(); }
     197             :     TriState        GetSavedValue() const { return meSaveValue; }
     198           0 :     bool            IsValueChangedFromSaved() const { return meSaveValue != GetState(); }
     199             : 
     200             :     Size            CalcMinimumSize( long nMaxWidth = 0 ) const;
     201             :     virtual Size    GetOptimalSize() const SAL_OVERRIDE;
     202             : 
     203             :     void            SetToggleHdl( const Link<>& rLink ) { maToggleHdl = rLink; }
     204             :     const Link<>&   GetToggleHdl() const { return maToggleHdl; }
     205             :     virtual bool    set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
     206             :     virtual void    ShowFocus(const Rectangle& rRect) SAL_OVERRIDE;
     207             : };
     208             : 
     209           0 : inline void PushButton::Check( bool bCheck )
     210             : {
     211           0 :     SetState( (bCheck) ? TRISTATE_TRUE : TRISTATE_FALSE );
     212           0 : }
     213             : 
     214           0 : inline bool PushButton::IsChecked() const
     215             : {
     216           0 :     return (GetState() == TRISTATE_TRUE);
     217             : }
     218             : 
     219           5 : class VCL_DLLPUBLIC OKButton : public PushButton
     220             : {
     221             : protected:
     222             :     using PushButton::ImplInit;
     223             : private:
     224             :     SAL_DLLPRIVATE void            ImplInit( vcl::Window* pParent, WinBits nStyle );
     225             : 
     226             :                                    OKButton (const OKButton &) SAL_DELETED_FUNCTION;
     227             :                                    OKButton & operator= (const OKButton &) SAL_DELETED_FUNCTION;
     228             : 
     229             : public:
     230             :     explicit        OKButton( vcl::Window* pParent, WinBits nStyle = WB_DEFBUTTON );
     231             : 
     232             :     virtual void    Click() SAL_OVERRIDE;
     233             : };
     234             : 
     235           5 : class VCL_DLLPUBLIC CancelButton : public PushButton
     236             : {
     237             : protected:
     238             :     using PushButton::ImplInit;
     239             : private:
     240             :     SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
     241             : 
     242             :                         CancelButton (const CancelButton &) SAL_DELETED_FUNCTION;
     243             :                         CancelButton & operator= (const CancelButton &) SAL_DELETED_FUNCTION;
     244             : 
     245             : public:
     246             :     explicit        CancelButton( vcl::Window* pParent, WinBits nStyle = 0 );
     247             : 
     248             :     virtual void    Click() SAL_OVERRIDE;
     249             : };
     250             : 
     251           0 : class VCL_DLLPUBLIC CloseButton : public CancelButton
     252             : {
     253             : public:
     254             :     explicit CloseButton(vcl::Window* pParent, WinBits nStyle = 0);
     255             : };
     256             : 
     257             : 
     258             : 
     259             : // - HelpButton -
     260             : 
     261             : 
     262           7 : class VCL_DLLPUBLIC HelpButton : public PushButton
     263             : {
     264             : protected:
     265             :     using PushButton::ImplInit;
     266             : private:
     267             :     SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
     268             : 
     269             :                         HelpButton( const HelpButton & ) SAL_DELETED_FUNCTION;
     270             :                         HelpButton & operator= ( const HelpButton & ) SAL_DELETED_FUNCTION;
     271             : 
     272             : public:
     273             :     explicit        HelpButton( vcl::Window* pParent, WinBits nStyle = 0 );
     274             : 
     275             :     virtual void    Click() SAL_OVERRIDE;
     276             : };
     277             : 
     278             : 
     279             : // - RadioButton -
     280             : class VCL_DLLPUBLIC RadioButton : public Button
     281             : {
     282             : private:
     283             :     std::shared_ptr< std::vector< VclPtr< RadioButton > > > m_xGroup;
     284             :     Rectangle       maStateRect;
     285             :     Rectangle       maMouseRect;
     286             :     Image           maImage;
     287             :     bool            mbChecked;
     288             :     bool            mbSaveValue;
     289             :     bool            mbRadioCheck;
     290             :     bool            mbStateChanged;
     291             :     Link<>          maToggleHdl;
     292             :     // when mbLegacyNoTextAlign is set then the old behaviour where
     293             :     // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement
     294             :     // occurs, otherwise the image ( radiobutton circle ) is placed
     295             :     // to the left or right ( depending on RTL or LTR settings )
     296             :     bool            mbLegacyNoTextAlign;
     297             :     SAL_DLLPRIVATE void     ImplInitRadioButtonData();
     298             :     SAL_DLLPRIVATE WinBits  ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle );
     299             :     SAL_DLLPRIVATE void     ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
     300             :     SAL_DLLPRIVATE void     ImplDrawRadioButtonState(vcl::RenderContext& rRenderContext);
     301             :     SAL_DLLPRIVATE void     ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags,
     302             :                               const Point& rPos, const Size& rSize,
     303             :                               const Size& rImageSize, Rectangle& rStateRect,
     304             :                               Rectangle& rMouseRect, bool bLayout = false );
     305             :     SAL_DLLPRIVATE void     ImplDrawRadioButton(vcl::RenderContext& rRenderContext, bool bLayout = false );
     306             :     SAL_DLLPRIVATE void     ImplUncheckAllOther();
     307             :     SAL_DLLPRIVATE Size     ImplGetRadioImageSize() const;
     308             :     SAL_DLLPRIVATE long     ImplGetImageToTextDistance() const;
     309             : 
     310             :                             RadioButton(const RadioButton &) SAL_DELETED_FUNCTION;
     311             :                             RadioButton& operator= (const RadioButton &) SAL_DELETED_FUNCTION;
     312             : 
     313             : protected:
     314             :     using Control::ImplInitSettings;
     315             :     using Window::ImplInit;
     316             :     SAL_DLLPRIVATE void     ImplInit( vcl::Window* pParent, WinBits nStyle );
     317             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     318             : 
     319             : public:
     320             :     SAL_DLLPRIVATE void     ImplCallClick( bool bGrabFocus = false, GetFocusFlags nFocusFlags = GetFocusFlags::NONE );
     321             :     SAL_DLLPRIVATE void     ImplSetMinimumNWFSize();
     322             : 
     323             : protected:
     324             :     virtual void    FillLayoutData() const SAL_OVERRIDE;
     325             :     virtual const vcl::Font&
     326             :                     GetCanonicalFont( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
     327             :     virtual const Color&
     328             :                     GetCanonicalTextColor( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
     329             : 
     330           0 :     inline void             SetMouseRect( const Rectangle& _rMouseRect )    { maMouseRect = _rMouseRect; }
     331             :     inline const Rectangle& GetMouseRect( ) const                           { return maMouseRect; }
     332           0 :     inline void             SetStateRect( const Rectangle& _rStateRect )    { maStateRect = _rStateRect; }
     333             :     inline const Rectangle& GetStateRect( ) const                           { return maStateRect; }
     334             : 
     335             :     // draws the radio button (the knob image), in its current state (pressed/checked)
     336             :     // at the usual location, which can be overridden with SetStateRect
     337             :     void            DrawRadioButtonState(vcl::RenderContext& rRenderContext);
     338             : 
     339             : public:
     340             :     explicit        RadioButton( vcl::Window* pParent, WinBits nWinStyle = 0 );
     341             :     explicit        RadioButton( vcl::Window* pParent, const ResId& );
     342             :     virtual         ~RadioButton();
     343             :     virtual void    dispose() SAL_OVERRIDE;
     344             : 
     345             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     346             :     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     347             :     virtual void    KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     348             :     virtual void    KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     349             :     virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
     350             :     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) SAL_OVERRIDE;
     351             :     virtual void    Resize() SAL_OVERRIDE;
     352             :     virtual void    GetFocus() SAL_OVERRIDE;
     353             :     virtual void    LoseFocus() SAL_OVERRIDE;
     354             :     virtual void    StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     355             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     356             :     virtual bool    PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     357             : 
     358             :     void            Toggle();
     359             : 
     360           0 :     bool            IsStateChanged() const { return mbStateChanged; }
     361             : 
     362          44 :     void            EnableRadioCheck( bool bRadioCheck = true ) { mbRadioCheck = bRadioCheck; }
     363          41 :     bool            IsRadioCheckEnabled() const { return mbRadioCheck; }
     364             : 
     365             :     bool            SetModeRadioImage( const Image& rImage );
     366           0 :     const Image&    GetModeRadioImage( ) const { return maImage;}
     367             : 
     368             :     void            SetState( bool bCheck );
     369             :     void            Check( bool bCheck = true );
     370       16134 :     bool            IsChecked() const { return mbChecked; }
     371             : 
     372           0 :     void            SaveValue() { mbSaveValue = IsChecked(); }
     373           0 :     bool            GetSavedValue() const { return mbSaveValue; }
     374           0 :     bool            IsValueChangedFromSaved() const { return mbSaveValue != IsChecked(); }
     375             : 
     376             :     static Image    GetRadioImage( const AllSettings& rSettings, DrawButtonFlags nFlags );
     377             : 
     378             :     Size            CalcMinimumSize( long nMaxWidth = 0 ) const;
     379             :     virtual Size    GetOptimalSize() const SAL_OVERRIDE;
     380             : 
     381           0 :     void            SetToggleHdl( const Link<>& rLink ) { maToggleHdl = rLink; }
     382             :     const Link<>&   GetToggleHdl() const { return maToggleHdl; }
     383             : 
     384             :     /** GetRadioButtonGroup returns a list of pointers to <code>RadioButton</code>s in the same group.
     385             : 
     386             :     The pointers in the returned list are valid at the time call returns. However rescheduling
     387             :     or giving up the SolarMutex may mean events get executed that lead to the pointers getting
     388             :     invalid.
     389             : 
     390             :     @param bIncludeThis
     391             :     defines whether <code>this</code> is contained in the returned list
     392             : 
     393             :     @return
     394             :     on return contains the <code>RadioButton</code>s
     395             :     in the same group as this <code>RadioButton</code>.
     396             :     */
     397             :     std::vector<VclPtr<RadioButton> > GetRadioButtonGroup(bool bIncludeThis = true) const;
     398             : 
     399             :     virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
     400             : 
     401             :     /*
     402             :      * Group this RadioButton with another
     403             :      */
     404             :     void group(RadioButton &rOther);
     405             :     virtual void ShowFocus(const Rectangle& rRect) SAL_OVERRIDE;
     406             : };
     407             : 
     408             : 
     409             : // - CheckBox -
     410             : 
     411             : 
     412        4430 : class VCL_DLLPUBLIC CheckBox : public Button
     413             : {
     414             : private:
     415             :     Rectangle       maStateRect;
     416             :     Rectangle       maMouseRect;
     417             :     TriState        meState;
     418             :     TriState        meSaveValue;
     419             :     bool            mbTriState;
     420             :     Link<>          maToggleHdl;
     421             :     // when mbLegacyNoTextAlign is set then the old behaviour where
     422             :     // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement
     423             :     // occurs, otherwise the image ( checkbox box ) is placed
     424             :     // to the left or right ( depending on RTL or LTR settings )
     425             :     bool            mbLegacyNoTextAlign;
     426             :     SAL_DLLPRIVATE void         ImplInitCheckBoxData();
     427             :     SAL_DLLPRIVATE WinBits      ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle );
     428             :     SAL_DLLPRIVATE void         ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
     429             :     SAL_DLLPRIVATE void         ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags,
     430             :                                     const Point& rPos, const Size& rSize,
     431             :                                     const Size& rImageSize, Rectangle& rStateRect,
     432             :                                     Rectangle& rMouseRect, bool bLayout );
     433             :     SAL_DLLPRIVATE void         ImplDrawCheckBox(vcl::RenderContext& rRenderContext, bool bLayout = false );
     434             :     SAL_DLLPRIVATE long         ImplGetImageToTextDistance() const;
     435             :     SAL_DLLPRIVATE Size         ImplGetCheckImageSize() const;
     436             : 
     437             :                                 CheckBox(const CheckBox &) SAL_DELETED_FUNCTION;
     438             :                                 CheckBox& operator= (const CheckBox &) SAL_DELETED_FUNCTION;
     439             : 
     440             : protected:
     441             :     using Control::ImplInitSettings;
     442             :     using Window::ImplInit;
     443             :     SAL_DLLPRIVATE void         ImplInit( vcl::Window* pParent, WinBits nStyle );
     444             :     SAL_DLLPRIVATE void         ImplLoadRes( const ResId& rResId );
     445             :     virtual void                FillLayoutData() const SAL_OVERRIDE;
     446             :     virtual const vcl::Font&    GetCanonicalFont( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
     447             :     virtual const Color&        GetCanonicalTextColor( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
     448             : 
     449             :     virtual void ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext);
     450           0 :     SAL_DLLPRIVATE const Rectangle& GetStateRect() const { return maStateRect; }
     451           0 :     SAL_DLLPRIVATE const Rectangle& GetMouseRect() const { return maMouseRect; }
     452             : 
     453             : public:
     454             :     SAL_DLLPRIVATE void         ImplCheck();
     455             :     SAL_DLLPRIVATE void         ImplSetMinimumNWFSize();
     456             : public:
     457             :     explicit        CheckBox( vcl::Window* pParent, WinBits nStyle = 0 );
     458             :     explicit        CheckBox( vcl::Window* pParent, const ResId& );
     459             : 
     460             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     461             :     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     462             :     virtual void    KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     463             :     virtual void    KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     464             :     virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
     465             :     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) SAL_OVERRIDE;
     466             :     virtual void    Resize() SAL_OVERRIDE;
     467             :     virtual void    GetFocus() SAL_OVERRIDE;
     468             :     virtual void    LoseFocus() SAL_OVERRIDE;
     469             :     virtual void    StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     470             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     471             :     virtual bool    PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     472             : 
     473             :     void            Toggle();
     474             : 
     475             :     void            SetState( TriState eState );
     476        6387 :     TriState        GetState() const { return meState; }
     477             : 
     478             :     void            Check( bool bCheck = true );
     479             :     bool            IsChecked() const;
     480             : 
     481             :     void            EnableTriState( bool bTriState = true );
     482           0 :     bool            IsTriStateEnabled() const { return mbTriState; }
     483             : 
     484           0 :     void            SaveValue() { meSaveValue = GetState(); }
     485           0 :     TriState        GetSavedValue() const { return meSaveValue; }
     486           0 :     bool            IsValueChangedFromSaved() const { return meSaveValue != GetState(); }
     487             : 
     488             :     static Image    GetCheckImage( const AllSettings& rSettings, DrawButtonFlags nFlags );
     489             : 
     490             :     Size            CalcMinimumSize( long nMaxWidth = 0 ) const;
     491             :     virtual Size    GetOptimalSize() const SAL_OVERRIDE;
     492             : 
     493           0 :     void            SetToggleHdl( const Link<>& rLink ) { maToggleHdl = rLink; }
     494             :     const Link<>&   GetToggleHdl() const { return maToggleHdl; }
     495             :     bool            IsLegacyNoTextAlign() { return mbLegacyNoTextAlign; }
     496          20 :     void            SetLegacyNoTextAlign( bool bVal ) { mbLegacyNoTextAlign = bVal; }
     497             : 
     498             :     virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
     499             :     virtual void ShowFocus(const Rectangle& rRect) SAL_OVERRIDE;
     500             : };
     501             : 
     502         209 : inline void CheckBox::Check( bool bCheck )
     503             : {
     504         209 :     SetState( (bCheck) ? TRISTATE_TRUE : TRISTATE_FALSE );
     505         209 : }
     506             : 
     507        6375 : inline bool CheckBox::IsChecked() const
     508             : {
     509        6375 :     return (GetState() == TRISTATE_TRUE);
     510             : }
     511             : 
     512             : 
     513             : // - Control-Layer fuer alten Code -
     514             : 
     515             : 
     516         872 : class VCL_DLLPUBLIC ImageButton : public PushButton
     517             : {
     518             : protected:
     519             :     using PushButton::ImplInitStyle;
     520             : private:
     521             :     SAL_DLLPRIVATE void     ImplInitStyle();
     522             : 
     523             :                             ImageButton( const ImageButton & ) SAL_DELETED_FUNCTION;
     524             :                             ImageButton & operator= ( const ImageButton & ) SAL_DELETED_FUNCTION;
     525             : 
     526             : public:
     527             :                  ImageButton( vcl::Window* pParent, WinBits nStyle = 0 );
     528             :                  ImageButton( vcl::Window* pParent, const ResId& rResId );
     529             : };
     530             : 
     531        3020 : class VCL_DLLPUBLIC ImageRadioButton : public RadioButton
     532             : {
     533             :                     ImageRadioButton( const ImageRadioButton & ) SAL_DELETED_FUNCTION;
     534             :                     ImageRadioButton & operator= ( const ImageRadioButton & ) SAL_DELETED_FUNCTION;
     535             : 
     536             : public:
     537             :     explicit        ImageRadioButton( vcl::Window* pParent, WinBits nStyle = 0 );
     538             : };
     539             : 
     540          40 : class VCL_DLLPUBLIC TriStateBox : public CheckBox
     541             : {
     542             :                     TriStateBox( const TriStateBox & ) SAL_DELETED_FUNCTION;
     543             :                     TriStateBox & operator= ( const TriStateBox & ) SAL_DELETED_FUNCTION;
     544             : 
     545             : public:
     546             :     explicit        TriStateBox( vcl::Window* pParent, WinBits nStyle = 0 );
     547             : };
     548             : 
     549           0 : class VCL_DLLPUBLIC DisclosureButton : public CheckBox
     550             : {
     551             : protected:
     552             :     SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
     553             : public:
     554             :     explicit DisclosureButton( vcl::Window* pParent, WinBits nStyle = 0 );
     555             : 
     556             :     virtual void    KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     557             : };
     558             : 
     559             : #endif // INCLUDED_VCL_BUTTON_HXX
     560             : 
     561             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11