Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7638 views
1
#ifndef MUPDF_PDF_WIDGET_H
2
#define MUPDF_PDF_WIDGET_H
3
4
/* Types of widget */
5
enum
6
{
7
PDF_WIDGET_TYPE_NOT_WIDGET = -1,
8
PDF_WIDGET_TYPE_PUSHBUTTON,
9
PDF_WIDGET_TYPE_CHECKBOX,
10
PDF_WIDGET_TYPE_RADIOBUTTON,
11
PDF_WIDGET_TYPE_TEXT,
12
PDF_WIDGET_TYPE_LISTBOX,
13
PDF_WIDGET_TYPE_COMBOBOX,
14
PDF_WIDGET_TYPE_SIGNATURE
15
};
16
17
/* Types of text widget content */
18
enum
19
{
20
PDF_WIDGET_CONTENT_UNRESTRAINED,
21
PDF_WIDGET_CONTENT_NUMBER,
22
PDF_WIDGET_CONTENT_SPECIAL,
23
PDF_WIDGET_CONTENT_DATE,
24
PDF_WIDGET_CONTENT_TIME
25
};
26
27
/*
28
Widgets that may appear in PDF forms
29
*/
30
31
/*
32
pdf_focused_widget: returns the currently focussed widget
33
34
Widgets can become focussed as a result of passing in ui events.
35
NULL is returned if there is no currently focussed widget. An
36
app may wish to create a native representative of the focussed
37
widget, e.g., to collect the text for a text widget, rather than
38
routing key strokes through pdf_pass_event.
39
*/
40
pdf_widget *pdf_focused_widget(fz_context *ctx, pdf_document *doc);
41
42
/*
43
pdf_first_widget: get first widget when enumerating
44
*/
45
pdf_widget *pdf_first_widget(fz_context *ctx, pdf_document *doc, pdf_page *page);
46
47
/*
48
pdf_next_widget: get next widget when enumerating
49
*/
50
pdf_widget *pdf_next_widget(fz_context *ctx, pdf_widget *previous);
51
52
/*
53
pdf_create_widget: create a new widget of a specific type
54
*/
55
pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page, int type, char *fieldname);
56
57
/*
58
pdf_widget_get_type: find out the type of a widget.
59
60
The type determines what widget subclass the widget
61
can safely be cast to.
62
*/
63
int pdf_widget_get_type(fz_context *ctx, pdf_widget *widget);
64
65
/*
66
pdf_bound_widget: get the bounding box of a widget.
67
*/
68
fz_rect *pdf_bound_widget(fz_context *ctx, pdf_widget *widget, fz_rect *);
69
70
/*
71
pdf_text_widget_text: Get the text currently displayed in
72
a text widget.
73
*/
74
char *pdf_text_widget_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
75
76
/*
77
pdf_widget_text_max_len: get the maximum number of
78
characters permitted in a text widget
79
*/
80
int pdf_text_widget_max_len(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
81
82
/*
83
pdf_text_widget_content_type: get the type of content
84
required by a text widget
85
*/
86
int pdf_text_widget_content_type(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
87
88
/*
89
pdf_text_widget_set_text: Update the text of a text widget.
90
The text is first validated and accepted only if it passes. The
91
function returns whether validation passed.
92
*/
93
int pdf_text_widget_set_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *text);
94
95
/*
96
pdf_choice_widget_options: get the list of options for a list
97
box or combo box. Returns the number of options and fills in their
98
names within the supplied array. Should first be called with a
99
NULL array to find out how big the array should be.
100
*/
101
int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *opts[]);
102
103
/*
104
pdf_choice_widget_is_multiselect: returns whether a list box or
105
combo box supports selection of multiple options
106
*/
107
int pdf_choice_widget_is_multiselect(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
108
109
/*
110
pdf_choice_widget_value: get the value of a choice widget.
111
Returns the number of options curently selected and fills in
112
the supplied array with their strings. Should first be called
113
with NULL as the array to find out how big the array need to
114
be. The filled in elements should not be freed by the caller.
115
*/
116
int pdf_choice_widget_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *opts[]);
117
118
/*
119
pdf_widget_set_value: set the value of a choice widget. The
120
caller should pass the number of options selected and an
121
array of their names
122
*/
123
void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int n, char *opts[]);
124
125
#endif
126
127