NvDialog 0.10.1
A cross-platform modal dialogs library for C/C++ that uses the native OS theme.
Loading...
Searching...
No Matches
nvdialog_input_box.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#pragma once
26
28#include "../nvdialog_string.h"
29
30/**
31 * @brief A simple input box that accepts text input from the user.
32 * @details An `NvdInputBox` provides the user with a small prompt (commonly a dialog window similar)
33 * to @ref NvdDialogBox that requests some text input from the user. When the input is submitted, the
34 * library returns the submitted text. For convenience and compatibility reasons, the input is guaranteed
35 * to be limited to a single line.
36 * @note Just like @ref NvdDialogBox and some other APIs, reusing an `NvdInputBox` is undefined behaviour, depending on the platform.
37 * @sa @ref NvdDialogBox
38 * @ingroup InputDialog
39 * @since v0.10.0
40 */
41
42typedef struct _NvdInputBox NvdInputBox;
43
44/**
45 * @brief Constructs a new @ref NvdInputBox and returns it.
46 * @param title The title of the input box, cannot be NULL
47 * @param msg The message of the input box. If NULL, then a preconfigured string will be displayed.
48 * @since v0.10.0
49 * @warning By default on Windows the dialog will use a fallback theme, since NvDialog does not want to force a manifest to load
50 * the proper theme as required by WinAPI. This may make controls look a bit outdated. To fix it, you must either supply your own .rc file
51 * and change the theming manually, or embed, at your own risk of breaking other libraries, the .rc file directly into NvDialog. If you do the former,
52 * do it before initializing the library. This does not apply on macOS and Linux.
53 * @ingroup InputDialog
54 * @returns A new @ref NvdInputBox on success, NULL otherwise.
55*/
56NVD_API NvdInputBox *nvd_input_box_new(const char *title, const char *msg);
57
58/**
59 * @brief Displays the @ref NvdInputBox given to the user.
60 * @param box The input box to display. May not be NULL.
61 * @note To retrieve the input of the user, use @ref nvd_input_box_get_string.
62 * @since v0.10.0
63 * @ingroup InputDialog
64*/
66
67/**
68 * @brief Retrieves the text entered by the user in an @ref NvdInputBox.
69 * @param box The input box to get the string from. May not be NULL.
70 * @returns A constant pointer to an @ref NvdDynamicString containing the user's input.
71 * @note Invalid data may be given by the user. Make sure you check the string for validity.
72 * @since v0.10.0
73 * @ingroup InputDialog
74 */
#define NVD_API
Definition nvdialog.h:113
NVD_API NvdDynamicString * nvd_input_box_get_string(NvdInputBox *box)
Retrieves the text entered by the user in an NvdInputBox.
NVD_API NvdInputBox * nvd_input_box_new(const char *title, const char *msg)
Constructs a new NvdInputBox and returns it.
struct _NvdInputBox NvdInputBox
A simple input box that accepts text input from the user.
Definition nvdialog_input_box.h:42
NVD_API void nvd_show_input_box(NvdInputBox *box)
Displays the NvdInputBox given to the user.
struct _NvdDynamicString NvdDynamicString
A string type that can be resized, manipulated, converted and read from.
Definition nvdialog_string.h:60