pcb 4.1.1
An interactive printed circuit board layout editor.

gui.h

Go to the documentation of this file.
00001 /*
00002  *                            COPYRIGHT
00003  *
00004  *  PCB, interactive printed circuit board design
00005  *  Copyright (C) 1994,1995,1996 Thomas Nau
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License along
00018  *  with this program; if not, write to the Free Software Foundation, Inc.,
00019  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00020  *
00021  */
00022 
00023 /* FIXME - rename this file to ghid.h */
00024 
00025 #ifndef PCB_HID_GTK_GHID_H
00026 #define PCB_HID_GTK_GHID_H
00027 
00028 #include <locale.h>
00029 
00030 #include "global.h"
00031 #include "hid.h"
00032 #include "hid_draw.h"
00033 #include "hid/common/hid_resource.h"
00034 
00035 #include "data.h"
00036 #include "misc.h"
00037 #include <sys/stat.h>
00038 
00039 #include <gtk/gtk.h>
00040 #include "ghid-coord-entry.h"
00041 #include "ghid-main-menu.h"
00042 #include "gui-pinout-preview.h"
00043 
00044 
00045   /* Silk and rats lines are the two additional selectable to draw on.
00046      |  gui code in gui-top-window.c and group code in misc.c must agree
00047      |  on what layer is what!
00048    */
00049 #define LAYER_BUTTON_SILK     (MAX_LAYER)
00050 #define LAYER_BUTTON_RATS     (MAX_LAYER + 1)
00051 #define N_SELECTABLE_LAYER_BUTTONS      (LAYER_BUTTON_RATS + 1)
00052 
00053 #define LAYER_BUTTON_PINS     (MAX_ALL_LAYER)
00054 #define LAYER_BUTTON_VIAS     (MAX_ALL_LAYER + 1)
00055 #define LAYER_BUTTON_FARSIDE  (MAX_ALL_LAYER + 2)
00056 #define LAYER_BUTTON_MASK     (MAX_ALL_LAYER + 3)
00057 #define N_LAYER_BUTTONS       (MAX_ALL_LAYER + 4)
00058 
00059   /* Go from from the grid units in use (millimeters or mils) to PCB units
00060      |  and back again.
00061      |  PCB keeps values internally higher precision, but gui
00062      |  widgets (spin buttons, labels, etc) need mils or millimeters.
00063    */
00064 #define FROM_PCB_UNITS(v)       coord_to_unit (Settings.grid_unit, v)
00065 #define TO_PCB_UNITS(v)         unit_to_coord (Settings.grid_unit, v)
00066 
00067 #define SIDE_X(x)         ((gport->view.flip_x ? PCB->MaxWidth - (x) : (x)))
00068 #define SIDE_Y(y)         ((gport->view.flip_y ? PCB->MaxHeight - (y) : (y)))
00069 
00070 #define DRAW_X(x)         (gint)((SIDE_X(x) - gport->view.x0) / gport->view.coord_per_px)
00071 #define DRAW_Y(y)         (gint)((SIDE_Y(y) - gport->view.y0) / gport->view.coord_per_px)
00072 
00073 #define EVENT_TO_PCB_X(x) SIDE_X((gint)((x) * gport->view.coord_per_px + gport->view.x0))
00074 #define EVENT_TO_PCB_Y(y) SIDE_Y((gint)((y) * gport->view.coord_per_px + gport->view.y0))
00075 
00076 /*
00077  * Used to intercept "special" hotkeys that gtk doesn't usually pass
00078  * on to the menu hotkeys.  We catch them and put them back where we
00079  * want them. 
00080  */
00081 
00082 /* The modifier keys */
00083 
00084  #define GHID_KEY_ALT     0x80
00085  #define GHID_KEY_CONTROL 0x40
00086  #define GHID_KEY_SHIFT   0x20
00087 
00088 /* The actual keys */
00089 #define GHID_KEY_TAB      0x01
00090 #define GHID_KEY_UP       0x02
00091 #define GHID_KEY_DOWN     0x03
00092 #define GHID_KEY_LEFT     0x04
00093 #define GHID_KEY_RIGHT    0x05
00094 
00095 typedef struct
00096 {
00097   GtkActionGroup *main_actions,
00098     *change_selected_actions, *displayed_name_actions;
00099 
00100   GtkWidget
00101     *status_line_label,
00102     *cursor_position_relative_label,
00103     *cursor_position_absolute_label,
00104     *grid_units_label, *status_line_hbox, *command_combo_box;
00105   GtkEntry *command_entry;
00106 
00107   GtkWidget *top_hbox,
00108     *top_bar_background,
00109     *menu_hbox, *position_hbox,
00110     *menubar_toolbar_vbox,
00111     *mode_buttons_frame;
00112   GtkWidget *left_toolbar;
00113   GtkWidget *grid_units_button;
00114   GtkWidget *menu_bar, *layer_selector, *route_style_selector;
00115   GtkWidget *mode_toolbar;
00116   GtkWidget *vbox_middle;
00117 
00118   GtkWidget *info_bar;
00119   GTimeVal our_mtime;
00120   GTimeVal last_seen_mtime;
00121 
00122   GtkWidget *h_range, *v_range;
00123   GtkObject *h_adjustment, *v_adjustment;
00124 
00125   GdkPixbuf *bg_pixbuf;
00126 
00127   gchar *name_label_string;
00128 
00129   gboolean adjustment_changed_holdoff,
00130     command_entry_status_line_active,
00131     in_popup;
00132 
00133   gboolean config_modified,
00134     small_label_markup,
00135     compact_horizontal,
00136     compact_vertical,
00137     use_command_window,
00138     creating;
00139 
00140   gint n_mode_button_columns,
00141     top_window_width,
00142     top_window_height,
00143     log_window_width,
00144     log_window_height,
00145     drc_window_width,
00146     drc_window_height,
00147     keyref_window_width,
00148     keyref_window_height,
00149     library_window_width,
00150     library_window_height,
00151     netlist_window_width,
00152     netlist_window_height,
00153     history_size,
00154     settings_mode;
00155 
00156   bool is_up;
00157 }
00158 GhidGui;
00159 
00160 extern GhidGui _ghidgui, *ghidgui;
00161 
00162 typedef struct
00163 {
00164   double coord_per_px; /* Zoom level described as PCB units per screen pixel */
00165 
00166   Coord x0;
00167   Coord y0;
00168   Coord width;
00169   Coord height;
00170 
00171   bool flip_x;
00172   bool flip_y;
00173 
00174 } view_data;
00175 
00176   /* The output viewport
00177    */
00178 typedef struct
00179 {
00180   GtkWidget *top_window,        /* toplevel widget              */
00181    *drawing_area;               /* and its drawing area */
00182   GdkPixmap *pixmap, *mask;
00183   GdkDrawable *drawable;        /* Current drawable for drawing routines */
00184   gint width, height;
00185 
00186   struct render_priv *render_priv;
00187 
00188   GdkColor bg_color, offlimits_color, grid_color;
00189 
00190   GdkColormap *colormap;
00191 
00192   GdkCursor *X_cursor;          /* used X cursor */
00193   GdkCursorType X_cursor_shape; /* and its shape */
00194 
00195   gboolean has_entered;
00196   gboolean panning;
00197 
00198   view_data view;
00199   Coord pcb_x, pcb_y;             /* PCB coordinates of the mouse pointer */
00200   Coord crosshair_x, crosshair_y; /* PCB coordinates of the crosshair     */
00201 
00202   guint tooltip_update_timeout_id;
00203 }
00204 GHidPort;
00205 
00206 extern GHidPort ghid_port, *gport;
00207 
00208 typedef enum
00209 {
00210   NONE_PRESSED               = 0,
00211   SHIFT_PRESSED              = M_Shift,
00212   CONTROL_PRESSED            = M_Ctrl,
00213   MOD1_PRESSED               = M_Mod(1),
00214   SHIFT_CONTROL_PRESSED      = M_Shift | M_Ctrl,
00215   SHIFT_MOD1_PRESSED         = M_Shift | M_Mod(1),
00216   CONTROL_MOD1_PRESSED       = M_Ctrl | M_Mod(1),
00217   SHIFT_CONTROL_MOD1_PRESSED = M_Shift | M_Ctrl | M_Mod(1),
00218 }
00219 ModifierKeysState;
00220 
00221 typedef enum
00222 {
00223   NO_BUTTON_PRESSED,
00224   BUTTON1_PRESSED,
00225   BUTTON2_PRESSED,
00226   BUTTON3_PRESSED
00227 }
00228 ButtonState;
00229 
00230 /* Function prototypes
00231 */
00232 void ghid_parse_arguments (gint * argc, gchar *** argv);
00233 void ghid_do_export (HID_Attr_Val * options);
00234 
00235 void ghid_create_pcb_widgets (void);
00236 void ghid_window_set_name_label (gchar * name);
00237 void ghid_interface_set_sensitive (gboolean sensitive);
00238 void ghid_interface_input_signals_connect (void);
00239 void ghid_interface_input_signals_disconnect (void);
00240 
00241 void ghid_pcb_saved_toggle_states_set (void);
00242 void ghid_sync_with_new_layout (void);
00243 
00244 void ghid_change_selected_update_menu_actions (void);
00245 
00246 void ghid_config_window_show ();
00247 void ghid_config_handle_units_changed (void);
00248 void ghid_config_start_backup_timer (void);
00249 void ghid_config_text_scale_update (void);
00250 void ghid_config_layer_name_update (gchar * name, gint layer);
00251 void ghid_config_groups_changed(void);
00252 
00253 void ghid_config_init (void);
00254 void ghid_config_files_write (void);
00255 void ghid_config_files_read (gint * argc, gchar *** argv);
00256 
00257 void ghid_mode_buttons_update (void);
00258 void ghid_pack_mode_buttons(void);
00259 void ghid_layer_buttons_update (void);
00260 void ghid_layer_buttons_color_update (void);
00261 
00262 
00263 /* gui-misc.c function prototypes
00264 */
00265 void ghid_status_line_set_text (const gchar * text);
00266 void ghid_cursor_position_label_set_text (gchar * text);
00267 void ghid_cursor_position_relative_label_set_text (gchar * text);
00268 
00269 void ghid_hand_cursor (void);
00270 void ghid_point_cursor (void);
00271 void ghid_watch_cursor (void);
00272 void ghid_mode_cursor (gint mode);
00273 void ghid_corner_cursor (void);
00274 void ghid_restore_cursor (void);
00275 void ghid_get_user_xy (const gchar * msg);
00276 void ghid_create_abort_dialog (gchar *);
00277 gboolean ghid_check_abort (void);
00278 void ghid_end_abort (void);
00279 void ghid_get_pointer (gint *, gint *);
00280 
00281 
00282 /* gui-output-events.c function prototypes.
00283 */
00284 void ghid_port_ranges_changed (void);
00285 void ghid_port_ranges_scale (void);
00286 
00287 gboolean ghid_note_event_location (GdkEventButton * ev);
00288 gboolean ghid_port_key_press_cb (GtkWidget * drawing_area,
00289                                  GdkEventKey * kev, gpointer data);
00290 gboolean ghid_port_key_release_cb (GtkWidget * drawing_area,
00291                                    GdkEventKey * kev, gpointer data);
00292 gboolean ghid_port_button_press_cb (GtkWidget * drawing_area,
00293                                     GdkEventButton * ev, gpointer data);
00294 gboolean ghid_port_button_release_cb (GtkWidget * drawing_area,
00295                                       GdkEventButton * ev, gpointer data);
00296 
00297 
00298 gint ghid_port_window_enter_cb (GtkWidget * widget,
00299                            GdkEventCrossing * ev, GHidPort * out);
00300 gint ghid_port_window_leave_cb (GtkWidget * widget, 
00301                            GdkEventCrossing * ev, GHidPort * out);
00302 gint ghid_port_window_motion_cb (GtkWidget * widget,
00303                                  GdkEventMotion * ev, GHidPort * out);
00304 gint ghid_port_window_mouse_scroll_cb (GtkWidget * widget,
00305                                        GdkEventScroll * ev, GHidPort * out);
00306 
00307 gint ghid_port_drawing_area_configure_event_cb (GtkWidget * widget,
00308                                                 GdkEventConfigure * ev,
00309                                                 GHidPort * out);
00310 
00311 
00312 /* gui-dialog.c function prototypes.
00313 */
00314 #define         GUI_DIALOG_RESPONSE_ALL 1
00315 
00316 gchar *ghid_dialog_file_select_open (gchar * title, gchar ** path,
00317                                      gchar * shortcuts);
00318 GSList *ghid_dialog_file_select_multiple (gchar * title, gchar ** path,
00319                                           gchar * shortcuts);
00320 gchar *ghid_dialog_file_select_save (gchar * title, gchar ** path,
00321                                      gchar * file, gchar * shortcuts);
00322 void ghid_dialog_message (gchar * message);
00323 gboolean ghid_dialog_confirm (gchar * message, gchar *cancelmsg, gchar *okmsg);
00324 int ghid_dialog_close_confirm (void);
00325 #define GUI_DIALOG_CLOSE_CONFIRM_CANCEL 0
00326 #define GUI_DIALOG_CLOSE_CONFIRM_NOSAVE 1
00327 #define GUI_DIALOG_CLOSE_CONFIRM_SAVE   2
00328 gint ghid_dialog_confirm_all (gchar * message);
00329 gchar *ghid_dialog_input (const char * prompt, const char * initial);
00330 void ghid_dialog_about (void);
00331 
00332 char * ghid_fileselect (const char *, const char *, char *, char *, const char *, int);
00333 
00334 
00335 /* gui-dialog-print.c */
00336 void ghid_dialog_export (void);
00337 void ghid_dialog_print (HID *);
00338 
00339 int ghid_attribute_dialog (HID_Attribute *, int, HID_Attr_Val *, const char *, const char *);
00340 
00341 /* gui-drc-window.c */
00342 void ghid_drc_window_show (gboolean raise);
00343 void ghid_drc_window_reset_message (void);
00344 void ghid_drc_window_append_violation (DrcViolationType *violation);
00345 void ghid_drc_window_append_messagev (const char *fmt, va_list va);
00346 int ghid_drc_window_throw_dialog (void);
00347 
00348 /* In gui-top-window.c  */
00349 void ghid_update_toggle_flags (void);
00350 void ghid_notify_save_pcb (const char *file, bool done);
00351 void ghid_notify_filename_changed (void);
00352 void ghid_install_accel_groups (GtkWindow *window, GhidGui *gui);
00353 void ghid_remove_accel_groups (GtkWindow *window, GhidGui *gui);
00354 void make_route_style_buttons (GHidRouteStyleSelector *rss);
00355 void layer_process (gchar **color_string, char **text, int *set, int i);
00356 
00357 /* gui-utils.c
00358 */
00359 gboolean dup_string (gchar ** dst, const gchar * src);
00360 void free_glist_and_data (GList ** list_head);
00361 
00362 ModifierKeysState ghid_modifier_keys_state (GdkModifierType *state);
00363 ButtonState ghid_button_state (GdkModifierType *state);
00364 gboolean ghid_is_modifier_key_sym (gint ksym);
00365 gboolean ghid_control_is_pressed (void);
00366 gboolean ghid_mod1_is_pressed (void);
00367 gboolean ghid_shift_is_pressed (void);
00368 
00369 void ghid_draw_area_update (GHidPort * out, GdkRectangle * rect);
00370 gchar *ghid_get_color_name (GdkColor * color);
00371 void ghid_map_color_string (gchar * color_string, GdkColor * color);
00372 gchar *ghid_entry_get_text (GtkWidget * entry);
00373 void ghid_check_button_connected (GtkWidget * box, GtkWidget ** button,
00374                                   gboolean active, gboolean pack_start,
00375                                   gboolean expand, gboolean fill, gint pad,
00376                                   void (*cb_func) (GtkToggleButton *, gpointer), gpointer data,
00377                                   gchar * string);
00378 void ghid_button_connected (GtkWidget * box, GtkWidget ** button,
00379                             gboolean pack_start, gboolean expand,
00380                             gboolean fill, gint pad, void (*cb_func) (gpointer),
00381                             gpointer data, gchar * string);
00382 void ghid_coord_entry (GtkWidget * box, GtkWidget ** coord_entry, Coord value,
00383                        Coord low, Coord high,  enum ce_step_size step_size,
00384                        gint width, void (*cb_func) (GHidCoordEntry *, gpointer),
00385                        gpointer data, gboolean right_align, gchar * string);
00386 void ghid_spin_button (GtkWidget * box, GtkWidget ** spin_button,
00387                        gfloat value, gfloat low, gfloat high, gfloat step0,
00388                        gfloat step1, gint digits, gint width,
00389                        void (*cb_func) (GtkSpinButton *, gpointer), gpointer data,
00390                        gboolean right_align, gchar * string);
00391 void ghid_table_coord_entry (GtkWidget * table, gint row, gint column,
00392                             GtkWidget ** coord_entry, Coord value,
00393                             Coord low, Coord high, enum ce_step_size, gint width,
00394                             void (*cb_func) (GHidCoordEntry *, gpointer), gpointer data,
00395                             gboolean right_align, gchar * string);
00396 void ghid_table_spin_button (GtkWidget * box, gint row, gint column,
00397                              GtkWidget ** spin_button, gfloat value,
00398                              gfloat low, gfloat high, gfloat step0,
00399                              gfloat step1, gint digits, gint width,
00400                              void (*cb_func) (GtkSpinButton *, gpointer), gpointer data,
00401                              gboolean right_align, gchar * string);
00402 
00403 void ghid_range_control (GtkWidget * box, GtkWidget ** scale_res,
00404                          gboolean horizontal, GtkPositionType pos,
00405                          gboolean set_draw_value, gint digits,
00406                          gboolean pack_start, gboolean expand, gboolean fill,
00407                          guint pad, gfloat value, gfloat low, gfloat high,
00408                          gfloat step0, gfloat step1, void (*cb_func) (),
00409                          gpointer data);
00410 GtkWidget *ghid_scrolled_vbox (GtkWidget * box, GtkWidget ** scr,
00411                                GtkPolicyType h_policy,
00412                                GtkPolicyType v_policy);
00413 GtkWidget *ghid_framed_vbox (GtkWidget * box, gchar * label,
00414                              gint frame_border_width, gboolean frame_expand,
00415                              gint vbox_pad, gint vbox_border_width);
00416 GtkWidget *ghid_framed_vbox_end (GtkWidget * box, gchar * label,
00417                                  gint frame_border_width,
00418                                  gboolean frame_expand, gint vbox_pad,
00419                                  gint vbox_border_width);
00420 GtkWidget *ghid_category_vbox (GtkWidget * box, const gchar * category_header,
00421                                gint header_pad, gint box_pad,
00422                                gboolean pack_start, gboolean bottom_pad);
00423 GtkWidget *ghid_notebook_page (GtkWidget * tabs, const char *name, gint pad,
00424                                gint border);
00425 GtkWidget *ghid_framed_notebook_page (GtkWidget * tabs, char *name,
00426                                       gint border, gint frame_border,
00427                                       gint vbox_pad, gint vbox_border);
00428 GtkWidget *ghid_scrolled_text_view (GtkWidget * box, GtkWidget ** scr,
00429                                     GtkPolicyType h_policy,
00430                                     GtkPolicyType v_policy);
00431 void ghid_text_view_append (GtkWidget * view, gchar * string);
00432 void ghid_text_view_append_strings (GtkWidget * view, gchar ** string,
00433                                     gint n_strings);
00434 GtkTreeSelection *ghid_scrolled_selection (GtkTreeView * treeview,
00435                                            GtkWidget * box,
00436                                            GtkSelectionMode s_mode,
00437                                            GtkPolicyType h_policy,
00438                                            GtkPolicyType v_policy,
00439                                            void (*func_cb) (GtkTreeSelection *, gpointer), gpointer data);
00440 
00441 void ghid_dialog_report (gchar * title, gchar * message);
00442 void ghid_label_set_markup (GtkWidget * label, const gchar * text);
00443 
00444 void ghid_set_cursor_position_labels (void);
00445 void ghid_set_status_line_label (void);
00446 
00447 
00448 /* gui-netlist-window.c */
00449 void ghid_netlist_window_create (GHidPort * out);
00450 void ghid_netlist_window_show (GHidPort * out, gboolean raise);
00451 void ghid_netlist_window_update (gboolean init_nodes);
00452 
00453 LibraryMenuType *ghid_get_net_from_node_name (gchar * name, gboolean);
00454 void ghid_netlist_highlight_node (gchar * name);
00455 
00456 
00457 /* gui-command-window.c */
00458 void ghid_handle_user_command (gboolean raise);
00459 void ghid_command_window_show (gboolean raise);
00460 gchar *ghid_command_entry_get (gchar * prompt, gchar * command);
00461 void ghid_command_use_command_window_sync (void);
00462 
00463 /* gui-keyref-window.c */
00464 void ghid_keyref_window_show (gboolean raise);
00465 
00466 /* gui-library-window.c */
00467 void ghid_library_window_create (GHidPort * out);
00468 void ghid_library_window_show (GHidPort * out, gboolean raise);
00469 
00470 
00471 /* gui-log-window.c */
00472 void ghid_log_window_create ();
00473 void ghid_log_window_show (gboolean raise);
00474 void ghid_log (const char *fmt, ...);
00475 void ghid_logv (const char *fmt, va_list args);
00476 
00477 /* gui-pinout-window.c */
00478 void ghid_pinout_window_show (GHidPort *out, ElementType *Element);
00479 
00480 /* gtkhid-gdk.c AND gtkhid-gl.c */
00481 int ghid_set_layer (const char *name, int group, int empty);
00482 hidGC ghid_make_gc (void);
00483 void ghid_destroy_gc (hidGC);
00484 void ghid_use_mask (enum mask_mode mode);
00485 void ghid_set_color (hidGC gc, const char *name);
00486 void ghid_set_line_cap (hidGC gc, EndCapStyle style);
00487 void ghid_set_line_width (hidGC gc, Coord width);
00488 void ghid_set_draw_xor (hidGC gc, int _xor);
00489 void ghid_draw_grid(BoxType * region);
00490 void ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2);
00491 void ghid_draw_arc (hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius,
00492                     Angle start_angle, Angle delta_angle);
00493 void ghid_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2);
00494 void ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius);
00495 void ghid_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y);
00496 void ghid_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2);
00497 void ghid_invalidate_lr (Coord left, Coord right, Coord top, Coord bottom);
00498 void ghid_invalidate_all ();
00499 void ghid_notify_crosshair_change (bool changes_complete);
00500 void ghid_notify_mark_change (bool changes_complete);
00501 void ghid_init_renderer (int *, char ***, GHidPort *);
00502 void ghid_shutdown_renderer (GHidPort *);
00503 void ghid_init_drawing_widget (GtkWidget *widget, GHidPort *);
00504 void ghid_drawing_area_configure_hook (GHidPort *port);
00505 void ghid_screen_update (void);
00506 gboolean ghid_drawing_area_expose_cb (GtkWidget *, GdkEventExpose *,
00507                                       GHidPort *);
00508 void ghid_port_drawing_realize_cb (GtkWidget *, gpointer);
00509 gboolean ghid_pinout_preview_expose (GtkWidget * widget, GdkEventExpose * ev);
00510 GdkPixmap *ghid_render_pixmap (int cx, int cy, double zoom,
00511                                int width, int height, int depth);
00512 HID_DRAW *ghid_request_debug_draw (void);
00513 void ghid_flush_debug_draw (void);
00514 void ghid_finish_debug_draw (void);
00515 bool ghid_event_to_pcb_coords (int event_x, int event_y, Coord *pcb_x, Coord *pcb_y);
00516 bool ghid_pcb_to_event_coords (Coord pcb_x, Coord pcb_y, int *event_x, int *event_y);
00517 void ghid_port_rotate (void *ball, float *quarternion, gpointer userdata);
00518 void ghid_view_2d (void *ball, gboolean view_2d, gpointer userdata);
00519 
00520 void ghid_lead_user_to_location (Coord x, Coord y);
00521 void ghid_cancel_lead_user (void);
00522 
00523 /* gtkhid-main.c */
00524 void ghid_pan_view_rel (Coord dx, Coord dy);
00525 void ghid_get_coords (const char *msg, Coord *x, Coord *y);
00526 gint PCBChanged (int argc, char **argv, Coord x, Coord y);
00527 
00528 
00529 
00530 
00531 extern GdkPixmap *XC_hand_source, *XC_hand_mask;
00532 extern GdkPixmap *XC_lock_source, *XC_lock_mask;
00533 extern GdkPixmap *XC_clock_source, *XC_clock_mask;
00534 
00535 
00536 /* Coordinate conversions */
00537 /* Px converts view->pcb, Vx converts pcb->view */
00538 static inline int
00539 Vx (Coord x)
00540 {
00541   int rv;
00542   if (gport->view.flip_x)
00543     rv = (PCB->MaxWidth - x - gport->view.x0) / gport->view.coord_per_px + 0.5;
00544   else
00545     rv = (x - gport->view.x0) / gport->view.coord_per_px + 0.5;
00546   return rv;
00547 }
00548 
00549 static inline int
00550 Vy (Coord y)
00551 {
00552   int rv;
00553   if (gport->view.flip_y)
00554     rv = (PCB->MaxHeight - y - gport->view.y0) / gport->view.coord_per_px + 0.5;
00555   else
00556     rv = (y - gport->view.y0) / gport->view.coord_per_px + 0.5;
00557   return rv;
00558 }
00559 
00560 static inline int
00561 Vz (Coord z)
00562 {
00563   return z / gport->view.coord_per_px + 0.5;
00564 }
00565 
00566 static inline Coord
00567 Px (int x)
00568 {
00569   Coord rv = x * gport->view.coord_per_px + gport->view.x0;
00570   if (gport->view.flip_x)
00571     rv = PCB->MaxWidth - (x * gport->view.coord_per_px + gport->view.x0);
00572   return  rv;
00573 }
00574 
00575 static inline Coord
00576 Py (int y)
00577 {
00578   Coord rv = y * gport->view.coord_per_px + gport->view.y0;
00579   if (gport->view.flip_y)
00580     rv = PCB->MaxHeight - (y * gport->view.coord_per_px + gport->view.y0);
00581   return  rv;
00582 }
00583 
00584 static inline Coord
00585 Pz (int z)
00586 {
00587   return (z * gport->view.coord_per_px);
00588 }
00589 
00590 #endif /* PCB_HID_GTK_GHID_H */