Browse Source

A few widgets are now working somewhat

tags/r14.0.0
Timothy Pearson 6 years ago
parent
commit
0bf8ed2645

+ 12
- 3
tdegtk/Makefile.am View File

@@ -7,6 +7,10 @@ source_h = \
7 7
 	$(srcdir)/tdegtk-draw.h \
8 8
 	$(srcdir)/tdegtk-engine.h \
9 9
 	$(srcdir)/tdegtk-support.h \
10
+	$(srcdir)/tdegtk-hooks.h \
11
+	$(srcdir)/tdegtk-signals.h \
12
+	$(srcdir)/tdegtk-widgetlookup.h \
13
+	$(srcdir)/tdegtk-utils.h \
10 14
 	$(srcdir)/tdegtk-types.h
11 15
 
12 16
 source_c = \
@@ -14,10 +18,14 @@ source_c = \
14 18
 	$(srcdir)/gtkroundedbox.c \
15 19
 	$(srcdir)/raico-blur.c \
16 20
 	$(srcdir)/tdegtk-cairo-support.c \
17
-	$(srcdir)/tdegtk-draw.c \
21
+	$(srcdir)/tdegtk-draw.cpp \
18 22
 	$(srcdir)/tdegtk-engine.c \
19 23
 	$(srcdir)/tdegtk-support.c \
20
-	$(srcdir)/tdegtk-theme.c
24
+	$(srcdir)/tdegtk-hooks.cpp \
25
+	$(srcdir)/tdegtk-signals.cpp \
26
+	$(srcdir)/tdegtk-widgetlookup.cpp \
27
+	$(srcdir)/tdegtk-utils.cpp \
28
+	$(srcdir)/tdegtk-theme.cpp
21 29
 
22 30
 enginedir = $(libdir)/gtk-3.0/$(GTK_VERSION)/theming-engines
23 31
 engine_LTLIBRARIES = libtdegtk.la
@@ -25,8 +33,9 @@ engine_LTLIBRARIES = libtdegtk.la
25 33
 libtdegtk_la_SOURCES = $(source_h) $(source_c)
26 34
 
27 35
 libtdegtk_la_CFLAGS = $(TDEGTK_CFLAGS)
36
+libtdegtk_la_CXXFLAGS = $(TDEGTK_CXXFLAGS) -I/usr/include/tqt -I/usr/include/tqt3 -I/opt/trinity/include $(TDEGTK_CFLAGS)
28 37
 
29
-libtdegtk_la_LIBADD = $(TDEGTK_LIBADD)
38
+libtdegtk_la_LIBADD = $(TDEGTK_LIBADD) libtqtcairo.la -ltqt -ltqt-mt -L/opt/trinity/lib -ltdecore
30 39
 
31 40
 libtdegtk_la_LDFLAGS = $(TDEGTK_LDFLAGS)
32 41
 

+ 0
- 1062
tdegtk/tdegtk-draw.c
File diff suppressed because it is too large
View File


+ 1273
- 0
tdegtk/tdegtk-draw.cpp
File diff suppressed because it is too large
View File


+ 100
- 0
tdegtk/tdegtk-hooks.cpp View File

@@ -0,0 +1,100 @@
1
+/*
2
+* this file was largely taken from the oxygen gtk engine
3
+* Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
4
+* Copyright (c) 2010 Ruslan Kabatsayev <b7.10110111@gmail.com>
5
+*
6
+* This  library is free  software; you can  redistribute it and/or
7
+* modify it  under  the terms  of the  GNU Lesser  General  Public
8
+* License  as published  by the Free  Software  Foundation; either
9
+* version 2 of the License, or( at your option ) any later version.
10
+*
11
+* This library is distributed  in the hope that it will be useful,
12
+* but  WITHOUT ANY WARRANTY; without even  the implied warranty of
13
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+* Lesser General Public License for more details.
15
+*
16
+* You should have received a copy of the GNU Lesser General Public
17
+* License  along  with  this library;  if not,  write to  the Free
18
+* Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
19
+* MA 02110-1301, USA.
20
+*/
21
+
22
+#include "tdegtk-hooks.h"
23
+#include "../config.h"
24
+
25
+#include <cassert>
26
+#include <iostream>
27
+
28
+    #if TDEGTK_DEBUG
29
+    static int counter( 0 );
30
+    #endif
31
+
32
+    //__________________________________________________________________
33
+    bool Hook::connect( const std::string& signal, GType typeId, GSignalEmissionHook hookFunction, gpointer data )
34
+    {
35
+        // make sure that signal is not already connected
36
+        assert( _signalId == 0 && _hookId == 0 );
37
+
38
+        // check type id
39
+        if( !g_type_class_peek( typeId ) )
40
+        {
41
+
42
+            #if TDEGTK_DEBUG
43
+            std::cerr << "Oxygen::Hook::connect - typeId " << g_type_name(typeId) << " not yet installed" << std::endl;
44
+            #endif
45
+
46
+            g_type_class_ref( typeId );
47
+
48
+        }
49
+
50
+        // store signal id
51
+        _signalId = g_signal_lookup( signal.c_str(), typeId );
52
+        if( !_signalId )
53
+        {
54
+
55
+            #if TDEGTK_DEBUG
56
+            std::cerr << "Oxygen::Hook::connect - signal " << signal << " not installed." << std::endl;
57
+            #endif
58
+
59
+            return false;
60
+
61
+        }
62
+
63
+        // store attributes and create connection
64
+        _hookId = g_signal_add_emission_hook(
65
+            _signalId,
66
+            (GQuark)0L,
67
+            hookFunction,
68
+            data, 0L);
69
+
70
+        #if TDEGTK_DEBUG
71
+        ++counter;
72
+        std::cerr << "Oxygen::Hook::connect - hook: " << _hookId << " counter: " << counter << std::endl;
73
+        #endif
74
+
75
+        return true;
76
+
77
+    }
78
+
79
+    //____________________________________________________________________
80
+    void Hook::disconnect( void )
81
+    {
82
+
83
+        // disconnect signal
84
+        if( _signalId > 0 && _hookId > 0 )
85
+        {
86
+
87
+            #if TDEGTK_DEBUG
88
+            --counter;
89
+            std::cerr << "Oxygen::Hook::disconnect - hook: " << _hookId << " counter: " << counter << std::endl;
90
+            #endif
91
+
92
+            g_signal_remove_emission_hook( _signalId, _hookId );
93
+
94
+        }
95
+
96
+        _signalId = 0;
97
+        _hookId = 0;
98
+
99
+    }
100
+

+ 63
- 0
tdegtk/tdegtk-hooks.h View File

@@ -0,0 +1,63 @@
1
+#ifndef tdegtk_hooks_h
2
+#define tdegtk_hooks_h
3
+/*
4
+* this file was largely taken from the oxygen gtk engine
5
+* Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
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 <gtk/gtk.h>
25
+#include <string>
26
+
27
+
28
+    //! handles gtk signal hooks
29
+    class Hook
30
+    {
31
+        public:
32
+
33
+        //! constructor
34
+        Hook( void ):
35
+            _signalId(0),
36
+            _hookId(0)
37
+        {}
38
+
39
+        //! destructor
40
+        virtual ~Hook( void )
41
+        {}
42
+
43
+
44
+
45
+        //! connect
46
+        bool connect( const std::string&, GType, GSignalEmissionHook, gpointer );
47
+
48
+        bool connect( const std::string& signal, GSignalEmissionHook hook, gpointer data )
49
+        { return connect( signal, GTK_TYPE_WIDGET, hook, data ); }
50
+
51
+        //! disconnect
52
+        void disconnect( void );
53
+
54
+        private:
55
+
56
+        //! signal id
57
+        guint _signalId;
58
+        gulong _hookId;
59
+
60
+    };
61
+
62
+#endif
63
+

+ 89
- 0
tdegtk/tdegtk-signals.cpp View File

@@ -0,0 +1,89 @@
1
+
2
+/*
3
+* this file was largely taken from the oxygen gtk engine
4
+* Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
5
+*
6
+* This  library is free  software; you can  redistribute it and/or
7
+* modify it  under  the terms  of the  GNU Lesser  General  Public
8
+* License  as published  by the Free  Software  Foundation; either
9
+* version 2 of the License, or(at your option ) any later version.
10
+*
11
+* This library is distributed  in the hope that it will be useful,
12
+* but  WITHOUT ANY WARRANTY; without even  the implied warranty of
13
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+* Lesser General Public License for more details.
15
+*
16
+* You should have received a copy of the GNU Lesser General Public
17
+* License  along  with  this library;  if not,  write to  the Free
18
+* Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
19
+* MA 02110-1301, USA.
20
+*/
21
+
22
+#include "tdegtk-signals.h"
23
+#include "../config.h"
24
+
25
+#include <iostream>
26
+
27
+
28
+    #if OXYGEN_DEBUG
29
+    static int counter( 0 );
30
+    #endif
31
+
32
+    //____________________________________________________________________
33
+    bool Signal::connect( GObject* object, const std::string& signal, GCallback callback, gpointer data, bool after )
34
+    {
35
+        // make sure that signal is not already connected
36
+        assert( _object == 0L && _id == 0 );
37
+
38
+        // check object
39
+        if( !object ) return false;
40
+
41
+        // first try lookup signal
42
+        if( !g_signal_lookup( signal.c_str(), G_OBJECT_TYPE(object) ) )
43
+        {
44
+
45
+            #if OXYGEN_DEBUG
46
+            std::cerr << "Oxygen::Signal::connect - signal " << signal << " not installed on widget " << object << std::endl;
47
+            #endif
48
+
49
+            return false;
50
+
51
+        }
52
+
53
+        // store attributes and create connection
54
+        _object = object;
55
+        if(after) _id = g_signal_connect_after( object, signal.c_str(), callback, data );
56
+        else _id = g_signal_connect( object, signal.c_str(), callback, data );
57
+
58
+        #if OXYGEN_DEBUG
59
+        ++counter;
60
+        std::cerr << "Oxygen::Signal::connect - _id: " << _id << " counter: " << counter << std::endl;
61
+        #endif
62
+
63
+        return true;
64
+
65
+    }
66
+
67
+    //____________________________________________________________________
68
+    void Signal::disconnect( void )
69
+    {
70
+
71
+        // disconnect signal
72
+        if( _object && _id > 0 )
73
+        {
74
+
75
+            #if OXYGEN_DEBUG
76
+            --counter;
77
+            std::cerr << "Oxygen::Signal::disconnect - _id: " << _id << " counter: " << counter << std::endl;
78
+            #endif
79
+
80
+            g_signal_handler_disconnect( _object, _id );
81
+
82
+        }
83
+
84
+        // reset members
85
+        _object = 0L;
86
+        _id = 0;
87
+
88
+    }
89
+

+ 64
- 0
tdegtk/tdegtk-signals.h View File

@@ -0,0 +1,64 @@
1
+#ifndef tdegtk_signal_h
2
+#define tdegtk_signal_h
3
+
4
+/*
5
+* this file was largely taken from the oxygen gtk engine
6
+* Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
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 <gtk/gtk.h>
25
+#include <cassert>
26
+#include <string>
27
+
28
+    //! handles gtk signal connections
29
+    class Signal
30
+    {
31
+        public:
32
+
33
+        //! constructor
34
+        Signal( void ):
35
+            _id(0),
36
+            _object(0L)
37
+        {}
38
+
39
+        //! destructor
40
+        virtual ~Signal( void )
41
+        {}
42
+
43
+        //! true if connected
44
+        bool isConnected( void ) const
45
+        { return _id > 0 && _object; }
46
+
47
+        //! connect
48
+        bool connect( GObject*, const std::string&, GCallback, gpointer, bool after=false );
49
+
50
+        //! disconnect
51
+        void disconnect( void );
52
+
53
+        private:
54
+
55
+        //! signal id
56
+        guint _id;
57
+
58
+        //! connected object
59
+        GObject* _object;
60
+
61
+    };
62
+
63
+#endif
64
+

+ 0
- 51
tdegtk/tdegtk-theme.c View File

@@ -1,51 +0,0 @@
1
-/* The TdeGtk Theming Engine for Gtk+.
2
- * Copyright (C) 2011 Canonical Ltd
3
- *
4
- * This  library is free  software; you can  redistribute it and/or
5
- * modify it  under  the terms  of the  GNU Lesser  General  Public
6
- * License  as published  by the Free  Software  Foundation; either
7
- * version 2 of the License, or (at your option) any later version.
8
- *
9
- * This library is distributed  in the hope that it will be useful,
10
- * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License  along  with  this library;  if not,  write to  the Free
16
- * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
17
- * MA 02110-1301, USA.
18
- *
19
- * Authored by Andrea Cimitan <andrea.cimitan@canonical.com>
20
- *
21
- */
22
-
23
-#include <gmodule.h>
24
-#include <gtk/gtk.h>
25
-
26
-#include "tdegtk-engine.h"
27
-
28
-G_MODULE_EXPORT void theme_init (GTypeModule *module);
29
-
30
-G_MODULE_EXPORT void theme_exit (void);
31
-
32
-G_MODULE_EXPORT GtkThemingEngine* create_engine (void);
33
-
34
-G_MODULE_EXPORT void 
35
-theme_init (GTypeModule *module)
36
-{
37
-  tdegtk_engine_register_types (module);
38
-}
39
-
40
-G_MODULE_EXPORT void 
41
-theme_exit (void)
42
-{
43
-}
44
-
45
-G_MODULE_EXPORT GtkThemingEngine*
46
-create_engine (void)
47
-{
48
-  return GTK_THEMING_ENGINE (g_object_new (TDEGTK_TYPE_ENGINE,
49
-                                           "name", "tdegtk",
50
-                                           NULL));
51
-}

+ 788
- 0
tdegtk/tdegtk-theme.cpp View File

@@ -0,0 +1,788 @@
1
+/* The TdeGtk Theming Engine for Gtk+.
2
+ * Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
3
+ *
4
+ * This  library is free  software; you can  redistribute it and/or
5
+ * modify it  under  the terms  of the  GNU Lesser  General  Public
6
+ * License  as published  by the Free  Software  Foundation; either
7
+ * version 2 of the License, or (at your option) any later version.
8
+ *
9
+ * This library is distributed  in the hope that it will be useful,
10
+ * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ * Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public
15
+ * License  along  with  this library;  if not,  write to  the Free
16
+ * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
17
+ * MA 02110-1301, USA.
18
+ *
19
+ */
20
+
21
+#define TDEGTK_THEME_THEME_DIRECTORY_NAME	"tdegtk"
22
+#define TDEGTK_THEME_CONTROL_FILE_NAME		"gtk.css"
23
+#define RC_CACHE_VERSION			TQString("1")
24
+#define DEBUG_PRINT(x)				if (gtk3TQtDebug) printf(x"\n\r");
25
+#define DEBUG_PRINT_ARGS(x,y)			if (gtk3TQtDebug) printf(x"\n\r",y);
26
+
27
+bool gtk3TQtEnable = false;
28
+int gtk3TQtDebug = false;
29
+bool tde_showIconsOnPushButtons = false;
30
+
31
+void initTDESettings();
32
+void writeGtkThemeControlFile(int forceRecreate);
33
+
34
+extern "C" {
35
+	#include <gmodule.h>
36
+	#include <gtk/gtk.h>
37
+	
38
+	#include "tdegtk-engine.h"
39
+	
40
+	G_MODULE_EXPORT void theme_init(GTypeModule *module);
41
+	
42
+	G_MODULE_EXPORT void theme_exit(void);
43
+	
44
+	G_MODULE_EXPORT GtkThemingEngine* create_engine(void);
45
+	
46
+	G_MODULE_EXPORT void theme_init(GTypeModule *module) {
47
+		tdegtk_engine_register_types(module);
48
+	}
49
+	
50
+	G_MODULE_EXPORT void theme_exit(void) {
51
+		//
52
+	}
53
+}
54
+
55
+#include <stdlib.h>
56
+#include <sys/stat.h>
57
+#include <sys/types.h>
58
+#include <utility>
59
+#include <vector>
60
+#include <fstream>
61
+#include <sstream>
62
+
63
+#include <tqpainter.h>
64
+#include <tqapplication.h>
65
+#include <tqdir.h>
66
+#include <tqfile.h>
67
+#include <tqstyle.h>
68
+#include <tqslider.h>
69
+#include <tqscrollbar.h>
70
+#include <tqregexp.h>
71
+#include <tqfont.h>
72
+
73
+#include <kapplication.h>
74
+#include <kcmdlineargs.h>
75
+#include <kaboutdata.h>
76
+#include <klocale.h>
77
+#include <kconfig.h>
78
+#include <kglobal.h>
79
+#include <kglobalsettings.h>
80
+
81
+#include <gdk/gdkx.h>
82
+
83
+#include "tdegtk-widgetlookup.h"
84
+
85
+extern WidgetLookup m_widgetLookup;
86
+
87
+typedef std::pair<std::string, unsigned int> SizePair;
88
+typedef std::vector<SizePair> SizeMap;
89
+SizeMap icon_sizes;
90
+
91
+G_MODULE_EXPORT GtkThemingEngine* create_engine(void) {
92
+	gtk3TQtEnable = true;
93
+
94
+	gtk3TQtDebug = (getenv("GTK3_TQT_ENGINE_DEBUG") != NULL) ? 1 : 0;
95
+	DEBUG_PRINT("Creating KApplication")
96
+
97
+	int argc = 1;
98
+	char** argv;
99
+	// Supply it with fake data to keep KApplication happy
100
+	argv = (char**) malloc(sizeof(char*));
101
+	argv[0] = (char*) malloc(sizeof(char) * 21);
102
+	strncpy(argv[0], "gtk3-tqt-application", 21);
103
+
104
+	KAboutData aboutData("gtk3-tqt-engine", I18N_NOOP("gtk3-tqt-engine"), "v0.1",
105
+		"GTK3 TQt theme engine", KAboutData::License_GPL,
106
+		"(c) 2012, Timothy Pearson",
107
+		"", 0 /* TODO: Website */, "kb9vqf@pearsoncomputing.net");
108
+	KCmdLineArgs::init(argc, const_cast<char**>(argv), &aboutData);
109
+
110
+	KApplication::disableAutoDcopRegistration();
111
+	new KApplication(gdk_x11_get_default_xdisplay(), true, 0, 0, true);
112
+
113
+	initTDESettings();
114
+
115
+        // initialize icon sizes
116
+        icon_sizes.push_back(std::make_pair("panel-menu", 16));
117
+        icon_sizes.push_back(std::make_pair("panel", 32));
118
+        icon_sizes.push_back(std::make_pair("gtk-small-toolbar", 22));
119
+        icon_sizes.push_back(std::make_pair("gtk-large-toolbar", 22));
120
+        icon_sizes.push_back(std::make_pair("gtk-dnd", 48));
121
+        icon_sizes.push_back(std::make_pair("gtk-button", 16));
122
+        icon_sizes.push_back(std::make_pair("gtk-menu", 16));
123
+        icon_sizes.push_back(std::make_pair("gtk-dialog", 32));
124
+        icon_sizes.push_back(std::make_pair("", 16));
125
+
126
+	writeGtkThemeControlFile(false);
127
+
128
+	// Initialize hooks
129
+	m_widgetLookup.initializeHooks();
130
+
131
+	return GTK_THEMING_ENGINE (g_object_new (TDEGTK_TYPE_ENGINE, "name", "tdegtk", NULL));
132
+}
133
+
134
+// =========================================================================================================
135
+//
136
+// TQt3/GTK Theme Control Functions
137
+//
138
+// =========================================================================================================
139
+
140
+TQStringList tdeSearchPaths;
141
+TQString iconTheme;
142
+TQStringList iconThemeDirs;
143
+TQColor alternateBackgroundColour;
144
+int showIconsOnButtons;
145
+int toolbarStyle;
146
+
147
+TQString tdeConfigValue(const TQString& section, const TQString& name, const TQString& def) {
148
+	KConfig currentConfig;
149
+	currentConfig.setGroup(section);
150
+	return currentConfig.readEntry(name, def);
151
+}
152
+
153
+bool tdeBoolConfigValue(const TQString& section, const TQString& name, bool def) {
154
+	KConfig currentConfig;
155
+	currentConfig.setGroup(section);
156
+	return currentConfig.readBoolEntry(name, def);
157
+}
158
+
159
+TQString tdeFindDir(const TQString& suffix, const TQString& file1, const TQString& file2) {
160
+	for ( TQStringList::Iterator it = tdeSearchPaths.begin(); it != tdeSearchPaths.end(); ++it )
161
+	{
162
+		if ((TQFile::exists((*it) + suffix + file1)) || (TQFile::exists((*it) + suffix + file2)))
163
+			return (*it) + suffix;
164
+	}
165
+	return TQString();
166
+}
167
+
168
+TQString runCommand(const TQString& command) {
169
+	FILE* p = popen(command.latin1(), "r");
170
+	if ((p == NULL) || (p < 0))
171
+		return TQString();
172
+	
173
+	TQString ret;
174
+	while (!feof(p))
175
+	{
176
+		char buffer[256];
177
+		int n = fread(buffer, 1, 255, p);
178
+		buffer[n] = '\0';
179
+		ret += buffer;
180
+	}
181
+	pclose(p);
182
+	
183
+	return ret.stripWhiteSpace();
184
+}
185
+
186
+void initTDESettings() {
187
+	tdeSearchPaths.clear();
188
+	
189
+	TQString tdeHome = getenv("TDEHOME");
190
+	TQString tdeDirs = getenv("TDEDIRS");
191
+	TQString tdeDir = getenv("TDEDIR");
192
+	
193
+	if (!tdeHome.isEmpty()) {
194
+		tdeSearchPaths.append(tdeHome);
195
+	}
196
+	tdeSearchPaths.append(runCommand("tde-config --localprefix"));
197
+	
198
+	if (!tdeDirs.isEmpty()) {
199
+		tdeSearchPaths += TQStringList::split(':', tdeDirs);
200
+	}
201
+	if (!tdeDir.isEmpty()) {
202
+		tdeSearchPaths.append(tdeDir);
203
+	}
204
+	tdeSearchPaths.append(runCommand("tde-config --prefix"));
205
+	
206
+	iconTheme = tdeConfigValue("Icons", "Theme", "crystalsvg");
207
+	tde_showIconsOnPushButtons = tdeBoolConfigValue("KDE", "ShowIconsOnPushButtons", false);
208
+
209
+	TQStringList back = TQStringList::split(',', tdeConfigValue("General", "alternateBackground", "238,246,255"));
210
+	alternateBackgroundColour.setRgb(back[0].toInt(), back[1].toInt(), back[2].toInt());
211
+
212
+	showIconsOnButtons = (tdeConfigValue("KDE", "ShowIconsOnPushButtons", "true").lower() == "true");
213
+
214
+	TQString tmp = tdeConfigValue("Toolbar style", "IconText", "true").lower();
215
+	if (tmp == "icononly") {
216
+		toolbarStyle = 0;
217
+	}
218
+	else if (tmp == "icontextright") {
219
+		toolbarStyle = 3;
220
+	}
221
+	else if (tmp == "textonly") {
222
+		toolbarStyle = 1;
223
+	}
224
+	else if (tmp == "icontextbottom") {
225
+		toolbarStyle = 2;
226
+	}
227
+	else {
228
+		// Should never happen, but just in case we fallback to TDE's default "icononly"
229
+		toolbarStyle = 0;
230
+	}
231
+}
232
+
233
+void gtk3_tqt_load_resource_string(const char* css_string) {
234
+	GtkCssProvider *provider;
235
+
236
+	provider = gtk_css_provider_new();
237
+	gtk_css_provider_load_from_data(provider, css_string, -1, NULL);
238
+	GdkDisplay *display = gdk_display_get_default();
239
+	GdkScreen *screen = gdk_display_get_default_screen(display);
240
+	gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); 
241
+	g_object_unref(provider);
242
+
243
+	DEBUG_PRINT_ARGS("gtk3_tqt_load_resource_string(%s)", css_string)
244
+}
245
+
246
+void gtk3_tqt_reload_theme_definition_file(const char* filename) {
247
+	GtkCssProvider *provider;
248
+	GError *error;
249
+
250
+	provider = gtk_css_provider_new();
251
+	GdkDisplay *display = gdk_display_get_default();
252
+	GdkScreen *screen = gdk_display_get_default_screen(display);
253
+	gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
254
+	g_object_unref(provider);
255
+	if (!gtk_css_provider_load_from_path(provider, filename, &error)) {
256
+		g_printerr("%s: error parsing %s: %s\n", G_STRFUNC, filename, error->message);
257
+		g_clear_error(&error);
258
+	}
259
+}
260
+
261
+TQString tdeFontToGTKFontString(TQFont font) {
262
+	TQString fontDescriptor = "font: ";
263
+	fontDescriptor.append(font.family());
264
+	if (font.bold()) {
265
+		fontDescriptor.append(" bold");
266
+	}
267
+	if (font.italic()) {
268
+		fontDescriptor.append(" italic");
269
+	}
270
+	if (font.pointSizeFloat() != -1) {
271
+		fontDescriptor.append(TQString(" %1").arg(font.pointSizeFloat()));
272
+	}
273
+	else {
274
+		fontDescriptor.append(TQString(" %1px").arg(font.pixelSize()));
275
+	}
276
+
277
+	return fontDescriptor;
278
+}
279
+
280
+// Thanks Martin Dvorak of metatheme
281
+TQString parse_rc_string(const TQString& defs, const TQString& pattern, bool widgetClass = true) {
282
+	static int dynamic_counter = 0;
283
+	++dynamic_counter;
284
+
285
+	return pattern + " {\n\t" + defs + ";\n}\n\n";
286
+}
287
+
288
+GtkIconSet* generateIconSet(const std::string& gtkIconName, const std::string& tdeIconName, TQStringList pathList) {
289
+	if (tdeIconName == "NONE") {
290
+		return 0L;
291
+	}
292
+	
293
+	bool empty = true;
294
+	
295
+	// create iconSet
296
+	GtkIconSet* iconSet = gtk_icon_set_new();
297
+
298
+	// loop over iconSizes
299
+	for (SizeMap::const_iterator sizeIter = icon_sizes.begin(); sizeIter != icon_sizes.end(); ++sizeIter) {
300
+		// generate full icon name
301
+		std::ostringstream iconFileStream;
302
+		iconFileStream << sizeIter->second << "x" << sizeIter->second << "/" << tdeIconName;
303
+
304
+		// loop over provided path to see if at least one icon is found
305
+		for (TQStringList::const_iterator pathIter = pathList.begin(); pathIter != pathList.end(); ++pathIter) {
306
+			std::string filename((*pathIter + '/' + iconFileStream.str()).latin1());
307
+			if (!std::ifstream(filename.c_str())) {
308
+				continue;
309
+			}
310
+
311
+			empty = false;
312
+			GtkIconSource* iconSource(gtk_icon_source_new());
313
+		
314
+			// set name
315
+			gtk_icon_source_set_filename(iconSource, filename.c_str());
316
+
317
+			// set direction and state wildcarded
318
+			gtk_icon_source_set_direction_wildcarded(iconSource, TRUE);
319
+			gtk_icon_source_set_state_wildcarded(iconSource, TRUE);
320
+
321
+			// set size
322
+			if (sizeIter->first.empty()) {
323
+				gtk_icon_source_set_size_wildcarded(iconSource, TRUE);
324
+			}
325
+			else {
326
+				GtkIconSize size = gtk_icon_size_from_name(sizeIter->first.c_str());
327
+				if (size != GTK_ICON_SIZE_INVALID) {
328
+					gtk_icon_source_set_size_wildcarded(iconSource, FALSE);
329
+					gtk_icon_source_set_size(iconSource, size);
330
+				}
331
+			}
332
+
333
+			// add source to iconSet
334
+			gtk_icon_set_add_source(iconSet, iconSource);
335
+			break;
336
+		}
337
+	}
338
+
339
+	// if nothing found, return;
340
+	if (empty) {
341
+		gtk_icon_set_unref(iconSet);
342
+		return 0L;
343
+	}
344
+	else {
345
+		return iconSet;
346
+	}
347
+
348
+}
349
+
350
+void doIconMapping(const char* gtkName, const char * tdeName, GtkIconFactory* factory, TQStringList tdeIconThemeDirs) {
351
+	GtkIconSet* iconSet = generateIconSet(gtkName, tdeName, tdeIconThemeDirs);
352
+	if (iconSet) {
353
+		gtk_icon_factory_add(factory, gtkName, iconSet);
354
+		gtk_icon_set_unref(iconSet);
355
+	}
356
+}
357
+
358
+TQString colorString(TQColor color) {
359
+	TQString ret = "rgb(";
360
+	ret += TQString::number(color.red()) + ", ";
361
+	ret += TQString::number(color.green()) + ", ";
362
+	ret += TQString::number(color.blue()) + ")";
363
+	
364
+	return ret;
365
+}
366
+
367
+void setColour(TQString name, TQString state, TQColor color) {
368
+	state = ":" + state;
369
+	if (state == ":normal") {
370
+		state = "";
371
+	}
372
+	gtk3_tqt_load_resource_string(parse_rc_string(name + ": " + colorString(color), "*" + state).latin1());
373
+}
374
+
375
+static TQStringList iconInheritsDirs(const TQString& icondir) {
376
+	TQFile index;
377
+	index.setName(icondir + "index.theme");
378
+	if( !index.open( IO_ReadOnly )) {
379
+		index.setName(icondir + "index.desktop");
380
+		if( !index.open( IO_ReadOnly ))
381
+			return TQStringList();
382
+	}
383
+	char buf[1024];
384
+	TQRegExp reg( "^\\s*Inherits=([^\\n]*)" );
385
+	for(;;) {
386
+		if( index.readLine(buf, 1023) <= 0 ) {
387
+			break;
388
+		}
389
+		if( reg.search(buf, 0) >= 0 ) {
390
+			return TQStringList::split(",", reg.cap(1));
391
+		}
392
+	}
393
+	return TQStringList();
394
+}
395
+
396
+void addIconThemeDir(const TQString& theme) {
397
+	// Try to find this theme's directory
398
+	TQString icondir = tdeFindDir("/share/icons/" + theme + "/", "index.theme", "index.desktop");
399
+	if(icondir.isEmpty()) {
400
+		return;
401
+	}
402
+	if (iconThemeDirs.contains(icondir)) {
403
+		return;
404
+	}
405
+
406
+	// Add this theme to the list
407
+	iconThemeDirs.append(icondir);
408
+
409
+	// Do it again for any parent themes
410
+	TQStringList parents = iconInheritsDirs(icondir);
411
+	for ( TQStringList::Iterator it=parents.begin() ; it!=parents.end(); ++it) {
412
+		addIconThemeDir((*it).stripWhiteSpace());
413
+	}
414
+}
415
+
416
+void writeGtkThemeControlFile(int forceRecreate) {
417
+	if (!gtk3TQtEnable) {
418
+		return;
419
+	}
420
+	
421
+	DEBUG_PRINT("writeGtkThemeControlFile()")
422
+	
423
+	// Set colors
424
+	// Normal
425
+	setColour("color",            "normal",     tqApp->palette().active().text());
426
+	setColour("background-color", "normal",     tqApp->palette().active().background());
427
+// 	setColour("text",             "normal",     tqApp->palette().active().text());
428
+// 	setColour("base",             "normal",     tqApp->palette().active().base());
429
+
430
+	// Active (on)
431
+	setColour("color",            "active",     tqApp->palette().active().text());
432
+	setColour("background-color", "active",     tqApp->palette().active().background());
433
+// 	setColour("text",             "active",     tqApp->palette().active().text());
434
+// 	setColour("base",             "active",     tqApp->palette().active().base());
435
+
436
+	// Mouseover
437
+	setColour("color",            "prelight",   tqApp->palette().active().text()); // menu items - change?
438
+	setColour("background-color", "prelight",   tqApp->palette().active().highlight());
439
+// 	setColour("text",             "prelight",   tqApp->palette().active().text());
440
+// 	setColour("base",             "prelight",   tqApp->palette().active().base());
441
+
442
+	// Selected
443
+	setColour("color",            "selected",   tqApp->palette().active().highlightedText());
444
+	setColour("background-color", "selected",   tqApp->palette().active().highlight());
445
+// 	setColour("text",             "selected",   tqApp->palette().active().highlightedText());
446
+// 	setColour("base",             "selected",   tqApp->palette().active().highlight());
447
+
448
+	// Disabled
449
+	setColour("color",             "insensitive",    tqApp->palette().disabled().text());
450
+	setColour("background-color",  "insensitive",    tqApp->palette().disabled().background());
451
+// 	setColour("text",              "insensitive",    tqApp->palette().disabled().text());
452
+// 	setColour("base",              "insensitive",    tqApp->palette().disabled().background());
453
+
454
+	// Set up global application settings
455
+	GtkSettings* gtksettings = gtk_settings_get_default();
456
+	GtkSettingsValue svalue;
457
+	if (gtksettings) {
458
+		g_object_set(gtksettings, "gtk-alternative-button-order", TRUE, NULL);
459
+		g_object_set(gtksettings, "gtk-button-images", tde_showIconsOnPushButtons, NULL);
460
+		g_object_set(gtksettings, "gtk-menu-popup-delay", tqApp->style().styleHint(TQStyle::SH_PopupMenu_SubMenuPopupDelay), NULL);
461
+		// Handle toolbar text display
462
+		if (toolbarStyle == 3) {
463
+			// This is broken by GTK bug #68700
464
+			g_object_set(gtksettings, "gtk-toolbar-style", GTK_TOOLBAR_BOTH_HORIZ, NULL);
465
+		}
466
+		else if (toolbarStyle == 2) {
467
+			g_object_set(gtksettings, "gtk-toolbar-style", GTK_TOOLBAR_BOTH, NULL);
468
+		}
469
+		else if (toolbarStyle == 1) {
470
+			g_object_set(gtksettings, "gtk-toolbar-style", GTK_TOOLBAR_TEXT, NULL);
471
+		}
472
+		else {
473
+			g_object_set(gtksettings, "gtk-toolbar-style", GTK_TOOLBAR_ICONS, NULL);
474
+		}
475
+	}
476
+
477
+	// This function takes quite a long time to execute, and is run at the start of every app.
478
+	// In order to speed it up, we can store the results in a file, along with the name of icon
479
+	// theme and style.  This file can then be regenerated when the icon theme or style change.
480
+
481
+	TQDir curDir;
482
+	TQString themeFilePath = TQDir::homeDirPath();
483
+	curDir.setPath(themeFilePath);
484
+	if (!curDir.exists()) {
485
+		curDir.mkdir(themeFilePath);
486
+	}
487
+	themeFilePath = themeFilePath + "/.themes/";
488
+	curDir.setPath(themeFilePath);
489
+	if (!curDir.exists()) {
490
+		curDir.mkdir(themeFilePath);
491
+	}
492
+	themeFilePath = themeFilePath + TQString(TDEGTK_THEME_THEME_DIRECTORY_NAME) + "/";
493
+	curDir.setPath(themeFilePath);
494
+	if (!curDir.exists()) {
495
+		curDir.mkdir(themeFilePath);
496
+	}
497
+	themeFilePath = themeFilePath + "gtk-3.0/";
498
+	curDir.setPath(themeFilePath);
499
+	if (!curDir.exists()) {
500
+		curDir.mkdir(themeFilePath);
501
+	}
502
+
503
+	themeFilePath = themeFilePath + TDEGTK_THEME_CONTROL_FILE_NAME;
504
+	TQFile themeFile(themeFilePath);
505
+	TQTextStream stream;
506
+	
507
+	if (!forceRecreate && themeFile.exists())
508
+	{
509
+		themeFile.open(IO_ReadOnly);
510
+		stream.setDevice(TQT_TQIODEVICE(&themeFile));
511
+		
512
+		if (stream.readLine() == "/* " + iconTheme + ", " + tqApp->style().name() + ", " + RC_CACHE_VERSION + " */")
513
+		{
514
+			// This cache matches the current icon theme and style
515
+			gtk3_tqt_reload_theme_definition_file(themeFilePath.latin1());
516
+			return;
517
+		}
518
+		
519
+		stream.unsetDevice();
520
+		themeFile.close();
521
+	}
522
+	
523
+	themeFile.open(IO_WriteOnly | IO_Truncate);
524
+	stream.setDevice(TQT_TQIODEVICE(&themeFile));
525
+	
526
+	stream << "/* " << iconTheme << ", " << tqApp->style().name() << ", " << RC_CACHE_VERSION << " */\n\n";
527
+	stream << "/* This file was generated by the Gtk TQt Theme Engine */\n";
528
+	stream << "/* It will be recreated when you change your TDE icon theme or widget style */\n\n";
529
+
530
+	stream << "\n";
531
+	stream << "* {\n\tengine:tdegtk;\n}\n";
532
+	stream << "\n";
533
+	
534
+	TQScrollBar sbar(NULL);
535
+	sbar.setOrientation(TQt::Horizontal);
536
+	sbar.setValue(1);
537
+	sbar.resize(200,25);
538
+	
539
+	// The following code determines how many buttons are on a scrollbar
540
+	// It works by looking at each pixel of the scrollbar's area not taken up by the groove,
541
+	// and asking the style which subcontrol is at that location.
542
+	TQRect rect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, &sbar, TQStyle::SC_ScrollBarGroove);
543
+	
544
+	bool back1 = false;
545
+	bool forward1 = false;
546
+	bool back2 = false;
547
+	bool forward2 = false;
548
+	
549
+	TQStyle::SubControl sc = TQStyle::SC_None;
550
+	for (TQPoint pos(0,7) ; pos.x()<rect.x() ; pos.setX(pos.x()+1))
551
+	{
552
+		TQStyle::SubControl sc2 = tqApp->style().querySubControl(TQStyle::CC_ScrollBar, &sbar, pos);
553
+		if (sc != sc2)
554
+		{
555
+			if (sc2 == TQStyle::SC_ScrollBarAddLine) forward1 = true;
556
+			if (sc2 == TQStyle::SC_ScrollBarSubLine) back1 = true;
557
+			sc = sc2;
558
+		}
559
+	}
560
+	sc = TQStyle::SC_None;
561
+	for (TQPoint pos(rect.x()+rect.width(),7) ; pos.x()<200 ; pos.setX(pos.x()+1))
562
+	{
563
+		TQStyle::SubControl sc2 = tqApp->style().querySubControl(TQStyle::CC_ScrollBar, &sbar, pos);
564
+		if (sc != sc2)
565
+		{
566
+			if (sc2 == TQStyle::SC_ScrollBarAddLine) forward2 = true;
567
+			if (sc2 == TQStyle::SC_ScrollBarSubLine) back2 = true;
568
+			sc = sc2;
569
+		}
570
+	}
571
+
572
+	bool combobox_appears_as_list = (!(tqApp->style().styleHint(TQStyle::SH_ComboBox_Popup) || tqApp->style().styleHint(TQStyle::SH_GUIStyle) == TQt::MotifStyle));
573
+	stream << parse_rc_string(TQString("-GtkComboBox-appears-as-list: %1px").arg(combobox_appears_as_list), "*");
574
+
575
+	stream << parse_rc_string(TQString("-GtkScrollbar-has-backward-stepper: ") + (back1 ? "1" : "0"), "*");
576
+	stream << parse_rc_string(TQString("-GtkScrollbar-has-forward-stepper: ") + (forward2 ? "1" : "0"), "*");
577
+	stream << parse_rc_string(TQString("-GtkScrollbar-has-secondary-forward-stepper: ") + (forward1 ? "1" : "0"), "*");
578
+	stream << parse_rc_string(TQString("-GtkScrollbar-has-secondary-backward-stepper: ") + (back2 ? "1" : "0"), "*");
579
+
580
+	stream << parse_rc_string("-GtkScrollbar-stepper-size: " + TQString::number(tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, &sbar, TQStyle::SC_ScrollBarSubLine).width() - 1), "*");
581
+
582
+	stream << parse_rc_string("-GtkScrollbar-min-slider-length: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ScrollBarSliderMin)), "*");
583
+	stream << parse_rc_string("-GtkScrollbar-slider-width: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ScrollBarExtent)-2), "*");
584
+
585
+	stream << parse_rc_string("-GtkButton-child-displacement-x: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ButtonShiftHorizontal)), "*");
586
+	stream << parse_rc_string("-GtkButton-child-displacement-y: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ButtonShiftVertical)), "*");
587
+	stream << parse_rc_string("-GtkButton-default-border: 0 0 0 0", "*");
588
+	stream << parse_rc_string("-GtkButton-default-outside-border: 0 0 0 0", "*");
589
+#ifdef USE_NATIVE_GTK_BUTTON_DRAWING
590
+	stream << parse_rc_string("-GtkButton-inner-border: 2 2 2 2", "*");
591
+#else
592
+	if (tde_showIconsOnPushButtons) {
593
+		stream << parse_rc_string("-GtkButton-inner-border: 10 10 2 2", "*");	// Allow space for the icon on either side of the text
594
+	}
595
+	else {
596
+		stream << parse_rc_string("-GtkButton-inner-border: 2 2 2 2", "*");
597
+	}
598
+#endif
599
+
600
+	stream << parse_rc_string("-GtkButtonBox-child_min_height: 0", "*");
601
+	stream << parse_rc_string("-GtkButtonBox-child_internal_pad_x: 0", "*");
602
+	stream << parse_rc_string("-GtkButtonBox-child_internal_pad_y: 0", "*");
603
+
604
+	TQSlider slider(NULL); // To keep BlueCurve happy
605
+	stream << parse_rc_string("-GtkScale-slider-length: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_SliderLength, &slider)), "*");
606
+
607
+	stream << parse_rc_string("-GtkRange-arrow-scaling: 1.0", "GtkScrollbar");
608
+
609
+	stream << parse_rc_string("-xthickness: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_DefaultFrameWidth)), "*.GtkMenu");
610
+	stream << parse_rc_string("-ythickness: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_DefaultFrameWidth)), "*.GtkMenu");
611
+	stream << parse_rc_string("-xthickness: 5", "*.GtkMenu.Gtk*MenuItem");
612
+	stream << parse_rc_string("-xthickness: 3", "*.GtkNotebook");
613
+	stream << parse_rc_string("-ythickness: 3", "*.GtkNotebook");
614
+	stream << parse_rc_string("-ythickness: 1", "*.GtkButton");
615
+	stream << parse_rc_string("-color: " + colorString(TQColor(0,0,0)), "gtk-tooltips.GtkLabel", false);
616
+
617
+	stream << parse_rc_string("-xthickness: 1", "*.GtkButton.*");
618
+	stream << parse_rc_string("-ythickness: 1", "*.GtkButton.*");
619
+
620
+//	stream << parse_rc_string("GtkTreeView::allow-rules = 0", "*");
621
+//	stream << parse_rc_string("GtkTreeView::tree-line-width = 1", "*");
622
+//	stream << parse_rc_string("GtkTreeView::vertical-separator = 30", "*");
623
+//	//stream << parse_rc_string("GtkTreeView::odd-row-color = { 0.0, 0.0, 0.0 }", "*");
624
+
625
+	stream << parse_rc_string("-GtkButton-inner-border: 0 0 0 0", "*GtkToolbar*GtkButton*");
626
+	stream << parse_rc_string("-GtkButton-inner-border: 0 0 0 0", "*GtkToolbar*GtkToggleButton*");
627
+	stream << parse_rc_string("-GtkButton-inner-border: 0 0 0 0", "*GtkNotebook*GtkButton*");
628
+	stream << parse_rc_string("-GtkButton-inner-border: 0 0 0 0", "*GtkNotebook*GtkToggleButton*");
629
+
630
+	// TQt calls them tab boxes, GTK calls them notebooks (!??!?)  Either way they are a pain...
631
+	//stream << parse_rc_string("-GtkNotebook-tab-overlap: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap)), "*");
632
+	stream << parse_rc_string("-GtkNotebook-tab-overlap: 0", "*");	// Overlap is handled in the style engine itself
633
+	stream << parse_rc_string("-GtkNotebook-tab-curvature: 0", "*");
634
+
635
+	// This sets both the radio button and check box sizes
636
+	stream << parse_rc_string("-GtkCheckButton-indicator-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_IndicatorHeight)), "*");
637
+
638
+	// FIXME
639
+	// GtkCellRendererToggle indicator-size must be set as follows, however GTK3 does not provide any means to change the default size!
640
+	// See upstream GTK bug #687076
641
+	//stream << parse_rc_string("-GtkCellRendererToggle-indicator-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_IndicatorHeight)), "*");
642
+
643
+	// FIXME
644
+	// There must be a way to set the selected tab offset (shift)
645
+	// If not, it may be neccessary to override the GTK text drawing routines for notebooks to insert the proper shift
646
+	//stream << parse_rc_string("-????: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_TabBarTabShiftHorizontal)), "*");
647
+
648
+	stream << parse_rc_string("-GtkButton-child-displacement-x: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ButtonShiftHorizontal)), "*");
649
+	stream << parse_rc_string("-GtkButton-child-displacement-y: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ButtonShiftVertical)), "*");
650
+
651
+	// Set up fonts
652
+	TQFont generalFont = KGlobalSettings::generalFont();
653
+	TQFont toolBarFont = KGlobalSettings::toolBarFont();
654
+	TQFont menuFont = KGlobalSettings::menuFont();
655
+	// TQFont windowTitleFont = KGlobalSettings::windowTitleFont();
656
+	// TQFont taskbarFont = KGlobalSettings::taskbarFont();
657
+ 
658
+	stream << parse_rc_string(tdeFontToGTKFontString(generalFont), "*");
659
+	stream << parse_rc_string(tdeFontToGTKFontString(toolBarFont), "*GtkToolbar*GtkButton*");
660
+	stream << parse_rc_string(tdeFontToGTKFontString(menuFont), "*.GtkMenu");
661
+
662
+	// Set up icons
663
+	// Build the list of icon theme directories.
664
+	// This function is recursive - it gets the directories of all the inherited themes as well
665
+	addIconThemeDir(iconTheme);
666
+
667
+	if (iconThemeDirs.isEmpty()) {
668
+		themeFile.close();
669
+		if (!forceRecreate) {
670
+			gtk3_tqt_reload_theme_definition_file(themeFilePath.latin1());
671
+		}
672
+		return;
673
+	}
674
+
675
+	GtkIconFactory* factory;
676
+	factory = gtk_icon_factory_new();
677
+
678
+	doIconMapping("gtk-about", "actions/about_kde.png", factory, iconThemeDirs);
679
+	doIconMapping("gtk-add", "actions/add.png", factory, iconThemeDirs);
680
+	doIconMapping("gtk-apply", "actions/apply.png", factory, iconThemeDirs);
681
+	doIconMapping("gtk-bold", "actions/text_bold.png", factory, iconThemeDirs);
682
+	doIconMapping("gtk-cancel", "actions/button_cancel.png", factory, iconThemeDirs);
683
+	doIconMapping("gtk-cdrom", "devices/cdrom_unmount.png", factory, iconThemeDirs);
684
+	doIconMapping("gtk-clear", "actions/editclear.png", factory, iconThemeDirs);
685
+	doIconMapping("gtk-close", "actions/fileclose.png", factory, iconThemeDirs);
686
+	doIconMapping("gtk-color-picker", "actions/colorpicker.png", factory, iconThemeDirs);
687
+	doIconMapping("gtk-copy", "actions/editcopy.png", factory, iconThemeDirs);
688
+	doIconMapping("gtk-convert", "actions/gtk-convert.png", factory, iconThemeDirs);
689
+	doIconMapping("gtk-connect", "actions/connect_creating.png", factory, iconThemeDirs);
690
+	doIconMapping("gtk-cut", "actions/editcut.png", factory, iconThemeDirs);
691
+	doIconMapping("gtk-delete", "actions/editdelete.png", factory, iconThemeDirs);
692
+	doIconMapping("gtk-dialog-authentication", "status/gtk-dialog-authentication", factory, iconThemeDirs);
693
+	doIconMapping("gtk-dialog-error", "actions/messagebox_critical.png", factory, iconThemeDirs);
694
+	doIconMapping("gtk-dialog-info", "actions/messagebox_info.png", factory, iconThemeDirs);
695
+	doIconMapping("gtk-dialog-question", "actions/help.png", factory, iconThemeDirs);
696
+	doIconMapping("gtk-dialog-warning", "actions/messagebox_warning.png", factory, iconThemeDirs);
697
+	doIconMapping("gtk-directory", "filesystems/folder.png", factory, iconThemeDirs);
698
+	doIconMapping("gtk-disconnect", "actions/connect_no.png", factory, iconThemeDirs);
699
+	doIconMapping("gtk-dnd", "mimetypes/empty.png", factory, iconThemeDirs);
700
+	doIconMapping("gtk-dnd-multiple", "mimetypes/kmultiple.png", factory, iconThemeDirs);
701
+	doIconMapping("gtk-edit", "actions/edit.png", factory, iconThemeDirs);  //2.6 
702
+	doIconMapping("gtk-execute", "actions/exec.png", factory, iconThemeDirs);
703
+	doIconMapping("gtk-file", "mimetypes/empty.png", factory, iconThemeDirs);
704
+	doIconMapping("gtk-find", "actions/find.png", factory, iconThemeDirs);
705
+	doIconMapping("gtk-find-and-replace", "actions/find.png", factory, iconThemeDirs);	// Is there a TDE "find and replace" icon? FIXME
706
+	doIconMapping("gtk-floppy", "devices/3floppy_unmount.png", factory, iconThemeDirs);
707
+	doIconMapping("gtk-fullscreen", "actions/window-fullscreen.png", factory, iconThemeDirs);
708
+	doIconMapping("gtk-goto-bottom", "actions/bottom.png", factory, iconThemeDirs);
709
+	doIconMapping("gtk-goto-first", "actions/start.png", factory, iconThemeDirs);
710
+	doIconMapping("gtk-goto-last", "actions/finish.png", factory, iconThemeDirs);
711
+	doIconMapping("gtk-goto-top", "actions/top.png", factory, iconThemeDirs);
712
+	doIconMapping("gtk-go-back", "actions/back.png", factory, iconThemeDirs);
713
+	doIconMapping("gtk-go-down", "actions/down.png", factory, iconThemeDirs);
714
+	doIconMapping("gtk-go-forward", "actions/forward.png", factory, iconThemeDirs);
715
+	doIconMapping("gtk-go-up", "actions/up.png", factory, iconThemeDirs);
716
+	doIconMapping("gtk-harddisk", "devices/hdd_unmount.png", factory, iconThemeDirs);
717
+	doIconMapping("gtk-help", "apps/khelpcenter.png", factory, iconThemeDirs);
718
+	doIconMapping("gtk-home", "filesystems/folder_home.png", factory, iconThemeDirs);
719
+	doIconMapping("gtk-indent", "actions/indent.png", factory, iconThemeDirs);
720
+	doIconMapping("gtk-index", "actions/contents.png", factory, iconThemeDirs);
721
+	doIconMapping("gtk-info", "actions/messagebox_info.png", factory, iconThemeDirs);
722
+	doIconMapping("gtk-italic", "actions/text_italic.png", factory, iconThemeDirs);
723
+	doIconMapping("gtk-jump-to", "actions/goto.png", factory, iconThemeDirs);
724
+	doIconMapping("gtk-justify-center", "actions/text_center.png", factory, iconThemeDirs);
725
+	doIconMapping("gtk-justify-fill", "actions/text_block.png", factory, iconThemeDirs);
726
+	doIconMapping("gtk-justify-left", "actions/text_left.png", factory, iconThemeDirs);
727
+	doIconMapping("gtk-justify-right", "actions/text_right.png", factory, iconThemeDirs);
728
+	doIconMapping("gtk-leave-fullscreen", "actions/window-nofullscreen.png", factory, iconThemeDirs);
729
+	doIconMapping("gtk-media-forward", "player-fwd.png", factory, iconThemeDirs);
730
+	doIconMapping("gtk-media-next", "actions/player-end.png", factory, iconThemeDirs);
731
+	doIconMapping("gtk-media-pause", "actions/player-pause.png", factory, iconThemeDirs);
732
+	doIconMapping("gtk-media-previous", "actions/player-start.png", factory, iconThemeDirs);
733
+	doIconMapping("gtk-media-record", "actions/gtk-media-record.png", factory, iconThemeDirs);	// FIXME
734
+	doIconMapping("gtk-media-rewind", "actions/player-rew.png", factory, iconThemeDirs);
735
+	doIconMapping("gtk-media-stop", "actions/player-stop.png", factory, iconThemeDirs);
736
+	doIconMapping("gtk-missing-image", "mimetypes/unknown.png", factory, iconThemeDirs);
737
+	doIconMapping("gtk-network", "filesystems/network.png", factory, iconThemeDirs);
738
+	doIconMapping("gtk-new", "actions/filenew.png", factory, iconThemeDirs);
739
+	doIconMapping("gtk-no", "actions/gtk-no.png", factory, iconThemeDirs);
740
+	doIconMapping("gtk-ok", "actions/button_ok.png", factory, iconThemeDirs);
741
+	doIconMapping("gtk-open", "actions/fileopen.png", factory, iconThemeDirs);
742
+	//doIconMapping("gtk-orientation-landscape", factory, iconThemeDirs);			// FIXME
743
+	//doIconMapping("gtk-orientation-portrait", factory, iconThemeDirs);			// FIXME
744
+	//doIconMapping("gtk-orientation-reverse-landscape", factory, iconThemeDirs);		// FIXME
745
+	//doIconMapping("gtk-orientation-reverse-portrait"", factory, iconThemeDirs);		// FIXME
746
+	doIconMapping("gtk-paste", "actions/editpaste.png", factory, iconThemeDirs);
747
+	doIconMapping("gtk-preferences", "actions/configure.png", factory, iconThemeDirs);
748
+	doIconMapping("gtk-print", "actions/fileprint.png", factory, iconThemeDirs);
749
+	doIconMapping("gtk-print-preview", "actions/filequickprint.png", factory, iconThemeDirs);
750
+	doIconMapping("gtk-properties", "actions/configure.png", factory, iconThemeDirs);
751
+	doIconMapping("gtk-quit", "actions/exit.png", factory, iconThemeDirs);
752
+	doIconMapping("gtk-redo", "actions/redo.png", factory, iconThemeDirs);
753
+	doIconMapping("gtk-refresh", "actions/reload.png", factory, iconThemeDirs);
754
+	doIconMapping("gtk-remove", "actions/remove.png", factory, iconThemeDirs);
755
+	doIconMapping("gtk-revert-to-saved", "actions/revert.png", factory, iconThemeDirs);
756
+	doIconMapping("gtk-save", "actions/filesave.png", factory, iconThemeDirs);
757
+	doIconMapping("gtk-save-as", "actions/filesaveas.png", factory, iconThemeDirs);
758
+	doIconMapping("gtk-select-all", "actions/gtk-select-all.png", factory, iconThemeDirs);	// FIXME
759
+	doIconMapping("gtk-select-color", "actions/colorize.png", factory, iconThemeDirs);
760
+	doIconMapping("gtk-select-font", "mimetypes/font.png", factory, iconThemeDirs);
761
+	//doIconMapping("gtk-sort-ascending", "??", factory, iconThemeDirs);				// FIXME
762
+	//doIconMapping("gtk-sort-descending", "??", factory, iconThemeDirs);				// FIXME
763
+	doIconMapping("gtk-spell-check", "actions/spellcheck.png", factory, iconThemeDirs);
764
+	doIconMapping("gtk-stop", "actions/stop.png", factory, iconThemeDirs);
765
+	doIconMapping("gtk-strikethrough", "actions/text_strike.png", factory, iconThemeDirs);
766
+	doIconMapping("gtk-undelete", "actions/gtk-undelete.png", factory, iconThemeDirs);		// FIXME
767
+	doIconMapping("gtk-underline", "actions/text_under.png", factory, iconThemeDirs);
768
+	doIconMapping("gtk-undo", "actions/undo.png", factory, iconThemeDirs);
769
+	doIconMapping("gtk-unindent", "actions/unindent.png", factory, iconThemeDirs);
770
+	doIconMapping("gtk-yes", "actions/button_ok.png", factory, iconThemeDirs);			// Verify mapping here
771
+	doIconMapping("gtk-zoom-100", "actions/viewmag1.png", factory, iconThemeDirs);
772
+	doIconMapping("gtk-zoom-fit", "actions/viewmagfit.png", factory, iconThemeDirs);
773
+	doIconMapping("gtk-zoom-in", "actions/viewmag+.png", factory, iconThemeDirs);
774
+	doIconMapping("gtk-zoom-out", "actions/viewmag-.png", factory, iconThemeDirs);
775
+
776
+	// Other icons that really should have Trinity equivalents in tdelibs
777
+	doIconMapping("list-add", "actions/add.png", factory, iconThemeDirs);
778
+	doIconMapping("list-remove", "actions/remove.png", factory, iconThemeDirs);
779
+
780
+	gtk_icon_factory_add_default(factory);
781
+	
782
+	themeFile.close();
783
+
784
+	if (!forceRecreate) {
785
+		gtk3_tqt_reload_theme_definition_file(themeFilePath.latin1());
786
+	}
787
+}
788
+// =========================================================================================================

+ 23
- 2
tdegtk/tdegtk-types.h View File

@@ -1,5 +1,5 @@
1 1
 /* The TdeGtk Theming Engine for Gtk+.
2
- * Copyright (C) 2011 Canonical Ltd
2
+ * Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
3 3
  *
4 4
  * This  library is free  software; you can  redistribute it and/or
5 5
  * modify it  under  the terms  of the  GNU Lesser  General  Public
@@ -16,7 +16,8 @@
16 16
  * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
17 17
  * MA 02110-1301, USA.
18 18
  *
19
- * Authored by Andrea Cimitan <andrea.cimitan@canonical.com>
19
+ * Portions of this file written by
20
+ * Andrea Cimitan <andrea.cimitan@canonical.com>
20 21
  *
21 22
  */
22 23
 
@@ -61,6 +62,26 @@ typedef enum
61 62
   TDEGTK_NUM_STYLES = 1
62 63
 } TdeGtkStyles;
63 64
 
65
+enum TQt3WidgetType {
66
+	TQT3WT_NONE,
67
+	TQT3WT_TQProgressBar,
68
+	TQT3WT_TQTabBar,
69
+	TQT3WT_TQRadioButton,
70
+	TQT3WT_TQCheckBox,
71
+	TQT3WT_TQPushButton,
72
+	TQT3WT_TQPopupMenu,
73
+	TQT3WT_TQComboBox,
74
+	TQT3WT_TQSlider,
75
+	TQT3WT_TQScrollBar,
76
+	TQT3WT_TQSpinBox,
77
+	TQT3WT_TQSpinWidget,
78
+	TQT3WT_TQTitleBar,
79
+	TQT3WT_TQMenuBar,
80
+	TQT3WT_TQToolBox,
81
+	TQT3WT_TQToolButton,
82
+	TQT3WT_GTKTreeViewCell,
83
+};
84
+
64 85
 typedef struct _TdeGtkStyleFunctions TdeGtkStyleFunctions;
65 86
 
66 87
 struct _TdeGtkStyleFunctions

+ 1064
- 0
tdegtk/tdegtk-utils.cpp
File diff suppressed because it is too large
View File


+ 428
- 0
tdegtk/tdegtk-utils.h View File

@@ -0,0 +1,428 @@
1
+#ifndef tdegtk_utils_h
2
+#define tdegtk_utils_h
3
+/*
4
+* this file was largely taken from the oxygen gtk engine
5
+* Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
6
+* Copyright (c) 2010 Ruslan Kabatsayev <b7.10110111@gmail.com>
7
+*
8
+* GdkPixbuf modification code from Walmis
9
+* <http://gnome-look.org/content/show.php?content=77783&forumpage=3>
10
+*
11
+* This  library is free  software; you can  redistribute it and/or
12
+* modify it  under  the terms  of the  GNU Lesser  General  Public
13
+* License  as published  by the Free  Software  Foundation; either
14
+* version 2 of the License, or( at your option ) any later version.
15
+*
16
+* This library is distributed  in the hope that it will be useful,
17
+* but  WITHOUT ANY WARRANTY; without even  the implied warranty of
18
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
+* Lesser General Public License for more details.
20
+*
21
+* You should have received a copy of the GNU Lesser General Public
22
+* License  along  with  this library;  if not,  write to  the Free
23
+* Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
24
+* MA 02110-1301, USA.
25
+*/
26
+
27
+// #include "oxygenrgba.h"
28
+
29
+#include <gdk/gdk.h>
30
+#include <gtk/gtk.h>
31
+
32
+#include <cmath>
33
+#include <string>
34
+
35
+#if 0
36
+    //! GdkRectangle streamer
37
+    inline std::ostream& operator << (std::ostream& out, const GdkRectangle& rect )
38
+    {
39
+        out << "( " << rect.x << "," << rect.y << "," << rect.width << "," << rect.height << ")";
40
+        return out;
41
+    }
42
+
43
+    //! GtkBorder streamer
44
+    inline std::ostream& operator << (std::ostream& out, const GtkBorder& border )
45
+    {
46
+        out << "( " << border.left << "," << border.right << "," << border.top << "," << border.bottom << ")";
47
+        return out;
48
+    }
49
+
50
+    //! streamer for GtkWidgetPath
51
+    std::ostream& operator << ( std::ostream& out, const GtkWidgetPath* path );
52
+
53
+    //! GtkContainer streamer
54
+    inline std::ostream& operator << (std::ostream& out, GtkContainer* container)
55
+    {
56
+        GList* children=gtk_container_get_children(container);
57
+        for(GList* child=g_list_first(children); child; child=g_list_next(child))
58
+        {
59
+            out << G_OBJECT_TYPE_NAME(child->data) << " ";
60
+        }
61
+        g_list_free(children);
62
+        return out;
63
+    }
64
+#endif
65
+
66
+    namespace Gtk
67
+    {
68
+
69
+        //! mouse button enumeration
70
+        enum MouseButton
71
+        {
72
+            NoButton = 0,
73
+            LeftButton = 1,
74
+            RightButton = 2,
75
+            MidButton = 3
76
+        };
77
+
78
+        //@!name gdk utilities
79
+        //@{
80
+
81
+#if 0
82
+        //! returns OxygenRgba color from GdkColor
83
+        /*! TODO: remove as obsolete */
84
+        inline ColorUtils::Rgba gdk_get_color( const GdkColor& color )
85
+        {
86
+            return ColorUtils::Rgba(
87
+                double(color.red)/0xffff,
88
+                double(color.green)/0xffff,
89
+                double(color.blue)/0xffff );
90
+        }
91
+
92
+        //! returns OxygenRgba color from GdkColor
93
+        inline ColorUtils::Rgba gdk_get_color( const GdkRGBA& color )
94
+        { return ColorUtils::Rgba( color.red, color.green, color.blue, color.alpha ); }
95
+#endif
96
+
97
+        //! map widget origin to top level
98
+        /*!
99
+        x and y correspond to (0,0) maped to toplevel window;
100
+        w and h correspond to toplevel window frame size
101
+        */
102
+        bool gdk_window_map_to_toplevel( GdkWindow*, gint*, gint*, gint*, gint*, bool frame = false );
103
+
104
+        //! map widget origin to top level
105
+        /*!
106
+        x and y correspond to (0,0) maped to toplevel window;
107
+        w and h correspond to toplevel window frame size
108
+        */
109
+        bool gtk_widget_map_to_toplevel( GtkWidget*, gint*, gint*, gint*, gint*, bool frame = false );
110
+
111
+        //! map widget onto another (parent) widget
112
+        /*! second argument can be any parent in widget's ancestry tree */
113
+        bool gtk_widget_map_to_parent( GtkWidget*, GtkWidget*, gint*, gint*, gint*, gint* );
114
+
115
+        //! map window/widget origin to top level
116
+        inline bool gdk_map_to_toplevel( GdkWindow* window, GtkWidget* widget, gint* x, gint* y, gint* w, gint* h, bool frame = false )
117
+        {
118
+            if( window && GDK_IS_WINDOW( window ) ) return gdk_window_map_to_toplevel( window, x, y, w, h, frame );
119
+            else return gtk_widget_map_to_toplevel( widget, x, y, w, h, frame );
120
+        }
121
+
122
+        //! map window origin to top level
123
+        inline bool gdk_map_to_toplevel( GdkWindow* window, gint* x, gint* y, gint* w, gint* h, bool frame = false )
124
+        { return gdk_window_map_to_toplevel( window, x, y, w, h, frame ); }
125
+
126
+        //! translate origin of child window into parent
127
+        /*! returns true on success */
128
+        bool gdk_window_translate_origin( GdkWindow*, GdkWindow*, gint*, gint* );
129
+
130
+        //! get top level windows dimension
131
+        void gdk_toplevel_get_size( GdkWindow*, gint*, gint* );
132
+
133
+        //! get top level windows dimension
134
+        void gdk_toplevel_get_frame_size( GdkWindow*, gint*, gint* );
135
+
136
+        //! get position relatve to toplevel
137
+        void gdk_window_get_toplevel_origin( GdkWindow*, gint*, gint* );
138
+
139
+        //! add alpha channel to pixbuf
140
+        GdkPixbuf* gdk_pixbuf_set_alpha( const GdkPixbuf*, double );
141
+
142
+        //! changes the gamma value of an image
143
+        bool gdk_pixbuf_to_gamma( GdkPixbuf* pixbuf, double value );
144
+
145
+        //! resize pixbuf
146
+        GdkPixbuf* gdk_pixbuf_resize( GdkPixbuf* src, int width, int height );
147
+
148
+        //! returns initialized GdkRectangle
149
+        inline GdkRectangle gdk_rectangle( int x = 0, int y = 0, int w = -1, int h = -1 )
150
+        {
151
+            GdkRectangle out = {x, y, w, h};
152
+            return out;
153
+        }
154
+
155
+        //! returns true if rectangle is valid
156
+        inline bool gdk_rectangle_is_valid( const GdkRectangle* rect )
157
+        { return rect && rect->width > 0 && rect->height > 0; }
158
+
159
+        //! performs union of two rectangle, properly accounting for their validity
160
+        inline void gdk_rectangle_union( const GdkRectangle* first, const GdkRectangle* second, GdkRectangle* out )
161
+        {
162
+            if( !out ) return;
163
+            const bool firstIsValid( Gtk::gdk_rectangle_is_valid( first ) );
164
+            const bool secondIsValid( Gtk::gdk_rectangle_is_valid( second ) );
165
+            if( firstIsValid && secondIsValid )  ::gdk_rectangle_union( first, second, out );
166
+            else if( secondIsValid ) *out = *second;
167
+            else *out = *first;
168
+        }
169
+
170
+        //! returns true if given rectangle contains point
171
+        inline bool gdk_rectangle_contains( const GdkRectangle* rect, int x, int y )
172
+        {
173
+            return
174
+                rect &&
175
+                ( rect->x <= x && (rect->x + rect->width) > x ) &&
176
+                ( rect->y <= y && (rect->y + rect->height) > y );
177
+        }
178
+
179
+        //@}
180
+
181
+        //! get arrow orientation from angle
182
+        inline GtkArrowType gtk_arrow_get_type( const double& angle )
183
+        {
184
+            static const double delta( 0.001 );
185
+            if( std::abs( angle ) < delta ) return GTK_ARROW_UP;
186
+            else if( std::abs( angle - M_PI/2 ) < delta ) return GTK_ARROW_RIGHT;
187
+            else if( std::abs( angle - M_PI ) < delta ) return GTK_ARROW_DOWN;
188
+            else return GTK_ARROW_LEFT;
189
+        }
190
+
191
+        //! returns true if widget's layout is reversed
192
+        inline bool gtk_widget_layout_is_reversed( GtkWidget* widget )
193
+        { return widget ? gtk_widget_get_direction( widget ) == GTK_TEXT_DIR_RTL : false; }
194
+
195
+        //! returns true if widget's layout is reversed
196
+        inline bool gtk_theming_engine_layout_is_reversed( GtkThemingEngine* engine )
197
+        { return engine ? gtk_theming_engine_get_direction( engine ) == GTK_TEXT_DIR_RTL : false; }
198
+
199
+        //! set all buttons in the container to state NORMAL
200
+        void gtk_container_adjust_buttons_state( GtkContainer*, gpointer=0L );
201
+
202
+        //! returns widget allocation
203
+        inline GtkAllocation gtk_widget_get_allocation( GtkWidget* widget )
204
+        {
205
+            GtkAllocation allocation = { 0, 0, -1, -1 };
206
+            ::gtk_widget_get_allocation( widget, &allocation );
207
+            return allocation;
208
+        }
209
+
210
+        //! returns true if given path as given type
211
+        bool gtk_widget_path_has_type( const GtkWidgetPath*, GType );
212
+
213
+        //! returns true if widget is a groupbox (a la Qt)
214
+        inline bool gtk_widget_is_groupbox( GtkWidget* widget )
215
+        {
216
+            return
217
+                GTK_IS_FRAME( widget ) &&
218
+                gtk_frame_get_label_widget( GTK_FRAME( widget ) ) &&
219
+                gtk_frame_get_shadow_type( GTK_FRAME( widget ) ) == GTK_SHADOW_OUT;
220
+        }
221
+
222
+        //! returns true if widget (or one of its parent) has a custom background
223
+        bool gtk_widget_has_custom_background( GtkWidget*, GtkStateType = GTK_STATE_NORMAL );
224
+
225
+        //! returns true if is an Gnome applet
226
+        bool gtk_widget_is_applet( GtkWidget* );
227
+
228
+        //! print some widget information
229
+        void gtk_widget_print_tree( GtkWidget* );
230
+
231
+        //! returns true if widget supports rgba
232
+        bool gtk_widget_has_rgba( GtkWidget* );
233
+
234
+        //! returns true if default screen is composited
235
+        bool gdk_default_screen_is_composited( void );
236
+
237
+        //! returns true if window supports rgba
238
+        bool gdk_window_has_rgba( GdkWindow* );
239
+
240
+        //! true if visual supports rgba
241
+        bool gdk_visual_has_rgba( GdkVisual* );
242
+
243
+        //! returns true if window is a base window
244
+        bool gdk_window_is_base( GdkWindow* );
245
+
246
+        //! returns true if window is a base window that do not need painting
247
+        bool gdk_window_nobackground( GdkWindow* );
248
+
249
+        //! true if object match a given type
250
+        bool g_object_is_a( const GObject*, const std::string& );
251
+
252
+        //! trigger area update using GdkRectangle
253
+        inline void gtk_widget_queue_draw( GtkWidget* widget, const GdkRectangle* rect = 0L )
254
+        {
255
+            if( !gdk_rectangle_is_valid( rect ) ) ::gtk_widget_queue_draw( widget );
256
+            else ::gtk_widget_queue_draw_area( widget, rect->x, rect->y, rect->width, rect->height );
257
+        }
258
+
259
+        //!@name check parent type
260
+        //@{
261
+
262
+        //! returns widget path as a string
263
+        std::string gtk_widget_path( GtkWidget* );
264
+
265
+        //! return parent of given type if any
266
+        GtkWidget* gtk_widget_find_parent( GtkWidget*, GType );
267
+
268
+        //! return parent of given type
269
+        inline GtkWidget* gtk_widget_find_parent( GtkWidget* widget, const std::string& typeName )
270
+        {
271
+            const GType tmp( g_type_from_name( typeName.c_str() ) );
272
+            return tmp ? gtk_widget_find_parent( widget, tmp ): 0L;
273
+        }
274
+
275
+        //! return parent "group box" if any.
276
+        GtkWidget* gtk_parent_groupbox( GtkWidget* widget );
277
+
278
+        //! return parent button if any.
279
+        inline GtkWidget* gtk_parent_button( GtkWidget* widget )
280
+        { return gtk_widget_find_parent( widget, GTK_TYPE_BUTTON ); }
281
+
282
+        //! return parent menu if any
283
+        inline GtkWidget* gtk_parent_menubar( GtkWidget* widget )
284
+        { return gtk_widget_find_parent( widget, GTK_TYPE_MENU_BAR ); }
285
+
286
+        //! return parent menu if any
287
+        inline GtkWidget* gtk_parent_menu( GtkWidget* widget )
288
+        { return gtk_widget_find_parent( widget, GTK_TYPE_MENU ); }
289
+
290
+        //! return parent treeview if any.
291
+        inline GtkWidget* gtk_parent_tree_view( GtkWidget* widget )
292
+        { return gtk_widget_find_parent( widget, GTK_TYPE_TREE_VIEW ); }
293
+
294
+        //! return parent combobox if any.
295
+        inline GtkWidget* gtk_parent_combobox( GtkWidget* widget )
296
+        { return gtk_widget_find_parent( widget, GTK_TYPE_COMBO_BOX ); }
297
+
298
+        //! return parent combobox if any.
299
+        inline GtkWidget* gtk_parent_combobox_entry( GtkWidget* widget )
300
+        {
301
+            GtkWidget* parent( gtk_parent_combobox( widget ) );
302
+            return ( parent && gtk_combo_box_get_has_entry( GTK_COMBO_BOX( parent ) ) ) ? parent:0L;
303
+        }
304
+
305
+        //! return parent scrolled window if any.
306
+        inline GtkWidget* gtk_parent_scrolled_window( GtkWidget* widget )
307
+        { return gtk_widget_find_parent( widget, GTK_TYPE_SCROLLED_WINDOW ); }
308
+
309
+        //! return parent statusbar if any.
310
+        inline GtkWidget* gtk_parent_statusbar( GtkWidget* widget )
311
+        { return gtk_widget_find_parent( widget, GTK_TYPE_STATUSBAR ); }
312
+
313
+        //! return parent combobox if any.
314
+        inline GtkWidget* gtk_parent_notebook( GtkWidget* widget )
315
+        { return gtk_widget_find_parent( widget, GTK_TYPE_NOTEBOOK ); }
316
+
317
+        //! returns true if potentialParent is (maybe indirect) parent of widget
318
+        bool gtk_widget_is_parent( GtkWidget*, GtkWidget* potentialParent );
319
+
320
+        //! returns true if one of the parent widgets has a sunken shadow
321
+        bool gtk_parent_is_shadow_in( GtkWidget* );
322
+
323
+        //@}
324
+
325
+        //! true if a widget (orientable) is horizontal
326
+        inline bool gtk_widget_is_horizontal( GtkWidget* widget )
327
+        {
328
+            if( !GTK_IS_ORIENTABLE( widget ) ) return true;
329
+            return gtk_orientable_get_orientation( GTK_ORIENTABLE( widget ) ) == GTK_ORIENTATION_HORIZONTAL;
330
+        }
331
+
332
+
333
+        //! true if a widget (orientable) is vertical
334
+        inline bool gtk_widget_is_vertical( GtkWidget* widget )
335
+        {
336
+            if( !GTK_IS_ORIENTABLE( widget ) ) return false;
337
+            return gtk_orientable_get_orientation( GTK_ORIENTABLE( widget ) ) == GTK_ORIENTATION_VERTICAL;
338
+        }
339
+
340
+        //! true if scrolled window must be forced to have a sunken frame
341
+        bool gtk_scrolled_window_force_sunken( GtkWidget* );
342
+
343
+        //!@name button utilities
344
+        //@{
345
+
346
+        //! true for 'flat' buttons (e.g. toolbuttons)
347
+        bool gtk_button_is_flat( GtkWidget* );
348
+
349
+        //! true for treeview headers and affiliated
350
+        bool gtk_button_is_header( GtkWidget* );
351
+
352
+        //! true for buttons in path bars
353
+        bool gtk_button_is_in_path_bar( GtkWidget* widget );
354
+
355
+        //! true if widget is last in path bar
356
+        bool gtk_path_bar_button_is_last( GtkWidget* widget );
357
+
358
+        //! returns an image on button-container
359
+        GtkWidget* gtk_button_find_image( GtkWidget* );
360
+
361
+        //! returns an image on button-container
362
+        GtkWidget* gtk_button_find_label( GtkWidget* );
363
+
364
+        //@}
365
+
366
+        //!@name combobox utilities
367
+        //@{
368
+
369
+        //! returns true if combobox has frame
370
+        bool gtk_combobox_has_frame( GtkWidget* );
371
+
372
+        //! true if widget is the treeview of a combobox
373
+        bool gtk_combobox_is_tree_view( GtkWidget* );
374
+
375
+        //! true if widget is the treeview of a combobox
376
+        bool gtk_combobox_is_scrolled_window( GtkWidget* );
377
+
378
+        //! true if widget is the treeview of a combobox
379
+        bool gtk_combobox_is_viewport( GtkWidget* );
380
+
381
+        //! true if widget is the treeview of a combobox
382
+        bool gtk_combobox_is_frame( GtkWidget* );
383
+
384
+        //! true if combobox must appear as list
385
+        bool gtk_combobox_appears_as_list( GtkWidget* );
386
+
387
+        //@}
388
+
389
+        //!@name notebook utilities
390
+        //@{
391
+
392
+        //! returns true if position is in hovered tab
393
+        //* this should move to OxygenTabWidgetData
394
+        bool gtk_notebook_tab_contains( GtkWidget*, int tab, int x, int y );
395
+
396
+        //! returns tab matching position or -1 if none
397
+        int gtk_notebook_find_tab( GtkWidget*, int x, int y );
398
+
399
+        //! returns index of first visible tab
400
+        int gtk_notebook_find_first_tab( GtkWidget* );
401
+
402
+        //! returns true if widget is one of the notebook's tab labels
403
+        bool gtk_notebook_is_tab_label( GtkNotebook*, GtkWidget* );
404
+
405
+        //! returns tabbar rect in notebook
406
+        void gtk_notebook_get_tabbar_rect( GtkNotebook*, GdkRectangle* );
407
+
408
+        //! returns true if notebook has visible scrollbar arrows
409
+        /*! arrows are dimmed visible if at least one of the child tab_labels is unmapped */
410
+        bool gtk_notebook_has_visible_arrows( GtkNotebook* );
411
+
412
+        // make all the buttons on the tabs normal
413
+        bool gtk_notebook_update_close_buttons( GtkNotebook*);
414
+
415
+        //! returns true if widget is a notebook close button
416
+        bool gtk_notebook_is_close_button( GtkWidget* );
417
+
418
+        //@}
419
+
420
+        //! calculates viewport offsets (between view window and bin window
421
+        void gtk_viewport_get_position( GtkViewport*, gint*, gint* );
422
+
423
+        //! returns a widget which has response_id as response id for dialog
424
+        GtkWidget* gtk_dialog_find_button( GtkDialog*, gint );
425
+
426
+    }
427
+
428
+#endif

+ 231
- 0
tdegtk/tdegtk-widgetlookup.cpp View File

@@ -0,0 +1,231 @@
1
+/*
2
+* this file was largely taken from the oxygen gtk engine
3
+* Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
4
+* Copyright (c) 2010 Ruslan Kabatsayev <b7.10110111@gmail.com>
5
+*
6
+* Hook-setup code provided by Ruslan
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 "tdegtk-widgetlookup.h"
25
+#include "config.h"
26
+
27
+#include <iostream>
28
+#include <cairo/cairo-gobject.h>
29
+
30
+// #define TDEGTK_DEBUG 1
31
+
32
+    //__________________________________________________________________
33
+    WidgetLookup::WidgetLookup( void ):
34
+        _hooksInitialized( false ),
35
+        _context( 0L )
36
+    {}
37
+
38
+
39
+    //_____________________________________________________
40
+    WidgetLookup::~WidgetLookup( void )
41
+    {
42
+
43
+        // disconnect hooks
44
+        _drawHook.disconnect();
45
+
46
+    }
47
+
48
+    //_____________________________________________________
49
+    void WidgetLookup::initializeHooks( void )
50
+    {
51
+
52
+        #if TDEGTK_DEBUG
53
+        std::cerr << "Oxygen::WidgetLookup::initializeHooks" << std::endl;
54
+        #endif
55
+
56
+        if( _hooksInitialized ) return;
57
+
58
+        // install hook and test
59
+        if( !_drawHook.connect( "draw", (GSignalEmissionHook)drawHook, this ) ) return;
60
+
61
+        // set initialization flag
62
+        _hooksInitialized = true;
63
+
64
+        return;
65
+
66
+    }
67
+
68
+    //_____________________________________________________
69
+    GtkWidget* WidgetLookup::find( cairo_t* context, const GtkWidgetPath* path ) const
70
+    {
71
+
72
+        // check path
73
+        if( !path ) return 0L;
74
+
75
+        // get length and check
76
+        const gint length( gtk_widget_path_length( path ) );
77
+        if( length < 1 ) return 0L;
78
+
79
+        // lookup last type
80
+        return find( context, gtk_widget_path_iter_get_object_type( path, length-1 ) );
81
+
82
+    }
83
+
84
+    //_____________________________________________________
85
+    GtkWidget* WidgetLookup::find( cairo_t* context, GType type ) const
86
+    {
87
+        // check context
88
+        if( context != _context )
89
+        {
90
+            #if TDEGTK_DEBUG
91
+            std::cerr << "Oxygen::WidgetLookup::find - invalid context: " << context << std::endl;
92
+            #endif
93
+            return 0L;
94
+        }
95
+
96
+        #if TDEGTK_DEBUG
97
+        std::cerr
98
+            << "Oxygen::WidgetLookup::find -"
99
+            << " context: " << context
100
+            << " type: " << g_type_name( type )
101
+            << std::endl;
102
+        #endif
103
+
104
+        // look for type in stored widgets
105
+        /* we loop backward, since last added widgets are more likely to be looked up */
106
+        for( WidgetList::const_reverse_iterator iter = _widgets.rbegin(); iter != _widgets.rend(); ++iter )
107
+        {
108
+            // compare types and return if matched
109
+            if( G_OBJECT_TYPE( *iter ) == type )
110
+            {
111
+                #if TDEGTK_DEBUG
112
+                std::cerr
113
+                    << "Oxygen::WidgetLookup::find -"
114
+                    << " context: " << context
115
+                    << " type: " << g_type_name( type )
116
+                    << " found: " << *iter
117
+                    << std::endl;
118
+                #endif
119
+                return *iter;
120
+            }
121
+        }
122
+
123
+        #if TDEGTK_DEBUG
124
+        std::cerr
125
+            << "Oxygen::WidgetLookup::find -"
126
+            << " context: " << context
127
+            << " type: " << g_type_name( type )
128
+            << " - no match found"
129
+            << std::endl;
130
+        #endif
131
+
132
+        return 0L;
133
+
134
+    }
135
+
136
+    //_____________________________________________________
137
+    void WidgetLookup::bind( GtkWidget* widget, cairo_t* context )
138
+    {
139
+        // check if context has changed and clear widgets if yes
140
+        if( context != _context )
141
+        {
142
+
143
+            #if TDEGTK_DEBUG
144
+            std::cerr
145
+                << "Oxygen::WidgetLookup::bind -"
146
+                << " context: " << _context
147
+                << " widgets: " << _widgets.size()
148
+                << std::endl;
149
+            #endif
150
+
151
+            _context = context;
152
+            _widgets.clear();
153
+        }
154
+
155
+        _widgets.push_back( widget );
156
+
157
+        // add to all widgets map
158
+        if( _allWidgets.find( widget ) == _allWidgets.end() )
159
+        {
160
+            Signal destroyId;
161
+            destroyId.connect( G_OBJECT( widget ), "destroy", G_CALLBACK( destroyNotifyEvent ), this );
162
+            _allWidgets.insert( std::make_pair( widget, destroyId ) );
163
+        }
164
+
165
+    }
166
+
167
+    //____________________________________________________________________________________________
168
+    void WidgetLookup::unregisterWidget( GtkWidget* widget )
169
+    {
170
+
171
+        #if TDEGTK_DEBUG
172
+        std::cerr << "Oxygen::WidgetLookup::unregisterWidget - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl;
173
+        #endif
174
+
175
+        // find in map
176
+        WidgetMap::iterator iter( _allWidgets.find( widget ) );
177
+        assert( iter != _allWidgets.end() );
178
+
179
+        // disconnect signal
180
+        iter->second.disconnect();
181
+
182
+        // erase from lists
183
+        _allWidgets.erase( widget );
184
+        _widgets.remove( widget );
185
+
186
+    }
187
+
188
+    //_____________________________________________________
189
+    gboolean WidgetLookup::drawHook( GSignalInvocationHint*, guint numParams, const GValue* params, gpointer data )
190
+    {
191
+
192
+        // check number of parameters
193
+        if( numParams < 2 ) return FALSE;
194
+
195
+        // get widget from params
196
+        GtkWidget* widget( GTK_WIDGET( g_value_get_object( params ) ) );
197
+
198
+        // check type
199
+        if( !GTK_IS_WIDGET( widget ) ) return FALSE;
200
+
201
+        // check second parameter type.
202
+        if( !G_VALUE_HOLDS( params+1, CAIRO_GOBJECT_TYPE_CONTEXT ) )
203
+        { return FALSE; }
204
+
205
+        // retrieve context and cast
206
+        cairo_t* context( static_cast<cairo_t*>( g_value_get_boxed(params+1) ) );
207
+
208
+        #if TDEGTK_DEBUG
209
+        std::cerr
210
+            << "Oxygen::WidgetLookup::drawHook -"
211
+            << " widget: " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")"
212
+            << " context: " << context
213
+            << std::endl;
214
+        #endif
215
+
216
+        // bind widget and context
217
+        static_cast<WidgetLookup*>( data )->bind( widget, context );
218
+
219
+        return TRUE;
220
+
221
+    }
222
+
223
+
224
+    //____________________________________________________________________________________________
225
+    gboolean WidgetLookup::destroyNotifyEvent( GtkWidget* widget, gpointer data )
226
+    {
227
+        static_cast<WidgetLookup*>(data)->unregisterWidget( widget );
228
+        return FALSE;
229
+    }
230
+
231
+

+ 92
- 0
tdegtk/tdegtk-widgetlookup.h View File

@@ -0,0 +1,92 @@
1
+#ifndef tdegtk_widgetlookup_h
2
+#define tdegtk_widgetlookup_h
3
+/*
4
+* this file was largely taken from the oxygen gtk engine
5
+* Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
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 "tdegtk-hooks.h"
25
+#include "tdegtk-signals.h"
26
+
27
+#include <cairo/cairo.h>
28
+#include <gtk/gtk.h>
29
+
30
+#include <list>
31
+#include <map>
32
+
33
+
34
+    //! uses the widget's "draw" signal to bind GtkWidget and cairo context
35
+    /*! this allows us to retrieve painted widgets from ThemingEngine rendering primitives */
36
+    class WidgetLookup
37
+    {
38
+
39
+        public:
40
+
41
+        //! constructor
42
+        explicit WidgetLookup( void );
43
+
44
+        //! destructor
45
+        virtual ~WidgetLookup( void );
46
+
47
+        //! initialize hooks
48
+        void initializeHooks( void );
49
+
50
+        //! find widget matching given context and type
51
+        GtkWidget* find( cairo_t*, const GtkWidgetPath* ) const;
52
+
53
+        //! find widget matching given context and type
54
+        GtkWidget* find( cairo_t*, GType ) const;
55
+
56
+        protected:
57
+
58
+        //! bind widget to context
59
+        void bind( GtkWidget*, cairo_t* );
60
+
61
+        //! unregister widget
62
+        void unregisterWidget( GtkWidget* );
63
+
64
+        //! hook connected to widget's "draw" signal
65
+        static gboolean drawHook( GSignalInvocationHint*, guint, const GValue*, gpointer );
66
+
67
+        //! destruction callback
68
+        static gboolean destroyNotifyEvent( GtkWidget*, gpointer );
69
+
70
+        private:
71
+
72
+        //! true if hooks are initialized
73
+        bool _hooksInitialized;
74
+
75
+        //! hook connected to widget's "draw" signal
76
+        Hook _drawHook;
77
+
78
+        //! store current context
79
+        cairo_t* _context;
80
+
81
+        //! store list of associated widgets, to keep track of destruction
82
+        typedef std::list<GtkWidget*> WidgetList;
83
+        WidgetList _widgets;
84
+
85
+        //! keep track of all registered widgets, and associated destroy callback
86
+        typedef std::map< GtkWidget*, Signal > WidgetMap;
87
+        WidgetMap _allWidgets;
88
+
89
+    };
90
+
91
+#endif
92
+

+ 9
- 5
tdegtk/tqtcairopainter.cpp View File

@@ -327,16 +327,16 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() {
327 327
 
328 328
 	if (!m_clipRegionEnabled) {
329 329
 		// Clipping disabled
330
-		cairo_set_source_surface(m_devicePainter, m_intermediateSurface, 0, 0);
330
+		cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY);
331 331
 		cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE);
332 332
 		cairo_paint(m_devicePainter);
333 333
 	}
334 334
 	else {
335 335
 		// Clipping enabled
336 336
 		cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion);
337
-		cairo_set_source_surface(m_devicePainter, m_intermediateSurface, 0, 0);
337
+		cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY);
338 338
 		cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE);
339
-		cairo_mask_surface(m_devicePainter, maskSurface, 0, 0);
339
+		cairo_mask_surface(m_devicePainter, maskSurface, m_offsetX, m_offsetY);
340 340
 		cairo_surface_destroy(maskSurface);
341 341
 	}
342 342
 
@@ -1083,16 +1083,18 @@ void TQt3CairoPaintDevice::setCairoTransformations() {
1083 1083
     Constructs TQt3CairoPaintDevice on an existing QPainter
1084 1084
 */
1085 1085
 
1086
-TQt3CairoPaintDevice::TQt3CairoPaintDevice( cairo_surface_t *cairosurface, int width, int height, cairo_t *overridepainter )
1086
+TQt3CairoPaintDevice::TQt3CairoPaintDevice( cairo_surface_t *cairosurface, int x, int y, int width, int height, cairo_t *overridepainter )
1087 1087
     : TQPaintDevice( TQInternal::Picture | TQInternal::ExternalDevice )
1088 1088
 {
1089 1089
 	init();
1090 1090
 
1091
+	m_offsetX = x;
1092
+	m_offsetY = y;
1091 1093
 	if (width >= 0) {
1092 1094
 		m_width = width;
1093 1095
 	}
1094 1096
 	if (height >= 0) {
1095
-		m_height = width;
1097
+		m_height = height;
1096 1098
 	}
1097 1099
 	if (overridepainter) {
1098 1100
 		m_overridePainter = overridepainter;
@@ -1138,6 +1140,8 @@ TQt3CairoPaintDevice::~TQt3CairoPaintDevice()
1138 1140
 void TQt3CairoPaintDevice::init() {
1139 1141
 	m_width = -1;
1140 1142
 	m_height = -1;
1143
+	m_offsetX = 0;
1144
+	m_offsetY = 0;
1141 1145
 
1142 1146
 	m_intermediateSurface = NULL;
1143 1147
 	m_painter = NULL;

+ 3
- 1
tdegtk/tqtcairopainter.h View File

@@ -40,7 +40,7 @@ typedef TQPtrStack<TQWMatrix> TQWMatrixStack;
40 40
 class Q_EXPORT TQt3CairoPaintDevice : public TQPaintDevice		// picture class
41 41
 {
42 42
 	public:
43
-		TQt3CairoPaintDevice( cairo_surface_t *, int width = -1, int height = -1, cairo_t *overridepainter = NULL );
43
+		TQt3CairoPaintDevice( cairo_surface_t *, int x = 0, int y = 0, int width = -1, int height = -1, cairo_t *overridepainter = NULL );
44 44
 		~TQt3CairoPaintDevice();
45 45
 
46 46
 	protected:
@@ -75,6 +75,8 @@ class Q_EXPORT TQt3CairoPaintDevice : public TQPaintDevice		// picture class
75 75
 	private:
76 76
 		mutable int m_width;
77 77
 		mutable int m_height;
78
+		mutable int m_offsetX;
79
+		mutable int m_offsetY;
78 80
 
79 81
 		cairo_surface_t *m_surface;
80 82
 		cairo_surface_t *m_intermediateSurface;

+ 3
- 0
tests/compare View File

@@ -0,0 +1,3 @@
1
+#!/bin/bash
2
+
3
+composite -compose subtract tqt3.png stroke.png diff.png

+ 90
- 0
tests/test-painter.cpp View File

@@ -257,6 +257,96 @@ void runTests(TQPaintDevice* pd) {
257 257
 	cg.setColor(TQColorGroup::Foreground, TQColor(0,0,0));
258 258
 	tqApp->style().drawPrimitive(TQStyle::PE_ExclusiveIndicator, &p, TQRect(400, 400, 16, 16), cg, TQStyle::Style_Down);
259 259
 
260
+	// Tab bar tab tests
261
+	{
262
+		int currentPage;
263
+		int numPages=3;
264
+		int tabIndex=2;
265
+
266
+		int x = 0;
267
+		int y = 300;
268
+		int width = 50;
269
+		int height = 20;
270
+
271
+		for (currentPage=0;currentPage<numPages;currentPage++) {
272
+			TQRect boundingRect(0, 0, width, height);
273
+
274
+			TQStringList objectTypes;
275
+			objectTypes.append(TQTABBAR_OBJECT_NAME_STRING);
276
+			TQPalette objectPalette = tqApp->palette(objectTypes);
277
+	
278
+			TQStyleControlElementData ceData;
279
+			TQStyle::ControlElementFlags elementFlags;
280
+			ceData.widgetObjectTypes = objectTypes;
281
+			ceData.rect = boundingRect;
282
+	
283
+			TQTab tqt3Tab;
284
+			tqt3Tab.setIdentifier(currentPage);
285
+			TQStyleOption tabOpt(&tqt3Tab, (TQTab*)NULL);
286
+	
287
+			elementFlags = elementFlags | TQStyle::CEF_HasParentWidget;
288
+			ceData.parentWidgetData.widgetObjectTypes.append(TQTABBAR_OBJECT_NAME_STRING);
289
+	
290
+			int tab_overlap = tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap);
291
+			x = x + width + tab_overlap;
292
+	
293
+			boundingRect = TQRect(x, y, width+(tab_overlap*2), height);
294
+	
295
+			ceData.tabBarData.shape = TQTabBar::RoundedAbove;
296
+			ceData.tabBarData.tabCount = numPages;
297
+			ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = currentPage;
298
+
299
+			TQColorGroup cg = tqApp->palette().active();
300
+	
301
+			// Draw tab
302
+			tqApp->style().drawControl(TQStyle::CE_TabBarTab, &p, ceData, elementFlags, boundingRect, cg, ((tabIndex==currentPage)?TQStyle::Style_Selected:TQStyle::Style_Default), tabOpt);
303
+		}
304
+	}
305
+	{
306
+		int currentPage;
307
+		int numPages=3;
308
+		int tabIndex=2;
309
+
310
+		int x = (50*4);
311
+		int y = 325;
312
+		int width = 50;
313
+		int height = 20;
314
+
315
+		for (currentPage=(numPages-1);currentPage>=0;currentPage--) {
316
+			TQRect boundingRect(0, 0, width, height);
317
+
318
+			TQStringList objectTypes;
319
+			objectTypes.append(TQTABBAR_OBJECT_NAME_STRING);
320
+			TQPalette objectPalette = tqApp->palette(objectTypes);
321
+	
322
+			TQStyleControlElementData ceData;
323
+			TQStyle::ControlElementFlags elementFlags;
324
+			ceData.widgetObjectTypes = objectTypes;
325
+			ceData.rect = boundingRect;
326
+	
327
+			TQTab tqt3Tab;
328
+			tqt3Tab.setIdentifier(currentPage);
329
+			TQStyleOption tabOpt(&tqt3Tab, (TQTab*)NULL);
330
+	
331
+			elementFlags = elementFlags | TQStyle::CEF_HasParentWidget;
332
+			ceData.parentWidgetData.widgetObjectTypes.append(TQTABBAR_OBJECT_NAME_STRING);
333
+	
334
+			int tab_overlap = tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap);
335
+			x = x - width - tab_overlap;
336
+	
337
+			boundingRect = TQRect(x, y, width+(tab_overlap*2), height);
338
+	
339
+			ceData.tabBarData.shape = TQTabBar::RoundedAbove;
340
+			ceData.tabBarData.tabCount = numPages;
341
+			ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = currentPage;
342
+
343
+			TQColorGroup cg = tqApp->palette().active();
344
+	
345
+			// Draw tab
346
+			tqApp->style().drawControl(TQStyle::CE_TabBarTab, &p, ceData, elementFlags, boundingRect, cg, ((tabIndex==currentPage)?TQStyle::Style_Selected:TQStyle::Style_Default), tabOpt);
347
+		}
348
+	}
349
+
260 350
 	p.end();
261 351
 }
262 352
 

Loading…
Cancel
Save