Use application properties instead of ugly dual-use global variable
[gnumeric.git] / src / colrow.h
blob78f55e8936f97be10056393d90315e9c7c410642
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 /* We never did get around to support 'thick' borders so these are effectively
30 * unitless (margins do not scale) constants . */
31 #define GNM_COL_MARGIN 2
32 #define GNM_ROW_MARGIN 0
34 /* The size, mask, and shift must be kept in sync */
35 #define COLROW_SEGMENT_SIZE 0x80
36 #define COLROW_SUB_INDEX(i) ((i) & 0x7f)
37 #define COLROW_SEGMENT_START(i) ((i) & ~(0x7f))
38 #define COLROW_SEGMENT_END(i) ((i) | 0x7f)
39 #define COLROW_SEGMENT_INDEX(i) ((i) >> 7)
40 #define COLROW_GET_SEGMENT(seg_array, i) \
41 (g_ptr_array_index ((seg_array)->info, COLROW_SEGMENT_INDEX(i)))
43 struct _ColRowSegment {
44 ColRowInfo *info [COLROW_SEGMENT_SIZE];
45 double size_pts;
46 int size_pixels;
48 typedef struct _ColRowState {
49 double size_pts;
50 unsigned is_default : 1;
51 unsigned outline_level : 4;
52 unsigned is_collapsed : 1; /* Does this terminate an outline ? */
53 unsigned hard_size : 1; /* are dimensions explicitly set ? */
54 unsigned visible : 1; /* visible */
55 } ColRowState;
57 typedef struct {
58 int length;
59 ColRowState state;
60 } ColRowRLEState;
62 #define COL_INTERNAL_WIDTH(col) \
63 ((col)->size_pixels - (GNM_COL_MARGIN + GNM_COL_MARGIN + 1))
65 double colrow_compute_pixel_scale (Sheet const *sheet, gboolean horizontal);
66 void colrow_compute_pixels_from_pts (ColRowInfo *cri, Sheet const *sheet,
67 gboolean horizontal, double scale);
68 void colrow_compute_pts_from_pixels (ColRowInfo *cri, Sheet const *sheet,
69 gboolean horizontal, double scale);
71 gboolean col_row_info_is_default (ColRowInfo const *cri);
72 gboolean col_row_info_is_empty (ColRowInfo const *cri);
73 gboolean col_row_info_equal (ColRowInfo const *a, ColRowInfo const *b);
74 void col_row_info_copy (ColRowInfo *dst, ColRowInfo const *src);
75 ColRowInfo *col_row_info_new (void);
76 void colrow_free (ColRowInfo *cri);
78 typedef struct {
79 int pos;
80 ColRowInfo const *cri;
81 } GnmColRowIter;
83 typedef gboolean (*ColRowHandler)(GnmColRowIter const *iter, gpointer user_data);
84 #define colrow_index_list_destroy(l) g_list_free_full ((l), g_free)
86 GString *colrow_index_list_to_string (ColRowIndexList *list,
87 gboolean is_cols,
88 gboolean *is_single);
89 ColRowIndexList *colrow_get_index_list (int first, int last,
90 ColRowIndexList *list);
91 ColRowIndexList *colrow_index_list_copy (ColRowIndexList *list);
93 ColRowStateList *colrow_state_list_destroy (ColRowStateList *list);
95 ColRowStateList *colrow_get_states (Sheet *sheet, gboolean is_cols,
96 int first, int last);
97 void colrow_set_states (Sheet *sheet, gboolean is_cols,
98 int first, ColRowStateList *states);
99 gboolean colrow_state_list_foreach (ColRowStateList *list,
100 Sheet const *sheet,
101 gboolean is_cols,
102 int base,
103 ColRowHandler callback,
104 gpointer user_data);
106 ColRowStateGroup *colrow_state_group_destroy (ColRowStateGroup *set);
107 ColRowStateGroup *colrow_set_sizes (Sheet *sheet, gboolean is_cols,
108 ColRowIndexList *src, int new_size,
109 int from, int to);
110 ColRowStateGroup *colrow_get_sizes (Sheet *sheet, gboolean is_cols,
111 ColRowIndexList *src, int new_size);
112 void colrow_restore_state_group (Sheet *sheet, gboolean is_cols,
113 ColRowIndexList *selection,
114 ColRowStateGroup *state_groups);
116 /* Support for Col/Row visibility */
117 void col_row_info_set_outline (ColRowInfo *cri, int outline_level,
118 gboolean is_collapsed);
119 int colrow_find_outline_bound (Sheet const *sheet, gboolean is_cols,
120 int index, int depth, gboolean inc);
121 ColRowVisList *colrow_get_outline_toggle (Sheet const *sheet, gboolean is_cols,
122 gboolean visible, int first, int last);
123 ColRowVisList *colrow_get_visibility_toggle (SheetView *sv, gboolean is_cols,
124 gboolean visible);
125 void colrow_set_visibility (Sheet *sheet, gboolean is_cols,
126 gboolean visible, int first, int last);
127 void colrow_get_global_outline (Sheet const *sheet, gboolean is_cols, int depth,
128 ColRowVisList **show, ColRowVisList **hide);
130 #define colrow_vis_list_destroy(l) g_slist_free_full ((l), g_free)
131 gint colrow_vis_list_length (ColRowVisList *list);
132 void colrow_set_visibility_list (Sheet *sheet, gboolean is_cols,
133 gboolean visible,
134 ColRowVisList *list);
136 /* Misc */
137 #define colrow_max(is_cols,sheet) ((is_cols) ? gnm_sheet_get_max_cols (sheet) : gnm_sheet_get_max_rows (sheet))
138 void rows_height_update (Sheet *sheet, GnmRange const *range,
139 gboolean shrink);
141 void colrow_autofit (Sheet *sheet,
142 GnmRange const *r,
143 gboolean is_cols,
144 gboolean ignore_strings,
145 gboolean min_current,
146 gboolean min_default,
147 ColRowIndexList **indices,
148 ColRowStateList **sizes);
149 void colrow_autofit_col (Sheet *sheet, GnmRange *r);
150 void colrow_autofit_row (Sheet *sheet, GnmRange *r);
152 G_END_DECLS
154 #endif /* _GNM_COLROW_H_ */