root/lib/widget/dialog.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 /*
   2    Dialog box features module for the Midnight Commander
   3  */
   4 
   5 /** \file dialog.h
   6  *  \brief Header: dialog box features module
   7  */
   8 
   9 #ifndef MC__DIALOG_H
  10 #define MC__DIALOG_H
  11 
  12 #include <sys/types.h>          /* size_t */
  13 
  14 #include "lib/global.h"
  15 #include "lib/hook.h"           /* hook_t */
  16 
  17 /*** typedefs(not structures) and defined constants **********************************************/
  18 
  19 #define DIALOG(x) ((WDialog *)(x))
  20 #define CONST_DIALOG(x) ((const WDialog *)(x))
  21 
  22 /* Common return values */
  23 /* ATTENTION: avoid overlapping with FileProgressStatus values */
  24 #define B_EXIT          0
  25 #define B_CANCEL        1
  26 #define B_ENTER         2
  27 #define B_HELP          3
  28 #define B_USER          100
  29 
  30 /*** enums ***************************************************************************************/
  31 
  32 /* Dialog color constants */
  33 typedef enum
  34 {
  35     DLG_COLOR_NORMAL,
  36     DLG_COLOR_FOCUS,
  37     DLG_COLOR_HOT_NORMAL,
  38     DLG_COLOR_HOT_FOCUS,
  39     DLG_COLOR_TITLE,
  40     DLG_COLOR_COUNT
  41 } dlg_colors_enum_t;
  42 
  43 /*** typedefs(not structures) ********************************************************************/
  44 
  45 typedef struct WDialog WDialog;
  46 
  47 /* get string representation of shortcut assigned  with command */
  48 /* as menu is a widget of dialog, ask dialog about shortcut string */
  49 typedef char *(*dlg_shortcut_str) (long command);
  50 
  51 /* get dialog name to show in dialog list */
  52 typedef char *(*dlg_title_str) (const WDialog * h, size_t len);
  53 
  54 typedef int dlg_colors_t[DLG_COLOR_COUNT];
  55 
  56 /*** structures declarations (and typedefs of structures)*****************************************/
  57 
  58 struct WDialog
  59 {
  60     WGroup group;               /* base class */
  61 
  62     /* Set by the user */
  63     gboolean compact;           /* Suppress spaces around the frame */
  64     const char *help_ctx;       /* Name of the help entry */
  65     const int *colors;          /* Color set. Unused in viewer and editor */
  66 
  67     /* Set and received by the user */
  68     int ret_value;              /* Result of dlg_run() */
  69 
  70     /* Internal variables */
  71     void *data;                 /* Data can be passed to dialog */
  72     char *event_group;          /* Name of event group for this dialog */
  73     Widget *bg;                 /* WFrame or WBackground */
  74 
  75     dlg_shortcut_str get_shortcut;      /* Shortcut string */
  76     dlg_title_str get_title;    /* useless for modal dialogs */
  77 };
  78 
  79 /*** global variables defined in .c file *********************************************************/
  80 
  81 /* Color styles for normal and error dialogs */
  82 extern dlg_colors_t dialog_colors;
  83 extern dlg_colors_t alarm_colors;
  84 extern dlg_colors_t listbox_colors;
  85 
  86 extern GList *top_dlg;
  87 
  88 /* A hook list for idle events */
  89 extern hook_t *idle_hook;
  90 
  91 extern gboolean fast_refresh;
  92 extern gboolean mouse_close_dialog;
  93 
  94 extern const global_keymap_t *dialog_map;
  95 
  96 /*** declarations of public functions ************************************************************/
  97 
  98 /* Creates a dialog head  */
  99 WDialog *dlg_create (gboolean modal, int y1, int x1, int lines, int cols,
 100                      widget_pos_flags_t pos_flags, gboolean compact,
 101                      const int *colors, widget_cb_fn callback, widget_mouse_cb_fn mouse_callback,
 102                      const char *help_ctx, const char *title);
 103 
 104 void dlg_set_default_colors (void);
 105 
 106 void dlg_init (WDialog * h);
 107 int dlg_run (WDialog * d);
 108 void dlg_destroy (WDialog * h);
 109 
 110 void dlg_run_done (WDialog * h);
 111 void dlg_save_history (WDialog * h);
 112 void dlg_process_event (WDialog * h, int key, Gpm_Event * event);
 113 
 114 char *dlg_get_title (const WDialog * h, size_t len);
 115 
 116 /* Default callbacks for dialogs */
 117 cb_ret_t dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data);
 118 void dlg_default_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event);
 119 
 120 void dlg_stop (WDialog * h);
 121 
 122 /* Redraw all dialogs */
 123 void do_refresh (void);
 124 
 125 /* --------------------------------------------------------------------------------------------- */
 126 /*** inline functions ****************************************************************************/
 127 /* --------------------------------------------------------------------------------------------- */
 128 
 129 #endif /* MC__DIALOG_H */

/* [previous][next][first][last][top][bottom][index][help]  */