PIPS
xv_query.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/text.h>
#include "xv_sizes.h"
#include "genC.h"
#include "misc.h"
#include "wpips.h"
+ Include dependency graph for xv_query.c:

Go to the source code of this file.

Functions

void start_query (char *window_title, char *query_title, char *help_topic, success(*ok_func)(char *), void(*cancel_func)(Panel_item, Event *))
 
void query_canvas_event_proc (Xv_Window window, Event *event)
 
void end_query_pad_notify (Panel_item item, Event *event)
 Pour debug seulement : More...
 
void end_query_notify (Panel_item item, Event *event)
 
void help_query_notify (Panel_item item, Event *event)
 
void cancel_query_notify (Panel_item item, Event *event)
 Ne fait rien d'autre que de fermer la fene^tre... More...
 
void cancel_user_request_notify (Panel_item item, Event *event)
 Cancel clear the string value and return: More...
 
success end_user_request_notify (char *the_answer)
 
string wpips_user_request (char *a_printf_format, va_list args)
 
void create_query_window ()
 

Variables

static Panel_item query_pad
 
static Panel_item query_cancel_button
 
static char * query_help_topic
 
static success(* apply_on_query )(char *)
 

Function Documentation

◆ cancel_query_notify()

void cancel_query_notify ( Panel_item  item,
Event *  event 
)

Ne fait rien d'autre que de fermer la fene^tre...

Definition at line 167 of file xv_query.c.

169 {
171 }
GtkWidget * query_frame
Definition: gpips-local.h:42
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
Definition: gtk_utils.c:89

References hide_window(), and query_frame.

+ Here is the call graph for this function:

◆ cancel_user_request_notify()

void cancel_user_request_notify ( Panel_item  item,
Event *  event 
)

Cancel clear the string value and return:

Just return the "":

Definition at line 176 of file xv_query.c.

178 {
179  xv_set(query_pad, PANEL_VALUE, "", NULL);
181  /* Just return the "": */
182  xv_window_return((Xv_opaque) xv_get(query_pad, PANEL_VALUE));
183 }
static Panel_item query_pad
Definition: xv_query.c:44

References hide_window(), query_frame, and query_pad.

Referenced by wpips_user_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_query_window()

void create_query_window ( )

Semble ne servir a` rien. RK, 9/11/93.

WIN_IGNORE_X_EVENT_MASK, KeyReleaseMask,

Definition at line 230 of file xv_query.c.

231 {
232  query_panel = xv_create(query_frame, PANEL, NULL);
233 
234 /* Semble ne servir a` rien. RK, 9/11/93. */
235  xv_set(canvas_paint_window(query_panel),
236  WIN_CONSUME_EVENT, LOC_WINENTER, NULL,
237 /* WIN_IGNORE_X_EVENT_MASK, KeyReleaseMask, */
238  WIN_EVENT_PROC, query_canvas_event_proc,
239  NULL);
240 
241 
242  query_pad = xv_create(query_panel, PANEL_TEXT,
243  PANEL_VALUE_DISPLAY_LENGTH, 20,
244  PANEL_VALUE_STORED_LENGTH, 128,
245  PANEL_NOTIFY_PROC, end_query_notify,
246  NULL);
247 
248  xv_set(query_panel, PANEL_DEFAULT_ITEM,
249  xv_create(query_panel, PANEL_BUTTON,
250  PANEL_LABEL_STRING, " OK ",
251  XV_Y, xv_row(query_panel, 2),
252  XV_X, QUERY_WIDTH/2-100,
253  PANEL_NOTIFY_PROC, end_query_notify,
254  NULL),NULL);
255 
256  (void) xv_create(query_panel, PANEL_BUTTON,
257  PANEL_LABEL_STRING, "Help",
258  PANEL_NOTIFY_PROC, help_query_notify,
259  NULL);
260 
261  query_cancel_button = xv_create(query_panel, PANEL_BUTTON,
262  PANEL_LABEL_STRING, "Cancel",
263  NULL);
264 }
#define QUERY_WIDTH
Definition: gtk_sizes.h:50
Panel query_panel
Definition: wpips-local.h:48
void query_canvas_event_proc(Xv_Window window, Event *event)
Definition: xv_query.c:91
static Panel_item query_cancel_button
Definition: xv_query.c:45
void end_query_notify(Panel_item item, Event *event)
Definition: xv_query.c:134
void help_query_notify(Panel_item item, Event *event)
Definition: xv_query.c:158

References end_query_notify(), help_query_notify(), query_cancel_button, query_canvas_event_proc(), query_frame, query_pad, query_panel, and QUERY_WIDTH.

+ Here is the call graph for this function:

◆ end_query_notify()

void end_query_notify ( Panel_item  item,
Event *  event 
)

Dans le cas ou` on vient d'un retour charriot dans le texte :

Cela ne peut bien entendu pas marcher... :-(

Remet le bouton OK a l'e'tat normal :

xv_set(xv_get(query_panel, PANEL_DEFAULT_ITEM, NULL), PANEL_BUSY, FALSE, NULL);

Definition at line 134 of file xv_query.c.

137 {
138 
139  char *s = (char *) xv_get(query_pad, PANEL_VALUE);
140 
141  /* Dans le cas ou` on vient d'un retour charriot dans le texte : */
142 /* Cela ne peut bien entendu pas marcher... :-( */
143 /*
144  xv_set(xv_get(query_panel, PANEL_DEFAULT_ITEM, NULL),
145  PANEL_BUSY, FALSE,
146  NULL);
147 */
148  if (apply_on_query(s)) {
150  /* Remet le bouton OK a l'e'tat normal : */
151 /* xv_set(xv_get(query_panel, PANEL_DEFAULT_ITEM, NULL),
152  PANEL_BUSY, FALSE,
153  NULL);
154 */
155  }
156 }
static success(* apply_on_query)(char *)
Definition: xv_query.c:48

References apply_on_query, hide_window(), query_frame, and query_pad.

Referenced by create_query_window(), and query_canvas_event_proc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end_query_pad_notify()

void end_query_pad_notify ( Panel_item  item,
Event *  event 
)

Pour debug seulement :

Definition at line 124 of file xv_query.c.

125 {
126  debug_on("WPIPS_EVENT_DEBUG_LEVEL");
127  debug(2,"find_dead_code",
128  "end_query_pad_notify: Event_id %d, event_action %d\n",
129  event_id(event), event_action(event));
130  debug_off();
131 }
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189

References debug(), debug_off, and debug_on.

+ Here is the call graph for this function:

◆ end_user_request_notify()

success end_user_request_notify ( char *  the_answer)

In fact, the function above never return...

Definition at line 187 of file xv_query.c.

188 {
190  xv_window_return((Xv_opaque) the_answer);
191  /* In fact, the function above never return... */
192  return TRUE;
193 }

References hide_window(), and query_frame.

Referenced by wpips_user_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ help_query_notify()

void help_query_notify ( Panel_item  item,
Event *  event 
)

Definition at line 158 of file xv_query.c.

161 {
163 }
void display_help(char *topic)
Definition: gtk_help.c:50
static char * query_help_topic
Definition: xv_query.c:47

References display_help(), and query_help_topic.

Referenced by create_query_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ query_canvas_event_proc()

void query_canvas_event_proc ( Xv_Window  window,
Event *  event 
)

enter_window(window);

ie. return key pressed

ie. key is released. It is necessary to use this event because notice_prompt() (in prompt_user() (in end_query_notify() )) also returns on up RETURN. This can cause the notice to return immediately when it is called on down RETURN. There schould be another possibility: put a mask to ignore key release events on the window which owns notice_prompt(). This was done in create_main_window() but seems without effect.

Definition at line 91 of file xv_query.c.

94 {
95  debug_on("WPIPS_EVENT_DEBUG_LEVEL");
96  debug(2,"query_canvas_event_proc",
97  "Event_id %d, event_action %d\n",
98  event_id(event), event_action(event));
99  debug_off();
100  switch(event_id(event)) {
101  case LOC_WINENTER :
102  /* enter_window(window); */
103  break;
104  case '\r' :
105  /* ie. return key pressed */
106  if (event_is_up(event))
107  /* ie. key is released. It is necessary to use this event
108  because notice_prompt() (in prompt_user() (in
109  end_query_notify() )) also returns on up RETURN.
110  This can cause the notice to return immediately when it is
111  called on down RETURN.
112  There schould be another possibility: put a mask to ignore
113  key release events on the window which owns notice_prompt().
114  This was done in create_main_window() but seems without
115  effect.
116  */
117  end_query_notify(NULL, event);
118  break;
119  default : ;
120  }
121 }

References debug(), debug_off, debug_on, and end_query_notify().

Referenced by create_query_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start_query()

void start_query ( char *  window_title,
char *  query_title,
char *  help_topic,
success(*)(char *)  ok_func,
void(*)(Panel_item, Event *)  cancel_func 
)

PANEL_NOTIFY_PROC, cancel_query_notify,

No cancel button requested:

move the pointer to the center of the query window

Valide le focus sur l'entrée :

J'ai l'impression que le code pre'ce'dent est pluto^t obsole`te... RK.

Mais pourquoi cela ne marche pas ???

xv_set(query_xwindow , WIN_SET_FOCUS, NULL);

Definition at line 51 of file xv_query.c.

56 {
57  xv_set(query_frame, FRAME_LABEL, window_title, NULL);
58  /* PANEL_NOTIFY_PROC, cancel_query_notify, */
59 
60  if (cancel_func == NULL)
61  /* No cancel button requested: */
62  xv_set(query_cancel_button,
63  PANEL_INACTIVE, TRUE,
64  NULL);
65  else
66  xv_set(query_cancel_button, PANEL_NOTIFY_PROC, cancel_func,
67  PANEL_INACTIVE, FALSE,
68  NULL);
69 
70  xv_set(query_pad, PANEL_LABEL_STRING, query_title, NULL);
71 
72  xv_set(query_pad, PANEL_VALUE, "", NULL);
73 
74  query_help_topic = help_topic;
75 
76  apply_on_query = ok_func;
77 
79 
80  /* move the pointer to the center of the query window */
82 
83  /* Valide le focus sur l'entrée : */
84  /* J'ai l'impression que le code pre'ce'dent est pluto^t obsole`te... RK. */
85  /* Mais pourquoi cela ne marche pas ??? */
86  win_set_kbd_focus(query_frame, xv_get(query_panel, XV_XID));
87  /* xv_set(query_xwindow , WIN_SET_FOCUS, NULL); */
88  xv_set(query_panel, PANEL_CARET_ITEM, query_pad, NULL);
89 }
void unhide_window(Frame frame)
map a frame on the screen
Definition: xv_utils.c:55
void pointer_in_center_of_frame(Frame frame)
Centre la souris sur une fene^tre :
Definition: xv_utils.c:64

References apply_on_query, pointer_in_center_of_frame(), query_cancel_button, query_frame, query_help_topic, query_pad, query_panel, and unhide_window().

Referenced by wpips_user_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wpips_user_request()

string wpips_user_request ( char *  a_printf_format,
va_list  args 
)

Loop on the Query window:

Log the answer for possible rerun through tpips:

returns a newly allocated string...

Definition at line 197 of file xv_query.c.

199 {
200  char * the_answer;
201 
202  static char message_buffer[SMALL_BUFFER_LENGTH];
203 
204  (void) vsprintf(message_buffer, a_printf_format, args);
205 
206  start_query("User Query",
207  message_buffer,
208  "UserQuery",
211 
212  user_log("User Request...\n");
213 
214  /* Loop on the Query window: */
215  the_answer = (string) xv_window_loop(query_frame);
216 
217  /* Log the answer for possible rerun through tpips: */
218  user_log("%s\n\"%s\"\nEnd User Request\n",
219  message_buffer, the_answer);
220 
221  /* returns a newly allocated string...
222  */
223  if (the_answer && !string_undefined_p(the_answer))
224  the_answer = strdup(the_answer);
225 
226  return the_answer;
227 }
void user_log(const char *format,...)
Definition: message.c:234
#define SMALL_BUFFER_LENGTH
Definition: gpips-local.h:24
char * string
STRING.
Definition: newgen_types.h:39
#define string_undefined_p(s)
Definition: newgen_types.h:41
char * strdup()
void cancel_user_request_notify(Panel_item item, Event *event)
Cancel clear the string value and return:
Definition: xv_query.c:176
success end_user_request_notify(char *the_answer)
Definition: xv_query.c:187
void start_query(char *window_title, char *query_title, char *help_topic, success(*ok_func)(char *), void(*cancel_func)(Panel_item, Event *))
Definition: xv_query.c:51

References cancel_user_request_notify(), end_user_request_notify(), query_frame, SMALL_BUFFER_LENGTH, start_query(), strdup(), string_undefined_p, and user_log().

Referenced by wpips_main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ apply_on_query

success(* apply_on_query) (char *) ( char *  )
static

Definition at line 48 of file xv_query.c.

Referenced by end_query_notify(), and start_query().

◆ query_cancel_button

Panel_item query_cancel_button
static

Definition at line 45 of file xv_query.c.

Referenced by create_query_window(), and start_query().

◆ query_help_topic

char* query_help_topic
static

Definition at line 47 of file xv_query.c.

Referenced by help_query_notify(), and start_query().

◆ query_pad

Panel_item query_pad
static