2 #include <libgnomecanvas/libgnomecanvas.h>
4 #define ENABLE_XINPUT_BUGFIX
5 /* comment out this line if you are experiencing calibration problems with
6 XInput and want to try things differently. This will probably break
7 on-the-fly display rotation after application startup, though. */
11 #define CONFIG_DIR ".xournal"
12 #define MRU_FILE "recent-files"
14 #define CONFIG_FILE "config"
16 // DATA STRUCTURES AND CONSTANTS
18 #define PIXEL_MOTION_THRESHOLD 0.3
22 #define DISPLAY_DPI_DEFAULT 96.0
25 #define VBOX_MAIN_NITEMS 5 // number of interface items in vboxMain
27 /* a string (+ aux data) that maintains a refcount */
29 typedef struct Refstring {
36 /* The journal is mostly a list of pages. Each page is a list of layers,
37 and a background. Each layer is a list of items, from bottom to top.
40 typedef struct Background {
42 GnomeCanvasItem *canvas_item;
50 int pixbuf_dpi; // for PDF only - the *current* dpi value
51 double pixbuf_scale; // for PIXMAP, this is the *current* zoom value
52 // for PDF, this is the *requested* zoom value
57 #define BG_PDF 2 // not implemented yet
60 #define RULING_LINED 1
61 #define RULING_RULED 2
62 #define RULING_GRAPH 3
64 #define DOMAIN_ABSOLUTE 0
65 #define DOMAIN_ATTACH 1
66 #define DOMAIN_CLONE 2 // only while loading file
68 typedef struct Brush {
82 #define COLOR_LIGHTBLUE 5
83 #define COLOR_LIGHTGREEN 6
84 #define COLOR_MAGENTA 7
85 #define COLOR_ORANGE 8
86 #define COLOR_YELLOW 9
87 #define COLOR_WHITE 10
88 #define COLOR_OTHER -1
91 extern guint predef_colors_rgba[COLOR_MAX];
92 extern guint predef_bgcolors_rgba[COLOR_MAX];
94 #define THICKNESS_VERYFINE 0
95 #define THICKNESS_FINE 1
96 #define THICKNESS_MEDIUM 2
97 #define THICKNESS_THICK 3
98 #define THICKNESS_VERYTHICK 4
99 #define THICKNESS_MAX 5
102 #define TOOL_ERASER 1
103 #define TOOL_HIGHLIGHTER 2
105 #define TOOL_SELECTREGION 4
106 #define TOOL_SELECTRECT 5
107 #define TOOL_VERTSPACE 6
109 #define NUM_STROKE_TOOLS 3
111 #define NUM_BUTTONS 3
113 #define TOOLOPT_ERASER_STANDARD 0
114 #define TOOLOPT_ERASER_WHITEOUT 1
115 #define TOOLOPT_ERASER_STROKES 2
117 extern double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX];
119 typedef struct BBox {
120 double left, right, top, bottom;
123 struct UndoErasureData;
125 typedef struct Item {
127 struct Brush brush; // the brush to use, if ITEM_STROKE
128 // 'brush" also contains color info for text items
129 GnomeCanvasPoints *path;
130 GnomeCanvasItem *canvas_item; // the corresponding canvas item, or NULL
132 struct UndoErasureData *erasure; // for temporary use during erasures
133 // the following fields for ITEM_TEXT:
137 GtkWidget *widget; // the widget while text is being edited (ITEM_TEMP_TEXT)
140 // item type values for Item.type, UndoItem.type, ui.cur_item_type ...
141 // (not all are valid in all places)
143 #define ITEM_STROKE 0
144 #define ITEM_TEMP_STROKE 1
145 #define ITEM_ERASURE 2
146 #define ITEM_SELECTRECT 3
147 #define ITEM_MOVESEL 4
149 #define ITEM_NEW_LAYER 6
150 #define ITEM_DELETE_LAYER 7
151 #define ITEM_NEW_BG_ONE 8
152 #define ITEM_NEW_BG_RESIZE 9
153 #define ITEM_PAPER_RESIZE 10
154 #define ITEM_NEW_DEFAULT_BG 11
155 #define ITEM_NEW_PAGE 13
156 #define ITEM_DELETE_PAGE 14
157 #define ITEM_REPAINTSEL 15
158 #define ITEM_MOVESEL_VERT 16
161 #define ITEM_TEMP_TEXT 19
162 #define ITEM_TEXT_EDIT 20
163 #define ITEM_TEXT_ATTRIB 21
165 typedef struct Layer {
166 GList *items; // the items on the layer, from bottom to top
168 GnomeCanvasGroup *group;
171 typedef struct Page {
172 GList *layers; // the layers on the page
174 double height, width;
175 double hoffset, voffset; // offsets of canvas group rel. to canvas root
176 struct Background *bg;
177 GnomeCanvasGroup *group;
180 typedef struct Journal {
181 GList *pages; // the pages in the journal
183 int last_attach_no; // for naming of attached backgrounds
186 typedef struct Selection {
187 int type; // ITEM_SELECTRECT, ITEM_MOVESEL_VERT
188 BBox bbox; // the rectangle bbox of the selection
189 struct Layer *layer; // the layer on which the selection lives
190 double anchor_x, anchor_y, last_x, last_y; // for selection motion
191 GnomeCanvasItem *canvas_item; // if the selection box is on screen
192 GList *items; // the selected items (a list of struct Item)
193 int move_pageno, orig_pageno; // if selection moves to a different page
194 struct Layer *move_layer;
195 float move_pagedelta;
198 typedef struct UIData {
199 int pageno, layerno; // the current page and layer
200 struct Page *cur_page;
201 struct Layer *cur_layer;
202 gboolean saved; // is file saved ?
203 struct Brush *cur_brush; // the brush in use (one of brushes[...])
204 int toolno[NUM_BUTTONS+1]; // the number of the currently selected tool
205 struct Brush brushes[NUM_BUTTONS+1][NUM_STROKE_TOOLS]; // the current pen, eraser, hiliter
206 struct Brush default_brushes[NUM_STROKE_TOOLS]; // the default ones
207 gboolean ruler[NUM_BUTTONS+1]; // whether each button is in ruler mode
208 int linked_brush[NUM_BUTTONS+1]; // whether brushes are linked across buttons
209 int cur_mapping; // the current button number for mappings
210 gboolean use_erasertip;
211 int which_mouse_button; // the mouse button drawing the current path
212 struct Page default_page; // the model for the default page
213 int layerbox_length; // the number of entries registered in the layers combo-box
214 struct Item *cur_item; // the item being drawn, or NULL
216 GnomeCanvasPoints cur_path; // the path being drawn
217 int cur_path_storage_alloc;
218 double zoom; // zoom factor, in pixels per pt
219 gboolean use_xinput; // use input devices instead of core pointer
220 gboolean allow_xinput; // allow use of xinput ?
221 gboolean discard_corepointer; // discard core pointer events in XInput mode
222 gboolean is_corestroke; // this stroke is painted with core pointer
223 int screen_width, screen_height; // initial screen size, for XInput events
224 double hand_refpt[2];
225 int hand_scrollto_cx, hand_scrollto_cy;
226 gboolean hand_scrollto_pending;
228 gchar *default_path; // default path for new notes
229 gboolean view_continuous, fullscreen, maximize_at_start;
230 gboolean in_update_page_stuff; // semaphore to avoid scrollbar retroaction
231 struct Selection *selection;
233 gboolean antialias_bg; // bilinear interpolation on bg pixmaps
234 gboolean progressive_bg; // rescale bg's one at a time
235 char *mrufile, *configfile; // file names for MRU & config
236 char *mru[MRU_SIZE]; // MRU data
237 GtkWidget *mrumenu[MRU_SIZE];
238 gboolean bg_apply_all_pages;
239 int window_default_width, window_default_height, scrollbar_step_increment;
240 gboolean print_ruling; // print the paper ruling ?
241 int default_unit; // the default unit for paper sizes
242 int startuptool; // the default tool at startup
243 gboolean startupruler;
244 int zoom_step_increment; // the increment in the zoom dialog box
245 double zoom_step_factor; // the multiplicative factor in zoom in/out
247 #if GLIB_CHECK_VERSION(2,6,0)
248 GKeyFile *config_data;
250 int vertical_order[2][VBOX_MAIN_NITEMS]; // the order of interface components
251 gchar *default_font_name, *font_name;
252 gdouble default_font_size, font_size;
253 gulong resize_signal_handler;
254 gdouble hiliter_opacity;
255 guint hiliter_alpha_mask;
256 gboolean left_handed; // left-handed mode?
257 gboolean auto_save_prefs; // auto-save preferences ?
258 gboolean shorten_menus; // shorten menus ?
259 gchar *shorten_menu_items; // which items to hide
262 #define BRUSH_LINKED 0
263 #define BRUSH_COPIED 1
264 #define BRUSH_STATIC 2
266 typedef struct UndoErasureData {
267 struct Item *item; // the item that got erased
268 int npos; // its position in its layer
269 int nrepl; // the number of replacement items
270 GList *replacement_items;
273 typedef struct UndoItem {
275 struct Item *item; // for ITEM_STROKE, ITEM_TEXT, ITEM_TEXT_EDIT, ITEM_TEXT_ATTRIB
276 struct Layer *layer; // for ITEM_STROKE, ITEM_ERASURE, ITEM_PASTE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_MOVESEL, ITEM_TEXT, ITEM_TEXT_EDIT
277 struct Layer *layer2; // for ITEM_DELETE_LAYER with val=-1, ITEM_MOVESEL
278 struct Page *page; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
279 GList *erasurelist; // for ITEM_ERASURE
280 GList *itemlist; // for ITEM_MOVESEL, ITEM_PASTE, ITEM_REPAINTSEL
281 GList *auxlist; // for ITEM_REPAINTSEL (brushes), ITEM_MOVESEL (depths)
282 struct Background *bg; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_DEFAULT_BG
283 int val; // for ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
284 double val_x, val_y; // for ITEM_MOVESEL, ITEM_NEW_BG_RESIZE, ITEM_PAPER_RESIZE, ITEM_NEW_DEFAULT_BG, ITEM_TEXT_ATTRIB
285 gchar *str; // for ITEM_TEXT_EDIT, ITEM_TEXT_ATTRIB
286 struct Brush *brush; // for ITEM_TEXT_ATTRIB
287 struct UndoItem *next;
291 #define MULTIOP_CONT_REDO 1 // not the last in a multiop, so keep redoing
292 #define MULTIOP_CONT_UNDO 2 // not the first in a multiop, so keep undoing
295 typedef struct BgPdfRequest {
298 gboolean initial_request; // if so, loop over page numbers
299 gboolean is_printing; // this is for printing, not for display
302 typedef struct BgPdfPage {
307 typedef struct BgPdf {
308 int status; // the rest only makes sense if this is not STATUS_NOT_INIT
309 int pid; // PID of the converter process
312 gchar *tmpfile_copy; // the temporary work copy of the file (in tmpdir)
314 GList *pages; // a list of BgPdfPage structures
315 GList *requests; // a list of BgPdfRequest structures
316 gchar *tmpdir; // where to look for pages coming from pdf converter
317 gboolean create_pages; // create journal pages as we find stuff in PDF
318 gboolean has_failed; // has failed in the past...
321 #define STATUS_NOT_INIT 0
322 #define STATUS_IDLE 1
323 #define STATUS_RUNNING 2 // currently running child process on head(requests)
324 #define STATUS_ABORTED 3 // child process running, but head(requests) aborted
325 #define STATUS_SHUTDOWN 4 // waiting for child process to shut down
329 // getting a component of the interface by name
330 #define GET_COMPONENT(a) GTK_WIDGET (g_object_get_data(G_OBJECT (winMain), a))
332 // the margin between consecutive pages in continuous view
333 #define VIEW_CONTINUOUS_SKIP 20.0
338 // the main window and the canvas
340 extern GtkWidget *winMain;
341 extern GnomeCanvas *canvas;
345 extern struct Journal journal;
346 extern struct UIData ui;
347 extern struct BgPdf bgpdf;
348 extern struct UndoItem *undo, *redo;
350 extern double DEFAULT_ZOOM;