forked from AndrewBelt/osdialog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
156 lines (139 loc) · 3.72 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include <stdlib.h>
#include <stdio.h>
#include "osdialog.h"
int main() {
// Message
if (1) {
int res;
fprintf(stderr, "message info\n");
res = osdialog_message(OSDIALOG_INFO, OSDIALOG_OK, "Info こんにちは");
fprintf(stderr, "\t%d\n", res);
fprintf(stderr, "message warning\n");
res = osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK_CANCEL, "Warning こんにちは");
fprintf(stderr, "\t%d\n", res);
fprintf(stderr, "message error\n");
res = osdialog_message(OSDIALOG_ERROR, OSDIALOG_YES_NO, "Error こんにちは");
fprintf(stderr, "\t%d\n", res);
}
// Prompt
if (0) {
char *text;
fprintf(stderr, "prompt info\n");
text = osdialog_prompt(OSDIALOG_INFO, "Info", "default text");
if (text) {
fprintf(stderr, "\t%s\n", text);
free(text);
}
else {
fprintf(stderr, "\tCanceled\n");
}
fprintf(stderr, "prompt warning\n");
text = osdialog_prompt(OSDIALOG_WARNING, "Warning", "default text");
if (text) {
fprintf(stderr, "\t%s\n", text);
free(text);
}
else {
fprintf(stderr, "\tCanceled\n");
}
fprintf(stderr, "prompt error\n");
text = osdialog_prompt(OSDIALOG_ERROR, "Error", "default text");
if (text) {
fprintf(stderr, "\t%s\n", text);
free(text);
}
else {
fprintf(stderr, "\tCanceled\n");
}
}
// Open directory with default arguments
if (1) {
fprintf(stderr, "file open dir\n");
char *filename = osdialog_file(OSDIALOG_OPEN_DIR, NULL, NULL, NULL);
if (filename) {
fprintf(stderr, "\t%s\n", filename);
free(filename);
}
else {
fprintf(stderr, "\tCanceled\n");
}
}
// Open file with default arguments
if (1) {
fprintf(stderr, "file open\n");
char *filename = osdialog_file(OSDIALOG_OPEN, NULL, NULL, NULL);
if (filename) {
fprintf(stderr, "\t%s\n", filename);
free(filename);
}
else {
fprintf(stderr, "\tCanceled\n");
}
}
// Save file with default arguments
if (1) {
fprintf(stderr, "file save\n");
char *filename = osdialog_file(OSDIALOG_SAVE, NULL, NULL, NULL);
if (filename) {
fprintf(stderr, "\t%s\n", filename);
free(filename);
}
else {
fprintf(stderr, "\tCanceled\n");
}
}
// Open directory with custom arguments
if (1) {
fprintf(stderr, "file open dir in cwd\n");
char *filename = osdialog_file(OSDIALOG_OPEN_DIR, ".", "こんにちは", NULL);
if (filename) {
fprintf(stderr, "\t%s\n", filename);
free(filename);
}
else {
fprintf(stderr, "\tCanceled\n");
}
}
// Open file with custom arguments
if (1) {
fprintf(stderr, "file open in cwd\n");
osdialog_filters *filters = osdialog_filters_parse("Source:c,cpp,m;Header:h,hpp");
char *filename = osdialog_file(OSDIALOG_OPEN, ".", "こんにちは", filters);
if (filename) {
fprintf(stderr, "\t%s\n", filename);
free(filename);
}
else {
fprintf(stderr, "\tCanceled\n");
}
osdialog_filters_free(filters);
}
// Save file with custom arguments
if (1) {
osdialog_filters *filters = osdialog_filters_parse("Source:c,cpp,m;Header:h,hpp");
fprintf(stderr, "file save in cwd\n");
char *filename = osdialog_file(OSDIALOG_SAVE, ".", "こんにちは", filters);
if (filename) {
fprintf(stderr, "\t%s\n", filename);
free(filename);
}
else {
fprintf(stderr, "\tCanceled\n");
}
osdialog_filters_free(filters);
}
// Color selector
if (1) {
int res;
osdialog_color color = {255, 0, 255, 255};
fprintf(stderr, "color picker\n");
res = osdialog_color_picker(&color, 0);
fprintf(stderr, "\t%d\n", res);
fprintf(stderr, "\t#%02x%02x%02x%02x\n", color.r, color.g, color.b, color.a);
fprintf(stderr, "color picker with opacity\n");
res = osdialog_color_picker(&color, 1);
fprintf(stderr, "\t%d\n", res);
fprintf(stderr, "\t#%02x%02x%02x%02x\n", color.r, color.g, color.b, color.a);
}
return 0;
}