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
in this group */
timer_startup();
font_startup();
event_startup();
grab_startup();
plugin_startup();

View file

@ -12,7 +12,9 @@
#define ELIPSES_LENGTH(font, shadow, offset) \
(font->elipses_length + (shadow ? offset : 0))
void font_startup(void)
static gboolean started = FALSE;
static void font_startup(void)
{
#ifdef DEBUG
int version;
@ -29,7 +31,7 @@ void font_startup(void)
#endif
}
static void measure_height(RrFont *f)
static void measure_font(RrFont *f)
{
XGlyphInfo info;
@ -39,16 +41,21 @@ static void measure_height(RrFont *f)
f->elipses_length = (signed) info.xOff;
}
RrFont *font_open(const RrInstance *inst, char *fontstring)
RrFont *RrFontOpen(const RrInstance *inst, char *fontstring)
{
RrFont *out;
XftFont *xf;
if (!started) {
font_startup();
started = TRUE;
}
if ((xf = XftFontOpenName(RrDisplay(inst), RrScreen(inst), fontstring))) {
out = g_new(RrFont, 1);
out->inst = inst;
out->xftfont = xf;
measure_height(out);
measure_font(out);
return out;
}
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->inst = inst;
out->xftfont = xf;
measure_height(out);
measure_font(out);
return out;
}
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 */
}
void font_close(RrFont *f)
void RrFontClose(RrFont *f)
{
if (f) {
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,
int *x, int *y)
static void font_measure_full(const RrFont *f, const gchar *str,
gint shadow, gint offset, gint *x, gint *y)
{
XGlyphInfo info;
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);
*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);
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);
}
int font_max_char_width(RrFont *f)
int RrFontMaxCharWidth(const RrFont *f)
{
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;
GString *text;
int mw, em, mh;
gint mw, em, mh;
size_t l;
gboolean shortened = FALSE;
/* center vertically */
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;
h = area->height;

View file

@ -11,11 +11,7 @@ struct _RrFont {
gint elipses_length;
};
void font_startup(void);
RrFont *font_open(const RrInstance *inst, char *fontstring);
void font_close(RrFont *f);
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);
RrFont *RrFontOpen(const RrInstance *inst, char *fontstring);
void RrFontClose(RrFont *f);
void RrFontDraw(XftDraw *d, RrTextureText *t, Rect *position);
#endif /* __font_h */

View file

@ -100,7 +100,7 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h)
RrVisual(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;
case RR_TEXTURE_MASK:
if (!transferred) {
@ -266,14 +266,14 @@ void RrMinsize(RrAppearance *l, gint *w, gint *h)
*h = MAX(*h, l->texture[i].data.mask.mask->height);
break;
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.shadow,
l->texture[i].data.text.offset);
*w = MAX(*w, m);
m = font_height(l->texture[i].data.text.font,
l->texture[i].data.text.shadow,
l->texture[i].data.text.offset);
m = RrFontHeight(l->texture[i].data.text.font,
l->texture[i].data.text.shadow,
l->texture[i].data.text.offset);
*h += MAX(*h, m);
break;
case RR_TEXTURE_RGBA:

View file

@ -161,6 +161,11 @@ RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex);
RrAppearance *RrAppearanceCopy (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 RrMinsize (RrAppearance *l, gint *w, gint *h);

View file

@ -125,9 +125,9 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
theme->winfont_shadow_tint < 100 || theme->winfont_shadow_tint > 100)
theme->winfont_shadow_tint = 25;
theme->winfont = font_open(inst, font_str);
theme->winfont_height = font_height(theme->winfont, theme->winfont_shadow,
theme->winfont_shadow_offset);
theme->winfont = RrFontOpen(inst, font_str);
theme->winfont_height = RrFontHeight(theme->winfont, theme->winfont_shadow,
theme->winfont_shadow_offset);
winjust = RR_JUSTIFY_LEFT;
if (read_string(db, "window.justify", &str)) {
@ -156,10 +156,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
theme->mtitlefont_shadow_tint > 100)
theme->mtitlefont_shadow_tint = 25;
theme->mtitlefont = font_open(inst, font_str);
theme->mtitlefont_height = font_height(theme->mtitlefont,
theme->mtitlefont_shadow,
theme->mtitlefont_shadow_offset);
theme->mtitlefont = RrFontOpen(inst, font_str);
theme->mtitlefont_height = RrFontHeight(theme->mtitlefont,
theme->mtitlefont_shadow,
theme->mtitlefont_shadow_offset);
mtitlejust = RR_JUSTIFY_LEFT;
if (read_string(db, "menu.title.justify", &str)) {
@ -188,9 +188,9 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
theme->mfont_shadow_tint > 100)
theme->mfont_shadow_tint = 25;
theme->mfont = font_open(inst, font_str);
theme->mfont_height = font_height(theme->mfont, theme->mfont_shadow,
theme->mfont_shadow_offset);
theme->mfont = RrFontOpen(inst, font_str);
theme->mfont_height = RrFontHeight(theme->mfont, theme->mfont_shadow,
theme->mfont_shadow_offset);
mjust = RR_JUSTIFY_LEFT;
if (read_string(db, "menu.frame.justify", &str)) {
@ -647,9 +647,9 @@ void RrThemeFree(RrTheme *theme)
RrPixmapMaskFree(theme->iconify_mask);
RrPixmapMaskFree(theme->close_mask);
font_close(theme->winfont);
font_close(theme->mtitlefont);
font_close(theme->mfont);
RrFontClose(theme->winfont);
RrFontClose(theme->mtitlefont);
RrFontClose(theme->mfont);
g_free(theme->title_layout);

View file

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