Introspection: fix problems with boxed type.
[gnumeric.git] / src / colrow.h
blob9e4bf579130c4bb5497e7e3778709e555ca0faa1
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 #ifndef _GNM_COLROW_H_
3 # define _GNM_COLROW_H_
5 #include "gnumeric.h"
7 G_BEGIN_DECLS
9 struct _ColRowInfo {
10 /* Size including margins, and right grid line */
11 double size_pts;
12 int size_pixels;
14 unsigned is_default : 1;
15 unsigned outline_level : 4;
16 unsigned is_collapsed : 1; /* Does this terminate an outline ? */
17 unsigned hard_size : 1; /* are dimensions explicitly set ? */
18 unsigned visible : 1; /* visible */
19 unsigned in_filter : 1; /* in a filter */
20 unsigned in_advanced_filter : 1; /* in an advanced filter */
21 unsigned needs_respan : 1; /* mark a row as needing span generation */
23 /* TODO : Add per row/col min/max */
25 gpointer spans; /* Only used for rows */
27 GType col_row_info_get_type (void);
29 struct _ColRowCollection {
30 int max_used;
31 ColRowInfo default_style;
32 GPtrArray * info;
33 int max_outline_level;
36 /* We never did get around to support 'thick' borders so these are effectively
37 * unitless (margins do not scale) constants . */
38 #define GNM_COL_MARGIN 2
39 #define GNM_ROW_MARGIN 0
41 /* The size, mask, and shift must be kept in sync */
42 #define COLROW_SEGMENT_SIZE 0x80
43 #define COLROW_SUB_INDEX(i) ((i) & 0x7f)
44 #define COLROW_SEGMENT_START(i) ((i) & ~(0x7f))
45 #define COLROW_SEGMENT_END(i) ((i) | 0x7f)
46 #define COLROW_SEGMENT_INDEX(i) ((i) >> 7)
47 #define COLROW_GET_SEGMENT(seg_array, i) \
48 (g_ptr_array_index ((seg_array)->info, COLROW_SEGMENT_INDEX(i)))
50 struct _ColRowSegment {
51 ColRowInfo *info [COLROW_SEGMENT_SIZE];
52 double size_pts;
53 int size_pixels;
55 typedef struct _ColRowState {
56 double size_pts;
57 unsigned is_default : 1;
58 unsigned outline_level : 4;
59 unsigned is_collapsed : 1; /* Does this terminate an outline ? */
60 unsigned hard_size : 1; /* are dimensions explicitly set ? */
61 unsigned visible : 1; /* visible */
62 } ColRowState;
64 typedef struct {
65 int length;
66 ColRowState state;
67 } ColRowRLEState;
69 #define COL_INTERNAL_WIDTH(col) \
70 ((col)->size_pixels - (GNM_COL_MARGIN + GNM_COL_MARGIN + 1))
72 double colrow_compute_pixel_scale (Sheet const *sheet, gboolean horizontal);
73 void colrow_compute_pixels_from_pts (ColRowInfo *cri, Sheet const *sheet,
74 gboolean horizontal, double scale);
75 void colrow_compute_pts_from_pixels (ColRowInfo *cri, Sheet const *sheet,
76 gboolean horizontal, double scale);
78 gboolean colrow_is_default (ColRowInfo const *cri);
79 gboolean colrow_is_empty (ColRowInfo const *cri);
80 gboolean colrow_equal (ColRowInfo const *a, ColRowInfo const *b);
81 void colrow_copy (ColRowInfo *dst, ColRowInfo const *src);
82 ColRowInfo *col_row_info_new (void);
83 void colrow_free (ColRowInfo *cri);
85 typedef struct {
86 int pos;
87 ColRowInfo const *cri;
88 } GnmColRowIter;
90 typedef gboolean (*ColRowHandler)(GnmColRowIter const *iter, gpointer user_data);
91 gboolean colrow_foreach (ColRowCollection const *infos,
92 int first, int last,
93 ColRowHandler callback,
94 gpointer user_data);
96 void colrow_resize (ColRowCollection *infos, int size);
98 #define colrow_index_list_destroy(l) g_list_free_full ((l), g_free)
100 GString *colrow_index_list_to_string (ColRowIndexList *list,
101 gboolean is_cols,
102 gboolean *is_single);
103 ColRowIndexList *colrow_get_index_list (int first, int last,
104 ColRowIndexList *list);
105 ColRowIndexList *colrow_index_list_copy (ColRowIndexList *list);
107 ColRowStateList *colrow_state_list_destroy (ColRowStateList *list);
109 ColRowStateList *colrow_get_states (Sheet *sheet, gboolean is_cols,
110 int first, int last);
111 void colrow_set_states (Sheet *sheet, gboolean is_cols,
112 int first, ColRowStateList *states);
114 ColRowStateGroup *colrow_state_group_destroy (ColRowStateGroup *set);
115 ColRowStateGroup *colrow_set_sizes (Sheet *sheet, gboolean is_cols,
116 ColRowIndexList *src, int new_size,
117 int from, int to);
118 ColRowStateGroup *colrow_get_sizes (Sheet *sheet, gboolean is_cols,
119 ColRowIndexList *src, int new_size);
120 void colrow_restore_state_group (Sheet *sheet, gboolean is_cols,
121 ColRowIndexList *selection,
122 ColRowStateGroup *saved_state);
124 /* Support for Col/Row visibility */
125 void colrow_set_outline (ColRowInfo *cri, int outline_level,
126 gboolean is_collapsed);
127 int colrow_find_outline_bound (Sheet const *sheet, gboolean is_cols,
128 int index, int depth, gboolean inc);
129 ColRowVisList *colrow_get_outline_toggle (Sheet const *sheet, gboolean is_cols,
130 gboolean visible, int first, int last);
131 ColRowVisList *colrow_get_visiblity_toggle (SheetView *sv, gboolean is_cols,
132 gboolean visible);
133 void colrow_set_visibility (Sheet *sheet, gboolean is_cols,
134 gboolean visible, int first, int last);
135 void colrow_get_global_outline (Sheet const *sheet, gboolean is_cols, int depth,
136 ColRowVisList **show, ColRowVisList **hide);
138 #define colrow_vis_list_destroy(l) g_slist_free_full ((l), g_free)
139 gint colrow_vis_list_length (ColRowVisList *list);
140 void colrow_set_visibility_list (Sheet *sheet, gboolean is_cols,
141 gboolean visible,
142 ColRowVisList *list);
144 /* Misc */
145 #define colrow_max(is_cols,sheet) ((is_cols) ? gnm_sheet_get_max_cols (sheet) : gnm_sheet_get_max_rows (sheet))
146 void rows_height_update (Sheet *sheet, GnmRange const *range,
147 gboolean shrink);
149 void colrow_autofit (Sheet *sheet,
150 GnmRange const *r,
151 gboolean is_cols,
152 gboolean ignore_strings,
153 gboolean min_current,
154 gboolean min_default,
155 ColRowIndexList **indices,
156 ColRowStateList **sizes);
157 void colrow_autofit_col (Sheet *sheet, GnmRange *r);
158 void colrow_autofit_row (Sheet *sheet, GnmRange *r);
160 G_END_DECLS
162 #endif /* _GNM_COLROW_H_ */