3 * This file is part of maemopad+
6 * This software is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * This software is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this software; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 #ifndef SKETCHWIDGET_H
24 #define SKETCHWIDGET_H
28 #define PRESSURE_MIN 0.1
29 #define PRESSURE_MAX 0.35
31 #define BACKGRAPH_LINE_HEIGHT 32
32 #define BACKGRAPH_LINE_MARGIN 40
33 #define BACKGRAPH_LINE_SIZE 1
34 #define BACKGRAPH_LINE_MARGIN_SIZE 2
36 #define BACKGRAPH_GRAPH_WIDTH 32
37 #define BACKGRAPH_GRAPH_SIZE 1
41 SKETCHBACK_UNSET
= -1,
54 #define TILES_ROWSTRIDE TILES_X
61 #define UNDO_LEVELS 10
65 SKETCHSHAPE_FREEHAND
= 0,
72 typedef struct _SketchWidgetTile SketchWidgetTile
;
73 struct _SketchWidgetTile
77 GdkPixmap
*tiledata_new
;
80 typedef struct _SketchWidgetUndo SketchWidgetUndo
;
81 struct _SketchWidgetUndo
85 * keep a linked list for modified tiles with their data
87 GSList
*tileList
; /*list of SketchWidgetTile */
88 char saved_tiles
[TILES_X
* TILES_Y
]; /*fast dupe check*/
91 typedef struct _SketchWidget SketchWidget
;
94 GtkWidget
*scrolledwindow
;
95 GtkWidget
*drawingarea
;
97 GdkPixmap
*backpixmap
;
99 GdkPixmap
*backpixmaps
[SKETCHBACK_COUNT
];
100 int backpixmapheights
[SKETCHBACK_COUNT
];
102 sketchBack backstyle
;
103 sketchBack backstyle_currentimage
;
111 GdkColor brush_color
;
116 unsigned long lastevent_x
, lastevent_y
, start_x
, start_y
, cur_x
, cur_y
;
121 GList
*undolist
; /*list of SketchWidgetUndo, kept reverse */
122 guint undocurrent
; /*current index on the undolist (=available redo steps) */
123 /*undocurrent = 0, no redo available*/
126 * current undo buffer, active when mouse pointer is held down
127 * when mouse pointer is released the new states of tiles will be saved again,
128 * then this will be prepended to *undolist and set to NULL
130 SketchWidgetUndo
*undocurbuffer
;
132 void (*callback_undotoggle
) (SketchWidget
* sk
, gboolean st
, gpointer data
);
133 void (*callback_redotoggle
) (SketchWidget
* sk
, gboolean st
, gpointer data
);
134 gpointer callback_undotoggle_data
;
135 gpointer callback_redotoggle_data
;
138 guint stupidflag
; /*1:ignore next motion_event 2:ignore next keypress 0:normal*/
141 SketchWidget
*sketchwidget_new(gint sizex
, gint sizey
, gboolean border
);
142 void sketchwidget_destroy(SketchWidget
* sk
);
143 gboolean
sketch_configure(GtkWidget
* widget
, GdkEventConfigure
* event
, SketchWidget
* sk
);
145 void sketchwidget_set_undocallback(SketchWidget
* sk
, void *func
, gpointer data
);
146 void sketchwidget_set_redocallback(SketchWidget
* sk
, void *func
, gpointer data
);
147 GtkWidget
*sketchwidget_get_drawingarea(SketchWidget
* sk
);
148 GtkWidget
*sketchwidget_get_mainwidget(SketchWidget
* sk
);
149 gboolean
sketchwidget_get_edited(SketchWidget
* sk
);
150 void sketchwidget_set_edited(SketchWidget
* sk
, gboolean status
);
151 void sketchwidget_clear_real(SketchWidget
* sk
);
152 void sketchwidget_clear(SketchWidget
* sk
);
153 void sketchwidget_set_fillmode(SketchWidget
* sk
, gboolean filled
);
154 void sketchwidget_set_shift(SketchWidget
* sk
, gboolean shift
);
155 gboolean
sketchwidget_get_shift(SketchWidget
* sk
);
156 void sketchwidget_set_shape(SketchWidget
* sk
, sketchShape sp
);
157 void sketchwidget_set_brushsize(SketchWidget
* sk
, guint bsize
);
158 guint
sketchwidget_get_brushsize(SketchWidget
* sk
);
159 void sketchwidget_set_brushcolor(SketchWidget
* sk
, GdkColor col
);
160 GdkColor
sketchwidget_get_brushcolor(SketchWidget
* sk
);
161 void sketchwidget_set_backstyle(SketchWidget
* sk
, sketchBack style
);
163 GdkPixbuf
*sketchwidget_trim_image(GdkPixbuf
* pixbuf
, guint totalw
, guint totalh
, double *w
, double *h
, gboolean doTopLeft
);
165 gboolean
sketchwidget_cut(SketchWidget
* sk
, GtkClipboard
* clippy
);
166 gboolean
sketchwidget_copy(SketchWidget
* sk
, GtkClipboard
* clippy
);
167 gboolean
sketchwidget_paste(SketchWidget
* sk
, GtkClipboard
* clippy
);
170 * unref the result afterwards
172 GdkPixmap
*sketchwidget_get_Pixmap(SketchWidget
* sk
);
177 gboolean
sketchwidget_undo(SketchWidget
* sk
);
178 gboolean
sketchwidget_redo(SketchWidget
* sk
);
179 void sketchwidget_wipe_undo(SketchWidget
* sk
);