39 #include <libgnomeprint/gnome-pgl.h>
40 #include <libgnomeprint/gnome-font.h>
41 #include <libgnomeprint/gnome-rfont.h>
50 #ifndef __GNOME_PRINT_I18N_H__
51 #define __GNOME_PRINT_I18N_H__
52 # define textdomain( String ) ( String )
53 # define gettext( String ) ( String )
54 # define dgettext( Domain, Message ) ( Message )
55 # define dcgettext( Domain, Message, Type ) ( Message )
56 # define bindtextdomain( Domain, Directory ) ( Domain )
57 # define _( String ) ( String )
58 # define N_( String ) ( String )
59 #endif // __GNOME_PRINT_I18N_H__
94 int cx,
int cy, GnomeCanvasItem **actual_item );
114 static GType type = 0;
127 type = g_type_register_static( GNOME_TYPE_CANVAS_ITEM,
"PlplotCanvasHacktext", &info, 0 );
135 GObjectClass *gobject_class;
136 GtkObjectClass *object_class;
137 GnomeCanvasItemClass *item_class;
139 object_class = (GtkObjectClass *)
class;
140 gobject_class = (GObjectClass *)
class;
141 item_class = (GnomeCanvasItemClass *)
class;
148 g_object_class_install_property
151 g_param_spec_string(
"text",
153 _(
"Text to render" ),
155 G_PARAM_READABLE | G_PARAM_WRITABLE ) );
156 g_object_class_install_property
159 g_param_spec_double(
"x", NULL, NULL,
160 -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
161 ( G_PARAM_READABLE | G_PARAM_WRITABLE ) ) );
162 g_object_class_install_property
165 g_param_spec_double(
"y", NULL, NULL,
166 -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
167 ( G_PARAM_READABLE | G_PARAM_WRITABLE ) ) );
168 g_object_class_install_property
171 g_param_spec_pointer(
"glyphlist",
174 ( G_PARAM_READABLE | G_PARAM_WRITABLE ) ) );
175 g_object_class_install_property
178 g_param_spec_string(
"fill_color",
180 _(
"Text color, as string" ),
182 G_PARAM_WRITABLE ) );
183 g_object_class_install_property
186 g_param_spec_uint(
"fill_color_rgba",
188 _(
"Text color, as an R/G/B/A combined integer" ),
190 ( G_PARAM_READABLE | G_PARAM_WRITABLE ) ) );
191 g_object_class_install_property
194 g_param_spec_object(
"font",
196 _(
"Font as a GnomeFont struct" ),
198 ( G_PARAM_READABLE | G_PARAM_WRITABLE ) ) );
213 hacktext->
text = NULL;
219 art_affine_identity( hacktext->
priv->
affine );
227 g_return_if_fail(
object != NULL );
232 if ( hacktext->
text )
234 g_free( hacktext->
text );
235 hacktext->
text = NULL;
238 if ( hacktext->
priv )
241 gnome_font_unref( hacktext->
priv->
font );
245 gnome_pgl_destroy( hacktext->
priv->
pgl );
246 g_free( hacktext->
priv );
247 hacktext->
priv = NULL;
251 ( *GTK_OBJECT_CLASS(
parent_class )->destroy )(
object );
257 g_assert( bbox != NULL );
258 g_assert( hacktext != NULL );
260 g_return_if_fail( hacktext->
priv );
262 if ( GTK_OBJECT_FLAGS( hacktext ) & GNOME_CANVAS_UPDATE_REQUESTED )
264 gnome_canvas_update_now( GNOME_CANVAS_ITEM( hacktext )->canvas );
270 gnome_pgl_bbox( hacktext->
priv->
pgl, bbox );
298 GnomeCanvasItem *item;
304 item = GNOME_CANVAS_ITEM(
object );
322 bp->
text = g_value_dup_string( value );
324 gnome_canvas_item_request_update( item );
328 gl = g_value_get_pointer( value );
344 gnome_glyphlist_ref( gl );
348 gnome_canvas_item_request_update( item );
353 if ( gnome_canvas_get_color( item->canvas, g_value_get_string( value ), &color ) )
358 ( ( color.red & 0xff00 ) << 16 ) |
359 ( ( color.green & 0xff00 ) << 8 ) |
360 ( color.blue & 0xff00 ) |
369 gnome_canvas_item_request_update( item );
374 bp->
fill_rgba = g_value_get_uint( value );
377 gnome_canvas_item_request_update( item );
382 font = g_value_get_object( value );
384 gnome_font_ref( font );
389 gnome_canvas_item_request_update( item );
393 bp->
x = g_value_get_double( value );
394 gnome_canvas_item_request_update( item );
398 bp->
y = g_value_get_double( value );
399 gnome_canvas_item_request_update( item );
422 g_value_set_string( value, bp->
text );
425 g_value_set_pointer( value, priv->
glyphlist );
431 g_value_set_object( value, bp->
priv->
font );
434 g_value_set_double( value, bp->
x );
437 g_value_set_double( value, bp->
y );
440 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, param_id, pspec );
449 ArtIRect ibbox = { 0, 0, 0, 0 };
454 ( *
parent_class->update )( item, affine, clip_path, flags );
459 gnome_canvas_item_reset_bounds( item );
465 hacktext->
priv->
affine[4] = affine[4] + hacktext->
x * affine[0] + hacktext->
y * affine[2];
466 hacktext->
priv->
affine[5] = affine[5] + hacktext->
x * affine[1] + hacktext->
y * affine[3];
468 if ( hacktext->
text )
486 GnomePosGlyphList * pgl;
491 gnome_pgl_destroy( hacktext->
priv->
pgl );
498 hacktext->
item.x1 = ibbox.x0;
499 hacktext->
item.y1 = ibbox.y0;
500 hacktext->
item.x2 = ibbox.x1;
501 hacktext->
item.y2 = ibbox.y1;
528 int cx,
int cy, GnomeCanvasItem **actual_item )
539 if ( gnome_pgl_test_point( hacktext->
priv->
pgl, cx, cy ) )
550 g_return_if_fail( item != NULL );
555 if ( hacktext->
text == NULL )
557 *x1 = *y1 = *x2 = *y2 = 0.0;
570 g_return_if_fail( hacktext->
priv );
575 if ( gnome_pgl_bbox( hacktext->
priv->
pgl, &gbbox ) )
578 art_drect_to_irect( &ibox, &gbbox );
579 gnome_canvas_request_redraw( hacktext->
item.canvas, ibox.x0, ibox.y0, ibox.x1, ibox.y1 );
581 art_irect_union( bbox, bbox, &ibox );
587 GnomeCanvasBuf *
buf )
593 g_return_if_fail( hacktext->
priv );
598 gnome_canvas_buf_ensure_buf( buf );
602 gnome_rfont_render_pgl_rgb8( hacktext->
priv->
pgl,
603 -buf->rect.x0, -buf->rect.y0,
605 buf->rect.x1 - buf->rect.x0,
606 buf->rect.y1 - buf->rect.y0,
608 GNOME_RFONT_RENDER_DEFAULT );
static void plplot_canvas_hacktext_destroy(GtkObject *object)
static void plplot_canvas_hacktext_set_property(GObject *object, guint param_id, const GValue *value, GParamSpec *pspec)
static void plplot_canvas_hacktext_get_property(GObject *object, guint param_id, GValue *value, GParamSpec *pspec)
static double plplot_canvas_hacktext_point(GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item)
#define PLPLOT_CANVAS_HACKTEXT(o)
void destroy(GtkWidget *widget, gpointer data)
void PLFLT PLINT PLINT PLFLT x
static void art_drect_hacktext(ArtDRect *bbox, PlplotCanvasHacktext *hacktext)
PlplotCanvasHacktextPriv * priv
static void plplot_canvas_hacktext_render(GnomeCanvasItem *item, GnomeCanvasBuf *buf)
struct _PlplotCanvasHacktextClass PlplotCanvasHacktextClass
struct _PlplotCanvasHacktext PlplotCanvasHacktext
void PLFLT PLINT PLINT PLFLT PLFLT y
static void plplot_canvas_hacktext_unrealize(GnomeCanvasItem *item)
static void get_bounds(PlplotCanvasHacktext *hacktext, double *bx1, double *by1, double *bx2, double *by2)
static void plplot_canvas_hacktext_req_repaint(PlplotCanvasHacktext *hacktext, ArtIRect *bbox)
static void plplot_canvas_hacktext_class_init(PlplotCanvasHacktextClass *class)
static void plplot_canvas_hacktext_realize(GnomeCanvasItem *item)
static GnomeCanvasItemClass * parent_class
static void plplot_canvas_hacktext_update(GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
static void plplot_canvas_hacktext_bounds(GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
static PLFLT value(double n1, double n2, double hue)
GnomeGlyphList * glyphlist
static void plplot_canvas_hacktext_init(PlplotCanvasHacktext *hacktext)
GType plplot_canvas_hacktext_get_type(void)
#define PLPLOT_IS_CANVAS_HACKTEXT(o)