Merge the usermenu branch. This reworks how the menus and hotkeys
[geda-pcb/pcjc2.git] / src / hid / gtk / gui.h
blob06029b9b1728602c7a45e88ad44779d9f6e4e1d9
1 /* $Id$ */
3 /*
4 * COPYRIGHT
6 * PCB, interactive printed circuit board design
7 * Copyright (C) 1994,1995,1996 Thomas Nau
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* FIXME - rename this file to ghid.h */
27 #ifndef __GHID_INCLUDED__
28 #define __GHID_INCLUDED__
30 #include "hid.h"
32 #include "data.h"
33 #include "misc.h"
34 #include <sys/stat.h>
36 #include <gtk/gtk.h>
38 /* Internationalization support.
40 #if defined (ENABLE_NLS)
41 #include <libintl.h>
42 # undef _
43 # define _(String) dgettext(PACKAGE,String)
44 # if defined(gettext_noop)
45 # define N_(String) gettext_noop(String)
46 # else
47 # define N_(String) (String)
48 # endif /* gettext_noop */
49 #else
50 # undef _
51 # define _(String) (String)
52 # define N_(String) (String)
53 # define textdomain(String) (String)
54 # define gettext(String) (String)
55 # define dgettext(Domain,String) (String)
56 # define dcgettext(Domain,String,Type) (String)
57 # define bindtextdomain(Domain,Directory) (Domain)
58 #endif /* ENABLE_NLS */
61 /* Silk and rats lines are the two additional selectable to draw on.
62 | gui code in gui-top-window.c and group code in misc.c must agree
63 | on what layer is what!
65 #define LAYER_BUTTON_SILK MAX_LAYER
66 #define LAYER_BUTTON_RATS (MAX_LAYER + 1)
67 #define N_SELECTABLE_LAYER_BUTTONS (LAYER_BUTTON_RATS + 1)
69 #define LAYER_BUTTON_PINS (MAX_LAYER + 2)
70 #define LAYER_BUTTON_VIAS (MAX_LAYER + 3)
71 #define LAYER_BUTTON_FARSIDE (MAX_LAYER + 4)
72 #define LAYER_BUTTON_MASK (MAX_LAYER + 5)
73 #define N_LAYER_BUTTONS (MAX_LAYER + 6)
75 /* Go from from the grid units in use (millimeters or mils) to PCB units
76 | and back again.
77 | PCB keeps values internally to 1/100000 inch (0.01 mils), but gui
78 | widgets (spin buttons, labels, etc) need mils or millimeters.
80 #define FROM_PCB_UNITS(v) (Settings.grid_units_mm ? \
81 ((v) * 0.000254) : ((v) * 0.01))
83 #define TO_PCB_UNITS(v) (Settings.grid_units_mm ? \
84 ((v) / 0.000254 + 0.5) : ((v) * 100.0 + 0.5))
86 extern int ghid_flip_x, ghid_flip_y;
87 #define SIDE_X(x) ((ghid_flip_x ? PCB->MaxWidth - (x) : (x)))
88 #define SIDE_Y(y) ((ghid_flip_y ? PCB->MaxHeight - (y) : (y)))
90 #define DRAW_X(x) (gint)((SIDE_X(x) - gport->view_x0) / gport->zoom)
91 #define DRAW_Y(y) (gint)((SIDE_Y(y) - gport->view_y0) / gport->zoom)
92 #define DRAW_Z(z) (gint)((z) / gport->zoom)
94 #define VIEW_X(x) SIDE_X((gint)((x) * gport->zoom + gport->view_x0))
95 #define VIEW_Y(y) SIDE_Y((gint)((y) * gport->zoom + gport->view_y0))
96 #define VIEW_Z(z) (gint)((z) * gport->zoom)
99 /* Pick one of two values depending on current grid units setting.
101 #define GRID_UNITS_VALUE(mm, mil) (Settings.grid_units_mm ? (mm) : (mil))
105 typedef struct hid_gc_struct
107 HID *me_pointer;
108 GdkGC *gc;
110 gchar *colorname;
111 gint width;
112 gint cap, join;
113 gchar xor;
114 gchar erase;
115 gint mask_seq;
117 hid_gc_struct;
120 typedef struct
122 GtkUIManager *ui_manager;
123 GtkActionGroup *main_actions,
124 *grid_actions, *change_selected_actions, *displayed_name_actions;
126 GtkWidget *name_label,
127 *status_line_label,
128 *cursor_position_relative_label,
129 *cursor_position_absolute_label,
130 *grid_units_label, *status_line_hbox, *command_combo_box;
131 GtkEntry *command_entry;
133 GtkWidget *top_hbox,
134 *menu_hbox, *compact_vbox, *compact_hbox, *position_hbox, *label_hbox,
135 *mode_buttons0_vbox, *mode_buttons1_hbox, *mode_buttons1_vbox,
136 *mode_buttons0_frame, *mode_buttons1_frame, *mode_buttons0_frame_vbox;
138 GtkWidget *h_range, *v_range;
139 GtkObject *h_adjustment, *v_adjustment;
141 GdkPixbuf *bg_pixbuf;
143 gchar *name_label_string;
145 gboolean adjustment_changed_holdoff,
146 toggle_holdoff,
147 command_entry_status_line_active,
148 auto_pan_on, in_popup, combine_adjustments;
150 gboolean config_modified,
151 small_label_markup,
152 compact_horizontal,
153 compact_vertical,
154 ghid_title_window, use_command_window, need_restore_crosshair, creating;
156 gint n_mode_button_columns,
157 top_window_width,
158 top_window_height,
159 log_window_width,
160 log_window_height,
161 keyref_window_width,
162 keyref_window_height,
163 library_window_height,
164 netlist_window_height, history_size, settings_mode, auto_pan_speed;
166 GhidGui;
168 extern GhidGui _ghidgui, *ghidgui;
171 /* The output viewport
173 typedef struct
175 GtkWidget *top_window, /* toplevel widget */
176 *drawing_area; /* and its drawing area */
177 GdkPixmap *pixmap, *mask;
178 GdkDrawable *drawable; /* Current drawable for drawing routines */
179 gint width, height;
181 GdkGC *bg_gc, *offlimits_gc, *mask_gc, *u_gc, *grid_gc;
183 GdkColor bg_color, offlimits_color, grid_color;
185 GdkColormap *colormap;
187 GdkCursor *X_cursor; /* used X cursor */
188 GdkCursorType X_cursor_shape; /* and its shape */
190 gboolean has_entered;
192 /* zoom value is PCB units per screen pixel. Larger numbers mean zooming
193 | out - the largest value means you are looking at the whole board.
195 gdouble zoom; /* PCB units per screen pixel. Larger */
196 /* numbers mean zooming out. */
197 gint view_x0, /* Viewport in PCB coordinates */
198 view_y0, view_width, view_height, view_x, view_y;
200 gint x_crosshair, y_crosshair;
202 GHidPort;
204 extern GHidPort ghid_port, *gport;
206 typedef enum
208 NONE_PRESSED,
209 SHIFT_PRESSED,
210 CONTROL_PRESSED,
211 MOD1_PRESSED,
212 SHIFT_CONTROL_PRESSED,
213 SHIFT_MOD1_PRESSED,
214 CONTROL_MOD1_PRESSED,
215 SHIFT_CONTROL_MOD1_PRESSED
217 ModifierKeysState;
219 typedef enum
221 NO_BUTTON_PRESSED,
222 BUTTON1_PRESSED,
223 BUTTON2_PRESSED,
224 BUTTON3_PRESSED
226 ButtonState;
228 typedef struct
230 GtkWidget *top_window, *drawing_area, *enlarge_button, *shrink_button;
232 ElementType element; /* element data to display */
234 gfloat zoom, /* zoom factor of window */
235 scale; /* scale factor of zoom */
236 gint x_max, y_max;
237 gint w_pixels, h_pixels;
239 PinoutType;
242 /* Function prototypes
244 void ghid_parse_arguments (gint * argc, gchar *** argv);
245 hidGC ghid_make_gc (void);
246 void ghid_destroy_gc (hidGC);
247 void ghid_do_export (HID_Attr_Val * options);
249 void ghid_create_pcb_widgets (void);
250 void ghid_window_set_name_label (gchar * name);
251 void ghid_interface_set_sensitive (gboolean sensitive);
252 void ghid_interface_input_signals_connect (void);
253 void ghid_interface_input_signals_disconnect (void);
255 void ghid_set_menu_toggle_button (GtkActionGroup * ag,
256 gchar * name, gboolean state);
257 void ghid_pcb_saved_toggle_states_set (void);
258 void ghid_sync_with_new_layout (void);
259 void ghid_size_increment_get_value (const gchar * saction,
260 gchar ** value, gchar ** units);
261 void ghid_line_increment_get_value (const gchar * saction,
262 gchar ** value, gchar ** units);
263 void ghid_clear_increment_get_value (const gchar * saction,
264 gchar ** value, gchar ** units);
265 void ghid_grid_size_increment_get_value (const gchar * saction,
266 gchar ** value, gchar ** units);
268 void ghid_grid_setting_update_menu_actions (void);
269 void ghid_change_selected_update_menu_actions (void);
271 void ghid_config_window_show ();
272 void ghid_config_handle_units_changed (void);
273 void ghid_config_start_backup_timer (void);
274 void ghid_config_text_scale_update (void);
275 void ghid_config_layer_name_update (gchar * name, gint layer);
276 void ghid_config_groups_changed(void);
278 void ghid_config_init (void);
279 void ghid_config_files_write (void);
280 void ghid_config_files_read (gint * argc, gchar *** argv);
282 void ghid_mode_buttons_update (void);
283 void ghid_pack_mode_buttons(void);
284 void ghid_layer_enable_buttons_update (void);
285 void ghid_layer_buttons_update (void);
286 void ghid_layer_button_select (gint layer);
287 void ghid_layer_buttons_color_update (void);
290 /* gui-misc.c function prototypes
292 void ghid_status_line_set_text (gchar * text);
293 void ghid_cursor_position_label_set_text (gchar * text);
294 void ghid_cursor_position_relative_label_set_text (gchar * text);
296 void ghid_hand_cursor (void);
297 void ghid_point_cursor (void);
298 void ghid_watch_cursor (void);
299 void ghid_mode_cursor (gint mode);
300 void ghid_corner_cursor (void);
301 void ghid_restore_cursor (void);
302 void ghid_get_user_xy (const gchar * msg);
303 void ghid_create_abort_dialog (gchar *);
304 gboolean ghid_check_abort (void);
305 void ghid_end_abort (void);
306 void ghid_get_pointer (gint *, gint *);
309 /* gui-output-events.c function prototypes.
311 void ghid_port_ranges_changed (void);
312 void ghid_port_ranges_zoom (gdouble zoom);
313 gboolean ghid_port_ranges_pan (gdouble x, gdouble y, gboolean relative);
314 void ghid_port_ranges_scale (gboolean emit_changed);
315 void ghid_port_ranges_update_ranges (void);
316 void ghid_show_crosshair (gboolean show);
317 void ghid_screen_update (void);
319 gboolean ghid_note_event_location (GdkEventButton * ev);
321 gboolean ghid_port_key_press_cb (GtkWidget * drawing_area,
322 GdkEventKey * kev, GtkUIManager * ui);
323 gboolean ghid_port_key_release_cb (GtkWidget * drawing_area,
324 GdkEventKey * kev, GtkUIManager * ui);
325 gboolean ghid_port_button_press_cb (GtkWidget * drawing_area,
326 GdkEventButton * ev, GtkUIManager * ui);
327 gboolean ghid_port_button_release_cb (GtkWidget * drawing_area,
328 GdkEventButton * ev, GtkUIManager * ui);
331 gint ghid_port_window_enter_cb (GtkWidget * widget,
332 GdkEventCrossing * ev, GHidPort * out);
333 gint ghid_port_window_leave_cb (GtkWidget * widget,
334 GdkEventCrossing * ev, GHidPort * out);
335 gint ghid_port_window_motion_cb (GtkWidget * widget,
336 GdkEventButton * ev, GHidPort * out);
337 gint ghid_port_window_mouse_scroll_cb (GtkWidget * widget,
338 GdkEventScroll * ev, GHidPort * out);
341 gint ghid_port_drawing_area_expose_event_cb (GtkWidget * widget,
342 GdkEventExpose * ev,
343 GHidPort * out);
344 gint ghid_port_drawing_area_configure_event_cb (GtkWidget * widget,
345 GdkEventConfigure * ev,
346 GHidPort * out);
347 void ghid_pinout_expose (PinoutType * po);
350 /* gui-dialog.c function prototypes.
352 #define GUI_DIALOG_RESPONSE_ALL 1
354 gchar *ghid_dialog_file_select_open (gchar * title, gchar ** path,
355 gchar * shortcuts);
356 gchar *ghid_dialog_file_select_save (gchar * title, gchar ** path,
357 gchar * file, gchar * shortcuts);
358 void ghid_dialog_message (gchar * message);
359 gboolean ghid_dialog_confirm (gchar * message);
360 gint ghid_dialog_confirm_all (gchar * message);
361 gchar *ghid_dialog_input (gchar * prompt, gchar * initial);
362 void ghid_dialog_about (void);
365 /* gui-dialog-print.c */
366 void ghid_dialog_print (HID * printer);
367 void ghid_dialog_export (void);
370 /* gui-route-style function prototypes.
372 /* In gui-dialog-size.c */
373 void ghid_route_style_dialog (gint index, RouteStyleType * rst);
374 /* In gui-top-window.c */
375 void ghid_route_style_set_button_label (gchar * name, gint index);
376 void ghid_route_style_set_temp_style (RouteStyleType * rst, gint which);
377 void ghid_route_style_button_set_active (gint number);
378 void ghid_route_style_buttons_update (void);
379 void ghid_update_toggle_flags (void);
381 /* gui-utils.c
383 gboolean dup_string (gchar ** dst, gchar * src);
384 gboolean utf8_dup_string (gchar ** dst_utf8, gchar * src);
385 void free_glist_and_data (GList ** list_head);
388 ModifierKeysState ghid_modifier_keys_state (GdkModifierType * state);
389 ButtonState ghid_button_state (GdkModifierType * state);
390 gboolean ghid_is_modifier_key_sym (gint ksym);
391 gboolean ghid_control_is_pressed (void);
392 gboolean ghid_shift_is_pressed (void);
394 void ghid_draw_area_update (GHidPort * out, GdkRectangle * rect);
395 void ghid_string_markup_extents (PangoFontDescription * font_desc,
396 gchar * string, gint * width, gint * height);
397 void ghid_draw_string_markup (GdkDrawable * drawable,
398 PangoFontDescription * font_desc,
399 GdkGC * gc, gint x, gint y, gchar * string);
401 gchar *ghid_get_color_name (GdkColor * color);
402 void ghid_map_color_string (gchar * color_string, GdkColor * color);
403 void ghid_button_set_text (GtkWidget * button, gchar * text);
404 gboolean ghid_button_active (GtkWidget * widget);
405 gchar *ghid_entry_get_text (GtkWidget * entry);
406 void ghid_check_button_connected (GtkWidget * box, GtkWidget ** button,
407 gboolean active, gboolean pack_start,
408 gboolean expand, gboolean fill, gint pad,
409 void (*cb_func) (), gpointer data,
410 gchar * string);
411 void ghid_button_connected (GtkWidget * box, GtkWidget ** button,
412 gboolean pack_start, gboolean expand,
413 gboolean fill, gint pad, void (*cb_func) (),
414 gpointer data, gchar * string);
415 void ghid_spin_button (GtkWidget * box, GtkWidget ** spin_button,
416 gfloat value, gfloat low, gfloat high, gfloat step0,
417 gfloat step1, gint digits, gint width,
418 void (*cb_func) (), gpointer data,
419 gboolean right_align, gchar * string);
420 void ghid_table_spin_button (GtkWidget * box, gint row, gint column,
421 GtkWidget ** spin_button, gfloat value,
422 gfloat low, gfloat high, gfloat step0,
423 gfloat step1, gint digits, gint width,
424 void (*cb_func) (), gpointer data,
425 gboolean right_align, gchar * string);
426 void ghid_range_control (GtkWidget * box, GtkWidget ** scale_res,
427 gboolean horizontal, GtkPositionType pos,
428 gboolean set_draw_value, gint digits,
429 gboolean pack_start, gboolean expand, gboolean fill,
430 guint pad, gfloat value, gfloat low, gfloat high,
431 gfloat step0, gfloat step1, void (*cb_func) (),
432 gpointer data);
433 GtkWidget *ghid_scrolled_vbox (GtkWidget * box, GtkWidget ** scr,
434 GtkPolicyType h_policy,
435 GtkPolicyType v_policy);
436 GtkWidget *ghid_framed_vbox (GtkWidget * box, gchar * label,
437 gint frame_border_width, gboolean frame_expand,
438 gint vbox_pad, gint vbox_border_width);
439 GtkWidget *ghid_framed_vbox_end (GtkWidget * box, gchar * label,
440 gint frame_border_width,
441 gboolean frame_expand, gint vbox_pad,
442 gint vbox_border_width);
443 GtkWidget *ghid_category_vbox (GtkWidget * box, const gchar * category_header,
444 gint header_pad, gint box_pad,
445 gboolean pack_start, gboolean bottom_pad);
446 GtkWidget *ghid_notebook_page (GtkWidget * tabs, char *name, gint pad,
447 gint border);
448 GtkWidget *ghid_framed_notebook_page (GtkWidget * tabs, char *name,
449 gint border, gint frame_border,
450 gint vbox_pad, gint vbox_border);
451 GtkWidget *ghid_scrolled_text_view (GtkWidget * box, GtkWidget ** scr,
452 GtkPolicyType h_policy,
453 GtkPolicyType v_policy);
454 void ghid_text_view_append (GtkWidget * view, gchar * string);
455 void ghid_text_view_append_strings (GtkWidget * view, gchar ** string,
456 gint n_strings);
457 GtkTreeSelection *ghid_scrolled_selection (GtkTreeView * treeview,
458 GtkWidget * box,
459 GtkSelectionMode s_mode,
460 GtkPolicyType h_policy,
461 GtkPolicyType v_policy,
462 void (*func_cb) (), gpointer data);
464 void ghid_dialog_report (gchar * title, gchar * message);
465 void ghid_label_set_markup (GtkWidget * label, gchar * text);
467 void ghid_set_cursor_position_labels (void);
468 void ghid_set_status_line_label (void);
471 /* gui-netlist-window.c */
472 void ghid_netlist_window_show (GHidPort * out, gboolean raise);
473 void ghid_netlist_window_update (gboolean init_nodes);
474 void ghid_netlist_nodes_update (LibraryMenuType * net);
476 LibraryMenuType *ghid_get_net_from_node_name (gchar * name, gboolean);
477 void ghid_netlist_highlight_node (gchar * name);
480 /* gui-command-window.c */
481 void ghid_handle_user_command (gboolean raise);
482 void ghid_command_window_show (gboolean raise);
483 gchar *ghid_command_entry_get (gchar * prompt, gchar * command);
484 void ghid_command_use_command_window_sync (void);
486 /* gui-keyref-window.c */
487 void ghid_keyref_window_show (gboolean raise);
489 /* gui-library-window.c */
490 void ghid_library_window_show (GHidPort * out, gboolean raise);
493 /* gui-log-window.c */
494 void ghid_log_window_show (gboolean raise);
495 void ghid_log (const char *fmt, ...);
496 void ghid_logv (const char *fmt, va_list args);
498 /* gui-pinout-window.c */
499 void ghid_pinout_window_show (GHidPort * out, ElementTypePtr Element);
501 /* gtkhid-main.c */
502 void ghid_invalidate_all ();
503 void ghid_get_coords (const char *msg, int *x, int *y);
504 void ghid_pinout_redraw (PinoutType * po);
505 gint PCBChanged (int argc, char **argv, int x, int y);
510 extern GdkPixmap *XC_hand_source, *XC_hand_mask;
511 extern GdkPixmap *XC_lock_source, *XC_lock_mask;
512 extern GdkPixmap *XC_clock_source, *XC_clock_mask;
514 #endif /* __GHID_INCLUDED__ */