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
29 /*#define NOTIFY_STUPID */
30 /*#define NOTIFY_COORDS */
31 /*#define PRESSURECOLORS_DEBUG */
33 #define PRESSURE_MIN 0.1
34 #define PRESSURE_MAX 0.35
36 #define PRESSURE_COLOR_MAX 0.25
37 #define PRESSURE_COLORS 5
39 #define BACKGRAPH_LINE_HEIGHT 32
40 #define BACKGRAPH_LINE_MARGIN 40
41 #define BACKGRAPH_LINE_SIZE 1
42 #define BACKGRAPH_LINE_MARGIN_SIZE 2
44 #define BACKGRAPH_GRAPH_WIDTH 32
45 #define BACKGRAPH_GRAPH_SIZE 1
49 SKETCHBACK_UNSET
= -1,
62 #define TILES_ROWSTRIDE TILES_X
69 #define UNDO_LEVELS 10
73 SKETCHSHAPE_FREEHAND
= 0,
80 typedef struct _SketchWidgetTile SketchWidgetTile
;
81 struct _SketchWidgetTile
85 GdkPixmap
*tiledata_new
;
88 typedef struct _SketchWidgetUndo SketchWidgetUndo
;
89 struct _SketchWidgetUndo
93 * keep a linked list for modified tiles with their data
95 GSList
*tileList
; /*list of SketchWidgetTile */
96 char saved_tiles
[TILES_X
* TILES_Y
]; /*fast dupe check*/
99 typedef struct _SketchWidget SketchWidget
;
102 GtkWidget
*scrolledwindow
;
103 GtkWidget
*drawingarea
;
105 GdkPixmap
*backpixmap
;
107 GdkPixmap
*backpixmaps
[SKETCHBACK_COUNT
];
108 int backpixmapheights
[SKETCHBACK_COUNT
];
110 sketchBack backstyle
;
111 sketchBack backstyle_currentimage
;
119 GdkColor brush_color
;
122 GdkColor brush_colors
[PRESSURE_COLORS
];
123 gdouble brush_colors_pressure_index
[PRESSURE_COLORS
];
125 gboolean pressuresensitivity
;
129 unsigned long lastevent_x
, lastevent_y
, start_x
, start_y
, cur_x
, cur_y
;
131 gboolean coords_valid
; /*if start_x/start_y valid*/
135 GList
*undolist
; /*list of SketchWidgetUndo, kept reverse */
136 guint undocurrent
; /*current index on the undolist (=available redo steps) */
137 /*undocurrent = 0, no redo available*/
140 * current undo buffer, active when mouse pointer is held down
141 * when mouse pointer is released the new states of tiles will be saved again,
142 * then this will be prepended to *undolist and set to NULL
144 SketchWidgetUndo
*undocurbuffer
;
146 void (*callback_undotoggle
) (SketchWidget
* sk
, gboolean st
, gpointer data
);
147 void (*callback_redotoggle
) (SketchWidget
* sk
, gboolean st
, gpointer data
);
148 gpointer callback_undotoggle_data
;
149 gpointer callback_redotoggle_data
;
151 void (*callback_finger
) (SketchWidget
* sk
, gint x
, gint y
, gdouble pressure
, gpointer data
);
152 gpointer callback_finger_data
;
155 guint stupidflag
; /*1:ignore next motion_event 2:ignore next keypress 0:normal*/
158 SketchWidget
*sketchwidget_new(gint sizex
, gint sizey
, gboolean border
);
159 void sketchwidget_destroy(SketchWidget
* sk
);
160 gboolean
sketch_configure(GtkWidget
* widget
, GdkEventConfigure
* event
, SketchWidget
* sk
);
162 void sketchwidget_set_fingercallback(SketchWidget
* sk
, void *func
, gpointer data
);
163 void sketchwidget_set_undocallback(SketchWidget
* sk
, void *func
, gpointer data
);
164 void sketchwidget_set_redocallback(SketchWidget
* sk
, void *func
, gpointer data
);
165 GtkWidget
*sketchwidget_get_drawingarea(SketchWidget
* sk
);
166 GtkWidget
*sketchwidget_get_mainwidget(SketchWidget
* sk
);
167 gboolean
sketchwidget_get_edited(SketchWidget
* sk
);
168 void sketchwidget_set_edited(SketchWidget
* sk
, gboolean status
);
169 void sketchwidget_clear_real(SketchWidget
* sk
);
170 void sketchwidget_clear(SketchWidget
* sk
);
171 void sketchwidget_set_fillmode(SketchWidget
* sk
, gboolean filled
);
172 void sketchwidget_set_shift(SketchWidget
* sk
, gboolean shift
);
173 gboolean
sketchwidget_get_shift(SketchWidget
* sk
);
174 void sketchwidget_set_shape(SketchWidget
* sk
, sketchShape sp
);
175 void sketchwidget_set_brushsize(SketchWidget
* sk
, guint bsize
);
176 guint
sketchwidget_get_brushsize(SketchWidget
* sk
);
177 void sketchwidget_set_brushcolor(SketchWidget
* sk
, GdkColor col
);
178 GdkColor
sketchwidget_get_brushcolor(SketchWidget
* sk
);
179 void sketchwidget_set_backstyle(SketchWidget
* sk
, sketchBack style
);
181 GdkPixbuf
*sketchwidget_trim_image(GdkPixbuf
* pixbuf
, guint totalw
, guint totalh
, double *w
, double *h
, gboolean doTopLeft
);
183 gboolean
sketchwidget_cut(SketchWidget
* sk
, GtkClipboard
* clippy
);
184 gboolean
sketchwidget_copy(SketchWidget
* sk
, GtkClipboard
* clippy
);
185 gboolean
sketchwidget_paste(SketchWidget
* sk
, GtkClipboard
* clippy
);
188 * unref the result afterwards
190 GdkPixmap
*sketchwidget_get_Pixmap(SketchWidget
* sk
);
195 gboolean
sketchwidget_undo(SketchWidget
* sk
);
196 gboolean
sketchwidget_redo(SketchWidget
* sk
);
197 void sketchwidget_wipe_undo(SketchWidget
* sk
);