File indexing completed on 2024-04-28 05:32:21

0001 #ifndef oxygenwindecobutton_h
0002 #define oxygenwindecobutton_h
0003 /*
0004 * this file is part of the oxygen gtk engine
0005 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0006 * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev <b7.10110111@gmail.com>
0007 *
0008 * SPDX-License-Identifier: LGPL-2.0-or-later
0009 */
0010 
0011 #include "oxygencairocontext.h"
0012 namespace Oxygen
0013 {
0014 
0015     // forward declarations
0016     class QtSettings;
0017     class StyleHelper;
0018 
0019     namespace WinDeco
0020     {
0021 
0022         //! button status
0023         enum ButtonStatus {
0024             Normal,
0025             Disabled, // this shouldn't be specified by WMs unless button is really insensitive
0026             Hovered,
0027             Pressed,
0028             ButtonStatusCount
0029         };
0030 
0031         //! buttons
0032         enum ButtonType {
0033             ButtonHelp=0,
0034             ButtonMax,
0035             ButtonMin,
0036             ButtonClose,
0037             ButtonMenu,
0038             ButtonStick,
0039             ButtonAbove,
0040             ButtonBelow,
0041             ButtonShade,
0042             ButtonUnmax,
0043             ButtonUnstick,
0044             ButtonUnshade,
0045             ButtonUndoAbove,
0046             ButtonUndoBelow,
0047             ButtonTypeCount
0048         };
0049 
0050         //! window decoration button
0051         class Button
0052         {
0053 
0054             public:
0055 
0056             //! constructor
0057             Button( const QtSettings& settings, StyleHelper& helper, const ButtonType& type ):
0058                 _settings( settings ),
0059                 _helper( helper ),
0060                 _type( type ),
0061                 _state( Normal )
0062             {}
0063 
0064             //! destructor
0065             virtual ~Button( void )
0066             {}
0067 
0068             //! state
0069             void setState( const ButtonStatus& state )
0070             { _state = state; }
0071 
0072             //! render
0073             void render( cairo_t*, gint x, gint y, gint w, gint h ) const;
0074 
0075             protected:
0076 
0077             //! icon
0078             void drawIcon( cairo_t*, gint w, gint h ) const;
0079 
0080             //! settings
0081             const QtSettings& settings( void ) const
0082             { return _settings; }
0083 
0084             //! helper
0085             StyleHelper& helper( void ) const
0086             { return _helper; }
0087 
0088             private:
0089 
0090             //! settings
0091             const QtSettings& _settings;
0092 
0093             //! helper
0094             StyleHelper& _helper;
0095 
0096             //! type
0097             ButtonType _type;
0098 
0099             //! status
0100             ButtonStatus _state;
0101 
0102         };
0103 
0104 
0105     }
0106 
0107 }
0108 
0109 #endif