2 #include <libgnomecanvas/libgnomecanvas.h>
4 // DATA STRUCTURES AND CONSTANTS
6 #define PIXEL_MOTION_THRESHOLD 0.3
10 #define DEFAULT_ZOOM 1.3333333333
13 /* a string (+ aux data) that maintains a refcount */
15 typedef struct Refstring {
22 /* The journal is mostly a list of pages. Each page is a list of layers,
23 and a background. Each layer is a list of items, from bottom to top.
26 typedef struct Background {
28 GnomeCanvasItem *canvas_item;
36 int pixbuf_dpi; // for PDF only - the *current* dpi value
37 double pixbuf_scale; // for PIXMAP, this is the *current* zoom value
38 // for PDF, this is the *requested* zoom value
43 #define BG_PDF 2 // not implemented yet
46 #define RULING_LINED 1
47 #define RULING_RULED 2
48 #define RULING_GRAPH 3
50 #define DOMAIN_ABSOLUTE 0
51 #define DOMAIN_ATTACH 1
52 #define DOMAIN_CLONE 2 // only while loading file
54 typedef struct Brush {
68 #define COLOR_LIGHTBLUE 5
69 #define COLOR_LIGHTGREEN 6
70 #define COLOR_MAGENTA 7
71 #define COLOR_ORANGE 8
72 #define COLOR_YELLOW 9
73 #define COLOR_WHITE 10
74 #define COLOR_OTHER -1
77 extern guint predef_colors_rgba[COLOR_MAX];
78 extern guint predef_bgcolors_rgba[COLOR_MAX];
80 #define THICKNESS_VERYFINE 0
81 #define THICKNESS_FINE 1
82 #define THICKNESS_MEDIUM 2
83 #define THICKNESS_THICK 3
84 #define THICKNESS_VERYTHICK 4
85 #define THICKNESS_MAX 5
89 #define TOOL_HIGHLIGHTER 2
91 #define TOOL_SELECTREGION 4
92 #define TOOL_SELECTRECT 5
93 #define TOOL_VERTSPACE 6
94 #define NUM_STROKE_TOOLS 3
96 #define TOOLOPT_ERASER_STANDARD 0
97 #define TOOLOPT_ERASER_WHITEOUT 1
98 #define TOOLOPT_ERASER_STROKES 2
100 #define HILITER_ALPHA_MASK 0xffffff80
102 extern double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX];
104 typedef struct BBox {
105 double left, right, top, bottom;
108 struct UndoErasureData;
110 typedef struct Item {
112 struct Brush brush; // the brush to use, if ITEM_STROKE
113 GnomeCanvasPoints *path;
114 GnomeCanvasItem *canvas_item; // the corresponding canvas item, or NULL
116 struct UndoErasureData *erasure; // for temporary use during erasures
119 // item type values for Item.type, UndoItem.type, ui.cur_item_type ...
120 // (not all are valid in all places)
122 #define ITEM_STROKE 0
123 #define ITEM_TEMP_STROKE 1
124 #define ITEM_ERASURE 2
125 #define ITEM_SELECTRECT 3
126 #define ITEM_MOVESEL 4
128 #define ITEM_NEW_LAYER 6
129 #define ITEM_DELETE_LAYER 7
130 #define ITEM_NEW_BG_ONE 8
131 #define ITEM_NEW_BG_RESIZE 9
132 #define ITEM_PAPER_RESIZE 10
133 #define ITEM_NEW_DEFAULT_BG 11
134 #define ITEM_NEW_PAGE 13
135 #define ITEM_DELETE_PAGE 14
137 typedef struct Layer {
138 GList *items; // the items on the layer, from bottom to top
140 GnomeCanvasGroup *group;
143 typedef struct Page {
144 GList *layers; // the layers on the page
146 double height, width;
147 double hoffset, voffset; // offsets of canvas group rel. to canvas root
148 struct Background *bg;
149 GnomeCanvasGroup *group;
152 typedef struct Journal {
153 GList *pages; // the pages in the journal
155 int last_attach_no; // for naming of attached backgrounds
158 typedef struct Selection {
160 BBox bbox; // the rectangle bbox of the selection
161 struct Layer *layer; // the layer on which the selection lives
162 double anchor_x, anchor_y, last_x, last_y; // for selection motion
163 GnomeCanvasItem *canvas_item; // if the selection box is on screen
164 GList *items; // the selected items (a list of struct Item)
167 typedef struct UIData {
168 int pageno, layerno; // the current page and layer
169 struct Page *cur_page;
170 struct Layer *cur_layer;
171 int toolno; // the number of the currently selected tool
172 gboolean saved; // is file saved ?
173 struct Brush *cur_brush; // the brush in use (one of brushes[...])
174 struct Brush brushes[NUM_STROKE_TOOLS]; // the current pen, eraser, hiliter
175 struct Brush default_brushes[NUM_STROKE_TOOLS]; // the default ones
176 gboolean ruler; // whether we're in ruler mode
177 struct Page default_page; // the model for the default page
178 int layerbox_length; // the number of entries registered in the layers combo-box
179 struct Item *cur_item; // the item being drawn, or NULL
181 GnomeCanvasPoints cur_path; // the path being drawn
182 int cur_path_storage_alloc;
183 int which_mouse_button; // the mouse button drawing the current path
184 int saved_toolno; // while using an eraser device
185 gboolean saved_ruler;
186 double zoom; // zoom factor, in pixels per pt
187 gboolean use_xinput; // use input devices instead of core pointer
188 gboolean allow_xinput; // allow use of xinput ?
189 int screen_width, screen_height; // initial screen size, for XInput events
191 gboolean view_continuous, fullscreen;
192 gboolean in_update_page_stuff; // semaphore to avoid scrollbar retroaction
193 struct Selection *selection;
195 gboolean emulate_eraser;
196 gboolean antialias_bg; // bilinear interpolation on bg pixmaps
197 gboolean progressive_bg; // rescale bg's one at a time
200 typedef struct UndoErasureData {
201 struct Item *item; // the item that got erased
202 int npos; // its position in its layer
203 int nrepl; // the number of replacement items
204 GList *replacement_items;
207 typedef struct UndoItem {
209 struct Item *item; // for ITEM_STROKE
210 struct Layer *layer; // for ITEM_STROKE, ITEM_ERASURE, ITEM_PASTE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER
211 struct Layer *layer2; // for ITEM_DELETE_LAYER with val=-1
212 struct Page *page; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
213 GList *erasurelist; // for ITEM_ERASURE
214 GList *itemlist; // for ITEM_MOVESEL, ITEM_PASTE
215 struct Background *bg; // for ITEM_NEW_BG_ONE/RESIZE, ITEM_NEW_DEFAULT_BG
216 int val; // for ITEM_NEW_PAGE, ITEM_NEW_LAYER, ITEM_DELETE_LAYER, ITEM_DELETE_PAGE
217 double val_x, val_y; // for ITEM_MOVESEL, ITEM_NEW_BG_RESIZE, ITEM_PAPER_RESIZE, ITEM_NEW_DEFAULT_BG
218 struct UndoItem *next;
222 #define MULTIOP_CONT_REDO 1 // not the last in a multiop, so keep redoing
223 #define MULTIOP_CONT_UNDO 2 // not the first in a multiop, so keep undoing
226 typedef struct BgPdfRequest {
229 gboolean initial_request; // if so, loop over page numbers
230 gboolean is_printing; // this is for printing, not for display
233 typedef struct BgPdfPage {
238 typedef struct BgPdf {
239 int status; // the rest only makes sense if this is not STATUS_NOT_INIT
240 int pid; // PID of the converter process
243 gchar *tmpfile_copy; // the temporary work copy of the file (in tmpdir)
245 GList *pages; // a list of BgPdfPage structures
246 GList *requests; // a list of BgPdfRequest structures
247 gchar *tmpdir; // where to look for pages coming from pdf converter
248 gboolean create_pages; // create journal pages as we find stuff in PDF
249 gboolean has_failed; // has failed in the past...
252 #define STATUS_NOT_INIT 0
253 #define STATUS_IDLE 1
254 #define STATUS_RUNNING 2 // currently running child process on head(requests)
255 #define STATUS_ABORTED 3 // child process running, but head(requests) aborted
256 #define STATUS_SHUTDOWN 4 // waiting for child process to shut down
260 // getting a component of the interface by name
261 #define GET_COMPONENT(a) GTK_WIDGET (g_object_get_data(G_OBJECT (winMain), a))
263 // the margin between consecutive pages in continuous view
264 #define VIEW_CONTINUOUS_SKIP 20.0
269 // the main window and the canvas
271 extern GtkWidget *winMain;
272 extern GnomeCanvas *canvas;
276 extern struct Journal journal;
277 extern struct UIData ui;
278 extern struct BgPdf bgpdf;
279 extern struct UndoItem *undo, *redo;