1 #ifndef oxygeninnershadowdata_h
2 #define oxygeninnershadowdata_h
3 /*
4 * this file is part of the oxygen gtk engine
5 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
6 * Copyright (c) 2010 Ruslan Kabatsayev <b7.10110111@gmail.com>
7 *
8 * This  library is free  software; you can  redistribute it and/or
9 * modify it  under  the terms  of the  GNU Lesser  General  Public
10 * License  as published  by the Free  Software  Foundation; either
11 * version 2 of the License, or(at your option ) any later version.
12 *
13 * This library is distributed  in the hope that it will be useful,
14 * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License  along  with  this library;  if not,  write to  the Free
20 * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 */
23 
24 #include "oxygensignal.h"
25 
26 #include <gtk/gtk.h>
27 #include <algorithm>
28 #include <map>
29 
30 namespace Oxygen
31 {
32     //! handle inner shadow drawing using composited GdkWindow API
33     class InnerShadowData
34     {
35 
36         public:
37 
38         //! constructor
InnerShadowData(void)39         InnerShadowData( void ):
40             _target(0)
41         {}
42 
43         //! destructor
~InnerShadowData(void)44         virtual ~InnerShadowData( void )
45         { disconnect( _target ); }
46 
47         //! setup connections
48         void connect( GtkWidget* );
49 
50         //! disconnect
51         void disconnect( GtkWidget* );
52 
53         //! register child
54         /*! needed to restore composited state on disconnect */
55         void registerChild( GtkWidget* );
56 
57         protected:
58 
59         //! unregister child
60         void unregisterChild( GtkWidget* );
61 
62         //!@ callbacks
63         //@{
64         static gboolean childUnrealizeNotifyEvent( GtkWidget*, gpointer );
65         static gboolean targetExposeEvent( GtkWidget*, GdkEventExpose*, gpointer );
66         //@}
67 
68         private:
69 
70         //! target widget
71         GtkWidget* _target;
72 
73         //! expose
74         Signal _exposeId;
75 
76         //! child data
77         class ChildData
78         {
79             public:
80 
81             //! constructor
ChildData(void)82             ChildData( void ):
83                 _initiallyComposited( false )
84             {}
85 
86             //! destructor
~ChildData(void)87             virtual ~ChildData( void )
88             {}
89 
90             //! disconnect all signals
91             void disconnect( GtkWidget* );
92 
93             //! signal
94             Signal _unrealizeId;
95 
96             //! keep track of composited state
97             bool _initiallyComposited;
98         };
99 
100         //! map registered children and corresponding data
101         typedef std::map<GtkWidget*, ChildData> ChildDataMap;
102         ChildDataMap _childrenData;
103 
104     };
105 
106 }
107 
108 #endif
109