1 #ifndef _GNM_STYLE_BORDER_H_
2 # define _GNM_STYLE_BORDER_H_
3 
4 #include <gnumeric.h>
5 #include <gdk/gdk.h>
6 
7 G_BEGIN_DECLS
8 
9 typedef enum {
10 	GNM_STYLE_BORDER_HORIZONTAL,
11 	GNM_STYLE_BORDER_VERTICAL,
12 	GNM_STYLE_BORDER_DIAGONAL
13 } GnmStyleBorderOrientation;
14 
15 typedef enum {
16 	GNM_STYLE_BORDER_NONE			= 0x0,
17 	GNM_STYLE_BORDER_THIN			= 0x1,
18 	GNM_STYLE_BORDER_MEDIUM			= 0x2,
19 	GNM_STYLE_BORDER_DASHED			= 0x3,
20 	GNM_STYLE_BORDER_DOTTED			= 0x4,
21 	GNM_STYLE_BORDER_THICK			= 0x5,
22 	GNM_STYLE_BORDER_DOUBLE			= 0x6,
23 	GNM_STYLE_BORDER_HAIR			= 0x7,
24 	GNM_STYLE_BORDER_MEDIUM_DASH		= 0x8,
25 	GNM_STYLE_BORDER_DASH_DOT			= 0x9,
26 	GNM_STYLE_BORDER_MEDIUM_DASH_DOT		= 0xa,
27 	GNM_STYLE_BORDER_DASH_DOT_DOT		= 0xb,
28 	GNM_STYLE_BORDER_MEDIUM_DASH_DOT_DOT	= 0xc,
29 	GNM_STYLE_BORDER_SLANTED_DASH_DOT		= 0xd,
30 
31 	/* ONLY for internal use */
32 	GNM_STYLE_BORDER_INCONSISTENT		= 0xe,
33 
34 	GNM_STYLE_BORDER_MAX
35 } GnmStyleBorderType;
36 
37 /* The order corresponds to the border_buttons name list
38  * in dialog_cell_format_impl
39  * GNM_STYLE_BORDER_TOP must be 0 */
40 typedef enum {
41 	GNM_STYLE_BORDER_TOP,		GNM_STYLE_BORDER_BOTTOM,
42 	GNM_STYLE_BORDER_LEFT,		GNM_STYLE_BORDER_RIGHT,
43 	GNM_STYLE_BORDER_REV_DIAG,	GNM_STYLE_BORDER_DIAG,
44 
45 	/* These are special.
46 	 * They are logical rather than actual borders, however, they
47 	 * require extra lines to be drawn so they need to be here.
48 	 */
49 	GNM_STYLE_BORDER_HORIZ,		GNM_STYLE_BORDER_VERT,
50 
51 	GNM_STYLE_BORDER_EDGE_MAX
52 } GnmStyleBorderLocation;
53 
54 #define GNM_STYLE_BORDER_LOCATION_TO_STYLE_ELEMENT(sbl) ((GnmStyleElement)(MSTYLE_BORDER_TOP + (int)((sbl) - GNM_STYLE_BORDER_TOP)))
55 
56 struct _GnmBorder {
57 	/* Key elements */
58 	GnmStyleBorderType line_type;
59 	GnmColor	*color;
60 	int		 begin_margin, end_margin, width;
61 
62 	/* Private */
63 	gint	        ref_count;
64 };
65 
66 void        gnm_border_shutdown (void);
67 GType       gnm_border_get_type    (void);
68 void	    gnm_style_border_unref (GnmBorder *border);
69 GnmBorder  *gnm_style_border_ref   (GnmBorder *border);
70 
71 #define	gnm_style_border_is_blank(b) ((b) == NULL || (b)->line_type == GNM_STYLE_BORDER_NONE)
72 GnmBorder  *gnm_style_border_none  (void);
73 void        gnm_style_border_none_set_color (GnmColor *color);
74 
75 GnmBorder  *gnm_style_border_fetch (GnmStyleBorderType line_type,
76 				    GnmColor *color,
77 				    GnmStyleBorderOrientation orientation);
78 gboolean gnm_style_border_visible_in_blank (GnmBorder const *border);
79 
80 GnmStyleBorderOrientation gnm_style_border_get_orientation (GnmStyleBorderLocation type);
81 
82 gint   gnm_style_border_get_width   (GnmStyleBorderType const line_type);
83 void gnm_style_border_set_dash (GnmStyleBorderType const i, cairo_t *context);
84 
85 void gnm_style_borders_row_draw (GnmBorder const * const * prev_vert,
86 				 GnmStyleRow const *sr,
87 				 cairo_t *cr,
88 				 int x, int y1, int y2,
89 				 int *colwidths,
90 				 gboolean draw_vertical, int dir);
91 void gnm_style_border_draw_diag  (GnmStyle const *style,
92 				  cairo_t *cr,
93 				  int x1, int y1, int x2, int y2);
94 
95 void gnm_style_borders_row_print_gtk (GnmBorder const * const * prev_vert,
96 				      GnmStyleRow const *sr,
97 				      cairo_t *context,
98 				      double x, double y1, double y2,
99 				      Sheet const *sheet,
100 				      gboolean draw_vertical, int dir);
101 void gnm_style_border_print_diag_gtk (GnmStyle const *style,
102 				      cairo_t *context,
103 				      double x1, double y1,
104 				      double x2, double y2);
105 
106 G_END_DECLS
107 
108 #endif /* _GNM_STYLE_BORDER_H_ */
109