2 #include <libgnomecanvas/libgnomecanvas.h>
6 #define CONFIG_DIR ".xournal"
7 #define MRU_FILE "recent-files"
10 // DATA STRUCTURES AND CONSTANTS
12 #define PIXEL_MOTION_THRESHOLD 0.3
16 #define DEFAULT_ZOOM 1.3333333333
19 /* a string (+ aux data) that maintains a refcount */
21 typedef struct Refstring {
28 /* The journal is mostly a list of pages. Each page is a list of layers,
29 and a background. Each layer is a list of items, from bottom to top.
32 typedef struct Background {
34 GnomeCanvasItem *canvas_item;
42 int pixbuf_dpi; // for PDF only - the *current* dpi value
43 double pixbuf_scale; // for PIXMAP, this is the *current* zoom value
44 // for PDF, this is the *requested* zoom value
49 #define BG_PDF 2 // not implemented yet
52 #define RULING_LINED 1
53 #define RULING_RULED 2
54 #define RULING_GRAPH 3
56 #define DOMAIN_ABSOLUTE 0
57 #define DOMAIN_ATTACH 1
58 #define DOMAIN_CLONE 2 // only while loading file
60 typedef struct Brush {
74 #define COLOR_LIGHTBLUE 5
75 #define COLOR_LIGHTGREEN 6
76 #define COLOR_MAGENTA 7
77 #define COLOR_ORANGE 8
78 #define COLOR_YELLOW 9
79 #define COLOR_WHITE 10
80 #define COLOR_OTHER -1
83 extern guint predef_colors_rgba[COLOR_MAX];
84 extern guint predef_bgcolors_rgba[COLOR_MAX];
86 #define THICKNESS_VERYFINE 0
87 #define THICKNESS_FINE 1
88 #define THICKNESS_MEDIUM 2
89 #define THICKNESS_THICK 3
90 #define THICKNESS_VERYTHICK 4
91 #define THICKNESS_MAX 5
95 #define TOOL_HIGHLIGHTER 2
97 #define TOOL_SELECTREGION 4
98 #define TOOL_SELECTRECT 5
99 #define TOOL_VERTSPACE 6
101 #define NUM_STROKE_TOOLS 3
102 #define NUM_BUTTONS 3
104 #define TOOLOPT_ERASER_STANDARD 0
105 #define TOOLOPT_ERASER_WHITEOUT 1
106 #define TOOLOPT_ERASER_STROKES 2
108 #define HILITER_ALPHA_MASK 0xffffff80
110 extern double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX];
112 typedef struct BBox {
113 double left, right, top, bottom;
116 struct UndoErasureData;
118 typedef struct Item {
120 struct Brush brush; // the brush to use, if ITEM_STROKE
121 GnomeCanvasPoints *path;
122 GnomeCanvasItem *canvas_item; // the corresponding canvas item, or NULL
124 struct UndoErasureData *erasure; // for temporary use during erasures
127 // item type values for Item.type, UndoItem.type, ui.cur_item_type ...
128 // (not all are valid in all places)
130 #define ITEM_STROKE 0
131 #define ITEM_TEMP_STROKE 1
132 #define ITEM_ERASURE 2
133 #define ITEM_SELECTRECT 3
134 #define ITEM_MOVESEL 4
136 #define ITEM_NEW_LAYER 6
137 #define ITEM_DELETE_LAYER 7
138 #define ITEM_NEW_BG_ONE 8
139 #define ITEM_NEW_BG_RESIZE 9
140 #define ITEM_PAPER_RESIZE 10
141 #define ITEM_NEW_DEFAULT_BG 11
142 #define ITEM_NEW_PAGE 13
143 #define ITEM_DELETE_PAGE 14
144 #define ITEM_REPAINTSEL 15
145 #define ITEM_MOVESEL_VERT 16
148 typedef struct Layer {
149 GList *items; // the items on the layer, from bottom to top
151 GnomeCanvasGroup *group;
154 typedef struct Page {
155 GList *layers; // the layers on the page
157 double height, width;
158 double hoffset, voffset; // offsets of canvas group rel. to canvas root
159 struct Background *bg;
160 GnomeCanvasGroup *group;
163 typedef struct Journal {
164 GList *pages; // the pages in the journal
166 int last_attach_no; // for naming of attached backgrounds
169 typedef struct Selection {
170 int type; // ITEM_SELECTRECT, ITEM_MOVESEL_VERT
171 BBox bbox; // the rectangle bbox of the selection
172 struct Layer *layer; // the layer on which the selection lives
173 double anchor_x, anchor_y, last_x, last_y; // for selection motion
174 GnomeCanvasItem *canvas_item; // if the selection box is on screen
175 GList *items; // the selected items (a list of struct Item)
176 int move_pageno, orig_pageno; // if selection moves to a different page
177 struct Layer *move_layer;
178 float move_pagedelta;
181 typedef struct UIData {
182 int pageno, layerno; // the current page and layer
183 struct Page *cur_page;
184 struct Layer *cur_layer;
185 gboolean saved; // is file saved ?
186 struct Brush *cur_brush; // the brush in use (one of brushes[...])
187 int toolno[NUM_BUTTONS+1]; // the number of the currently selected tool
188 struct Brush brushes[NUM_BUTTONS+1][NUM_STROKE_TOOLS]; // the current pen, eraser, hiliter
189 struct Brush default_brushes[NUM_STROKE_TOOLS]; // the default ones
190 gboolean ruler[NUM_BUTTONS+1]; // whether each button is in ruler mode
191 int linked_brush[NUM_BUTTONS+1]; // whether brushes are linked across buttons
192 int cur_mapping; // the current button number for mappings
193 gboolean use_erasertip;
194 int which_mouse_button; // the mouse button drawing the current path
195 struct Page default_page; // the model for the default page
196 int layerbox_length; // the number of entries registered in the layers combo-box
197 struct Item *cur_item; // the item being drawn, or NULL
199 GnomeCanvasPoints cur_path; // the path being drawn
200 int cur_path_storage_alloc;
201 double zoom; // zoom factor, in pixels per pt
202 gboolean use_xinput; // use input devices instead of core pointer
203 gboolean allow_xinput; // allow use of xinput ?
204 int screen_width, screen_height; // initial screen size, for XInput events
205 double hand_refpt[2];
207 gboolean view_continuous, fullscreen;
208 gboolean in_update_page_stuff; // semaphore to avoid scrollbar retroaction
209 struct Selection *selection;
211 gboolean antialias_bg; // bilinear interpolation on bg pixmaps
212 gboolean progressive_bg; // rescale bg's one at a time
213 char *mrufile; // file for the MRU
214 char *mru[MRU_SIZE]; // MRU data
215 GtkWidget *mrumenu[MRU_SIZE];
216 gboolean bg_apply_all_pages;
219 #define BRUSH_LINKED 0
220 #define BRUSH_COPIED 1
221 #define BRUSH_STATIC 2
223 typedef struct UndoErasureData {
224 struct Item *item; // the item that got erased
225 int npos; // its position in its layer
226 int nrepl; // the number of replacement items
227 GList *replacement_items;
230 typedef struct UndoItem {
232 struct Item *item; // for ITEM_STROKE
233 struct Layer *layer; // for ITEM_STROKE, ITEM_ERASURE, ITEM_PASTE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_MOVESEL
234 struct Layer *layer2; // for ITEM_DELETE_LAYER with val=-1, ITEM_MOVESEL
235 struct Page *page; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
236 GList *erasurelist; // for ITEM_ERASURE
237 GList *itemlist; // for ITEM_MOVESEL, ITEM_PASTE, ITEM_REPAINTSEL
238 GList *auxlist; // for ITEM_REPAINTSEL (brushes), ITEM_MOVESEL (depths)
239 struct Background *bg; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_DEFAULT_BG
240 int val; // for ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
241 double val_x, val_y; // for ITEM_MOVESEL, ITEM_NEW_BG_RESIZE, ITEM_PAPER_RESIZE, ITEM_NEW_DEFAULT_BG
242 struct UndoItem *next;
246 #define MULTIOP_CONT_REDO 1 // not the last in a multiop, so keep redoing
247 #define MULTIOP_CONT_UNDO 2 // not the first in a multiop, so keep undoing
250 typedef struct BgPdfRequest {
253 gboolean initial_request; // if so, loop over page numbers
254 gboolean is_printing; // this is for printing, not for display
257 typedef struct BgPdfPage {
262 typedef struct BgPdf {
263 int status; // the rest only makes sense if this is not STATUS_NOT_INIT
264 int pid; // PID of the converter process
267 gchar *tmpfile_copy; // the temporary work copy of the file (in tmpdir)
269 GList *pages; // a list of BgPdfPage structures
270 GList *requests; // a list of BgPdfRequest structures
271 gchar *tmpdir; // where to look for pages coming from pdf converter
272 gboolean create_pages; // create journal pages as we find stuff in PDF
273 gboolean has_failed; // has failed in the past...
276 #define STATUS_NOT_INIT 0
277 #define STATUS_IDLE 1
278 #define STATUS_RUNNING 2 // currently running child process on head(requests)
279 #define STATUS_ABORTED 3 // child process running, but head(requests) aborted
280 #define STATUS_SHUTDOWN 4 // waiting for child process to shut down
284 // getting a component of the interface by name
285 #define GET_COMPONENT(a) GTK_WIDGET (g_object_get_data(G_OBJECT (winMain), a))
287 // the margin between consecutive pages in continuous view
288 #define VIEW_CONTINUOUS_SKIP 20.0
293 // the main window and the canvas
295 extern GtkWidget *winMain;
296 extern GnomeCanvas *canvas;
300 extern struct Journal journal;
301 extern struct UIData ui;
302 extern struct BgPdf bgpdf;
303 extern struct UndoItem *undo, *redo;