1
/* ipuz-style.h
2
 *
3
 * Copyright 2022 Jonathan Blandford <jrb@gnome.org>
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
 *
19
 * SPDX-License-Identifier: (LGPL-2.1-or-later OR MIT)
20
 */
21

            
22
#pragma once
23

            
24
#include <glib-object.h>
25
#include <json-glib/json-glib.h>
26

            
27
G_BEGIN_DECLS
28

            
29

            
30
#define IPUZ_TYPE_STYLE (ipuz_style_get_type ())
31
#define IPUZ_STYLE(style) ((IPuzStyle *)style)
32
typedef enum
33
{
34
  IPUZ_STYLE_SHAPE_NONE,
35
  IPUZ_STYLE_SHAPE_CIRCLE,
36
  IPUZ_STYLE_SHAPE_ARROW_LEFT,
37
  IPUZ_STYLE_SHAPE_ARROW_RIGHT,
38
  IPUZ_STYLE_SHAPE_ARROW_UP,
39
  IPUZ_STYLE_SHAPE_ARROW_DOWN,
40
  IPUZ_STYLE_SHAPE_TRIANGLE_LEFT,
41
  IPUZ_STYLE_SHAPE_TRIANGLE_RIGHT,
42
  IPUZ_STYLE_SHAPE_TRIANGLE_UP,
43
  IPUZ_STYLE_SHAPE_TRIANGLE_DOWN,
44
  IPUZ_STYLE_SHAPE_DIAMOND,
45
  IPUZ_STYLE_SHAPE_CLUB,
46
  IPUZ_STYLE_SHAPE_HEART,
47
  IPUZ_STYLE_SHAPE_SPADE,
48
  IPUZ_STYLE_SHAPE_STAR,
49
  IPUZ_STYLE_SHAPE_SQUARE,
50
  IPUZ_STYLE_SHAPE_RHOMBUS,
51
  IPUZ_STYLE_SHAPE_SLASH,
52
  IPUZ_STYLE_SHAPE_BACKSLASH,
53
  IPUZ_STYLE_SHAPE_X,
54
} IPuzStyleShape;
55

            
56
typedef enum
57
{
58
  IPUZ_STYLE_DIVIDED_NONE,
59
  IPUZ_STYLE_DIVIDED_HORIZ,    /* @ "-" @ */
60
  IPUZ_STYLE_DIVIDED_VERT,     /* @ "|" @ */
61
  IPUZ_STYLE_DIVIDED_UP_RIGHT, /* @ "/" @ */
62
  IPUZ_STYLE_DIVIDED_UP_LEFT,  /* @ "\" @ */
63
  IPUZ_STYLE_DIVIDED_PLUS,     /* @ "+" @ */
64
  IPUZ_STYLE_DIVIDED_CROSS,    /* @ "X" @ */
65
} IPuzStyleDivided;
66

            
67
typedef enum
68
{
69
  IPUZ_STYLE_MARK_TL = 1 << 0,
70
  IPUZ_STYLE_MARK_T = 1 << 1,
71
  IPUZ_STYLE_MARK_TR = 1 << 2,
72
  IPUZ_STYLE_MARK_L = 1 << 3,
73
  IPUZ_STYLE_MARK_C = 1 << 4,
74
  IPUZ_STYLE_MARK_R = 1 << 5,
75
  IPUZ_STYLE_MARK_BL = 1 << 6,
76
  IPUZ_STYLE_MARK_B = 1 << 7,
77
  IPUZ_STYLE_MARK_BR = 1 << 8,
78
} IPuzStyleMark;
79

            
80
typedef enum
81
{
82
  IPUZ_STYLE_SIDES_TOP    = 1 << 0,
83
  IPUZ_STYLE_SIDES_RIGHT  = 1 << 1,
84
  IPUZ_STYLE_SIDES_BOTTOM = 1 << 2,
85
  IPUZ_STYLE_SIDES_LEFT   = 1 << 3,
86
} IPuzStyleSides;
87

            
88
#define IPUZ_STYLE_MARK_TOP (IPUZ_STYLE_MARK_TL | IPUZ_STYLE_MARK_T | IPUZ_STYLE_MARK_TR)
89
#define IPUZ_STYLE_MARK_CENTER_ROW (IPUZ_STYLE_MARK_L | IPUZ_STYLE_MARK_C | IPUZ_STYLE_MARK_R)
90
#define IPUZ_STYLE_MARK_BOTTOM (IPUZ_STYLE_MARK_BL | IPUZ_STYLE_MARK_B | IPUZ_STYLE_MARK_BR)
91
#define IPUZ_STYLE_MARK_LEFT (IPUZ_STYLE_MARK_TL | IPUZ_STYLE_MARK_L | IPUZ_STYLE_MARK_BL)
92
#define IPUZ_STYLE_MARK_CENTER_COL (IPUZ_STYLE_MARK_T | IPUZ_STYLE_MARK_C | IPUZ_STYLE_MARK_B)
93
#define IPUZ_STYLE_MARK_RIGHT (IPUZ_STYLE_MARK_TR | IPUZ_STYLE_MARK_R | IPUZ_STYLE_MARK_BR)
94

            
95
#define IPUZ_STYLE_SIDES_TOP_LEFT     (IPUZ_STYLE_SIDES_TOP|IPUZ_STYLE_SIDES_LEFT)
96
#define IPUZ_STYLE_SIDES_BOTTOM_RIGHT (IPUZ_STYLE_SIDES_BOTTOM|IPUZ_STYLE_SIDES_RIGHT)
97

            
98
#define IPUZ_STYLE_SIDES_HAS_LEFT(sides)   ((sides&IPUZ_STYLE_SIDES_LEFT)==IPUZ_STYLE_SIDES_LEFT)
99
#define IPUZ_STYLE_SIDES_HAS_RIGHT(sides)  ((sides&IPUZ_STYLE_SIDES_RIGHT)==IPUZ_STYLE_SIDES_RIGHT)
100
#define IPUZ_STYLE_SIDES_HAS_TOP(sides)    ((sides&IPUZ_STYLE_SIDES_TOP)==IPUZ_STYLE_SIDES_TOP)
101
#define IPUZ_STYLE_SIDES_HAS_BOTTOM(sides) ((sides&IPUZ_STYLE_SIDES_BOTTOM)==IPUZ_STYLE_SIDES_BOTTOM)
102

            
103
typedef void (*IPuzMarkFunc) (IPuzStyleMark  mark,
104
                              const gchar   *label,
105
                              gpointer       user_data);
106

            
107
typedef struct _IPuzStyle IPuzStyle;
108

            
109

            
110
GType             ipuz_style_get_type               (void) G_GNUC_CONST;
111
IPuzStyle        *ipuz_style_new                    (void);
112
IPuzStyle        *ipuz_style_new_from_json          (JsonNode         *node);
113
IPuzStyle        *ipuz_style_ref                    (IPuzStyle        *style);
114
void              ipuz_style_unref                  (IPuzStyle        *style);
115
gboolean          ipuz_style_equal                  (IPuzStyle        *a,
116
                                                     IPuzStyle        *b);
117
IPuzStyle        *ipuz_style_copy                   (IPuzStyle        *style);
118
void              ipuz_style_build                  (IPuzStyle        *style,
119
                                                     JsonBuilder      *builder);
120
gboolean          ipuz_style_is_empty               (IPuzStyle        *style);
121
const gchar      *ipuz_style_get_style_name         (IPuzStyle        *style);
122
void              ipuz_style_set_style_name         (IPuzStyle        *style,
123
                                                     const gchar      *style_name);
124
const gchar      *ipuz_style_get_named              (IPuzStyle        *style);
125
void              ipuz_style_set_named              (IPuzStyle        *style,
126
                                                     const gchar      *named);
127
gint              ipuz_style_get_border             (IPuzStyle        *style);
128
void              ipuz_style_set_border             (IPuzStyle        *style,
129
                                                     gint              border);
130
IPuzStyleShape    ipuz_style_get_shapebg            (IPuzStyle        *style);
131
void              ipuz_style_set_shapebg            (IPuzStyle        *style,
132
                                                     IPuzStyleShape    shapebg);
133
gboolean          ipuz_style_get_highlight          (IPuzStyle        *style);
134
void              ipuz_style_set_highlight          (IPuzStyle        *style,
135
                                                     gboolean          highlight);
136
IPuzStyleDivided  ipuz_style_get_divided            (IPuzStyle        *style);
137
void              ipuz_style_set_divided            (IPuzStyle        *style,
138
                                                     IPuzStyleDivided  divided);
139
void              ipuz_style_mark_foreach           (IPuzStyle        *style,
140
                                                     IPuzMarkFunc      func,
141
                                                     gpointer          user_data);
142
const gchar      *ipuz_style_get_label              (IPuzStyle        *style);
143
void              ipuz_style_set_label              (IPuzStyle        *style,
144
                                                     const gchar      *label);
145
const gchar      *ipuz_style_get_image_url          (IPuzStyle        *style);
146
void              ipuz_style_set_image_url          (IPuzStyle        *style,
147
                                                     const gchar      *image_url);
148
const gchar      *ipuz_style_get_imagebg_url        (IPuzStyle        *style);
149
void              ipuz_style_set_imagebg_url        (IPuzStyle        *style,
150
                                                     const gchar      *imagebg_url);
151
const gchar      *ipuz_style_get_bg_color           (IPuzStyle        *style);
152
void              ipuz_style_set_bg_color           (IPuzStyle        *style,
153
                                                     const gchar      *bg_color);
154
const gchar      *ipuz_style_get_text_color         (IPuzStyle        *style);
155
void              ipuz_style_set_text_color         (IPuzStyle        *style,
156
                                                     const gchar      *text_color);
157
const gchar      *ipuz_style_get_border_color       (IPuzStyle        *style);
158
void              ipuz_style_set_border_color       (IPuzStyle        *style,
159
                                                     const gchar      *border_color);
160
IPuzStyleSides    ipuz_style_get_barred             (IPuzStyle        *style);
161
void              ipuz_style_set_barred             (IPuzStyle        *style,
162
                                                     IPuzStyleSides    barred);
163
IPuzStyleSides    ipuz_style_get_dotted             (IPuzStyle        *style);
164
void              ipuz_style_set_dotted             (IPuzStyle        *style,
165
                                                     IPuzStyleSides    dotted);
166
IPuzStyleSides    ipuz_style_get_dashed             (IPuzStyle        *style);
167
void              ipuz_style_set_dashed             (IPuzStyle        *style,
168
                                                     IPuzStyleSides    dashed);
169
IPuzStyleSides    ipuz_style_get_lessthan           (IPuzStyle        *style);
170
void              ipuz_style_set_lessthan           (IPuzStyle        *style,
171
                                                     IPuzStyleSides    lessthan);
172
IPuzStyleSides    ipuz_style_get_greaterthan        (IPuzStyle        *style);
173
void              ipuz_style_set_greaterthan        (IPuzStyle        *style,
174
                                                     IPuzStyleSides    greaterthan);
175
IPuzStyleSides    ipuz_style_get_equal              (IPuzStyle        *style);
176
void              ipuz_style_set_equal              (IPuzStyle        *style,
177
                                                     IPuzStyleSides    equal);
178

            
179
IPuzStyleSides    ipuz_style_side_opposite          (IPuzStyleSides    side);
180
IPuzStyleSides    ipuz_style_sides_rotate_180       (IPuzStyleSides    sides);
181
IPuzStyleSides    ipuz_style_sides_rotate_rt        (IPuzStyleSides    sides);
182
IPuzStyleSides    ipuz_style_sides_rotate_lt        (IPuzStyleSides    sides);
183
IPuzStyleSides    ipuz_style_sides_flip_horiz       (IPuzStyleSides    sides);
184
IPuzStyleSides    ipuz_style_sides_flip_vert        (IPuzStyleSides    sides);
185

            
186
const gchar      *ipuz_style_shape_get_display_name (IPuzStyleShape    shapebg);
187

            
188

            
189
4
G_DEFINE_AUTOPTR_CLEANUP_FUNC(IPuzStyle, ipuz_style_unref);
190

            
191

            
192
G_END_DECLS