GUI: Move .ui files from goffice resources to glib resources
[gnumeric.git] / src / validation.h
blobc57dff69cad1bb930ea269a4bb0802eea1f6d71f
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 #ifndef _GNM_VALIDATION_H_
3 # define _GNM_VALIDATION_H_
5 #include "gnumeric.h"
6 #include "dependent.h"
8 G_BEGIN_DECLS
10 typedef enum {
11 GNM_VALIDATION_STATUS_VALID, /* things validate */
12 GNM_VALIDATION_STATUS_INVALID_DISCARD, /* things do not validate and should be discarded */
13 GNM_VALIDATION_STATUS_INVALID_EDIT /* things do not validate and editing should continue */
14 } ValidationStatus;
15 typedef enum {
16 GNM_VALIDATION_STYLE_NONE,
17 GNM_VALIDATION_STYLE_STOP,
18 GNM_VALIDATION_STYLE_WARNING,
19 GNM_VALIDATION_STYLE_INFO,
20 GNM_VALIDATION_STYLE_PARSE_ERROR
21 } ValidationStyle;
22 typedef enum {
23 GNM_VALIDATION_TYPE_ANY,
24 GNM_VALIDATION_TYPE_AS_INT,
25 GNM_VALIDATION_TYPE_AS_NUMBER,
26 GNM_VALIDATION_TYPE_IN_LIST,
27 GNM_VALIDATION_TYPE_AS_DATE,
28 GNM_VALIDATION_TYPE_AS_TIME,
29 GNM_VALIDATION_TYPE_TEXT_LENGTH,
30 GNM_VALIDATION_TYPE_CUSTOM
31 } ValidationType;
32 typedef enum {
33 GNM_VALIDATION_OP_NONE = -1,
34 GNM_VALIDATION_OP_BETWEEN,
35 GNM_VALIDATION_OP_NOT_BETWEEN,
36 GNM_VALIDATION_OP_EQUAL,
37 GNM_VALIDATION_OP_NOT_EQUAL,
38 GNM_VALIDATION_OP_GT,
39 GNM_VALIDATION_OP_LT,
40 GNM_VALIDATION_OP_GTE,
41 GNM_VALIDATION_OP_LTE
42 } ValidationOp;
44 struct _GnmValidation {
45 int ref_count;
47 GOString *title;
48 GOString *msg;
49 GnmDependent deps[2];
50 ValidationStyle style;
51 ValidationType type;
52 ValidationOp op;
53 gboolean allow_blank;
54 gboolean use_dropdown;
57 GType gnm_validation_type_get_type (void);
58 #define GNM_VALIDATION_TYPE_TYPE (gnm_validation_type_get_type ())
60 GType gnm_validation_style_get_type (void);
61 #define GNM_VALIDATION_STYLE_TYPE (gnm_validation_style_get_type ())
63 GType gnm_validation_op_get_type (void);
64 #define GNM_VALIDATION_OP_TYPE (gnm_validation_op_get_type ())
67 GType gnm_validation_get_type (void);
68 GnmValidation *gnm_validation_new (ValidationStyle style,
69 ValidationType type,
70 ValidationOp op,
71 Sheet *sheet,
72 char const *title, char const *msg,
73 GnmExprTop const *texpr0,
74 GnmExprTop const *texpr1,
75 gboolean allow_blank,
76 gboolean use_dropdown);
77 GnmValidation *gnm_validation_dup (GnmValidation *v);
78 gboolean gnm_validation_equal (GnmValidation const *a,
79 GnmValidation const *b,
80 gboolean relax_sheet);
82 GnmValidation *gnm_validation_ref (GnmValidation const *v);
83 void gnm_validation_unref (GnmValidation const *v);
85 void gnm_validation_set_expr (GnmValidation *v,
86 GnmExprTop const *texpr, unsigned indx);
87 GError *gnm_validation_is_ok (GnmValidation const *v);
89 Sheet *gnm_validation_get_sheet (GnmValidation const *v);
90 void gnm_validation_set_sheet (GnmValidation *v, Sheet *sheet);
92 ValidationStatus gnm_validation_eval (WorkbookControl *wbc,
93 GnmStyle const *mstyle,
94 Sheet *sheet, GnmCellPos const *pos,
95 gboolean *showed_dialog);
96 ValidationStatus gnm_validation_eval_range (WorkbookControl *wbc,
97 Sheet *sheet,
98 GnmCellPos const *pos,
99 GnmRange const *r,
100 gboolean *showed_dialog);
102 G_END_DECLS
104 #endif /* _GNM_VALIDATION_H_ */