more namespacing to Rr*

This commit is contained in:
Dana Jansens 2003-06-21 02:15:13 +00:00
parent 10232a436a
commit dbe2851b91
7 changed files with 51 additions and 44 deletions

View file

@ -176,7 +176,6 @@ int main(int argc, char **argv)
/* anything that is going to read data from the rc file needs to be /* anything that is going to read data from the rc file needs to be
in this group */ in this group */
timer_startup(); timer_startup();
font_startup();
event_startup(); event_startup();
grab_startup(); grab_startup();
plugin_startup(); plugin_startup();

View file

@ -12,7 +12,9 @@
#define ELIPSES_LENGTH(font, shadow, offset) \ #define ELIPSES_LENGTH(font, shadow, offset) \
(font->elipses_length + (shadow ? offset : 0)) (font->elipses_length + (shadow ? offset : 0))
void font_startup(void) static gboolean started = FALSE;
static void font_startup(void)
{ {
#ifdef DEBUG #ifdef DEBUG
int version; int version;
@ -29,7 +31,7 @@ void font_startup(void)
#endif #endif
} }
static void measure_height(RrFont *f) static void measure_font(RrFont *f)
{ {
XGlyphInfo info; XGlyphInfo info;
@ -39,16 +41,21 @@ static void measure_height(RrFont *f)
f->elipses_length = (signed) info.xOff; f->elipses_length = (signed) info.xOff;
} }
RrFont *font_open(const RrInstance *inst, char *fontstring) RrFont *RrFontOpen(const RrInstance *inst, char *fontstring)
{ {
RrFont *out; RrFont *out;
XftFont *xf; XftFont *xf;
if (!started) {
font_startup();
started = TRUE;
}
if ((xf = XftFontOpenName(RrDisplay(inst), RrScreen(inst), fontstring))) { if ((xf = XftFontOpenName(RrDisplay(inst), RrScreen(inst), fontstring))) {
out = g_new(RrFont, 1); out = g_new(RrFont, 1);
out->inst = inst; out->inst = inst;
out->xftfont = xf; out->xftfont = xf;
measure_height(out); measure_font(out);
return out; return out;
} }
g_warning(_("Unable to load font: %s\n"), fontstring); g_warning(_("Unable to load font: %s\n"), fontstring);
@ -58,7 +65,7 @@ RrFont *font_open(const RrInstance *inst, char *fontstring)
out = g_new(RrFont, 1); out = g_new(RrFont, 1);
out->inst = inst; out->inst = inst;
out->xftfont = xf; out->xftfont = xf;
measure_height(out); measure_font(out);
return out; return out;
} }
g_warning(_("Unable to load font: %s\n"), "sans"); g_warning(_("Unable to load font: %s\n"), "sans");
@ -67,7 +74,7 @@ RrFont *font_open(const RrInstance *inst, char *fontstring)
exit(3); /* can't continue without a font */ exit(3); /* can't continue without a font */
} }
void font_close(RrFont *f) void RrFontClose(RrFont *f)
{ {
if (f) { if (f) {
XftFontClose(RrDisplay(f->inst), f->xftfont); XftFontClose(RrDisplay(f->inst), f->xftfont);
@ -75,47 +82,48 @@ void font_close(RrFont *f)
} }
} }
void font_measure_full(RrFont *f, char *str, int shadow, int offset, static void font_measure_full(const RrFont *f, const gchar *str,
int *x, int *y) gint shadow, gint offset, gint *x, gint *y)
{ {
XGlyphInfo info; XGlyphInfo info;
XftTextExtentsUtf8(RrDisplay(f->inst), f->xftfont, XftTextExtentsUtf8(RrDisplay(f->inst), f->xftfont,
(FcChar8*)str, strlen(str), &info); (const FcChar8*)str, strlen(str), &info);
*x = (signed) info.xOff + (shadow ? ABS(offset) : 0); *x = (signed) info.xOff + (shadow ? ABS(offset) : 0);
*y = info.height + (shadow ? ABS(offset) : 0); *y = info.height + (shadow ? ABS(offset) : 0);
} }
int font_measure_string(RrFont *f, char *str, int shadow, int offset) int RrFontMeasureString(const RrFont *f, const gchar *str,
gint shadow, gint offset)
{ {
int x, y; gint x, y;
font_measure_full (f, str, shadow, offset, &x, &y); font_measure_full (f, str, shadow, offset, &x, &y);
return x; return x;
} }
int font_height(RrFont *f, int shadow, int offset) int RrFontHeight(const RrFont *f, gint shadow, gint offset)
{ {
return f->xftfont->ascent + f->xftfont->descent + (shadow ? offset : 0); return f->xftfont->ascent + f->xftfont->descent + (shadow ? offset : 0);
} }
int font_max_char_width(RrFont *f) int RrFontMaxCharWidth(const RrFont *f)
{ {
return (signed) f->xftfont->max_advance_width; return (signed) f->xftfont->max_advance_width;
} }
void font_draw(XftDraw *d, RrTextureText *t, Rect *area) void RrFontDraw(XftDraw *d, RrTextureText *t, Rect *area)
{ {
int x,y,w,h; gint x,y,w,h;
XftColor c; XftColor c;
GString *text; GString *text;
int mw, em, mh; gint mw, em, mh;
size_t l; size_t l;
gboolean shortened = FALSE; gboolean shortened = FALSE;
/* center vertically */ /* center vertically */
y = area->y + y = area->y +
(area->height - font_height(t->font, t->shadow, t->offset)) / 2; (area->height - RrFontHeight(t->font, t->shadow, t->offset)) / 2;
w = area->width; w = area->width;
h = area->height; h = area->height;

View file

@ -11,11 +11,7 @@ struct _RrFont {
gint elipses_length; gint elipses_length;
}; };
void font_startup(void); RrFont *RrFontOpen(const RrInstance *inst, char *fontstring);
RrFont *font_open(const RrInstance *inst, char *fontstring); void RrFontClose(RrFont *f);
void font_close(RrFont *f); void RrFontDraw(XftDraw *d, RrTextureText *t, Rect *position);
int font_measure_string(RrFont *f, char *str, int shadow, int offset);
int font_height(RrFont *f, int shadow, int offset);
int font_max_char_width(RrFont *f);
void font_draw(XftDraw *d, RrTextureText *t, Rect *position);
#endif /* __font_h */ #endif /* __font_h */

View file

@ -100,7 +100,7 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h)
RrVisual(l->inst), RrVisual(l->inst),
RrColormap(l->inst)); RrColormap(l->inst));
} }
font_draw(l->xftdraw, &l->texture[i].data.text, &tarea); RrFontDraw(l->xftdraw, &l->texture[i].data.text, &tarea);
break; break;
case RR_TEXTURE_MASK: case RR_TEXTURE_MASK:
if (!transferred) { if (!transferred) {
@ -266,12 +266,12 @@ void RrMinsize(RrAppearance *l, gint *w, gint *h)
*h = MAX(*h, l->texture[i].data.mask.mask->height); *h = MAX(*h, l->texture[i].data.mask.mask->height);
break; break;
case RR_TEXTURE_TEXT: case RR_TEXTURE_TEXT:
m = font_measure_string(l->texture[i].data.text.font, m = RrFontMeasureString(l->texture[i].data.text.font,
l->texture[i].data.text.string, l->texture[i].data.text.string,
l->texture[i].data.text.shadow, l->texture[i].data.text.shadow,
l->texture[i].data.text.offset); l->texture[i].data.text.offset);
*w = MAX(*w, m); *w = MAX(*w, m);
m = font_height(l->texture[i].data.text.font, m = RrFontHeight(l->texture[i].data.text.font,
l->texture[i].data.text.shadow, l->texture[i].data.text.shadow,
l->texture[i].data.text.offset); l->texture[i].data.text.offset);
*h += MAX(*h, m); *h += MAX(*h, m);

View file

@ -161,6 +161,11 @@ RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex);
RrAppearance *RrAppearanceCopy (RrAppearance *a); RrAppearance *RrAppearanceCopy (RrAppearance *a);
void RrAppearanceFree (RrAppearance *a); void RrAppearanceFree (RrAppearance *a);
int RrFontMeasureString (const RrFont *f, const gchar *str,
gint shadow, gint offset);
int RrFontHeight (const RrFont *f, gint shadow, gint offset);
int RrFontMaxCharWidth (const RrFont *f);
void RrPaint (RrAppearance *l, Window win, gint w, gint h); void RrPaint (RrAppearance *l, Window win, gint w, gint h);
void RrMinsize (RrAppearance *l, gint *w, gint *h); void RrMinsize (RrAppearance *l, gint *w, gint *h);

View file

@ -125,8 +125,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
theme->winfont_shadow_tint < 100 || theme->winfont_shadow_tint > 100) theme->winfont_shadow_tint < 100 || theme->winfont_shadow_tint > 100)
theme->winfont_shadow_tint = 25; theme->winfont_shadow_tint = 25;
theme->winfont = font_open(inst, font_str); theme->winfont = RrFontOpen(inst, font_str);
theme->winfont_height = font_height(theme->winfont, theme->winfont_shadow, theme->winfont_height = RrFontHeight(theme->winfont, theme->winfont_shadow,
theme->winfont_shadow_offset); theme->winfont_shadow_offset);
winjust = RR_JUSTIFY_LEFT; winjust = RR_JUSTIFY_LEFT;
@ -156,8 +156,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
theme->mtitlefont_shadow_tint > 100) theme->mtitlefont_shadow_tint > 100)
theme->mtitlefont_shadow_tint = 25; theme->mtitlefont_shadow_tint = 25;
theme->mtitlefont = font_open(inst, font_str); theme->mtitlefont = RrFontOpen(inst, font_str);
theme->mtitlefont_height = font_height(theme->mtitlefont, theme->mtitlefont_height = RrFontHeight(theme->mtitlefont,
theme->mtitlefont_shadow, theme->mtitlefont_shadow,
theme->mtitlefont_shadow_offset); theme->mtitlefont_shadow_offset);
@ -188,8 +188,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
theme->mfont_shadow_tint > 100) theme->mfont_shadow_tint > 100)
theme->mfont_shadow_tint = 25; theme->mfont_shadow_tint = 25;
theme->mfont = font_open(inst, font_str); theme->mfont = RrFontOpen(inst, font_str);
theme->mfont_height = font_height(theme->mfont, theme->mfont_shadow, theme->mfont_height = RrFontHeight(theme->mfont, theme->mfont_shadow,
theme->mfont_shadow_offset); theme->mfont_shadow_offset);
mjust = RR_JUSTIFY_LEFT; mjust = RR_JUSTIFY_LEFT;
@ -647,9 +647,9 @@ void RrThemeFree(RrTheme *theme)
RrPixmapMaskFree(theme->iconify_mask); RrPixmapMaskFree(theme->iconify_mask);
RrPixmapMaskFree(theme->close_mask); RrPixmapMaskFree(theme->close_mask);
font_close(theme->winfont); RrFontClose(theme->winfont);
font_close(theme->mtitlefont); RrFontClose(theme->mtitlefont);
font_close(theme->mfont); RrFontClose(theme->mfont);
g_free(theme->title_layout); g_free(theme->title_layout);

View file

@ -3,7 +3,6 @@
#include "render.h" #include "render.h"
#include "color.h" #include "color.h"
#include "font.h"
#include "mask.h" #include "mask.h"
typedef struct _RrTheme RrTheme; typedef struct _RrTheme RrTheme;