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

0001 #ifndef oxygenstyleoptions_h
0002 #define oxygenstyleoptions_h
0003 
0004 /*
0005 * this file is part of the oxygen gtk engine
0006 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0007 *
0008 * SPDX-License-Identifier: LGPL-2.0-or-later
0009 */
0010 
0011 #include "oxygenflags.h"
0012 #include "oxygengtkutils.h"
0013 #include "oxygenpalette.h"
0014 
0015 #include <iostream>
0016 #include <gtk/gtk.h>
0017 
0018 namespace Oxygen
0019 {
0020 
0021     //! internal option flags to pass arguments around
0022     enum StyleOption
0023     {
0024         Blend = 1<<0,
0025         Sunken = 1<<1,
0026         Active = 1<<2,
0027         Flat = 1<<3,
0028         Focus = 1<<4,
0029         Hover = 1<<5,
0030         NoFill = 1<<6,
0031         Vertical = 1<<7,
0032         Alpha = 1<<8,
0033         Round = 1<<9,
0034         Contrast = 1<<10,
0035         Selected = 1<<11,
0036         Disabled = 1<<12,
0037         Menu = 1<<13,
0038         DrawAlphaChannel = 1<<14
0039     };
0040 
0041     class StyleOptions: public Flags<StyleOption>
0042     {
0043 
0044         public:
0045 
0046         //! constructor
0047         StyleOptions( void )
0048         {}
0049 
0050         //! constructor
0051         StyleOptions(StyleOption f):
0052             Flags<StyleOption>( f )
0053         {}
0054 
0055         //! constructor
0056         StyleOptions( Flags<StyleOption> f):
0057             Flags<StyleOption>( f )
0058         {}
0059 
0060         //! constructor from widget
0061         StyleOptions( GtkWidget* widget, GtkStateType state, GtkShadowType shadow = GTK_SHADOW_NONE )
0062         {
0063             if( state == GTK_STATE_INSENSITIVE ) (*this) |= Disabled;
0064             else if( state == GTK_STATE_PRELIGHT ) (*this) |= Hover;
0065             else if( state == GTK_STATE_SELECTED ) (*this) |= Selected;
0066             else if( state == GTK_STATE_ACTIVE ) (*this) |= Active;
0067 
0068             if( shadow == GTK_SHADOW_IN ) (*this) |= Sunken;
0069             if( widget && gtk_widget_has_focus(widget) ) (*this)|=Focus;
0070         }
0071 
0072         //! destructor
0073         virtual ~StyleOptions( void )
0074         {}
0075 
0076 
0077         //! color set
0078         /*! it is used to pass custom colors to painting routines */
0079         Palette::ColorSet _customColors;
0080 
0081         //! streamer
0082         friend std::ostream& operator << (std::ostream& out, const StyleOptions& options );
0083 
0084     };
0085 
0086 }
0087 
0088 OX_DECLARE_OPERATORS_FOR_FLAGS( Oxygen::StyleOptions )
0089 
0090 #endif