| 1 |
/* GDK - The GIMP Drawing Kit |
| 2 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 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 |
| 16 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 17 |
* Boston, MA 02111-1307, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 22 |
* file for a list of people on the GTK+ Team. |
| 23 |
*/ |
| 24 |
|
| 25 |
/* |
| 26 |
* GTK+ DirectFB backend |
| 27 |
* Copyright (C) 2001-2002 convergence integrated media GmbH |
| 28 |
* Copyright (C) 2002-2004 convergence GmbH |
| 29 |
* Written by Denis Oliver Kropp <[email protected]> and |
| 30 |
* Sven Neumann <[email protected]> |
| 31 |
*/ |
| 32 |
|
| 33 |
#undef GDK_DISABLE_DEPRECATED |
| 34 |
|
| 35 |
#include "config.h" |
| 36 |
#include "gdk.h" |
| 37 |
|
| 38 |
#include <string.h> |
| 39 |
|
| 40 |
#include "gdkdirectfb.h" |
| 41 |
#include "gdkprivate-directfb.h" |
| 42 |
|
| 43 |
#include "gdkgc.h" |
| 44 |
#include "gdkfont.h" |
| 45 |
#include "gdkpixmap.h" |
| 46 |
#include "gdkregion-generic.h" |
| 47 |
|
| 48 |
#include "gdkalias.h" |
| 49 |
|
| 50 |
static void gdk_directfb_gc_get_values (GdkGC *gc, |
| 51 |
GdkGCValues *values); |
| 52 |
static void gdk_directfb_gc_set_values (GdkGC *gc, |
| 53 |
GdkGCValues *values, |
| 54 |
GdkGCValuesMask values_mask); |
| 55 |
static void gdk_directfb_gc_set_dashes (GdkGC *gc, |
| 56 |
gint dash_offset, |
| 57 |
gint8 dash_list[], |
| 58 |
gint n); |
| 59 |
|
| 60 |
|
| 61 |
static void gdk_gc_directfb_finalize (GObject *object); |
| 62 |
|
| 63 |
G_DEFINE_TYPE (GdkGCDirectFB, _gdk_gc_directfb, GDK_TYPE_GC) |
| 64 |
|
| 65 |
static void |
| 66 |
_gdk_gc_directfb_init (GdkGCDirectFB *directfb_gc) |
| 67 |
{ |
| 68 |
} |
| 69 |
|
| 70 |
static void |
| 71 |
_gdk_gc_directfb_class_init (GdkGCDirectFBClass *klass) |
| 72 |
{ |
| 73 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 74 |
GdkGCClass *gc_class = GDK_GC_CLASS (klass); |
| 75 |
|
| 76 |
object_class->finalize = gdk_gc_directfb_finalize; |
| 77 |
|
| 78 |
gc_class->get_values = gdk_directfb_gc_get_values; |
| 79 |
gc_class->set_values = gdk_directfb_gc_set_values; |
| 80 |
gc_class->set_dashes = gdk_directfb_gc_set_dashes; |
| 81 |
} |
| 82 |
|
| 83 |
static void |
| 84 |
gdk_gc_directfb_finalize (GObject *object) |
| 85 |
{ |
| 86 |
GdkGCDirectFB *directfb_gc = GDK_GC_DIRECTFB (object); |
| 87 |
|
| 88 |
if (directfb_gc->clip_region.numRects) |
| 89 |
temp_region_deinit (&directfb_gc->clip_region); |
| 90 |
if (directfb_gc->values.clip_mask) |
| 91 |
g_object_unref (directfb_gc->values.clip_mask); |
| 92 |
if (directfb_gc->values.stipple) |
| 93 |
g_object_unref (directfb_gc->values.stipple); |
| 94 |
if (directfb_gc->values.tile) |
| 95 |
g_object_unref (directfb_gc->values.tile); |
| 96 |
|
| 97 |
G_OBJECT_CLASS (_gdk_gc_directfb_parent_class)->finalize (object); |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
GdkGC * |
| 102 |
_gdk_directfb_gc_new (GdkDrawable *drawable, |
| 103 |
GdkGCValues *values, |
| 104 |
GdkGCValuesMask values_mask) |
| 105 |
{ |
| 106 |
GdkGC *gc; |
| 107 |
GdkGCDirectFB *private; |
| 108 |
|
| 109 |
/* NOTICE that the drawable here has to be the impl drawable, not the |
| 110 |
publicly visible drawable. */ |
| 111 |
g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_DIRECTFB (drawable), NULL); |
| 112 |
|
| 113 |
gc = GDK_GC (g_object_new (_gdk_gc_directfb_get_type (), NULL)); |
| 114 |
|
| 115 |
_gdk_gc_init (gc, drawable, values, values_mask); |
| 116 |
|
| 117 |
private = GDK_GC_DIRECTFB (gc); |
| 118 |
#if 0 |
| 119 |
private->values.background.pixel = 0; |
| 120 |
private->values.background.red = 0; |
| 121 |
private->values.background.green = 0; |
| 122 |
private->values.background.blue = 0; |
| 123 |
|
| 124 |
private->values.foreground.pixel = 0; |
| 125 |
private->values.foreground.red = 0; |
| 126 |
private->values.foreground.green = 0; |
| 127 |
private->values.foreground.blue = 0; |
| 128 |
#endif |
| 129 |
|
| 130 |
private->values.cap_style = GDK_CAP_BUTT; |
| 131 |
|
| 132 |
gdk_directfb_gc_set_values (gc, values, values_mask); |
| 133 |
|
| 134 |
return gc; |
| 135 |
} |
| 136 |
|
| 137 |
static void |
| 138 |
gdk_directfb_gc_get_values (GdkGC *gc, |
| 139 |
GdkGCValues *values) |
| 140 |
{ |
| 141 |
*values = GDK_GC_DIRECTFB (gc)->values; |
| 142 |
} |
| 143 |
|
| 144 |
#if 0 |
| 145 |
void |
| 146 |
_gdk_windowing_gc_get_foreground (GdkGC *gc, |
| 147 |
GdkColor *color) |
| 148 |
{ |
| 149 |
GdkGCDirectFB *private = GDK_GC_DIRECTFB (gc); |
| 150 |
*color =private->values.foreground; |
| 151 |
} |
| 152 |
#endif |
| 153 |
|
| 154 |
static void |
| 155 |
gdk_directfb_gc_set_values (GdkGC *gc, |
| 156 |
GdkGCValues *values, |
| 157 |
GdkGCValuesMask values_mask) |
| 158 |
{ |
| 159 |
GdkGCDirectFB *private = GDK_GC_DIRECTFB (gc); |
| 160 |
|
| 161 |
if (values_mask & GDK_GC_FOREGROUND) |
| 162 |
{ |
| 163 |
private->values.foreground = values->foreground; |
| 164 |
private->values_mask |= GDK_GC_FOREGROUND; |
| 165 |
} |
| 166 |
|
| 167 |
if (values_mask & GDK_GC_BACKGROUND) |
| 168 |
{ |
| 169 |
private->values.background = values->background; |
| 170 |
private->values_mask |= GDK_GC_BACKGROUND; |
| 171 |
} |
| 172 |
|
| 173 |
if (values_mask & GDK_GC_FONT) |
| 174 |
{ |
| 175 |
GdkFont *oldf = private->values.font; |
| 176 |
|
| 177 |
private->values.font = gdk_font_ref (values->font); |
| 178 |
private->values_mask |= GDK_GC_FONT; |
| 179 |
|
| 180 |
if (oldf) |
| 181 |
gdk_font_unref (oldf); |
| 182 |
} |
| 183 |
|
| 184 |
if (values_mask & GDK_GC_FUNCTION) |
| 185 |
{ |
| 186 |
private->values.function = values->function; |
| 187 |
private->values_mask |= GDK_GC_FUNCTION; |
| 188 |
} |
| 189 |
|
| 190 |
if (values_mask & GDK_GC_FILL) |
| 191 |
{ |
| 192 |
private->values.fill = values->fill; |
| 193 |
private->values_mask |= GDK_GC_FILL; |
| 194 |
} |
| 195 |
|
| 196 |
if (values_mask & GDK_GC_TILE) |
| 197 |
{ |
| 198 |
GdkPixmap *oldpm = private->values.tile; |
| 199 |
|
| 200 |
if (values->tile) |
| 201 |
g_assert (GDK_PIXMAP_OBJECT (values->tile)->depth > 1); |
| 202 |
|
| 203 |
private->values.tile = values->tile ? g_object_ref (values->tile) : NULL; |
| 204 |
private->values_mask |= GDK_GC_TILE; |
| 205 |
|
| 206 |
if (oldpm) |
| 207 |
g_object_unref (oldpm); |
| 208 |
} |
| 209 |
|
| 210 |
if (values_mask & GDK_GC_STIPPLE) |
| 211 |
{ |
| 212 |
GdkPixmap *oldpm = private->values.stipple; |
| 213 |
|
| 214 |
if (values->stipple) |
| 215 |
g_assert (GDK_PIXMAP_OBJECT (values->stipple)->depth == 1); |
| 216 |
|
| 217 |
private->values.stipple = (values->stipple ? |
| 218 |
g_object_ref (values->stipple) : NULL); |
| 219 |
private->values_mask |= GDK_GC_STIPPLE; |
| 220 |
|
| 221 |
if (oldpm) |
| 222 |
g_object_unref (oldpm); |
| 223 |
} |
| 224 |
|
| 225 |
if (values_mask & GDK_GC_CLIP_MASK) |
| 226 |
{ |
| 227 |
GdkPixmap *oldpm = private->values.clip_mask; |
| 228 |
|
| 229 |
private->values.clip_mask = (values->clip_mask ? |
| 230 |
g_object_ref (values->clip_mask) : NULL); |
| 231 |
private->values_mask |= GDK_GC_CLIP_MASK; |
| 232 |
|
| 233 |
if (oldpm) |
| 234 |
g_object_unref (oldpm); |
| 235 |
|
| 236 |
temp_region_reset (&private->clip_region); |
| 237 |
} |
| 238 |
|
| 239 |
if (values_mask & GDK_GC_SUBWINDOW) |
| 240 |
{ |
| 241 |
private->values.subwindow_mode = values->subwindow_mode; |
| 242 |
private->values_mask |= GDK_GC_SUBWINDOW; |
| 243 |
} |
| 244 |
|
| 245 |
if (values_mask & GDK_GC_TS_X_ORIGIN) |
| 246 |
{ |
| 247 |
private->values.ts_x_origin = values->ts_x_origin; |
| 248 |
private->values_mask |= GDK_GC_TS_X_ORIGIN; |
| 249 |
} |
| 250 |
|
| 251 |
if (values_mask & GDK_GC_TS_Y_ORIGIN) |
| 252 |
{ |
| 253 |
private->values.ts_y_origin = values->ts_y_origin; |
| 254 |
private->values_mask |= GDK_GC_TS_Y_ORIGIN; |
| 255 |
} |
| 256 |
|
| 257 |
if (values_mask & GDK_GC_CLIP_X_ORIGIN) |
| 258 |
{ |
| 259 |
private->values.clip_x_origin = GDK_GC (gc)->clip_x_origin = values->clip_x_origin; |
| 260 |
private->values_mask |= GDK_GC_CLIP_X_ORIGIN; |
| 261 |
} |
| 262 |
|
| 263 |
if (values_mask & GDK_GC_CLIP_Y_ORIGIN) |
| 264 |
{ |
| 265 |
private->values.clip_y_origin = GDK_GC (gc)->clip_y_origin = values->clip_y_origin; |
| 266 |
private->values_mask |= GDK_GC_CLIP_Y_ORIGIN; |
| 267 |
} |
| 268 |
|
| 269 |
if (values_mask & GDK_GC_EXPOSURES) |
| 270 |
{ |
| 271 |
private->values.graphics_exposures = values->graphics_exposures; |
| 272 |
private->values_mask |= GDK_GC_EXPOSURES; |
| 273 |
} |
| 274 |
|
| 275 |
if (values_mask & GDK_GC_LINE_WIDTH) |
| 276 |
{ |
| 277 |
private->values.line_width = values->line_width; |
| 278 |
private->values_mask |= GDK_GC_LINE_WIDTH; |
| 279 |
} |
| 280 |
|
| 281 |
if (values_mask & GDK_GC_LINE_STYLE) |
| 282 |
{ |
| 283 |
private->values.line_style = values->line_style; |
| 284 |
private->values_mask |= GDK_GC_LINE_STYLE; |
| 285 |
} |
| 286 |
|
| 287 |
if (values_mask & GDK_GC_CAP_STYLE) |
| 288 |
{ |
| 289 |
private->values.cap_style = values->cap_style; |
| 290 |
private->values_mask |= GDK_GC_CAP_STYLE; |
| 291 |
} |
| 292 |
|
| 293 |
if (values_mask & GDK_GC_JOIN_STYLE) |
| 294 |
{ |
| 295 |
private->values.join_style = values->join_style; |
| 296 |
private->values_mask |= GDK_GC_JOIN_STYLE; |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
static void |
| 301 |
gdk_directfb_gc_set_dashes (GdkGC *gc, |
| 302 |
gint dash_offset, |
| 303 |
gint8 dash_list[], |
| 304 |
gint n) |
| 305 |
{ |
| 306 |
g_warning ("gdk_directfb_gc_set_dashes not implemented"); |
| 307 |
} |
| 308 |
|
| 309 |
static void |
| 310 |
gc_unset_clip_mask (GdkGC *gc) |
| 311 |
{ |
| 312 |
GdkGCDirectFB *data = GDK_GC_DIRECTFB (gc); |
| 313 |
|
| 314 |
if (data->values.clip_mask) |
| 315 |
{ |
| 316 |
g_object_unref (data->values.clip_mask); |
| 317 |
data->values.clip_mask = NULL; |
| 318 |
data->values_mask &= ~ GDK_GC_CLIP_MASK; |
| 319 |
} |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
void |
| 324 |
_gdk_windowing_gc_set_clip_region (GdkGC *gc, |
| 325 |
const GdkRegion *region, |
| 326 |
gboolean reset_origin) |
| 327 |
{ |
| 328 |
GdkGCDirectFB *data; |
| 329 |
|
| 330 |
g_return_if_fail (gc != NULL); |
| 331 |
|
| 332 |
data = GDK_GC_DIRECTFB (gc); |
| 333 |
|
| 334 |
if (region == &data->clip_region) |
| 335 |
return; |
| 336 |
|
| 337 |
if (region) |
| 338 |
temp_region_init_copy (&data->clip_region, region); |
| 339 |
else |
| 340 |
temp_region_reset (&data->clip_region); |
| 341 |
|
| 342 |
if (reset_origin) |
| 343 |
{ |
| 344 |
gc->clip_x_origin = 0; |
| 345 |
gc->clip_y_origin = 0; |
| 346 |
data->values.clip_x_origin = 0; |
| 347 |
data->values.clip_y_origin = 0; |
| 348 |
} |
| 349 |
|
| 350 |
gc_unset_clip_mask (gc); |
| 351 |
} |
| 352 |
|
| 353 |
void |
| 354 |
_gdk_windowing_gc_copy (GdkGC *dst_gc, |
| 355 |
GdkGC *src_gc) |
| 356 |
{ |
| 357 |
GdkGCDirectFB *dst_private; |
| 358 |
|
| 359 |
g_return_if_fail (dst_gc != NULL); |
| 360 |
g_return_if_fail (src_gc != NULL); |
| 361 |
|
| 362 |
dst_private = GDK_GC_DIRECTFB (dst_gc); |
| 363 |
|
| 364 |
temp_region_reset(&dst_private->clip_region); |
| 365 |
|
| 366 |
if (dst_private->values_mask & GDK_GC_FONT) |
| 367 |
gdk_font_unref (dst_private->values.font); |
| 368 |
if (dst_private->values_mask & GDK_GC_TILE) |
| 369 |
g_object_unref (dst_private->values.tile); |
| 370 |
if (dst_private->values_mask & GDK_GC_STIPPLE) |
| 371 |
g_object_unref (dst_private->values.stipple); |
| 372 |
if (dst_private->values_mask & GDK_GC_CLIP_MASK) |
| 373 |
g_object_unref (dst_private->values.clip_mask); |
| 374 |
|
| 375 |
*dst_gc = *src_gc; |
| 376 |
if (dst_private->values_mask & GDK_GC_FONT) |
| 377 |
gdk_font_ref (dst_private->values.font); |
| 378 |
if (dst_private->values_mask & GDK_GC_TILE) |
| 379 |
g_object_ref (dst_private->values.tile); |
| 380 |
if (dst_private->values_mask & GDK_GC_STIPPLE) |
| 381 |
g_object_ref (dst_private->values.stipple); |
| 382 |
if (dst_private->values_mask & GDK_GC_CLIP_MASK) |
| 383 |
g_object_ref (dst_private->values.clip_mask); |
| 384 |
} |
| 385 |
|
| 386 |
/** |
| 387 |
* gdk_gc_get_screen: |
| 388 |
* @gc: a #GdkGC. |
| 389 |
* |
| 390 |
* Gets the #GdkScreen for which @gc was created |
| 391 |
* |
| 392 |
* Returns: the #GdkScreen for @gc. |
| 393 |
* |
| 394 |
* Since: 2.2 |
| 395 |
*/ |
| 396 |
GdkScreen * |
| 397 |
gdk_gc_get_screen (GdkGC *gc) |
| 398 |
{ |
| 399 |
g_return_val_if_fail (GDK_IS_GC_DIRECTFB (gc), NULL); |
| 400 |
|
| 401 |
return _gdk_screen; |
| 402 |
} |
| 403 |
#define __GDK_GC_X11_C__ |
| 404 |
#include "gdkaliasdef.c" |