15 #ifdef HAVE_LIBDMALLOC
21 /* This is the "gui" that is installed at startup, and is used when
22 there is no other real GUI to use. For the most part, it just
23 stops the application from (1) crashing randomly, and (2) doing
24 gui-specific things when it shouldn't. */
26 #define CRASH fprintf(stderr, "HID error: pcb called GUI function %s without having a GUI available.\n", __FUNCTION__); abort()
28 typedef struct hid_gc_struct
30 int nothing_interesting_here
;
33 static HID_Attribute
*
34 nogui_get_export_options (int *n_ret
)
41 nogui_do_export (HID_Attr_Val
* options
)
47 nogui_parse_arguments (int *argc
, char ***argv
)
53 nogui_invalidate_wh (int x
, int y
, int width
, int height
, int last
)
59 nogui_invalidate_lr (int l
, int r
, int t
, int b
, int last
)
65 nogui_invalidate_all (void)
71 nogui_set_layer (const char *name
, int idx
, int empty
)
84 nogui_destroy_gc (hidGC gc
)
89 nogui_use_mask (int use_it
)
95 nogui_set_color (hidGC gc
, const char *name
)
101 nogui_set_line_cap (hidGC gc
, EndCapStyle style
)
107 nogui_set_line_width (hidGC gc
, int width
)
113 nogui_set_draw_xor (hidGC gc
, int xor)
119 nogui_set_draw_faded (hidGC gc
, int faded
)
125 nogui_set_line_cap_angle (hidGC gc
, int x1
, int y1
, int x2
, int y2
)
131 nogui_draw_line (hidGC gc
, int x1
, int y1
, int x2
, int y2
)
137 nogui_draw_arc (hidGC gc
, int cx
, int cy
, int width
, int height
,
138 int start_angle
, int end_angle
)
144 nogui_draw_rect (hidGC gc
, int x1
, int y1
, int x2
, int y2
)
150 nogui_fill_circle (hidGC gc
, int cx
, int cy
, int radius
)
156 nogui_fill_polygon (hidGC gc
, int n_coords
, int *x
, int *y
)
162 nogui_fill_pcb_polygon (hidGC gc
, PolygonType
*poly
, const BoxType
*clip_box
)
168 nogui_fill_rect (hidGC gc
, int x1
, int y1
, int x2
, int y2
)
174 nogui_calibrate (double xval
, double yval
)
180 nogui_shift_is_pressed (void)
182 /* This is called from FitCrosshairIntoGrid() when the board is loaded. */
187 nogui_control_is_pressed (void)
194 nogui_get_coords (const char *msg
, int *x
, int *y
)
200 nogui_set_crosshair (int x
, int y
, int action
)
205 nogui_add_timer (void (*func
) (hidval user_data
),
206 unsigned long milliseconds
, hidval user_data
)
215 nogui_stop_timer (hidval timer
)
221 nogui_watch_file (int fd
, unsigned int condition
, void (*func
) (hidval watch
, int fd
, unsigned int condition
, hidval user_data
),
231 nogui_unwatch_file (hidval watch
)
237 nogui_add_block_hook (void (*func
) (hidval data
), hidval data
)
246 nogui_stop_block_hook (hidval block_hook
)
252 nogui_log (const char *fmt
, ...)
261 nogui_logv (const char *fmt
, va_list ap
)
267 nogui_confirm_dialog (char *msg
, ...)
270 printf ("%s ? 0=cancel 1=ok : ", msg
);
277 nogui_close_confirm_dialog ()
279 return nogui_confirm_dialog (_("OK to lose data ?"), NULL
);
283 nogui_report_dialog (char *title
, char *msg
)
285 printf ("--- %s ---\n%s\n", title
, msg
);
289 nogui_prompt_for (char *msg
, char *default_string
)
291 static char buf
[1024];
293 printf ("%s [%s] : ", msg
, default_string
);
295 printf ("%s : ", msg
);
296 fgets (buf
, 1024, stdin
);
297 if (buf
[0] == 0 && default_string
)
298 strcpy (buf
, default_string
);
302 /* FIXME - this could use some enhancement to actually use the other
305 nogui_fileselect (const char *title
, const char *descr
,
306 char *default_file
, char *default_ext
,
307 const char *history_tag
, int flags
)
309 static char buf
[1024];
311 printf ("%s [%s] : ", title
, default_file
);
313 printf ("%s : ", title
);
314 fgets (buf
, 1024, stdin
);
315 if (buf
[0] == 0 && default_file
)
316 strcpy (buf
, default_file
);
321 nogui_attribute_dialog (HID_Attribute
* attrs
,
322 int n_attrs
, HID_Attr_Val
* results
,
323 const char * title
, const char * descr
)
329 nogui_show_item (void *item
)
342 nogui_progress (int so_far
, int total
, const char *message
)
350 "Default GUI when no other GUI is present. Does nothing.",
352 nogui_get_export_options
,
354 nogui_parse_arguments
,
357 nogui_invalidate_all
,
364 nogui_set_line_width
,
366 nogui_set_draw_faded
,
367 nogui_set_line_cap_angle
,
373 nogui_fill_pcb_polygon
,
374 0 /* nogui_thindraw_pcb_polygon */ ,
377 nogui_shift_is_pressed
,
378 nogui_control_is_pressed
,
385 nogui_add_block_hook
,
386 nogui_stop_block_hook
,
389 nogui_confirm_dialog
,
390 nogui_close_confirm_dialog
,
394 nogui_attribute_dialog
,
400 #define AD(x) if (!d->x) d->x = s->x
403 apply_default_hid (HID
* d
, HID
* s
)
407 AD (get_export_options
);
409 AD (parse_arguments
);
421 AD (set_line_cap_angle
);
426 AD (fill_pcb_polygon
);
427 AD (thindraw_pcb_polygon
);
429 AD (shift_is_pressed
);
430 AD (control_is_pressed
);
438 AD (stop_block_hook
);
442 AD (close_confirm_dialog
);
446 AD (attribute_dialog
);