2 * This file is part of MaePad
3 * Copyright (c) 2010 Thomas Perl <thp@thpinfo.com>
4 * http://thpinfo.com/2010/maepad/
7 * Copyright (c) 2006-2008 Kemal Hadimli
8 * Copyright (c) 2008 Thomas Perl
10 * This software is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1 of
13 * the License, or (at your option) any later version.
15 * This software is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this software; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
33 #include <ui/sketchwidget.h>
36 #include "../he/he-fullscreen-button.h"
39 * If you want to have finger-friendly support (i.e. big fonts in
40 * checklists, big scrollbars in checklists, texts and sketches),
41 * uncomment the following #define line.
43 /* #define MAEMOPADPLUS_FINGER_FRIENDLY */
44 #define MAEMOPADPLUS_FINGER_FONT "sans 20"
46 #include <hildon/hildon-program.h>
47 #include <hildon/hildon-color-button.h>
48 #include <wptextview.h>
49 #include <wptextbuffer.h>
52 #define EXPANDING_ROWS
55 #ifndef EXPANDING_ROWS
56 #error EXPANDING_ROWS is needed for NEW_SEL_LOGIC
59 #define _(String) gettext(String)
61 #define USE_TEMP_TABLES
63 #ifdef USE_TEMP_TABLES
64 #define TEMPTABLE_KEYWORD " TEMP"
66 #define TEMPTABLE_KEYWORD ""
70 RESPONSE_CREATE_NEW
= 1,
76 * confirmation responses
78 #define CONFRESP_YES 1
81 #define CONFRESP_CANCEL 4
82 #define CONFRESP_ERROR 5
84 #define BRUSHSIZE_COUNT 7
86 #define SKETCHNODE_X 288
87 #define SKETCHNODE_Y 96
88 #define SKETCHNODE_RX 144
89 #define SKETCHNODE_RY 48
102 NODEFLAG_SKETCHLINES
= 1 << 0,
103 NODEFLAG_SKETCHGRAPH
= 1 << 1,
104 NODEFLAG_WORDWRAP
= 1 << 2
106 * NODEFLAG_OTHER = 1 << 3
107 * NODEFLAG_OTHER2 = 1 << 4
132 CHECKSTYLE_CHECKED
= 1 << 0,
133 CHECKSTYLE_BOLD
= 1 << 1,
134 CHECKSTYLE_STRIKE
= 1 << 2
137 typedef struct _nodeData nodeData
;
146 unsigned long lastMod
;
151 * Struct to include view's information
153 typedef struct _MainView MainView
;
157 * Handle to app's data
164 GtkWidget
*tools_item
;
165 GtkWidget
*delete_node_item
;
166 GtkWidget
*rename_node_item
;
167 GtkWidget
*export_node_item
;
168 GtkWidget
*move_node_item
;
169 GtkWidget
*move_up_node_item
;
170 GtkWidget
*move_down_node_item
;
171 GtkWidget
*move_to_bottom_node_item
;
172 GtkWidget
*move_to_top_node_item
;
173 GtkWidget
*tools_brushsize
;
174 GtkWidget
*tools_pagestyle
;
175 GtkWidget
*tools_shape
;
176 GtkWidget
*tools_font
;
177 GtkWidget
*tools_wordwrap
;
178 GtkWidget
*tools_color
;
179 GtkWidget
*tools_pressure
;
181 GtkWidget
*brushsizemenu
;
182 GtkWidget
*sketchlinesmenu
;
183 GtkWidget
*shapemenu
;
192 * GtkToolItem* cut_tb;
193 * GtkToolItem* copy_tb;
194 * GtkToolItem* paste_tb;
195 * GtkToolItem* separator_tb2;
197 GtkToolItem
*bold_tb
, *italic_tb
, *underline_tb
, *bullet_tb
, *strikethru_tb
, *check_tb
, *checkadd_tb
, *checkedit_tb
, *checkdel_tb
;
199 GtkToolItem
*font_tb
;
200 GtkToolItem
*colorbutton_tb
;
202 GdkColor
* current_color
;
204 GtkToolItem
*brushsize_tb
;
205 GtkWidget
*brushsizemenuitems
[BRUSHSIZE_COUNT
];
207 GtkToolItem
*eraser_tb
;
209 GtkToolItem
*sketchlines_tb
;
210 GtkWidget
*sketchlinesmenuitems
[3];
212 GtkToolItem
*undo_tb
;
213 GtkToolItem
*redo_tb
;
215 GtkToolItem
*shape_tb
;
216 GtkWidget
*shapemenuitems
[4];
218 GtkToolItem
* fullscreen_tb
;
223 GtkWidget
*scrolledwindow
; /* textview is under this widget */
224 GtkWidget
*textview
; /* widget that shows the text */
225 WPTextBuffer
*buffer
; /* buffer that contains the text */
226 GtkClipboard
*clipboard
; /* clipboard for copy/paste */
228 GtkWidget
*listscroll
; /* checklist is under this widget */
229 GtkWidget
*listview
; /*checklist */
230 GtkTreeViewColumn
*listtextcol
;
232 gboolean checklist_edited
; /* set to TRUE when the checklist is "dirty" and needs to be saved */
235 GtkWidget
*scrolledtree
; /* scrolledwindow for the tree */
236 GtkWidget
* action_area_button_add
; /* "Add new node" button in action area */
238 /* Node list item on which a longpress has been carried out */
239 GtkTreePath
* node_list_longpress_path
;
244 GtkWidget
* main_view_app_menu
;
245 GtkWidget
* menu_button_new
;
246 GtkWidget
* menu_button_open
;
247 GtkWidget
* menu_button_save
;
248 GtkWidget
* menu_button_about
;
250 GtkWidget
* node_view_app_menu
;
251 GtkWidget
* menu_button_rename
;
252 GtkWidget
* menu_button_delete
;
253 GtkWidget
* menu_button_export
;
254 GtkWidget
* menu_button_clear
;
255 GtkWidget
* menu_button_square
;
256 GtkWidget
* menu_button_filled
;
257 /* End AppMenu stuff */
259 gboolean can_show_node_view
;
261 HeFullscreenButton
* node_view_fullscreen_button
;
265 gboolean file_edited
; /* for node operations and notification of new stuff in tmptable */
272 nodeData
*cansel_node
;
276 gboolean newnodedialog_createchild
;
279 #define datatable_name "nodes"
280 #define datatable_tmpname "tmpnodes"
281 #define datatable_backupname "nodesbackup"
283 #define datatable "( \
284 nodeid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
285 parent INTEGER NOT NULL DEFAULT 0, \
286 bodytype INTEGER NOT NULL DEFAULT 0, \
291 lastmodified INTEGER NOT NULL DEFAULT 0, \
292 ord INTEGER NOT NULL DEFAULT 0, \
293 flags INTEGER NOT NULL DEFAULT 0);"
295 #define dataindex "(parent, ord);"
297 #define misctable_name "settings"
298 #define misctable "(skey TEXT UNIQUE, sval TEXT);"
300 #define datatableversion 1
302 #define checklisttable_name "checklists"
303 #define checklisttable_tmpname "tmpchecklists"
304 #define checklisttable_backupname "checklistsbackup"
306 #define checklisttable "( \
307 idx INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
308 nodeid INTEGER NOT NULL DEFAULT 0, \
310 style INTEGER NOT NULL DEFAULT 0, \
311 color INTEGER NOT NULL DEFAULT 0, \
312 ord INTEGER NOT NULL DEFAULT 0);"
313 #define checklistindex "(nodeid, ord);"
315 #define checklisttableversion 1
320 void sk_set_brushsize(MainView
* main
, guint bsize
);
321 void _toggle_tool_button_set_inconsistent(GtkToggleToolButton
*button
, gboolean inconsistent
);
322 MainView
*interface_main_view_new(AppData
* data
);
323 void interface_main_view_destroy(MainView
* main
);
324 gchar
*interface_file_chooser(MainView
* mainview
, GtkFileChooserAction action
, gchar
* suggname
, gchar
* suggext
);
326 /* Get the window that should be used as parent for dialogs */
328 mainview_get_dialog_parent(MainView
* mainview
);
330 SetupResponse
interface_initial_setup(MainView
* main
);