25 #include "pips_config.h"
38 #include <sys/resource.h>
39 #include <xview/xview.h>
40 #include <xview/panel.h>
41 #include <xview/text.h>
77 int item_is_in_the_list;
79 curchoice =
strdup((
char *) xv_get(
choice, PANEL_VALUE, 0));
80 if (strlen(curchoice)==0)
85 nchoices = (
int) xv_get(
choices, PANEL_LIST_NROWS, 0);
86 item_is_in_the_list = FALSE;
87 for(i = 0; i < nchoices; i++)
88 if (strcmp((
char *)xv_get(
choices, PANEL_LIST_STRING, i),
90 item_is_in_the_list = TRUE;
93 if (item_is_in_the_list == FALSE)
94 prompt_user(
"You have to choose one item of the list!");
97 (*apply_on_choice)(curchoice);
114 nchoices = (
int) xv_get(
choices, PANEL_LIST_NROWS, NULL);
118 PANEL_LIST_DELETE_ROWS, 0, nchoices,
121 xv_set(
choice, PANEL_VALUE,
"", NULL);
131 (*apply_on_cancel)();
138 Xv_opaque client_data,
144 case PANEL_LIST_OP_SELECT:
146 PANEL_VALUE, item_string,
151 case PANEL_LIST_OP_DELETE:
152 case PANEL_LIST_OP_VALIDATE:
155 case PANEL_LIST_OP_DESELECT:
159 pips_assert(
"schoose_choice_notify: unknown operation !", 0);
171 (*apply_on_cancel)();
179 char * initial_choice,
180 void (*function_for_ok)(
char *),
181 void (*function_for_cancel)(
void))
193 nchoices = (
int) xv_get(
choices, PANEL_LIST_NROWS, 0);
197 PANEL_LIST_DELETE_ROWS, 0, nchoices,
200 for (i = 0; i < argc; i++) {
202 xv_set(
choices, PANEL_LIST_STRING, i, name, NULL);
207 if (initial_choice != NULL)
209 for (i = 0; i < argc; i++)
212 if (strcmp(initial_choice, name) == 0) {
213 xv_set(
choice, PANEL_VALUE, name, NULL);
214 xv_set(
choices, PANEL_LIST_SELECT, i, TRUE, NULL);
232 void (* real_user_notify_function)(
char *);
234 char *
text = (
char *) xv_get(text_item, PANEL_VALUE);
237 debug(9,
"schoose_abbrev_menu_with_text_text_notify",
"Entering ...\n");
239 real_user_notify_function =
240 (void (*)(
char *)) xv_get(text_item, XV_KEY_DATA,
242 real_user_notify_function(
text);
252 void (* real_user_notify_function)(
char *);
253 char * menu_choice = (
char *) xv_get(menu_item, MENU_STRING);
256 debug(9,
"abbrev_menu_with_text_menu_notify",
"Entering...\n");
258 real_user_notify_function =
259 (void (*)(
char *)) xv_get(menu, MENU_CLIENT_DATA);
261 real_user_notify_function(menu_choice);
271 Notify_event_type
type)
275 Menu (* generate_menu)(void);
278 debug(9,
"abbrev_menu_event_filter_proc",
"Entering ...\n");
281 if (event_is_down(event)) {
283 PANEL_EACH_ITEM(panel, item)
285 rect = (Rect *) xv_get(item, XV_RECT);
286 if (rect_includespoint(rect,
290 (Menu (* )()) xv_get(item,
294 if (generate_menu != NULL) {
297 void (* a_menu_notify_procedure)(Menu, Menu_item);
299 Menu old_menu = (Menu) xv_get(item, PANEL_ITEM_MENU);
301 debug(9,
"abbrev_menu_event_filter_proc",
302 "OK, we clicked on a abbrev_menu_with_text menu.\n");
304 if (old_menu != NULL)
305 xv_destroy(old_menu);
308 new_menu = generate_menu();
310 a_menu_notify_procedure = (void (*)(Menu, Menu_item)) xv_get(new_menu, MENU_NOTIFY_PROC);
324 xv_set(new_menu, MENU_NOTIFY_PROC,
327 debug(9,
"abbrev_menu_event_filter_proc",
328 "Attaching abbrev_menu_with_text_menu_notify...\n");
336 void (* after_selection)(
char *);
338 after_selection = (void (*)(
char *))
348 xv_set(item, PANEL_ITEM_MENU, new_menu);
357 return notify_next_event_func(panel, (Notify_event) event, arg,
type);
367 int value_display_length,
370 Menu (* generate_menu)(
void),
371 void (* after_selection)(
char *))
373 Panel_item item,
text;
375 item = xv_create(
main_panel, PANEL_ABBREV_MENU_BUTTON,
376 PANEL_LABEL_STRING, label_string,
377 PANEL_VALUE_DISPLAY_LENGTH, value_display_length,
378 PANEL_LAYOUT, PANEL_HORIZONTAL,
382 PANEL_ITEM_MENU, xv_create(NULL, MENU,
383 MENU_STRINGS,
"* none *", NULL,
395 PANEL_VALUE_DISPLAY_LENGTH, value_display_length,
396 PANEL_VALUE_STORED_LENGTH, 128,
397 PANEL_READ_ONLY, FALSE,
404 PANEL_VALUE_X,
x + 25,
424 PANEL_LABEL_STRING,
"Current choice",
425 PANEL_VALUE_DISPLAY_LENGTH, 30,
431 PANEL_LABEL_STRING,
"Available choices",
432 PANEL_LIST_DISPLAY_ROWS, 5,
434 PANEL_CHOOSE_ONE, TRUE,
440 PANEL_LABEL_STRING,
"OK",
447 PANEL_LABEL_STRING,
"Cancel",
452 PANEL_LABEL_STRING,
"Help",
void const char const char const int
size_t gen_array_nitems(const gen_array_t a)
void * gen_array_item(const gen_array_t a, size_t i)
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
void display_help(char *topic)
void prompt_user(string a_printf_format,...)
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
struct _newgen_struct_text_ * text
static void schoose_abbrev_menu_with_text_text_notify(Panel_item text_item, Event *event)
Accept only typed text in the menu list:
void schoose_cancel_notify(Panel_item item, Event *event)
@ ABBREV_MENU_WITH_TEXT_GENERATE_MENU
@ ABBREV_MENU_WITH_TEXT_AFTER_SELECTION
static Panel_item choices
void schoose_close()
schoose_close() can be called even when schoose window is already closed.
static void(* apply_on_cancel)(void)
static void abbrev_menu_with_text_menu_notify(Menu menu, Menu_item menu_item)
The function that calls the real user notifying function:
static void(* apply_on_choice)(char *)
void schoose(char *title, gen_array_t array, char *initial_choice, void(*function_for_ok)(char *), void(*function_for_cancel)(void))
static int schoose_choice_notify(Panel_item item, char *item_string, Xv_opaque client_data, Panel_list_op op, Event *event, int row)
Function used to update the text panel according to the list panel:
static void schoose_ok_notify(Panel_item item, Event *event)
Cette routine est appelé d'une part lorsqu'on a cliqué sur OK pour valider un nom tapé textuellement,...
static void schoose_help_notify(Panel_item item, Event *event)
Panel_item schoose_create_abbrev_menu_with_text(Panel main_panel, char *label_string, int value_display_length, int x, int y, Menu(*generate_menu)(void), void(*after_selection)(char *))
Create an abbreviation menu attached with a text item.
void create_schoose_window()
static Notify_value abbrev_menu_event_filter_proc(Panel panel, Event *event, Notify_arg arg, Notify_event_type type)
static void schoose_frame_done_proc(Frame frame)
Avoid the schoose_frame destruction and act as cancel:
void unhide_window(Frame frame)
map a frame on the screen
void pointer_in_center_of_frame(Frame frame)
Centre la souris sur une fene^tre :