6 #define FOCUSC h->color[1]
7 #define NORMALC h->color[0]
8 #define HOT_NORMALC h->color[2]
9 #define HOT_FOCUSC h->color[3]
11 /* Possible directions */
13 #define DIR_BACKWARD 0
15 /* Common return values */
24 WIDGET_INIT
, /* Initialize widget */
25 WIDGET_FOCUS
, /* Draw widget in focused state */
26 WIDGET_UNFOCUS
, /* Draw widget in unfocused state */
27 WIDGET_DRAW
, /* Sent to widget to draw themselves */
28 WIDGET_KEY
, /* Sent to widgets on key press */
29 WIDGET_HOTKEY
, /* Sent to widget to catch preprocess key */
30 WIDGET_DESTROY
, /* Sent to widget at destruction time */
31 WIDGET_CURSOR
, /* Sent to widget to position the cursor */
32 WIDGET_IDLE
, /* Send to widgets with options & W_WANT_IDLE*/
33 WIDGET_USER
= 0x100000
35 } /* Widget_Messages */;
42 /* Widgets are expected to answer to the following messages:
44 WIDGET_FOCUS: 1 if the accept the focus, 0 if they do not.
45 WIDGET_UNFOCUS: 1 if they accept to release the focus, 0 if they don't.
46 WIDGET_KEY: 1 if they actually used the key, 0 if not.
47 WIDGET_HOTKEY: 1 if they actually used the key, 0 if not.
52 DLG_KEY
, /* Sent on keypress before sending to widget */
53 DLG_INIT
, /* Sent on init */
54 DLG_END
, /* Sent on shutdown */
56 DLG_DRAW
, /* Sent for updating dialog managed area */
57 DLG_FOCUS
, /* Sent on give focus to a widget */
58 DLG_UNFOCUS
, /* Sent on remove focus from widget */
59 DLG_ONE_UP
, /* Sent on selecting next */
60 DLG_ONE_DOWN
, /* Sent on selecting prev */
61 DLG_POST_KEY
, /* Sent after key has been sent */
62 DLG_IDLE
, /* Sent if idle is active */
63 DLG_UNHANDLED_KEY
, /* Send if no widget wanted the key */
64 DLG_HOTKEY_HANDLED
, /* Send if a child got the hotkey */
65 DLG_PRE_EVENT
/* Send before calling get_event */
66 } /* Dialog_Messages */;
68 typedef unsigned long widget_data
;
69 typedef struct Dlg_head
{
70 int *color
; /* color set */
71 int count
; /* number of widgets */
75 int mouse_status
; /* For the autorepeat status of the mouse */
77 void *previous_dialog
; /* Pointer to the previously running Dlg_head */
78 int refresh_pushed
; /* Did the dialog actually run? */
81 int x
, y
; /* Position relative to screen origin */
88 char *name
; /* Dialog name Tk code */
91 /* Internal variables */
92 struct Widget_Item
*current
, *first
, *last
;
93 int (*callback
) (struct Dlg_head
*, int, int);
95 struct Widget_Item
*initfocus
;
104 int has_menubar
; /* GrossHack: Send events on row 1 to a menubar? */
105 int raw
; /* Should the tab key be sent to the dialog? */
108 int grided
; /* Does it use the automatic layout? */
111 /* Every Widget must have this as it's first element */
112 typedef struct Widget
{
115 int color
; /* If the widget uses it, the color */
117 int focused
; /* Tells if the widget is focused */
118 int (*callback
)(Dlg_head
*, void *, int, int); /* The callback function */
119 void (*destroy
)(void *);
121 struct Dlg_head
*parent
;
123 widget_data wcontainer
; /* For children of midnight_dlg, identifies
124 * the frame in which they should reside
126 char *frame
; /* Tk version: frame containing it */
127 char *tkname
; /* Tk version: widget name */
133 } area
; /* Used by X platforms, should stay here always because the size
134 of this structure has to be same everywhere :) */
137 /* The options for the widgets */
138 #define W_WANT_POST_KEY 1
139 #define W_WANT_HOTKEY 2
140 #define W_WANT_CURSOR 4
141 #define W_WANT_IDLE 8
142 #define W_IS_INPUT 16
143 #define W_PANEL_HIDDEN 32
145 typedef struct Widget_Item
{
147 struct Widget_Item
*next
; /* next in circle buffer */
148 struct Widget_Item
*prev
; /* previous in circle buffer */
149 Widget
*widget
; /* point to the component */
152 /* draw box in window */
153 void draw_box (Dlg_head
*h
, int y
, int x
, int ys
, int xs
);
155 /* doubled line if possible */
156 void draw_double_box (Dlg_head
*h
, int y
, int x
, int ys
, int xs
);
158 /* Creates a dialog head */
159 Dlg_head
*create_dlg (int y1
, int x1
, int lines
, int cols
,
161 int (*callback
) (struct Dlg_head
*, int, int),
162 char *help_ctx
, char *name
, int flags
);
165 #define DLG_NO_TOPLEVEL 32 /* GNOME only: Do not create a toplevel window, user provides it */
166 #define DLG_GNOME_APP 16 /* GNOME only: use a gnome-app for the toplevel window */
167 #define DLG_NO_TED 8 /* GNOME only: do not manage layout with a GNOME GtkTed widget */
168 #define DLG_GRID 4 /* Widgets should be created under .widgets */
169 #define DLG_TRYUP 2 /* Try to move two lines up the dialog */
170 #define DLG_CENTER 1 /* Center the dialog */
171 #define DLG_NONE 0 /* No options */
172 int add_widget (Dlg_head
*dest
, void *Widget
);
173 int remove_widget (Dlg_head
*dest
, void *Widget
);
174 int destroy_widget (Widget
*w
);
177 void run_dlg (Dlg_head
*d
);
179 void dlg_run_done (Dlg_head
*h
);
180 void dlg_process_event (Dlg_head
*h
, int key
, Gpm_Event
*event
);
181 void init_dlg (Dlg_head
*h
);
183 /* To activate/deactivate the idle message generation */
184 void set_idle_proc (Dlg_head
*d
, int state
);
186 void dlg_redraw (Dlg_head
*h
);
187 void dlg_refresh (void *parameter
);
188 void destroy_dlg (Dlg_head
*h
);
190 void widget_set_size (Widget
*widget
, int x1
, int y1
, int x2
, int y2
);
192 void dlg_broadcast_msg_to (Dlg_head
*h
, int message
, int reverse
, int flags
);
193 void dlg_broadcast_msg (Dlg_head
*h
, int message
, int reverse
);
194 void dlg_mouse (Dlg_head
*h
, Gpm_Event
*event
);
196 typedef void (*destroy_fn
)(void *);
197 typedef int (*callback_fn
)(Dlg_head
*, void *, int, int);
199 void init_widget (Widget
*w
, int y
, int x
, int lines
, int cols
,
200 callback_fn callback
, destroy_fn destroy
,
201 mouse_h mouse_handler
, char *tkname
);
203 /* Various default service provision */
204 int default_dlg_callback (Dlg_head
*h
, int id
, int msg
);
205 int std_callback (Dlg_head
*h
, int Msg
, int Par
);
206 int default_proc (Dlg_head
*h
, int Msg
, int Par
);
208 #define real_widget_move(w, _y, _x) move((w)->y + _y, (w)->x + _x)
209 #define dlg_move(h, _y, _x) move(((Dlg_head *) h)->y + _y, \
210 ((Dlg_head *) h)->x + _x)
212 #define widget_move(w,y,x) real_widget_move((Widget*)w,y,x)
214 extern Dlg_head
*current_dlg
;
216 int send_message (Dlg_head
*h
, Widget
*w
, int msg
, int par
);
217 int send_message_to (Dlg_head
*h
, Widget
*w
, int msg
, int par
);
218 void dlg_replace_widget (Dlg_head
*h
, Widget
*old
, Widget
*new);
219 void widget_redraw (Dlg_head
*h
, Widget_Item
*w
);
220 int dlg_overlap (Widget
*a
, Widget
*b
);
221 void widget_erase (Widget
*);
222 void dlg_erase (Dlg_head
*h
);
223 void dlg_stop (Dlg_head
*h
);
225 /* Widget selection */
226 int dlg_select_widget (Dlg_head
*h
, void *widget
);
227 void dlg_one_up (Dlg_head
*h
);
228 void dlg_one_down (Dlg_head
*h
);
229 int dlg_focus (Dlg_head
*h
);
230 int dlg_unfocus (Dlg_head
*h
);
231 int dlg_select_nth_widget (Dlg_head
*h
, int n
);
232 int dlg_item_number (Dlg_head
*h
);
233 Widget
*find_widget_type (Dlg_head
*h
, callback_fn signature
);
235 /* Sets/clear the specified flag in the options field */
236 #define widget_option(w,f,i) \
237 w.options = ((i) ? (w.options | (f)) : (w.options & (~(f))))
239 #define widget_want_cursor(w,i) widget_option(w, W_WANT_CURSOR, i)
240 #define widget_want_hotkey(w,i) widget_option(w, W_WANT_HOTKEY, i)
241 #define widget_want_postkey(w,i) widget_option(w, W_WANT_POSTKEY, i)
243 typedef void (*movefn
)(void *, int);
245 /* Layout definitions */
247 void x_set_dialog_title (Dlg_head
*h
, const char *title
);
249 /* The inner workings of run_dlg, exported for the Tk and XView toolkits */
250 int dlg_key_event (Dlg_head
*h
, int d_key
);
251 void update_cursor (Dlg_head
*h
);
253 /* FIXME: Remove those functions */
254 #define x_focus_widget(x) {}
255 #define x_unfocus_widget(x) {}
256 #define x_init_dlg(x) {}
257 #define x_destroy_dlg(x) {}
258 #define x_destroy_dlg_start(x) {}
260 #endif /* MC_DLG_H */