Commit b2028ce844206a15054885b876570f8a3e068dbe
1 parent
2d35de35
Exists in
master
and in
5 other branches
Melhorando posicionamento na OIA
Showing
2 changed files
with
15 additions
and
13 deletions
Show diff stats
src/pw3270/v3270/oia.c
@@ -278,11 +278,22 @@ static void draw_undera(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, | @@ -278,11 +278,22 @@ static void draw_undera(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, | ||
278 | 278 | ||
279 | } | 279 | } |
280 | 280 | ||
281 | -void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect) | 281 | +static void draw_centered_text(cairo_t *cr, struct v3270_metrics *metrics, int x, int y, const gchar *str) |
282 | { | 282 | { |
283 | cairo_text_extents_t extents; | 283 | cairo_text_extents_t extents; |
284 | + cairo_text_extents(cr,str,&extents); | ||
285 | + cairo_move_to(cr,x+(((metrics->width+2)/2)-(extents.width/2)),y+extents.height+( (metrics->spacing/2) - (extents.height/2))); | ||
286 | + cairo_show_text(cr,str); | ||
287 | +} | ||
288 | + | ||
289 | +void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, const GdkRectangle *rect) | ||
290 | +{ | ||
284 | const gchar *str; | 291 | const gchar *str; |
285 | 292 | ||
293 | + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_BACKGROUND); | ||
294 | + cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); | ||
295 | + cairo_fill(cr); | ||
296 | + | ||
286 | gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); | 297 | gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); |
287 | cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); | 298 | cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); |
288 | cairo_stroke(cr); | 299 | cairo_stroke(cr); |
@@ -301,9 +312,7 @@ void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metri | @@ -301,9 +312,7 @@ void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metri | ||
301 | else | 312 | else |
302 | str = "?"; | 313 | str = "?"; |
303 | 314 | ||
304 | - cairo_text_extents(cr,str,&extents); | ||
305 | - cairo_move_to(cr,rect->x+((rect->width/2)-(extents.width/2)),rect->y+extents.height+( (rect->height/2) - (extents.height/2))); | ||
306 | - cairo_show_text(cr,str); | 315 | + draw_centered_text(cr,metrics,rect->x,rect->y,str); |
307 | 316 | ||
308 | } | 317 | } |
309 | 318 | ||
@@ -533,8 +542,6 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | @@ -533,8 +542,6 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | ||
533 | cairo_rectangle(cr, metrics->left, row, cols*metrics->width, metrics->spacing); | 542 | cairo_rectangle(cr, metrics->left, row, cols*metrics->width, metrics->spacing); |
534 | cairo_fill(cr); | 543 | cairo_fill(cr); |
535 | 544 | ||
536 | - gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); | ||
537 | - | ||
538 | for(f=0;f<G_N_ELEMENTS(right);f++) | 545 | for(f=0;f<G_N_ELEMENTS(right);f++) |
539 | { | 546 | { |
540 | GdkRectangle *r = rect+right[f].id; | 547 | GdkRectangle *r = rect+right[f].id; |
@@ -551,12 +558,7 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | @@ -551,12 +558,7 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | ||
551 | 558 | ||
552 | gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); | 559 | gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); |
553 | 560 | ||
554 | - const gchar *str = "4"; | ||
555 | - cairo_text_extents_t extents; | ||
556 | - | ||
557 | - cairo_text_extents(cr,str,&extents); | ||
558 | - cairo_move_to(cr,lCol+(((metrics->width+2)/2)-(extents.width/2)),row+extents.height+( (metrics->spacing/2) - (extents.height/2))); | ||
559 | - cairo_show_text(cr,str); | 561 | + draw_centered_text(cr,metrics,lCol,row,"4"); |
560 | 562 | ||
561 | cairo_stroke(cr); | 563 | cairo_stroke(cr); |
562 | cairo_rectangle(cr, lCol, row, metrics->width+2, metrics->spacing); | 564 | cairo_rectangle(cr, lCol, row, metrics->width+2, metrics->spacing); |
src/pw3270/v3270/private.h
@@ -253,7 +253,7 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3 | @@ -253,7 +253,7 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3 | ||
253 | void v3270_start_timer(GtkWidget *terminal); | 253 | void v3270_start_timer(GtkWidget *terminal); |
254 | void v3270_stop_timer(GtkWidget *terminal); | 254 | void v3270_stop_timer(GtkWidget *terminal); |
255 | 255 | ||
256 | -void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); | 256 | +void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, const GdkRectangle *rect); |
257 | void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); | 257 | void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); |
258 | 258 | ||
259 | void v3270_update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor); | 259 | void v3270_update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor); |