PIPS
xv_frames.c
Go to the documentation of this file.
1 /*
2 
3  $Id: xv_frames.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 #include <stdio.h>
28 
29 #include <sys/time.h>
30 #include <sys/resource.h>
31 #include <xview/xview.h>
32 #include <xview/panel.h>
33 #include <xview/defaults.h>
34 
35 #include "genC.h"
36 #include "misc.h"
37 #include "wpips.h"
38 #include "xv_sizes.h"
39 
40 #define BOUND(x,lb,ub) \
41  ((x)<(lb)) ? (lb) :\
42  ((x)>(ub)) ? (ub) : (x)
43 /*#define MAX(a, b) ((a)>(b) ? (a) : (b))*/
44 
46 
47 
48 void
49 event_procedure(Xv_Window window, Event *event, Notify_arg arg)
50 {
51  debug_on("WPIPS_EVENT_DEBUG_LEVEL");
52  debug(2, "event_procedure",
53  "Event_id %d, event_action %d\n",
54  event_id(event), event_action(event));
55  switch (event_id(event)) {
56  case LOC_WINENTER :
57  win_set_kbd_focus(window, xv_get(window, XV_XID));
58  debug(2, "event_procedure", "LOC_WINENTER\n");
59  break;
60  }
61  debug_off();
62 }
63 
64 
65 void
66 install_event_procedure(Xv_Window window)
67 {
68  xv_set(window,
69  WIN_EVENT_PROC, event_procedure,
70  WIN_CONSUME_EVENTS, LOC_WINENTER, NULL,
71  NULL);
72 }
73 
74 
75 void place_frame(frame, l, t)
76 Frame frame;
77 int l, t;
78 {
79  Rect rect;
80 
81  frame_get_rect(frame, &rect);
82 
83  /* We need to estimate the size of the decor added by the widow
84  manager, Y_WM_DECOR_SIZE & X_WM_DECOR_SIZE. RK, 9/10/1993. */
85  rect.r_top = BOUND(t, 0, MAX(0,display_height-rect.r_height-Y_WM_DECOR_SIZE));
86  rect.r_left = BOUND(l, 0, MAX(0,display_width-rect.r_width-X_WM_DECOR_SIZE));
87 
88  frame_set_rect(frame, &rect);
89 }
90 
92 {
93  int i;
94  Display *dpy;
95  Xv_Screen screen;
96  int screen_no,display_width,display_height;
97 
98  main_frame = xv_create(NULL, FRAME,
99  FRAME_LABEL, "Wpips",
100  /* XV_WIDTH, WPIPS_WIDTH,
101  XV_HEIGHT, WPIPS_HEIGHT,
102  */ NULL);
104 
105 
106  /* get the display dimensions */
107  dpy = (Display *)xv_get(main_frame, XV_DISPLAY);
108  screen = (Xv_Screen)xv_get(main_frame, XV_SCREEN);
109  screen_no = (int)xv_get(screen, SCREEN_NUMBER);
110 
111  display_width = DisplayWidth(dpy, screen_no);
112  display_height = DisplayHeight(dpy, screen_no);
113 
114  log_frame = xv_create(main_frame, FRAME,
115  XV_SHOW, FALSE,
116  FRAME_DONE_PROC, close_log_subwindow,
119  NULL);
121 
122  xv_set(log_frame, FRAME_LABEL, "Pips Log Window", NULL);
123 
124 
125  /* Footers added to edit window.
126  RK, 21/05/1993. */
127  for (i = 0; i < MAX_NUMBER_OF_WPIPS_WINDOWS; i++)
128  edit_frame[i] = xv_create(main_frame, FRAME,
129  XV_SHOW, FALSE,
130  FRAME_DONE_PROC, hide_window,
131  XV_WIDTH, EDIT_WIDTH,
132  XV_HEIGHT, EDIT_HEIGHT,
133  FRAME_SHOW_FOOTER, TRUE,
134  FRAME_LEFT_FOOTER, "<",
135  FRAME_RIGHT_FOOTER, ">",
136  NULL);
137 
138 
139  help_frame = xv_create(main_frame, FRAME,
140  FRAME_LABEL, "Pips On Line Help Facility",
141  XV_SHOW, FALSE,
142  FRAME_DONE_PROC, hide_window,
143  XV_WIDTH, HELP_WIDTH,
144  XV_HEIGHT, HELP_HEIGHT,
145  NULL);
147 
148  mchoose_frame = xv_create(main_frame, FRAME,
149  XV_SHOW, FALSE,
150  FRAME_DONE_PROC, hide_window,
151  NULL);
153 
154  schoose_frame = xv_create(main_frame, FRAME,
155  XV_SHOW, FALSE,
156  FRAME_DONE_PROC, hide_window,
157  NULL);
159 
160  query_frame = xv_create(main_frame, FRAME,
161  XV_SHOW, FALSE,
162  FRAME_DONE_PROC, hide_window,
163  XV_WIDTH, QUERY_WIDTH,
164  XV_HEIGHT, QUERY_HEIGHT,
165  NULL);
167 
168  options_frame = xv_create(main_frame, FRAME,
169  FRAME_LABEL, "Wpips options",
170  XV_SHOW, FALSE,
171  XV_WIDTH, display_width - EDIT_WIDTH -2*X_WM_DECOR_SIZE,
172  FRAME_DONE_PROC, hide_window,
173  NULL);
175 }
176 
178 {
179  Rect rect;
180  int main_l, main_t, main_w, main_h;
181  int main_center_l, main_center_t;
182  int i;
183 
184  Frame full_frame;
185  Xv_Screen screen;
186  Display *dpy;
187  int screen_no;
188 
189  /* get the display dimensions */
190  full_frame = (Frame) xv_create(XV_NULL, FRAME, NULL);
191  dpy = (Display *)xv_get(full_frame, XV_DISPLAY);
192  screen = (Xv_Screen)xv_get(full_frame, XV_SCREEN);
193  screen_no = (int)xv_get(screen, SCREEN_NUMBER);
194  xv_destroy(full_frame);
195 
196  display_width = DisplayWidth(dpy, screen_no);
197  display_height = DisplayHeight(dpy, screen_no);
198 
199  /* warning: some window managers do NOT place the top frame (main_frame)
200  themselves. In this case add this fonction call and modify the call
201  to place_frames().
202 
203  place_frame(main_frame,
204  (display_width-WPIPS_WIDTH)/2,
205  (display_height-WPIPS_HEIGHT)/2);
206  */
207  /* in the bottom left : */
209 
210  frame_get_rect(log_frame, &rect);
211 
212  main_t = rect.r_top;
213  main_w = rect.r_width;
214  main_h = rect.r_height;
215  main_l = rect.r_left;
216 
218  0,
219  main_t - xv_get(main_frame, XV_HEIGHT) - Y_WM_DECOR_SIZE);
220 
221  frame_get_rect(main_frame, &rect);
222 
223  main_t = rect.r_top;
224  main_w = rect.r_width;
225  main_h = rect.r_height;
226  main_l = rect.r_left;
227 
228  main_center_t = main_t+main_h/2;
229  main_center_l = main_l+main_w/2;
230 
231 
232  /* Above the main frame : */
234  0,
235  main_t - xv_get(options_frame, XV_HEIGHT) - Y_WM_DECOR_SIZE);
236 
237  /* in the upper right corner, in the bottom right corner, etc : */
238  for(i = 0; i < MAX_NUMBER_OF_WPIPS_WINDOWS; i++)
239  /* According to the 2 least bits of the window number... */
240  place_frame(edit_frame[i], display_width*(1 - ((i >> 1) & 1)),
241  display_height*(i & 1));
242 
243  /* in the upper */
245  main_l + (main_w - HELP_WIDTH)/2,
246  main_t - HELP_HEIGHT);
247 
248  /* in the upper left corner : */
249  place_frame(mchoose_frame, 0, 0);
250 
251  /* in the upper left corner : */
252  place_frame(schoose_frame, 0, 0);
253 
254  /* in the upper left corner */
256  main_l - QUERY_WIDTH + MIN(main_w, QUERY_WIDTH)/3,
257  main_t - QUERY_HEIGHT - Y_WM_DECOR_SIZE);
258 }
void const char const char const int
#define MIN(x, y)
minimum and maximum if they are defined somewhere else, they are very likely to be defined the same w...
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
Definition: gpips.c:60
GtkWidget * mchoose_frame
Definition: gpips-local.h:42
GtkWidget * help_frame
Definition: gpips-local.h:43
GtkWidget * query_frame
Definition: gpips-local.h:42
void close_log_subwindow(GtkWidget *widget, gpointer data)
Definition: gtk_log.c:172
GtkWidget * options_frame
Definition: gtk_props.c:67
#define EDIT_HEIGHT
#define EDIT_HEIGHT 400
Definition: gtk_sizes.h:35
#define HELP_HEIGHT
Definition: gtk_sizes.h:41
#define QUERY_WIDTH
Definition: gtk_sizes.h:50
#define EDIT_WIDTH
Definition: gtk_sizes.h:33
#define QUERY_HEIGHT
Definition: gtk_sizes.h:49
#define Y_WM_DECOR_SIZE
We need to estimate the size of the decor added by the widow manager, Y_WM_DECOR_SIZE & X_WM_DECOR_SI...
Definition: gtk_sizes.h:27
#define HELP_WIDTH
Definition: gtk_sizes.h:40
#define X_WM_DECOR_SIZE
Definition: gtk_sizes.h:28
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
Definition: gtk_utils.c:89
#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
#define MAX(x, y)
Definition: string.c:110
#define WPIPS_LOG_WINDOW_WIDTH_RESSOURCE_NAME
Here are the X ressource stuff:
Definition: wpips-local.h:100
#define MAX_NUMBER_OF_WPIPS_WINDOWS
How many display wondows can be opened :
Definition: wpips-local.h:30
#define WPIPS_LOG_WINDOW_WIDTH_DEFAULT
Definition: wpips-local.h:102
Frame log_frame
Definition: wpips-local.h:40
Frame schoose_frame
Definition: wpips-local.h:38
#define WPIPS_LOG_WINDOW_WIDTH_RESSOURCE_CLASS
Definition: wpips-local.h:101
#define WPIPS_LOG_WINDOW_HEIGHT_DEFAULT
Definition: wpips-local.h:106
Frame edit_frame[MAX_NUMBER_OF_WPIPS_WINDOWS]
Definition: wpips-local.h:41
#define WPIPS_LOG_WINDOW_HEIGHT_RESSOURCE_CLASS
Definition: wpips-local.h:105
#define WPIPS_LOG_WINDOW_HEIGHT_RESSOURCE_NAME
Definition: wpips-local.h:104
#define BOUND(x, lb, ub)
Definition: xv_frames.c:40
void event_procedure(Xv_Window window, Event *event, Notify_arg arg)
Definition: xv_frames.c:49
void place_frame(Frame frame, int l, int t)
Definition: xv_frames.c:75
void create_frames()
Definition: xv_frames.c:91
static int display_height
Definition: xv_frames.c:45
void install_event_procedure(Xv_Window window)
Definition: xv_frames.c:66
void place_frames()
Definition: xv_frames.c:177
static int display_width
define MAX(a, b) ((a)>(b) ? (a) : (b))
Definition: xv_frames.c:45