Commit bc4c1af21c59d941d9d3e3fa056aaa54342cb600

Authored by perry.werneck@gmail.com
1 parent 2bc1baf7
Exists in master and in 1 other branch develop

Implementando sinal quando algum elemento da OIA receb um click, incluindo trata…

…mento de ponteiros ao movimentar o mouse sobre a OIA
genmarshal
... ... @@ -10,3 +10,4 @@ VOID:VOID,BOOL
10 10 BOOL:VOID,BOOL,BOOL,POINTER
11 11 VOID:VOID,UINT,UINT
12 12 VOID:VOID,UINT,POINTER,POINTER,POINTER
  13 +BOOL:VOID,BOOL,UINT,POINTER
... ...
mouse.c
... ... @@ -128,28 +128,49 @@ void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event)
128 128 gdk_beep();
129 129 }
130 130  
131   -gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event)
  131 +static V3270_OIA_FIELD get_field_from_event(v3270 *widget, GdkEventButton *event)
132 132 {
133   - int baddr = v3270_get_offset_at_point(GTK_V3270(widget),event->x,event->y);
  133 + if(event->y >= widget->oia_rect->y)
  134 + {
  135 + V3270_OIA_FIELD f;
134 136  
135   - if(baddr < 0)
136   - return FALSE;
  137 + for(f=0;f<V3270_OIA_FIELD_COUNT;f++)
  138 + {
  139 + if(event->x >= widget->oia_rect[f].x && event->x <= (widget->oia_rect[f].x+widget->oia_rect[f].width))
  140 + return f;
  141 + }
  142 + }
137 143  
138   -// trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type);
  144 + return V3270_OIA_FIELD_INVALID;
  145 +}
139 146  
140   - switch(event->button)
  147 +gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event)
  148 +{
  149 + int baddr = v3270_get_offset_at_point(GTK_V3270(widget),event->x,event->y);
  150 +
  151 + if(baddr >= 0)
141 152 {
142   - case 1: // Left button
143   - button_1_press(widget,event->type,baddr);
144   - break;
  153 + GTK_V3270(widget)->selected_field = V3270_OIA_FIELD_INVALID;
145 154  
146   - case 3: // Right button
147   - if(event->type == GDK_BUTTON_PRESS)
148   - v3270_emit_popup(GTK_V3270(widget),baddr,event);
149   - break;
  155 + switch(event->button)
  156 + {
  157 + case 1: // Left button
  158 + button_1_press(widget,event->type,baddr);
  159 + break;
150 160  
151   - default:
152   - trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type);
  161 + case 3: // Right button
  162 + if(event->type == GDK_BUTTON_PRESS)
  163 + v3270_emit_popup(GTK_V3270(widget),baddr,event);
  164 + break;
  165 +
  166 + default:
  167 + trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type);
  168 + }
  169 + }
  170 + else if(event->button == 1 && event->type == GDK_BUTTON_PRESS)
  171 + {
  172 + GTK_V3270(widget)->selected_field = get_field_from_event(GTK_V3270(widget),event);
  173 + trace("%s field=%d",__FUNCTION__,GTK_V3270(widget)->selected_field);
153 174 }
154 175  
155 176 return FALSE;
... ... @@ -163,24 +184,44 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event)
163 184 GTK_V3270(widget)->selecting = 0;
164 185 GTK_V3270(widget)->moving = 0;
165 186 GTK_V3270(widget)->resizing = 0;
  187 +
  188 + if(GTK_V3270(widget)->selected_field != V3270_OIA_FIELD_INVALID && GTK_V3270(widget)->selected_field == get_field_from_event(GTK_V3270(widget),event))
  189 + {
  190 + gboolean handled = FALSE;
  191 +
  192 + trace("%s field %d was clicked event=%p",__FUNCTION__,GTK_V3270(widget)->selected_field,event);
  193 +
  194 + g_signal_emit(widget, v3270_widget_signal[SIGNAL_FIELD], 0,
  195 + lib3270_connected(GTK_V3270(widget)->host) ? TRUE : FALSE,
  196 + GTK_V3270(widget)->selected_field,
  197 + event,
  198 + &handled);
  199 +
  200 + trace("Handled: %s",handled ? "Yes": "No");
  201 +
  202 + if(!handled)
  203 + gdk_beep();
  204 +
  205 + }
  206 +
  207 + GTK_V3270(widget)->selected_field = V3270_OIA_FIELD_INVALID;
  208 +
166 209 break;
167 210  
168 211 default:
169 212 trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type);
170 213 }
171 214  
172   -
173 215 return FALSE;
174 216 }
175 217  
176   -
177 218 static void update_mouse_pointer(GtkWidget *widget, int baddr)
178 219 {
179   - v3270 *terminal = GTK_V3270(widget);
  220 + v3270 * terminal = GTK_V3270(widget);
  221 + int id = terminal->pointer;
180 222  
181 223 if(baddr >= 0 && terminal->pointer_id == LIB3270_CURSOR_EDITABLE)
182 224 {
183   - int id = terminal->pointer;
184 225  
185 226 switch(lib3270_get_selection_flags(terminal->host,baddr) & 0x8f)
186 227 {
... ... @@ -225,9 +266,10 @@ static void update_mouse_pointer(GtkWidget *widget, int baddr)
225 266  
226 267 }
227 268  
228   - gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]);
229 269 }
230 270  
  271 + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]);
  272 +
231 273 }
232 274  
233 275 void v3270_update_mouse_pointer(GtkWidget *widget)
... ... @@ -244,11 +286,20 @@ void v3270_update_mouse_pointer(GtkWidget *widget)
244 286  
245 287 gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event)
246 288 {
247   - v3270 * terminal = GTK_V3270(widget);
248   - int baddr = v3270_get_offset_at_point(terminal,event->x,event->y);
  289 + v3270 * terminal = GTK_V3270(widget);
  290 + int baddr;
  291 +
  292 + if(!lib3270_connected(terminal->host))
  293 + {
  294 + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[V3270_CURSOR_PROTECTED]);
  295 + return FALSE;
  296 + }
  297 +
  298 + baddr = v3270_get_offset_at_point(terminal,event->x,event->y);
249 299  
250 300 if(baddr >= 0)
251 301 {
  302 +
252 303 if(terminal->selecting) // Select region
253 304 {
254 305 lib3270_select_to(terminal->host,baddr);
... ... @@ -263,6 +314,37 @@ gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event)
263 314 update_mouse_pointer(widget,baddr);
264 315 }
265 316 }
  317 + else if(event->y >= terminal->oia_rect->y)
  318 + {
  319 + int id = V3270_CURSOR_PROTECTED;
  320 +
  321 + if(event->x >= terminal->oia_rect[V3270_OIA_SSL].x && event->x <= (terminal->oia_rect[V3270_OIA_SSL].x + terminal->oia_rect[V3270_OIA_SSL].width))
  322 + {
  323 + switch(lib3270_get_secure(terminal->host))
  324 + {
  325 + case LIB3270_SSL_UNSECURE: /**< No secure connection */
  326 + id = V3270_CURSOR_QUESTION;
  327 + break;
  328 +
  329 + case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */
  330 + id = V3270_CURSOR_WAITING;
  331 + break;
  332 +
  333 + case LIB3270_SSL_NEGOTIATED: /**< Connection secure, no CA or self-signed */
  334 + id = V3270_CURSOR_QUESTION;
  335 + break;
  336 +
  337 + case LIB3270_SSL_SECURE: /**< Connection secure with CA check */
  338 + id = V3270_CURSOR_QUESTION;
  339 + break;
  340 +
  341 + default:
  342 + id = V3270_CURSOR_LOCKED;
  343 + }
  344 + }
  345 +
  346 + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]);
  347 + }
266 348  
267 349 return FALSE;
268 350 }
... ...
oia.c
... ... @@ -335,6 +335,13 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri
335 335 bits = (unsigned char *) unlocked_bits;
336 336 break;
337 337  
  338 + case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */
  339 + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING);
  340 + width = unlocked_width;
  341 + height = unlocked_height;
  342 + bits = (unsigned char *) unlocked_bits;
  343 + break;
  344 +
338 345 case LIB3270_SSL_NEGOTIATED: /**< Connection secure, no CA or self-signed */
339 346 gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING);
340 347 width = negotiated_width;
... ... @@ -342,7 +349,6 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri
342 349 bits = (unsigned char *) negotiated_bits;
343 350 break;
344 351  
345   -
346 352 case LIB3270_SSL_SECURE: /**< Connection secure with CA check */
347 353 gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_OK);
348 354 width = locked_width;
... ... @@ -350,19 +356,11 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri
350 356 bits = (unsigned char *) locked_bits;
351 357 break;
352 358  
353   - case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */
354   - gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING);
355   - width = unlocked_width;
356   - height = unlocked_height;
357   - bits = (unsigned char *) unlocked_bits;
358   - break;
359   -
360 359 default:
361 360 return;
362 361  
363 362 }
364 363  
365   -
366 364 icon = cairo_image_surface_create_for_data( bits,
367 365 CAIRO_FORMAT_A1,
368 366 width,height,
... ...
private.h
... ... @@ -81,10 +81,12 @@ G_BEGIN_DECLS
81 81 SIGNAL_CLIPBOARD,
82 82 SIGNAL_CHANGED,
83 83 SIGNAL_MESSAGE,
  84 + SIGNAL_FIELD,
84 85  
85 86 LAST_SIGNAL
86 87 };
87 88  
  89 +
88 90 /*--[ Globals ]--------------------------------------------------------------------------------------*/
89 91  
90 92 #define V3270_CURSOR_UNPROTECTED LIB3270_CURSOR_EDITABLE
... ... @@ -101,8 +103,9 @@ G_BEGIN_DECLS
101 103 #define V3270_CURSOR_SELECTION_BOTTOM LIB3270_CURSOR_USER+7
102 104 #define V3270_CURSOR_SELECTION_LEFT LIB3270_CURSOR_USER+8
103 105 #define V3270_CURSOR_SELECTION_RIGHT LIB3270_CURSOR_USER+9
  106 + #define V3270_CURSOR_QUESTION LIB3270_CURSOR_USER+10
104 107  
105   - #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+10
  108 + #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+11
106 109  
107 110  
108 111 struct v3270_metrics
... ... @@ -144,8 +147,10 @@ G_BEGIN_DECLS
144 147 gchar * clipboard; /**< Clipboard contents (text only) */
145 148  
146 149 LIB3270_CURSOR pointer_id;
147   - unsigned char pointer; /** Mouse pointer ID */
148   - int selection_addr; /** Selection addr */
  150 + unsigned char pointer; /**< Mouse pointer ID */
  151 + int selection_addr; /**< Selection addr */
  152 +
  153 + V3270_OIA_FIELD selected_field; /**< Clicked OIA field */
149 154  
150 155 // Font info
151 156 gchar * font_family;
... ...
widget.c
... ... @@ -333,6 +333,8 @@ static void v3270_class_init(v3270Class *klass)
333 333 // Cursors
334 334 {
335 335 #ifdef WIN32
  336 + // http://git.gnome.org/browse/gtk+/tree/gdk/win32/gdkcursor-win32.c
  337 + // http://www.functionx.com/win32/Lesson02b.htm
336 338 static const gchar * cr[V3270_CURSOR_COUNT] =
337 339 {
338 340 "ibeam", // V3270_CURSOR_UNPROTECTED
... ... @@ -348,6 +350,7 @@ static void v3270_class_init(v3270Class *klass)
348 350 "sizens", // V3270_CURSOR_SELECTION_BOTTOM
349 351 "sizewe", // V3270_CURSOR_SELECTION_LEFT
350 352 "sizewe", // V3270_CURSOR_SELECTION_RIGHT
  353 + "help", // V3270_CURSOR_QUESTION
351 354 };
352 355 #else
353 356 static const int cr[V3270_CURSOR_COUNT] =
... ... @@ -365,6 +368,7 @@ static void v3270_class_init(v3270Class *klass)
365 368 GDK_BOTTOM_SIDE, // V3270_CURSOR_SELECTION_BOTTOM
366 369 GDK_LEFT_SIDE, // V3270_CURSOR_SELECTION_LEFT
367 370 GDK_RIGHT_SIDE, // V3270_CURSOR_SELECTION_RIGHT
  371 + GDK_QUESTION_ARROW, // V3270_CURSOR_QUESTION
368 372 };
369 373 #endif // WIN32
370 374  
... ... @@ -516,6 +520,15 @@ static void v3270_class_init(v3270Class *klass)
516 520 pw3270_VOID__VOID_UINT_POINTER_POINTER_POINTER,
517 521 G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
518 522  
  523 + v3270_widget_signal[SIGNAL_FIELD] =
  524 + g_signal_new( "field_clicked",
  525 + G_OBJECT_CLASS_TYPE (gobject_class),
  526 + G_SIGNAL_RUN_LAST,
  527 + 0,
  528 + NULL, NULL,
  529 + pw3270_BOOL__VOID_BOOL_UINT_POINTER,
  530 + G_TYPE_BOOLEAN, 3, G_TYPE_BOOLEAN, G_TYPE_UINT, G_TYPE_POINTER);
  531 +
519 532 }
520 533  
521 534 void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height)
... ...