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       gnu@gnu.org                   *
18  *                                                                  *
19 \********************************************************************/
20 
21 #ifndef GNUCASH_ITEM_EDIT_H
22 #define GNUCASH_ITEM_EDIT_H
23 
24 #include <gtk/gtk.h>
25 #include "gnucash-date-picker.h"
26 #include "gnucash-item-list.h"
27 #include "gnucash-sheet.h"
28 /** @ingroup Register
29  * @addtogroup Gnome
30  * @{
31  */
32 /** @file gnucash-item-edit.h
33  * @brief Public declarations for GncItemEdit class
34  */
35 #define GNC_TYPE_ITEM_EDIT        (gnc_item_edit_get_type ())
36 #define GNC_ITEM_EDIT(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), GNC_TYPE_ITEM_EDIT, GncItemEdit))
37 #define GNC_ITEM_EDIT_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_ITEM_EDIT, GncItemEditClass))
38 #define GNC_IS_ITEM_EDIT(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_ITEM_EDIT))
39 
40 #define GNC_TYPE_ITEM_EDIT_TB        (gnc_item_edit_tb_get_type ())
41 #define GNC_ITEM_EDIT_TB(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), GNC_TYPE_ITEM_EDIT_TB, GncItemEditTb))
42 #define GNC_ITEM_EDIT_TB_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_ITEM_EDIT_TB, GncItemEditTbClass))
43 #define GNC_IS_ITEM_EDIT_TB(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_ITEM_EDIT_TB))
44 
45 typedef int (*PopupGetHeight) (GtkWidget *item,
46                                int space_available,
47                                int row_height,
48                                gpointer user_data);
49 
50 typedef int (*PopupAutosize) (GtkWidget *item,
51                               int max_width,
52                               gpointer user_data);
53 
54 typedef void (*PopupSetFocus) (GtkWidget *item,
55                                gpointer user_data);
56 
57 typedef void (*PopupPostShow) (GtkWidget *item,
58                                gpointer user_data);
59 
60 typedef int (*PopupGetWidth) (GtkWidget *item,
61                               gpointer user_data);
62 
63 typedef struct _PopupToggle PopupToggle;
64 struct _PopupToggle
65 {
66     GtkWidget *ebox;
67     GtkWidget *tbutton;
68     gboolean   arrow_down;
69     gboolean signals_connected;
70 };
71 
72 
73 typedef struct
74 {
75     GtkBox hbox;
76     GnucashSheet *sheet;
77 
78     /* The editor whose status we reflect on the sheet */
79     GtkWidget *editor;
80     gulong preedit_length;
81 
82     gboolean is_popup;
83     gboolean show_popup;
84 
85     PopupToggle popup_toggle;
86     GtkWidget *popup_item;
87     PopupGetHeight   popup_get_height;
88     PopupAutosize    popup_autosize;
89     PopupSetFocus    popup_set_focus;
90     PopupPostShow    popup_post_show;
91     PopupGetWidth    popup_get_width;
92     gpointer         popup_user_data;
93     gint             popup_returned_height;
94     gulong           popup_height_signal_id;
95 
96     GtkBorder        padding;
97     GtkBorder        margin;
98     GtkBorder        border;
99     gint             button_width;
100 
101     /* Where are we */
102     VirtualLocation virt_loc;
103 
104     SheetBlockStyle *style;
105 } GncItemEdit;
106 
107 typedef struct
108 {
109     GtkBoxClass parent_class;
110 } GncItemEditClass;
111 
112 typedef struct
113 {
114     GtkToggleButton tb;
115     GnucashSheet *sheet;
116 } GncItemEditTb;
117 
118 typedef struct
119 {
120     GtkToggleButtonClass parent_class;
121 
122     void (* toggled) (GncItemEditTb *item_edit_tb);
123 } GncItemEditTbClass;
124 
125 typedef enum
126 {
127     left,
128     right,
129     top,
130     bottom,
131     left_right,
132     top_bottom,
133 } Sides;
134 
135 GType gnc_item_edit_get_type (void);
136 
137 void gnc_item_edit_configure (GncItemEdit *item_edit);
138 
139 void gnc_item_edit_get_pixel_coords (GncItemEdit *item_edit,
140                                      int *x, int *y,
141                                      int *w, int *h);
142 
143 GtkWidget *gnc_item_edit_new (GnucashSheet *sheet);
144 
145 void gnc_item_edit_set_popup (GncItemEdit    *item_edit,
146                               GtkWidget      *popup_item,
147                               PopupGetHeight  popup_get_height,
148                               PopupAutosize   popup_autosize,
149                               PopupSetFocus   popup_set_focus,
150                               PopupPostShow   popup_post_show,
151                               PopupGetWidth   popup_get_width,
152                               gpointer        popup_user_data);
153 
154 void gnc_item_edit_show_popup (GncItemEdit *item_edit);
155 void gnc_item_edit_hide_popup (GncItemEdit *item_edit);
156 
157 void gnc_item_edit_cut_clipboard (GncItemEdit *item_edit);
158 void gnc_item_edit_copy_clipboard (GncItemEdit *item_edit);
159 void gnc_item_edit_paste_clipboard (GncItemEdit *item_edit);
160 
161 gboolean gnc_item_edit_get_has_selection (GncItemEdit *item_edit);
162 void gnc_item_edit_focus_in (GncItemEdit *item_edit);
163 void gnc_item_edit_focus_out (GncItemEdit *item_edit);
164 
165 gint gnc_item_edit_get_margin (GncItemEdit *item_edit, Sides side);
166 gint gnc_item_edit_get_padding_border (GncItemEdit *item_edit, Sides side);
167 gint gnc_item_edit_get_button_width (GncItemEdit *item_edit);
168 
169 
170 GType gnc_item_edit_tb_get_type (void);
171 GtkWidget *gnc_item_edit_tb_new (GnucashSheet *sheet);
172 
173 /** @} */
174 #endif /* GNUCASH_ITEM_EDIT_H */
175