LCOV - code coverage report
Current view: top level - vcl/inc/vcl - button.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2012-08-25 Functions: 0 17 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SV_BUTTON_HXX
      30                 :            : #define _SV_BUTTON_HXX
      31                 :            : 
      32                 :            : #include <tools/solar.h>
      33                 :            : #include <vcl/dllapi.h>
      34                 :            : #include <vcl/image.hxx>
      35                 :            : #include <vcl/symbol.hxx>
      36                 :            : #include <vcl/ctrl.hxx>
      37                 :            : #include <vcl/bitmap.hxx>
      38                 :            : #include <vcl/salnativewidgets.hxx>
      39                 :            : 
      40                 :            : #include <vector>
      41                 :            : 
      42                 :            : class UserDrawEvent;
      43                 :            : class ImplCommonButtonData;
      44                 :            : 
      45                 :            : // ----------
      46                 :            : // - Button -
      47                 :            : // ----------
      48                 :            : 
      49                 :            : class VCL_DLLPUBLIC Button : public Control
      50                 :            : {
      51                 :            : private:
      52                 :            :     ImplCommonButtonData *mpButtonData;
      53                 :            :     Link                  maClickHdl;
      54                 :            : 
      55                 :            :     // Copy assignment is forbidden and not implemented.
      56                 :            :     SAL_DLLPRIVATE                  Button (const Button &);
      57                 :            :     SAL_DLLPRIVATE                  Button & operator= (const Button &);
      58                 :            : public:
      59                 :            :     SAL_DLLPRIVATE sal_uInt16           ImplGetButtonState() const;
      60                 :            :     SAL_DLLPRIVATE sal_uInt16&          ImplGetButtonState();
      61                 :            :     SAL_DLLPRIVATE sal_uInt16           ImplGetTextStyle( XubString& rText, WinBits nWinStyle, sal_uLong nDrawFlags );
      62                 :            :     SAL_DLLPRIVATE void             ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, Size& rSize,
      63                 :            :                                               sal_Bool bLayout, sal_uLong nImageSep, sal_uLong nDrawFlags,
      64                 :            :                                               sal_uInt16 nTextStyle, Rectangle *pSymbolRect=NULL, bool bAddImageSep = false );
      65                 :            :     SAL_DLLPRIVATE void             ImplSetFocusRect( const Rectangle &rFocusRect );
      66                 :            :     SAL_DLLPRIVATE const Rectangle& ImplGetFocusRect() const;
      67                 :            :     SAL_DLLPRIVATE void             ImplSetSymbolAlign( SymbolAlign eAlign );
      68                 :            :     SAL_DLLPRIVATE void             ImplSetSmallSymbol( sal_Bool bSmall = sal_True );
      69                 :            :     /// The x-coordinate of the vertical separator line, use in MenuButton subclass only.
      70                 :            :     SAL_DLLPRIVATE long             ImplGetSeparatorX() const;
      71                 :            :     SAL_DLLPRIVATE void             ImplSetSeparatorX( long nX );
      72                 :            : 
      73                 :            : protected:
      74                 :            :                         Button( WindowType nType );
      75                 :            : 
      76                 :            : public:
      77                 :            :                        ~Button();
      78                 :            : 
      79                 :            :     virtual void        Click();
      80                 :            : 
      81                 :          0 :     void                SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
      82                 :            :     const Link&         GetClickHdl() const { return maClickHdl; }
      83                 :            : 
      84                 :            :     static XubString    GetStandardText( StandardButtonType eButton );
      85                 :            :     static XubString    GetStandardHelpText( StandardButtonType eButton );
      86                 :            : 
      87                 :            :     sal_Bool            SetModeImage( const Image& rImage );
      88                 :            :     const Image         GetModeImage( ) const;
      89                 :            :     sal_Bool            HasImage() const;
      90                 :            :     void                SetImageAlign( ImageAlign eAlign );
      91                 :            :     ImageAlign          GetImageAlign() const;
      92                 :            : 
      93                 :            :     void                EnableImageDisplay( sal_Bool bEnable );
      94                 :            :     void                EnableTextDisplay( sal_Bool bEnable );
      95                 :            : 
      96                 :            :     void                SetFocusRect( const Rectangle& rFocusRect );
      97                 :            :     bool IsSmallSymbol () const;
      98                 :            : };
      99                 :            : 
     100                 :            : // --------------------
     101                 :            : // - PushButton-Types -
     102                 :            : // --------------------
     103                 :            : 
     104                 :            : #define PUSHBUTTON_DROPDOWN_TOOLBOX         ((sal_uInt16)0x0001)
     105                 :            : #define PUSHBUTTON_DROPDOWN_MENUBUTTON      ((sal_uInt16)0x0002)
     106                 :            : 
     107                 :            : // --------------
     108                 :            : // - PushButton -
     109                 :            : // --------------
     110                 :            : 
     111                 :            : class VCL_DLLPUBLIC PushButton : public Button
     112                 :            : {
     113                 :            : protected:
     114                 :            :     SymbolType      meSymbol;
     115                 :            :     TriState        meState;
     116                 :            :     TriState        meSaveValue;
     117                 :            :     sal_uInt16          mnDDStyle;
     118                 :            :     sal_Bool            mbPressed;
     119                 :            :     sal_Bool            mbInUserDraw;
     120                 :            :     Link            maToggleHdl;
     121                 :            : 
     122                 :            :     SAL_DLLPRIVATE void            ImplInitPushButtonData();
     123                 :            :     SAL_DLLPRIVATE WinBits         ImplInitStyle( const Window* pPrevWindow, WinBits nStyle );
     124                 :            :     SAL_DLLPRIVATE void            ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
     125                 :            :     SAL_DLLPRIVATE void            ImplDrawPushButtonContent( OutputDevice* pDev, sal_uLong nDrawFlags,
     126                 :            :                                                const Rectangle& rRect, bool bLayout, bool bMenuBtnSep );
     127                 :            :     SAL_DLLPRIVATE void            ImplDrawPushButton( bool bLayout = false );
     128                 :            :     using Button::ImplGetTextStyle;
     129                 :            :     SAL_DLLPRIVATE sal_uInt16          ImplGetTextStyle( sal_uLong nDrawFlags ) const;
     130                 :            :     SAL_DLLPRIVATE sal_Bool            IsSymbol() const { return ( (meSymbol != SYMBOL_NOSYMBOL) && (meSymbol != SYMBOL_IMAGE) ); }
     131                 :            :     SAL_DLLPRIVATE sal_Bool            IsImage() const { return Button::HasImage(); }
     132                 :            : 
     133                 :            :     // Copy assignment is forbidden and not implemented.
     134                 :            :     SAL_DLLPRIVATE                 PushButton( const PushButton & );
     135                 :            :     SAL_DLLPRIVATE                 PushButton& operator=( const PushButton & );
     136                 :            : 
     137                 :            :     SAL_DLLPRIVATE void            ImplInit( Window* pParent, WinBits nStyle );
     138                 :            : 
     139                 :            :     using Control::ImplInitSettings;
     140                 :            :     using Window::ImplInit;
     141                 :            : public:
     142                 :            :     SAL_DLLPRIVATE void            ImplSetDefButton( sal_Bool bSet );
     143                 :            :     SAL_DLLPRIVATE static void     ImplDrawPushButtonFrame( Window* pDev, Rectangle& rRect, sal_uInt16 nStyle );
     144                 :            :     SAL_DLLPRIVATE static sal_Bool     ImplHitTestPushButton( Window* pDev, const Point& rPos );
     145                 :            :     SAL_DLLPRIVATE sal_Bool            ImplIsDefButton() const;
     146                 :            : 
     147                 :            : protected:
     148                 :            :                     PushButton( WindowType nType );
     149                 :            : 
     150                 :            :     virtual void    FillLayoutData() const;
     151                 :            :     virtual const Font&
     152                 :            :                     GetCanonicalFont( const StyleSettings& _rStyle ) const;
     153                 :            :     virtual const Color&
     154                 :            :                     GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
     155                 :            : public:
     156                 :            :                     PushButton( Window* pParent, WinBits nStyle = 0 );
     157                 :            :                     PushButton( Window* pParent, const ResId& rResId );
     158                 :            :                     ~PushButton();
     159                 :            : 
     160                 :            :     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
     161                 :            :     virtual void    Tracking( const TrackingEvent& rTEvt );
     162                 :            :     virtual void    KeyInput( const KeyEvent& rKEvt );
     163                 :            :     virtual void    KeyUp( const KeyEvent& rKEvt );
     164                 :            :     virtual void    Paint( const Rectangle& rRect );
     165                 :            :     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
     166                 :            :     virtual void    Resize();
     167                 :            :     virtual void    GetFocus();
     168                 :            :     virtual void    LoseFocus();
     169                 :            :     virtual void    StateChanged( StateChangedType nType );
     170                 :            :     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
     171                 :            :     virtual long    PreNotify( NotifyEvent& rNEvt );
     172                 :            :     virtual void    UserDraw( const UserDrawEvent& rUDEvt );
     173                 :            : 
     174                 :            :     virtual void    Toggle();
     175                 :            : 
     176                 :            :     void            SetSymbol( SymbolType eSymbol );
     177                 :            :     SymbolType      GetSymbol() const { return meSymbol; }
     178                 :            :     void            SetSymbolAlign( SymbolAlign eAlign );
     179                 :            : 
     180                 :            :     void            SetDropDown( sal_uInt16 nStyle );
     181                 :            :     sal_uInt16          GetDropDown() const { return mnDDStyle; }
     182                 :            : 
     183                 :            :     void            SetState( TriState eState );
     184                 :            :     TriState        GetState() const { return meState; }
     185                 :            : 
     186                 :            :     void            Check( sal_Bool bCheck = sal_True );
     187                 :            :     sal_Bool            IsChecked() const;
     188                 :            : 
     189                 :            :     void            SetPressed( sal_Bool bPressed );
     190                 :            :     sal_Bool            IsPressed() const { return mbPressed; }
     191                 :            : 
     192                 :            :     void            EndSelection();
     193                 :            : 
     194                 :            :     void            SaveValue() { meSaveValue = GetState(); }
     195                 :            :     TriState        GetSavedValue() const { return meSaveValue; }
     196                 :            : 
     197                 :            :     Size            CalcMinimumSize( long nMaxWidth = 0 ) const;
     198                 :            :     virtual Size    GetOptimalSize(WindowSizeType eType) const;
     199                 :            : 
     200                 :            :     void            SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; }
     201                 :            :     const Link&     GetToggleHdl() const { return maToggleHdl; }
     202                 :            : };
     203                 :            : 
     204                 :            : inline void PushButton::Check( sal_Bool bCheck )
     205                 :            : {
     206                 :            :     SetState( (bCheck) ? STATE_CHECK : STATE_NOCHECK );
     207                 :            : }
     208                 :            : 
     209                 :            : inline sal_Bool PushButton::IsChecked() const
     210                 :            : {
     211                 :            :     return (GetState() == STATE_CHECK);
     212                 :            : }
     213                 :            : 
     214                 :            : // ------------
     215                 :            : // - OKButton -
     216                 :            : // ------------
     217                 :            : 
     218         [ #  # ]:          0 : class VCL_DLLPUBLIC OKButton : public PushButton
     219                 :            : {
     220                 :            : protected:
     221                 :            :     using PushButton::ImplInit;
     222                 :            : private:
     223                 :            :     SAL_DLLPRIVATE void            ImplInit( Window* pParent, WinBits nStyle );
     224                 :            : 
     225                 :            :     // Copy assignment is forbidden and not implemented.
     226                 :            :     SAL_DLLPRIVATE                 OKButton (const OKButton &);
     227                 :            :     SAL_DLLPRIVATE                 OKButton & operator= (const OKButton &);
     228                 :            : 
     229                 :            : public:
     230                 :            :                     OKButton( Window* pParent, WinBits nStyle = WB_DEFBUTTON );
     231                 :            :                     OKButton( Window* pParent, const ResId& rResId );
     232                 :            : 
     233                 :            :     virtual void    Click();
     234                 :            : };
     235                 :            : 
     236                 :            : // ----------------
     237                 :            : // - CancelButton -
     238                 :            : // ----------------
     239                 :            : 
     240         [ #  # ]:          0 : class VCL_DLLPUBLIC CancelButton : public PushButton
     241                 :            : {
     242                 :            : protected:
     243                 :            :     using PushButton::ImplInit;
     244                 :            : private:
     245                 :            :     SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
     246                 :            : 
     247                 :            :     // Copy assignment is forbidden and not implemented.
     248                 :            :     SAL_DLLPRIVATE      CancelButton (const CancelButton &);
     249                 :            :     SAL_DLLPRIVATE      CancelButton & operator= (const CancelButton &);
     250                 :            : 
     251                 :            : public:
     252                 :            :                     CancelButton( Window* pParent, WinBits nStyle = 0 );
     253                 :            :                     CancelButton( Window* pParent, const ResId& rResId );
     254                 :            : 
     255                 :            :     virtual void    Click();
     256                 :            : };
     257                 :            : 
     258                 :            : // --------------
     259                 :            : // - HelpButton -
     260                 :            : // --------------
     261                 :            : 
     262         [ #  # ]:          0 : class VCL_DLLPUBLIC HelpButton : public PushButton
     263                 :            : {
     264                 :            : protected:
     265                 :            :     using PushButton::ImplInit;
     266                 :            : private:
     267                 :            :     SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
     268                 :            : 
     269                 :            :     // Copy assignment is forbidden and not implemented.
     270                 :            :     SAL_DLLPRIVATE      HelpButton( const HelpButton & );
     271                 :            :     SAL_DLLPRIVATE      HelpButton & operator= ( const HelpButton & );
     272                 :            : 
     273                 :            : public:
     274                 :            :                     HelpButton( Window* pParent, WinBits nStyle = 0 );
     275                 :            :                     HelpButton( Window* pParent, const ResId& rResId );
     276                 :            : 
     277                 :            :     virtual void    Click();
     278                 :            : };
     279                 :            : 
     280                 :            : // ---------------
     281                 :            : // - RadioButton -
     282                 :            : // ---------------
     283                 :            : 
     284                 :            : class VCL_DLLPUBLIC RadioButton : public Button
     285                 :            : {
     286                 :            : private:
     287                 :            :     Rectangle       maStateRect;
     288                 :            :     Rectangle       maMouseRect;
     289                 :            :     Image           maImage;
     290                 :            :     sal_Bool            mbChecked;
     291                 :            :     sal_Bool            mbSaveValue;
     292                 :            :     sal_Bool            mbRadioCheck;
     293                 :            :     sal_Bool            mbStateChanged;
     294                 :            :     Link            maToggleHdl;
     295                 :            :     // when mbLegacyNoTextAlign is set then the old behaviour where
     296                 :            :     // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement
     297                 :            :     // occurs, otherwise the image ( radiobutton circle ) is placed
     298                 :            :     // to the left or right ( depending on RTL or LTR settings )
     299                 :            :     bool            mbLegacyNoTextAlign;
     300                 :            :     SAL_DLLPRIVATE void     ImplInitRadioButtonData();
     301                 :            :     SAL_DLLPRIVATE WinBits  ImplInitStyle( const Window* pPrevWindow, WinBits nStyle );
     302                 :            :     SAL_DLLPRIVATE void     ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
     303                 :            :     SAL_DLLPRIVATE void     ImplDrawRadioButtonState();
     304                 :            :     SAL_DLLPRIVATE void     ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
     305                 :            :                               const Point& rPos, const Size& rSize,
     306                 :            :                               const Size& rImageSize, Rectangle& rStateRect,
     307                 :            :                               Rectangle& rMouseRect, bool bLayout = false );
     308                 :            :     SAL_DLLPRIVATE void     ImplDrawRadioButton( bool bLayout = false );
     309                 :            :     SAL_DLLPRIVATE void     ImplInvalidateOrDrawRadioButtonState();
     310                 :            :     SAL_DLLPRIVATE void     ImplUncheckAllOther();
     311                 :            :     SAL_DLLPRIVATE Size     ImplGetRadioImageSize() const;
     312                 :            :     SAL_DLLPRIVATE long     ImplGetImageToTextDistance() const;
     313                 :            : 
     314                 :            :     // Copy assignment is forbidden and not implemented.
     315                 :            :     SAL_DLLPRIVATE          RadioButton(const RadioButton &);
     316                 :            :     SAL_DLLPRIVATE          RadioButton& operator= (const RadioButton &);
     317                 :            : 
     318                 :            : protected:
     319                 :            :     using Control::ImplInitSettings;
     320                 :            :     using Window::ImplInit;
     321                 :            :     SAL_DLLPRIVATE void     ImplInit( Window* pParent, WinBits nStyle );
     322                 :            :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     323                 :            : 
     324                 :            : public:
     325                 :            :     SAL_DLLPRIVATE void     ImplCallClick( sal_Bool bGrabFocus = sal_False, sal_uInt16 nFocusFlags = 0 );
     326                 :            :     SAL_DLLPRIVATE void     ImplSetMinimumNWFSize();
     327                 :            : 
     328                 :            : protected:
     329                 :            :     virtual void FillLayoutData() const;
     330                 :            :     virtual const Font&
     331                 :            :                     GetCanonicalFont( const StyleSettings& _rStyle ) const;
     332                 :            :     virtual const Color&
     333                 :            :                     GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
     334                 :            : 
     335                 :            :     inline void             SetMouseRect( const Rectangle& _rMouseRect )    { maMouseRect = _rMouseRect; }
     336                 :            :     inline const Rectangle& GetMouseRect( ) const                           { return maMouseRect; }
     337                 :            :     inline void             SetStateRect( const Rectangle& _rStateRect )    { maStateRect = _rStateRect; }
     338                 :            :     inline const Rectangle& GetStateRect( ) const                           { return maStateRect; }
     339                 :            : 
     340                 :            :     // draws the radio button (the knob image), in it's current state (pressed/checked)
     341                 :            :     // at the usual location, which can be overridden with SetStateRect
     342                 :            :     void            DrawRadioButtonState( );
     343                 :            : 
     344                 :            : public:
     345                 :            :                     RadioButton( Window* pParent, WinBits nWinStyle = 0 );
     346                 :            :                     RadioButton( Window* pParent, const ResId& rResId );
     347                 :            :                     ~RadioButton();
     348                 :            : 
     349                 :            :     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
     350                 :            :     virtual void    Tracking( const TrackingEvent& rTEvt );
     351                 :            :     virtual void    KeyInput( const KeyEvent& rKEvt );
     352                 :            :     virtual void    KeyUp( const KeyEvent& rKEvt );
     353                 :            :     virtual void    Paint( const Rectangle& rRect );
     354                 :            :     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
     355                 :            :     virtual void    Resize();
     356                 :            :     virtual void    GetFocus();
     357                 :            :     virtual void    LoseFocus();
     358                 :            :     virtual void    StateChanged( StateChangedType nType );
     359                 :            :     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
     360                 :            :     virtual long    PreNotify( NotifyEvent& rNEvt );
     361                 :            : 
     362                 :            :     virtual void    Toggle();
     363                 :            : 
     364                 :            :     sal_Bool            IsStateChanged() const { return mbStateChanged; }
     365                 :            : 
     366                 :            :     void            EnableRadioCheck( sal_Bool bRadioCheck = sal_True ) { mbRadioCheck = bRadioCheck; }
     367                 :            :     sal_Bool            IsRadioCheckEnabled() const { return mbRadioCheck; }
     368                 :            : 
     369                 :            :     sal_Bool        SetModeRadioImage( const Image& rImage );
     370                 :            :     const Image&    GetModeRadioImage( ) const;
     371                 :            : 
     372                 :            :     void            SetState( sal_Bool bCheck );
     373                 :            :     void            Check( sal_Bool bCheck = sal_True );
     374                 :          0 :     sal_Bool            IsChecked() const { return mbChecked; }
     375                 :            : 
     376                 :            :     void            SaveValue() { mbSaveValue = IsChecked(); }
     377                 :            :     sal_Bool            GetSavedValue() const { return mbSaveValue; }
     378                 :            : 
     379                 :            :     static Image    GetRadioImage( const AllSettings& rSettings, sal_uInt16 nFlags );
     380                 :            : 
     381                 :            :     Size            CalcMinimumSize( long nMaxWidth = 0 ) const;
     382                 :            :     virtual Size    GetOptimalSize(WindowSizeType eType) const;
     383                 :            : 
     384                 :          0 :     void            SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; }
     385                 :            :     const Link&     GetToggleHdl() const { return maToggleHdl; }
     386                 :            : 
     387                 :            :     /** GetRadioButtonGroup returns a list of pointers to <code>RadioButton</code>s in the same group.
     388                 :            : 
     389                 :            :     The pointers in the returned list are valid at the time call returns. However rescheduling
     390                 :            :     or giving up the SolarMutex may mean events get executed that lead to the pointers getting
     391                 :            :     invalid.
     392                 :            : 
     393                 :            :     @param io_rGroup
     394                 :            :     gets cleared on entering the function. on return contains the <code>RadioButton</code>s
     395                 :            :     in the same group as this <code>RadioButton</code>.
     396                 :            : 
     397                 :            :     @param bIncludeThis
     398                 :            :     defines whether <code>this</code> is contained in the returned list
     399                 :            :     */
     400                 :            :     void            GetRadioButtonGroup( std::vector<RadioButton*>& io_rGroup, bool bIncludeThis ) const;
     401                 :            : };
     402                 :            : 
     403                 :            : // ------------
     404                 :            : // - CheckBox -
     405                 :            : // ------------
     406                 :            : 
     407         [ #  # ]:          0 : class VCL_DLLPUBLIC CheckBox : public Button
     408                 :            : {
     409                 :            : private:
     410                 :            :     Rectangle       maStateRect;
     411                 :            :     Rectangle       maMouseRect;
     412                 :            :     TriState        meState;
     413                 :            :     TriState        meSaveValue;
     414                 :            :     sal_Bool            mbTriState;
     415                 :            :     Link            maToggleHdl;
     416                 :            :     // when mbLegacyNoTextAlign is set then the old behaviour where
     417                 :            :     // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement
     418                 :            :     // occurs, otherwise the image ( checkbox box ) is placed
     419                 :            :     // to the left or right ( depending on RTL or LTR settings )
     420                 :            :     bool            mbLegacyNoTextAlign;
     421                 :            :     SAL_DLLPRIVATE void         ImplInitCheckBoxData();
     422                 :            :     SAL_DLLPRIVATE WinBits      ImplInitStyle( const Window* pPrevWindow, WinBits nStyle );
     423                 :            :     SAL_DLLPRIVATE void         ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
     424                 :            :     SAL_DLLPRIVATE void         ImplInvalidateOrDrawCheckBoxState();
     425                 :            :     SAL_DLLPRIVATE void         ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
     426                 :            :                                     const Point& rPos, const Size& rSize,
     427                 :            :                                     const Size& rImageSize, Rectangle& rStateRect,
     428                 :            :                                     Rectangle& rMouseRect, bool bLayout );
     429                 :            :     SAL_DLLPRIVATE void         ImplDrawCheckBox( bool bLayout = false );
     430                 :            :     SAL_DLLPRIVATE long         ImplGetImageToTextDistance() const;
     431                 :            :     SAL_DLLPRIVATE Size         ImplGetCheckImageSize() const;
     432                 :            : 
     433                 :            :     // Copy assignment is forbidden and not implemented.
     434                 :            :     SAL_DLLPRIVATE              CheckBox(const CheckBox &);
     435                 :            :     SAL_DLLPRIVATE              CheckBox& operator= (const CheckBox &);
     436                 :            : 
     437                 :            : protected:
     438                 :            :     using Control::ImplInitSettings;
     439                 :            :     using Window::ImplInit;
     440                 :            :     SAL_DLLPRIVATE void         ImplInit( Window* pParent, WinBits nStyle );
     441                 :            :     SAL_DLLPRIVATE void         ImplLoadRes( const ResId& rResId );
     442                 :            :     SAL_DLLPRIVATE virtual void FillLayoutData() const;
     443                 :            :     SAL_DLLPRIVATE virtual const Font&
     444                 :            :                                 GetCanonicalFont( const StyleSettings& _rStyle ) const;
     445                 :            :     SAL_DLLPRIVATE virtual const Color&
     446                 :            :                                 GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
     447                 :            : 
     448                 :            :     SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState();
     449                 :            :     SAL_DLLPRIVATE const Rectangle& GetStateRect() const { return maStateRect; }
     450                 :            :     SAL_DLLPRIVATE const Rectangle& GetMouseRect() const { return maMouseRect; }
     451                 :            : public:
     452                 :            :     SAL_DLLPRIVATE void         ImplCheck();
     453                 :            :     SAL_DLLPRIVATE void         ImplSetMinimumNWFSize();
     454                 :            : public:
     455                 :            :                     CheckBox( Window* pParent, WinBits nStyle = 0 );
     456                 :            :                     CheckBox( Window* pParent, const ResId& rResId );
     457                 :            : 
     458                 :            :     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
     459                 :            :     virtual void    Tracking( const TrackingEvent& rTEvt );
     460                 :            :     virtual void    KeyInput( const KeyEvent& rKEvt );
     461                 :            :     virtual void    KeyUp( const KeyEvent& rKEvt );
     462                 :            :     virtual void    Paint( const Rectangle& rRect );
     463                 :            :     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
     464                 :            :     virtual void    Resize();
     465                 :            :     virtual void    GetFocus();
     466                 :            :     virtual void    LoseFocus();
     467                 :            :     virtual void    StateChanged( StateChangedType nType );
     468                 :            :     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
     469                 :            :     virtual long    PreNotify( NotifyEvent& rNEvt );
     470                 :            : 
     471                 :            :     virtual void    Toggle();
     472                 :            : 
     473                 :            :     void            SetState( TriState eState );
     474                 :          0 :     TriState        GetState() const { return meState; }
     475                 :            : 
     476                 :            :     void            Check( sal_Bool bCheck = sal_True );
     477                 :            :     sal_Bool            IsChecked() const;
     478                 :            : 
     479                 :            :     void            EnableTriState( sal_Bool bTriState = sal_True );
     480                 :            :     sal_Bool            IsTriStateEnabled() const { return mbTriState; }
     481                 :            : 
     482                 :            :     void            SaveValue() { meSaveValue = GetState(); }
     483                 :            :     TriState        GetSavedValue() const { return meSaveValue; }
     484                 :            : 
     485                 :            :     static Image    GetCheckImage( const AllSettings& rSettings, sal_uInt16 nFlags );
     486                 :            : 
     487                 :            :     Size            CalcMinimumSize( long nMaxWidth = 0 ) const;
     488                 :            :     virtual Size    GetOptimalSize(WindowSizeType eType) const;
     489                 :            : 
     490                 :          0 :     void            SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; }
     491                 :            :     const Link&     GetToggleHdl() const { return maToggleHdl; }
     492                 :            :     bool            IsLegacyNoTextAlign() { return mbLegacyNoTextAlign; }
     493                 :            :     void            SetLegacyNoTextAlign( bool bVal ) { mbLegacyNoTextAlign = bVal; }
     494                 :            : };
     495                 :            : 
     496                 :          0 : inline void CheckBox::Check( sal_Bool bCheck )
     497                 :            : {
     498         [ #  # ]:          0 :     SetState( (bCheck) ? STATE_CHECK : STATE_NOCHECK );
     499                 :          0 : }
     500                 :            : 
     501                 :          0 : inline sal_Bool CheckBox::IsChecked() const
     502                 :            : {
     503                 :          0 :     return (GetState() == STATE_CHECK);
     504                 :            : }
     505                 :            : 
     506                 :            : // ---------------------------------
     507                 :            : // - Control-Layer fuer alten Code -
     508                 :            : // ---------------------------------
     509                 :            : 
     510                 :            : class VCL_DLLPUBLIC ImageButton : public PushButton
     511                 :            : {
     512                 :            : protected:
     513                 :            :     using PushButton::ImplInitStyle;
     514                 :            : private:
     515                 :            :     SAL_DLLPRIVATE void     ImplInitStyle();
     516                 :            : 
     517                 :            :     // Copy assignment is forbidden and not implemented.
     518                 :            :     SAL_DLLPRIVATE          ImageButton( const ImageButton & );
     519                 :            :     SAL_DLLPRIVATE          ImageButton & operator= ( const ImageButton & );
     520                 :            : 
     521                 :            : public:
     522                 :            :                     ImageButton( Window* pParent, WinBits nStyle = 0 );
     523                 :            :                     ImageButton( Window* pParent, const ResId& rResId );
     524                 :            :                     ~ImageButton();
     525                 :            : };
     526                 :            : 
     527                 :            : class VCL_DLLPUBLIC ImageRadioButton : public RadioButton
     528                 :            : {
     529                 :            :     // Copy assignment is forbidden and not implemented.
     530                 :            :     SAL_DLLPRIVATE  ImageRadioButton( const ImageRadioButton & );
     531                 :            :     SAL_DLLPRIVATE  ImageRadioButton & operator= ( const ImageRadioButton & );
     532                 :            : 
     533                 :            : public:
     534                 :            :                     ImageRadioButton( Window* pParent, WinBits nStyle = 0 );
     535                 :            :                     ImageRadioButton( Window* pParent, const ResId& rResId );
     536                 :            :                     ~ImageRadioButton();
     537                 :            : };
     538                 :            : 
     539                 :            : class VCL_DLLPUBLIC TriStateBox : public CheckBox
     540                 :            : {
     541                 :            :     // Copy assignment is forbidden and not implemented.
     542                 :            :     SAL_DLLPRIVATE  TriStateBox( const TriStateBox & );
     543                 :            :     SAL_DLLPRIVATE  TriStateBox & operator= ( const TriStateBox & );
     544                 :            : 
     545                 :            : public:
     546                 :            :             TriStateBox( Window* pParent, WinBits nStyle = 0 );
     547                 :            :             TriStateBox( Window* pParent, const ResId& rResId );
     548                 :            :             ~TriStateBox();
     549                 :            : };
     550                 :            : 
     551         [ #  # ]:          0 : class VCL_DLLPUBLIC DisclosureButton : public CheckBox
     552                 :            : {
     553                 :            : protected:
     554                 :            :     SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState();
     555                 :            : public:
     556                 :            :     DisclosureButton( Window* pParent, const ResId& rResId );
     557                 :            : 
     558                 :            :     virtual void    KeyInput( const KeyEvent& rKEvt );
     559                 :            : };
     560                 :            : 
     561                 :            : #endif  // _SV_BUTTON_HXX
     562                 :            : 
     563                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10