* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
- * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
#include "gtkstyle.h"
#include "gtkwidget.h"
#include "gtkthemes.h"
-
+#include "gtkiconfactory.h"
#define LIGHTNESS_MULT 1.3
#define DARKNESS_MULT 0.7
GtkStateType state_type);
static GtkStyle *gtk_style_real_clone (GtkStyle *style);
static void gtk_style_real_init_from_rc (GtkStyle *style,
- GtkRcStyle *rc_style);
+ GtkRcStyle *rc_style);
+
+
+static GdkPixbuf *gtk_default_render_icon (GtkStyle *style,
+ const GtkIconSource *source,
+ GtkTextDirection direction,
+ GtkStateType state,
+ const gchar *size,
+ GtkWidget *widget,
+ const gchar *detail);
static void gtk_default_draw_hline (GtkStyle *style,
GdkWindow *window,
gint y,
gint width,
gint height);
-static void gtk_default_draw_oval (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height);
static void gtk_default_draw_string (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
gint y,
gint width,
gint height);
-static void gtk_default_draw_cross (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height);
-static void gtk_default_draw_ramp (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- GtkArrowType arrow_type,
- gint x,
- gint y,
- gint width,
- gint height);
static void gtk_default_draw_tab (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
gint width,
gint height,
GtkOrientation orientation);
+static void gtk_default_draw_expander (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gboolean is_open);
+static void gtk_default_draw_layout (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ PangoLayout *layout);
static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
object_type = g_type_register_static (G_TYPE_OBJECT,
"GtkStyle",
- &object_info);
+ &object_info, 0);
}
return object_type;
{
default_font = gdk_font_from_description (style->font_desc);
- if (!default_font)
- g_error ("Unable to load default font.");
+ if (!default_font)
+ default_font = gdk_font_load ("fixed");
+
+ if (!default_font)
+ g_error ("Unable to load \"fixed\" font!");
}
style->font = default_font;
klass->realize = gtk_style_real_realize;
klass->unrealize = gtk_style_real_unrealize;
klass->set_background = gtk_style_real_set_background;
-
+ klass->render_icon = gtk_default_render_icon;
+
klass->draw_hline = gtk_default_draw_hline;
klass->draw_vline = gtk_default_draw_vline;
klass->draw_shadow = gtk_default_draw_shadow;
klass->draw_polygon = gtk_default_draw_polygon;
klass->draw_arrow = gtk_default_draw_arrow;
klass->draw_diamond = gtk_default_draw_diamond;
- klass->draw_oval = gtk_default_draw_oval;
klass->draw_string = gtk_default_draw_string;
klass->draw_box = gtk_default_draw_box;
klass->draw_flat_box = gtk_default_draw_flat_box;
klass->draw_check = gtk_default_draw_check;
klass->draw_option = gtk_default_draw_option;
- klass->draw_cross = gtk_default_draw_cross;
- klass->draw_ramp = gtk_default_draw_ramp;
klass->draw_tab = gtk_default_draw_tab;
klass->draw_shadow_gap = gtk_default_draw_shadow_gap;
klass->draw_box_gap = gtk_default_draw_box_gap;
klass->draw_focus = gtk_default_draw_focus;
klass->draw_slider = gtk_default_draw_slider;
klass->draw_handle = gtk_default_draw_handle;
+ klass->draw_expander = gtk_default_draw_expander;
+ klass->draw_layout = gtk_default_draw_layout;
}
static void
{
GtkStyle *new_style;
- g_return_val_if_fail (style != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
new_style = gtk_style_copy (style);
GtkStyle *new_style = NULL;
GdkColormap *colormap;
- g_return_val_if_fail (style != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
g_return_val_if_fail (window != NULL, NULL);
colormap = gdk_window_get_colormap (window);
void
gtk_style_detach (GtkStyle *style)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
style->attach_count -= 1;
if (style->attach_count == 0)
gtk_style_realize (GtkStyle *style,
GdkColormap *colormap)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
style->colormap = colormap;
style->depth = gdk_colormap_get_visual (colormap)->depth;
GTK_STYLE_GET_CLASS (style)->realize (style);
}
+GtkIconSet*
+gtk_style_lookup_icon_set (GtkStyle *style,
+ const char *stock_id)
+{
+ GSList *iter;
+
+ g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+ g_return_val_if_fail (stock_id != NULL, NULL);
+
+ iter = style->icon_factories;
+ while (iter != NULL)
+ {
+ GtkIconSet *icon_set =
+ gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
+ stock_id);
+
+ if (icon_set)
+ return icon_set;
+
+ iter = g_slist_next (iter);
+ }
+
+ return gtk_icon_factory_lookup_default (stock_id);
+}
+
void
gtk_draw_hline (GtkStyle *style,
GdkWindow *window,
gint x2,
gint y)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
gint y2,
gint x)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
gint npoints,
gboolean fill)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
}
-void
-gtk_draw_oval (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_oval != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_oval (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
-
void
gtk_draw_string (GtkStyle *style,
GdkWindow *window,
gint y,
const gchar *string)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
}
-void
-gtk_draw_cross (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_cross != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_cross (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
-
-void
-gtk_draw_ramp (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GtkArrowType arrow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_ramp != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_ramp (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
-}
-
void
gtk_draw_tab (GtkStyle *style,
GdkWindow *window,
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
gint gap_x,
gint gap_width)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
gint gap_x,
gint gap_width)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
gint height,
GtkPositionType gap_side)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
gint height,
GtkOrientation orientation)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
gint height,
GtkOrientation orientation)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
}
+void
+gtk_draw_expander (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ gint x,
+ gint y,
+ gboolean is_open)
+{
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
+
+ GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
+ NULL, NULL, NULL,
+ x, y, is_open);
+}
+
+void
+gtk_draw_layout (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ gint x,
+ gint y,
+ PangoLayout *layout)
+{
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
+
+ GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type,
+ NULL, NULL, NULL,
+ x, y, layout);
+}
+
void
gtk_style_set_background (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
style->xthickness = rc_style->xthickness;
if (rc_style->ythickness >= 0)
style->ythickness = rc_style->ythickness;
+
+
+ if (rc_style->icon_factories)
+ {
+ GSList *iter;
+
+ style->icon_factories = g_slist_copy (rc_style->icon_factories);
+
+ iter = style->icon_factories;
+ while (iter != NULL)
+ {
+ g_object_ref (G_OBJECT (iter->data));
+
+ iter = g_slist_next (iter);
+ }
+ }
}
static void
gdk_window_set_background (window, &style->bg[state_type]);
}
+GdkPixbuf *
+gtk_style_render_icon (GtkStyle *style,
+ const GtkIconSource *source,
+ GtkTextDirection direction,
+ GtkStateType state,
+ const gchar *size,
+ GtkWidget *widget,
+ const gchar *detail)
+{
+ GdkPixbuf *pixbuf;
+
+ g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+ g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
+
+ pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
+ size, widget, detail);
+
+ g_return_val_if_fail (pixbuf != NULL, NULL);
+
+ return pixbuf;
+}
+
+/* Default functions */
void
gtk_style_apply_default_background (GtkStyle *style,
GdkWindow *window,
}
}
+static GdkPixbuf*
+scale_or_ref (GdkPixbuf *src,
+ gint width,
+ gint height)
+{
+ if (width == gdk_pixbuf_get_width (src) &&
+ height == gdk_pixbuf_get_height (src))
+ {
+ gdk_pixbuf_ref (src);
+ return src;
+ }
+ else
+ {
+ return gdk_pixbuf_scale_simple (src,
+ width, height,
+ GDK_INTERP_BILINEAR);
+ }
+}
+
+static GdkPixbuf *
+gtk_default_render_icon (GtkStyle *style,
+ const GtkIconSource *source,
+ GtkTextDirection direction,
+ GtkStateType state,
+ const gchar *size,
+ GtkWidget *widget,
+ const gchar *detail)
+{
+ gint width = 1;
+ gint height = 1;
+ GdkPixbuf *scaled;
+ GdkPixbuf *stated;
+
+ /* Oddly, style can be NULL in this function, because
+ * GtkIconSet can be used without a style and if so
+ * it uses this function.
+ */
+
+ g_return_val_if_fail (source->pixbuf != NULL, NULL);
+
+ if (!gtk_icon_size_lookup (size, &width, &height))
+ {
+ g_warning ("Bad icon size '%s' passed to render_icon", size);
+ return NULL;
+ }
+
+ /* If the size was wildcarded, then scale; otherwise, leave it
+ * alone.
+ */
+ if (source->any_size)
+ scaled = scale_or_ref (source->pixbuf, width, height);
+ else
+ scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (source->pixbuf)));
+
+ /* If the state was wildcarded, then generate a state. */
+ if (source->any_state)
+ {
+ if (state == GTK_STATE_INSENSITIVE)
+ {
+ stated = gdk_pixbuf_copy (scaled);
+
+ gdk_pixbuf_saturate_and_pixelate (scaled, stated,
+ 0.8, TRUE);
+
+ gdk_pixbuf_unref (scaled);
+ }
+ else if (state == GTK_STATE_PRELIGHT)
+ {
+ stated = gdk_pixbuf_copy (scaled);
+
+ gdk_pixbuf_saturate_and_pixelate (scaled, stated,
+ 1.2, FALSE);
+
+ gdk_pixbuf_unref (scaled);
+ }
+ else
+ {
+ stated = scaled;
+ }
+ }
+ else
+ stated = scaled;
+
+ return stated;
+}
+
static void
gtk_default_draw_hline (GtkStyle *style,
GdkWindow *window,
gint thickness_dark;
gint i;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
thickness_light = style->ythickness / 2;
gint thickness_dark;
gint i;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
thickness_light = style->xthickness / 2;
gint thickness_dark;
gint i;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if ((width == -1) && (height == -1))
gint yadjust;
gint i;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
g_return_if_fail (points != NULL);
gint half_height;
GdkPoint points[3];
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
switch (shadow_type)
gint half_width;
gint half_height;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if ((width == -1) && (height == -1))
}
}
-static void
-gtk_default_draw_oval (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (window != NULL);
-
- g_warning ("gtk_default_draw_oval(): FIXME, this function is currently unimplemented");
-}
-
static void
gtk_default_draw_string (GtkStyle *style,
GdkWindow *window,
gint y,
const gchar *string)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if (area)
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if (width == -1 && height == -1)
{
GdkGC *gc1;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if (width == -1 && height == -1)
detail, x, y, width, height);
}
-static void
-gtk_default_draw_cross (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (window != NULL);
-
- g_warning ("gtk_default_draw_cross(): FIXME, this function is currently unimplemented");
-}
-
-static void
-gtk_default_draw_ramp (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- GtkArrowType arrow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (window != NULL);
-
- g_warning ("gtk_default_draw_ramp(): FIXME, this function is currently unimplemented");
-}
-
static void
gtk_default_draw_tab (GtkStyle *style,
GdkWindow *window,
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
GdkGC *gc3 = NULL;
GdkGC *gc4 = NULL;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if (width == -1 && height == -1)
GdkGC *gc3 = NULL;
GdkGC *gc4 = NULL;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
gtk_style_apply_default_background (style, window,
GdkGC *gc3 = NULL;
GdkGC *gc4 = NULL;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
gtk_style_apply_default_background (style, window,
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if (width == -1 && height == -1)
gint height,
GtkOrientation orientation)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if (width == -1 && height == -1)
GdkRectangle dest;
gint intersect;
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
if (width == -1 && height == -1)
gdk_gc_set_clip_rectangle (dark_gc, NULL);
}
+static void
+gtk_default_draw_expander (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gboolean is_open)
+{
+ /* FIXME replace macro with a style property */
+#define PM_SIZE 8
+
+ GdkPoint points[3];
+
+ if (area)
+ {
+ gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
+ gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
+ }
+
+ if (is_open)
+ {
+ points[0].x = x;
+ points[0].y = y + (PM_SIZE + 2) / 6;
+ points[1].x = points[0].x + 1 * (PM_SIZE + 2);
+ points[1].y = points[0].y;
+ points[2].x = (points[0].x + 1 * (PM_SIZE + 2) / 2);
+ points[2].y = y + 2 * (PM_SIZE + 2) / 3;
+ }
+ else
+ {
+ points[0].x = x + 1 * ((PM_SIZE + 2) / 6 + 2);
+ points[0].y = y - 1;
+ points[1].x = points[0].x;
+ points[1].y = points[0].y + (PM_SIZE + 2);
+ points[2].x = (points[0].x + 1 * (2 * (PM_SIZE + 2) / 3 - 1));
+ points[2].y = points[0].y + (PM_SIZE + 2) / 2;
+ }
+
+ gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
+ TRUE, points, 3);
+ gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
+ FALSE, points, 3);
+
+
+ if (area)
+ {
+ gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
+ gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
+ }
+
+#undef PM_SIZE
+}
+
+static void
+gtk_default_draw_layout (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ PangoLayout *layout)
+{
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (window != NULL);
+
+ if (area)
+ {
+ gdk_gc_set_clip_rectangle (style->white_gc, area);
+ gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
+ }
+
+ /* FIXME this is frickin' ugly with any kind of attributes set on the
+ * text being rendered
+ */
+ if (state_type == GTK_STATE_INSENSITIVE)
+ gdk_draw_layout (window, style->white_gc, x + 1, y + 1, layout);
+
+ gdk_draw_layout (window, style->fg_gc[state_type], x, y, layout);
+
+ if (area)
+ {
+ gdk_gc_set_clip_rectangle (style->white_gc, NULL);
+ gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
+ }
+}
+
static void
gtk_style_shade (GdkColor *a,
GdkColor *b,
gint x2,
gint y)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
gint y2,
gint x)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
gint npoints,
gboolean fill)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
}
-void
-gtk_paint_oval (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_oval != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_oval (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
-}
-
void
gtk_paint_string (GtkStyle *style,
GdkWindow *window,
gint y,
const gchar *string)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
}
-void
-gtk_paint_cross (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_cross != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_cross (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
-}
-
-void
-gtk_paint_ramp (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- GtkArrowType arrow_type,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (style != NULL);
- g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_ramp != NULL);
-
- GTK_STYLE_GET_CLASS (style)->draw_ramp (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
-}
-
void
gtk_paint_tab (GtkStyle *style,
GdkWindow *window,
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
gint gap_x,
gint gap_width)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
gint gap_x,
gint gap_width)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
gint height,
GtkPositionType gap_side)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
gint width,
gint height)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget, detail, x, y, width, height);
gint height,
GtkOrientation orientation)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
gint height,
GtkOrientation orientation)
{
- g_return_if_fail (style != NULL);
+ g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
}
+
+void
+gtk_paint_expander (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gboolean is_open)
+{
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
+
+ GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
+ widget, detail, x, y, is_open);
+}
+
+void
+gtk_paint_layout (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ PangoLayout *layout)
+{
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
+
+ GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, area,
+ widget, detail, x, y, layout);
+}
+
+