1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 #ifndef _GNM_SHEET_OBJECT_IMPL_H_
3 # define _GNM_SHEET_OBJECT_IMPL_H_
7 #include "sheet-object.h"
8 #include <goffice/goffice.h>
9 #include <gsf/gsf-libxml.h>
10 #include <libxml/tree.h>
11 #include <glib-object.h>
15 SHEET_OBJECT_IS_VISIBLE
= 1 << 0, /* user selectable */
16 SHEET_OBJECT_PRINT
= 1 << 1,
17 SHEET_OBJECT_CAN_PRESS
= 1 << 2,
18 SHEET_OBJECT_CAN_RESIZE
= 1 << 3,
19 SHEET_OBJECT_CAN_EDIT
= 1 << 4,
21 /* Gnumeric specific properties */
22 SHEET_OBJECT_MOVE_WITH_CELLS
= 1 << 16,
23 SHEET_OBJECT_SIZE_WITH_CELLS
= 1 << 17,
24 SHEET_OBJECT_OBSCURED
= 1 << 18 /* cells associated with region are hidden */
28 GObject parent_object
;
31 SheetObjectAnchor anchor
;
32 SheetObjectFlags flags
;
36 typedef void (*SheetObjectActionFunc
) (SheetObject
*so
, SheetControl
*sc
);
37 typedef gboolean (*SheetObjectEnableActionFunc
) (SheetObject
const *so
);
39 char const *icon
; /* optionally NULL */
40 char const *label
; /* NULL for separators */
41 char const *msg_domain
; /* for plugins to specify translations */
42 int submenu
; /* > 1 starts a menu, < 1 end one */
43 SheetObjectActionFunc func
;
44 SheetObjectEnableActionFunc enable_func
;
48 GObjectClass parent_class
;
51 void (*bounds_changed
) (SheetObject
*so
);
52 void (*unrealized
) (SheetObject
*so
);
53 void (*signal_pad1
) (void);
54 void (*signal_pad2
) (void);
57 gboolean (*remove_from_sheet
) (SheetObject
*so
);
58 gboolean (*assign_to_sheet
) (SheetObject
*so
,
61 SheetObjectView
*(*new_view
) (SheetObject
*so
,
62 SheetObjectViewContainer
*container
);
63 void (*populate_menu
) (SheetObject
*so
,
65 void (*user_config
) (SheetObject
*so
,
66 SheetControl
*s_control
);
67 void (*prep_sax_parser
) (SheetObject
*so
,
68 GsfXMLIn
*xin
, xmlChar
const **attrs
,
69 GnmConventions
const *convs
);
70 void (*write_xml_sax
) (SheetObject
const *so
,
72 GnmConventions
const *convs
);
73 void (*copy
) (SheetObject
*dst
,
74 SheetObject
const *src
);
76 void (*default_size
) (SheetObject
const *so
,
77 double *w
, double *h
);
79 void (*draw_cairo
) (SheetObject
const *so
, cairo_t
*cr
,
80 double width
, double height
);
82 void (*foreach_dep
) (SheetObject
*so
,
83 SheetObjectForeachDepFunc func
,
86 void (*func_pad1
) (void);
87 void (*func_pad2
) (void);
90 * If false, we draw a rectangle where the object is going to
91 * be layed out If true, we draw the object while laying
92 * it out on the sheet.
94 gboolean rubber_band_directly
;
97 * If FALSE, a mouse click will select the object.
101 char const *xml_export_name
;
108 #define GNM_SO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNM_SO_TYPE, SheetObjectClass))
110 /***************************************************************************/
112 struct _SheetObjectView
{
115 GnmSOResizeMode resize_mode
;
121 void (*active
) (SheetObjectView
*sov
, gboolean is_active
);
122 void (*set_bounds
) (SheetObjectView
*sov
,
123 double const *coords
, gboolean visible
);
124 } SheetObjectViewClass
;
126 #define GNM_SO_VIEW_TYPE (sheet_object_view_get_type ())
127 #define GNM_SO_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GNM_SO_VIEW_TYPE, SheetObjectView))
128 #define GNM_IS_SO_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNM_SO_VIEW_TYPE))
129 #define GNM_SO_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNM_SO_VIEW_TYPE, SheetObjectViewIface))
130 #define GNM_IS_SO_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GNM_SO_VIEW_TYPE))
131 #define GNM_SO_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNM_SO_VIEW_TYPE, SheetObjectViewClass))
133 GType
sheet_object_view_get_type (void);
134 SheetObject
*sheet_object_view_get_so (SheetObjectView
*sov
);
135 void sheet_object_view_set_bounds (SheetObjectView
*sov
,
136 double const *coords
,
139 /***************************************************************************/
144 /* Map between anchors and un-normalized coordinates */
145 void (*anchor_to_coords
) (SheetObjectViewContainer
*sovc
,
146 SheetObjectAnchor
const *input
, double *output
);
147 void (*coords_to_anchor
) (SheetObjectViewContainer
*sovc
,
148 double const *input
, SheetObjectAnchor
*output
);
149 } SheetObjectViewContainerIface
;
152 void so_vc_anchor_to_coords (SheetObjectViewContainer
*sovc
,
153 SheetObjectAnchor
const *input
, double *output
);
154 void so_vc_coords_to_anchor (SheetObjectViewContainer
*sovc
,
155 double const *input
, SheetObjectAnchor
*output
);
158 /***************************************************************************/
163 GtkTargetList
*(*get_target_list
) (SheetObject
const *so
);
164 void (*write_image
) (SheetObject
const *so
,
169 } SheetObjectImageableIface
;
171 /***************************************************************************/
176 GtkTargetList
*(*get_target_list
) (SheetObject
const *so
);
177 void (*write_object
) (SheetObject
const *so
,
179 GsfOutput
*output
, GError
**err
,
180 GnmConventions
const *convs
);
181 } SheetObjectExportableIface
;
185 #endif /* _GNM_SHEET_OBJECT_IMPL_H_ */