[gtk+] Porting MS Windows theme engine to cairo - Part 1: stippling
- From: Fridrich Strba <strba src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Porting MS Windows theme engine to cairo - Part 1: stippling
- Date: Tue, 31 Aug 2010 16:06:46 +0000 (UTC)
commit 5032cdf88f92b9685e624c0e923b3c4533708a2f
Author: Fridrich Å trba <fridrich strba bluewin ch>
Date: Tue Aug 31 18:02:31 2010 +0200
Porting MS Windows theme engine to cairo - Part 1: stippling
modules/engines/ms-windows/msw_style.c | 199 ++++++++++++++++++++------------
1 files changed, 127 insertions(+), 72 deletions(-)
---
diff --git a/modules/engines/ms-windows/msw_style.c b/modules/engines/ms-windows/msw_style.c
index 1105fa1..8229ad0 100755
--- a/modules/engines/ms-windows/msw_style.c
+++ b/modules/engines/ms-windows/msw_style.c
@@ -82,81 +82,137 @@ typedef enum
#define PART_SIZE 13
-static const gchar check_aa_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+static const unsigned char check_aa_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar check_base_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x07, 0xfc, 0x07, 0xfc, 0x07,
- 0xfc, 0x07, 0xfc,
- 0x07, 0xfc, 0x07, 0xfc, 0x07, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00
+static const unsigned char check_base_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar check_black_bits[] = {
- 0x00, 0x00, 0xfe, 0x0f, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,
- 0x02, 0x00, 0x02,
- 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00
+static const unsigned char check_black_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar check_dark_bits[] = {
- 0xff, 0x1f, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
- 0x01, 0x00, 0x01,
- 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00
+static const unsigned char check_dark_bits[] = {
+ 0xff, 0x1f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00
};
-static const gchar check_light_bits[] = {
- 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10,
- 0x00, 0x10, 0x00,
- 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0xfe, 0x1f
+static const unsigned char check_light_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0xfe, 0x1f, 0x00, 0x00
};
-static const gchar check_mid_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08,
- 0x00, 0x08, 0x00,
- 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0xfc, 0x0f, 0x00, 0x00
+static const unsigned char check_mid_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar check_text_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x88, 0x03,
- 0xd8, 0x01, 0xf8,
- 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+static const unsigned char check_text_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x03, 0x00, 0x00, 0x88, 0x03, 0x00, 0x00,
+ 0xd8, 0x01, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
+ 0x70, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar check_inconsistent_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf0, 0x03, 0xf0,
- 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+static const unsigned char check_inconsistent_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar radio_base_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0xf8, 0x03, 0xfc, 0x07, 0xfc, 0x07,
- 0xfc, 0x07, 0xfc,
- 0x07, 0xfc, 0x07, 0xf8, 0x03, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00
+static const unsigned char radio_base_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0x01, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
+ 0xfc, 0x07, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00,
+ 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar radio_black_bits[] = {
- 0x00, 0x00, 0xf0, 0x01, 0x0c, 0x02, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00,
- 0x02, 0x00, 0x02,
- 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+static const unsigned char radio_black_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
+ 0x0c, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar radio_dark_bits[] = {
- 0xf0, 0x01, 0x0c, 0x06, 0x02, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00,
- 0x01, 0x00, 0x01,
- 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
+static const unsigned char radio_dark_bits[] = {
+ 0xf0, 0x01, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar radio_light_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10,
- 0x00, 0x10, 0x00,
- 0x10, 0x00, 0x10, 0x00, 0x08, 0x00, 0x08, 0x0c, 0x06, 0xf0, 0x01
+static const unsigned char radio_light_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00,
+ 0xf0, 0x01, 0x00, 0x00
};
-static const gchar radio_mid_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08,
- 0x00, 0x08, 0x00,
- 0x08, 0x00, 0x08, 0x00, 0x04, 0x0c, 0x06, 0xf0, 0x01, 0x00, 0x00
+static const unsigned char radio_mid_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x0c, 0x06, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static const gchar radio_text_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xf0, 0x01,
- 0xf0, 0x01, 0xf0,
- 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+static const unsigned char radio_text_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
+ 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
+ 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
static struct
{
- const gchar *bits;
- GdkBitmap *bmap;
+ const unsigned char *bits;
+ cairo_surface_t *bmap;
} parts[] = {
{ check_aa_bits, NULL },
{ check_base_bits, NULL },
@@ -915,28 +971,27 @@ combo_box_draw_arrow (GtkStyle *style,
static void
draw_part (GdkDrawable *drawable,
- GdkGC *gc, GdkRectangle *area, gint x, gint y, Part part)
+ GdkColor *gc, GdkRectangle *area, gint x, gint y, Part part)
{
+ cairo_t *cr = gdk_cairo_create (drawable);
+
if (area)
- gdk_gc_set_clip_rectangle (gc, area);
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
if (!parts[part].bmap)
{
- parts[part].bmap = gdk_bitmap_create_from_data (drawable,
- parts[part].bits,
- PART_SIZE, PART_SIZE);
+ parts[part].bmap = cairo_image_surface_create_for_data ((unsigned char *)parts[part].bits,
+ CAIRO_FORMAT_A1,
+ PART_SIZE, PART_SIZE, 4);
}
- gdk_gc_set_ts_origin (gc, x, y);
- gdk_gc_set_stipple (gc, parts[part].bmap);
- gdk_gc_set_fill (gc, GDK_STIPPLED);
+ gdk_cairo_set_source_color (cr, gc);
+ cairo_mask_surface (cr, parts[part].bmap, x, y);
- gdk_draw_rectangle (drawable, gc, TRUE, x, y, PART_SIZE, PART_SIZE);
-
- gdk_gc_set_fill (gc, GDK_SOLID);
-
- if (area)
- gdk_gc_set_clip_rectangle (gc, NULL);
+ cairo_destroy(cr);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]