Introspection fixes.
[gnumeric.git] / src / colrow.h
blob126744af710c6bb75d413280ed39c476be1c4455
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 col_row_info_is_default (ColRowInfo const *cri);
79 gboolean col_row_info_is_empty (ColRowInfo const *cri);
80 gboolean col_row_info_equal (ColRowInfo const *a, ColRowInfo const *b);
81 void col_row_info_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 col_row_collection_foreach (ColRowCollection const *infos,
92 int first, int last,
93 ColRowHandler callback,
94 gpointer user_data);
96 void col_row_collection_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);
113 gboolean colrow_state_list_foreach (ColRowStateList *list,
114 Sheet const *sheet,
115 gboolean is_cols,
116 int base,
117 ColRowHandler callback,
118 gpointer user_data);
120 ColRowStateGroup *colrow_state_group_destroy (ColRowStateGroup *set);
121 ColRowStateGroup *colrow_set_sizes (Sheet *sheet, gboolean is_cols,
122 ColRowIndexList *src, int new_size,
123 int from, int to);
124 ColRowStateGroup *colrow_get_sizes (Sheet *sheet, gboolean is_cols,
125 ColRowIndexList *src, int new_size);
126 void colrow_restore_state_group (Sheet *sheet, gboolean is_cols,
127 ColRowIndexList *selection,
128 ColRowStateGroup *state_groups);
130 /* Support for Col/Row visibility */
131 void col_row_info_set_outline (ColRowInfo *cri, int outline_level,
132 gboolean is_collapsed);
133 int colrow_find_outline_bound (Sheet const *sheet, gboolean is_cols,
134 int index, int depth, gboolean inc);
135 ColRowVisList *colrow_get_outline_toggle (Sheet const *sheet, gboolean is_cols,
136 gboolean visible, int first, int last);
137 ColRowVisList *colrow_get_visibility_toggle (SheetView *sv, gboolean is_cols,
138 gboolean visible);
139 void colrow_set_visibility (Sheet *sheet, gboolean is_cols,
140 gboolean visible, int first, int last);
141 void colrow_get_global_outline (Sheet const *sheet, gboolean is_cols, int depth,
142 ColRowVisList **show, ColRowVisList **hide);
144 #define colrow_vis_list_destroy(l) g_slist_free_full ((l), g_free)
145 gint colrow_vis_list_length (ColRowVisList *list);
146 void colrow_set_visibility_list (Sheet *sheet, gboolean is_cols,
147 gboolean visible,
148 ColRowVisList *list);
150 /* Misc */
151 #define colrow_max(is_cols,sheet) ((is_cols) ? gnm_sheet_get_max_cols (sheet) : gnm_sheet_get_max_rows (sheet))
152 void rows_height_update (Sheet *sheet, GnmRange const *range,
153 gboolean shrink);
155 void colrow_autofit (Sheet *sheet,
156 GnmRange const *r,
157 gboolean is_cols,
158 gboolean ignore_strings,
159 gboolean min_current,
160 gboolean min_default,
161 ColRowIndexList **indices,
162 ColRowStateList **sizes);
163 void colrow_autofit_col (Sheet *sheet, GnmRange *r);
164 void colrow_autofit_row (Sheet *sheet, GnmRange *r);
166 G_END_DECLS
168 #endif /* _GNM_COLROW_H_ */