2 #include <libgnomecanvas/libgnomecanvas.h>
6 #define CONFIG_DIR ".xournal"
7 #define MRU_FILE "recent-files"
9 #define CONFIG_FILE "config"
11 // DATA STRUCTURES AND CONSTANTS
13 #define PIXEL_MOTION_THRESHOLD 0.3
17 #define DISPLAY_DPI_DEFAULT 96.0
20 #define VBOX_MAIN_NITEMS 5 // number of interface items in vboxMain
22 /* a string (+ aux data) that maintains a refcount */
24 typedef struct Refstring {
31 /* The journal is mostly a list of pages. Each page is a list of layers,
32 and a background. Each layer is a list of items, from bottom to top.
35 typedef struct Background {
37 GnomeCanvasItem *canvas_item;
45 int pixbuf_dpi; // for PDF only - the *current* dpi value
46 double pixbuf_scale; // for PIXMAP, this is the *current* zoom value
47 // for PDF, this is the *requested* zoom value
52 #define BG_PDF 2 // not implemented yet
55 #define RULING_LINED 1
56 #define RULING_RULED 2
57 #define RULING_GRAPH 3
59 #define DOMAIN_ABSOLUTE 0
60 #define DOMAIN_ATTACH 1
61 #define DOMAIN_CLONE 2 // only while loading file
63 typedef struct Brush {
77 #define COLOR_LIGHTBLUE 5
78 #define COLOR_LIGHTGREEN 6
79 #define COLOR_MAGENTA 7
80 #define COLOR_ORANGE 8
81 #define COLOR_YELLOW 9
82 #define COLOR_WHITE 10
83 #define COLOR_OTHER -1
86 extern guint predef_colors_rgba[COLOR_MAX];
87 extern guint predef_bgcolors_rgba[COLOR_MAX];
89 #define THICKNESS_VERYFINE 0
90 #define THICKNESS_FINE 1
91 #define THICKNESS_MEDIUM 2
92 #define THICKNESS_THICK 3
93 #define THICKNESS_VERYTHICK 4
94 #define THICKNESS_MAX 5
98 #define TOOL_HIGHLIGHTER 2
100 #define TOOL_SELECTREGION 4
101 #define TOOL_SELECTRECT 5
102 #define TOOL_VERTSPACE 6
104 #define NUM_STROKE_TOOLS 3
106 #define NUM_BUTTONS 3
108 #define TOOLOPT_ERASER_STANDARD 0
109 #define TOOLOPT_ERASER_WHITEOUT 1
110 #define TOOLOPT_ERASER_STROKES 2
112 #define HILITER_ALPHA_MASK 0xffffff80
114 extern double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX];
116 typedef struct BBox {
117 double left, right, top, bottom;
120 struct UndoErasureData;
122 typedef struct Item {
124 struct Brush brush; // the brush to use, if ITEM_STROKE
125 GnomeCanvasPoints *path;
126 GnomeCanvasItem *canvas_item; // the corresponding canvas item, or NULL
128 struct UndoErasureData *erasure; // for temporary use during erasures
131 // item type values for Item.type, UndoItem.type, ui.cur_item_type ...
132 // (not all are valid in all places)
134 #define ITEM_STROKE 0
135 #define ITEM_TEMP_STROKE 1
136 #define ITEM_ERASURE 2
137 #define ITEM_SELECTRECT 3
138 #define ITEM_MOVESEL 4
140 #define ITEM_NEW_LAYER 6
141 #define ITEM_DELETE_LAYER 7
142 #define ITEM_NEW_BG_ONE 8
143 #define ITEM_NEW_BG_RESIZE 9
144 #define ITEM_PAPER_RESIZE 10
145 #define ITEM_NEW_DEFAULT_BG 11
146 #define ITEM_NEW_PAGE 13
147 #define ITEM_DELETE_PAGE 14
148 #define ITEM_REPAINTSEL 15
149 #define ITEM_MOVESEL_VERT 16
152 typedef struct Layer {
153 GList *items; // the items on the layer, from bottom to top
155 GnomeCanvasGroup *group;
158 typedef struct Page {
159 GList *layers; // the layers on the page
161 double height, width;
162 double hoffset, voffset; // offsets of canvas group rel. to canvas root
163 struct Background *bg;
164 GnomeCanvasGroup *group;
167 typedef struct Journal {
168 GList *pages; // the pages in the journal
170 int last_attach_no; // for naming of attached backgrounds
173 typedef struct Selection {
174 int type; // ITEM_SELECTRECT, ITEM_MOVESEL_VERT
175 BBox bbox; // the rectangle bbox of the selection
176 struct Layer *layer; // the layer on which the selection lives
177 double anchor_x, anchor_y, last_x, last_y; // for selection motion
178 GnomeCanvasItem *canvas_item; // if the selection box is on screen
179 GList *items; // the selected items (a list of struct Item)
180 int move_pageno, orig_pageno; // if selection moves to a different page
181 struct Layer *move_layer;
182 float move_pagedelta;
185 typedef struct UIData {
186 int pageno, layerno; // the current page and layer
187 struct Page *cur_page;
188 struct Layer *cur_layer;
189 gboolean saved; // is file saved ?
190 struct Brush *cur_brush; // the brush in use (one of brushes[...])
191 int toolno[NUM_BUTTONS+1]; // the number of the currently selected tool
192 struct Brush brushes[NUM_BUTTONS+1][NUM_STROKE_TOOLS]; // the current pen, eraser, hiliter
193 struct Brush default_brushes[NUM_STROKE_TOOLS]; // the default ones
194 gboolean ruler[NUM_BUTTONS+1]; // whether each button is in ruler mode
195 int linked_brush[NUM_BUTTONS+1]; // whether brushes are linked across buttons
196 int cur_mapping; // the current button number for mappings
197 gboolean use_erasertip;
198 int which_mouse_button; // the mouse button drawing the current path
199 struct Page default_page; // the model for the default page
200 int layerbox_length; // the number of entries registered in the layers combo-box
201 struct Item *cur_item; // the item being drawn, or NULL
203 GnomeCanvasPoints cur_path; // the path being drawn
204 int cur_path_storage_alloc;
205 double zoom; // zoom factor, in pixels per pt
206 gboolean use_xinput; // use input devices instead of core pointer
207 gboolean allow_xinput; // allow use of xinput ?
208 gboolean discard_corepointer; // discard core pointer events in XInput mode
209 gboolean is_corestroke; // this stroke is painted with core pointer
210 int screen_width, screen_height; // initial screen size, for XInput events
211 double hand_refpt[2];
213 gchar *default_path; // default path for new notes
214 gboolean view_continuous, fullscreen, maximize_at_start;
215 gboolean in_update_page_stuff; // semaphore to avoid scrollbar retroaction
216 struct Selection *selection;
218 gboolean antialias_bg; // bilinear interpolation on bg pixmaps
219 gboolean progressive_bg; // rescale bg's one at a time
220 char *mrufile, *configfile; // file names for MRU & config
221 char *mru[MRU_SIZE]; // MRU data
222 GtkWidget *mrumenu[MRU_SIZE];
223 gboolean bg_apply_all_pages;
224 int window_default_width, window_default_height, scrollbar_step_increment;
225 gboolean print_ruling; // print the paper ruling ?
226 int default_unit; // the default unit for paper sizes
227 int startuptool; // the default tool at startup
228 gboolean startupruler;
229 int zoom_step_increment; // the increment in the zoom dialog box
230 double zoom_step_factor; // the multiplicative factor in zoom in/out
232 #if GLIB_CHECK_VERSION(2,6,0)
233 GKeyFile *config_data;
235 int vertical_order[2][VBOX_MAIN_NITEMS]; // the order of interface components
238 #define BRUSH_LINKED 0
239 #define BRUSH_COPIED 1
240 #define BRUSH_STATIC 2
242 typedef struct UndoErasureData {
243 struct Item *item; // the item that got erased
244 int npos; // its position in its layer
245 int nrepl; // the number of replacement items
246 GList *replacement_items;
249 typedef struct UndoItem {
251 struct Item *item; // for ITEM_STROKE
252 struct Layer *layer; // for ITEM_STROKE, ITEM_ERASURE, ITEM_PASTE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_MOVESEL
253 struct Layer *layer2; // for ITEM_DELETE_LAYER with val=-1, ITEM_MOVESEL
254 struct Page *page; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
255 GList *erasurelist; // for ITEM_ERASURE
256 GList *itemlist; // for ITEM_MOVESEL, ITEM_PASTE, ITEM_REPAINTSEL
257 GList *auxlist; // for ITEM_REPAINTSEL (brushes), ITEM_MOVESEL (depths)
258 struct Background *bg; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_DEFAULT_BG
259 int val; // for ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
260 double val_x, val_y; // for ITEM_MOVESEL, ITEM_NEW_BG_RESIZE, ITEM_PAPER_RESIZE, ITEM_NEW_DEFAULT_BG
261 struct UndoItem *next;
265 #define MULTIOP_CONT_REDO 1 // not the last in a multiop, so keep redoing
266 #define MULTIOP_CONT_UNDO 2 // not the first in a multiop, so keep undoing
269 typedef struct BgPdfRequest {
272 gboolean initial_request; // if so, loop over page numbers
273 gboolean is_printing; // this is for printing, not for display
276 typedef struct BgPdfPage {
281 typedef struct BgPdf {
282 int status; // the rest only makes sense if this is not STATUS_NOT_INIT
283 int pid; // PID of the converter process
286 gchar *tmpfile_copy; // the temporary work copy of the file (in tmpdir)
288 GList *pages; // a list of BgPdfPage structures
289 GList *requests; // a list of BgPdfRequest structures
290 gchar *tmpdir; // where to look for pages coming from pdf converter
291 gboolean create_pages; // create journal pages as we find stuff in PDF
292 gboolean has_failed; // has failed in the past...
295 #define STATUS_NOT_INIT 0
296 #define STATUS_IDLE 1
297 #define STATUS_RUNNING 2 // currently running child process on head(requests)
298 #define STATUS_ABORTED 3 // child process running, but head(requests) aborted
299 #define STATUS_SHUTDOWN 4 // waiting for child process to shut down
303 // getting a component of the interface by name
304 #define GET_COMPONENT(a) GTK_WIDGET (g_object_get_data(G_OBJECT (winMain), a))
306 // the margin between consecutive pages in continuous view
307 #define VIEW_CONTINUOUS_SKIP 20.0
312 // the main window and the canvas
314 extern GtkWidget *winMain;
315 extern GnomeCanvas *canvas;
319 extern struct Journal journal;
320 extern struct UIData ui;
321 extern struct BgPdf bgpdf;
322 extern struct UndoItem *undo, *redo;
324 extern double DEFAULT_ZOOM;