00001 #ifndef __VRR_MAIN_H__
00002 #define __VRR_MAIN_H__
00003
00016 #include "lib/lib.h"
00017
00018 #include <gtk/gtk.h>
00019 #include <libguile.h>
00020 #include "kernel/kernel.h"
00021 #include "gui/visualisation.h"
00022
00024 #define MAX_ERR_MSG_LENGTH TRANS_ERR_SIZE + 200
00025
00026 #define VRR_HOMEPAGE "http://vrr.ucw.cz/"
00027
00029 #define TOLERANCE_PIX 10
00030
00031 #define EXTERNAL_TEXT_EDITOR "vim"
00032
00033 #define TEXT_EDITOR_RUN_IN_TERM 1
00034
00035 #define WWW_BROWSER "links"
00036
00037 #define WWW_BROWSER_RUN_IN_TERM 1
00038
00039 #define FAVOURITE_TERMINAL "rxvt"
00040
00041 #define GRID_X1 10.0
00042
00043 #define GRID_Y1 0.0
00044
00045 #define GRID_X2 0.0
00046
00047 #define GRID_Y2 10.0
00048
00049 #define GRID_COLOR (rgba_uns2uns(128, 128, 128, 255))
00050
00051 #define RULERX_RES 10.0
00052
00053 #define RULERY_RES 10.0
00054
00055 #define PANNING_DRAG_IMAGE 0
00056
00057 #define ENABLE_FIFI 0
00058
00060 #define SAFE_G_VALUE(_x) GValue _x; bzero(&_x, sizeof(_x))
00061
00063 enum
00064 {
00065 SNAP_HANGERS = 1,
00066 SNAP_GRID = 2,
00067 SNAP_LINES = 4,
00068 SNAP_INTERS = 8,
00069 SNAP_DEPENDENCY = 16
00070 };
00071
00072 extern GtkWidget * view_menu;
00073 extern GSList * view_list;
00074 extern GtkWidget * main_window;
00075 extern struct console *console_window;
00076
00078 enum window_type
00079 {
00080 WT_VIEW,
00081 WT_UNDO_HISTORY,
00082 WT_UNIVERSE_BROWSER,
00083 WT_PROPERTIES,
00084 WT_PLUGINS,
00085 WT_TEXT_EDITOR,
00086 WT_CONSOLE,
00087 WT_MAIN_WINDOW,
00088 WT_UNITS,
00089 };
00090
00093 #define WIN_O_MAGIC u8 type; SCM proxy; GtkWidget * statusbar; gint context_id
00094
00096 struct window { WIN_O_MAGIC; };
00098 void win_o_init( struct window * window, uns type );
00100 void win_o_finish( struct window * window );
00101
00103 struct context {
00104 struct window * w;
00105 struct obj_doc * doc;
00106 struct obj_page * page;
00107 struct go_group * group;
00108 struct o * o;
00109 int sel_cnt[GOT_MAX];
00110 int sel_cnt_all;
00111 int msel_cnt_all;
00112 int sel_valid;
00113 int msel_valid;
00114 uns sel_mask;
00115 uns msel_mask;
00116 };
00118 extern struct context context;
00120 void change_context( struct window * window, struct go_group * group, struct o * o );
00121
00122
00124 struct wnd_main
00125 {
00126 WIN_O_MAGIC;
00127 GtkWidget * window;
00128 GtkWidget * menubar, * menubox;
00129 GtkWidget * toolbar, * toolbox;
00130 };
00132 extern struct wnd_main wnd_main;
00134 void main_window_create(void);
00136 void main_window_show(void);
00137
00138 void main_window_refresh_menu(void);
00139 void main_window_refresh_toolbar(void);
00140
00141
00142
00143 struct VrrKernelStore;
00145 struct wnd_univ_browser{
00146 WIN_O_MAGIC;
00147 GtkWidget * window;
00148 int visible;
00149 struct VrrKernelStore * tree_store;
00150 GtkWidget * tree_view;
00151 GtkWidget * menu;
00152 };
00154 extern struct wnd_univ_browser wnd_univ_browser;
00155
00157 void create_universe_browser(void);
00159 void ub_refresh_menu(void);
00161 void ub_context_changed(struct context * old_context);
00162
00163
00165 struct wnd_settings{
00166 GtkWidget *window;
00167 struct prop_item * pi;
00168 struct obj_hook oh;
00169 };
00171 extern struct wnd_settings wnd_settings;
00172
00173
00175 struct wnd_style
00176 {
00177 GtkWidget * window;
00178 struct prop_item * pi;
00179 struct go_hook gh;
00180 };
00182 extern struct wnd_style wnd_style;
00183
00184
00186 struct wnd_plugins
00187 {
00188 WIN_O_MAGIC;
00189 GtkWidget * window;
00190 int visible;
00191 GtkListStore * plugin_list;
00192 GtkTreeStore * function_list;
00193 GtkWidget * plugin_view;
00194 GtkWidget * function_view;
00195 GtkWidget * unload_button;
00196 };
00198 extern struct wnd_plugins wnd_plugins;
00199
00200
00202 enum moving_mode
00203 {
00204 MOVE_NONE,
00205 MOVE_FACTORY,
00206 MOVE_TRANSFORM,
00207 MOVE_TRANSFORM_2,
00208 MOVE_PANNING,
00209 MOVE_PANNING_NAV,
00210 MOVE_PANNING_IMG,
00211 MOVE_SELECT,
00212 MOVE_CNT
00213 };
00214
00215 struct view_navigator;
00216 struct visualisation;
00218 struct view{
00219 WIN_O_MAGIC;
00220 struct go_group * group;
00221 struct obj_page *page;
00222 struct obj_hook obj_hook;
00223 struct go_hook go_hook;
00224 struct visualisation vis;
00225 int tf_drag_on;
00226 struct geom_point transform_origin;
00227 struct geom_point axis;
00228 uns transform_state;
00229 real tolerance;
00230 struct geom_transform2 grid;
00231 struct vcl_affinity * fifi;
00232
00233 GtkWidget *window;
00234 GtkWidget *table;
00235 GtkWidget *vruler;
00236 GtkWidget *hruler;
00237 GtkWidget *toolbar;
00238 GtkWidget *toolbar2;
00239 GtkAdjustment *vadj;
00240 GtkAdjustment *hadj;
00241 GtkWidget *vscrollbar;
00242 GtkWidget *hscrollbar;
00243 GtkWidget *image_on;
00244 GtkWidget *image_modified;
00245 struct view_navigator * navigator;
00246
00247 GtkWidget * zoombar;
00248 GtkWidget * factory_statusbar;
00249 GtkWidget * factory_box;
00250 uns factory_box_full;
00251 GtkWidget * coords_label;
00252 struct prop_item * pi;
00253 };
00255 struct view_navigator
00256 {
00257 GtkWidget * window;
00258 GtkSpinButton * zoom_entry, * rot_entry;
00259 real zoom, rotation;
00260 struct visualisation vis;
00261 struct vcl_path * box;
00262 struct view * parent_view;
00263 };
00265 struct view * create_view(struct go_group * group);
00267 void close_view(struct view * vw);
00268 void view_refresh_toolbar(struct view * vw);
00269 void view_refresh_menu(void);
00270 void view_update_grid(struct view * vw);
00271
00272 void transform_update( struct view *vw );
00273 void view_get_size (struct view * vw, uns *width, uns *height);
00274
00275
00279 void view_moving_start(struct geom_point pix, struct view * vw, enum moving_mode mode, GdkCursorType cursor_type);
00281 void view_moving_end(void);
00283 void view_moving_release( GdkEventButton *event, struct view * vw );
00285 void view_moving_motion( GdkEventMotion *event, struct view *vw );
00287 void view_clicked( GdkEventButton * event, struct view * vw );
00289 void view_selection_start( struct geom_point coords, struct geom_point coords_pix, struct view * vw );
00291 int view_transform_start( GdkEventButton *event, struct geom_point coords, struct geom_point coords_pix, struct view * vw );
00293 void view_s_transform_start( GdkEventButton *event, struct geom_point coords, struct geom_point coords_pix, struct view * view );
00295 void view_panning_start( struct geom_point coords_pix, struct view * vw );
00297 void view_panning_nav_start( struct geom_point coords, struct geom_point coords_pix, struct view * vw );
00298
00302 void set_fifi_on(uns on);
00306 void set_fifi_enabled(uns enabled);
00308 void transform_set_shift( int on, struct view * vw );
00310 void transform_update( struct view *vw );
00313 void transform_recalc_dimen( struct view * vw );
00315 void transform_recalc_all( struct view * vw );
00317 extern enum moving_mode moving_mode;
00318
00319
00320
00321 struct VrrUndoStore;
00323 struct wnd_undo_history{
00324 WIN_O_MAGIC;
00325 GtkWidget * window;
00326 GtkWidget * vbox;
00327 GtkWidget * undo_view;
00328 struct VrrUndoStore * undo_model;
00329 GtkWidget * toolbar;
00330 struct obj_page * page;
00331 struct obj_hook obj_hook;
00332 struct trans_hook trans_hook;
00333 };
00334 extern GSList * wuh_list;
00335
00339 struct wnd_undo_history * create_wnd_undo_history(struct obj_page *page);
00340 void wuh_refresh_toolbar( struct wnd_undo_history * wuh );
00341
00342
00344 struct text_edit
00345 {
00346 WIN_O_MAGIC;
00347 uns mode;
00348 struct o * o;
00349 struct obj_page * parent_page;
00350 struct prop_item * pi;
00351 string text_key;
00352 uns prop_count;
00353 GtkWidget * window;
00354 GtkTextBuffer * text_buf;
00355 GtkWidget * modified_icon;
00356 struct obj_hook obj_hook;
00357 struct go_hook go_hook;
00358 };
00360 extern GSList * text_edit_list;
00362 extern GtkListStore *font_list;
00364 void gui_fonts_finish(void);
00366 int fill_font_list(void);
00368 uns fonts_iter_to_font_id( GtkTreeIter * ti );
00370 int fonts_compare_iter_with( GtkTreeIter * ti, char * filename );
00372 int fonts_get_default(void);
00377 void text_edit_create( struct o * o, string text_key );
00378
00379
00380
00381 enum console_state
00382 {
00383 STATE_NORMAL,
00384 STATE_FSEARCH_FIRST,
00385 STATE_RSEARCH_FIRST,
00386 STATE_FSEARCH,
00387 STATE_RSEARCH
00388 };
00389
00390 struct console_string {
00391 struct snode list;
00392 char *data;
00393 };
00394
00395 struct console_search_stack
00396 {
00397 enum console_state state;
00398 s16 search_buffer_used;
00399 s16 search_buffer_chars;
00400 GtkTextMark *mark;
00401 struct console_search_stack *next;
00402 };
00403
00404 struct console {
00405 WIN_O_MAGIC;
00406 GtkWidget *window;
00407 GtkTextView *text;
00408 GtkTextBuffer *buf;
00409 GtkTextTag *input_tag, *output_tag, *edit_tag;
00410 GtkTextMark *open_mark, *close_mark;
00411
00412 int visible;
00413 int blockread;
00414 enum console_state state;
00415
00416 char *search_buffer;
00417 s16 search_buffer_size;
00418 s16 search_buffer_used;
00419 s16 search_buffer_chars;
00420 struct console_search_stack *search_stack;
00421
00422 SCM port;
00423 };
00424
00425 void console_create (void);
00426 void console_init (void);
00427
00428
00429
00431 enum of_input_kind
00432 {
00433 OFIK_NONE,
00434 OFIK_DPR,
00435 OFIK_PROP,
00436 OFIK_SEL,
00437 OFIK_TRANSFORM,
00438 OFIK_TF,
00439 };
00440
00441 enum of_go_role { OFR_DISPLAY, OFR_CNT };
00443 enum ofs_flags {
00444 OFF_FULL = 1,
00445 OFF_START_MOVE = 2,
00446 OFF_END_MOVE = 4,
00447 OFF_PATHABLE = 8,
00448 OFF_HIDE_HANGERS = 16
00449 };
00451 struct of_state {
00452 uns flags;
00453 enum of_input_kind input_kind;
00454 uns input_type;
00455
00456 uns input_subtype;
00457 union {
00458 struct dist_pass_result dpr;
00459 struct prop prop;
00460 } value;
00461 char * description;
00462 void (* action_func)(struct of_state *);
00463 void (* cleanup_func)(struct of_state *);
00464 struct of_state * prev;
00465 struct of_state * next;
00466 struct undo_gui * prev_undo_item;
00467 struct go * tmp_go[OFR_CNT];
00468 };
00470 extern struct of_state ofs_start;
00472 extern struct of_state ofs_end;
00473
00475 enum of_flags {
00476 OFF_OPERATION_ACTIVE = 1,
00477 OFF_PATH_ON = 2,
00478 OFF_PATH_ACTIVE = 4,
00479 OFF_PATH_DESTROYED = 8
00480 };
00482 extern struct factory {
00483 uns flags;
00484 struct obj_page * page;
00485 struct go_group * group;
00486 struct of_state * state;
00487 struct of_state * start_state;
00488 string desc;
00489 real snap_tolerance;
00490 uns snap_set;
00491 uns snap_tol_pix;
00492 struct hanger * hanger_cursor;
00493 struct go_path * path;
00494 } factory;
00495
00496
00497 extern struct of_state ofs_select;
00498 extern struct of_state ofs_transform_x;
00499 extern struct of_state ofs_point;
00500 extern struct of_state ofs_decorator_pt;
00501 extern struct of_state ofs_arrow;
00502 extern struct of_state ofs_point_inters;
00503 extern struct of_state ofs_ngon_1;
00504 extern struct of_state ofs_segment_1;
00505 extern struct of_state ofs_bez_cub_1;
00506 extern struct of_state ofs_bez_quad_1;
00507 extern struct of_state ofs_arc_3p_1;
00508 extern struct of_state ofs_arc_center_radius_1;
00509 extern struct of_state ofs_circ_3p_1;
00510 extern struct of_state ofs_circ_center_pt_1;
00511 extern struct of_state ofs_circ_center_radius_1;
00512 extern struct of_state ofs_ellipse_3p_smallest_1;
00513 extern struct of_state ofs_ellipse_3p_ecc_1;
00514 extern struct of_state ofs_ellarc_center_radii_1;
00515 extern struct of_state ofs_ellipse_center_radii_1;
00516 extern struct of_state ofs_ellipse_foci_pt_1;
00517 extern struct of_state ofs_ellipse_xy1ecc_1;
00518 extern struct of_state ofs_transform_1;
00519 extern struct of_state ofs_rehang_1, ofs_rehang_2;
00520 extern struct of_state ofs_text_1;
00521 extern struct of_state ofs_tex_text_1;
00522
00523
00524 void factory_init(void);
00525 void factory_finish(void);
00529 void factory_op_start( struct go_group * group, struct of_state * state, char * desc );
00531 void factory_op_break( void );
00533 void factory_moving_step(struct geom_point po);
00536 void factory_op_step( void );
00538 int factory_merge_trans(void);
00540 void factory_op_step_back(void);
00542 void factory_msg(const char * text);
00543
00544 struct go * factory_get_created_go(void);
00545
00553 void snap_point( struct geom_point * pos, struct dist_pass_result * dpr, struct geom_transform2 * grid, struct obj_page * page, real maxdist );
00560 void snap_to_go( struct geom_point * pos, struct dist_pass_result * dpr, struct obj_page * page, real maxdist );
00567 void snap_to_anchor( struct geom_point * pos, struct dist_pass_result * dpr, struct obj_page * page, real maxdist );
00568
00569
00573 char * get_new_noname(void);
00577 char * get_new_page_noname(struct obj_doc * doc);
00581 void refresh_gui(void);
00582
00586 void main_quit(void);
00587
00588
00589 extern GdkPixbuf * icon_arrow_down, * icon_arrow_up, * icon_arrow_left, * icon_arrow_right;
00590 extern GdkPixbuf * icon_pencil_on, * icon_modified;
00591 extern GdkPixbuf * icon_rotation_left, * icon_rotation_right, * icon_zoom_in, * icon_zoom_out;
00592
00593
00594 GdkPixbuf * icon_load( const char * filename );
00595 GtkWidget * image_get_from_icon( GdkPixbuf * icon );
00596
00597 void statusbar_clear(struct window * window);
00598 void statusbar_msg(struct window * window, const char * fmt, ... ) FORMAT(2,3);
00599 #define statusbar_err(_win,...) statusbar_msg(_win, ":-( "__VA_ARGS__)
00600
00605 void modify_selection( struct go * go, struct obj_page * page, GdkEventButton * event, struct geom_rectangle * rect, struct go_group * group );
00607 void modify_meta_selection( struct obj * obj, GdkEventButton * event );
00608
00610 float *new_float(float val);
00611
00613 char *str_trim(char *str);
00614
00615
00616
00617
00618 void on_file_new( void * subj );
00619 void on_file_open( void * subj );
00620 void on_svg_file_import( void * subj );
00621 void on_import_ipe5( void * subj );
00622 void on_file_save( void * subj );
00623 void on_file_save_all( void * subj );
00624 void on_file_save_as( void * subj );
00625 void on_file_close( void * subj );
00626 void on_file_new_page( void * subj );
00627 void on_file_close_page( void * subj );
00628 void on_group_new_view( void * subj );
00629 void on_page_new_view( void * subj );
00630 void on_document_rerun_tex( void * subj );
00631 void on_page_rerun_tex( void * subj );
00632
00633 void on_view_fit_selected( void * subj );
00634 void on_view_fit_all( void * subj );
00635 void on_view_zoom_in( void * subj );
00636 void on_view_zoom_out( void * subj );
00637 void on_view_zoom_reset( void * subj );
00638
00639 void on_export_pdf( void * subj );
00640 void on_export_ps( void * subj );
00641 void on_export_eps( void * subj );
00642 void on_export_svg( void * subj );
00643
00644 void on_set_vrr_options( void * subj );
00645 void on_help( void * subj);
00646 void on_open_www( void * subj);
00647 void on_show_about_window( void * subj );
00648 void on_file_exit( void * subj );
00649 void on_show_property_window( void * subj );
00650 void on_show_console_window( void * subj );
00651 void on_show_universe_browser( void * subj );
00652 void on_show_main_window( void * subj );
00653 void on_show_undo_history( void * subj );
00654 void on_view_clipboard( void * subj );
00655 void on_show_plugin_window( void * subj );
00656 void on_show_unit_window( void * subj );
00657 void on_show_settings_window( void * subj );
00658 void on_show_style_window( void * subj );
00659
00660 void on_copy( void * subj );
00661 void on_cut( void * subj );
00662 void on_paste( void * subj );
00663
00664 void on_obj_copy( void * subj );
00665 void on_obj_cut( void * subj );
00666 void on_obj_paste( void * subj );
00667
00668 void on_group_selected( void * subj );
00669 void on_group_ungroup( void * subj );
00670 void on_group_pathize_selected( void * subj );
00671
00672 void on_group_select_all( void * subj );
00673 void on_group_select_none( void * subj );
00674
00675 void on_move_up( void * subj );
00676 void on_move_down( void * subj );
00677 void on_move_front( void * subj );
00678 void on_move_back( void * subj );
00679
00680 void on_page_move_up( void * subj );
00681 void on_page_move_down( void * subj );
00682 void on_page_move_front( void * subj );
00683 void on_page_move_back( void * subj );
00684
00685 void on_create_proxy( void * subj );
00686
00688 void on_obj_undo( void * subj );
00689 void on_obj_redo( void * subj );
00690 void on_page_undo( void * subj );
00691 void on_page_redo( void * subj );
00692 void on_hist_jump( void * subj );
00693
00694 void on_delete( void * subj );
00695 void on_go_enclose_sel( void * subj );
00696
00697 void on_rotate90( void * subj );
00698 void on_rotate180( void * subj );
00699 void on_rotate270( void * subj );
00700 void on_flip_vertical( void * subj );
00701 void on_flip_horizontal( void * subj );
00702
00704 void on_change_prop( void * subj );
00705 void on_edit_text( void * subj );
00706
00707 void on_undo_history( void * subj );
00708 void on_dump( void * subj );
00709 void on_kerntest( void * subj );
00710
00711
00712 void on_random_point( void * subj );
00713 void on_random_segment( void * subj );
00714 void on_random_bezier_quad( void * subj );
00715 void on_random_bezier_cubic( void * subj );
00716
00717 void on_path_switch( void * subj );
00718 void on_path_end_close( void * subj );
00719 void on_path_end( void * subj );
00720 void on_step_back( void * subj );
00721 void on_break_op( void * subj );
00722
00723
00724 void on_snap_hangers( void * subj );
00725 void on_snap_grid( void * subj );
00726 void on_snap_lines( void * subj );
00727 void on_snap_inters( void * subj );
00728 void on_snap_depend( void * subj );
00729
00730
00731
00734 struct o * o_get_gui_ancestor(struct o * o);
00735
00736 #endif