From c313b219a226c3b968ff312b96120eef0c527d91 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 6 Feb 2008 21:35:55 -0500 Subject: you can create dialog windows called "prompts" which have a message and some buttons! they don't do anything interesting yet. --- render/font.c | 12 ++++++++---- render/render.c | 11 ++++++++++- render/render.h | 5 ++++- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'render') diff --git a/render/font.c b/render/font.c index 369f262e..29d48215 100644 --- a/render/font.c +++ b/render/font.c @@ -109,6 +109,7 @@ RrFont *RrFontOpen(const RrInstance *inst, const gchar *name, gint size, /* setup the layout */ pango_layout_set_font_description(out->layout, out->font_desc); pango_layout_set_single_paragraph_mode(out->layout, TRUE); + pango_layout_set_wrap(out->layout, PANGO_WRAP_WORD_CHAR); /* get the ascent and descent */ measure_font(inst, out); @@ -139,12 +140,14 @@ void RrFontClose(RrFont *f) } static void font_measure_full(const RrFont *f, const gchar *str, - gint *x, gint *y, gint shadow_x, gint shadow_y) + gint *x, gint *y, gint shadow_x, gint shadow_y, + gint maxwidth) { PangoRectangle rect; pango_layout_set_text(f->layout, str, -1); - pango_layout_set_width(f->layout, -1); + pango_layout_set_width(f->layout, + (maxwidth <= 0 ? -1 : maxwidth * PANGO_SCALE)); /* pango_layout_get_pixel_extents lies! this is the right way to get the size of the text's area */ @@ -163,11 +166,12 @@ static void font_measure_full(const RrFont *f, const gchar *str, } RrSize *RrFontMeasureString(const RrFont *f, const gchar *str, - gint shadow_x, gint shadow_y) + gint shadow_x, gint shadow_y, gint maxwidth) { RrSize *size; size = g_new(RrSize, 1); - font_measure_full(f, str, &size->width, &size->height, shadow_x, shadow_y); + font_measure_full(f, str, &size->width, &size->height, shadow_x, shadow_y, + maxwidth); return size; } diff --git a/render/render.c b/render/render.c index 4119dc7f..2147df01 100644 --- a/render/render.c +++ b/render/render.c @@ -178,6 +178,14 @@ RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex) return out; } +void RrAppearanceRemoveTextures(RrAppearance *a) +{ + gint i; + + g_free(a->texture); + a->textures = 0; +} + void RrAppearanceAddTextures(RrAppearance *a, gint numtex) { g_assert(a->textures == 0); @@ -378,7 +386,8 @@ gint RrMinWidth(RrAppearance *a) m = RrFontMeasureString(a->texture[i].data.text.font, a->texture[i].data.text.string, a->texture[i].data.text.shadow_offset_x, - a->texture[i].data.text.shadow_offset_y); + a->texture[i].data.text.shadow_offset_y, + a->texture[i].data.text.maxwidth); w = MAX(w, m->width); g_free(m); break; diff --git a/render/render.h b/render/render.h index 1f87c6e0..c812c316 100644 --- a/render/render.h +++ b/render/render.h @@ -141,6 +141,7 @@ struct _RrTextureText { gboolean shortcut; /*!< Underline a character */ guint shortcut_pos; /*!< Position in bytes of the character to underline */ RrEllipsizeMode ellipsize; + gint maxwidth; }; struct _RrPixmapMask { @@ -244,6 +245,7 @@ GC RrColorGC (RrColor *c); RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex); RrAppearance *RrAppearanceCopy (RrAppearance *a); void RrAppearanceFree (RrAppearance *a); +void RrAppearanceRemoveTextures(RrAppearance *a); void RrAppearanceAddTextures(RrAppearance *a, gint numtex); RrFont *RrFontOpen (const RrInstance *inst, const gchar *name, @@ -251,7 +253,8 @@ RrFont *RrFontOpen (const RrInstance *inst, const gchar *name, RrFont *RrFontOpenDefault (const RrInstance *inst); void RrFontClose (RrFont *f); RrSize *RrFontMeasureString (const RrFont *f, const gchar *str, - gint shadow_offset_x, gint shadow_offset_y); + gint shadow_offset_x, gint shadow_offset_y, + gint maxwidth); gint RrFontHeight (const RrFont *f, gint shadow_offset_y); gint RrFontMaxCharWidth (const RrFont *f); -- cgit v1.2.3