1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 #ifndef _GNM_SHEET_OBJECT_H_
3 # define _GNM_SHEET_OBJECT_H_
7 #include <gsf/gsf-output.h>
8 #include <goffice/goffice.h>
12 /***********************************************************/
15 GNM_SO_RESIZE_MANUAL
, /* can be manually resized */
16 GNM_SO_RESIZE_AUTO
, /* automatically resized like cell bounded widgets */
17 GNM_SO_RESIZE_NONE
/* can't be resized like some sheet components */
21 GNM_SO_ANCHOR_TWO_CELLS
, /* move and size (if sizeable) with cells) */
22 GNM_SO_ANCHOR_ONE_CELL
, /* move with cells */
23 GNM_SO_ANCHOR_ABSOLUTE
/* anchored to the sheet */
25 GType
gnm_sheet_object_anchor_mode_get_type (void);
26 #define GNM_SHEET_OBJECT_ANCHOR_MODE_TYPE (gnm_sheet_object_anchor_mode_get_type ())
28 struct _SheetObjectAnchor
{
31 GnmRange cell_bound
; /* cellpos containing corners */
32 double offset
[4]; /* offsets from the top left (in LTR of cell_bound) */
35 GType
sheet_object_anchor_get_type (void); /* Boxed type */
37 #define GNM_SO_TYPE (sheet_object_get_type ())
38 #define GNM_SO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNM_SO_TYPE, SheetObject))
39 #define GNM_IS_SO(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNM_SO_TYPE))
40 GType
sheet_object_get_type (void);
42 #define GNM_SO_IMAGEABLE_TYPE (sheet_object_imageable_get_type ())
43 #define GNM_SO_IMAGEABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNM_SO_IMAGEABLE_TYPE, SheetObjectImageableIface))
44 #define GNM_IS_SO_IMAGEABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNM_SO_IMAGEABLE_TYPE))
46 GType
sheet_object_imageable_get_type (void);
48 #define GNM_SO_EXPORTABLE_TYPE (sheet_object_exportable_get_type ())
49 #define GNM_SO_EXPORTABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNM_SO_EXPORTABLE_TYPE, SheetObjectExportableIface))
50 #define GNM_IS_SO_EXPORTABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNM_SO_EXPORTABLE_TYPE))
52 GType
sheet_object_exportable_get_type (void);
54 gboolean
sheet_object_set_sheet (SheetObject
*so
, Sheet
*sheet
);
55 Sheet
*sheet_object_get_sheet (SheetObject
const *so
);
56 void sheet_object_clear_sheet (SheetObject
*so
);
58 void sheet_object_set_name (SheetObject
*so
, const char *name
);
59 void sheet_object_set_print_flag (SheetObject
*so
, gboolean
*print
);
61 SheetObject
*sheet_object_dup (SheetObject
const *so
);
62 gboolean
sheet_object_can_print (SheetObject
const *so
);
63 gboolean
sheet_object_can_resize (SheetObject
const *so
);
64 gboolean
sheet_object_can_edit (SheetObject
const *so
);
66 void sheet_object_get_editor (SheetObject
*so
, SheetControl
*sc
);
67 void sheet_object_populate_menu (SheetObject
*so
, GPtrArray
*actions
);
68 GtkWidget
* sheet_object_build_menu (SheetObjectView
*view
,
69 GPtrArray
const *actions
,
71 void sheet_object_update_bounds (SheetObject
*so
, GnmCellPos
const *p
);
72 void sheet_object_default_size (SheetObject
*so
, double *w
, double *h
);
73 gint
sheet_object_adjust_stacking(SheetObject
*so
, gint positions
);
74 gint
sheet_object_get_stacking (SheetObject
*so
);
75 SheetObjectView
*sheet_object_new_view (SheetObject
*so
,
76 SheetObjectViewContainer
*container
);
77 SheetObjectView
*sheet_object_get_view (SheetObject
const *so
,
78 SheetObjectViewContainer
*container
);
79 GnmRange
const *sheet_object_get_range (SheetObject
const *so
);
80 void sheet_object_set_anchor (SheetObject
*so
,
81 SheetObjectAnchor
const *anchor
);
83 SheetObjectAnchor
const *sheet_object_get_anchor (SheetObject
const *so
);
84 void sheet_object_position_pts_get (SheetObject
const *so
, double *coords
);
86 void sheet_object_invalidate_sheet (SheetObject
*so
,
89 typedef void (*SheetObjectForeachDepFunc
) (GnmDependent
*dep
,
92 void sheet_object_foreach_dep (SheetObject
*so
,
93 SheetObjectForeachDepFunc func
,
97 /* Object Management */
98 void sheet_objects_relocate (GnmExprRelocateInfo
const *rinfo
,
99 gboolean update
, GOUndo
**pundo
);
100 void sheet_objects_clear (Sheet
const *sheet
, GnmRange
const *r
,
101 GType t
, GOUndo
**pundo
);
102 GOUndo
*sheet_object_move_undo (GSList
*objects
, gboolean objects_created
);
103 GOUndo
*sheet_object_move_do (GSList
*objects
, GSList
*anchors
,
104 gboolean objects_created
);
105 GSList
*sheet_objects_get (Sheet
const *sheet
, GnmRange
const *r
,
107 void sheet_objects_dup (Sheet
const *src
, Sheet
*dst
, GnmRange
*range
);
109 void sheet_object_direction_set (SheetObject
*so
, gdouble
const *coords
);
110 gboolean
sheet_object_rubber_band_directly (SheetObject
const *so
);
111 void sheet_object_set_anchor_mode (SheetObject
*so
, GnmSOAnchorMode
const *mode
);
113 /* Anchor utilities */
114 void sheet_object_anchor_to_pts (SheetObjectAnchor
const *anchor
,
115 Sheet
const *sheet
, double *res_pts
);
116 void sheet_object_anchor_to_offset_pts (SheetObjectAnchor
const *anchor
,
117 Sheet
const *sheet
, double *res_pts
);
118 void sheet_object_anchor_init (SheetObjectAnchor
*anchor
,
119 GnmRange
const *cell_bound
,
120 const double *offsets
,
121 GODrawingAnchorDir direction
,
122 GnmSOAnchorMode mode
);
123 void sheet_object_pts_to_anchor (SheetObjectAnchor
*anchor
,
124 Sheet
const *sheet
, double const *res_pts
);
126 sheet_object_anchor_dup (SheetObjectAnchor
const *src
);
128 /* Image rendering */
129 GtkTargetList
*sheet_object_get_target_list (SheetObject
const *so
);
130 void sheet_object_write_image (SheetObject
const *so
,
137 GtkTargetList
*sheet_object_exportable_get_target_list (SheetObject
const *so
);
138 void sheet_object_write_object (SheetObject
const *so
,
140 GsfOutput
*output
, GError
**err
,
141 GnmConventions
const *convs
);
143 /* cairo rendering */
144 void sheet_object_draw_cairo (SheetObject
const *so
, cairo_t
*cr
, gboolean rtl
);
145 void sheet_object_draw_cairo_sized (SheetObject
const *so
, cairo_t
*cr
, double width
, double height
);
147 /* management routine to register all the builtin object types */
148 void sheet_objects_init (void);
151 #endif /* _GNM_SHEET_OBJECT_H_ */