- cleaned up and improved the X gui text font handling
* dimension_update() stores the global variables columns, rows and font_height_orig; it uses X font sizes to recalculate the screen size * text_update() uses the columns, rows and X font sizes when redrawing the screen; it adjusts the cursor shape using the font sizes
This commit is contained in:
parent
a0c64105fa
commit
a8fc8f8d84
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: x.cc,v 1.42 2002-04-20 07:19:35 vruppert Exp $
|
||||
// $Id: x.cc,v 1.43 2002-05-18 16:02:20 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -59,6 +59,7 @@ static Window win;
|
||||
static GC gc, gc_inv, gc_headerbar, gc_headerbar_inv;
|
||||
static XFontStruct *font_info;
|
||||
static unsigned font_width, font_height;
|
||||
static unsigned font_height_orig = 16;
|
||||
static Bit8u blank_line[80];
|
||||
static unsigned dimension_x=0, dimension_y=0;
|
||||
|
||||
@ -1010,32 +1011,30 @@ bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
|
||||
unsigned long cursor_x, unsigned long cursor_y,
|
||||
Bit16u cursor_state, unsigned nrows)
|
||||
{
|
||||
int font_height;
|
||||
unsigned i, x, y, curs;
|
||||
unsigned new_foreground, new_background;
|
||||
Bit8u string[1];
|
||||
Bit8u cs_start, cs_end;
|
||||
unsigned nchars, ncols;
|
||||
unsigned nchars;
|
||||
|
||||
cs_start = (cursor_state >> 8) & 0x3f;
|
||||
cs_end = cursor_state & 0x1f;
|
||||
UNUSED(nrows);
|
||||
|
||||
font_height = font_info->ascent + font_info->descent;
|
||||
cs_start = ((cursor_state >> 8) & 0x3f) * font_height / font_height_orig;
|
||||
cs_end = (cursor_state & 0x1f) * font_height / font_height_orig;
|
||||
|
||||
// Number of characters on screen, variable number of rows
|
||||
ncols = dimension_x/8;
|
||||
nchars = ncols*nrows;
|
||||
nchars = columns*rows;
|
||||
|
||||
// first draw over character at original block cursor location
|
||||
if ( (prev_block_cursor_y*ncols + prev_block_cursor_x) < nchars ) {
|
||||
curs = (prev_block_cursor_y*ncols + prev_block_cursor_x)*2;
|
||||
if ( (prev_block_cursor_y*columns + prev_block_cursor_x) < nchars ) {
|
||||
curs = (prev_block_cursor_y*columns + prev_block_cursor_x)*2;
|
||||
string[0] = new_text[curs];
|
||||
if (string[0] == 0) string[0] = ' '; // convert null to space
|
||||
XSetForeground(bx_x_display, gc, col_vals[new_text[curs+1] & 0x0f]);
|
||||
XSetBackground(bx_x_display, gc, col_vals[(new_text[curs+1] & 0xf0) >> 4]);
|
||||
XDrawImageString(bx_x_display, win,
|
||||
gc,
|
||||
prev_block_cursor_x * font_info->max_bounds.width,
|
||||
prev_block_cursor_x * font_width,
|
||||
prev_block_cursor_y * font_height + font_info->max_bounds.ascent + bx_headerbar_y,
|
||||
(char *) string,
|
||||
1);
|
||||
@ -1056,12 +1055,12 @@ bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
|
||||
//XSetForeground(bx_x_display, gc, white_pixel);
|
||||
//XSetBackground(bx_x_display, gc, black_pixel);
|
||||
|
||||
x = (i/2) % ncols;
|
||||
y = (i/2) / ncols;
|
||||
x = (i/2) % columns;
|
||||
y = (i/2) / columns;
|
||||
|
||||
XDrawImageString(bx_x_display, win,
|
||||
gc,
|
||||
x * font_info->max_bounds.width,
|
||||
x * font_width,
|
||||
y * font_height + font_info->max_bounds.ascent + bx_headerbar_y,
|
||||
(char *) string,
|
||||
1);
|
||||
@ -1075,13 +1074,13 @@ bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
|
||||
XSetBackground(bx_x_display, gc, black_pixel);
|
||||
|
||||
// now draw character at new block cursor location in reverse
|
||||
if ( ( (cursor_y*ncols + cursor_x) < nchars ) && (cs_start <= cs_end) ) {
|
||||
if ( ( (cursor_y*columns + cursor_x) < nchars ) && (cs_start <= cs_end) ) {
|
||||
for (unsigned i = cs_start; i <= cs_end; i++)
|
||||
XDrawLine(bx_x_display, win,
|
||||
gc_inv,
|
||||
cursor_x * font_info->max_bounds.width,
|
||||
cursor_x * font_width,
|
||||
cursor_y * font_height + bx_headerbar_y + i,
|
||||
(cursor_x + 1) * font_info->max_bounds.width - 1,
|
||||
(cursor_x + 1) * font_width - 1,
|
||||
cursor_y * font_height + bx_headerbar_y + i
|
||||
);
|
||||
}
|
||||
@ -1215,8 +1214,14 @@ bx_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned
|
||||
bx_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
|
||||
{
|
||||
if (fheight > 0) {
|
||||
if (fheight != 16) {
|
||||
y = y * 16 / fheight;
|
||||
font_height_orig = fheight;
|
||||
rows = y / fheight;
|
||||
columns = x / 8;
|
||||
if (fheight != font_height) {
|
||||
y = rows * font_height;
|
||||
}
|
||||
if (font_width != 8) {
|
||||
x = columns * font_width;
|
||||
}
|
||||
}
|
||||
if ( (x != dimension_x) || (y != (dimension_y-bx_headerbar_y)) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user