Commit 52166de6805d0631efc88efca9c7dfc6158885a8
1 parent
26ded741
Exists in
master
and in
5 other branches
Implementando seleção por mouse (work in progress)
Showing
4 changed files
with
61 additions
and
9 deletions
Show diff stats
src/gtk/v3270/draw.c
| ... | ... | @@ -364,13 +364,22 @@ void v3270_update_cursor_surface(v3270 *widget,unsigned char chr,unsigned short |
| 364 | 364 | { |
| 365 | 365 | GdkRectangle rect = widget->cursor.rect; |
| 366 | 366 | cairo_t * cr = cairo_create(widget->cursor.surface); |
| 367 | - GdkColor * fg = widget->color+((attr & 0x00F0) >> 4); | |
| 367 | + GdkColor * fg; | |
| 368 | 368 | GdkColor * bg; |
| 369 | 369 | |
| 370 | - if(attr & LIB3270_ATTR_FIELD) | |
| 371 | - bg = widget->color+(attr & 0x0003)+V3270_COLOR_FIELD; | |
| 370 | + if(attr & LIB3270_ATTR_SELECTED) | |
| 371 | + { | |
| 372 | + fg = widget->color+V3270_COLOR_SELECTED_FG; | |
| 373 | + bg = widget->color+V3270_COLOR_SELECTED_BG; | |
| 374 | + } | |
| 372 | 375 | else |
| 373 | - bg = widget->color+(attr & 0x000F); | |
| 376 | + { | |
| 377 | + fg = widget->color+((attr & 0x00F0) >> 4); | |
| 378 | + if(attr & LIB3270_ATTR_FIELD) | |
| 379 | + bg = widget->color+(attr & 0x0003)+V3270_COLOR_FIELD; | |
| 380 | + else | |
| 381 | + bg = widget->color+(attr & 0x000F); | |
| 382 | + } | |
| 374 | 383 | |
| 375 | 384 | cairo_set_scaled_font(cr,widget->font_scaled); |
| 376 | 385 | ... | ... |
src/gtk/v3270/mouse.c
| ... | ... | @@ -52,6 +52,30 @@ static int decode_position(v3270 *widget, gdouble x, gdouble y) |
| 52 | 52 | return -1; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | +static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr) | |
| 56 | +{ | |
| 57 | + GTK_V3270(widget)->selecting = 1; | |
| 58 | + | |
| 59 | + switch(type) | |
| 60 | + { | |
| 61 | + case GDK_BUTTON_PRESS: // Single click - Just move cursor | |
| 62 | + lib3270_set_cursor_address(GTK_V3270(widget)->host,baddr); | |
| 63 | + lib3270_clear_selection(GTK_V3270(widget)->host); | |
| 64 | + break; | |
| 65 | + | |
| 66 | + case GDK_2BUTTON_PRESS: // Double click - Select work | |
| 67 | + break; | |
| 68 | + | |
| 69 | + case GDK_3BUTTON_PRESS: // Triple clock - Select field | |
| 70 | + break; | |
| 71 | + | |
| 72 | +#ifdef DEBUG | |
| 73 | + default: | |
| 74 | + trace("Unexpected button 1 type %d",type); | |
| 75 | +#endif | |
| 76 | + } | |
| 77 | +} | |
| 78 | + | |
| 55 | 79 | gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event) |
| 56 | 80 | { |
| 57 | 81 | int baddr = decode_position(GTK_V3270(widget),event->x,event->y); |
| ... | ... | @@ -59,14 +83,15 @@ gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event) |
| 59 | 83 | if(baddr < 0) |
| 60 | 84 | return FALSE; |
| 61 | 85 | |
| 62 | - trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type); | |
| 86 | +// trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type); | |
| 63 | 87 | |
| 64 | 88 | switch(event->button) |
| 65 | 89 | { |
| 66 | 90 | case 1: |
| 67 | - lib3270_set_cursor_address(GTK_V3270(widget)->host,baddr); | |
| 68 | - GTK_V3270(widget)->selecting = 1; | |
| 69 | - lib3270_clear_selection(GTK_V3270(widget)->host); | |
| 91 | + button_1_press(widget,event->type,baddr); | |
| 92 | +// lib3270_set_cursor_address(GTK_V3270(widget)->host,baddr); | |
| 93 | +// GTK_V3270(widget)->selecting = 1; | |
| 94 | +// lib3270_clear_selection(GTK_V3270(widget)->host); | |
| 70 | 95 | break; |
| 71 | 96 | |
| 72 | 97 | default: | ... | ... |
src/gtk/v3270/widget.c
| ... | ... | @@ -78,6 +78,20 @@ static void v3270_destroy (GtkObject * object); |
| 78 | 78 | |
| 79 | 79 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 80 | 80 | |
| 81 | +static void v3270_cursor_draw(v3270 *widget) | |
| 82 | +{ | |
| 83 | + int pos = lib3270_get_cursor_address(widget->host); | |
| 84 | + unsigned char c; | |
| 85 | + unsigned short attr; | |
| 86 | + | |
| 87 | + lib3270_get_contents(widget->host,pos,pos,&c,&attr); | |
| 88 | + v3270_update_cursor_surface(widget,c,attr); | |
| 89 | + gtk_widget_queue_draw_area( GTK_WIDGET(widget), | |
| 90 | + widget->cursor.rect.x,widget->cursor.rect.y, | |
| 91 | + widget->cursor.rect.width,widget->cursor.rect.height); | |
| 92 | + | |
| 93 | +} | |
| 94 | + | |
| 81 | 95 | static void v3270_toggle_changed(v3270 *widget,LIB3270_TOGGLE toggle_id, gboolean toggle_state,const gchar *toggle_name) |
| 82 | 96 | { |
| 83 | 97 | trace("%s: toggle %d (%s)=%s",__FUNCTION__,toggle_id,toggle_name,toggle_state ? "Yes" : "No"); |
| ... | ... | @@ -94,6 +108,10 @@ static void v3270_toggle_changed(v3270 *widget,LIB3270_TOGGLE toggle_id, gboolea |
| 94 | 108 | widget->cursor.show |= 1; |
| 95 | 109 | break; |
| 96 | 110 | |
| 111 | + case LIB3270_TOGGLE_INSERT: | |
| 112 | + v3270_cursor_draw(widget); | |
| 113 | + break; | |
| 114 | + | |
| 97 | 115 | default: |
| 98 | 116 | return; |
| 99 | 117 | ... | ... |
src/lib3270/telnet.c
| ... | ... | @@ -395,7 +395,7 @@ void popup_a_sockerr(H3270 *session, char *fmt, ...) |
| 395 | 395 | #if defined(_WIN32) |
| 396 | 396 | const char *msg = win32_strerror(socket_errno()); |
| 397 | 397 | #else |
| 398 | - const char *msg = strerror(errno) | |
| 398 | + const char *msg = strerror(errno); | |
| 399 | 399 | #endif // WIN32 |
| 400 | 400 | va_list args; |
| 401 | 401 | char buffer[4096]; | ... | ... |