NvDialog 0.10.1
A cross-platform modal dialogs library for C/C++ that uses the native OS theme.
Loading...
Searching...
No Matches
nvdialog.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2025 Aggelos Tselios
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
25#ifndef __nvdialog_h__
26#define __nvdialog_h__
27
28#ifdef __cplusplus
29extern "C" {
30#endif /* __cplusplus */
31
32/**
33 * @mainpage
34 * <b>Documentation</b>
35 *
36 * This manual documents the NvDialog library, a dialog box library written in C
37 * that uses the system API to display its dialogs, making it minimal, dependency-free, portable and easy to use.
38 * Instructions on how to build the library can be found in @ref building "this page". There are also multiple examples
39 * to get you started - You can probably copy them in your source and continue with your project.
40 *
41 * NvDialog is verified to work on Windows (XP through 11), macOS (Catalina), Debian (10-13), Arch Linux and FreeBSD. Most other
42 * Unix-like OSes also work, as long as Gtk3 is installed on the system.
43 *
44 * To get started, you should read about @ref NvdDialogBox, which is a simple
45 * dialog box with no special functionality in it apart from the very basics. NvDialog also provides the following (among many many others)
46 * features as part of its API:
47 * - @ref NvdAboutDialog
48 * - @ref NvdQuestionBox
49 * - @ref NvdFileDialog
50 *
51 * # Examples
52 * If you want to check out some code before using this library in your
53 * project, this is a simple example: (Taken directly from the [GitHub
54 * README](https://github.com/tseli0s/nvdialog)).
55 * @code
56 * #include <nvdialog/nvdialog.h>
57 * int main(int argc, char** argv) {
58 * nvd_init();
59 * NvdDialogBox *dialog = nvd_dialog_box_new("Dialog Title", "Dialog
60 * Message", NVD_DIALOG_SIMPLE); if (!dialog) return -1;
61 *
62 * nvd_show_dialog(dialog);
63 * nvd_free_object(dialog);
64 *
65 * return 0;
66 * }
67 * @endcode
68 * # Other Resources
69 * - [GitHub URL](https://github.com/tseli0s/nvdialog.git)
70 * - [Homepage](https://tseli0s.github.io/nv.dialog)
71 * - [Bug Tracker](https://github.com/tseli0s/nvdialog/issues)
72 * - [Releases](https://github.com/tseli0s/nvdialog/releases)
73 */
75/** Major version of NvDialog at compile time. */
76#define NVDIALOG_VERSION_MAJOR 0
77/** Minor version of NvDialog at compile time. */
78#define NVDIALOG_VERSION_MINOR 10
79/** Patch version of NvDialog at compile time. */
80#define NVDIALOG_VERSION_PATCH 1
82/** @brief A macro to set the version at compile time. */
83#define NVD_VERSION(x) \
84 { \
85 (NvdVersion) x.major = NVDIALOG_VERSION_MAJOR; \
86 (NvdVersion) x.minor = NVDIALOG_VERSION_MINOR; \
87 (NvdVersion) x.patch = NVDIALOG_VERSION_PATCH; \
88 }
89
90#if !defined(NVD_API_EXPORT) && !defined(NVD_API_IMPORT) && !defined(NVD_API)
91
92#if defined(_WIN32) || defined(WIN32)
93#if defined(__clang__) || defined(__GNUC__)
94#define NVD_API_EXPORT __attribute__((dllexport))
95#else /* __clang__ */
96#define NVD_API_EXPORT __declspec(dllexport)
97#endif /* NVD_API */
98#else /* _WIN32 */
99#define NVD_API_EXPORT
100#endif /* _WIN32 */
101
102#if defined(_WIN32) || defined(WIN32)
103#if defined(__clang__) || defined(__GNUC__)
104#define NVD_API_IMPORT __attribute__((dllimport))
105#else /* __clang__ */
106#define NVD_API_IMPORT __declspec(dllimport)
107#endif /* NVD_API */
108#else /* _WIN32 */
109#define NVD_API_IMPORT
110#endif /* _WIN32 */
111
112#if defined(NVD_EXPORT_SYMBOLS)
113#define NVD_API NVD_API_EXPORT
114#else
115#define NVD_API NVD_API_IMPORT
116#endif /* DLLEXPORT */
117
118#endif /* !defined(NVD_API_EXPORT) && !defined(NVD_API_IMPORT) && \
119 !defined(NVD_API) */
120
121#if !defined(_WIN32) || !defined(WIN32)
122
123#if __STDC_VERSION__ >= 201112L
124/**
125 * @brief A macro to create thread-local static variables, primarily intended
126 * for usage within NvDialog.
127 * @note This requires C11 and newer to work, due to the `_Thread_local` macro.
128 * @since v0.7.0
129 */
130#define NVD_THREAD_LOCAL(var) static _Thread_local var
131#else
132#warning Compiler does not implement the C11 standard as required, thread local variables will be disabled.
133#define NVD_THREAD_LOCAL(var) static var
134#endif
135
136#else
137#define NVD_THREAD_LOCAL(var) static var
138#endif /* _WIN32 */
139
140#include "nvdialog_capab.h"
141#include "nvdialog_core.h"
142#include "nvdialog_dialog.h"
143#include "nvdialog_error.h"
144#include "nvdialog_image.h"
146#include "nvdialog_types.h"
147
148/**
149 * @brief Returns the version of nvdialog currently linked with.
150 * @details For a compile time alternative implementation see the
151 * NVDIALOG_VERSION_MAJOR, NVDIALOG_VERSION_MINOR and NVDIALOG_VERSION_PATCH
152 * constants.
153 * @returns The version of NvDialog linked with at runtime, as a struct.
154 * @since v0.2.0
155 * @ingroup Version
156 */
158
159#ifdef __cplusplus
160}
161#endif /* __cplusplus */
162
163#endif /* __nvdialog_h__ */
NvdVersion nvd_get_version()
Returns the version of nvdialog currently linked with.
A struct that identifies the version of NvDialog.
Definition nvdialog_types.h:84