internals.h
15.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* Copyright (C) 2008 Banco do Brasil S.A.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef V3270_INTERNALS_H_INCLUDED
#define V3270_INTERNALS_H_INCLUDED 1
#include <config.h>
#define ENABLE_NLS
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <lib3270.h>
#include <lib3270/log.h>
#include <v3270.h>
#include <v3270/toggle.h>
#include <lib3270/popup.h>
G_BEGIN_DECLS
/* not really I18N-related, but also a string marker macro */
#define I_(string) g_intern_static_string (string)
/*--[ Structures ]-----------------------------------------------------------------------------------*/
struct v3270_character
{
unsigned char chr; ///< @brief Character value.
unsigned short attr; ///< @brief Character attribute.
};
/// @brief Head for settings widgets.
#define ENTRY_FIELD_HEAD \
gint left; \
gint top; \
gint width; \
gint height; \
const gchar * label; \
const gchar * tooltip;
struct v3270_entry_field
{
ENTRY_FIELD_HEAD
};
//--[ Globals ]--------------------------------------------------------------------------------------
/// @brief V3270 Signal list
enum V3270_SIGNAL
{
V3270_SIGNAL_TOGGLE_CHANGED,
V3270_SIGNAL_MESSAGE_CHANGED,
V3270_SIGNAL_KEYPRESS,
V3270_SIGNAL_MODEL_CHANGED,
V3270_SIGNAL_CHANGED,
V3270_SIGNAL_FIELD,
V3270_SIGNAL_SESSION_CHANGED,
//
// Clipboard signals.
//
V3270_SIGNAL_SELECTING,
V3270_SIGNAL_CLIPBOARD,
V3270_SIGNAL_PASTENEXT,
//
// Network signals.
//
V3270_SIGNAL_CONNECTED,
V3270_SIGNAL_DISCONNECTED,
//
// Print session signals.
//
V3270_SIGNAL_PRINT_DONE,
V3270_SIGNAL_PRINT_SETUP,
//
// Popup signals
//
V3270_SIGNAL_POPUP,
V3270_SIGNAL_OIA_POPUP,
//
// Settings signals (Mostly fired by V3270Settings dialogs).
//
V3270_SIGNAL_SAVE_SETTINGS, ///< @brief Notify main application to save all widget settings.
V3270_SIGNAL_LOAD_POPUP_RESPONSE, ///< @brief Load popup response (GTK_RESPONSE_NONE to show popup).
V3270_SIGNAL_SAVE_POPUP_RESPONSE, ///< @brief Save popup response.
//
// Misc signals
//
V3270_SIGNAL_FIRE_ACTION, ///< @brief Fire action by name.
V3270_SIGNAL_OPEN_URL, ///< @brief An URL was selected.
V3270_SIGNAL_LAST
};
/*--[ Constants ]------------------------------------------------------------------------------------*/
G_GNUC_INTERNAL const gchar * v3270_get_default_colors();
/*--[ Internal methods ]-----------------------------------------------------------------------------*/
G_GNUC_INTERNAL void v3270_drag_dest_set(GtkWidget *widget, GCallback callback);
G_GNUC_INTERNAL GtkWidget * v3270_box_pack_start(GtkWidget *box, GtkWidget *child, gboolean expand, gboolean fill, guint padding);
G_GNUC_INTERNAL GtkWidget * v3270_box_pack_end(GtkWidget *box, GtkWidget *child, gboolean expand, gboolean fill, guint padding);
G_GNUC_INTERNAL GtkWidget * v3270_box_pack_frame(GtkWidget *box, GtkWidget *child, const gchar *title, const gchar *tooltip, GtkAlign align, gboolean expand, gboolean fill, guint padding);
G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_grid(GtkAlign align);
G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_frame(GtkWidget * child, const gchar *title);
G_GNUC_INTERNAL GtkResponseType v3270_popup_dialog_show(GtkWidget *widget, const LIB3270_POPUP *popup, gboolean wait);
G_GNUC_INTERNAL void v3270_signal_emit(gpointer instance, enum V3270_SIGNAL signal_id, ...);
G_GNUC_INTERNAL void v3270_dialog_close(GtkDialog *dialog, gpointer user_data);
/// @brief Emit "has-text" signal.
G_GNUC_INTERNAL void v3270_emit_copy_state(GtkWidget *widget);
G_GNUC_INTERNAL gchar * v3270_convert_to_3270_charset(GtkWidget *widget, const gchar *text, const gchar *encoding, GError **error);
/// @brief Add current lib3270 selection to a list
G_GNUC_INTERNAL GList * g_list_append_lib3270_selection(GList *list, H3270 *hSession, gboolean all);
G_GNUC_INTERNAL const gchar * v3270_translate_cg_to_utf(unsigned char chr);
/*--[ Internal Widgets & Tools ]---------------------------------------------------------------------*/
enum
{
V3270_ACCELERATOR_TYPE_INTERNAL, ///< @brief Accelerator is internal.
V3270_ACCELERATOR_TYPE_LIB3270_ACTION, ///< @brief Accelerator is a lib3270 action.
V3270_ACCELERATOR_TYPE_LIB3270_TOGGLE, ///< @brief Accelerator is a lib3270 toggle.
V3270_ACCELERATOR_TYPE_PFKEY, ///< @brief Accelerator is a PFKEY.
V3270_ACCELERATOR_TYPE_CUSTOM, ///< @brief Custom (application based) accelerator.
};
struct _V3270Accelerator
{
unsigned short type;
guint key;
GdkModifierType mods;
gconstpointer arg;
GCallback activate;
};
typedef struct _V3270PFKeyAccelerator
{
struct _V3270Accelerator parent;
GdkAtom name;
} V3270PFKeyAccelerator;
typedef struct _V3270CustomAccelerator
{
struct _V3270Accelerator parent;
const gchar *name;
} V3270CustomAccelerator;
#if GTK_CHECK_VERSION(3,12,0)
G_GNUC_INTERNAL GtkHeaderBar * v3270_dialog_get_header_bar(GtkWidget * widget);
#endif // ! GTK 3.12
G_GNUC_INTERNAL gboolean v3270_dialog_get_use_header();
G_GNUC_INTERNAL void v3270_grid_attach(GtkGrid *grid, const struct v3270_entry_field * description, GtkWidget *widget);
// Toggle button widget
#define GTK_TYPE_V3270_TOGGLE_BUTTON (V3270ToggleButton_get_type ())
#define GTK_V3270_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_TOGGLE_BUTTON, V3270ToggleButton))
#define GTK_V3270_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270_TOGGLE_BUTTON, V3270ToggleButtonClass))
#define GTK_IS_V3270_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_TOGGLE_BUTTON))
#define GTK_IS_V3270_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_TOGGLE_BUTTON))
#define GTK_V3270_TOGGLE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270_TOGGLE_BUTTON, V3270ToggleButtonClass))
typedef struct _V3270ToggleButton V3270ToggleButton;
typedef struct _V3270ToggleButtonClass V3270ToggleButtonClass;
G_GNUC_INTERNAL GtkWidget * v3270_toggle_button_new(LIB3270_TOGGLE_ID toggle);
G_GNUC_INTERNAL void v3270_toggle_button_set_session(GtkWidget *button, H3270 *hSession);
// Activity list widget.
#define GTK_TYPE_V3270_FT_ACTIVITY_LIST (V3270FTActivityList_get_type ())
#define GTK_V3270_FT_ACTIVITY_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_FT_ACTIVITY_LIST, V3270FTActivityList))
#define GTK_V3270_FT_ACTIVITY_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270_FT_ACTIVITY_LIST, V3270FTActivityListClass))
#define GTK_IS_V3270_FT_ACTIVITY_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_FT_ACTIVITY_LIST))
#define GTK_IS_V3270_FT_ACTIVITY_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_FT_ACTIVITY_LIST))
#define GTK_V3270_FT_ACTIVITY_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270_FT_ACTIVITY_LIST, V3270FTActivityListClass))
typedef struct _V3270FTActivityList V3270FTActivityList;
typedef struct _V3270FTActivityListClass V3270FTActivityListClass;
G_GNUC_INTERNAL GtkWidget * v3270_activity_list_new();
G_GNUC_INTERNAL void v3270_activity_list_append(GtkWidget *widget, GObject *activity, gboolean select);
G_GNUC_INTERNAL void v3270_activity_list_remove(GtkWidget *widget, GObject *activity);
G_GNUC_INTERNAL void v3270_activity_list_load(GtkWidget *widget);
G_GNUC_INTERNAL void v3270_activity_list_save(GtkWidget *widget);
G_GNUC_INTERNAL void v3270_activity_list_save_as(GtkWidget *widget);
G_GNUC_INTERNAL gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename);
#if ! GTK_CHECK_VERSION(3,16,0)
G_GNUC_INTERNAL void gtk_text_view_set_monospace (GtkTextView *text_view, gboolean monospace);
#endif //! GTK 3.16
G_GNUC_INTERNAL GtkWidget * v3270_charset_combo_box_new();
/*--[ Font Info ]------------------------------------------------------------------------------------*/
typedef struct _v3270FontInfo {
double size; ///< @brief Current font size.
double step; ///< @brief Steps for zoom in/out.
guint width;
guint height;
guint ascent;
guint descent;
struct {
gboolean dynamic;
guint value;
} spacing;
struct
{
gint left;
gint top;
} margin;
gchar * family;
cairo_font_face_t * face;
cairo_font_weight_t weight;
cairo_scaled_font_t * scaled;
} v3270FontInfo;
G_GNUC_INTERNAL void v3270_font_info_init(v3270FontInfo *info);
G_GNUC_INTERNAL void v3270_font_info_unset(v3270FontInfo *info);
G_GNUC_INTERNAL void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *color);
/*--[ Internal Methods ]-----------------------------------------------------------------------------*/
const GtkWidgetClass * v3270_get_parent_class(void);
G_GNUC_INTERNAL void v3270_reconfigure(v3270 * terminal);
G_GNUC_INTERNAL gboolean v3270_draw(GtkWidget * widget, cairo_t * cr);
G_GNUC_INTERNAL void v3270_cursor_draw(v3270 *widget);
G_GNUC_INTERNAL void v3270_set_cursor(GtkWidget *widget, LIB3270_POINTER id);
G_GNUC_INTERNAL void v3270_draw_oia(v3270 *terminal, cairo_t *cr, int row, int cols);
G_GNUC_INTERNAL void v3270_update_mouse_pointer(GtkWidget *widget);
G_GNUC_INTERNAL AtkObject * v3270_get_accessible(GtkWidget * widget);
#if ! GTK_CHECK_VERSION(2,18,0)
G_GNUC_INTERNAL void gtk_widget_get_allocation(GtkWidget *widget,GtkAllocation *allocation);
#endif // !GTK(2,18)
#if ! GTK_CHECK_VERSION(2,20,0)
#define gtk_widget_get_realized(w) GTK_WIDGET_REALIZED(w)
#define gtk_widget_set_realized(w,r) if(r) { GTK_WIDGET_SET_FLAGS(w,GTK_REALIZED); } else { GTK_WIDGET_UNSET_FLAGS(w,GTK_REALIZED); }
#endif // !GTK(2,20)
#if ! GTK_CHECK_VERSION(2,22,0)
#define gtk_accessible_set_widget(a,w) g_object_set_data(G_OBJECT(a),"widget",w)
#define gtk_accessible_get_widget(a) GTK_WIDGET(g_object_get_data(G_OBJECT(a),"widget"))
G_GNUC_INTERNAL cairo_surface_t * gdk_window_create_similar_surface(GdkWindow *window, cairo_content_t content, int width, int height);
#endif // !GTK(2,22)
#if ! GTK_CHECK_VERSION(3,0,0)
gboolean v3270_expose(GtkWidget * widget, GdkEventExpose *event);
#endif // GTK 3
G_GNUC_INTERNAL void v3270_draw_shift_status(v3270 *terminal);
G_GNUC_INTERNAL void v3270_draw_alt_status(v3270 *terminal);
G_GNUC_INTERNAL void v3270_draw_ins_status(v3270 *terminal);
G_GNUC_INTERNAL void v3270_clear_selection(v3270 *terminal);
G_GNUC_INTERNAL void v3270_update_cursor_surface(v3270 *widget, unsigned char chr, unsigned short attr);
G_GNUC_INTERNAL void v3270_register_io_handlers(v3270Class *cls);
G_GNUC_INTERNAL void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg);
G_GNUC_INTERNAL void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font, const char *str);
G_GNUC_INTERNAL void v3270_draw_text_at(cairo_t *cr, int x, int y, v3270FontInfo *font, const char *str);
G_GNUC_INTERNAL void v3270_start_timer(GtkWidget *terminal);
G_GNUC_INTERNAL void v3270_stop_timer(GtkWidget *terminal);
G_GNUC_INTERNAL void v3270_redraw(v3270 *terminal, cairo_t * cr, gint width, gint height);
G_GNUC_INTERNAL void v3270_draw_connection(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGBA *color, const GdkRectangle *rect);
G_GNUC_INTERNAL void v3270_draw_ssl_status(v3270 *widget, cairo_t *cr, GdkRectangle *rect);
G_GNUC_INTERNAL void v3270_update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor);
G_GNUC_INTERNAL void v3270_update_font_metrics(v3270 *terminal, unsigned int width, unsigned int height);
G_GNUC_INTERNAL void v3270_compute_font_size(v3270 *terminal, cairo_t *cr, unsigned int width, unsigned int height);
G_GNUC_INTERNAL void v3270_update_cursor_rect(v3270 *widget, GdkRectangle *rect, const struct v3270_character *element);
G_GNUC_INTERNAL void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id);
G_GNUC_INTERNAL void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr);
G_GNUC_INTERNAL void v3270_update_oia(v3270 *terminal, LIB3270_FLAG id, unsigned char on);
G_GNUC_INTERNAL gboolean v3270_blink_ssl(v3270 *terminal);
G_GNUC_INTERNAL void v3270_queue_draw_area(GtkWidget *widget, gint x, gint y, gint width, gint height);
G_GNUC_INTERNAL void v3270_disable_updates(GtkWidget *widget);
G_GNUC_INTERNAL void v3270_enable_updates(GtkWidget *widget);
G_GNUC_INTERNAL void v3270_start_blinking(GtkWidget *widget);
G_GNUC_INTERNAL void v3270_oia_update_text_field(v3270 *terminal, gboolean flag, V3270_OIA_FIELD id, const gchar chr);
G_GNUC_INTERNAL cairo_t * v3270_oia_set_update_region(v3270 * terminal, GdkRectangle **r, V3270_OIA_FIELD id);
G_GNUC_INTERNAL void v3270_install_callbacks(v3270 *widget);
// Keyboard & Mouse
G_GNUC_INTERNAL gboolean v3270_key_press_event(GtkWidget *widget, GdkEventKey *event);
G_GNUC_INTERNAL gboolean v3270_key_release_event(GtkWidget *widget, GdkEventKey *event);
G_GNUC_INTERNAL void v3270_key_commit(GtkIMContext *imcontext, gchar *str, v3270 *widget);
G_GNUC_INTERNAL gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event);
G_GNUC_INTERNAL gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event);
G_GNUC_INTERNAL gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event);
G_GNUC_INTERNAL void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event);
G_GNUC_INTERNAL gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y);
G_GNUC_INTERNAL gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event);
// I/O Callbacks
G_GNUC_INTERNAL GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata);
G_GNUC_INTERNAL void IO_source_set_state(GSource *source, gboolean enable);
// Tools
G_GNUC_INTERNAL void v3270_translate_text_to_rgba(const gchar *colors, GdkRGBA *clr);
G_GNUC_INTERNAL gchar * v3270_translate_rgba_to_text(GdkRGBA *clr);
// Properties
G_GNUC_INTERNAL void v3270_init_properties(GObjectClass * gobject_class);
G_GNUC_INTERNAL gboolean v3270_update_associated_lu(v3270 *terminal);
G_GNUC_INTERNAL void v3270_update_toggle(GtkWidget *widget, LIB3270_TOGGLE_ID id, unsigned char value, const char *name);
// Accelerators
G_GNUC_INTERNAL GSList * v3270_accelerator_map_sort(GSList * accelerators);
G_GNUC_INTERNAL GSList * v3270_accelerator_map_load_default(GSList * accelerators);
G_END_DECLS
#endif // V3270_INTERNALS_H_INCLUDED