mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-08 20:41:59 +03:00
* dlg.h: Define dlg_cb_fn - dialog callback function. Improve
typedefs for callbacks and use them everywhere. Clean up some unused defines. * dlg.c: Adjust declarations for match.
This commit is contained in:
parent
11913b36a2
commit
e3bc0b2b86
@ -1,5 +1,10 @@
|
|||||||
2002-11-12 Pavel Roskin <proski@gnu.org>
|
2002-11-12 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* dlg.h: Define dlg_cb_fn - dialog callback function. Improve
|
||||||
|
typedefs for callbacks and use them everywhere. Clean up some
|
||||||
|
unused defines.
|
||||||
|
* dlg.c: Adjust declarations for match.
|
||||||
|
|
||||||
* wtools.h: Eliminate the_widget filed in QuickWidget.
|
* wtools.h: Eliminate the_widget filed in QuickWidget.
|
||||||
* wtools.c (quick_callback): Allocate widget table dynamically.
|
* wtools.c (quick_callback): Allocate widget table dynamically.
|
||||||
|
|
||||||
|
25
src/dlg.c
25
src/dlg.c
@ -117,21 +117,22 @@ void dlg_erase (Dlg_head *h)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_widget (Widget *w, int y, int x, int lines, int cols,
|
void
|
||||||
int (*callback)(Dlg_head *, void *, int, int),
|
init_widget (Widget *w, int y, int x, int lines, int cols,
|
||||||
destroy_fn destroy, mouse_h mouse_handler, char *tkname)
|
callback_fn callback, destroy_fn destroy,
|
||||||
|
mouse_h mouse_handler, char *tkname)
|
||||||
{
|
{
|
||||||
w->x = x;
|
w->x = x;
|
||||||
w->y = y;
|
w->y = y;
|
||||||
w->cols = cols;
|
w->cols = cols;
|
||||||
w->lines = lines;
|
w->lines = lines;
|
||||||
w->callback = callback;
|
w->callback = callback;
|
||||||
w->destroy = destroy;
|
w->destroy = destroy;
|
||||||
w->mouse = mouse_handler;
|
w->mouse = mouse_handler;
|
||||||
w->parent = 0;
|
w->parent = 0;
|
||||||
w->tkname = tkname;
|
w->tkname = tkname;
|
||||||
|
|
||||||
if (tkname && *tkname == 0){
|
if (tkname && *tkname == 0) {
|
||||||
fprintf (stderr, "Got a null string for the tkname\n");
|
fprintf (stderr, "Got a null string for the tkname\n");
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
@ -209,16 +210,16 @@ int default_dlg_callback (Dlg_head *h, int id, int msg)
|
|||||||
return MSG_NOT_HANDLED;
|
return MSG_NOT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
Dlg_head *
|
||||||
const int *color_set,
|
create_dlg (int y1, int x1, int lines, int cols, const int *color_set,
|
||||||
int (*callback) (struct Dlg_head *, int, int),
|
dlg_cb_fn callback, char *help_ctx, const char *title,
|
||||||
char *help_ctx, const char *title, int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
Dlg_head *new_d;
|
Dlg_head *new_d;
|
||||||
|
|
||||||
if (flags & DLG_CENTER){
|
if (flags & DLG_CENTER) {
|
||||||
y1 = (LINES-lines)/2;
|
y1 = (LINES - lines) / 2;
|
||||||
x1 = (COLS-cols)/2;
|
x1 = (COLS - cols) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & DLG_TRYUP) && (y1 > 3))
|
if ((flags & DLG_TRYUP) && (y1 > 3))
|
||||||
|
24
src/dlg.h
24
src/dlg.h
@ -63,6 +63,10 @@ enum {
|
|||||||
} /* Dialog_Messages */;
|
} /* Dialog_Messages */;
|
||||||
|
|
||||||
|
|
||||||
|
/* Dialog callback */
|
||||||
|
struct Dlg_head;
|
||||||
|
typedef int (*dlg_cb_fn)(struct Dlg_head *h, int Par, int Msg);
|
||||||
|
|
||||||
typedef struct Dlg_head {
|
typedef struct Dlg_head {
|
||||||
|
|
||||||
/* Set by the user */
|
/* Set by the user */
|
||||||
@ -87,32 +91,36 @@ typedef struct Dlg_head {
|
|||||||
/* Internal variables */
|
/* Internal variables */
|
||||||
int count; /* number of widgets */
|
int count; /* number of widgets */
|
||||||
struct Widget_Item *current, *first, *last;
|
struct Widget_Item *current, *first, *last;
|
||||||
int (*callback) (struct Dlg_head *, int, int);
|
dlg_cb_fn callback;
|
||||||
struct Widget_Item *initfocus;
|
struct Widget_Item *initfocus;
|
||||||
void *previous_dialog; /* Pointer to the previously running Dlg_head */
|
void *previous_dialog; /* Pointer to the previously running Dlg_head */
|
||||||
|
|
||||||
} Dlg_head;
|
} Dlg_head;
|
||||||
|
|
||||||
|
|
||||||
|
/* Call when the widget is destroyed */
|
||||||
|
typedef void (*destroy_fn)(void *widget);
|
||||||
|
|
||||||
|
/* Widget callback */
|
||||||
|
typedef int (*callback_fn)(Dlg_head *h, void *widget, int Msg, int Par);
|
||||||
|
|
||||||
/* Every Widget must have this as it's first element */
|
/* Every Widget must have this as it's first element */
|
||||||
typedef struct Widget {
|
typedef struct Widget {
|
||||||
int x, y;
|
int x, y;
|
||||||
int cols, lines;
|
int cols, lines;
|
||||||
int options;
|
int options;
|
||||||
int (*callback)(Dlg_head *, void *, int, int); /* The callback function */
|
callback_fn callback; /* The callback function */
|
||||||
void (*destroy)(void *);
|
destroy_fn destroy;
|
||||||
mouse_h mouse;
|
mouse_h mouse;
|
||||||
struct Dlg_head *parent;
|
struct Dlg_head *parent;
|
||||||
char *tkname; /* name used for history saving */
|
char *tkname; /* name used for history saving */
|
||||||
} Widget;
|
} Widget;
|
||||||
|
|
||||||
/* The options for the widgets */
|
/* The options for the widgets */
|
||||||
#define W_WANT_POST_KEY 1
|
|
||||||
#define W_WANT_HOTKEY 2
|
#define W_WANT_HOTKEY 2
|
||||||
#define W_WANT_CURSOR 4
|
#define W_WANT_CURSOR 4
|
||||||
#define W_WANT_IDLE 8
|
#define W_WANT_IDLE 8
|
||||||
#define W_IS_INPUT 16
|
#define W_IS_INPUT 16
|
||||||
#define W_PANEL_HIDDEN 32
|
|
||||||
|
|
||||||
/* Items in the circular buffer. Each item refers to a widget. */
|
/* Items in the circular buffer. Each item refers to a widget. */
|
||||||
typedef struct Widget_Item {
|
typedef struct Widget_Item {
|
||||||
@ -130,8 +138,7 @@ void draw_double_box (Dlg_head *h, int y, int x, int ys, int xs);
|
|||||||
|
|
||||||
/* Creates a dialog head */
|
/* Creates a dialog head */
|
||||||
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||||
const int *color_set,
|
const int *color_set, dlg_cb_fn callback,
|
||||||
int (*callback) (struct Dlg_head *, int, int),
|
|
||||||
char *help_ctx, const char *title, int flags);
|
char *help_ctx, const char *title, int flags);
|
||||||
|
|
||||||
|
|
||||||
@ -163,9 +170,6 @@ void widget_set_size (Widget *widget, int x1, int y1, int x2, int y2);
|
|||||||
|
|
||||||
void dlg_broadcast_msg (Dlg_head *h, int message, int reverse);
|
void dlg_broadcast_msg (Dlg_head *h, int message, int reverse);
|
||||||
|
|
||||||
typedef void (*destroy_fn)(void *);
|
|
||||||
typedef int (*callback_fn)(Dlg_head *, void *, int, int);
|
|
||||||
|
|
||||||
void init_widget (Widget *w, int y, int x, int lines, int cols,
|
void init_widget (Widget *w, int y, int x, int lines, int cols,
|
||||||
callback_fn callback, destroy_fn destroy,
|
callback_fn callback, destroy_fn destroy,
|
||||||
mouse_h mouse_handler, char *tkname);
|
mouse_h mouse_handler, char *tkname);
|
||||||
|
Loading…
Reference in New Issue
Block a user