Commit 2ebc6b93313128071caf53aaa468b63446bb1847
1 parent
81d108b9
Exists in
master
and in
5 other branches
Separando informações de fonte numa estrutura independente
Showing
7 changed files
with
122 additions
and
118 deletions
Show diff stats
src/include/pw3270/v3270.h
src/pw3270/v3270/accessible.c
| ... | ... | @@ -308,10 +308,10 @@ static void v3270_accessible_get_character_extents( AtkText *text, |
| 308 | 308 | gdk_window_get_origin(window, x, y); |
| 309 | 309 | |
| 310 | 310 | // Get screen position |
| 311 | - *x += widget->metrics.left + ((offset%cols) * widget->metrics.width); | |
| 312 | - *y += widget->metrics.top + ((offset/cols) * widget->metrics.spacing); | |
| 313 | - *width = widget->metrics.width; | |
| 314 | - *height = widget->metrics.spacing; | |
| 311 | + *x += widget->font.left + ((offset%cols) * widget->font.width); | |
| 312 | + *y += widget->font.top + ((offset/cols) * widget->font.spacing); | |
| 313 | + *width = widget->font.width; | |
| 314 | + *height = widget->font.spacing; | |
| 315 | 315 | |
| 316 | 316 | if(coords == ATK_XY_WINDOW) |
| 317 | 317 | { |
| ... | ... | @@ -631,7 +631,7 @@ static AtkAttributeSet * v3270_accessible_get_run_attributes(AtkText *text, gint |
| 631 | 631 | // The font family name |
| 632 | 632 | attributes = add_attribute( attributes, |
| 633 | 633 | ATK_TEXT_ATTR_FAMILY_NAME, |
| 634 | - GTK_V3270(widget)->font_family ); | |
| 634 | + GTK_V3270(widget)->font.family ); | |
| 635 | 635 | |
| 636 | 636 | return attributes; |
| 637 | 637 | } | ... | ... |
src/pw3270/v3270/draw.c
| ... | ... | @@ -51,7 +51,7 @@ gboolean v3270_draw(GtkWidget * widget, cairo_t * cr) |
| 51 | 51 | |
| 52 | 52 | gdk_cairo_set_source_rgba(cr,terminal->color+V3270_COLOR_CROSS_HAIR); |
| 53 | 53 | |
| 54 | - cairo_rectangle(cr, 0,terminal->cursor.rect.y+terminal->metrics.height,allocation.width,1); | |
| 54 | + cairo_rectangle(cr, 0,terminal->cursor.rect.y+terminal->font.height,allocation.width,1); | |
| 55 | 55 | cairo_fill(cr); |
| 56 | 56 | |
| 57 | 57 | cairo_rectangle(cr, terminal->cursor.rect.x,0,1,terminal->oia_rect->y-3); |
| ... | ... | @@ -72,9 +72,9 @@ gboolean v3270_draw(GtkWidget * widget, cairo_t * cr) |
| 72 | 72 | else |
| 73 | 73 | { |
| 74 | 74 | cairo_rectangle(cr, terminal->cursor.rect.x, |
| 75 | - terminal->cursor.rect.y+terminal->metrics.height, | |
| 75 | + terminal->cursor.rect.y+terminal->font.height, | |
| 76 | 76 | terminal->cursor.rect.width, |
| 77 | - terminal->metrics.descent ); | |
| 77 | + terminal->font.descent ); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | cairo_fill(cr); |
| ... | ... | @@ -364,9 +364,9 @@ void v3270_reload(GtkWidget *widget) |
| 364 | 364 | lib3270_get_screen_size(terminal->host,&rows,&cols); |
| 365 | 365 | |
| 366 | 366 | memset(&rect,0,sizeof(rect)); |
| 367 | - rect.y = terminal->metrics.top; | |
| 368 | - rect.width = terminal->metrics.width; | |
| 369 | - rect.height = terminal->metrics.spacing; | |
| 367 | + rect.y = terminal->font.top; | |
| 368 | + rect.width = terminal->font.width; | |
| 369 | + rect.height = terminal->font.spacing; | |
| 370 | 370 | addr = 0; |
| 371 | 371 | cursor = lib3270_get_cursor_address(terminal->host); |
| 372 | 372 | |
| ... | ... | @@ -374,7 +374,7 @@ void v3270_reload(GtkWidget *widget) |
| 374 | 374 | { |
| 375 | 375 | int c; |
| 376 | 376 | |
| 377 | - rect.x = terminal->metrics.left; | |
| 377 | + rect.x = terminal->font.left; | |
| 378 | 378 | |
| 379 | 379 | for(c=0;c < cols;c++) |
| 380 | 380 | { |
| ... | ... | @@ -386,18 +386,18 @@ void v3270_reload(GtkWidget *widget) |
| 386 | 386 | if(addr == cursor) |
| 387 | 387 | v3270_update_cursor_rect(terminal,&rect,chr,attr); |
| 388 | 388 | |
| 389 | - v3270_draw_element(cr,chr,attr,terminal->host,terminal->metrics.height,&rect,terminal->color); | |
| 389 | + v3270_draw_element(cr,chr,attr,terminal->host,terminal->font.height,&rect,terminal->color); | |
| 390 | 390 | |
| 391 | 391 | addr++; |
| 392 | 392 | rect.x += rect.width; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - rect.y += terminal->metrics.spacing; | |
| 395 | + rect.y += terminal->font.spacing; | |
| 396 | 396 | |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - cairo_set_scaled_font(cr,terminal->font_scaled); | |
| 400 | - v3270_draw_oia(cr, terminal->host, rect.y, cols, &terminal->metrics, terminal->color,terminal->oia_rect); | |
| 399 | + cairo_set_scaled_font(cr,terminal->font.scaled); | |
| 400 | + v3270_draw_oia(cr, terminal->host, rect.y, cols, &terminal->font, terminal->color,terminal->oia_rect); | |
| 401 | 401 | |
| 402 | 402 | cairo_destroy(cr); |
| 403 | 403 | |
| ... | ... | @@ -423,16 +423,16 @@ void v3270_update_char(H3270 *session, int addr, unsigned char chr, unsigned sho |
| 423 | 423 | lib3270_get_screen_size(terminal->host,&rows,&cols); |
| 424 | 424 | |
| 425 | 425 | memset(&rect,0,sizeof(rect)); |
| 426 | - rect.x = terminal->metrics.left + ((addr % cols) * terminal->metrics.width); | |
| 427 | - rect.y = terminal->metrics.top + ((addr / cols) * terminal->metrics.spacing); | |
| 428 | - rect.width = terminal->metrics.width; | |
| 429 | - rect.height = terminal->metrics.spacing; | |
| 426 | + rect.x = terminal->font.left + ((addr % cols) * terminal->font.width); | |
| 427 | + rect.y = terminal->font.top + ((addr / cols) * terminal->font.spacing); | |
| 428 | + rect.width = terminal->font.width; | |
| 429 | + rect.height = terminal->font.spacing; | |
| 430 | 430 | |
| 431 | 431 | // trace("%s: c=%c attr=%04x addr=%d pos=%d,%d x=%d y=%d w=%d h=%d",__FUNCTION__,chr,(int) attr,addr,(addr / cols),(addr % cols),rect.x,rect.y,rect.width,rect.height); |
| 432 | 432 | |
| 433 | 433 | cr = cairo_create(terminal->surface); |
| 434 | - cairo_set_scaled_font(cr,terminal->font_scaled); | |
| 435 | - v3270_draw_element(cr, chr, attr, terminal->host, terminal->metrics.height, &rect,terminal->color); | |
| 434 | + cairo_set_scaled_font(cr,terminal->font.scaled); | |
| 435 | + v3270_draw_element(cr, chr, attr, terminal->host, terminal->font.height, &rect,terminal->color); | |
| 436 | 436 | cairo_destroy(cr); |
| 437 | 437 | if(cursor) |
| 438 | 438 | v3270_update_cursor_rect(terminal,&rect,chr,attr); |
| ... | ... | @@ -454,11 +454,11 @@ void v3270_update_cursor_surface(v3270 *widget,unsigned char chr,unsigned short |
| 454 | 454 | |
| 455 | 455 | get_element_colors(attr,&fg,&bg,widget->color); |
| 456 | 456 | |
| 457 | - cairo_set_scaled_font(cr,widget->font_scaled); | |
| 457 | + cairo_set_scaled_font(cr,widget->font.scaled); | |
| 458 | 458 | |
| 459 | 459 | rect.x = 0; |
| 460 | 460 | rect.y = 0; |
| 461 | - v3270_draw_char(cr,chr,attr,widget->host,widget->metrics.height,&rect,bg,fg); | |
| 461 | + v3270_draw_char(cr,chr,attr,widget->host,widget->font.height,&rect,bg,fg); | |
| 462 | 462 | |
| 463 | 463 | cairo_destroy(cr); |
| 464 | 464 | } |
| ... | ... | @@ -471,7 +471,7 @@ void v3270_update_cursor_rect(v3270 *widget, GdkRectangle *rect, unsigned char c |
| 471 | 471 | widget->cursor.chr = chr; |
| 472 | 472 | widget->cursor.rect = *rect; |
| 473 | 473 | widget->cursor.attr = attr; |
| 474 | - widget->cursor.rect.height = widget->metrics.height + widget->metrics.descent; | |
| 474 | + widget->cursor.rect.height = widget->font.height + widget->font.descent; | |
| 475 | 475 | v3270_update_cursor_surface(widget,chr,attr); |
| 476 | 476 | } |
| 477 | 477 | ... | ... |
src/pw3270/v3270/mouse.c
| ... | ... | @@ -49,12 +49,12 @@ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y) |
| 49 | 49 | GdkPoint point; |
| 50 | 50 | int r,c; |
| 51 | 51 | |
| 52 | - g_return_val_if_fail(widget->metrics.width > 0,-1); | |
| 52 | + g_return_val_if_fail(widget->font.width > 0,-1); | |
| 53 | 53 | |
| 54 | 54 | if(x > 0 && y > 0) |
| 55 | 55 | { |
| 56 | - point.x = ((x-widget->metrics.left)/widget->metrics.width); | |
| 57 | - point.y = ((y-widget->metrics.top)/widget->metrics.spacing); | |
| 56 | + point.x = ((x-widget->font.left)/widget->font.width); | |
| 57 | + point.y = ((y-widget->font.top)/widget->font.spacing); | |
| 58 | 58 | |
| 59 | 59 | lib3270_get_screen_size(widget->host,&r,&c); |
| 60 | 60 | ... | ... |
src/pw3270/v3270/oia.c
| ... | ... | @@ -47,7 +47,7 @@ |
| 47 | 47 | |
| 48 | 48 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
| 49 | 49 | |
| 50 | -static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_metrics *metrics, int row, int col); | |
| 50 | +static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, v3270FontInfo *metrics, int row, int col); | |
| 51 | 51 | |
| 52 | 52 | /*--[ Statics ]--------------------------------------------------------------------------------------*/ |
| 53 | 53 | |
| ... | ... | @@ -124,7 +124,7 @@ static gint draw_spinner(cairo_t *cr, GdkRectangle *r, GdkRGBA *color, gint step |
| 124 | 124 | } |
| 125 | 125 | #endif // HAVE_LIBM |
| 126 | 126 | |
| 127 | -static void setup_cursor_position(GdkRectangle *rect, struct v3270_metrics *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 127 | +static void setup_cursor_position(GdkRectangle *rect, v3270FontInfo *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 128 | 128 | { |
| 129 | 129 | rect->width = metrics->width * 8; |
| 130 | 130 | rect->x -= rect->width; |
| ... | ... | @@ -136,7 +136,7 @@ static void setup_cursor_position(GdkRectangle *rect, struct v3270_metrics *metr |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | -static void setup_timer_position(GdkRectangle *rect, struct v3270_metrics *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 139 | +static void setup_timer_position(GdkRectangle *rect, v3270FontInfo *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 140 | 140 | { |
| 141 | 141 | char buffer[7]; |
| 142 | 142 | cairo_text_extents_t extents; |
| ... | ... | @@ -151,14 +151,14 @@ static void setup_timer_position(GdkRectangle *rect, struct v3270_metrics *metri |
| 151 | 151 | rect->x -= rect->width; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | -static void setup_spinner_position(GdkRectangle *rect, struct v3270_metrics *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 154 | +static void setup_spinner_position(GdkRectangle *rect, v3270FontInfo *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 155 | 155 | { |
| 156 | 156 | rect->width = rect->height; |
| 157 | 157 | rect->x -= rect->width; |
| 158 | 158 | // draw_spinner(cr,rect,color,0); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | -static void setup_luname_position(GdkRectangle *rect, struct v3270_metrics *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 161 | +static void setup_luname_position(GdkRectangle *rect, v3270FontInfo *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 162 | 162 | { |
| 163 | 163 | const char *luname = lib3270_get_luname(host); |
| 164 | 164 | |
| ... | ... | @@ -190,7 +190,7 @@ static void setup_luname_position(GdkRectangle *rect, struct v3270_metrics *metr |
| 190 | 190 | |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | -static void setup_single_char_right(GdkRectangle *rect, struct v3270_metrics *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 193 | +static void setup_single_char_right(GdkRectangle *rect, v3270FontInfo *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 194 | 194 | { |
| 195 | 195 | rect->x -= rect->width; |
| 196 | 196 | |
| ... | ... | @@ -202,7 +202,7 @@ static void setup_single_char_right(GdkRectangle *rect, struct v3270_metrics *me |
| 202 | 202 | |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | -static void setup_insert_position(GdkRectangle *rect, struct v3270_metrics *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 205 | +static void setup_insert_position(GdkRectangle *rect, v3270FontInfo *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color) | |
| 206 | 206 | { |
| 207 | 207 | if(rect->width > rect->height) |
| 208 | 208 | { |
| ... | ... | @@ -239,7 +239,7 @@ static void setup_double_char_position(GdkRectangle *rect, struct v3270_metrics |
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | -static void draw_undera(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkRGBA *color, GdkRectangle *rect) | |
| 242 | +static void draw_undera(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect) | |
| 243 | 243 | { |
| 244 | 244 | #ifdef DEBUG |
| 245 | 245 | cairo_set_source_rgb(cr,0.1,0.1,0.1); |
| ... | ... | @@ -289,7 +289,7 @@ static void draw_centered_text(cairo_t *cr, struct v3270_metrics *metrics, int x |
| 289 | 289 | } |
| 290 | 290 | */ |
| 291 | 291 | |
| 292 | -static void draw_centered_char(cairo_t *cr, struct v3270_metrics *metrics, int x, int y, const gchar chr) | |
| 292 | +static void draw_centered_char(cairo_t *cr, v3270FontInfo *metrics, int x, int y, const gchar chr) | |
| 293 | 293 | { |
| 294 | 294 | char str[2] = { chr, 0 }; |
| 295 | 295 | |
| ... | ... | @@ -301,7 +301,7 @@ static void draw_centered_char(cairo_t *cr, struct v3270_metrics *metrics, int x |
| 301 | 301 | |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | -void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkRGBA *color, const GdkRectangle *rect) | |
| 304 | +void v3270_draw_connection(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGBA *color, const GdkRectangle *rect) | |
| 305 | 305 | { |
| 306 | 306 | gchar str = ' '; |
| 307 | 307 | |
| ... | ... | @@ -352,7 +352,7 @@ static void draw_xbm(cairo_t *cr, GdkRectangle *rect, int width, int height, uns |
| 352 | 352 | cairo_restore(cr); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | -void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkRGBA *color, GdkRectangle *rect) | |
| 355 | +void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect) | |
| 356 | 356 | { |
| 357 | 357 | #ifdef DEBUG |
| 358 | 358 | cairo_set_source_rgb(cr,0.1,0.1,0.1); |
| ... | ... | @@ -396,7 +396,7 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri |
| 396 | 396 | |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | -static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, struct v3270_metrics *metrics, GdkRGBA *color, GdkRectangle *rect) | |
| 399 | +static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect) | |
| 400 | 400 | { |
| 401 | 401 | #ifdef DEBUG |
| 402 | 402 | #define OIA_MESSAGE(x,c,y) { #x, c, y } |
| ... | ... | @@ -559,12 +559,12 @@ static void draw_insert(cairo_t *cr, H3270 *host, GdkRGBA *color, GdkRectangle * |
| 559 | 559 | |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | -void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkRGBA *color, GdkRectangle *rect) | |
| 562 | +void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect) | |
| 563 | 563 | { |
| 564 | 564 | static const struct _right_fields |
| 565 | 565 | { |
| 566 | 566 | V3270_OIA_FIELD id; |
| 567 | - void (*draw)(GdkRectangle *rect, struct v3270_metrics *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color); | |
| 567 | + void (*draw)(GdkRectangle *rect, v3270FontInfo *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color); | |
| 568 | 568 | } right[] = |
| 569 | 569 | { |
| 570 | 570 | { V3270_OIA_CURSOR_POSITION, setup_cursor_position }, |
| ... | ... | @@ -676,7 +676,7 @@ static cairo_t * set_update_region(v3270 * terminal, GdkRectangle **r, V3270_OIA |
| 676 | 676 | GdkRectangle * rect = terminal->oia_rect + id; |
| 677 | 677 | cairo_t * cr = cairo_create(terminal->surface); |
| 678 | 678 | |
| 679 | - cairo_set_scaled_font(cr,terminal->font_scaled); | |
| 679 | + cairo_set_scaled_font(cr,terminal->font.scaled); | |
| 680 | 680 | |
| 681 | 681 | cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); |
| 682 | 682 | cairo_clip(cr); |
| ... | ... | @@ -709,7 +709,7 @@ void v3270_update_luname(GtkWidget *widget,const gchar *name) |
| 709 | 709 | |
| 710 | 710 | if(name) |
| 711 | 711 | { |
| 712 | - cairo_move_to(cr,rect->x,rect->y+terminal->metrics.height); | |
| 712 | + cairo_move_to(cr,rect->x,rect->y+terminal->font.height); | |
| 713 | 713 | gdk_cairo_set_source_rgba(cr,terminal->color+V3270_COLOR_OIA_LUNAME); |
| 714 | 714 | cairo_show_text(cr,name); |
| 715 | 715 | cairo_stroke(cr); |
| ... | ... | @@ -738,7 +738,7 @@ void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id) |
| 738 | 738 | |
| 739 | 739 | cr = set_update_region(widget,&rect,V3270_OIA_MESSAGE); |
| 740 | 740 | |
| 741 | - draw_status_message(cr,id,&widget->metrics,widget->color,rect); | |
| 741 | + draw_status_message(cr,id,&widget->font,widget->color,rect); | |
| 742 | 742 | |
| 743 | 743 | cairo_destroy(cr); |
| 744 | 744 | |
| ... | ... | @@ -749,7 +749,7 @@ void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id) |
| 749 | 749 | |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | -static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_metrics *metrics, int row, int col) | |
| 752 | +static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, v3270FontInfo *metrics, int row, int col) | |
| 753 | 753 | { |
| 754 | 754 | cairo_text_extents_t extents; |
| 755 | 755 | char buffer[10]; |
| ... | ... | @@ -777,10 +777,10 @@ void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, |
| 777 | 777 | // Update cursor rectangle |
| 778 | 778 | saved = terminal->cursor.rect; |
| 779 | 779 | |
| 780 | - terminal->cursor.rect.x = terminal->metrics.left + (col * terminal->cursor.rect.width); | |
| 781 | - terminal->cursor.rect.y = terminal->metrics.top + (row * terminal->metrics.spacing); | |
| 782 | - terminal->cursor.rect.width = terminal->metrics.width; | |
| 783 | - terminal->cursor.rect.height = terminal->metrics.height+terminal->metrics.descent; | |
| 780 | + terminal->cursor.rect.x = terminal->font.left + (col * terminal->cursor.rect.width); | |
| 781 | + terminal->cursor.rect.y = terminal->font.top + (row * terminal->font.spacing); | |
| 782 | + terminal->cursor.rect.width = terminal->font.width; | |
| 783 | + terminal->cursor.rect.height = terminal->font.height+terminal->font.descent; | |
| 784 | 784 | terminal->cursor.show |= 1; |
| 785 | 785 | |
| 786 | 786 | gtk_widget_queue_draw_area( GTK_WIDGET(terminal), saved.x, |
| ... | ... | @@ -800,10 +800,10 @@ void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, |
| 800 | 800 | GtkAllocation allocation; |
| 801 | 801 | gtk_widget_get_allocation(GTK_WIDGET(terminal), &allocation); |
| 802 | 802 | |
| 803 | - gtk_widget_queue_draw_area(GTK_WIDGET(terminal),0,saved.y+terminal->metrics.height,allocation.width,1); | |
| 803 | + gtk_widget_queue_draw_area(GTK_WIDGET(terminal),0,saved.y+terminal->font.height,allocation.width,1); | |
| 804 | 804 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),saved.x,0,1,terminal->oia_rect->y-3); |
| 805 | 805 | |
| 806 | - gtk_widget_queue_draw_area(GTK_WIDGET(terminal),0,terminal->cursor.rect.y+terminal->metrics.height,allocation.width,1); | |
| 806 | + gtk_widget_queue_draw_area(GTK_WIDGET(terminal),0,terminal->cursor.rect.y+terminal->font.height,allocation.width,1); | |
| 807 | 807 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),terminal->cursor.rect.x,0,1,terminal->oia_rect->y-3); |
| 808 | 808 | } |
| 809 | 809 | |
| ... | ... | @@ -815,7 +815,7 @@ void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, |
| 815 | 815 | |
| 816 | 816 | cr = set_update_region(terminal,&rect,V3270_OIA_CURSOR_POSITION); |
| 817 | 817 | |
| 818 | - draw_cursor_position(cr,rect,&terminal->metrics,row,col); | |
| 818 | + draw_cursor_position(cr,rect,&terminal->font,row,col); | |
| 819 | 819 | |
| 820 | 820 | cairo_destroy(cr); |
| 821 | 821 | |
| ... | ... | @@ -940,7 +940,7 @@ static void update_text_field(v3270 *terminal, gboolean flag, V3270_OIA_FIELD id |
| 940 | 940 | |
| 941 | 941 | if(flag) |
| 942 | 942 | { |
| 943 | - cairo_move_to(cr,0,terminal->metrics.height); | |
| 943 | + cairo_move_to(cr,0,terminal->font.height); | |
| 944 | 944 | cairo_show_text(cr, text); |
| 945 | 945 | cairo_stroke(cr); |
| 946 | 946 | } |
| ... | ... | @@ -1007,8 +1007,8 @@ static gboolean update_timer(struct timer_info *info) |
| 1007 | 1007 | short2string(buffer+3,seconds%60,2); |
| 1008 | 1008 | buffer[5] = 0; |
| 1009 | 1009 | |
| 1010 | - cairo_set_scaled_font(cr,info->terminal->font_scaled); | |
| 1011 | - cairo_move_to(cr,rect->x,rect->y+info->terminal->metrics.height); | |
| 1010 | + cairo_set_scaled_font(cr,info->terminal->font.scaled); | |
| 1011 | + cairo_move_to(cr,rect->x,rect->y+info->terminal->font.height); | |
| 1012 | 1012 | cairo_show_text(cr, buffer); |
| 1013 | 1013 | cairo_stroke(cr); |
| 1014 | 1014 | |
| ... | ... | @@ -1092,7 +1092,7 @@ void v3270_update_ssl(H3270 *session, LIB3270_SSL_STATE state) |
| 1092 | 1092 | return; |
| 1093 | 1093 | |
| 1094 | 1094 | cr = set_update_region(terminal,&r,V3270_OIA_SSL); |
| 1095 | - v3270_draw_ssl_status(cr,terminal->host,&terminal->metrics,terminal->color,r); | |
| 1095 | + v3270_draw_ssl_status(cr,terminal->host,&terminal->font,terminal->color,r); | |
| 1096 | 1096 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); |
| 1097 | 1097 | cairo_destroy(cr); |
| 1098 | 1098 | |
| ... | ... | @@ -1113,7 +1113,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) |
| 1113 | 1113 | case LIB3270_FLAG_BOXSOLID: |
| 1114 | 1114 | debug("%s",__FUNCTION__); |
| 1115 | 1115 | cr = set_update_region(terminal,&r,V3270_OIA_CONNECTION); |
| 1116 | - v3270_draw_connection(cr,terminal->host,&terminal->metrics,terminal->color,r); | |
| 1116 | + v3270_draw_connection(cr,terminal->host,&terminal->font,terminal->color,r); | |
| 1117 | 1117 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); |
| 1118 | 1118 | cairo_destroy(cr); |
| 1119 | 1119 | break; |
| ... | ... | @@ -1121,7 +1121,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) |
| 1121 | 1121 | case LIB3270_FLAG_UNDERA: |
| 1122 | 1122 | debug("%s",__FUNCTION__); |
| 1123 | 1123 | cr = set_update_region(terminal,&r,V3270_OIA_UNDERA); |
| 1124 | - draw_undera(cr,terminal->host,&terminal->metrics,terminal->color,r); | |
| 1124 | + draw_undera(cr,terminal->host,&terminal->font,terminal->color,r); | |
| 1125 | 1125 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); |
| 1126 | 1126 | cairo_destroy(cr); |
| 1127 | 1127 | break; | ... | ... |
src/pw3270/v3270/private.h
| ... | ... | @@ -24,8 +24,6 @@ |
| 24 | 24 | * |
| 25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
| 26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
| 27 | - * licinio@bb.com.br (Licínio Luis Branco) | |
| 28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
| 29 | 27 | * |
| 30 | 28 | */ |
| 31 | 29 | |
| ... | ... | @@ -109,19 +107,6 @@ G_BEGIN_DECLS |
| 109 | 107 | #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+11 |
| 110 | 108 | |
| 111 | 109 | |
| 112 | - struct v3270_metrics | |
| 113 | - { | |
| 114 | - guint width; | |
| 115 | - guint height; | |
| 116 | - guint ascent; | |
| 117 | - guint descent; | |
| 118 | - | |
| 119 | - guint spacing; | |
| 120 | - | |
| 121 | - guint left; | |
| 122 | - guint top; | |
| 123 | - }; | |
| 124 | - | |
| 125 | 110 | struct v3270_ssl_status_msg |
| 126 | 111 | { |
| 127 | 112 | long id; |
| ... | ... | @@ -130,6 +115,28 @@ G_BEGIN_DECLS |
| 130 | 115 | const gchar * message; |
| 131 | 116 | }; |
| 132 | 117 | |
| 118 | + /** | |
| 119 | + * @brief Informações para desenho de fontes com o cairo. | |
| 120 | + * | |
| 121 | + */ | |
| 122 | + struct _v3270FontInfo { | |
| 123 | + | |
| 124 | + guint width; | |
| 125 | + guint height; | |
| 126 | + guint ascent; | |
| 127 | + guint descent; | |
| 128 | + | |
| 129 | + guint spacing; | |
| 130 | + | |
| 131 | + guint left; | |
| 132 | + guint top; | |
| 133 | + | |
| 134 | + gchar * family; | |
| 135 | + cairo_font_weight_t weight; | |
| 136 | + cairo_scaled_font_t * scaled; | |
| 137 | + | |
| 138 | + }; | |
| 139 | + | |
| 133 | 140 | /*--[ Widget data ]----------------------------------------------------------------------------------*/ |
| 134 | 141 | |
| 135 | 142 | struct _v3270 |
| ... | ... | @@ -166,18 +173,14 @@ G_BEGIN_DECLS |
| 166 | 173 | V3270_OIA_FIELD selected_field; /**< Clicked OIA field */ |
| 167 | 174 | |
| 168 | 175 | // Font info |
| 169 | - gchar * font_family; | |
| 170 | - cairo_font_weight_t font_weight; | |
| 171 | - cairo_scaled_font_t * font_scaled; | |
| 172 | 176 | cairo_surface_t * surface; |
| 173 | - | |
| 174 | - struct v3270_metrics metrics; | |
| 177 | + v3270FontInfo font; | |
| 175 | 178 | |
| 176 | 179 | gint minimum_width; |
| 177 | 180 | gint minimum_height; |
| 178 | 181 | |
| 179 | 182 | // Colors |
| 180 | - GdkRGBA color[V3270_COLOR_COUNT]; /**< Terminal widget colors */ | |
| 183 | + GdkRGBA color[V3270_COLOR_COUNT]; /**< Terminal widget colors */ | |
| 181 | 184 | |
| 182 | 185 | // Regions |
| 183 | 186 | GdkRectangle oia_rect[V3270_OIA_FIELD_COUNT]; |
| ... | ... | @@ -252,7 +255,7 @@ G_BEGIN_DECLS |
| 252 | 255 | const GtkWidgetClass * v3270_get_parent_class(void); |
| 253 | 256 | |
| 254 | 257 | gboolean v3270_draw(GtkWidget * widget, cairo_t * cr); |
| 255 | -void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkRGBA *color, GdkRectangle *rect); | |
| 258 | +void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect); | |
| 256 | 259 | void v3270_update_mouse_pointer(GtkWidget *widget); |
| 257 | 260 | |
| 258 | 261 | #if ! GTK_CHECK_VERSION(2,18,0) |
| ... | ... | @@ -292,8 +295,8 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3 |
| 292 | 295 | void v3270_start_timer(GtkWidget *terminal); |
| 293 | 296 | void v3270_stop_timer(GtkWidget *terminal); |
| 294 | 297 | |
| 295 | -void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkRGBA *color, const GdkRectangle *rect); | |
| 296 | -void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkRGBA *color, GdkRectangle *rect); | |
| 298 | +void v3270_draw_connection(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGBA *color, const GdkRectangle *rect); | |
| 299 | +void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect); | |
| 297 | 300 | |
| 298 | 301 | void v3270_update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor); |
| 299 | 302 | ... | ... |
src/pw3270/v3270/widget.c
| ... | ... | @@ -54,8 +54,8 @@ |
| 54 | 54 | #define WIDTH_IN_PIXELS(terminal,x) (x * cols) |
| 55 | 55 | #define HEIGHT_IN_PIXELS(terminal,x) (x * (rows+1)) |
| 56 | 56 | |
| 57 | - #define CONTENTS_WIDTH(terminal) (cols * terminal->metrics.width) | |
| 58 | - #define CONTENTS_HEIGHT(terminal) (((rows+1) * terminal->metrics.spacing)+OIA_TOP_MARGIN+2) | |
| 57 | + #define CONTENTS_WIDTH(terminal) (cols * terminal->font.width) | |
| 58 | + #define CONTENTS_HEIGHT(terminal) (((rows+1) * terminal->font.spacing)+OIA_TOP_MARGIN+2) | |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * SECTION: v3270 |
| ... | ... | @@ -554,11 +554,11 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig |
| 554 | 554 | |
| 555 | 555 | lib3270_get_screen_size(terminal->host,&rows,&cols); |
| 556 | 556 | |
| 557 | - terminal->font_weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | |
| 557 | + terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | |
| 558 | 558 | |
| 559 | - cairo_select_font_face(cr, terminal->font_family, CAIRO_FONT_SLANT_NORMAL,terminal->font_weight); | |
| 559 | + cairo_select_font_face(cr,terminal->font.family, CAIRO_FONT_SLANT_NORMAL,terminal->font.weight); | |
| 560 | 560 | |
| 561 | - if(terminal->scaled_fonts) | |
| 561 | + if(terminal->font.scaled) | |
| 562 | 562 | { |
| 563 | 563 | double w = ((double) width) / ((double)cols); |
| 564 | 564 | double h = ((double) height) / ((double) (rows+2)); |
| ... | ... | @@ -612,38 +612,38 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig |
| 612 | 612 | cairo_font_extents(cr,&extents); |
| 613 | 613 | |
| 614 | 614 | // Save scaled font for use on next drawings |
| 615 | - if(terminal->font_scaled) | |
| 616 | - cairo_scaled_font_destroy(terminal->font_scaled); | |
| 615 | + if(terminal->font.scaled) | |
| 616 | + cairo_scaled_font_destroy(terminal->font.scaled); | |
| 617 | 617 | |
| 618 | - terminal->font_scaled = cairo_get_scaled_font(cr); | |
| 619 | - cairo_scaled_font_reference(terminal->font_scaled); | |
| 618 | + terminal->font.scaled = cairo_get_scaled_font(cr); | |
| 619 | + cairo_scaled_font_reference(terminal->font.scaled); | |
| 620 | 620 | |
| 621 | - cairo_scaled_font_extents(terminal->font_scaled,&extents); | |
| 621 | + cairo_scaled_font_extents(terminal->font.scaled,&extents); | |
| 622 | 622 | |
| 623 | - terminal->metrics.width = (int) extents.max_x_advance; | |
| 624 | - terminal->metrics.height = (int) extents.height; | |
| 625 | - terminal->metrics.ascent = (int) extents.ascent; | |
| 626 | - terminal->metrics.descent = (int) extents.descent; | |
| 623 | + terminal->font.width = (int) extents.max_x_advance; | |
| 624 | + terminal->font.height = (int) extents.height; | |
| 625 | + terminal->font.ascent = (int) extents.ascent; | |
| 626 | + terminal->font.descent = (int) extents.descent; | |
| 627 | 627 | |
| 628 | - hFont = terminal->metrics.height + terminal->metrics.descent; | |
| 628 | + hFont = terminal->font.height + terminal->font.descent; | |
| 629 | 629 | |
| 630 | 630 | // Create new cursor surface |
| 631 | 631 | if(terminal->cursor.surface) |
| 632 | 632 | cairo_surface_destroy(terminal->cursor.surface); |
| 633 | 633 | |
| 634 | - terminal->cursor.surface = gdk_window_create_similar_surface(gtk_widget_get_window(GTK_WIDGET(terminal)),CAIRO_CONTENT_COLOR,terminal->metrics.width,hFont); | |
| 634 | + terminal->cursor.surface = gdk_window_create_similar_surface(gtk_widget_get_window(GTK_WIDGET(terminal)),CAIRO_CONTENT_COLOR,terminal->font.width,hFont); | |
| 635 | 635 | |
| 636 | 636 | // Center image |
| 637 | 637 | size = CONTENTS_WIDTH(terminal); |
| 638 | - terminal->metrics.left = (width >> 1) - ((size) >> 1); | |
| 638 | + terminal->font.left = (width >> 1) - ((size) >> 1); | |
| 639 | 639 | |
| 640 | - terminal->metrics.spacing = height / (rows+2); | |
| 641 | - if(terminal->metrics.spacing < hFont) | |
| 642 | - terminal->metrics.spacing = hFont; | |
| 640 | + terminal->font.spacing = height / (rows+2); | |
| 641 | + if(terminal->font.spacing < hFont) | |
| 642 | + terminal->font.spacing = hFont; | |
| 643 | 643 | |
| 644 | 644 | size = CONTENTS_HEIGHT(terminal); |
| 645 | 645 | |
| 646 | - terminal->metrics.top = (height >> 1) - (size >> 1); | |
| 646 | + terminal->font.top = (height >> 1) - (size >> 1); | |
| 647 | 647 | |
| 648 | 648 | } |
| 649 | 649 | |
| ... | ... | @@ -1021,16 +1021,16 @@ static void v3270_destroy(GtkObject *widget) |
| 1021 | 1021 | terminal->host = NULL; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | - if(terminal->font_family) | |
| 1024 | + if(terminal->font.family) | |
| 1025 | 1025 | { |
| 1026 | - g_free(terminal->font_family); | |
| 1027 | - terminal->font_family = 0; | |
| 1026 | + g_free(terminal->font.family); | |
| 1027 | + terminal->font.family = 0; | |
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | - if(terminal->font_scaled) | |
| 1030 | + if(terminal->font.scaled) | |
| 1031 | 1031 | { |
| 1032 | - cairo_scaled_font_destroy(terminal->font_scaled); | |
| 1033 | - terminal->font_scaled = NULL; | |
| 1032 | + cairo_scaled_font_destroy(terminal->font.scaled); | |
| 1033 | + terminal->font.scaled = NULL; | |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | if(terminal->surface) |
| ... | ... | @@ -1455,18 +1455,18 @@ void v3270_set_font_family(GtkWidget *widget, const gchar *name) |
| 1455 | 1455 | name = "courier new"; |
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | - if(terminal->font_family) | |
| 1458 | + if(terminal->font.family) | |
| 1459 | 1459 | { |
| 1460 | - if(!g_ascii_strcasecmp(terminal->font_family,name)) | |
| 1460 | + if(!g_ascii_strcasecmp(terminal->font.family,name)) | |
| 1461 | 1461 | return; |
| 1462 | - g_free(terminal->font_family); | |
| 1463 | - terminal->font_family = NULL; | |
| 1462 | + g_free(terminal->font.family); | |
| 1463 | + terminal->font.family = NULL; | |
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | - terminal->font_family = g_strdup(name); | |
| 1467 | - terminal->font_weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | |
| 1466 | + terminal->font.family = g_strdup(name); | |
| 1467 | + terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | |
| 1468 | 1468 | |
| 1469 | - trace("%s: %s (%p)",__FUNCTION__,terminal->font_family,terminal->font_family); | |
| 1469 | + trace("%s: %s (%p)",__FUNCTION__,terminal->font.family,terminal->font.family); | |
| 1470 | 1470 | |
| 1471 | 1471 | g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "font-family", name); |
| 1472 | 1472 | |
| ... | ... | @@ -1479,7 +1479,7 @@ void v3270_set_font_family(GtkWidget *widget, const gchar *name) |
| 1479 | 1479 | const gchar * v3270_get_font_family(GtkWidget *widget) |
| 1480 | 1480 | { |
| 1481 | 1481 | g_return_val_if_fail(GTK_IS_V3270(widget),NULL); |
| 1482 | - return GTK_V3270(widget)->font_family; | |
| 1482 | + return GTK_V3270(widget)->font.family; | |
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | void v3270_disconnect(GtkWidget *widget) | ... | ... |