~ubuntu-branches/ubuntu/precise/gtkmm3.0/precise

« back to all changes in this revision

Viewing changes to gtk/src/stylecontext.hg

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-17 00:12:44 UTC
  • Revision ID: james.westby@ubuntu.com-20110617001244-9hl5an15hiaaahi6
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2010 The gtkmm Development Team
 
2
 *
 
3
 * This library is free software; you can redistribute it and/or
 
4
 * modify it under the terms of the GNU Lesser General Public
 
5
 * License as published by the Free Software Foundation; either
 
6
 * version 2.1 of the License, or (at your option) any later version.
 
7
 *
 
8
 * This library is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public
 
14
 * License along with this library; if not, write to the Free
 
15
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
16
 */
 
17
 
 
18
_DEFS(gtkmm,gtk)
 
19
_PINCLUDE(glibmm/private/object_p.h)
 
20
_PINCLUDE(gtk/gtk.h)
 
21
 
 
22
#include <gtkmm/styleprovider.h>
 
23
#include <gtkmm/border.h>
 
24
#include <gtkmm/enums.h>
 
25
#include <gdkmm/window.h>
 
26
#include <gdkmm/screen.h>
 
27
 
 
28
#include <gtkmm/enums.h>
 
29
#include <gtkmm/iconsource.h>
 
30
#include <gtkmm/iconset.h>
 
31
#include <gtkmm/widgetpath.h>
 
32
#include <gtkmmconfig.h>
 
33
 
 
34
 
 
35
namespace Gtk
 
36
{
 
37
 
 
38
class IconSet;
 
39
 
 
40
//TODO: Add (and translate to C++) the code examples from the C documentation.
 
41
//TODO: Find a way to show the headings as headings in this doxygen comment.
 
42
/** This object stores styling information affecting a widget defined by WidgetPath.
 
43
 *
 
44
 * In order to construct the final style information, StyleContext
 
45
 * queries information from all attached StyleProviders. Style providers
 
46
 * can be either attached explicitly to the context through
 
47
 * add_provider(), or to the screen through
 
48
 * add_provider_for_screen(). The resulting style is a
 
49
 * combination of all providers' information in priority order.
 
50
 *
 
51
 * For GTK+ widgets, any StyleContext returned by
 
52
 * Widget::get_style_context() will already have a WidgetPath, a
 
53
 * Gdk::Screen and RTL/LTR information set, The style context will be also
 
54
 * updated automatically if any of these settings change on the widget.
 
55
 *
 
56
 * If you are using the theming layer standalone, you will need to set a
 
57
 * widget path and a screen yourself to the created style context through
 
58
 * set_path() and set_screen(), as well
 
59
 * as updating the context yourself using invalidate()
 
60
 * whenever any of the conditions change, such as a change in the
 
61
 * Settings::property_gtk_theme_name() setting or a hierarchy change in the rendered
 
62
 * widget.
 
63
 *
 
64
 * Transition animations
 
65
 * 
 
66
 * StyleContext has built-in support for state change transitions.
 
67
 * Note that these animations respect the Settings::property_gtk_enable_animations()
 
68
 * setting.
 
69
 *
 
70
 * For simple widgets where state changes affect the whole widget area,
 
71
 * calling notify_state_change() with a no region
 
72
 * is sufficient to trigger the transition animation. And GTK+ already
 
73
 * does that when Widget::set_state() or Widget::set_state_flags()
 
74
 * are called.
 
75
 * 
 
76
 * If a widget needs to declare several animatable regions (i.e. not
 
77
 * affecting the whole widget area), its Widget::signal_draw() signal handler
 
78
 * needs to wrap the render operations for the different regions with
 
79
 * calls to push_animatable_region() and
 
80
 * pop_animatable_region(). These methods take an
 
81
 * identifier for the region which must be unique within the style context.
 
82
 * For simple widgets with a fixed set of animatable regions, using an
 
83
 * enumeration works well.
 
84
 *
 
85
 * For complex widgets with an arbitrary number of animatable regions, it
 
86
 * is up to the implementation to come up with a way to uniquely identify
 
87
 * each animatable region. Using pointers to internal objects is one way
 
88
 * to achieve this.
 
89
 *
 
90
 * The widget also needs to notify the style context about a state change
 
91
 * for a given animatable region so the animation is triggered. 
 
92
 * notify_state_change() can take no region IDs, meaning that the whole widget 
 
93
 * area will be updated by the animation.
 
94
 *
 
95
 * @newin{3,0}
 
96
 */
 
97
class StyleContext : public Glib::Object
 
98
{
 
99
  _CLASS_GOBJECT(StyleContext, GtkStyleContext, GTK_STYLE_CONTEXT, Glib::Object, GObject)
 
100
protected:
 
101
  _CTOR_DEFAULT()
 
102
 
 
103
public:
 
104
  _WRAP_CREATE()
 
105
  _IGNORE(gtk_style_context_new)
 
106
  
 
107
  _WRAP_METHOD(static void add_provider_for_screen(const Glib::RefPtr<Gdk::Screen>& screen, const Glib::RefPtr<StyleProvider>& provider, guint priority), gtk_style_context_add_provider_for_screen)
 
108
  _WRAP_METHOD(static void remove_provider_for_screen(const Glib::RefPtr<Gdk::Screen>& screen, const Glib::RefPtr<StyleProvider>& provider), gtk_style_context_remove_provider_for_screen)
 
109
 
 
110
  _WRAP_METHOD(void add_provider(const Glib::RefPtr<StyleProvider>& provider, guint priority), gtk_style_context_add_provider)
 
111
 
 
112
  _WRAP_METHOD(void remove_provider(const Glib::RefPtr<StyleProvider>& provider), gtk_style_context_remove_provider)
 
113
 
 
114
  _WRAP_METHOD(void context_save(), gtk_style_context_save)
 
115
  _WRAP_METHOD(void context_restore(), gtk_style_context_restore)
 
116
 
 
117
/* TODO:
 
118
  _WRAP_METHOD(void get_property (
 
119
                                     const Glib::ustring& property,
 
120
                                     StateFlags    state,
 
121
                                     GValue          *value), gtk_style_context_get_property)
 
122
  _WRAP_METHOD(void get_valist   (
 
123
                                     StateFlags    state,
 
124
                                     va_list          args), gtk_style_context_get_valist)
 
125
  _WRAP_METHOD(void get          (
 
126
                                     StateFlags    state,
 
127
                                     ...) G_GNUC_NULL_TERMINATED;
 
128
*/
 
129
 
 
130
  _WRAP_METHOD(void set_state(StateFlags flags), gtk_style_context_set_state)
 
131
  _WRAP_METHOD(StateFlags get_state() const, gtk_style_context_get_state)
 
132
 
 
133
  _WRAP_METHOD(bool state_is_running(StateType state, gdouble* progress), gtk_style_context_state_is_running)
 
134
 
 
135
  _WRAP_METHOD(void set_path(const WidgetPath& path), gtk_style_context_set_path)
 
136
  
 
137
#m4 _CONVERSION(`const GtkWidgetPath*',`WidgetPath',`WidgetPath(const_cast<GtkWidgetPath*>($3), true)')
 
138
  _WRAP_METHOD(WidgetPath get_path() const, gtk_style_context_get_path)
 
139
 
 
140
  //TODO: _WRAP_METHOD(GList * list_classes (), gtk_style_context_list_classes)
 
141
 
 
142
  _WRAP_METHOD(void add_class(const Glib::ustring& class_name), gtk_style_context_add_class)
 
143
  _WRAP_METHOD(void remove_class(const Glib::ustring& class_name), gtk_style_context_remove_class)
 
144
  _WRAP_METHOD(bool has_class(const Glib::ustring& class_name), gtk_style_context_has_class)
 
145
 
 
146
  _WRAP_METHOD(GList* list_regions (), gtk_style_context_list_regions)
 
147
 
 
148
  _WRAP_METHOD(void add_region(const Glib::ustring& region_name, RegionFlags flags), gtk_style_context_add_region)
 
149
  _WRAP_METHOD(void remove_region(const Glib::ustring& region_name), gtk_style_context_remove_region)
 
150
  _WRAP_METHOD(bool has_region(const Glib::ustring& region_name, RegionFlags& flags_return), gtk_style_context_has_region)
 
151
/*
 
152
  _WRAP_METHOD(void get_style_property (
 
153
                                           const Glib::ustring& property_name,
 
154
                                           GValue          *value), gtk_style_context_get_style_property)
 
155
  _WRAP_METHOD(void get_style_valist   (
 
156
                                           va_list          args), gtk_style_context_get_style_valis)
 
157
  _WRAP_METHOD(void get_style          (
 
158
                                           ...), gtk_style_context_get_style)
 
159
*/
 
160
 
 
161
  _WRAP_METHOD(Glib::RefPtr<IconSet> lookup_icon_set(const Glib::ustring& stock_id), gtk_style_context_lookup_icon_set, refreturn)
 
162
 
 
163
/* TODO: Move this to Iconset?
 
164
  _WRAP_METHOD(GdkPixbuf  * gtk_icon_set_render_icon_pixbuf   (const Glib::RefPtr<IconSet>& con_set,
 
165
                                                GtkStyleContext *context,
 
166
                                                GtkIconSize      size), gtk_icon_set_render_icon_pixbuf)
 
167
*/
 
168
 
 
169
  _WRAP_METHOD(void set_screen(const Glib::RefPtr<Gdk::Screen>& screen), gtk_style_context_set_screen)
 
170
                                          
 
171
  _WRAP_METHOD(Glib::RefPtr<Gdk::Screen> get_screen(), gtk_style_context_get_screen, refreturn)
 
172
  _WRAP_METHOD(Glib::RefPtr<const Gdk::Screen> get_screen() const, gtk_style_context_get_screen, refreturn, constversion)
 
173
 
 
174
  _WRAP_METHOD(void set_direction(TextDirection direction), gtk_style_context_set_direction)
 
175
  _WRAP_METHOD(TextDirection get_direction() const, gtk_style_context_get_direction)
 
176
 
 
177
  _WRAP_METHOD(void set_junction_sides(JunctionSides sides), gtk_style_context_set_junction_sides)
 
178
  _WRAP_METHOD(JunctionSides get_junction_sides() const, gtk_style_context_get_junction_sides)
 
179
 
 
180
  _WRAP_METHOD(bool lookup_color(const Glib::ustring& color_name, Gdk::RGBA& color), gtk_style_context_lookup_color)
 
181
 
 
182
  //TODO: region_id can be NULL.
 
183
  _WRAP_METHOD(void notify_state_change(const Glib::RefPtr<Gdk::Window>& window, gpointer region_id, StateType state, bool state_value), gtk_style_context_notify_state_change)
 
184
  
 
185
  _WRAP_METHOD(void push_animatable_region(gpointer region_id), gtk_style_context_push_animatable_region)
 
186
  _WRAP_METHOD(void pop_animatable_region(), gtk_style_context_pop_animatable_region)
 
187
 
 
188
  //TODO: Documentation
 
189
  Gdk::RGBA get_color(StateFlags state = (StateFlags)0) const;
 
190
  _IGNORE(gtk_style_context_get_color)
 
191
  
 
192
  Gdk::RGBA get_background_color(StateFlags state = (StateFlags)0) const;
 
193
  _IGNORE(gtk_style_context_get_background_color)
 
194
  
 
195
  Gdk::RGBA  get_border_color(StateFlags state = (StateFlags)0) const;
 
196
  _IGNORE(gtk_style_context_get_border_color)
 
197
 
 
198
  Border get_border(StateFlags state = (StateFlags)0) const;
 
199
  _IGNORE(gtk_style_context_get_border)
 
200
  
 
201
  Border get_padding(StateFlags state = (StateFlags)0) const;
 
202
  _IGNORE(gtk_style_context_get_padding)
 
203
 
 
204
  Border get_margin (StateFlags state = (StateFlags)0) const;
 
205
  _IGNORE(gtk_style_context_get_margin)
 
206
 
 
207
  _WRAP_METHOD(void invalidate(), gtk_style_context_invalidate)
 
208
  //TODO: _WRAP_METHOD(void reset_widgets(const Glib::RefPtr<Gdk::Screen>& screen), gtk_style_context_reset_widgets)
 
209
 
 
210
  _WRAP_METHOD(void set_background(const Glib::RefPtr<Gdk::Window>& window), gtk_style_context_set_background)
 
211
  
 
212
  _WRAP_METHOD(void render_check(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_check)
 
213
  _WRAP_METHOD(void render_option(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_option)
 
214
  _WRAP_METHOD(void render_arrow(const Cairo::RefPtr<Cairo::Context>& cr, double angle, double x, double y, double size), gtk_render_arrow)
 
215
  _WRAP_METHOD(void render_background(const Cairo::RefPtr<Cairo::Context>& cr, double x,  double y, double width, double height), gtk_render_background)
 
216
  _WRAP_METHOD(void render_frame(const Cairo::RefPtr<Cairo::Context>& cr, double x,  double y, double width, double height), gtk_render_frame)
 
217
  _WRAP_METHOD(void render_expander(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_expander)
 
218
  _WRAP_METHOD(void render_focus(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_focus)
 
219
  _WRAP_METHOD(void render_layout(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y,  PangoLayout     *layout), gtk_render_layout)
 
220
  _WRAP_METHOD(void render_line(const Cairo::RefPtr<Cairo::Context>& cr, double x0, double y0,  double x1, double y1), gtk_render_line)
 
221
  _WRAP_METHOD(void render_slider(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height,  Orientation orientation), gtk_render_slider)
 
222
  _WRAP_METHOD(void render_frame_gap(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height,  PositionType  gap_side, double xy0_gap, double xy1_gap), gtk_render_frame_gap)
 
223
  _WRAP_METHOD(void render_extension(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height,  PositionType gap_side), gtk_render_extension)
 
224
  _WRAP_METHOD(void render_handle(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_handle)
 
225
  _WRAP_METHOD(void render_activity(const Cairo::RefPtr<Cairo::Context>& cr,  double x,  double y, double width, double height), gtk_render_activity)
 
226
  _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> render_icon_pixbuf(const IconSource& source, IconSize size), gtk_render_icon_pixbuf)
 
227
                                    
 
228
  
 
229
  _WRAP_SIGNAL(void changed(), "changed")
 
230
 
 
231
  _WRAP_PROPERTY("screen", Glib::RefPtr<Gdk::Screen>)
 
232
  _WRAP_PROPERTY("direction", TextDirection)
 
233
};
 
234
 
 
235
} // namespace Gtk