From b2028ce844206a15054885b876570f8a3e068dbe Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 10 Apr 2013 13:14:09 +0000 Subject: [PATCH] Melhorando posicionamento na OIA --- src/pw3270/v3270/oia.c | 26 ++++++++++++++------------ src/pw3270/v3270/private.h | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/pw3270/v3270/oia.c b/src/pw3270/v3270/oia.c index 2352291..57dc512 100644 --- a/src/pw3270/v3270/oia.c +++ b/src/pw3270/v3270/oia.c @@ -278,11 +278,22 @@ static void draw_undera(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, } -void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect) +static void draw_centered_text(cairo_t *cr, struct v3270_metrics *metrics, int x, int y, const gchar *str) { cairo_text_extents_t extents; + cairo_text_extents(cr,str,&extents); + cairo_move_to(cr,x+(((metrics->width+2)/2)-(extents.width/2)),y+extents.height+( (metrics->spacing/2) - (extents.height/2))); + cairo_show_text(cr,str); +} + +void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, const GdkRectangle *rect) +{ const gchar *str; + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_BACKGROUND); + cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); + cairo_fill(cr); + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); cairo_stroke(cr); @@ -301,9 +312,7 @@ void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metri else str = "?"; - cairo_text_extents(cr,str,&extents); - cairo_move_to(cr,rect->x+((rect->width/2)-(extents.width/2)),rect->y+extents.height+( (rect->height/2) - (extents.height/2))); - cairo_show_text(cr,str); + draw_centered_text(cr,metrics,rect->x,rect->y,str); } @@ -533,8 +542,6 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me cairo_rectangle(cr, metrics->left, row, cols*metrics->width, metrics->spacing); cairo_fill(cr); - gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); - for(f=0;fwidth+2)/2)-(extents.width/2)),row+extents.height+( (metrics->spacing/2) - (extents.height/2))); - cairo_show_text(cr,str); + draw_centered_text(cr,metrics,lCol,row,"4"); cairo_stroke(cr); cairo_rectangle(cr, lCol, row, metrics->width+2, metrics->spacing); diff --git a/src/pw3270/v3270/private.h b/src/pw3270/v3270/private.h index bb574a5..0e54959 100644 --- a/src/pw3270/v3270/private.h +++ b/src/pw3270/v3270/private.h @@ -253,7 +253,7 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3 void v3270_start_timer(GtkWidget *terminal); void v3270_stop_timer(GtkWidget *terminal); -void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); +void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, const GdkRectangle *rect); void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); void v3270_update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor); -- libgit2 0.21.2