GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnucash-item-edit.h
1 /********************************************************************\
2  * This program is free software; you can redistribute it and/or *
3  * modify it under the terms of the GNU General Public License as *
4  * published by the Free Software Foundation; either version 2 of *
5  * the License, or (at your option) any later version. *
6  * *
7  * This program is distributed in the hope that it will be useful, *
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10  * GNU General Public License for more details. *
11  * *
12  * You should have received a copy of the GNU General Public License*
13  * along with this program; if not, contact: *
14  * *
15  * Free Software Foundation Voice: +1-617-542-5942 *
16  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
17  * Boston, MA 02110-1301, USA [email protected] *
18  * *
19 \********************************************************************/
20 
21 #ifndef GNUCASH_ITEM_EDIT_H
22 #define GNUCASH_ITEM_EDIT_H
23 
24 
25 #include "gnucash-date-picker.h"
26 #include "gnucash-item-list.h"
27 #include "gnucash-sheet.h"
28 
29 #define GNC_TYPE_ITEM_EDIT (gnc_item_edit_get_type ())
30 #define GNC_ITEM_EDIT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GNC_TYPE_ITEM_EDIT, GncItemEdit))
31 #define GNC_ITEM_EDIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_ITEM_EDIT, GncItemEditClass))
32 #define GNC_IS_ITEM_EDIT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_ITEM_EDIT))
33 
34 
35 typedef int (*GetPopupHeight) (GnomeCanvasItem *item,
36  int space_available,
37  int row_height,
38  gpointer user_data);
39 
40 typedef int (*PopupAutosize) (GnomeCanvasItem *item,
41  int max_width,
42  gpointer user_data);
43 
44 typedef void (*PopupSetFocus) (GnomeCanvasItem *item,
45  gpointer user_data);
46 
47 typedef void (*PopupPostShow) (GnomeCanvasItem *item,
48  gpointer user_data);
49 
50 typedef int (*PopupGetWidth) (GnomeCanvasItem *item,
51  gpointer user_data);
52 
53 typedef struct _PopupToggle PopupToggle;
55 {
56  GtkToggleButton *toggle_button;
57  GnomeCanvasItem *toggle_button_item;
58 
59  gint toggle_offset;
60 
61  GtkArrow *arrow;
62 
63  gboolean signals_connected;
64 };
65 
66 
67 typedef struct
68 {
69  GnomeCanvasItem canvas_item;
70 
71  GnomeCanvasGroup *parent;
72 
73  GnucashSheet *sheet;
74 
75  /* The editor whose status we reflect on the sheet */
76  GtkWidget *editor;
77 
78  gboolean has_selection;
79 
80  gboolean is_popup;
81  gboolean show_popup;
82 
83  PopupToggle popup_toggle;
84 
85  GnomeCanvasItem *popup_item;
86  GetPopupHeight get_popup_height;
87  PopupAutosize popup_autosize;
88  PopupSetFocus popup_set_focus;
89  PopupPostShow popup_post_show;
90  PopupGetWidth popup_get_width;
91  gpointer popup_user_data;
92 
93  GdkGC *gc;
94 
95  gboolean reset_pos;
96  gint x_offset;
97  gint anchor_pos;
98 
99  /* Where are we */
100  VirtualLocation virt_loc;
101 
102  SheetBlockStyle *style;
103 } GncItemEdit;
104 
105 typedef struct
106 {
107  GnomeCanvasItemClass parent_class;
109 
110 
111 GType gnc_item_edit_get_type (void);
112 
113 void gnc_item_edit_configure (GncItemEdit *item_edit);
114 
115 void gnc_item_edit_get_pixel_coords (GncItemEdit *item_edit,
116  int *x, int *y,
117  int *w, int *h);
118 
119 GnomeCanvasItem *gnc_item_edit_new (GnomeCanvasGroup *parent,
120  GnucashSheet *sheet, GtkWidget *entry);
121 
122 GncItemList * gnc_item_edit_new_list (GncItemEdit *item_edit, GtkListStore *shared_store);
123 GNCDatePicker * gnc_item_edit_new_date_picker (GncItemEdit *item_edit);
124 
125 void gnc_item_edit_set_popup (GncItemEdit *item_edit,
126  GnomeCanvasItem *popup_item,
127  GetPopupHeight get_popup_height,
128  PopupAutosize popup_autosize,
129  PopupSetFocus popup_set_focus,
130  PopupPostShow popup_post_show,
131  PopupGetWidth popup_get_width,
132  gpointer popup_user_data);
133 
134 void gnc_item_edit_show_popup (GncItemEdit *item_edit);
135 void gnc_item_edit_hide_popup (GncItemEdit *item_edit);
136 
137 int gnc_item_edit_get_toggle_offset (int row_height);
138 
139 gboolean gnc_item_edit_set_cursor_pos (GncItemEdit *item_edit,
140  VirtualLocation virt_loc, int x,
141  gboolean changed_cells,
142  gboolean extend_selection);
143 
144 void gnc_item_edit_redraw (GncItemEdit *item_edit);
145 
146 void gnc_item_edit_cut_clipboard (GncItemEdit *item_edit, guint32 time);
147 void gnc_item_edit_copy_clipboard (GncItemEdit *item_edit, guint32 time);
148 void gnc_item_edit_paste_selection (GncItemEdit *item_edit, GdkAtom selection,
149  guint32 time);
150 
151 void gnc_item_edit_set_has_selection (GncItemEdit *item_edit, gboolean has_selection);
152 gboolean gnc_item_edit_get_has_selection (GncItemEdit *item_edit);
153 void gnc_item_edit_focus_in (GncItemEdit *item_edit);
154 void gnc_item_edit_focus_out (GncItemEdit *item_edit);
155 
156 void gnc_item_edit_reset_offset (GncItemEdit *item_edit);
157 
158 #endif /* GNUCASH_ITEM_EDIT_H */
159 
160