Add support for filling / thindrawing raw polygons to the HID interface
[geda-pcb/gde.git] / src / hid / gtk / gui.h
blob0b4eb219dc3c997eab77271338e625689a537e99
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 "global.h"
31 #include "hid.h"
33 #include "data.h"
34 #include "misc.h"
35 #include <sys/stat.h>
37 #include <gtk/gtk.h>
39 /* Internationalization support.
41 #if defined (ENABLE_NLS)
42 #include <libintl.h>
43 # undef _
44 # define _(String) dgettext(GETTEXT_PACKAGE,String)
45 # if defined(gettext_noop)
46 # define N_(String) gettext_noop(String)
47 # else
48 # define N_(String) (String)
49 # endif /* gettext_noop */
50 #else
51 # undef _
52 # define _(String) (String)
53 # define N_(String) (String)
54 # define textdomain(String) (String)
55 # define gettext(String) (String)
56 # define dgettext(Domain,String) (String)
57 # define dcgettext(Domain,String,Type) (String)
58 # define bindtextdomain(Domain,Directory) (Domain)
59 #endif /* ENABLE_NLS */
62 /* Silk and rats lines are the two additional selectable to draw on.
63 | gui code in gui-top-window.c and group code in misc.c must agree
64 | on what layer is what!
66 #define LAYER_BUTTON_SILK MAX_LAYER
67 #define LAYER_BUTTON_RATS (MAX_LAYER + 1)
68 #define N_SELECTABLE_LAYER_BUTTONS (LAYER_BUTTON_RATS + 1)
70 #define LAYER_BUTTON_PINS (MAX_LAYER + 2)
71 #define LAYER_BUTTON_VIAS (MAX_LAYER + 3)
72 #define LAYER_BUTTON_FARSIDE (MAX_LAYER + 4)
73 #define LAYER_BUTTON_MASK (MAX_LAYER + 5)
74 #define N_LAYER_BUTTONS (MAX_LAYER + 6)
76 /* Go from from the grid units in use (millimeters or mils) to PCB units
77 | and back again.
78 | PCB keeps values internally to 1/100000 inch (0.01 mils), but gui
79 | widgets (spin buttons, labels, etc) need mils or millimeters.
81 #define FROM_PCB_UNITS(v) (Settings.grid_units_mm ? \
82 ((v) * 0.000254) : ((v) * 0.01))
84 #define TO_PCB_UNITS(v) (Settings.grid_units_mm ? \
85 ((v) / 0.000254 + 0.5) : ((v) * 100.0 + 0.5))
87 extern int ghid_flip_x, ghid_flip_y;
88 #define SIDE_X(x) ((ghid_flip_x ? PCB->MaxWidth - (x) : (x)))
89 #define SIDE_Y(y) ((ghid_flip_y ? PCB->MaxHeight - (y) : (y)))
91 #define DRAW_X(x) (gint)((SIDE_X(x) - gport->view_x0) / gport->zoom)
92 #define DRAW_Y(y) (gint)((SIDE_Y(y) - gport->view_y0) / gport->zoom)
93 #define DRAW_Z(z) (gint)((z) / gport->zoom)
95 #define VIEW_X(x) SIDE_X((gint)((x) * gport->zoom + gport->view_x0))
96 #define VIEW_Y(y) SIDE_Y((gint)((y) * gport->zoom + gport->view_y0))
97 #define VIEW_Z(z) (gint)((z) * gport->zoom)
100 * Used to intercept "special" hotkeys that gtk doesn't usually pass
101 * on to the menu hotkeys. We catch them and put them back where we
102 * want them.
105 /* The modifier keys */
107 #define GHID_KEY_ALT 0x80
108 #define GHID_KEY_CONTROL 0x40
109 #define GHID_KEY_SHIFT 0x20
111 /* The actual keys */
112 #define GHID_KEY_TAB 0x01
113 #define GHID_KEY_UP 0x02
114 #define GHID_KEY_DOWN 0x03
115 #define GHID_KEY_LEFT 0x04
116 #define GHID_KEY_RIGHT 0x05
118 /* Pick one of two values depending on current grid units setting.
120 #define GRID_UNITS_VALUE(mm, mil) (Settings.grid_units_mm ? (mm) : (mil))
124 typedef struct hid_gc_struct
126 HID *me_pointer;
127 GdkGC *gc;
129 gchar *colorname;
130 gint width;
131 gint cap, join;
132 gchar xor;
133 gchar erase;
134 gint mask_seq;
136 hid_gc_struct;
139 typedef struct
141 GtkUIManager *ui_manager;
142 GtkActionGroup *main_actions,
143 *grid_actions, *change_selected_actions, *displayed_name_actions;
145 GtkWidget *name_label,
146 *status_line_label,
147 *cursor_position_relative_label,
148 *cursor_position_absolute_label,
149 *grid_units_label, *status_line_hbox, *command_combo_box;
150 GtkEntry *command_entry;
152 GtkWidget *top_hbox,
153 *menu_hbox, *compact_vbox, *compact_hbox, *position_hbox, *label_hbox,
154 *mode_buttons0_vbox, *mode_buttons1_hbox, *mode_buttons1_vbox,
155 *mode_buttons0_frame, *mode_buttons1_frame, *mode_buttons0_frame_vbox;
157 GtkWidget *h_range, *v_range;
158 GtkObject *h_adjustment, *v_adjustment;
160 GdkPixbuf *bg_pixbuf;
162 gchar *name_label_string;
164 gboolean adjustment_changed_holdoff,
165 toggle_holdoff,
166 command_entry_status_line_active,
167 auto_pan_on, in_popup, combine_adjustments;
169 gboolean config_modified,
170 small_label_markup,
171 compact_horizontal,
172 compact_vertical,
173 ghid_title_window, use_command_window, need_restore_crosshair, creating;
175 gint n_mode_button_columns,
176 top_window_width,
177 top_window_height,
178 log_window_width,
179 log_window_height,
180 keyref_window_width,
181 keyref_window_height,
182 library_window_width,
183 library_window_height,
184 netlist_window_height, history_size, settings_mode, auto_pan_speed;
186 GhidGui;
188 extern GhidGui _ghidgui, *ghidgui;
191 /* The output viewport
193 typedef struct
195 GtkWidget *top_window, /* toplevel widget */
196 *drawing_area; /* and its drawing area */
197 GdkPixmap *pixmap, *mask;
198 GdkDrawable *drawable; /* Current drawable for drawing routines */
199 gint width, height;
201 GdkGC *bg_gc, *offlimits_gc, *mask_gc, *u_gc, *grid_gc;
203 GdkColor bg_color, offlimits_color, grid_color;
205 GdkColormap *colormap;
207 GdkCursor *X_cursor; /* used X cursor */
208 GdkCursorType X_cursor_shape; /* and its shape */
210 gboolean has_entered;
212 /* zoom value is PCB units per screen pixel. Larger numbers mean zooming
213 | out - the largest value means you are looking at the whole board.
215 gdouble zoom; /* PCB units per screen pixel. Larger */
216 /* numbers mean zooming out. */
217 gint view_x0, /* Viewport in PCB coordinates */
218 view_y0, view_width, view_height, view_x, view_y;
220 gint x_crosshair, y_crosshair;
222 GHidPort;
224 extern GHidPort ghid_port, *gport;
226 typedef enum
228 NONE_PRESSED,
229 SHIFT_PRESSED,
230 CONTROL_PRESSED,
231 MOD1_PRESSED,
232 SHIFT_CONTROL_PRESSED,
233 SHIFT_MOD1_PRESSED,
234 CONTROL_MOD1_PRESSED,
235 SHIFT_CONTROL_MOD1_PRESSED
237 ModifierKeysState;
239 typedef enum
241 NO_BUTTON_PRESSED,
242 BUTTON1_PRESSED,
243 BUTTON2_PRESSED,
244 BUTTON3_PRESSED
246 ButtonState;
248 /* Function prototypes
250 void ghid_parse_arguments (gint * argc, gchar *** argv);
251 hidGC ghid_make_gc (void);
252 void ghid_destroy_gc (hidGC);
253 void ghid_do_export (HID_Attr_Val * options);
255 void ghid_create_pcb_widgets (void);
256 void ghid_window_set_name_label (gchar * name);
257 void ghid_interface_set_sensitive (gboolean sensitive);
258 void ghid_interface_input_signals_connect (void);
259 void ghid_interface_input_signals_disconnect (void);
261 void ghid_set_menu_toggle_button (GtkActionGroup * ag,
262 gchar * name, gboolean state);
263 void ghid_pcb_saved_toggle_states_set (void);
264 void ghid_sync_with_new_layout (void);
265 void ghid_size_increment_get_value (const gchar * saction,
266 gchar ** value, gchar ** units);
267 void ghid_line_increment_get_value (const gchar * saction,
268 gchar ** value, gchar ** units);
269 void ghid_clear_increment_get_value (const gchar * saction,
270 gchar ** value, gchar ** units);
271 void ghid_grid_size_increment_get_value (const gchar * saction,
272 gchar ** value, gchar ** units);
274 void ghid_grid_setting_update_menu_actions (void);
275 void ghid_change_selected_update_menu_actions (void);
277 void ghid_config_window_show ();
278 void ghid_config_handle_units_changed (void);
279 void ghid_config_start_backup_timer (void);
280 void ghid_config_text_scale_update (void);
281 void ghid_config_layer_name_update (gchar * name, gint layer);
282 void ghid_config_groups_changed(void);
284 void ghid_config_init (void);
285 void ghid_config_files_write (void);
286 void ghid_config_files_read (gint * argc, gchar *** argv);
288 void ghid_mode_buttons_update (void);
289 void ghid_pack_mode_buttons(void);
290 void ghid_layer_enable_buttons_update (void);
291 void ghid_layer_buttons_update (void);
292 void ghid_layer_button_select (gint layer);
293 void ghid_layer_buttons_color_update (void);
296 /* gui-misc.c function prototypes
298 void ghid_status_line_set_text (const gchar * text);
299 void ghid_cursor_position_label_set_text (gchar * text);
300 void ghid_cursor_position_relative_label_set_text (gchar * text);
302 void ghid_hand_cursor (void);
303 void ghid_point_cursor (void);
304 void ghid_watch_cursor (void);
305 void ghid_mode_cursor (gint mode);
306 void ghid_corner_cursor (void);
307 void ghid_restore_cursor (void);
308 void ghid_get_user_xy (const gchar * msg);
309 void ghid_create_abort_dialog (gchar *);
310 gboolean ghid_check_abort (void);
311 void ghid_end_abort (void);
312 void ghid_get_pointer (gint *, gint *);
315 /* gui-output-events.c function prototypes.
317 void ghid_port_ranges_changed (void);
318 void ghid_port_ranges_zoom (gdouble zoom);
319 gboolean ghid_port_ranges_pan (gdouble x, gdouble y, gboolean relative);
320 void ghid_port_ranges_scale (gboolean emit_changed);
321 void ghid_port_ranges_update_ranges (void);
322 void ghid_show_crosshair (gboolean show);
323 void ghid_screen_update (void);
325 gboolean ghid_note_event_location (GdkEventButton * ev);
327 gboolean ghid_port_key_press_cb (GtkWidget * drawing_area,
328 GdkEventKey * kev, GtkUIManager * ui);
329 gboolean ghid_port_key_release_cb (GtkWidget * drawing_area,
330 GdkEventKey * kev, GtkUIManager * ui);
331 gboolean ghid_port_button_press_cb (GtkWidget * drawing_area,
332 GdkEventButton * ev, GtkUIManager * ui);
333 gboolean ghid_port_button_release_cb (GtkWidget * drawing_area,
334 GdkEventButton * ev, GtkUIManager * ui);
337 gint ghid_port_window_enter_cb (GtkWidget * widget,
338 GdkEventCrossing * ev, GHidPort * out);
339 gint ghid_port_window_leave_cb (GtkWidget * widget,
340 GdkEventCrossing * ev, GHidPort * out);
341 gint ghid_port_window_motion_cb (GtkWidget * widget,
342 GdkEventButton * ev, GHidPort * out);
343 gint ghid_port_window_mouse_scroll_cb (GtkWidget * widget,
344 GdkEventScroll * ev, GHidPort * out);
347 gint ghid_port_drawing_area_expose_event_cb (GtkWidget * widget,
348 GdkEventExpose * ev,
349 GHidPort * out);
350 gint ghid_port_drawing_area_configure_event_cb (GtkWidget * widget,
351 GdkEventConfigure * ev,
352 GHidPort * out);
355 /* gui-dialog.c function prototypes.
357 #define GUI_DIALOG_RESPONSE_ALL 1
359 gchar *ghid_dialog_file_select_open (gchar * title, gchar ** path,
360 gchar * shortcuts);
361 gchar *ghid_dialog_file_select_save (gchar * title, gchar ** path,
362 gchar * file, gchar * shortcuts);
363 void ghid_dialog_message (gchar * message);
364 gboolean ghid_dialog_confirm (gchar * message, gchar *cancelmsg, gchar *okmsg);
365 int ghid_dialog_close_confirm (void);
366 #define GUI_DIALOG_CLOSE_CONFIRM_CANCEL 0
367 #define GUI_DIALOG_CLOSE_CONFIRM_NOSAVE 1
368 #define GUI_DIALOG_CLOSE_CONFIRM_SAVE 2
369 gint ghid_dialog_confirm_all (gchar * message);
370 gchar *ghid_dialog_input (gchar * prompt, gchar * initial);
371 void ghid_dialog_about (void);
373 char * ghid_fileselect (const char *, const char *, char *, char *, const char *, int);
376 /* gui-dialog-print.c */
377 void ghid_dialog_export (void);
378 void ghid_dialog_print (HID *);
380 int ghid_attribute_dialog (HID_Attribute *, int, HID_Attr_Val *, const char *, const char *);
382 /* gui-route-style function prototypes.
384 /* In gui-dialog-size.c */
385 void ghid_route_style_dialog (gint index, RouteStyleType * rst);
386 /* In gui-top-window.c */
387 void ghid_route_style_set_button_label (gchar * name, gint index);
388 void ghid_route_style_set_temp_style (RouteStyleType * rst, gint which);
389 void ghid_route_style_button_set_active (gint number);
390 void ghid_route_style_buttons_update (void);
391 void ghid_update_toggle_flags (void);
393 /* gui-utils.c
395 gboolean dup_string (gchar ** dst, gchar * src);
396 gboolean utf8_dup_string (gchar ** dst_utf8, gchar * src);
397 void free_glist_and_data (GList ** list_head);
400 ModifierKeysState ghid_modifier_keys_state (GdkModifierType * state);
401 ButtonState ghid_button_state (GdkModifierType * state);
402 gboolean ghid_is_modifier_key_sym (gint ksym);
403 gboolean ghid_control_is_pressed (void);
404 gboolean ghid_shift_is_pressed (void);
406 void ghid_draw_area_update (GHidPort * out, GdkRectangle * rect);
407 void ghid_string_markup_extents (PangoFontDescription * font_desc,
408 gchar * string, gint * width, gint * height);
409 void ghid_draw_string_markup (GdkDrawable * drawable,
410 PangoFontDescription * font_desc,
411 GdkGC * gc, gint x, gint y, gchar * string);
413 gchar *ghid_get_color_name (GdkColor * color);
414 void ghid_map_color_string (gchar * color_string, GdkColor * color);
415 void ghid_button_set_text (GtkWidget * button, gchar * text);
416 gboolean ghid_button_active (GtkWidget * widget);
417 gchar *ghid_entry_get_text (GtkWidget * entry);
418 void ghid_check_button_connected (GtkWidget * box, GtkWidget ** button,
419 gboolean active, gboolean pack_start,
420 gboolean expand, gboolean fill, gint pad,
421 void (*cb_func) (), gpointer data,
422 gchar * string);
423 void ghid_button_connected (GtkWidget * box, GtkWidget ** button,
424 gboolean pack_start, gboolean expand,
425 gboolean fill, gint pad, void (*cb_func) (),
426 gpointer data, gchar * string);
427 void ghid_spin_button (GtkWidget * box, GtkWidget ** spin_button,
428 gfloat value, gfloat low, gfloat high, gfloat step0,
429 gfloat step1, gint digits, gint width,
430 void (*cb_func) (), gpointer data,
431 gboolean right_align, gchar * string);
432 void ghid_table_spin_button (GtkWidget * box, gint row, gint column,
433 GtkWidget ** spin_button, gfloat value,
434 gfloat low, gfloat high, gfloat step0,
435 gfloat step1, gint digits, gint width,
436 void (*cb_func) (), gpointer data,
437 gboolean right_align, gchar * string);
438 void ghid_range_control (GtkWidget * box, GtkWidget ** scale_res,
439 gboolean horizontal, GtkPositionType pos,
440 gboolean set_draw_value, gint digits,
441 gboolean pack_start, gboolean expand, gboolean fill,
442 guint pad, gfloat value, gfloat low, gfloat high,
443 gfloat step0, gfloat step1, void (*cb_func) (),
444 gpointer data);
445 GtkWidget *ghid_scrolled_vbox (GtkWidget * box, GtkWidget ** scr,
446 GtkPolicyType h_policy,
447 GtkPolicyType v_policy);
448 GtkWidget *ghid_framed_vbox (GtkWidget * box, gchar * label,
449 gint frame_border_width, gboolean frame_expand,
450 gint vbox_pad, gint vbox_border_width);
451 GtkWidget *ghid_framed_vbox_end (GtkWidget * box, gchar * label,
452 gint frame_border_width,
453 gboolean frame_expand, gint vbox_pad,
454 gint vbox_border_width);
455 GtkWidget *ghid_category_vbox (GtkWidget * box, const gchar * category_header,
456 gint header_pad, gint box_pad,
457 gboolean pack_start, gboolean bottom_pad);
458 GtkWidget *ghid_notebook_page (GtkWidget * tabs, char *name, gint pad,
459 gint border);
460 GtkWidget *ghid_framed_notebook_page (GtkWidget * tabs, char *name,
461 gint border, gint frame_border,
462 gint vbox_pad, gint vbox_border);
463 GtkWidget *ghid_scrolled_text_view (GtkWidget * box, GtkWidget ** scr,
464 GtkPolicyType h_policy,
465 GtkPolicyType v_policy);
466 void ghid_text_view_append (GtkWidget * view, gchar * string);
467 void ghid_text_view_append_strings (GtkWidget * view, gchar ** string,
468 gint n_strings);
469 GtkTreeSelection *ghid_scrolled_selection (GtkTreeView * treeview,
470 GtkWidget * box,
471 GtkSelectionMode s_mode,
472 GtkPolicyType h_policy,
473 GtkPolicyType v_policy,
474 void (*func_cb) (), gpointer data);
476 void ghid_dialog_report (gchar * title, gchar * message);
477 void ghid_label_set_markup (GtkWidget * label, const gchar * text);
479 void ghid_set_cursor_position_labels (void);
480 void ghid_set_status_line_label (void);
483 /* gui-netlist-window.c */
484 void ghid_netlist_window_show (GHidPort * out, gboolean raise);
485 void ghid_netlist_window_update (gboolean init_nodes);
486 void ghid_netlist_nodes_update (LibraryMenuType * net);
488 LibraryMenuType *ghid_get_net_from_node_name (gchar * name, gboolean);
489 void ghid_netlist_highlight_node (gchar * name);
492 /* gui-command-window.c */
493 void ghid_handle_user_command (gboolean raise);
494 void ghid_command_window_show (gboolean raise);
495 gchar *ghid_command_entry_get (gchar * prompt, gchar * command);
496 void ghid_command_use_command_window_sync (void);
498 /* gui-keyref-window.c */
499 void ghid_keyref_window_show (gboolean raise);
501 /* gui-library-window.c */
502 void ghid_library_window_show (GHidPort * out, gboolean raise);
505 /* gui-log-window.c */
506 void ghid_log_window_show (gboolean raise);
507 void ghid_log (const char *fmt, ...);
508 void ghid_logv (const char *fmt, va_list args);
510 /* gui-pinout-window.c */
511 void ghid_pinout_window_show (GHidPort * out, ElementTypePtr Element);
513 /* gtkhid-main.c */
514 void ghid_invalidate_all ();
515 void ghid_get_coords (const char *msg, int *x, int *y);
516 gint PCBChanged (int argc, char **argv, int x, int y);
521 extern GdkPixmap *XC_hand_source, *XC_hand_mask;
522 extern GdkPixmap *XC_lock_source, *XC_lock_mask;
523 extern GdkPixmap *XC_clock_source, *XC_clock_mask;
525 #endif /* __GHID_INCLUDED__ */