1 #ifndef oxygentabwidgetengine_h
2 #define oxygentabwidgetengine_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 *
7 * This  library is free  software; you can  redistribute it and/or
8 * modify it  under  the terms  of the  GNU Lesser  General  Public
9 * License  as published  by the Free  Software  Foundation; either
10 * version 2 of the License, or(at your option ) any later version.
11 *
12 * This library is distributed  in the hope that it will be useful,
13 * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License  along  with  this library;  if not,  write to  the Free
19 * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 */
22 
23 
24 #include "oxygengenericengine.h"
25 #include "oxygendatamap.h"
26 #include "oxygentabwidgetdata.h"
27 
28 #include <gtk/gtk.h>
29 
30 namespace Oxygen
31 {
32     //! forward declaration
33     class Animations;
34 
35     //! stores data associated to editable tabwidgetes
36     /*!
37     ensures that the text entry and the button of editable tabwidgetes
38     gets hovered and focus flags at the same time
39     */
40     class TabWidgetEngine: public GenericEngine<TabWidgetData>
41     {
42 
43         public:
44 
45         //! constructor
TabWidgetEngine(Animations * widget)46         TabWidgetEngine( Animations* widget ):
47             GenericEngine<TabWidgetData>( widget )
48             {}
49 
50         //! destructor
~TabWidgetEngine(void)51         virtual ~TabWidgetEngine( void )
52         {}
53 
54         //!@name modifiers
55         //@{
56 
57         //! returns hovered tab, if any
updateTabRect(GtkWidget * widget,int index,int x,int y,int w,int h)58         void updateTabRect( GtkWidget* widget, int index, int x, int y, int w, int h )
59         {
60             GdkRectangle local = { x, y, w, h };
61             return data().value( widget ).updateTabRect( widget, index, local );
62         }
63 
64         //! returns hovered tab, if any
updateTabRect(GtkWidget * widget,int index,const GdkRectangle & r)65         void updateTabRect( GtkWidget* widget, int index, const GdkRectangle& r )
66         { return data().value( widget ).updateTabRect( widget, index, r ); }
67 
68         //! returns hovered tab, if any
updateHoveredTab(GtkWidget * widget)69         void updateHoveredTab( GtkWidget* widget )
70         { return data().value( widget ).updateHoveredTab( widget ); }
71 
72         //! true when drag is in progress
setDragInProgress(GtkWidget * widget,bool value)73         void setDragInProgress( GtkWidget* widget, bool value )
74         { data().value( widget ).setDragInProgress( value ); }
75 
76         //! toggle dirty state
toggleDirty(GtkWidget * widget)77         void toggleDirty( GtkWidget* widget )
78         { data().value( widget ).toggleDirty(); }
79 
80         //! true when tabbar is dirty
setDirty(GtkWidget * widget,bool value)81         void setDirty( GtkWidget* widget, bool value )
82         { data().value( widget ).setDirty( value ); }
83 
84         //@}
85 
86         //!@name accessors
87         //@{
88 
89         //! returns hovered tab, if any
hoveredTab(GtkWidget * widget)90         int hoveredTab( GtkWidget* widget )
91         { return data().value( widget ).hoveredTab(); }
92 
93         //! returns true if provided point is in one tab of the widget
isInTab(GtkWidget * widget,int x,int y)94         bool isInTab( GtkWidget* widget, int x, int y )
95         { return data().value( widget ).isInTab( x, y ); }
96 
97         //! true when drag is in progress
dragInProgress(GtkWidget * widget)98         bool dragInProgress( GtkWidget* widget )
99         { return data().value( widget ).dragInProgress(); }
100 
101         //! true when tabbar is dirty
isDirty(GtkWidget * widget)102         bool isDirty( GtkWidget* widget )
103         { return data().value( widget ).isDirty(); }
104 
105         //@}
106 
107     };
108 
109 }
110 
111 #endif
112