ELinks 0.18.0
dialog.h File Reference
#include "bfu/style.h"
#include "bfu/widget.h"
#include "main/timer.h"
#include "terminal/terminal.h"
#include "terminal/window.h"
#include "util/memlist.h"
Include dependency graph for dialog.h:

Data Structures

struct  dialog_layout
 
struct  dialog_refresh
 
struct  dialog
 
struct  dialog_data
 

Macros

#define sizeof_dialog(n, add_size)    (sizeof(struct dialog) + ((n) - 1) * sizeof(struct widget) + (add_size))
 Gets the amount of memory needed for a dialog.
 
#define calloc_dialog(n, add_size)   ((struct dialog *) mem_calloc(1, sizeof_dialog(n, add_size)))
 Allocates and clears memory for a dialog.
 
#define get_dialog_offset(dlg, n)    (((char *) dlg) + sizeof_dialog(n, 0))
 Gets the address of the additional data of a dialog.
 
#define dialog_has_refresh(dlg_data)    ((dlg_data)->dlg->refresh && (dlg_data)->dlg->refresh->timer != TIMER_ID_UNDEF)
 
#define selected_widget(dlg_data)   (&(dlg_data)->widgets_data[(dlg_data)->selected_widget_id])
 
#define before_widgets(dlg_data)   (&(dlg_data)->widgets_data[-1])
 
#define end_of_widgets(dlg_data)   (&(dlg_data)->widgets_data[(dlg_data)->number_of_widgets])
 
#define first_widget(dlg_data)   (&(dlg_data)->widgets_data[0])
 
#define last_widget(dlg_data)   (&(dlg_data)->widgets_data[(dlg_data)->number_of_widgets - 1])
 
#define foreach_widget(dlg_data, widget_data)
 
#define foreach_widget_back(dlg_data, widget_data)
 
#define is_selected_widget(dlg_data, widget_data)   ((widget_data) == selected_widget(dlg_data))
 
#define add_dlg_end(dlg, n)
 

Typedefs

typedef enum dlg_refresh_code(* dialog_refresh_handler_T) (struct dialog_data *, void *)
 

Enumerations

enum  dlg_refresh_code { REFRESH_DIALOG , REFRESH_CANCEL , REFRESH_NONE , REFRESH_STOP }
 

Functions

static int dialog_max_width (struct terminal *term)
 
static int dialog_max_height (struct terminal *term)
 
struct dialog_datado_dialog (struct terminal *, struct dialog *, struct memory_list *)
 
void draw_dialog (struct dialog_data *dlg_data, int width, int height)
 
void redraw_dialog (struct dialog_data *dlg_data, int layout)
 
widget_handler_status_T ok_dialog (struct dialog_data *, struct widget_data *)
 
widget_handler_status_T cancel_dialog (struct dialog_data *, struct widget_data *)
 
widget_handler_status_T clear_dialog (struct dialog_data *, struct widget_data *)
 
int check_dialog (struct dialog_data *)
 
int update_dialog_data (struct dialog_data *)
 
void generic_dialog_layouter (struct dialog_data *dlg_data)
 
void refresh_dialog (struct dialog_data *, dialog_refresh_handler_T handler, void *data)
 
void select_widget (struct dialog_data *dlg_data, struct widget_data *widget_data)
 
struct widget_dataselect_widget_by_id (struct dialog_data *dlg_data, int i)
 

Macro Definition Documentation

◆ add_dlg_end

#define add_dlg_end ( dlg,
n )
Value:
do { \
if (0 && (n)); \
assert(n == (dlg)->number_of_widgets); \
} while (0)
int n
Definition general.c:868

◆ before_widgets

#define before_widgets ( dlg_data)    (&(dlg_data)->widgets_data[-1])

◆ calloc_dialog

#define calloc_dialog ( n,
add_size )   ((struct dialog *) mem_calloc(1, sizeof_dialog(n, add_size)))

Allocates and clears memory for a dialog.

Parameters
nHow many widgets there will be in the dialog.
add_sizeThe size of the additional data, in bytes.
Returns
struct dialog *; or NULL if out of memory.

This macro sets dialog.number_of_widgets = 0. The caller can then add widgets to the dialog until dialog.number_of_widgets reaches n.

◆ dialog_has_refresh

#define dialog_has_refresh ( dlg_data)     ((dlg_data)->dlg->refresh && (dlg_data)->dlg->refresh->timer != TIMER_ID_UNDEF)

◆ end_of_widgets

#define end_of_widgets ( dlg_data)    (&(dlg_data)->widgets_data[(dlg_data)->number_of_widgets])

◆ first_widget

#define first_widget ( dlg_data)    (&(dlg_data)->widgets_data[0])

◆ foreach_widget

#define foreach_widget ( dlg_data,
widget_data )
Value:
for ((widget_data) = first_widget(dlg_data); \
(widget_data) != end_of_widgets(dlg_data); \
#define end_of_widgets(dlg_data)
Definition dialog.h:207
#define first_widget(dlg_data)
Definition dialog.h:208
Definition widget.h:56

◆ foreach_widget_back

#define foreach_widget_back ( dlg_data,
widget_data )
Value:
for ((widget_data) = last_widget(dlg_data); \
(widget_data) != before_widgets(dlg_data); \
#define last_widget(dlg_data)
Definition dialog.h:209
#define before_widgets(dlg_data)
Definition dialog.h:206

◆ get_dialog_offset

#define get_dialog_offset ( dlg,
n )    (((char *) dlg) + sizeof_dialog(n, 0))

Gets the address of the additional data of a dialog.

Parameters
dlgstruct dialog *dlg; the dialog that carries the additional data.
nFor how many widgets the dialog was allocated; i.e. the n parameter of sizeof_dialog() and calloc_dialog(). This macro does not read dialog.number_of_widgets because that is typically still zero when this macro is used.
Returns
The address of the additional data.

◆ is_selected_widget

#define is_selected_widget ( dlg_data,
widget_data )   ((widget_data) == selected_widget(dlg_data))

◆ last_widget

#define last_widget ( dlg_data)    (&(dlg_data)->widgets_data[(dlg_data)->number_of_widgets - 1])

◆ selected_widget

#define selected_widget ( dlg_data)    (&(dlg_data)->widgets_data[(dlg_data)->selected_widget_id])

◆ sizeof_dialog

#define sizeof_dialog ( n,
add_size )    (sizeof(struct dialog) + ((n) - 1) * sizeof(struct widget) + (add_size))

Gets the amount of memory needed for a dialog.

Parameters
nHow many widgets there will be in the dialog.
add_sizeThe size of the additional data, in bytes.
Returns
The total amount of memory needed for struct dialog, the widgets, and the additional data. This however does not include struct dialog_data.

struct dialog already reserves memory for one widget.

Typedef Documentation

◆ dialog_refresh_handler_T

typedef enum dlg_refresh_code(* dialog_refresh_handler_T) (struct dialog_data *, void *)

Enumeration Type Documentation

◆ dlg_refresh_code

Enumerator
REFRESH_DIALOG 
REFRESH_CANCEL 
REFRESH_NONE 
REFRESH_STOP 

Function Documentation

◆ cancel_dialog()

widget_handler_status_T cancel_dialog ( struct dialog_data * dlg_data,
struct widget_data * xxx )

◆ check_dialog()

int check_dialog ( struct dialog_data * dlg_data)

◆ clear_dialog()

widget_handler_status_T clear_dialog ( struct dialog_data * dlg_data,
struct widget_data * xxx )

◆ dialog_max_height()

static int dialog_max_height ( struct terminal * term)
inlinestatic

◆ dialog_max_width()

static int dialog_max_width ( struct terminal * term)
inlinestatic

◆ do_dialog()

struct dialog_data * do_dialog ( struct terminal * term,
struct dialog * dlg,
struct memory_list * ml )

◆ draw_dialog()

void draw_dialog ( struct dialog_data * dlg_data,
int width,
int height )

◆ generic_dialog_layouter()

void generic_dialog_layouter ( struct dialog_data * dlg_data)

◆ ok_dialog()

widget_handler_status_T ok_dialog ( struct dialog_data * dlg_data,
struct widget_data * widget_data )

◆ redraw_dialog()

void redraw_dialog ( struct dialog_data * dlg_data,
int layout )

◆ refresh_dialog()

void refresh_dialog ( struct dialog_data * dlg_data,
dialog_refresh_handler_T handler,
void * data )

◆ select_widget()

void select_widget ( struct dialog_data * dlg_data,
struct widget_data * widget_data )

◆ select_widget_by_id()

struct widget_data * select_widget_by_id ( struct dialog_data * dlg_data,
int i )

◆ update_dialog_data()

int update_dialog_data ( struct dialog_data * dlg_data)