Added underline_height in jdraw_text() function.

Removed jdraw_widget_text() (deprecated).
This commit is contained in:
David Capello 2010-03-07 23:16:20 -02:00
parent ed3428345f
commit 0a7136a0b4
9 changed files with 28 additions and 38 deletions

View File

@ -980,9 +980,8 @@ static void anieditor_draw_header_part(JWidget widget, JRect clip, int x1, int y
else
x = x2 - 3 - text_length(widget->getFont(), line1);
jdraw_text(widget->getFont(), line1,
x, y1+3,
fg, face, true);
jdraw_text(widget->getFont(), line1, x, y1+3,
fg, face, true, guiscale());
}
if (line2 != NULL) {
@ -995,7 +994,7 @@ static void anieditor_draw_header_part(JWidget widget, JRect clip, int x1, int y
jdraw_text(widget->getFont(), line2,
x, y1+3+ji_font_get_size(widget->getFont())+3,
fg, face, true);
fg, face, true, guiscale());
}
}
@ -1101,7 +1100,7 @@ static void anieditor_draw_layer(JWidget widget, JRect clip, int layer_index)
/* draw the layer's name */
jdraw_text(widget->getFont(), layer->get_name().c_str(),
u, y_mid - ji_font_get_size(widget->getFont())/2,
fg, bg, true);
fg, bg, true, guiscale());
/* the background should be underlined */
if (layer->is_background()) {

View File

@ -155,18 +155,17 @@ void jdraw_rectexclude(const JRect rc, const JRect exclude, int color)
exclude->x2-1, exclude->y2-1, color);
}
void jdraw_char(FONT *f, int chr, int x, int y, int fg, int bg, bool fill_bg)
void jdraw_char(FONT* f, int chr, int x, int y, int fg, int bg, bool fill_bg)
{
SETUP_ANTIALISING(f, bg, fill_bg);
f->vtable->render_char(f, chr, fg, fill_bg ? bg: -1, ji_screen, x, y);
}
/* see ji_font_text_len */
void jdraw_text(FONT *font, const char *s, int x, int y,
int fg_color, int bg_color, bool fill_bg)
void jdraw_text(FONT* font, const char *s, int x, int y,
int fg_color, int bg_color, bool fill_bg, int underline_height)
{
/* original code from allegro/src/guiproc.c */
// original code from allegro/src/guiproc.c
char tmp[1024];
int hline_pos = -1;
int len = 0;
@ -207,20 +206,11 @@ void jdraw_text(FONT *font, const char *s, int x, int y,
c = usetc(tmp, c);
usetc(tmp+c, 0);
c = text_length(font, tmp);
hline(ji_screen, x+hline_pos,
/* y+text_height(font)-1, */
y+text_height(font),
x+hline_pos+c-1, fg_color);
}
}
void jdraw_widget_text(JWidget widget, int fg, int bg, bool fill_bg)
{
if (widget->getText()) {
struct jrect box, text, icon;
jwidget_get_texticon_info(widget, &box, &text, &icon, 0, 0, 0);
jdraw_text(widget->getFont(), widget->getText(),
text.x1, text.y1, fg, bg, fill_bg);
rectfill(ji_screen, x+hline_pos,
y+text_height(font),
x+hline_pos+c-1,
y+text_height(font)+underline_height-1, fg_color);
}
}

View File

@ -60,9 +60,8 @@ void jdraw_rectedge(const JRect rect, int c1, int c2);
void jdraw_rectshade(const JRect rect, int c1, int c2, int align);
void jdraw_rectexclude(const JRect rc, const JRect exclude, int color);
void jdraw_char(struct FONT *f, int chr, int x, int y, int fg, int bg, bool fill_bg);
void jdraw_text(struct FONT *f, const char *text, int x, int y, int fg, int bg, bool fill_bg);
void jdraw_widget_text(JWidget widget, int fg, int bg, bool fill_bg);
void jdraw_char(FONT* f, int chr, int x, int y, int fg, int bg, bool fill_bg);
void jdraw_text(FONT* f, const char* text, int x, int y, int fg, int bg, bool fill_bg, int underline_height = 1);
void jdraw_inverted_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);

View File

@ -593,7 +593,7 @@ int ji_font_char_len(FONT* f, int chr)
return f->vtable->char_length(f, chr);
}
/* see jdraw_text */
// see jdraw_text
int ji_font_text_len(struct FONT* f, const char *s)
{
int in_pos = 0;
@ -1024,7 +1024,7 @@ int ji_font_char_len(FONT* f, int chr)
return f->vtable->char_length(f, chr);
}
/* see jdraw_text */
// see jdraw_text
int ji_font_text_len(struct FONT* f, const char* s)
{
int in_pos = 0;

View File

@ -930,7 +930,7 @@ void SkinneableTheme::draw_listitem(JWidget widget, JRect clip)
if (widget->hasText()) {
/* text */
jdraw_text(widget->getFont(), widget->getText(), x, y, fg, bg, true);
jdraw_text(widget->getFont(), widget->getText(), x, y, fg, bg, true, guiscale());
/* background */
jrectexclude
@ -1444,7 +1444,7 @@ void SkinneableTheme::draw_frame(Frame* window, JRect clip)
jdraw_text(window->getFont(), window->getText(),
cpos->x1,
pos->y1+jrect_h(pos)/2-text_height(window->getFont())/2,
COLOR_BACKGROUND, -1, false);
COLOR_BACKGROUND, -1, false, guiscale());
}
// menubox
else {
@ -1539,11 +1539,11 @@ void SkinneableTheme::draw_textstring(const char *t, int fg_color, int bg_color,
if (jwidget_is_disabled (widget)) {
/* TODO avoid this */
if (fill_bg) /* only to draw the background */
jdraw_text(widget->getFont(), t, x, y, 0, bg_color, fill_bg);
jdraw_text(widget->getFont(), t, x, y, 0, bg_color, fill_bg, guiscale());
/* draw white part */
jdraw_text(widget->getFont(), t, x+1, y+1,
COLOR_BACKGROUND, bg_color, fill_bg);
COLOR_BACKGROUND, bg_color, fill_bg, guiscale());
if (fill_bg)
fill_bg = false;
@ -1553,7 +1553,7 @@ void SkinneableTheme::draw_textstring(const char *t, int fg_color, int bg_color,
jwidget_is_disabled(widget) ?
COLOR_DISABLED: (fg_color >= 0 ? fg_color :
COLOR_FOREGROUND),
bg_color, fill_bg);
bg_color, fill_bg, guiscale());
}
}

View File

@ -24,6 +24,7 @@
#include "core/color.h"
#include "modules/gfx.h"
#include "modules/gui.h"
#include "raster/sprite.h"
#include "widgets/colbar.h"
#include "widgets/colbut.h"
@ -242,7 +243,7 @@ static void colorbutton_draw(JWidget widget)
rectfill(ji_screen, text.x1, text.y1, text.x2-1, text.y2-1, makecol(0, 0, 0));
jdraw_text(widget->getFont(), widget->getText(), text.x1, text.y1,
makecol(255, 255, 255),
makecol(0, 0, 0), false);
makecol(0, 0, 0), false, guiscale());
}
static void colorbutton_open_tooltip(JWidget widget)

View File

@ -30,6 +30,7 @@
#include "jinete/jwidget.h"
#include "modules/gfx.h"
#include "modules/gui.h"
#include "widgets/colview.h"
typedef struct ColorViewer
@ -142,7 +143,7 @@ static bool colorviewer_msg_proc(JWidget widget, JMessage msg)
jdraw_rectfill(&text, makecol(0, 0, 0));
jdraw_text(widget->getFont(), widget->getText(), text.x1, text.y1,
makecol(255, 255, 255), makecol(0, 0, 0), false);
makecol(255, 255, 255), makecol(0, 0, 0), false, guiscale());
jrect_free(rect);
return true;

View File

@ -273,7 +273,7 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
jdraw_text(widget->getFont(),
"[+]", x, y+2,
fgcolor, bgcolor, true);
fgcolor, bgcolor, true, guiscale());
// background for the icon
jrectexclude(ji_screen,
@ -300,7 +300,7 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
// item name
jdraw_text(widget->getFont(),
fileitem_get_displayname(fi).c_str(), x, y+2,
fgcolor, bgcolor, true);
fgcolor, bgcolor, true, guiscale());
// background for the item name
jrectexclude(ji_screen,

View File

@ -275,7 +275,7 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
jdraw_text(widget->getFont(), tab->text.c_str(),
box->x1+4,
(box->y1+box->y2)/2-text_height(widget->getFont())/2+1,
text_color, face_color, false);
text_color, face_color, false, guiscale());
}
box->x1 = box->x2;