diff --git a/pw3270.cbp b/pw3270.cbp
index a3ecde0..dc3cc35 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -440,6 +440,7 @@
+
diff --git a/src/pw3270/v3270/draw.c b/src/pw3270/v3270/draw.c
index 39a9154..b4a58bf 100644
--- a/src/pw3270/v3270/draw.c
+++ b/src/pw3270/v3270/draw.c
@@ -30,8 +30,11 @@
#include
#include
#include
+ #include
#include
+ #include
#include
+
#include
#include "private.h"
@@ -142,8 +145,47 @@ void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H32
}
+void v3270_draw_text_at(cairo_t *cr, int x, int y, v3270FontInfo *font, const char *str) {
+
+ size_t szText = strlen(str);
+
+ if(szText == 1 && isspace(*str)) {
+ return;
+ }
+
+ // Tem string, desenha
+ cairo_status_t status;
+ cairo_glyph_t * glyphs = NULL;
+ int num_glyphs = 0;
+ cairo_text_cluster_t * clusters = NULL;
+ int num_clusters = 0;
+ cairo_text_cluster_flags_t cluster_flags;
+ cairo_scaled_font_t * scaled_font = cairo_get_scaled_font(cr);
+
+ status = cairo_scaled_font_text_to_glyphs(
+ scaled_font,
+ (double) x, (double) (y+font->height),
+ str, szText,
+ &glyphs, &num_glyphs,
+ &clusters, &num_clusters, &cluster_flags );
+
+ if (status == CAIRO_STATUS_SUCCESS) {
+ cairo_show_text_glyphs(cr,str,szText,glyphs, num_glyphs,clusters, num_clusters, cluster_flags);
+ }
+
+ if(glyphs)
+ cairo_glyph_free(glyphs);
+
+ if(clusters)
+ cairo_text_cluster_free(clusters);
+
+}
+
void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font, const char *str) {
+ v3270_draw_text_at(cr,rect->x,rect->y,font,str);
+
+/*
cairo_status_t status;
cairo_glyph_t * glyphs = NULL;
int num_glyphs = 0;
@@ -168,7 +210,7 @@ void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font,
if(clusters)
cairo_text_cluster_free(clusters);
-
+*/
}
void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg)
@@ -470,6 +512,7 @@ void v3270_update_cursor_rect(v3270 *widget, GdkRectangle *rect, unsigned char c
void v3270_queue_draw_area(GtkWidget *widget, gint x, gint y, gint width, gint height)
{
+
if(GTK_V3270(widget)->drawing && gtk_widget_get_realized(widget))
{
gtk_widget_queue_draw_area(widget,x,y,width,height);
diff --git a/src/pw3270/v3270/oia.c b/src/pw3270/v3270/oia.c
index 5013310..b6abc9a 100644
--- a/src/pw3270/v3270/oia.c
+++ b/src/pw3270/v3270/oia.c
@@ -180,13 +180,8 @@ static void setup_luname_position(GdkRectangle *rect, v3270FontInfo *font, cairo
if(luname)
{
-// cairo_move_to(cr,rect->x,rect->y+font->height);
-
gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_LUNAME);
v3270_draw_text(cr,rect,font,luname);
-
-// cairo_show_text(cr,luname);
-// cairo_stroke(cr);
}
cairo_restore(cr);
@@ -242,55 +237,41 @@ static void setup_double_char_position(GdkRectangle *rect, v3270FontInfo *metric
}
+static int draw_centered_char(cairo_t *cr, v3270FontInfo *metrics, int x, int y, const gchar chr)
+{
+ char str[2] = { chr, 0 };
+// cairo_text_extents_t extents;
+
+ cairo_set_scaled_font(cr,metrics->scaled);
+// cairo_text_extents(cr,str,&extents);
+
+ v3270_draw_text_at(cr, x, y, metrics, str);
+
+ return y+metrics->height+2;
+
+}
+
static void draw_undera(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect)
{
-#ifdef DEBUG
- cairo_set_source_rgb(cr,0.1,0.1,0.1);
-#else
gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_BACKGROUND);
-#endif
cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
cairo_fill(cr);
if(lib3270_get_undera(host))
{
- const gchar *chr = lib3270_in_e(host) ? "B" : "A";
- cairo_text_extents_t extents;
- int x,y;
-
- gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_BACKGROUND);
- cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
- cairo_fill(cr);
+ int y;
gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_FOREGROUND);
- cairo_text_extents(cr,chr,&extents);
-
- x = rect->x + ((rect->width/2) - ((extents.width+extents.x_bearing)/2));
- y = rect->y + extents.height+((rect->height/2) - (extents.height/2));
-
- cairo_move_to(cr,x,y);
- cairo_show_text(cr,chr);
-
- cairo_move_to(cr,x+extents.x_bearing,y+2);
- cairo_rel_line_to(cr,extents.width,0);
+ y = draw_centered_char(cr, metrics,rect->x,rect->y, lib3270_in_e(host) ? 'B' : 'A');
+ cairo_move_to(cr,rect->x,y);
+ cairo_rel_line_to(cr,10,0);
cairo_stroke(cr);
}
-
-}
-
-static void draw_centered_char(cairo_t *cr, v3270FontInfo *metrics, int x, int y, const gchar chr)
-{
- char str[2] = { chr, 0 };
-
- 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);
+ debug("%s",__FUNCTION__);
}
@@ -706,10 +687,12 @@ void v3270_update_luname(GtkWidget *widget,const gchar *name)
if(name)
{
- cairo_move_to(cr,rect->x,rect->y+terminal->font.height);
+// cairo_move_to(cr,rect->x,rect->y+terminal->font.height);
+// cairo_show_text(cr,name);
+// cairo_stroke(cr);
gdk_cairo_set_source_rgba(cr,terminal->color+V3270_COLOR_OIA_LUNAME);
- cairo_show_text(cr,name);
- cairo_stroke(cr);
+ v3270_draw_text_at(cr, rect->x, rect->y, &terminal->font, name);
+
}
cairo_destroy(cr);
@@ -757,10 +740,7 @@ static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, v3270FontInfo
buffer[7] = 0;
cairo_text_extents(cr,buffer,&extents);
-
- cairo_move_to(cr,(rect->x+rect->width)-(extents.width+2),rect->y+metrics->height);
- cairo_show_text(cr, buffer);
- cairo_stroke(cr);
+ v3270_draw_text_at(cr,(rect->x+rect->width)-(extents.width+2),rect->y,metrics,buffer);
}
void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr)
@@ -937,9 +917,10 @@ static void update_text_field(v3270 *terminal, gboolean flag, V3270_OIA_FIELD id
if(flag)
{
- cairo_move_to(cr,0,terminal->font.height);
- cairo_show_text(cr, text);
- cairo_stroke(cr);
+ v3270_draw_text_at(cr,0,0,&terminal->font,text);
+// cairo_move_to(cr,0,terminal->font.height);
+// cairo_show_text(cr, text);
+// cairo_stroke(cr);
}
cairo_destroy(cr);
@@ -1108,29 +1089,33 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on)
switch(id)
{
case LIB3270_FLAG_BOXSOLID:
- debug("%s",__FUNCTION__);
+ debug("%s LIB3270_FLAG_BOXSOLID",__FUNCTION__);
cr = set_update_region(terminal,&r,V3270_OIA_CONNECTION);
v3270_draw_connection(cr,terminal->host,&terminal->font,terminal->color,r);
- v3270_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height);
cairo_destroy(cr);
+ v3270_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height);
break;
case LIB3270_FLAG_UNDERA:
- debug("%s",__FUNCTION__);
+ debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__);
cr = set_update_region(terminal,&r,V3270_OIA_UNDERA);
+ debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__);
draw_undera(cr,terminal->host,&terminal->font,terminal->color,r);
- v3270_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height);
+ debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__);
cairo_destroy(cr);
+ debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__);
+ v3270_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height);
+ debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__);
break;
case LIB3270_FLAG_TYPEAHEAD:
- debug("%s",__FUNCTION__);
+ debug("%s LIB3270_FLAG_TYPEAHEAD",__FUNCTION__);
update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,'T');
break;
#ifdef HAVE_PRINTER
case LIB3270_FLAG_PRINTER:
- debug("%s",__FUNCTION__);
+ debug("%s LIB3270_FLAG_PRINTER",__FUNCTION__);
update_text_field(terminal,on,V3270_OIA_PRINTER,'P');
break;
#endif // HAVE_PRINTER
diff --git a/src/pw3270/v3270/private.h b/src/pw3270/v3270/private.h
index 80feaa1..e1ad649 100644
--- a/src/pw3270/v3270/private.h
+++ b/src/pw3270/v3270/private.h
@@ -271,6 +271,7 @@ void v3270_register_io_handlers(v3270Class *cls);
void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg);
void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font, const char *str);
+void v3270_draw_text_at(cairo_t *cr, int x, int y, v3270FontInfo *font, const char *str);
void v3270_start_timer(GtkWidget *terminal);
void v3270_stop_timer(GtkWidget *terminal);
--
libgit2 0.21.2