2 * This file is part of maemopad+
5 * This software is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1 of
8 * the License, or (at your option) any later version.
10 * This software is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this software; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 #include <ui/sketchwidget.h>
32 * If you want to have finger-friendly support (i.e. big fonts in
33 * checklists, big scrollbars in checklists, texts and sketches),
34 * uncomment the following #define line.
36 /* #define MAEMOPADPLUS_FINGER_FRIENDLY */
37 #define MAEMOPADPLUS_FINGER_FONT "sans 20"
39 #include <hildon/hildon-program.h>
40 #include <hildon/hildon-color-button.h>
41 #include <wptextview.h>
42 #include <wptextbuffer.h>
45 #define EXPANDING_ROWS
48 #ifndef EXPANDING_ROWS
49 #error EXPANDING_ROWS is needed for NEW_SEL_LOGIC
52 #define _(String) gettext(String)
54 #define USE_TEMP_TABLES
56 #ifdef USE_TEMP_TABLES
57 #define TEMPTABLE_KEYWORD " TEMP"
59 #define TEMPTABLE_KEYWORD ""
63 * confirmation responses
65 #define CONFRESP_YES 1
68 #define CONFRESP_CANCEL 4
69 #define CONFRESP_ERROR 5
71 #define BRUSHSIZE_COUNT 7
73 #define SKETCHNODE_X 288
74 #define SKETCHNODE_Y 96
75 #define SKETCHNODE_RX 144
76 #define SKETCHNODE_RY 48
89 NODEFLAG_SKETCHLINES
= 1 << 0,
90 NODEFLAG_SKETCHGRAPH
= 1 << 1,
91 NODEFLAG_WORDWRAP
= 1 << 2
93 * NODEFLAG_OTHER = 1 << 3
94 * NODEFLAG_OTHER2 = 1 << 4
119 CHECKSTYLE_CHECKED
= 1 << 0,
120 CHECKSTYLE_BOLD
= 1 << 1,
121 CHECKSTYLE_STRIKE
= 1 << 2
124 typedef struct _nodeData nodeData
;
133 unsigned long lastMod
;
141 * Struct to include view's information
143 typedef struct _MainView MainView
;
147 * Handle to app's data
152 /*old (guint fullscreen): 0:normal 1:notree-normal 2:normal-full 3:notree-full 4:justdoc-full */
153 /*new (guint viewflags): 1:tree 2:toolbar 4:fullscreen*/
158 GtkWidget
*file_item
;
159 GtkWidget
*tools_item
;
160 GtkWidget
*new_node_item
;
161 GtkWidget
*delete_node_item
;
162 GtkWidget
*rename_node_item
;
163 GtkWidget
*expand_collapse_node_item
;
164 GtkWidget
*export_node_item
;
165 GtkWidget
*move_node_item
;
166 GtkWidget
*move_up_node_item
;
167 GtkWidget
*move_down_node_item
;
168 GtkWidget
*move_to_bottom_node_item
;
169 GtkWidget
*move_to_top_node_item
;
171 GtkWidget
*open_item
;
172 GtkWidget
*save_item
;
173 GtkWidget
*edit_item
;
175 GtkWidget
*copy_item
;
176 GtkWidget
*paste_item
;
177 GtkWidget
*clear_item
;
178 GtkWidget
*tools_brushsize
;
179 GtkWidget
*tools_pagestyle
;
180 GtkWidget
*tools_shape
;
181 GtkWidget
*tools_font
;
182 GtkWidget
*tools_wordwrap
;
183 GtkWidget
*tools_color
;
184 GtkWidget
*tools_pressure
;
185 GtkWidget
*view_item
;
187 GtkWidget
*brushsizemenu
;
188 GtkWidget
*sketchlinesmenu
;
190 GtkWidget
*shapemenu
;
198 GtkToolItem
*toggletree_tb
;
203 * GtkToolItem* open_tb;
205 GtkToolItem
*save_tb
;
206 GtkToolItem
*separator_tb1
;
209 * GtkToolItem* cut_tb;
210 * GtkToolItem* copy_tb;
211 * GtkToolItem* paste_tb;
212 * GtkToolItem* separator_tb2;
214 GtkToolItem
*bold_tb
, *italic_tb
, *underline_tb
, *bullet_tb
, *strikethru_tb
, *check_tb
, *checkadd_tb
, *checkdel_tb
;
216 GtkToolItem
*font_tb
;
217 GtkWidget
*colorbutton
;
218 GtkToolItem
*colorbutton_tb
;
219 GtkWidget
*viewmenuitems
[3];
221 GtkToolItem
*brushsize_tb
;
222 GtkWidget
*brushsizemenuitems
[BRUSHSIZE_COUNT
];
224 GtkToolItem
*eraser_tb
;
226 GtkToolItem
*sketchlines_tb
;
227 GtkWidget
*sketchlinesmenuitems
[3];
229 GtkToolItem
*undo_tb
;
230 GtkToolItem
*redo_tb
;
232 GtkToolItem
*shape_tb
;
233 GtkWidget
*shapemenuitems
[4];
235 GtkEntry
*search_entry
;
240 GtkWidget
*scrolledwindow
; /* textview is under this widget */
241 GtkWidget
*textview
; /* widget that shows the text */
242 WPTextBuffer
*buffer
; /* buffer that contains the text */
243 GtkClipboard
*clipboard
; /* clipboard for copy/paste */
245 GtkWidget
*listscroll
; /* checklist is under this widget */
246 GtkWidget
*listview
; /*checklist */
247 GtkTreeViewColumn
*listtextcol
;
250 GtkWidget
*scrolledtree
; /* scrolledwindow for the tree */
251 GtkWidget
*hpaned
; /* hpaned between tree and document */
254 guint brushsize_backup
;
256 GdkCursor
*cursorBusy
;
259 gboolean file_edited
; /* for node operations and notification of new stuff in tmptable */
263 /* For highlighting searches */
264 char* color_highlight
;
269 nodeData
*cansel_node
;
273 gboolean newnodedialog_createchild
;
277 /* Initial size and increment for the search result node ID array */
278 #define SEARCH_RESULTS_ARRAY_SIZE 64
280 /* Saves the found node IDs after a search */
281 typedef struct _SearchResults SearchResults
;
282 struct _SearchResults
{
290 #define datatable_name "nodes"
291 #define datatable_tmpname "tmpnodes"
292 #define datatable_backupname "nodesbackup"
294 #define datatable "( \
295 nodeid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
296 parent INTEGER NOT NULL DEFAULT 0, \
297 bodytype INTEGER NOT NULL DEFAULT 0, \
302 lastmodified INTEGER NOT NULL DEFAULT 0, \
303 ord INTEGER NOT NULL DEFAULT 0, \
304 flags INTEGER NOT NULL DEFAULT 0);"
306 #define dataindex "(parent, ord);"
308 #define misctable_name "settings"
309 #define misctable "(skey TEXT UNIQUE, sval TEXT);"
311 #define datatableversion 1
313 #define checklisttable_name "checklists"
314 #define checklisttable_tmpname "tmpchecklists"
315 #define checklisttable_backupname "checklistsbackup"
317 #define checklisttable "( \
318 idx INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
319 nodeid INTEGER NOT NULL DEFAULT 0, \
321 style INTEGER NOT NULL DEFAULT 0, \
322 color INTEGER NOT NULL DEFAULT 0, \
323 ord INTEGER NOT NULL DEFAULT 0);"
324 #define checklistindex "(nodeid, ord);"
326 #define checklisttableversion 1
331 void sk_set_brushsize(MainView
* main
, guint bsize
);
332 void _toggle_tool_button_set_inconsistent(GtkToggleToolButton
*button
, gboolean inconsistent
);
333 MainView
*interface_main_view_new(AppData
* data
);
334 void interface_main_view_destroy(MainView
* main
);
335 gchar
*interface_file_chooser(MainView
* mainview
, GtkFileChooserAction action
, gchar
* suggname
, gchar
* suggext
);
336 gint
interface_create_new_file(MainView
* main
);