summaryrefslogtreecommitdiffstats
path: root/tdegtk/tdegtk-tabwidgetengine.h
blob: 6ec74d9365e84b865b342f7197b835eeb4215beb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef tdegtk_tabwidgetengine_h
#define tdegtk_tabwidgetengine_h
/*
* this file was largely taken from the oxygen gtk engine
* Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
*
* This  library is free  software; you can  redistribute it and/or
* modify it  under  the terms  of the  GNU Lesser  General  Public
* License  as published  by the Free  Software  Foundation; either
* version 2 of the License, or(at your option ) any later version.
*
* This library is distributed  in the hope that it will be useful,
* but  WITHOUT ANY WARRANTY; without even  the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License  along  with  this library;  if not,  write to  the Free
* Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/


#include "tdegtk-genericengine.h"
#include "tdegtk-datamap.h"
#include "tdegtk-tabwidgetdata.h"

#include <gtk/gtk.h>

    //! forward declaration
    class Animations;

    //! stores data associated to editable tabwidgetes
    /*!
    ensures that the text entry and the button of editable tabwidgetes
    gets hovered and focus flags at the same time
    */
    class TabWidgetEngine: public GenericEngine<TabWidgetData>
    {

        public:

        //! constructor
        TabWidgetEngine( Animations* widget ):
            GenericEngine<TabWidgetData>( widget )
            {}

        //! destructor
        virtual ~TabWidgetEngine( void )
        {}

        //!@name modifiers
        //@{

        //! returns hovered tab, if any
        void updateTabRect( GtkWidget* widget, int index, int x, int y, int w, int h )
        {
            GdkRectangle local = { x, y, w, h };
            return data().value( widget ).updateTabRect( widget, index, local );
        }

        //! returns hovered tab, if any
        void updateTabRect( GtkWidget* widget, int index, const GdkRectangle& r )
        { return data().value( widget ).updateTabRect( widget, index, r ); }

        //! returns hovered tab, if any
        void updateHoveredTab( GtkWidget* widget )
        { return data().value( widget ).updateHoveredTab( widget ); }

        //! true when drag is in progress
        void setDragInProgress( GtkWidget* widget, bool value )
        { data().value( widget ).setDragInProgress( value ); }

        //! toggle dirty state
        void toggleDirty( GtkWidget* widget )
        { data().value( widget ).toggleDirty(); }

        //! true when tabbar is dirty
        void setDirty( GtkWidget* widget, bool value )
        { data().value( widget ).setDirty( value ); }

        //@}

        //!@name accessors
        //@{

        //! returns hovered tab, if any
        int hoveredTab( GtkWidget* widget )
        { return data().value( widget ).hoveredTab(); }

        //! returns true if provided point is in one tab of the widget
        bool isInTab( GtkWidget* widget, int x, int y )
        { return data().value( widget ).isInTab( x, y ); }

        //! true when drag is in progress
        bool dragInProgress( GtkWidget* widget )
        { return data().value( widget ).dragInProgress(); }

        //! true when tabbar is dirty
        bool isDirty( GtkWidget* widget )
        { return data().value( widget ).isDirty(); }

        //@}

    };


#endif