NvDialog 0.10.1
A cross-platform modal dialogs library for C/C++ that uses the native OS theme.
Loading...
Searching...
No Matches
nvdialog_dialog_box.h File Reference

Go to the source code of this file.

Typedefs

typedef struct _NvdDialogBox NvdDialogBox
 A type to identify a single dialog box.
typedef struct _NvdQuestionBox NvdQuestionBox
 A similar struct to NvdDialogBox, but instead used for question dialogs.

Functions

NVD_API NvdDialogBoxnvd_dialog_box_new (const char *title, const char *message, NvdDialogType type)
 Creates a new dialog object and returns it.
NVD_API void nvd_show_dialog (NvdDialogBox *dialog)
 Shows a dialog to the system shell.
NVD_API NvdQuestionBoxnvd_dialog_question_new (const char *title, const char *question, NvdQuestionButton button)
 Creates a question dialog box with the given parameters. This function creates a dialog box containing a question with a few buttons such as:
NVD_API NvdReply nvd_get_reply (NvdQuestionBox *box)
 Shows the question dialog given to the system and returns the choice given.
NVD_API void * nvd_dialog_question_get_raw (NvdQuestionBox *dialog)
 Returns the raw object behind the dialog.
NVD_API void * nvd_dialog_box_get_raw (NvdDialogBox *dialog)
 Returns the raw object behind the dialog.
NVD_API void nvd_dialog_box_set_accept_text (NvdDialogBox *dialog, const char *accept_text)
 Sets the accept text for the dialog (The "Ok" button label).

Typedef Documentation

◆ NvdDialogBox

typedef struct _NvdDialogBox NvdDialogBox

A type to identify a single dialog box.

Note
You can only use a dialog box once. Reusing it is undefined behavior. Example:
#include <nvdialog/nvdialog.h>
int main(int argc, char** argv) {
nvd_init(argv[0]);
NvdDialogBox *dialog = nvd_dialog_box_new("Hello World!",
"A simple dialog box.",
if (!dialog) return -1;
nvd_show_dialog(dialog);
nvd_free_object(dialog);
return 0;
}
NVD_API void nvd_free_object(void *object)
Deletes an object creates by NvDialog.
NVD_API int nvd_init()
Initializes NvDialog.
struct _NvdDialogBox NvdDialogBox
A type to identify a single dialog box.
Definition nvdialog_dialog_box.h:49
NVD_API void nvd_show_dialog(NvdDialogBox *dialog)
Shows a dialog to the system shell.
NVD_API NvdDialogBox * nvd_dialog_box_new(const char *title, const char *message, NvdDialogType type)
Creates a new dialog object and returns it.
@ NVD_DIALOG_SIMPLE
Definition nvdialog_types.h:42
Since
v0.1.0

◆ NvdQuestionBox

typedef struct _NvdQuestionBox NvdQuestionBox

A similar struct to NvdDialogBox, but instead used for question dialogs.

Since
v0.1.0

Function Documentation

◆ nvd_dialog_box_get_raw()

NVD_API void * nvd_dialog_box_get_raw ( NvdDialogBox * dialog)

Returns the raw object behind the dialog.

Parameters
dialogThe dialog to retrieve the object from.
Returns
void* The raw toolkit-created object.
Warning
On Windows this will always return NULL, as the dialog is created on the spot upon showing it (See MessageBox for details.)

◆ nvd_dialog_box_new()

NVD_API NvdDialogBox * nvd_dialog_box_new ( const char * title,
const char * message,
NvdDialogType type )

Creates a new dialog object and returns it.

This function creates a simple dialog with the specified arguments, and returns an opaque handle to it for use with nvd_show_dialog.

Returns
The dialog handle on success, else NULL.
Since
v0.1.0

◆ nvd_dialog_box_set_accept_text()

NVD_API void nvd_dialog_box_set_accept_text ( NvdDialogBox * dialog,
const char * accept_text )

Sets the accept text for the dialog (The "Ok" button label).

Parameters
dialogThe dialog to change the button label.
accept_textThe new label of the dialog button. May not be NULL.
Warning
This function has no effect on Windows - The system will decide the button's text based on language and user preferences.
Since
v0.8.0

◆ nvd_dialog_question_get_raw()

NVD_API void * nvd_dialog_question_get_raw ( NvdQuestionBox * dialog)

Returns the raw object behind the dialog.

Parameters
dialogThe dialog to retrieve the object from.
Returns
void* The raw toolkit-created object.
Warning
On Windows this will always return NULL, as the dialog is created on the spot upon showing it (See MessageBox for details.)

◆ nvd_dialog_question_new()

NVD_API NvdQuestionBox * nvd_dialog_question_new ( const char * title,
const char * question,
NvdQuestionButton button )

Creates a question dialog box with the given parameters. This function creates a dialog box containing a question with a few buttons such as:

  • Yes / No
  • Yes / No / Cancel
  • Yes / Cancel
Returns
The NvdReply on success, else -1 – Check nvd_get_error for more.
Since
v0.1.1

◆ nvd_get_reply()

NVD_API NvdReply nvd_get_reply ( NvdQuestionBox * box)

Shows the question dialog given to the system and returns the choice given.

Parameters
boxThe box to use to show the reply.
Returns
The reply from the dialog box.

◆ nvd_show_dialog()

NVD_API void nvd_show_dialog ( NvdDialogBox * dialog)

Shows a dialog to the system shell.

The dialog given is rendered to the screen when this function is called. Note that this function works even on headless environments, although it will not produce any result.

Parameters
dialogThe dialog to show.