Commit a75072d6d157a92b290c55d8d25d80df76ab3a2f

Authored by perry.werneck@gmail.com
1 parent 462bca78

Iniciando remoção da cairo-toy

src/include/pw3270/v3270.h
... ... @@ -225,7 +225,7 @@
225 225 LIB3270_EXPORT void v3270_set_color_table(GdkRGBA *table, const gchar *colors);
226 226 LIB3270_EXPORT const GdkRGBA * v3270_get_color_table(GtkWidget *widget);
227 227 LIB3270_EXPORT void v3270_set_mono_color_table(GdkRGBA *table, const gchar *fg, const gchar *bg);
228   - LIB3270_EXPORT void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, guint height, GdkRectangle *rect, GdkRGBA *color);
  228 + LIB3270_EXPORT void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *color);
229 229 LIB3270_EXPORT void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, GdkRGBA *color);
230 230 LIB3270_EXPORT GdkRGBA * v3270_get_color(GtkWidget *widget, enum V3270_COLOR id);
231 231  
... ...
src/pw3270/print.c
... ... @@ -189,7 +189,7 @@
189 189 {
190 190 if(!info->show_selection)
191 191 attr &= ~LIB3270_ATTR_SELECTED;
192   - v3270_draw_element(cr,c,attr,info->session,info->font.height,&rect,info->color);
  192 + v3270_draw_element(cr,c,attr,info->session,&info->font,&rect,info->color);
193 193 }
194 194  
195 195 rect.x += (rect.width-1);
... ...
src/pw3270/v3270/draw.c
... ... @@ -112,13 +112,13 @@ static void get_element_colors(unsigned short attr, GdkRGBA **fg, GdkRGBA **bg,
112 112 }
113 113 }
114 114  
115   -void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, guint height, GdkRectangle *rect, GdkRGBA *color)
  115 +void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *fontInfo, GdkRectangle *rect, GdkRGBA *color)
116 116 {
117 117 GdkRGBA *fg;
118 118 GdkRGBA *bg;
119 119  
120 120 get_element_colors(attr,&fg,&bg,color);
121   - v3270_draw_char(cr,chr,attr,session,height,rect,fg,bg);
  121 + v3270_draw_char(cr,chr,attr,session,fontInfo,rect,fg,bg);
122 122  
123 123 if(attr & LIB3270_ATTR_UNDERLINE)
124 124 {
... ... @@ -142,7 +142,7 @@ void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H32
142 142  
143 143 }
144 144  
145   -void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, guint height, const char *str) {
  145 +void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font, const char *str) {
146 146  
147 147 cairo_status_t status;
148 148 cairo_glyph_t * glyphs = NULL;
... ... @@ -154,13 +154,13 @@ void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, guint height, const
154 154  
155 155 status = cairo_scaled_font_text_to_glyphs(
156 156 scaled_font,
157   - (double) rect->x, (double) (rect->y+height),
  157 + (double) rect->x, (double) (rect->y+font->height),
158 158 str, strlen(str),
159 159 &glyphs, &num_glyphs,
160 160 &clusters, &num_clusters, &cluster_flags );
161 161  
162 162 if (status == CAIRO_STATUS_SUCCESS) {
163   - cairo_show_text_glyphs (cr,str,strlen(str),glyphs, num_glyphs,clusters, num_clusters, cluster_flags);
  163 + cairo_show_text_glyphs(cr,str,strlen(str),glyphs, num_glyphs,clusters, num_clusters, cluster_flags);
164 164 }
165 165  
166 166 if(glyphs)
... ... @@ -169,14 +169,9 @@ void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, guint height, const
169 169 if(clusters)
170 170 cairo_text_cluster_free(clusters);
171 171  
172   -/*
173   - cairo_move_to(cr,rect->x,rect->y+height);
174   - cairo_show_text(cr, str);
175   -*/
176   -
177 172 }
178 173  
179   -void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, guint height, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg)
  174 +void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg)
180 175 {
181 176 // Clear element area
182 177 gdk_cairo_set_source_rgba(cr,bg);
... ... @@ -277,23 +272,23 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270
277 272 break;
278 273  
279 274 case 0x8c: // CG 0xf7, less or equal "≤"
280   - v3270_draw_text(cr,rect,height,"≤");
  275 + v3270_draw_text(cr,rect,font,"≤");
281 276 break;
282 277  
283 278 case 0xae: // CG 0xd9, greater or equal "≥"
284   - v3270_draw_text(cr,rect,height,"≥");
  279 + v3270_draw_text(cr,rect,font,"≥");
285 280 break;
286 281  
287 282 case 0xbe: // CG 0x3e, not equal "≠"
288   - v3270_draw_text(cr,rect,height,"≠");
  283 + v3270_draw_text(cr,rect,font,"≠");
289 284 break;
290 285  
291 286 case 0xad: // "["
292   - v3270_draw_text(cr,rect,height,"[");
  287 + v3270_draw_text(cr,rect,font,"[");
293 288 break;
294 289  
295 290 case 0xbd: // "]"
296   - v3270_draw_text(cr,rect,height,"]");
  291 + v3270_draw_text(cr,rect,font,"]");
297 292 break;
298 293  
299 294 default:
... ... @@ -306,7 +301,7 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270
306 301  
307 302 if(utf)
308 303 {
309   - v3270_draw_text(cr,rect,height,utf);
  304 + v3270_draw_text(cr,rect,font,utf);
310 305 g_free(utf);
311 306 }
312 307 }
... ... @@ -386,7 +381,7 @@ void v3270_reload(GtkWidget *widget)
386 381 if(addr == cursor)
387 382 v3270_update_cursor_rect(terminal,&rect,chr,attr);
388 383  
389   - v3270_draw_element(cr,chr,attr,terminal->host,terminal->font.height,&rect,terminal->color);
  384 + v3270_draw_element(cr,chr,attr,terminal->host,&terminal->font,&rect,terminal->color);
390 385  
391 386 addr++;
392 387 rect.x += rect.width;
... ... @@ -432,7 +427,7 @@ void v3270_update_char(H3270 *session, int addr, unsigned char chr, unsigned sho
432 427  
433 428 cr = cairo_create(terminal->surface);
434 429 cairo_set_scaled_font(cr,terminal->font.scaled);
435   - v3270_draw_element(cr, chr, attr, terminal->host, terminal->font.height, &rect,terminal->color);
  430 + v3270_draw_element(cr, chr, attr, terminal->host, &terminal->font, &rect,terminal->color);
436 431 cairo_destroy(cr);
437 432 if(cursor)
438 433 v3270_update_cursor_rect(terminal,&rect,chr,attr);
... ... @@ -458,7 +453,7 @@ void v3270_update_cursor_surface(v3270 *widget,unsigned char chr,unsigned short
458 453  
459 454 rect.x = 0;
460 455 rect.y = 0;
461   - v3270_draw_char(cr,chr,attr,widget->host,widget->font.height,&rect,bg,fg);
  456 + v3270_draw_char(cr,chr,attr,widget->host,&widget->font,&rect,bg,fg);
462 457  
463 458 cairo_destroy(cr);
464 459 }
... ...
src/pw3270/v3270/oia.c
... ... @@ -158,7 +158,7 @@ static void setup_spinner_position(GdkRectangle *rect, v3270FontInfo *metrics, c
158 158 // draw_spinner(cr,rect,color,0);
159 159 }
160 160  
161   -static void setup_luname_position(GdkRectangle *rect, v3270FontInfo *metrics, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color)
  161 +static void setup_luname_position(GdkRectangle *rect, v3270FontInfo *font, cairo_t *cr, H3270 *host, int cols, GdkRGBA *color)
162 162 {
163 163 const char *luname = lib3270_get_luname(host);
164 164  
... ... @@ -180,10 +180,13 @@ static void setup_luname_position(GdkRectangle *rect, v3270FontInfo *metrics, ca
180 180  
181 181 if(luname)
182 182 {
183   - cairo_move_to(cr,rect->x,rect->y+metrics->height);
  183 +// cairo_move_to(cr,rect->x,rect->y+font->height);
  184 +
184 185 gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_LUNAME);
185   - cairo_show_text(cr,luname);
186   - cairo_stroke(cr);
  186 + v3270_draw_text(cr,rect,font,luname);
  187 +
  188 +// cairo_show_text(cr,luname);
  189 +// cairo_stroke(cr);
187 190 }
188 191  
189 192 cairo_restore(cr);
... ... @@ -279,16 +282,6 @@ static void draw_undera(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGB
279 282  
280 283 }
281 284  
282   -/*
283   -static void draw_centered_text(cairo_t *cr, struct v3270_metrics *metrics, int x, int y, const gchar *str)
284   -{
285   - cairo_text_extents_t extents;
286   - cairo_text_extents(cr,str,&extents);
287   - cairo_move_to(cr,x+(((metrics->width+2)/2)-(extents.width/2)),y+extents.height+( (metrics->spacing/2) - (extents.height/2)));
288   - cairo_show_text(cr,str);
289   -}
290   -*/
291   -
292 285 static void draw_centered_char(cairo_t *cr, v3270FontInfo *metrics, int x, int y, const gchar chr)
293 286 {
294 287 char str[2] = { chr, 0 };
... ... @@ -396,7 +389,7 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, Gdk
396 389  
397 390 }
398 391  
399   -static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect)
  392 +static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, v3270FontInfo *font, GdkRGBA *color, const GdkRectangle *r)
400 393 {
401 394 #ifdef DEBUG
402 395 #define OIA_MESSAGE(x,c,y) { #x, c, y }
... ... @@ -477,7 +470,10 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, v3270FontInfo *
477 470  
478 471 };
479 472  
480   - const gchar *msg = message[0].msg;
  473 + GdkRectangle rect;
  474 + const gchar * msg = message[0].msg;
  475 +
  476 + memcpy(&rect,r,sizeof(GdkRectangle));
481 477  
482 478 // trace("%s: id=%d",__FUNCTION__,id);
483 479  
... ... @@ -492,7 +488,7 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, v3270FontInfo *
492 488  
493 489 // Limpa o bloco
494 490 gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_BACKGROUND);
495   - cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
  491 + cairo_rectangle(cr, rect.x, rect.y, rect.width, rect.height);
496 492 cairo_fill(cr);
497 493  
498 494 if(msg && *msg)
... ... @@ -502,7 +498,7 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, v3270FontInfo *
502 498  
503 499 if(msg && *msg)
504 500 {
505   - int x = rect->x+1;
  501 + rect.x++;
506 502  
507 503 debug("%s(%s)",__FUNCTION__,msg);
508 504  
... ... @@ -512,13 +508,13 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, v3270FontInfo *
512 508 {
513 509 cairo_save(cr);
514 510  
515   - cairo_move_to(cr,x+1,rect->y+(metrics->height)-(metrics->ascent));
516   - cairo_rel_line_to(cr,metrics->width,metrics->ascent);
517   - cairo_rel_move_to(cr,-metrics->width,0);
518   - cairo_rel_line_to(cr,metrics->width,-metrics->ascent);
  511 + cairo_move_to(cr,rect.x+1,rect.y+(font->height)-(font->ascent));
  512 + cairo_rel_line_to(cr,font->width,font->ascent);
  513 + cairo_rel_move_to(cr,-font->width,0);
  514 + cairo_rel_line_to(cr,font->width,-font->ascent);
519 515  
520 516 cairo_stroke(cr);
521   - x += metrics->width;
  517 + rect.x += font->width;
522 518 msg++;
523 519  
524 520 cairo_restore(cr);
... ... @@ -527,13 +523,14 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, v3270FontInfo *
527 523 while(isspace(*msg))
528 524 {
529 525 msg++;
530   - x += metrics->width;
  526 + rect.x += font->width;
531 527 }
532 528  
533 529 if(*msg)
534 530 {
535   - cairo_move_to(cr,x,rect->y+metrics->height);
536   - cairo_show_text(cr,msg);
  531 + v3270_draw_text(cr,&rect, font, msg);
  532 +// cairo_move_to(cr,x,rect->y+metrics->height);
  533 +// cairo_show_text(cr,msg);
537 534 }
538 535  
539 536 }
... ...
src/pw3270/v3270/private.h
... ... @@ -268,7 +268,8 @@ void v3270_update_cursor_surface(v3270 *widget,unsigned char chr,unsigned sho
268 268  
269 269 void v3270_register_io_handlers(v3270Class *cls);
270 270  
271   -void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, guint height, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg);
  271 +void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg);
  272 +void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font, const char *str);
272 273  
273 274 void v3270_start_timer(GtkWidget *terminal);
274 275 void v3270_stop_timer(GtkWidget *terminal);
... ...