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
100 #define NUM_STROKE_TOOLS 3
102 #define TOOLOPT_ERASER_STANDARD 0
103 #define TOOLOPT_ERASER_WHITEOUT 1
104 #define TOOLOPT_ERASER_STROKES 2
106 #define HILITER_ALPHA_MASK 0xffffff80
108 extern double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX];
110 typedef struct BBox {
111 double left, right, top, bottom;
114 struct UndoErasureData;
116 typedef struct Item {
118 struct Brush brush; // the brush to use, if ITEM_STROKE
119 GnomeCanvasPoints *path;
120 GnomeCanvasItem *canvas_item; // the corresponding canvas item, or NULL
122 struct UndoErasureData *erasure; // for temporary use during erasures
125 // item type values for Item.type, UndoItem.type, ui.cur_item_type ...
126 // (not all are valid in all places)
128 #define ITEM_STROKE 0
129 #define ITEM_TEMP_STROKE 1
130 #define ITEM_ERASURE 2
131 #define ITEM_SELECTRECT 3
132 #define ITEM_MOVESEL 4
134 #define ITEM_NEW_LAYER 6
135 #define ITEM_DELETE_LAYER 7
136 #define ITEM_NEW_BG_ONE 8
137 #define ITEM_NEW_BG_RESIZE 9
138 #define ITEM_PAPER_RESIZE 10
139 #define ITEM_NEW_DEFAULT_BG 11
140 #define ITEM_NEW_PAGE 13
141 #define ITEM_DELETE_PAGE 14
142 #define ITEM_REPAINTSEL 15
144 typedef struct Layer {
145 GList *items; // the items on the layer, from bottom to top
147 GnomeCanvasGroup *group;
150 typedef struct Page {
151 GList *layers; // the layers on the page
153 double height, width;
154 double hoffset, voffset; // offsets of canvas group rel. to canvas root
155 struct Background *bg;
156 GnomeCanvasGroup *group;
159 typedef struct Journal {
160 GList *pages; // the pages in the journal
162 int last_attach_no; // for naming of attached backgrounds
165 typedef struct Selection {
167 BBox bbox; // the rectangle bbox of the selection
168 struct Layer *layer; // the layer on which the selection lives
169 double anchor_x, anchor_y, last_x, last_y; // for selection motion
170 GnomeCanvasItem *canvas_item; // if the selection box is on screen
171 GList *items; // the selected items (a list of struct Item)
174 typedef struct UIData {
175 int pageno, layerno; // the current page and layer
176 struct Page *cur_page;
177 struct Layer *cur_layer;
178 int toolno; // the number of the currently selected tool
179 gboolean saved; // is file saved ?
180 struct Brush *cur_brush; // the brush in use (one of brushes[...])
181 struct Brush brushes[NUM_STROKE_TOOLS]; // the current pen, eraser, hiliter
182 struct Brush default_brushes[NUM_STROKE_TOOLS]; // the default ones
183 gboolean ruler; // whether we're in ruler mode
184 struct Page default_page; // the model for the default page
185 int layerbox_length; // the number of entries registered in the layers combo-box
186 struct Item *cur_item; // the item being drawn, or NULL
188 GnomeCanvasPoints cur_path; // the path being drawn
189 int cur_path_storage_alloc;
190 int which_mouse_button; // the mouse button drawing the current path
191 int saved_toolno; // while using an eraser device
192 gboolean saved_ruler;
193 double zoom; // zoom factor, in pixels per pt
194 gboolean use_xinput; // use input devices instead of core pointer
195 gboolean allow_xinput; // allow use of xinput ?
196 int screen_width, screen_height; // initial screen size, for XInput events
198 gboolean view_continuous, fullscreen;
199 gboolean in_update_page_stuff; // semaphore to avoid scrollbar retroaction
200 struct Selection *selection;
202 gboolean emulate_eraser;
203 gboolean antialias_bg; // bilinear interpolation on bg pixmaps
204 gboolean progressive_bg; // rescale bg's one at a time
205 char *mrufile; // file for the MRU
206 char *mru[MRU_SIZE]; // MRU data
207 GtkWidget *mrumenu[MRU_SIZE];
210 typedef struct UndoErasureData {
211 struct Item *item; // the item that got erased
212 int npos; // its position in its layer
213 int nrepl; // the number of replacement items
214 GList *replacement_items;
217 typedef struct UndoItem {
219 struct Item *item; // for ITEM_STROKE
220 struct Layer *layer; // for ITEM_STROKE, ITEM_ERASURE, ITEM_PASTE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER
221 struct Layer *layer2; // for ITEM_DELETE_LAYER with val=-1
222 struct Page *page; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
223 GList *erasurelist; // for ITEM_ERASURE
224 GList *itemlist; // for ITEM_MOVESEL, ITEM_PASTE, ITEM_REPAINTSEL
225 GList *auxlist; // for ITEM_REPAINTSEL
226 struct Background *bg; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_DEFAULT_BG
227 int val; // for ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
228 double val_x, val_y; // for ITEM_MOVESEL, ITEM_NEW_BG_RESIZE, ITEM_PAPER_RESIZE, ITEM_NEW_DEFAULT_BG
229 struct UndoItem *next;
233 #define MULTIOP_CONT_REDO 1 // not the last in a multiop, so keep redoing
234 #define MULTIOP_CONT_UNDO 2 // not the first in a multiop, so keep undoing
237 typedef struct BgPdfRequest {
240 gboolean initial_request; // if so, loop over page numbers
241 gboolean is_printing; // this is for printing, not for display
244 typedef struct BgPdfPage {
249 typedef struct BgPdf {
250 int status; // the rest only makes sense if this is not STATUS_NOT_INIT
251 int pid; // PID of the converter process
254 gchar *tmpfile_copy; // the temporary work copy of the file (in tmpdir)
256 GList *pages; // a list of BgPdfPage structures
257 GList *requests; // a list of BgPdfRequest structures
258 gchar *tmpdir; // where to look for pages coming from pdf converter
259 gboolean create_pages; // create journal pages as we find stuff in PDF
260 gboolean has_failed; // has failed in the past...
263 #define STATUS_NOT_INIT 0
264 #define STATUS_IDLE 1
265 #define STATUS_RUNNING 2 // currently running child process on head(requests)
266 #define STATUS_ABORTED 3 // child process running, but head(requests) aborted
267 #define STATUS_SHUTDOWN 4 // waiting for child process to shut down
271 // getting a component of the interface by name
272 #define GET_COMPONENT(a) GTK_WIDGET (g_object_get_data(G_OBJECT (winMain), a))
274 // the margin between consecutive pages in continuous view
275 #define VIEW_CONTINUOUS_SKIP 20.0
280 // the main window and the canvas
282 extern GtkWidget *winMain;
283 extern GnomeCanvas *canvas;
287 extern struct Journal journal;
288 extern struct UIData ui;
289 extern struct BgPdf bgpdf;
290 extern struct UndoItem *undo, *redo;