-
Notifications
You must be signed in to change notification settings - Fork 0
/
UNativeDialogs.h
119 lines (94 loc) · 2.42 KB
/
UNativeDialogs.h
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
// Author: Damian Kaczmarek <damian@codecharm.co.uk>
#ifndef UNATIVEDIALOGS_H
#define UNATIVEDIALOGS_H
/*
Usage:
struct UFileDialogHints hints = DEFAULT_UFILEDIALOGHINTS;
<setup your hints>
dialog = UFileDialog_Create(hints);
and in the event loop call:
bool status = UFileDialog_ProcessEvents(dialog);
if(!status) {
const UFileDialogResult* result = UFileDialog_Result(dialog);
<do something with the result>
UFileDialog_Destroy(dialog);
}
*/
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
struct UFileDialog;
typedef struct UFileDialog UFileDialog;
typedef enum
{
UFileDialogActionOpen = 0,
UFileDialogActionOpenMultiple = 1,
UFileDialogActionOpenDirectory = 2,
UFileDialogActionSave = 3
} UFileDialogActionType;
struct UFileDialogHints
{
UFileDialogActionType Action;
//! (optional) for example "All C++ files (*.cpp *.cc *.C *.cxx *.c++)""
const char* NameFilter;
//! (optional) absolute directory from which the dialog whould open
const char* InitialDirectory;
//! (optional) title to put on open file dialog
const char* WindowTitle;
};
#define DEFAULT_UFILEDIALOGHINTS { \
UFileDialogActionOpen, \
"All files (*.*)", \
NULL, \
NULL \
}
typedef struct UFileDialogResult
{
int count;
const char** selection;
} UFileDialogResult;
UFileDialog* UFileDialog_Create(struct UFileDialogHints* hints);
bool UFileDialog_ProcessEvents(UFileDialog* handle);
// valid after Process returning false
const UFileDialogResult* UFileDialog_Result(UFileDialog* handle);
void UFileDialog_Destroy(UFileDialog* handle);
struct UFontDialog;
typedef struct UFontDialog UFontDialog;
typedef enum {
UFontDialogNormal = 0,
UFontDialogBold = 1,
UFontDialogItalic = 2,
UFontDialogBoldItalic = 3
} UFontDialogFontFlags;
struct UFontDialogHints
{
float InitialPointSize;
int InitialPixelSize;
const char* InitialFontName;
const char* WindowTitle;
};
#define DEFAULT_UFONTDIALOGHINTS { \
0.0f, \
0 , \
NULL, \
NULL \
}
typedef struct UFontDialogResult
{
const char* fontName;
float pointSize;
int pixelSize;
UFontDialogFontFlags flags;
} UFontDialogResult;
UFontDialog* UFontDialog_Create(struct UFontDialogHints* hints);
bool UFontDialog_ProcessEvents(UFontDialog* handle);
// valid after Process returning false
const UFontDialogResult* UFontDialog_Result(UFontDialog* handle);
void UFontDialog_Destroy(UFontDialog* handle);
#ifdef __cplusplus
}
#endif
#endif // UNATIVEDIALOGS_H