mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +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>
|
||||
|
||||
* 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.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,
|
||||
int (*callback)(Dlg_head *, void *, int, int),
|
||||
destroy_fn destroy, mouse_h mouse_handler, char *tkname)
|
||||
void
|
||||
init_widget (Widget *w, int y, int x, int lines, int cols,
|
||||
callback_fn callback, destroy_fn destroy,
|
||||
mouse_h mouse_handler, char *tkname)
|
||||
{
|
||||
w->x = x;
|
||||
w->y = y;
|
||||
w->cols = cols;
|
||||
w->lines = lines;
|
||||
w->callback = callback;
|
||||
w->destroy = destroy;
|
||||
w->destroy = destroy;
|
||||
w->mouse = mouse_handler;
|
||||
w->parent = 0;
|
||||
w->tkname = tkname;
|
||||
|
||||
if (tkname && *tkname == 0){
|
||||
if (tkname && *tkname == 0) {
|
||||
fprintf (stderr, "Got a null string for the tkname\n");
|
||||
abort ();
|
||||
}
|
||||
@ -209,16 +210,16 @@ int default_dlg_callback (Dlg_head *h, int id, int msg)
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||
const int *color_set,
|
||||
int (*callback) (struct Dlg_head *, int, int),
|
||||
char *help_ctx, const char *title, int flags)
|
||||
Dlg_head *
|
||||
create_dlg (int y1, int x1, int lines, int cols, const int *color_set,
|
||||
dlg_cb_fn callback, char *help_ctx, const char *title,
|
||||
int flags)
|
||||
{
|
||||
Dlg_head *new_d;
|
||||
|
||||
if (flags & DLG_CENTER){
|
||||
y1 = (LINES-lines)/2;
|
||||
x1 = (COLS-cols)/2;
|
||||
if (flags & DLG_CENTER) {
|
||||
y1 = (LINES - lines) / 2;
|
||||
x1 = (COLS - cols) / 2;
|
||||
}
|
||||
|
||||
if ((flags & DLG_TRYUP) && (y1 > 3))
|
||||
|
24
src/dlg.h
24
src/dlg.h
@ -63,6 +63,10 @@ enum {
|
||||
} /* Dialog_Messages */;
|
||||
|
||||
|
||||
/* Dialog callback */
|
||||
struct Dlg_head;
|
||||
typedef int (*dlg_cb_fn)(struct Dlg_head *h, int Par, int Msg);
|
||||
|
||||
typedef struct Dlg_head {
|
||||
|
||||
/* Set by the user */
|
||||
@ -87,32 +91,36 @@ typedef struct Dlg_head {
|
||||
/* Internal variables */
|
||||
int count; /* number of widgets */
|
||||
struct Widget_Item *current, *first, *last;
|
||||
int (*callback) (struct Dlg_head *, int, int);
|
||||
dlg_cb_fn callback;
|
||||
struct Widget_Item *initfocus;
|
||||
void *previous_dialog; /* Pointer to the previously running 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 */
|
||||
typedef struct Widget {
|
||||
int x, y;
|
||||
int cols, lines;
|
||||
int options;
|
||||
int (*callback)(Dlg_head *, void *, int, int); /* The callback function */
|
||||
void (*destroy)(void *);
|
||||
callback_fn callback; /* The callback function */
|
||||
destroy_fn destroy;
|
||||
mouse_h mouse;
|
||||
struct Dlg_head *parent;
|
||||
char *tkname; /* name used for history saving */
|
||||
} Widget;
|
||||
|
||||
/* The options for the widgets */
|
||||
#define W_WANT_POST_KEY 1
|
||||
#define W_WANT_HOTKEY 2
|
||||
#define W_WANT_CURSOR 4
|
||||
#define W_WANT_IDLE 8
|
||||
#define W_IS_INPUT 16
|
||||
#define W_PANEL_HIDDEN 32
|
||||
|
||||
/* Items in the circular buffer. Each item refers to a widget. */
|
||||
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 */
|
||||
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||
const int *color_set,
|
||||
int (*callback) (struct Dlg_head *, int, int),
|
||||
const int *color_set, dlg_cb_fn callback,
|
||||
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);
|
||||
|
||||
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,
|
||||
callback_fn callback, destroy_fn destroy,
|
||||
mouse_h mouse_handler, char *tkname);
|
||||
|
Loading…
Reference in New Issue
Block a user