ARB
AW_window.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : AW_window.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include "aw_at.hxx"
12 #include "aw_nawar.hxx"
13 #include "aw_xfig.hxx"
14 #include "aw_Xm.hxx"
15 #include "aw_window.hxx"
16 #include "aw_window_Xm.hxx"
17 #include "aw_xkey.hxx"
18 #include "aw_select.hxx"
19 #include "aw_awar.hxx"
20 #include "aw_msg.hxx"
21 #include "aw_root.hxx"
22 #include "aw_xargs.hxx"
23 #include "aw_device_click.hxx"
24 #include "aw_localdef.hxx"
25 
26 #include <arbdbt.h>
27 #include <arb_file.h>
28 #include <arb_str.h>
29 #include <arb_strarray.h>
30 
31 #include <X11/Shell.h>
32 #include <Xm/AtomMgr.h>
33 #include <Xm/Frame.h>
34 #include <Xm/PushB.h>
35 #include <Xm/Protocols.h>
36 #include <Xm/RowColumn.h>
37 #include <Xm/DrawingA.h>
38 #include <Xm/Form.h>
39 #include <Xm/Separator.h>
40 #include <Xm/MainW.h>
41 #include <Xm/CascadeB.h>
42 #include <Xm/MenuShell.h>
43 #include <Xm/ScrollBar.h>
44 #include <Xm/MwmUtil.h>
45 
46 #include "aw_question.hxx"
47 
48 #include <cctype>
49 #include <map>
50 #include <string>
51 
52 void AW_POPDOWN(AW_window *window){
53  window->hide();
54 }
55 
61 #if defined(DEBUG)
62 #define NOWINWARN() fputs("window factory did not create a window\n", stderr)
63 #else
64 #define NOWINWARN()
65 #endif
66 
67 #if defined(DEBUG)
68 // #define TRACE_WM_OFFSETS
69 #endif
70 
71 static AW_window *find_or_createAndRegisterWindow(CreateWindowCallback *windowMaker) {
72  typedef std::map<CreateWindowCallback, AW_window*> window_map;
73 
74  static window_map window; // previously popped up windows
75  CreateWindowCallback& maker = *windowMaker;
76 
77  if (window.find(maker) == window.end()) {
78  AW_window *made = maker(AW_root::SINGLETON);
79  if (!made) { NOWINWARN(); return NULp; }
80 
81  window[maker] = made;
82  }
83  return window[maker];
84 }
85 
86 void AW_window::popper(AW_window *, CreateWindowCallback *windowMaker) {
87  AW_window *toPopup = find_or_createAndRegisterWindow(windowMaker);
88  if (toPopup) toPopup->activate();
89 }
90 void AW_window::replacer(AW_window *caller, CreateWindowCallback *windowMaker) {
91  AW_window *toPopup = find_or_createAndRegisterWindow(windowMaker);
92  if (toPopup) {
93  toPopup->activate();
94  caller->hide();
95  }
96 }
97 void AW_window::destroyCreateWindowCallback(CreateWindowCallback *windowMaker) {
98  delete windowMaker;
99 }
100 
101 
102 void AW_window::label(const char *_label) {
103  aw_assert(_label); // cannot clear label with this method (consider using unset_at_commands)
104  aw_assert(_label[0]); // empty labels not supported
105  aw_assert(_at->label_for_inputfield == NULp); // you are overwriting an existing label (probably by mistake or wrong design)
106  freedup(_at->label_for_inputfield, _label);
107 }
108 
109 void AW_window::get_window_size(int &width, int &height){
110  unsigned short hoffset = 0;
111  if (p_w->menu_bar[0]) XtVaGetValues(p_w->menu_bar[0], XmNheight, &hoffset, NULp);
112  width = _at->max_x_size;
113  height = hoffset + _at->max_y_size;
114 }
115 
116 void AW_window::help_text(const char *id) {
118  delete _at->helptext_for_next_button; // @@@ delete/free mismatch
119  _at->helptext_for_next_button = strdup(id);
120 }
121 
124  _at->highlight = true;
125 }
126 
129  aw_assert(legal_mask(mask));
130  _at->widget_mask = mask;
131 }
132 
133 void AW_window::callback(const WindowCallback& wcb) {
138  _callback = new AW_cb(this, wcb);
139 }
140 
141 void AW_window::d_callback(const WindowCallback& wcb) {
146  _d_callback = new AW_cb(this, wcb);
147 }
148 
149 // -------------------------------------------------------------
150 // code used by scalers
151 
152 static float apply_ScalerType(float val, AW_ScalerType scalerType, bool inverse) {
153  float res = 0.0;
154 
155  aw_assert(val>=0.0 && val<=1.0);
156 
157  switch (scalerType) {
158  case AW_SCALER_LINEAR:
159  res = val;
160  break;
161 
162  case AW_SCALER_EXP_LOWER:
163  if (inverse) res = pow(val, 1/3.0);
164  else res = pow(val, 3.0);
165  break;
166 
167  case AW_SCALER_EXP_UPPER:
168  res = 1.0-apply_ScalerType(1.0-val, AW_SCALER_EXP_LOWER, inverse);
169  break;
170 
172  inverse = !inverse;
173  // fall-through
174  case AW_SCALER_EXP_CENTER: {
176  if (val>0.5) res = (1+apply_ScalerType(2*val-1, subType, false))/2;
177  else if (val<0.5) res = (1-apply_ScalerType(1-2*val, subType, false))/2;
178  else res = val;
179  break;
180  }
181  }
182 
183  aw_assert(res>=0.0 && res<=1.0);
184 
185  return res;
186 }
187 
188 float AW_ScalerTransformer::scaler2awar(float scaler, AW_awar *awar) {
189  float amin = awar->get_min();
190  float amax = awar->get_max();
191  float modScaleRel = apply_ScalerType(scaler, type, false);
192  float aval = amin + modScaleRel*(amax-amin);
193 
194  return aval;
195 }
196 
198  float amin = awar->get_min();
199  float amax = awar->get_max();
200 
201  float awarRel = 0.0;
202  switch (awar->variable_type) {
203  case AW_FLOAT:
204  awarRel = (awar->read_float()-amin) / (amax-amin);
205  break;
206 
207  case AW_INT:
208  awarRel = (awar->read_int()-amin) / (amax-amin);
209  break;
210 
211  default:
212  GBK_terminatef("Unsupported awar type %i in calculate_scaler_value", int(awar->variable_type));
213  break;
214  }
215 
216  aw_assert(awarRel>=0.0 && awarRel<=1.0);
217 
218  return apply_ScalerType(awarRel, type, true);
219 }
220 
221 static unsigned timed_window_title_cb(AW_root*, char *title, AW_window *aw) {
224  aw->set_window_title_intern(title);
225  }
226 
227  delete title;
228  return 0; // do not recall
229 }
230 
231 void AW_window::message(char *title, int ms) {
232  char *old_title = NULp;
233 
235 
236  old_title = strdup(window_name);
237 
238  XtVaSetValues(p_w->shell, XmNtitle, title, NULp);
239 
240  get_root()->add_timed_callback(ms, makeTimedCallback(timed_window_title_cb, old_title, this));
241 }
242 
243 // -------------------------
244 // Hotkey Checking
245 
246 #if defined(DEBUG)
247 #define CHECK_DUPLICATED_MNEMONICS
248 #endif
249 
250 #ifdef CHECK_DUPLICATED_MNEMONICS
251 
252 inline char oppositeCase(char c) {
253  return isupper(c) ? tolower(c) : toupper(c);
254 }
255 static void strcpy_overlapping(char *dest, char *src) {
256  int src_len = strlen(src);
257  memmove(dest, src, src_len+1);
258 }
259 static const char *possible_mnemonics(const char *used_mnemonics, bool top_level, const char *topic_name) {
260  static char *unused;
261  for (int fromTopic = 1; fromTopic>=0; --fromTopic) {
262  freedup(unused, fromTopic ? topic_name : "abcdefghijklmnopqrstuvwxyz");
263 
264  for (int t = 0; unused[t]; ++t) {
265  bool remove = false;
266  if ((top_level && !isalpha(unused[t])) || !isalnum(unused[t])) { // remove useless chars
267  remove = true;
268  }
269  else {
270  char *dup = strchr(unused, unused[t]);
271  if (dup && (dup-unused)<t) { // remove duplicated chars
272  remove = true;
273  }
274  else {
275  dup = strchr(unused, oppositeCase(unused[t]));
276  if (dup && (dup-unused)<t) { // char is duplicated with opposite case
277  dup[0] = toupper(dup[0]); // prefer upper case
278  remove = true;
279  }
280  }
281  }
282  if (remove) {
283  strcpy_overlapping(unused+t, unused+t+1);
284  --t;
285  }
286  }
287 
288  for (int t = 0; used_mnemonics[t]; ++t) {
289  char c = used_mnemonics[t]; // upper case!
290  char *u = strchr(unused, c);
291  if (u) strcpy_overlapping(u, u+1); // remove char
292  u = strchr(unused, tolower(c));
293  if (u) strcpy_overlapping(u, u+1); // remove char
294  }
295 
296  if (unused[0]) {
297  if (!fromTopic) {
298  freeset(unused, GBS_global_string_copy("unused but not in topic: \"%s\"", unused));
299  }
300  break;
301  }
302  }
303  return unused;
304 }
305 
306 class MnemonicScope : virtual Noncopyable {
307  typedef std::map<char,std::string> Char2Topic;
308 
309  std::string name; // of menu or window
310  MnemonicScope *parent;
311  StrArray requested; // topics lacking sufficient mnemonic
312  Char2Topic accepted; // accepted mnemonics (key = uppercase hotkey, value=topic)
313 
314  void print_at_menu(FILE *out) {
315  if (parent) {
316  parent->print_at_menu(out);
317  fputc('|', out);
318  }
319  fputs(name.c_str(), out);
320  }
321  void print_at_location(FILE *out, const char *topic) {
322  fputs(" (", out);
323  print_at_menu(out);
324  fprintf(out, "|%s)\n", topic);
325  }
326 
327  void requestPossibilities(const char *topic_name) {
328  // will be shown delayed (when menu closes)
329  if (requested.index_of(topic_name) == -1) { // avoid duplicates
330  requested.put(strdup(topic_name));
331  }
332  }
333 
334  void showRequestedPossibilities() {
335  unsigned size = accepted.size();
336  char *used = new char[size+1];
337 
338  int i = 0;
339  for (Char2Topic::iterator a = accepted.begin(); a != accepted.end(); ++a) {
340  used[i++] = a->first;
341  }
342  used[size] = 0;
343 
344  for (i = 0; requested[i]; ++i) {
345  const char *possible = possible_mnemonics(used, !parent, requested[i]);
346  fprintf(stderr, "Warning: Possible mnemonics for '%s': '%s'\n", requested[i], possible);
347  }
348 
349  delete [] used;
350  }
351 
352  void warn_mnemonic(const char *topic_name, const char *mnemonic, const char *warning) {
353  fprintf(stderr, "Warning: mnemonic '%s' %s", mnemonic, warning);
354  print_at_location(stderr, topic_name);
355  }
356 
357 public:
358 
359  MnemonicScope(const char *name_, MnemonicScope *parent_)
360  : name(name_),
361  parent(parent_)
362  {}
363 
364  ~MnemonicScope() {
365  showRequestedPossibilities();
366  }
367 
368  void add(const char *topic_name, const char *mnemonic);
369 
370  MnemonicScope *get_parent() { return parent; }
371 };
372 
373 static MnemonicScope *current_mscope = NULp;
374 static MnemonicScope *help_mscope = NULp;
375 
376 void MnemonicScope::add(const char *topic_name, const char *mnemonic) {
377  if (mnemonic && mnemonic[0] != 0) {
378  if (mnemonic[1]) { // longer than 1 char -> wrong
379  warn_mnemonic(topic_name, mnemonic, "is too long; only 1 character allowed");
380  }
381 
382  if (AW_IS_IMAGEREF(topic_name)) {
383  if (mnemonic[0]) {
384  warn_mnemonic(topic_name, mnemonic, "is useless for graphical menu entry");
385  }
386  }
387  else if (!isalpha(mnemonic[0]) && !get_parent()) { // do not allow top-level numeric mnemonics
388  warn_mnemonic(topic_name, mnemonic, "is invalid (allowed: a-z)");
389  requestPossibilities(topic_name);
390  }
391  else if (!isalnum(mnemonic[0])) {
392  warn_mnemonic(topic_name, mnemonic, "is invalid (allowed: a-z and 0-9)");
393  requestPossibilities(topic_name);
394  }
395  else {
396  char *TOPIC_NAME = ARB_strupper(strdup(topic_name));
397  char HOTKEY = toupper(mnemonic[0]); // store hotkeys case-less (case does not matter when pressing the hotkey)
398 
399  if (strchr(TOPIC_NAME, HOTKEY)) { // occurs in menu text
400  Char2Topic::iterator found = accepted.find(HOTKEY);
401 
402  if (found != accepted.end()) {
403  warn_mnemonic(topic_name, mnemonic, "is used multiple times");
404  requestPossibilities(topic_name);
405  requestPossibilities(found->second.c_str()); // show possibilities for accepted duplicate
406  }
407  else {
408  accepted[HOTKEY] = topic_name;
409 
410  if (!strchr(topic_name, mnemonic[0])) {
411  char *warning = GBS_global_string_copy("has wrong case, use '%c'", HOTKEY == mnemonic[0] ? tolower(HOTKEY) : HOTKEY);
412  warn_mnemonic(topic_name, mnemonic, warning);
413  free(warning);
414  }
415  }
416  }
417  else {
418  warn_mnemonic(topic_name, mnemonic, "is useless; does not occur in text");
419  requestPossibilities(topic_name);
420  }
421  free(TOPIC_NAME);
422  }
423  }
424  else {
425  if (!AW_IS_IMAGEREF(topic_name)) {
426  fputs("Warning: mnemonic is missing", stderr);
427  print_at_location(stderr, topic_name);
428  requestPossibilities(topic_name);
429  }
430  }
431 }
432 
433 static void open_test_duplicate_mnemonics(const char *sub_menu_name, const char *mnemonic) {
434  aw_assert(current_mscope);
435  current_mscope->add(sub_menu_name, mnemonic);
436 
437  MnemonicScope *prev = current_mscope;
438  current_mscope = new MnemonicScope(sub_menu_name, prev);
439 }
440 
441 static void close_test_duplicate_mnemonics() {
442  MnemonicScope *prev = current_mscope->get_parent();
443  delete current_mscope;
444  current_mscope = prev;
445 }
446 
447 static void init_duplicate_mnemonic(const char *window_name) {
448  if (!current_mscope) {
449  current_mscope = new MnemonicScope(window_name, NULp);
450  help_mscope = new MnemonicScope("<HELP>", current_mscope);
451  }
452  else {
453  while (current_mscope->get_parent()) {
454  close_test_duplicate_mnemonics();
455  }
456  }
457 }
458 
459 static void test_duplicate_mnemonics(const char *topic_name, const char *mnemonic) {
460  aw_assert(current_mscope);
461  current_mscope->add(topic_name, mnemonic);
462 }
463 
464 static void exit_duplicate_mnemonic() {
465  delete help_mscope; help_mscope = NULp;
466  while (current_mscope) close_test_duplicate_mnemonics();
467 }
468 
469 
470 #endif
471 
472 void AW_window::create_menu(AW_label name, const char *mnemonic, AW_active mask) {
473  aw_assert(legal_mask(mask));
474  p_w->menu_deep = 0;
475 
476 #ifdef CHECK_DUPLICATED_MNEMONICS
477  init_duplicate_mnemonic(window_name);
478 #endif
479 
480 #if defined(DUMP_MENU_LIST)
481  dumpCloseAllSubMenus();
482 #endif // DUMP_MENU_LIST
483  insert_sub_menu(name, mnemonic, mask);
484 }
485 
491 #ifdef CHECK_DUPLICATED_MNEMONICS
492  close_test_duplicate_mnemonics();
493 #endif
494 #if defined(DUMP_MENU_LIST)
495  dumpCloseSubMenu();
496 #endif // DUMP_MENU_LIST
497  if (p_w->menu_deep>0)
498  p_w->menu_deep--;
499 }
500 
501 void AW_window::all_menus_created() const { // this is called by AW_window::show() (i.e. after all menus have been created)
502 #if defined(DEBUG)
503  if (p_w->menu_deep>0) { // window had menu
504  aw_assert(p_w->menu_deep == 1);
505 #ifdef CHECK_DUPLICATED_MNEMONICS
506  exit_duplicate_mnemonic(); // cleanup mnemonic check
507 #endif
508  }
509 #endif // DEBUG
510 }
511 
512 void AW_window::draw_line(int x1, int y1, int x2, int y2, int width, bool resize) {
513  aw_assert(xfig_data); // forgot to call load_xfig ?
514 
515  xfig_data->add_line(x1, y1, x2, y2, width);
516 
517  _at->max_x_size = std::max(_at->max_x_size, xfig_data->maxx - xfig_data->minx);
518  _at->max_y_size = std::max(_at->max_y_size, xfig_data->maxy - xfig_data->miny);
519 
520  if (resize) {
522  set_window_size(WIDER_THAN_SCREEN, HIGHER_THAN_SCREEN);
523  }
524 }
525 
526 AW_device_click *AW_window::get_click_device(AW_area area, int mousex, int mousey, int max_distance) {
527  AW_area_management *aram = MAP_ARAM(area);
528  AW_device_click *click_device = NULp;
529 
530  if (aram) {
531  click_device = aram->get_click_device();
532  click_device->init_click(AW::Position(mousex, mousey), max_distance, AW_ALL_DEVICES);
533  }
534  return click_device;
535 }
536 
537 AW_device *AW_window::get_device(AW_area area) { // @@@ rename to get_screen_device
538  AW_area_management *aram = MAP_ARAM(area);
539  arb_assert(aram);
540  return aram->get_screen_device();
541 }
542 
543 void AW_window::get_event(AW_event *eventi) const {
544  *eventi = event;
545 }
546 
547 AW_device_print *AW_window::get_print_device(AW_area area) {
548  AW_area_management *aram = MAP_ARAM(area);
549  return aram ? aram->get_print_device() : NULp;
550 }
551 
553  AW_area_management *aram = MAP_ARAM(area);
554  if (!aram) return NULp;
555 
556  AW_device_size *size_device = aram->get_size_device();
557  if (size_device) {
558  size_device->restart_tracking();
559  size_device->reset(); // @@@ hm
560  }
561  return size_device;
562 }
563 
565  AW_area_management *aram = MAP_ARAM(area);
566  return aram ? aram->get_common() : NULp;
567 }
568 
569 void AW_window::insert_help_topic(const char *labeli,
570  const char *mnemonic, const char *helpText,
571  AW_active mask, const WindowCallback& cb) {
572  aw_assert(legal_mask(mask));
573  Widget button;
574 
575 #ifdef CHECK_DUPLICATED_MNEMONICS
576  if (!current_mscope) init_duplicate_mnemonic(window_name);
577  MnemonicScope *tmp = current_mscope;
578  current_mscope = help_mscope;
579  test_duplicate_mnemonics(labeli, mnemonic);
580  current_mscope = tmp;
581 #endif
582 
583  // insert one help-sub-menu-entry
584  button = XtVaCreateManagedWidget("", xmPushButtonWidgetClass,
586  RES_CONVERT(XmNlabelString, labeli),
587  RES_CONVERT(XmNmnemonic, mnemonic), NULp);
588  XtAddCallback(button, XmNactivateCallback,
589  (XtCallbackProc) AW_server_callback,
590  (XtPointer) new AW_cb(this, cb, helpText));
591 
592  root->make_sensitive(button, mask);
593 }
594 
595 void AW_window::insert_menu_topic(const char *topic_id, const char *labeltext,
596  const char *mnemonic, const char *helpText,
597  AW_active mask, const WindowCallback& wcb) {
598  aw_assert(legal_mask(mask));
599  Widget button;
600 
601  TuneBackground(p_w->menu_bar[p_w->menu_deep], TUNE_MENUTOPIC); // set background color for normal menu topics
602 
603 #if defined(DUMP_MENU_LIST)
604  dumpMenuEntry(name);
605 #endif // DUMP_MENU_LIST
606 
607 #ifdef CHECK_DUPLICATED_MNEMONICS
608  test_duplicate_mnemonics(labeltext, mnemonic);
609 #endif
610 
611  Label topiclabel(labeltext, this);
612  if (mnemonic && *mnemonic && strchr(labeltext, mnemonic[0])) {
613  // create one sub-menu-point
614  button = XtVaCreateManagedWidget("", xmPushButtonWidgetClass,
616  RES_LABEL_CONVERT(topiclabel),
617  RES_CONVERT(XmNmnemonic, mnemonic),
618  XmNbackground, _at->background_color, NULp);
619  }
620  else {
621  button = XtVaCreateManagedWidget("",
622  xmPushButtonWidgetClass,
624  RES_LABEL_CONVERT(topiclabel),
625  XmNbackground, _at->background_color,
626  NULp);
627  }
628 
629  AW_label_in_awar_list(this, button, labeltext);
630  AW_cb *cbs = new AW_cb(this, wcb, helpText);
631  XtAddCallback(button, XmNactivateCallback,
632  (XtCallbackProc) AW_server_callback,
633  (XtPointer) cbs);
634 
635 #if defined(DEVEL_RALF) // wanted version
636  aw_assert(topic_id);
637 #else // !defined(DEVEL_RALF)
638  if (!topic_id) topic_id = labeltext;
639 #endif
640  cbs->id = strdup(topic_id);
642  root->make_sensitive(button, mask);
643 }
644 
645 void AW_window::insert_sub_menu(const char *labeli, const char *mnemonic, AW_active mask){
646  aw_assert(legal_mask(mask));
647  Widget shell, Label;
648 
649  TuneBackground(p_w->menu_bar[p_w->menu_deep], TUNE_SUBMENU); // set background color for submenus
650  // (Note: This must even be called if TUNE_SUBMENU is 0!
651  // Otherwise several submenus get the TUNE_MENUTOPIC color)
652 
653 #if defined(DUMP_MENU_LIST)
654  dumpOpenSubMenu(name);
655 #endif // DUMP_MENU_LIST
656 
657 #ifdef CHECK_DUPLICATED_MNEMONICS
658  open_test_duplicate_mnemonics(labeli, mnemonic);
659 #endif
660 
661  // create shell for Pull-Down
662  shell = XtVaCreatePopupShell("menu_shell", xmMenuShellWidgetClass,
664  XmNwidth, 1,
665  XmNheight, 1,
666  XmNallowShellResize, true,
667  XmNoverrideRedirect, true,
668  NULp);
669 
670  // create row column in Pull-Down shell
671 
672  p_w->menu_bar[p_w->menu_deep+1] = XtVaCreateWidget("menu_row_column",
673  xmRowColumnWidgetClass, shell,
674  XmNrowColumnType, XmMENU_PULLDOWN,
675  XmNtearOffModel, XmTEAR_OFF_ENABLED,
676  NULp);
677 
678  // create label in menu bar
679  if (mnemonic && *mnemonic && strchr(labeli, mnemonic[0])) {
680  // if mnemonic is "" -> Cannot convert string "" to type KeySym
681  Label = XtVaCreateManagedWidget("menu1_top_b1",
682  xmCascadeButtonWidgetClass, p_w->menu_bar[p_w->menu_deep],
683  RES_CONVERT(XmNlabelString, labeli),
684  RES_CONVERT(XmNmnemonic, mnemonic),
685  XmNsubMenuId, p_w->menu_bar[p_w->menu_deep+1],
686  XmNbackground, _at->background_color, NULp);
687  }
688  else {
689  Label = XtVaCreateManagedWidget("menu1_top_b1",
690  xmCascadeButtonWidgetClass,
692  RES_CONVERT(XmNlabelString, labeli),
693  XmNsubMenuId, p_w->menu_bar[p_w->menu_deep+1],
694  XmNbackground, _at->background_color,
695  NULp);
696  }
697 
699 
700  root->make_sensitive(Label, mask);
701 }
702 
703 static void AW_xfigCB_info_area(AW_window *aww, AW_xfig *xfig) {
704  AW_device *device = aww->get_device(AW_INFO_AREA);
705  device->reset();
706 
707  if (aww->get_root()->color_mode == 0) { // mono colr
708  device->clear(-1);
709  }
710  device->set_offset(AW::Vector(-xfig->minx, -xfig->miny));
711 
712  xfig->print(device);
713 }
714 
715 void AW_window::get_font_size(int& width, int& height) {
716  width = get_root()->font_width;
717  height = get_root()->font_height;
718 }
719 
720 void AW_window::load_xfig(const char *file, bool resize /*= true*/) {
721  int width, height;
722  get_font_size(width, height);
723 
724  if (file) xfig_data = new AW_xfig(file, width, height);
725  else xfig_data = new AW_xfig(width, height); // create an empty xfig
726 
727  xfig_data->create_gcs(get_device(AW_INFO_AREA), get_root()->color_mode ? 8 : 1);
728 
729  // @@@ move into AW_at::set_xfig
730  int xsize = xfig_data->maxx - xfig_data->minx;
731  int ysize = xfig_data->maxy - xfig_data->miny;
732  if (xsize>_at->max_x_size) _at->max_x_size = xsize;
733  if (ysize>_at->max_y_size) _at->max_y_size = ysize;
734 
735  if (resize) {
737  set_window_size(WIDER_THAN_SCREEN, HIGHER_THAN_SCREEN);
738  }
739 
740  set_expose_callback(AW_INFO_AREA, makeWindowCallback(AW_xfigCB_info_area, xfig_data));
741 }
742 
747 const char *AW_window::local_id(const char *id) const {
748  static char *last_local_id = NULp;
749  freeset(last_local_id, GBS_global_string_copy("%s/%s", get_window_id(), id));
750  return last_local_id;
751 }
752 
755  XtVaCreateManagedWidget("", xmSeparatorWidgetClass,
757  NULp);
758 }
759 
765 void AW_window::set_expose_callback(AW_area area, const WindowCallback& wcb) {
766  AW_area_management *aram = MAP_ARAM(area);
767  if (aram) aram->set_expose_callback(this, wcb);
768 }
769 
770 static void AW_focusCB(Widget /*wgt*/, XtPointer cl_aww, XEvent*, Boolean*) {
771  AW_window *aww = (AW_window*)cl_aww;
772  aww->run_focus_callback();
773 }
774 
778 void AW_window::set_focus_callback(const WindowCallback& wcb) {
779  if (!focus_cb) {
780  XtAddEventHandler(MIDDLE_WIDGET, EnterWindowMask, FALSE, AW_focusCB, (XtPointer) this);
781  }
782 
783  if (!is_focus_callback(AnyWinCB(wcb.callee()))) {
784  focus_cb = new AW_cb(this, wcb, NULp, focus_cb);
785  }
786 }
787 
792 void AW_window::set_popup_callback(const WindowCallback& wcb) {
793  p_w->popup_cb = new AW_cb(this, wcb, NULp, p_w->popup_cb);
794 }
795 
797  XtVaSetValues(INFO_WIDGET, XmNheight, h, NULp);
798  XtVaSetValues(p_w->frame, XmNtopOffset, h, NULp);
799 }
800 
802  XtVaSetValues(BOTTOM_WIDGET, XmNheight, h, NULp);
803  XtVaSetValues(p_w->scroll_bar_horizontal, XmNbottomOffset, (int)h, NULp);
804 }
805 
806 void AW_window::set_input_callback(AW_area area, const WindowCallback& wcb) {
807  AW_area_management *aram = MAP_ARAM(area);
808  if (aram) aram->set_input_callback(this, wcb);
809 }
810 
811 void AW_window::set_motion_callback(AW_area area, const WindowCallback& wcb) {
812  AW_area_management *aram = MAP_ARAM(area);
813  if (aram) aram->set_motion_callback(this, wcb);
814 }
815 
816 void AW_window::set_resize_callback(AW_area area, const WindowCallback& wcb) {
817  AW_area_management *aram = MAP_ARAM(area);
818  if (aram) aram->set_resize_callback(this, wcb);
819 }
820 
821 // SCROLL BAR STUFF
822 
824  picture->l = rectangle.l;
825  picture->r = rectangle.r;
826  picture->t = rectangle.t;
827  picture->b = rectangle.b;
828 }
829 
831  picture->l = (int)rectangle.l;
832  picture->r = (int)rectangle.r;
833  picture->t = (int)rectangle.t;
834  picture->b = (int)rectangle.b;
835 }
836 
838  return picture->r - picture->l;
839 }
840 
842  return picture->b - picture->t;
843 }
844 
846  picture->l = 0;
847  picture->r = 0;
848  picture->t = 0;
849  picture->b = 0;
850 }
851 
853  XtVaSetValues(p_w->scroll_bar_vertical, XmNtopOffset, (int)indent, NULp);
854  top_indent_of_vertical_scrollbar = indent;
855 }
856 
858  XtVaSetValues(p_w->scroll_bar_horizontal, XmNleftOffset, (int)indent, NULp);
859  left_indent_of_horizontal_scrollbar = indent;
860 }
861 
863  AW_area_management *aram = MAP_ARAM(area);
864  *square = aram->get_common()->get_screen();
865 }
866 
869  square->r -= left_indent_of_horizontal_scrollbar;
870  square->b -= top_indent_of_vertical_scrollbar;
871 }
872 
874  AW_screen_area scrollArea;
875  get_scrollarea_size(&scrollArea);
876 
877  // HORIZONTAL
878  {
879  int slider_max = (int)get_scrolled_picture_width();
880  if (slider_max <1) {
881  slider_max = 1;
882  XtVaSetValues(p_w->scroll_bar_horizontal, XmNsliderSize, 1, NULp);
883  }
884 
885  bool use_horizontal_bar = true;
886  int slider_size_horizontal = scrollArea.r;
887 
888  if (slider_size_horizontal < 1) slider_size_horizontal = 1; // ist der slider zu klein (<1) ?
889  if (slider_size_horizontal > slider_max) { // Schirm groesser als Bild
890  slider_size_horizontal = slider_max; // slider nimmt ganze laenge ein
891  XtVaSetValues(p_w->scroll_bar_horizontal, XmNvalue, 0, NULp); // slider ganz links setzen
892  use_horizontal_bar = false; // kein horizontaler slider mehr
893  }
894 
895  // check wether XmNValue is to big
896  int position_of_slider;
897  XtVaGetValues(p_w->scroll_bar_horizontal, XmNvalue, &position_of_slider, NULp);
898  if (position_of_slider > (slider_max-slider_size_horizontal)) { // steht der slider fuer slidergroesse zu rechts ?
899  position_of_slider = slider_max-slider_size_horizontal; // -1 ? vielleicht !
900  if (position_of_slider < 0) position_of_slider = 0;
901  XtVaSetValues(p_w->scroll_bar_horizontal, XmNvalue, position_of_slider, NULp);
902  }
903  // Anpassung fuer resize, wenn unbeschriebener Bereich vergroessert wird
904  int max_slider_pos = (int)(get_scrolled_picture_width() - scrollArea.r);
905  if (slider_pos_horizontal>max_slider_pos) {
906  slider_pos_horizontal = use_horizontal_bar ? max_slider_pos : 0;
907  }
908 
909  XtVaSetValues(p_w->scroll_bar_horizontal, XmNsliderSize, 1, NULp);
910  XtVaSetValues(p_w->scroll_bar_horizontal, XmNmaximum, slider_max, NULp);
911  XtVaSetValues(p_w->scroll_bar_horizontal, XmNsliderSize, slider_size_horizontal, NULp);
912 
914  }
915 
916  // VERTICAL
917  {
918  int slider_max = (int)get_scrolled_picture_height();
919  if (slider_max <1) {
920  slider_max = 1;
921  XtVaSetValues(p_w->scroll_bar_vertical, XmNsliderSize, 1, NULp);
922  }
923 
924  bool use_vertical_bar = true;
925  int slider_size_vertical = scrollArea.b;
926 
927  if (slider_size_vertical < 1) slider_size_vertical = 1;
928  if (slider_size_vertical > slider_max) {
929  slider_size_vertical = slider_max;
930  XtVaSetValues(p_w->scroll_bar_vertical, XmNvalue, 0, NULp);
931  use_vertical_bar = false;
932  }
933 
934  // check wether XmNValue is to big
935  int position_of_slider;
936  XtVaGetValues(p_w->scroll_bar_vertical, XmNvalue, &position_of_slider, NULp);
937  if (position_of_slider > (slider_max-slider_size_vertical)) {
938  position_of_slider = slider_max-slider_size_vertical; // -1 ? vielleicht !
939  if (position_of_slider < 0) position_of_slider = 0;
940  XtVaSetValues(p_w->scroll_bar_vertical, XmNvalue, position_of_slider, NULp);
941  }
942  // Anpassung fuer resize, wenn unbeschriebener Bereich vergroessert wird
943  int max_slider_pos = (int)(get_scrolled_picture_height() - scrollArea.b);
944  if (slider_pos_vertical>max_slider_pos) {
945  slider_pos_vertical = use_vertical_bar ? max_slider_pos : 0;
946  }
947 
948  XtVaSetValues(p_w->scroll_bar_vertical, XmNsliderSize, 1, NULp);
949  XtVaSetValues(p_w->scroll_bar_vertical, XmNmaximum, slider_max, NULp);
950  XtVaSetValues(p_w->scroll_bar_vertical, XmNsliderSize, slider_size_vertical, NULp);
951 
953  }
954 }
955 
958 }
959 
962 }
963 
964 const char *AW_window::window_local_awarname(const char *localname, bool tmp) {
965  CONSTEXPR int MAXNAMELEN = 200;
966  static char buffer[MAXNAMELEN];
967  return GBS_global_string_to_buffer(buffer, MAXNAMELEN,
968  tmp ? "tmp/window/%s/%s" : "window/%s/%s",
969  window_defaults_name, localname);
970  // (see also aw_size_awar_name)
971 }
972 
973 AW_awar *AW_window::window_local_awar(const char *localname, bool tmp) {
974  return get_root()->awar(window_local_awarname(localname, tmp));
975 }
976 
978  RootCallback hor_src = makeRootCallback(horizontal_scrollbar_redefinition_cb, this);
979  RootCallback ver_src = makeRootCallback(vertical_scrollbar_redefinition_cb, this);
980 
981  get_root()->awar_int(window_local_awarname("horizontal_page_increment"), 50)->add_callback(hor_src);
982  get_root()->awar_int(window_local_awarname("vertical_page_increment"), 50)->add_callback(ver_src);
983  get_root()->awar_int(window_local_awarname("scroll_width_horizontal"), 9)->add_callback(hor_src);
984  get_root()->awar_int(window_local_awarname("scroll_width_vertical"), 20)->add_callback(ver_src);
985  get_root()->awar_int(window_local_awarname("scroll_delay_horizontal"), 20)->add_callback(hor_src);
986  get_root()->awar_int(window_local_awarname("scroll_delay_vertical"), 20)->add_callback(ver_src);
987 }
988 
990 #if defined(DEBUG) && 0
991  fprintf(stderr, "set_vertical_scrollbar_position to %i\n", position);
992 #endif
993  // @@@ test and constrain against limits
994  slider_pos_vertical = position;
995  XtVaSetValues(p_w->scroll_bar_vertical, XmNvalue, position, NULp);
996 }
997 
999 #if defined(DEBUG) && 0
1000  fprintf(stderr, "set_horizontal_scrollbar_position to %i\n", position);
1001 #endif
1002  // @@@ test and constrain against limits
1003  slider_pos_horizontal = position;
1004  XtVaSetValues(p_w->scroll_bar_horizontal, XmNvalue, position, NULp);
1005 }
1006 
1007 static void value_changed_scroll_bar_vertical(Widget /*wgt*/, XtPointer aw_cb_struct, XtPointer call_data) {
1008  XmScrollBarCallbackStruct *sbcbs = (XmScrollBarCallbackStruct *)call_data;
1009  AW_cb *cbs = (AW_cb *) aw_cb_struct;
1010  cbs->aw->slider_pos_vertical = sbcbs->value; // setzt Scrollwerte im AW_window
1011  cbs->run_callbacks();
1012 }
1013 static void value_changed_scroll_bar_horizontal(Widget /*wgt*/, XtPointer aw_cb_struct, XtPointer call_data) {
1014  XmScrollBarCallbackStruct *sbcbs = (XmScrollBarCallbackStruct *)call_data;
1015  AW_cb *cbs = (AW_cb *) aw_cb_struct;
1016  (cbs->aw)->slider_pos_horizontal = sbcbs->value; // setzt Scrollwerte im AW_window
1017  cbs->run_callbacks();
1018 }
1019 
1020 static void drag_scroll_bar_vertical(Widget /*wgt*/, XtPointer aw_cb_struct, XtPointer call_data) {
1021  XmScrollBarCallbackStruct *sbcbs = (XmScrollBarCallbackStruct *)call_data;
1022  AW_cb *cbs = (AW_cb *) aw_cb_struct;
1023  cbs->aw->slider_pos_vertical = sbcbs->value; // setzt Scrollwerte im AW_window
1024  cbs->run_callbacks();
1025 }
1026 static void drag_scroll_bar_horizontal(Widget /*wgt*/, XtPointer aw_cb_struct, XtPointer call_data) {
1027  XmScrollBarCallbackStruct *sbcbs = (XmScrollBarCallbackStruct *)call_data;
1028  AW_cb *cbs = (AW_cb *) aw_cb_struct;
1029  (cbs->aw)->slider_pos_horizontal = sbcbs->value; // setzt Scrollwerte im AW_window
1030  cbs->run_callbacks();
1031 }
1032 
1033 void AW_window::set_vertical_change_callback(const WindowCallback& wcb) {
1034  XtAddCallback(p_w->scroll_bar_vertical, XmNvalueChangedCallback,
1035  (XtCallbackProc) value_changed_scroll_bar_vertical,
1036  (XtPointer) new AW_cb(this, wcb, ""));
1037  XtAddCallback(p_w->scroll_bar_vertical, XmNdragCallback,
1038  (XtCallbackProc) drag_scroll_bar_vertical,
1039  (XtPointer) new AW_cb(this, wcb, ""));
1040 
1041  XtAddCallback(p_w->scroll_bar_vertical, XmNpageIncrementCallback,
1042  (XtCallbackProc) drag_scroll_bar_vertical,
1043  (XtPointer) new AW_cb(this, wcb, ""));
1044  XtAddCallback(p_w->scroll_bar_vertical, XmNpageDecrementCallback,
1045  (XtCallbackProc) drag_scroll_bar_vertical,
1046  (XtPointer) new AW_cb(this, wcb, ""));
1047 }
1048 
1049 void AW_window::set_horizontal_change_callback(const WindowCallback& wcb) {
1050  XtAddCallback(p_w->scroll_bar_horizontal, XmNvalueChangedCallback,
1051  (XtCallbackProc) value_changed_scroll_bar_horizontal,
1052  (XtPointer) new AW_cb(this, wcb, ""));
1053  XtAddCallback(p_w->scroll_bar_horizontal, XmNdragCallback,
1054  (XtCallbackProc) drag_scroll_bar_horizontal,
1055  (XtPointer) new AW_cb(this, wcb, ""));
1056 }
1057 
1058 // END SCROLLBAR STUFF
1059 
1060 
1061 void AW_window::set_window_size(int width, int height) {
1062  XtVaSetValues(p_w->shell, XmNwidth, (int)width, XmNheight, (int)height, NULp);
1063 }
1064 
1066  XtVaSetValues(p_w->shell, XmNtitle, title, NULp);
1067 }
1068 
1070  XtVaSetValues(p_w->shell, XmNtitle, title, NULp);
1071  freedup(window_name, title);
1072 }
1073 
1074 const char* AW_window::get_window_title() const {
1075  return window_name;
1076 }
1077 
1078 void AW_window::shadow_width(int shadow_thickness) {
1079  _at->shadow_thickness = shadow_thickness;
1080 }
1081 
1082 void AW_window::button_height(int height) {
1083  _at->height_of_buttons = height>1 ? height : 0;
1084 }
1085 
1087  int width, height;
1088  get_window_size(width, height);
1089  set_window_size(width, height);
1090 }
1091 
1093  : recalc_size_at_show(AW_KEEP_SIZE),
1094  recalc_pos_at_show(AW_KEEP_POS),
1095  hide_cb(NULp),
1096  expose_callback_added(false),
1097  focus_cb(NULp),
1098  xfig_data(NULp),
1099  _at(new AW_at),
1100  left_indent_of_horizontal_scrollbar(0),
1101  top_indent_of_vertical_scrollbar(0),
1102  root(NULp),
1103  click_time(0),
1104  color_table_size(0),
1105  color_table(NULp),
1106  number_of_timed_title_changes(0),
1107  p_w(new AW_window_Motif),
1108  _callback(NULp),
1109  _d_callback(NULp),
1110  window_name(NULp),
1111  window_defaults_name(NULp),
1112  slider_pos_vertical(0),
1113  slider_pos_horizontal(0),
1114  window_is_shown(false),
1115  picture(new AW_screen_area)
1116 {
1118 }
1119 
1121  delete picture;
1122  delete p_w;
1123  delete hide_cb;
1124 }
1125 
1126 #if defined(DEBUG)
1127 // #define DUMP_MENU_LIST // this should NOT be defined normally (if defined, every window writes all menu-entries to stdout)
1128 #endif // DEBUG
1129 #if defined(DUMP_MENU_LIST)
1130 
1131 static char *window_name = 0;
1132 static char *sub_menu = 0;
1133 
1134 static void initMenuListing(const char *win_name) {
1135  aw_assert(win_name);
1136 
1137  freedup(window_name, win_name);
1138  freenull(sub_menu);
1139 
1140  printf("---------------------------------------- list of menus for '%s'\n", window_name);
1141 }
1142 
1143 static void dumpMenuEntry(const char *entry) {
1144  aw_assert(window_name);
1145  if (sub_menu) {
1146  printf("'%s/%s/%s'\n", window_name, sub_menu, entry);
1147  }
1148  else {
1149  printf("'%s/%s'\n", window_name, entry);
1150  }
1151 }
1152 
1153 static void dumpOpenSubMenu(const char *sub_name) {
1154  aw_assert(sub_name);
1155 
1156  dumpMenuEntry(sub_name); // dump the menu itself
1157 
1158  if (sub_menu) freeset(sub_menu, GBS_global_string_copy("%s/%s", sub_menu, sub_name));
1159  else sub_menu = strdup(sub_name);
1160 }
1161 
1162 static void dumpCloseSubMenu() {
1163  aw_assert(sub_menu);
1164  char *lslash = strrchr(sub_menu, '/');
1165  if (lslash) {
1166  lslash[0] = 0;
1167  }
1168  else freenull(sub_menu);
1169 }
1170 
1171 static void dumpCloseAllSubMenus() {
1172  freenull(sub_menu);
1173 }
1174 
1175 #endif // DUMP_MENU_LIST
1176 
1177 AW_window_menu_modes::AW_window_menu_modes() : AW_window_menu_modes_private(NULp) {}
1179 
1182 
1183 AW_window_simple::AW_window_simple() {}
1184 AW_window_simple::~AW_window_simple() {}
1185 
1188 
1191 
1192 #define LAYOUT_AWAR_ROOT "window/windows"
1193 #define BUFSIZE 256
1195 static const char *aw_size_awar_name(AW_window *aww, const char *sub_entry) {
1196 #if defined(DEBUG)
1197  int size =
1198 #endif // DEBUG
1199  sprintf(aw_size_awar_name_buffer, LAYOUT_AWAR_ROOT "/%s/%s",
1200  aww->window_defaults_name, sub_entry);
1201 #if defined(DEBUG)
1202  aw_assert(size < BUFSIZE);
1203 #endif // DEBUG
1204  return aw_size_awar_name_buffer;
1205  // (see also AW_window::window_local_awarname)
1206 }
1207 #undef BUFSIZE
1208 
1209 #define aw_awar_name_posx(aww) aw_size_awar_name((aww), "posx")
1210 #define aw_awar_name_posy(aww) aw_size_awar_name((aww), "posy")
1211 #define aw_awar_name_width(aww) aw_size_awar_name((aww), "width")
1212 #define aw_awar_name_height(aww) aw_size_awar_name((aww), "height")
1213 
1214 void AW_window::create_user_geometry_awars(int posx, int posy, int width, int height) {
1215  get_root()->awar_int(aw_awar_name_posx(this), posx);
1216  get_root()->awar_int(aw_awar_name_posy(this), posy);
1217  get_root()->awar_int(aw_awar_name_width(this), width);
1218  get_root()->awar_int(aw_awar_name_height(this), height);
1219 }
1220 
1221 
1222 void AW_window::store_size_in_awars(int width, int height) {
1223  get_root()->awar(aw_awar_name_width(this))->write_int(width);
1224  get_root()->awar(aw_awar_name_height(this))->write_int(height);
1225 }
1226 
1227 void AW_window::get_size_from_awars(int& width, int& height) {
1228  width = get_root()->awar(aw_awar_name_width(this))->read_int();
1229  height = get_root()->awar(aw_awar_name_height(this))->read_int();
1230 }
1231 
1232 void AW_window::store_pos_in_awars(int posx, int posy) {
1233  get_root()->awar(aw_awar_name_posx(this))->write_int(posx);
1234  get_root()->awar(aw_awar_name_posy(this))->write_int(posy);
1235 }
1236 
1237 void AW_window::get_pos_from_awars(int& posx, int& posy) {
1238  posx = get_root()->awar(aw_awar_name_posx(this))->read_int();
1239  posy = get_root()->awar(aw_awar_name_posy(this))->read_int();
1240 }
1241 
1242 void AW_window::reset_geometry_awars() {
1243  AW_root *awr = get_root();
1244 
1249 
1252 }
1253 
1254 #undef aw_awar_name_posx
1255 #undef aw_awar_name_posy
1256 #undef aw_awar_name_width
1257 #undef aw_awar_name_height
1258 
1259 static void aw_onExpose_calc_WM_offsets(AW_window *aww);
1261 
1263  AW_window_Motif *motif = p_aww(aww);
1264 
1265  int posx, posy; aww->get_window_content_pos(posx, posy);
1266 
1267  bool knows_window_position = posx != 0 || posy != 0;
1268 
1269  if (!knows_window_position) { // oops - motif has no idea where the window has been placed
1270  // assume positions stored in awars are correct and use them.
1271  // This works around problems with unclickable GUI-elements when running on 'Unity'
1272 
1273  int oposx, oposy; aww->get_pos_from_awars(oposx, oposy);
1274  aww->set_window_frame_pos(oposx, oposy);
1275 
1276  if (!motif->knows_WM_offset()) {
1277  aww->get_root()->add_timed_callback(100, makeTimedCallback(aw_calc_WM_offsets_delayed, aww));
1278  }
1279  }
1280  else if (!motif->knows_WM_offset()) {
1281  int oposx, oposy; aww->get_pos_from_awars(oposx, oposy);
1282 
1283  // calculate offset
1284  int left = posx-oposx;
1285  int top = posy-oposy;
1286 
1287  if (top == 0 || left == 0) { // invalid frame size
1288  if (motif->WM_left_offset == 0) {
1289  motif->WM_left_offset = 1; // hack: unused yet, use as flag to avoid endless repeats
1290 #if defined(TRACE_WM_OFFSETS)
1291  fprintf(stderr, "aw_onExpose_calc_WM_offsets: failed to detect framesize (shift window 1 pixel and retry)\n");
1292 #endif
1293  oposx = oposx>10 ? oposx-1 : oposx+1;
1294  oposy = oposy>10 ? oposy-1 : oposy+1;
1295 
1296  aww->set_window_frame_pos(oposx, oposy);
1297  aww->store_pos_in_awars(oposx, oposy);
1298 
1299  aww->get_root()->add_timed_callback(500, makeTimedCallback(aw_calc_WM_offsets_delayed, aww));
1300  return;
1301  }
1302  else {
1303  // use maximum seen frame size
1306 
1307  if (top == 0 || left == 0) { // still invalid -> retry later
1308  aww->get_root()->add_timed_callback(10000, makeTimedCallback(aw_calc_WM_offsets_delayed, aww));
1309  return;
1310  }
1311  }
1312  }
1313  motif->WM_top_offset = top;
1314  motif->WM_left_offset = left;
1315 
1316  // remember maximum seen offsets
1319 
1320 #if defined(TRACE_WM_OFFSETS)
1321  fprintf(stderr, "WM_top_offset=%i WM_left_offset=%i (pos from awar: %i/%i, content-pos: %i/%i)\n",
1322  motif->WM_top_offset, motif->WM_left_offset,
1323  oposx, oposy, posx, posy);
1324 #endif
1325  }
1326 }
1327 
1329  : last_widget(NULp),
1330  display(NULp),
1331  context(NULp),
1332  toplevel_widget(NULp),
1333  main_widget(NULp),
1334  main_aww(NULp),
1335  message_shell(NULp),
1336  foreground(0),
1337  background(0),
1338  fontlist(NULp),
1339  option_menu_list(NULp),
1340  last_option_menu(NULp),
1341  current_option_menu(NULp),
1342  toggle_field_list(NULp),
1343  last_toggle_field(NULp),
1344  selection_list(NULp),
1345  last_selection_list(NULp),
1346  screen_depth(0),
1347  color_table(NULp),
1348  colormap(0),
1349  help_active(0),
1350  clock_cursor(0),
1351  question_cursor(0),
1352  old_cursor_display(NULp),
1353  old_cursor_window(0),
1354  no_exit(false),
1355  action_hash(NULp)
1356 {}
1357 
1360  XmFontListFree(fontlist);
1361  free(color_table);
1362 }
1363 
1364 void AW_root_Motif::set_cursor(Display *d, Window w, Cursor c) {
1365  XSetWindowAttributes attrs;
1366  old_cursor_display = d;
1367  old_cursor_window = w;
1368 
1369  if (c)
1370  attrs.cursor = c;
1371  else
1372  attrs.cursor = None;
1373 
1374  if (d && w) {
1375  XChangeWindowAttributes(d, w, CWCursor, &attrs);
1376  }
1377  XChangeWindowAttributes(XtDisplay(main_widget), XtWindow(main_widget),
1378  CWCursor, &attrs);
1379  XFlush(XtDisplay(main_widget));
1380 }
1381 
1384 }
1385 
1386 void AW_server_callback(Widget /*wgt*/, XtPointer aw_cb_struct, XtPointer /*call_data*/) {
1387  AW_cb *cbs = (AW_cb *) aw_cb_struct;
1388 
1389  AW_root *root = cbs->aw->get_root();
1390  if (p_global->help_active) {
1391  p_global->help_active = 0;
1392  p_global->normal_cursor();
1393 
1394  if (cbs->help_text && ((GBS_string_matches(cbs->help_text, "*.ps", GB_IGNORE_CASE)) ||
1395  (GBS_string_matches(cbs->help_text, "*.hlp", GB_IGNORE_CASE)) ||
1396  (GBS_string_matches(cbs->help_text, "*.help", GB_IGNORE_CASE))))
1397  {
1398  AW_help_popup(NULp, cbs->help_text);
1399  }
1400  else {
1401  aw_message("Sorry no help available");
1402  }
1403  return;
1404  }
1405 
1406  if (root->is_tracking()) root->track_action(cbs->id);
1407 
1408  p_global->set_cursor(XtDisplay(p_global->toplevel_widget),
1409  XtWindow(p_aww(cbs->aw)->shell),
1410  p_global->clock_cursor);
1411  cbs->run_callbacks();
1412 
1413  XEvent event; // destroy all old events !!!
1414  while (XCheckMaskEvent(XtDisplay(p_global->toplevel_widget),
1415  ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|
1416  KeyPressMask|KeyReleaseMask|PointerMotionMask, &event)) {
1417  }
1418 
1419  if (p_global->help_active) {
1420  p_global->set_cursor(XtDisplay(p_global->toplevel_widget),
1421  XtWindow(p_aww(cbs->aw)->shell),
1422  p_global->question_cursor);
1423  }
1424  else {
1425  p_global->set_cursor(XtDisplay(p_global->toplevel_widget),
1426  XtWindow(p_aww(cbs->aw)->shell),
1427  0);
1428  }
1429 }
1430 
1432  recalc_pos_at_show = pr;
1433 }
1434 
1436  return recalc_pos_at_show;
1437 }
1438 
1440  if (sr == AW_RESIZE_ANY) {
1441  sr = (recalc_size_at_show == AW_RESIZE_USER) ? AW_RESIZE_USER : AW_RESIZE_DEFAULT;
1442  }
1443  recalc_size_at_show = sr;
1444 }
1445 
1446 
1447 
1448 // --------------
1449 // focus
1450 
1451 
1453  if (focus_cb) focus_cb->run_callbacks();
1454 }
1455 
1457  return focus_cb && focus_cb->contains(f);
1458 }
1459 
1460 // ---------------
1461 // popup
1462 
1464  if (p_w->popup_cb) {
1466  }
1467 }
1468 
1469 // ---------------
1470 // expose
1471 
1473  if (expose_cb) expose_cb->run_callbacks();
1474 }
1475 
1476 static void AW_exposeCB(Widget /*wgt*/, XtPointer aw_cb_struct, XmDrawingAreaCallbackStruct *call_data) {
1477  XEvent *ev = call_data->event;
1478  AW_area_management *aram = (AW_area_management *) aw_cb_struct;
1479  if (ev->xexpose.count == 0) { // last expose cb
1480  aram->run_expose_callback();
1481  }
1482 }
1483 
1484 void AW_area_management::set_expose_callback(AW_window *aww, const WindowCallback& cb) {
1485  // insert expose callback for draw_area
1486  if (!expose_cb) {
1487  XtAddCallback(area, XmNexposeCallback, (XtCallbackProc) AW_exposeCB,
1488  (XtPointer) this);
1489  }
1490  expose_cb = new AW_cb(aww, cb, NULp, expose_cb);
1491 }
1492 
1494  return expose_cb && expose_cb->contains(f);
1495 }
1496 
1498  AW_area_management *aram = MAP_ARAM(area);
1499  return aram && aram->is_expose_callback(f);
1500 }
1501 
1503  XmDrawingAreaCallbackStruct da_struct;
1504 
1505  da_struct.reason = XmCR_EXPOSE;
1506  da_struct.event = NULp;
1507  da_struct.window = XtWindow(p_w->shell);
1508 
1509  XtCallCallbacks(p_w->shell, XmNexposeCallback, (XtPointer) &da_struct);
1510 }
1511 
1512 // ---------------
1513 // resize
1514 
1515 
1517  return resize_cb && resize_cb->contains(f);
1518 }
1519 
1521  AW_area_management *aram = MAP_ARAM(area);
1522  return aram && aram->is_resize_callback(f);
1523 }
1524 
1525 void AW_window::set_window_frame_pos(int x, int y) {
1526  // this will set the position of the frame around the client-area (see also WM_top_offset ..)
1527  XtVaSetValues(p_w->shell, XmNx, (int)x, XmNy, (int)y, NULp);
1528 }
1529 void AW_window::get_window_content_pos(int& xpos, int& ypos) {
1530  // this will report the position of the client-area (see also WM_top_offset ..)
1531  unsigned short x, y;
1532  XtVaGetValues(p_w->shell, XmNx, &x, XmNy, &y, NULp);
1533  xpos = x;
1534  ypos = y;
1535 }
1536 
1537 void AW_window::get_screen_size(int &width, int &height) {
1538  Screen *screen = XtScreen(p_w->shell);
1539 
1540  width = WidthOfScreen(screen);
1541  height = HeightOfScreen(screen);
1542 }
1543 
1544 bool AW_window::get_mouse_pos(int& x, int& y) {
1545  Display *d = XtDisplay(p_w->shell);
1546  Window w1 = XtWindow(p_w->shell);
1547  Window w2;
1548  Window w3;
1549  int rx, ry;
1550  int wx, wy;
1551  unsigned int mask;
1552 
1553  Bool ok = XQueryPointer(d, w1, &w2, &w3, &rx, &ry, &wx, &wy, &mask);
1554 
1555  if (ok) {
1556 #if defined(DEBUG) && 0
1557  printf("get_mouse_pos: rx/ry=%i/%i wx/wy=%i/%i\n", rx, ry, wx, wy);
1558 #endif // DEBUG
1559  x = rx;
1560  y = ry;
1561  }
1562  return ok;
1563 }
1564 
1565 static int is_resize_event(Display *display, XEvent *event, XPointer) {
1566  // Predicate function: checks, if the given event is a ResizeEvent
1567  if (event && (event->type == ResizeRequest || event->type
1568  == ConfigureNotify) && event->xany.display == display) {
1569  return 1;
1570  }
1571  return 0;
1572 }
1573 
1574 static void cleanupResizeEvents(Display *display) {
1575  // Removes redundant resize events from the x-event queue
1576  if (display) {
1577  XLockDisplay(display);
1578  XEvent event;
1579  if (XCheckIfEvent(display, &event, is_resize_event, NULp)) {
1580  // Some magic happens here... ;-) (removing redundant events from queue)
1581  while (XCheckIfEvent(display, &event, is_resize_event, NULp))
1582  ;
1583  // Keep last Event in queue
1584  XPutBackEvent(display, &event);
1585  }
1586  XUnlockDisplay(display);
1587  }
1588 }
1589 
1590 static void aw_window_avoid_destroy_cb(Widget, AW_window *, XmAnyCallbackStruct *) {
1591  aw_message("If YOU do not know what to answer, how should ARB know?\nPlease think again and answer the prompt!");
1592 }
1593 static void aw_window_noexit_destroy_cb(Widget, AW_window *aww, XmAnyCallbackStruct *) {
1594  aww->hide();
1595  // don't exit, when using destroy callback
1596 }
1597 static void aw_window_destroy_cb(Widget, AW_window *aww, XmAnyCallbackStruct *) {
1598  AW_root *root = aww->get_root();
1599  if ((p_global->main_aww == aww) || !p_global->main_aww->is_shown()) {
1600 #ifdef NDEBUG
1601  if (!aw_ask_sure("quit_by_X", "Are you sure to quit?")) return;
1602 #endif
1603  exit(EXIT_SUCCESS);
1604  }
1605  aww->hide();
1606 }
1607 
1608 static void aw_set_delete_window_cb(AW_window *aww, Widget shell, bool allow_close) {
1609  Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), (char*)"WM_DELETE_WINDOW", False);
1610 
1611  // remove any previous callbacks
1612  XmRemoveWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc)aw_window_avoid_destroy_cb, (caddr_t)aww);
1613  XmRemoveWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc)aw_window_noexit_destroy_cb, (caddr_t)aww);
1614  XmRemoveWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc)aw_window_destroy_cb, (caddr_t)aww);
1615 
1616  if (!allow_close) {
1617  XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc)aw_window_avoid_destroy_cb, (caddr_t)aww);
1618  }
1619  else {
1620  AW_root *root = aww->get_root();
1621  if (p_global->no_exit) {
1622  XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc)aw_window_noexit_destroy_cb, (caddr_t)aww);
1623  }
1624  else {
1625  XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc)aw_window_destroy_cb, (caddr_t)aww);
1626  }
1627  }
1628 }
1629 
1630 void AW_window::allow_delete_window(bool allow_close) {
1631  aw_set_delete_window_cb(this, p_w->shell, allow_close);
1632 }
1633 
1634 bool AW_window::is_shown() const {
1635  // return true if window is shown ( = not invisible and already created)
1636  // Note: does return TRUE!, if window is only minimized by WM
1637  return window_is_shown;
1638 }
1639 
1641  AW_window_Motif *motif = p_aww(aww);
1642 
1643  short posx, posy;
1644  unsigned short width, height, borderwidth;
1645  XtVaGetValues(motif->shell, // bad hack
1646  XmNborderWidth, &borderwidth,
1647  XmNwidth, &width,
1648  XmNheight, &height,
1649  XmNx, &posx,
1650  XmNy, &posy,
1651  NULp);
1652 
1653  if (motif->knows_WM_offset()) {
1654  posx -= motif->WM_left_offset;
1655  posy -= motif->WM_top_offset;
1656 
1657  if (posx<0) posx = 0;
1658  if (posy<0) posy = 0;
1659 
1660  aww->store_pos_in_awars(posx, posy);
1661  }
1662 #if defined(TRACE_WM_OFFSETS)
1663  else {
1664  fprintf(stderr, "Warning: WM_offsets unknown => did not update awars for window '%s'\n", aww->get_window_title());
1665  }
1666 #endif
1667  aww->store_size_in_awars(width, height);
1668 }
1669 
1671  bool was_shown = true;
1672  if (!window_is_shown) {
1673  all_menus_created();
1674  get_root()->window_show();
1675  window_is_shown = true;
1676  was_shown = false;
1677  }
1678 
1679  int width, height; // w/o window frame
1680  if (recalc_size_at_show != AW_KEEP_SIZE) {
1681  if (recalc_size_at_show == AW_RESIZE_DEFAULT) {
1682  // window ignores user-size (even if changed inside current session).
1683  // used for question boxes, user masks, ...
1684  window_fit();
1685  get_window_size(width, height);
1686  }
1687  else {
1688  aw_assert(recalc_size_at_show == AW_RESIZE_USER);
1689  // check whether user size is too small and increase to minimum window size
1690 
1691  int min_width, min_height; get_window_size(min_width, min_height);
1692  int user_width, user_height; get_size_from_awars(user_width, user_height);
1693 
1694  if (user_width <min_width) user_width = min_width;
1695  if (user_height<min_height) user_height = min_height;
1696 
1697  set_window_size(user_width, user_height); // restores user size
1698 
1699  width = user_width;
1700  height = user_height;
1701 
1702 #if defined(DEBUG)
1703  if (!was_shown) { // first popup
1704  // warn about too big default size
1705 #define LOWEST_SUPPORTED_SCREEN_X 1280 // @@@ this size is wrong when 'window/font' has changed (e.g. to "9x15bold")
1706 #define LOWEST_SUPPORTED_SCREEN_Y 800
1707 
1708  if (min_width>LOWEST_SUPPORTED_SCREEN_X || min_height>LOWEST_SUPPORTED_SCREEN_Y) {
1709  fprintf(stderr,
1710  "Warning: Window '%s' won't fit on %ix%i (win=%ix%i)\n",
1711  get_window_title(),
1712  LOWEST_SUPPORTED_SCREEN_X, LOWEST_SUPPORTED_SCREEN_Y,
1713  min_width, min_height);
1714 #if defined(DEVEL_RALF)
1715  aw_assert(0);
1716 #endif
1717  }
1718  }
1719 #endif
1720  }
1721  store_size_in_awars(width, height);
1722  recalc_size_at_show = AW_KEEP_SIZE;
1723  }
1724  else {
1725  get_window_size(width, height);
1726  }
1727 
1728  {
1729  int posx, posy;
1730  int swidth, sheight; get_screen_size(swidth, sheight);
1731  bool posIsFrame = false;
1732 
1733  switch (recalc_pos_at_show) {
1735  recalc_pos_at_show = AW_KEEP_POS;
1736  // fallthrough
1737  case AW_REPOS_TO_MOUSE: {
1738  int mx, my;
1739  if (!get_mouse_pos(mx, my)) goto FALLBACK_CENTER;
1740 
1741  posx = mx-width/2;
1742  posy = my-height/2;
1743  break;
1744  }
1745  case AW_REPOS_TO_CENTER:
1746  FALLBACK_CENTER:
1747  posx = (swidth-width)/2;
1748  posy = (sheight-height)/4;
1749  break;
1750 
1751  case AW_KEEP_POS:
1752  if (was_shown) {
1753  // user might have moved the window -> store (new) positions
1755  }
1756  get_pos_from_awars(posx, posy);
1757  get_size_from_awars(width, height);
1758  posIsFrame = true;
1759  break;
1760  }
1761 
1762  int frameWidth, frameHeight;
1763  if (p_w->knows_WM_offset()) {
1764  frameWidth = p_w->WM_left_offset;
1765  frameHeight = p_w->WM_top_offset;
1766  }
1767  else {
1768  // estimate
1769  frameWidth = AW_window_Motif::WM_max_left_offset + 1;
1770  frameHeight = AW_window_Motif::WM_max_top_offset + 1;
1771  }
1772 
1773  if (!posIsFrame) {
1774  posx -= frameWidth;
1775  posy -= frameHeight;
1776  posIsFrame = true;
1777  }
1778 
1779  // avoid windows outside of screen (or too near to screen-edges)
1780  {
1781  int maxx = swidth - 2*frameWidth - width;
1782  int maxy = sheight - frameWidth-frameHeight - height; // assumes lower border-width == frameWidth
1783 
1784  if (posx>maxx) posx = maxx;
1785  if (posy>maxy) posy = maxy;
1786 
1787  if (p_w->knows_WM_offset()) {
1788  if (posx<0) posx = 0;
1789  if (posy<0) posy = 0;
1790  }
1791  else {
1792  // workaround a bug leading to wrong WM-offsets (occurs when window-content is placed at screen-border)
1793  // shift window away from border
1794  if (posx<frameWidth) posx = frameWidth;
1795  if (posy<frameHeight) posy = frameHeight;
1796  }
1797  }
1798 
1799  aw_assert(implicated(p_w->knows_WM_offset(), posIsFrame));
1800 
1801  // store position and position window
1802  store_pos_in_awars(posx, posy);
1803  set_window_frame_pos(posx, posy);
1804  }
1805 
1806  XtPopup(p_w->shell, XtGrabNone);
1807  if (!was_shown) {
1809  }
1810  if (!expose_callback_added) {
1811  set_expose_callback(AW_INFO_AREA, aw_onExpose_calc_WM_offsets); // @@@ should be removed after it was called once
1812  expose_callback_added = true;
1813  }
1814 }
1815 
1818  get_root()->current_modal_window = this;
1819  activate();
1820 }
1821 
1823  if (window_is_shown) {
1825  if (hide_cb) (*hide_cb)(this);
1826  get_root()->window_hide(this);
1827  window_is_shown = false;
1828  }
1829  XtPopdown(p_w->shell);
1830 }
1831 
1833  if (error) aw_message(error);
1834  else hide();
1835 }
1836 
1837 void AW_window::on_hide(const WindowCallback& call_on_hide) {
1838  hide_cb = new WindowCallback(call_on_hide);
1839 }
1840 
1842  if (resize_cb) resize_cb->run_callbacks();
1843 }
1844 
1845 static void AW_resizeCB_draw_area(Widget /*wgt*/, XtPointer aw_cb_struct, XtPointer /*call_data*/) {
1846  AW_area_management *aram = (AW_area_management *) aw_cb_struct;
1848  aram->run_resize_callback();
1849 }
1850 
1851 void AW_area_management::set_resize_callback(AW_window *aww, const WindowCallback& cb) {
1852  // insert resize callback for draw_area
1853  if (!resize_cb) {
1854  XtAddCallback(area, XmNresizeCallback,
1855  (XtCallbackProc) AW_resizeCB_draw_area, (XtPointer) this);
1856  }
1857  resize_cb = new AW_cb(aww, cb, NULp, resize_cb);
1858 }
1859 
1860 // -------------------
1861 // user input
1862 
1863 
1864 static void AW_inputCB_draw_area(Widget wgt, XtPointer aw_cb_struct, XmDrawingAreaCallbackStruct *call_data) {
1865  XEvent *ev = call_data->event;
1866  AW_cb *cbs = (AW_cb *) aw_cb_struct;
1867  AW_window *aww = cbs->aw;
1868 
1869  bool run_callback = false;
1870  bool run_double_click_callback = false;
1871 
1872  AW_area_management *area = NULp;
1873  {
1874  int i;
1875  for (i=0; i<AW_MAX_AREA; i++) {
1876  if (p_aww(aww)->areas[i]->get_area() == wgt) {
1877  area = p_aww(aww)->areas[i];
1878  break;
1879  }
1880  }
1881  }
1882 
1883  if (ev->xbutton.type == ButtonPress || ev->xbutton.type == ButtonRelease) {
1884  AW_MouseButton currButton = AW_MouseButton(ev->xbutton.button);
1885 
1886  bool ignore_this_event = false;
1887  bool last_was_click_or_drag = aww->event.type == AW_Mouse_Press || aww->event.type == AW_Mouse_Drag;
1888 
1889  if (last_was_click_or_drag && aww->event.button == AW_BUTTON_MIDDLE) { // last event was drag with middle mouse button
1890  ignore_this_event = currButton != AW_BUTTON_MIDDLE; // then ignore all other mouse buttons until drag finished
1891  }
1892 
1893  if (!ignore_this_event) {
1894  aww->event.button = currButton;
1895  aww->event.x = ev->xbutton.x;
1896  aww->event.y = ev->xbutton.y;
1898  aww->event.keycode = AW_KEY_NONE;
1899  aww->event.character = '\0';
1900 
1901  if (ev->xbutton.type == ButtonPress) {
1902  aww->event.type = AW_Mouse_Press;
1903  if (area && area->get_double_click_cb()) {
1904  if ((ev->xbutton.time - area->get_click_time()) < 200) {
1905  run_double_click_callback = true;
1906  }
1907  else {
1908  run_callback = true;
1909  }
1910  area->set_click_time(ev->xbutton.time);
1911  }
1912  else {
1913  run_callback = true;
1914  }
1915  aww->event.time = ev->xbutton.time;
1916  }
1917  else if (ev->xbutton.type == ButtonRelease) {
1918  aww->event.type = AW_Mouse_Release;
1919  run_callback = true;
1920  // keep event.time set in ButtonPress-branch
1921  }
1922  }
1923  }
1924  else if (ev->xkey.type == KeyPress || ev->xkey.type == KeyRelease) {
1925  aww->event.time = ev->xbutton.time;
1926 
1927  const awXKeymap *mykey = aw_xkey_2_awkey(&(ev->xkey));
1928 
1929  aww->event.keycode = mykey->awkey;
1930  aww->event.keymodifier = mykey->awmod;
1931 
1932  if (mykey->awstr) {
1933  aww->event.character = mykey->awstr[0];
1934  }
1935  else {
1936  aww->event.character = 0;
1937  }
1938 
1939  if (ev->xkey.type == KeyPress) {
1940  aww->event.type = AW_Keyboard_Press;
1941  }
1942  else {
1944  }
1945  aww->event.button = AW_BUTTON_NONE;
1946  aww->event.x = ev->xbutton.x;
1947  aww->event.y = ev->xbutton.y;
1948 
1949  if (!mykey->awmod && mykey->awkey >= AW_KEY_F1 && mykey->awkey
1950  <= AW_KEY_F12 && p_aww(aww)->modes_f_callbacks && p_aww(aww)->modes_f_callbacks[mykey->awkey-AW_KEY_F1]
1951  && aww->event.type == AW_Keyboard_Press) {
1952  p_aww(aww)->modes_f_callbacks[mykey->awkey-AW_KEY_F1]->run_callbacks();
1953  }
1954  else {
1955  run_callback = true;
1956  }
1957  }
1958 
1959  if (run_double_click_callback) {
1960  if (cbs->help_text == (char*)1) {
1961  cbs->run_callbacks();
1962  }
1963  else {
1964  if (area)
1966  }
1967  }
1968 
1969  if (run_callback && !cbs->help_text) {
1970  cbs->run_callbacks();
1971  }
1972 }
1973 
1974 void AW_area_management::set_input_callback(AW_window *aww, const WindowCallback& wcb) {
1975  XtAddCallback(area, XmNinputCallback,
1976  (XtCallbackProc)AW_inputCB_draw_area,
1977  (XtPointer)new AW_cb(aww, wcb));
1978 }
1979 
1980 void AW_area_management::set_double_click_callback(AW_window *aww, const WindowCallback& wcb) {
1981  double_click_cb = new AW_cb(aww, wcb, NULp, double_click_cb);
1982 }
1983 
1984 void AW_window::set_double_click_callback(AW_area area, const WindowCallback& wcb) {
1985  AW_area_management *aram = MAP_ARAM(area);
1986  if (!aram)
1987  return;
1988  aram->set_double_click_callback(this, wcb);
1989 }
1990 
1991 // ---------------
1992 // motion
1993 
1994 static void AW_motionCB(Widget /*w*/, XtPointer aw_cb_struct, XEvent *ev, Boolean*) {
1995  AW_cb *cbs = (AW_cb *) aw_cb_struct;
1996 
1997  cbs->aw->event.type = AW_Mouse_Drag;
1998  cbs->aw->event.x = ev->xmotion.x;
1999  cbs->aw->event.y = ev->xmotion.y;
2000  cbs->aw->event.keycode = AW_KEY_NONE;
2001 
2002  cbs->run_callbacks();
2003 }
2004 void AW_area_management::set_motion_callback(AW_window *aww, const WindowCallback& wcb) {
2005  XtAddEventHandler(area, ButtonMotionMask, False,
2006  AW_motionCB, (XtPointer) new AW_cb(aww, wcb, ""));
2007 }
2008 static long destroy_awar(const char *, long val, void *) {
2009  AW_awar *awar = (AW_awar*)val;
2010  delete awar;
2011  return 0; // remove from hash
2012 }
2013 
2014 void AW_root::exit_variables() {
2019  }
2020 
2021  if (hash_for_windows) {
2024  }
2025 
2026  if (application_database) {
2027  GBDATA *prop_main = application_database;
2028  application_database = NULp;
2029  GB_close(prop_main);
2030  }
2031 }
2032 
2033 void AW_root::exit_root() {
2035 }
2036 
2038  AW_screen_area scrolled;
2039  get_scrollarea_size(&scrolled);
2040 
2041  if (orientation == AW_HORIZONTAL) {
2042  XtVaSetValues(p_w->scroll_bar_horizontal, XmNpageIncrement, (int)(scrolled.r*(window_local_awar("horizontal_page_increment")->read_int()*0.01)), NULp);
2043  XtVaSetValues(p_w->scroll_bar_horizontal, XmNincrement, (int)(window_local_awar("scroll_width_horizontal")->read_int()), NULp);
2044  XtVaSetValues(p_w->scroll_bar_horizontal, XmNrepeatDelay, (int)(window_local_awar("scroll_delay_horizontal")->read_int()), NULp);
2045  }
2046  else {
2047  XtVaSetValues(p_w->scroll_bar_vertical, XmNpageIncrement, (int)(scrolled.b*(window_local_awar("vertical_page_increment")->read_int()*0.01)), NULp);
2048  XtVaSetValues(p_w->scroll_bar_vertical, XmNincrement, (int)(window_local_awar("scroll_width_vertical")->read_int()), NULp);
2049  XtVaSetValues(p_w->scroll_bar_vertical, XmNrepeatDelay, (int)(window_local_awar("scroll_delay_vertical")->read_int()), NULp);
2050  }
2051 }
2052 
2054  AW_root *root = aww->get_root();
2055  common = new AW_common_Xm(XtDisplay(area), XtWindow(area), p_global->color_table, aww->color_table, aww->color_table_size, aww, ar);
2056 }
2057 
2058 AW_color_idx AW_window::alloc_named_data_color(int colnum, const char *colorname) {
2059  if (!color_table_size) {
2062  for (int i = 0; i<color_table_size; ++i) color_table[i] = AW_NO_COLOR;
2063  }
2064  else {
2065  if (colnum>=color_table_size) {
2066  long new_size = colnum+8;
2067  ARB_realloc(color_table, new_size);
2068  for (int i = color_table_size; i<new_size; ++i) {
2069  color_table[i] = AW_NO_COLOR;
2070  }
2071  color_table_size = new_size;
2072  }
2073  }
2074  XColor xcolor_returned, xcolor_exakt;
2075 
2076  if (p_global->screen_depth == 1) { // Black and White Monitor
2077  static int col = 1;
2078  if (colnum == AW_DATA_BG) {
2079  col = 1;
2080  if (strcmp(colorname, "white"))
2081  col *= -1;
2082  }
2083  if (col==1) {
2084  color_table[colnum] = WhitePixelOfScreen(XtScreen(p_global->toplevel_widget));
2085  }
2086  else {
2087  color_table[colnum] = BlackPixelOfScreen(XtScreen(p_global->toplevel_widget));
2088  }
2089  if (colnum == AW_DATA_BG)
2090  col *= -1;
2091  }
2092  else { // Color monitor
2093  if (color_table[colnum] != AW_NO_COLOR) {
2094  unsigned long color = color_table[colnum];
2095  XFreeColors(p_global->display, p_global->colormap, &color, 1, 0);
2096  }
2097  if (XAllocNamedColor(p_global->display, p_global->colormap, colorname, &xcolor_returned, &xcolor_exakt) == 0) {
2098  aw_message(GBS_global_string("XAllocColor failed: %s\n", colorname));
2099  color_table[colnum] = AW_NO_COLOR;
2100  }
2101  else {
2102  color_table[colnum] = xcolor_returned.pixel;
2103  }
2104  }
2105  if (colnum == AW_DATA_BG) {
2106  XtVaSetValues(p_w->areas[AW_MIDDLE_AREA]->get_area(), XmNbackground, color_table[colnum], NULp);
2107  }
2108  return (AW_color_idx)colnum;
2109 }
2110 
2112  unsigned long background_color;
2113  if (p_w->areas[AW_INFO_AREA]) {
2115  XtVaGetValues(p_w->areas[AW_INFO_AREA]->get_area(), XmNbackground, &background_color, NULp);
2116  p_global->color_table[AW_WINDOW_DRAG] = background_color ^ p_global->color_table[AW_WINDOW_FG];
2117  }
2118  if (p_w->areas[AW_MIDDLE_AREA]) {
2120  }
2121  if (p_w->areas[AW_BOTTOM_AREA]) {
2123  }
2124 }
2125 
2126 void aw_insert_default_help_entries(AW_window *aww) { // used externally from ../GL/glAW/AW_window_ogl.cxx
2127  aww->insert_help_topic("Click here and then on the questionable button/menu/...", "q", NULp, AWM_ALL, AW_help_entry_pressed);
2128 
2129  aww->insert_help_topic("How to use help", "H", "help.hlp", AWM_ALL, makeHelpCallback("help.hlp"));
2130  aww->insert_help_topic("ARB help", "A", "arb.hlp", AWM_ALL, makeHelpCallback("arb.hlp"));
2131 }
2132 
2133 inline char *strdup_getlen(const char *str, int& len) {
2134  len = strlen(str);
2135  return ARB_strduplen(str, len);
2136 }
2137 Label::Label(const char *labeltext, AW_window *aww) {
2138  imageref = AW_IS_IMAGEREF(labeltext);
2139  if (imageref) {
2140  label = strdup_getlen(AW_get_pixmapPath(labeltext+1), len);
2141  }
2142  else {
2143  AW_awar *is_awar = aww->get_root()->label_is_awar(labeltext);
2144 
2145  if (is_awar) { // for labels displaying awar values, insert dummy text here
2146  len = aww->get_at().length_of_buttons - 2;
2147  if (len < 1) len = 1;
2148 
2149  ARB_alloc(label, len+1);
2150  memset(label, 'y', len);
2151  label[len] = 0;
2152  }
2153  else {
2154  label = strdup_getlen(labeltext, len);
2155  }
2156  }
2157 }
2158 
2159 void AW_label_in_awar_list(AW_window *aww, Widget widget, const char *str) {
2160  AW_awar *is_awar = aww->get_root()->label_is_awar(str);
2161  if (is_awar) {
2162  char *display = is_awar->read_as_string();
2163 
2164  if (!display) {
2165  aw_assert(0); // awar not found
2166  freeset(display, GBS_global_string_copy("<undef AWAR: %s>", str));
2167  }
2168  if (!display[0]) freeset(display, strdup(" ")); // empty string causes wrong-sized buttons
2169 
2170  aww->update_label(widget, display);
2171  free(display);
2172 
2173  is_awar->tie_widget(0, widget, AW_WIDGET_LABEL_FIELD, aww);
2174  }
2175 }
2176 
2177 static void aw_loop_get_window_geometry(const char *, long val, void *) {
2179 }
2182 }
2183 
2184 static void aw_loop_forget_window_geometry(const char *, long val, void *) {
2185  ((AW_window*)val)->reset_geometry_awars();
2186 }
2188  AW_root *awr = aww->get_root();
2189  GBS_hash_do_const_loop(awr->hash_for_windows, aw_loop_forget_window_geometry, NULp); // reset geometry for used windows
2190 
2191  // reset geometry in stored, unused windows
2192  GBDATA *gb_props = awr->check_properties(NULp);
2193  GB_transaction ta(gb_props);
2194  GBDATA *gb_win = GB_search(gb_props, LAYOUT_AWAR_ROOT, GB_FIND);
2195  if (gb_win) {
2196  for (GBDATA *gbw = GB_child(gb_win); gbw; ) {
2197  const char *key = GB_read_key_pntr(gbw);
2198  long usedWin = GBS_read_hash(awr->hash_for_windows, key);
2199  GBDATA *gbnext = GB_nextChild(gbw);
2200 
2201  if (!usedWin) {
2202  GB_ERROR error = GB_delete(gbw);
2203  aw_message_if(error);
2204  }
2205  gbw = gbnext;
2206  }
2207  }
2208 }
2209 
2210 static const char *existingPixmap(const char *icon_relpath, const char *name) {
2211  const char *icon_relname = GBS_global_string("%s/%s.xpm", icon_relpath, name);
2212  const char *icon_fullname = AW_get_pixmapPath(icon_relname);
2213 
2214  if (!GB_is_regularfile(icon_fullname)) icon_fullname = NULp;
2215 
2216  return icon_fullname;
2217 }
2218 
2219 
2220 static Pixmap getIcon(Screen *screen, const char *iconName, Pixel foreground, Pixel background) {
2221  static SmartCustomPtr(GB_HASH, GBS_free_hash) icon_hash;
2222  if (icon_hash.isNull()) {
2223  icon_hash = GBS_create_hash(100, GB_MIND_CASE);
2224  }
2225 
2226  Pixmap pixmap = GBS_read_hash(&*icon_hash, iconName);
2227 
2228  if (!pixmap && iconName) {
2229  const char *iconFile = existingPixmap("icons", iconName);
2230 
2231  if (iconFile) {
2232  char *ico = strdup(iconFile);
2233  pixmap = XmGetPixmap(screen, ico, foreground, background);
2234  GBS_write_hash(&*icon_hash, iconName, pixmap);
2235  free(ico);
2236  }
2237  }
2238 
2239  return pixmap;
2240 }
2241 
2242 STATIC_ASSERT_ANNOTATED(CopyFromParent == 0, "value of CopyFromParent changed. Check use below");
2243 #define CopyFromParent_AsPtr NULp
2244 
2245 Widget aw_create_shell(AW_window *aww, bool allow_resize, bool allow_close, int width, int height, int posx, int posy) { // @@@ move into class AW_window?
2246  AW_root *root = aww->get_root();
2247  Widget shell;
2248 
2249  // set minimum window size to size provided by init
2250  if (width >aww->get_at().max_x_size) aww->get_at().max_x_size = width;
2251  if (height>aww->get_at().max_y_size) aww->get_at().max_y_size = height;
2252 
2253  bool has_user_geometry = false;
2254  if (!GBS_read_hash(root->hash_for_windows, aww->get_window_id())) {
2255  GBS_write_hash(root->hash_for_windows, aww->get_window_id(), (long)aww);
2256 
2257  aww->create_user_geometry_awars(posx, posy, width, height);
2258  }
2259  {
2260  int user_width, user_height; aww->get_size_from_awars(user_width, user_height);
2261  int user_posx, user_posy; aww->get_pos_from_awars(user_posx, user_posy);
2262 
2263  if (allow_resize) {
2264  if (width != user_width) { width = user_width; has_user_geometry = true; }
2265  if (height != user_height) { height = user_height; has_user_geometry = true; }
2266  }
2267 
2268  // @@@ FIXME: maximum should be set to current screen size minus some offset
2269  // to ensure that windows do not appear outside screen
2270  if (posx != user_posx) { posx = user_posx; has_user_geometry = true; }
2271  if (posy != user_posy) { posy = user_posy; has_user_geometry = true; }
2272 
2273  if (has_user_geometry) {
2274  aww->recalc_size_atShow(AW_RESIZE_USER); // keep user geometry (only if user size is smaller than default size, the latter is used)
2275  }
2276  else { // no geometry yet
2277  aww->recalc_pos_atShow(AW_REPOS_TO_MOUSE_ONCE); // popup the window at current mouse position
2278  }
2279  }
2280 
2281  if (allow_resize) {
2282  // create the window big enough to ensure that all widgets
2283  // are created in visible area (otherwise widget are crippled).
2284  // window will be resized later (on show)
2285 
2286  width = WIDER_THAN_SCREEN;
2287  height = HIGHER_THAN_SCREEN;
2288 
2290  }
2291 
2292  Widget father = p_global->toplevel_widget;
2293  Screen *screen = XtScreen(father);
2294  Pixmap icon_pixmap = getIcon(screen, aww->window_defaults_name, p_global->foreground, p_global->background);
2295 
2296  if (!icon_pixmap) {
2297  icon_pixmap = getIcon(screen, root->program_name, p_global->foreground, p_global->background);
2298  }
2299 
2300  if (!icon_pixmap) {
2301  GBK_terminatef("Missing icon pixmap for window '%s'\n", aww->window_defaults_name);
2302  }
2303  else if (icon_pixmap == XmUNSPECIFIED_PIXMAP) {
2304  GBK_terminatef("Failed to load icon pixmap for window '%s'\n", aww->window_defaults_name);
2305  }
2306 
2307  int focusPolicy = root->focus_follows_mouse ? XmPOINTER : XmEXPLICIT;
2308 
2309  {
2310  aw_xargs args(9);
2311 
2312  args.add(XmNwidth, width);
2313  args.add(XmNheight, height);
2314  args.add(XmNx, posx);
2315  args.add(XmNy, posy);
2316  args.add(XmNtitle, (XtArgVal)aww->window_name);
2317  args.add(XmNiconName, (XtArgVal)aww->window_name);
2318  args.add(XmNkeyboardFocusPolicy, focusPolicy);
2319  args.add(XmNdeleteResponse, XmDO_NOTHING);
2320  args.add(XtNiconPixmap, icon_pixmap);
2321 
2322  if (!p_global->main_widget || !p_global->main_aww->is_shown()) {
2323  shell = XtCreatePopupShell("editor", applicationShellWidgetClass, father, args.list(), args.size());
2324  }
2325  else {
2326  shell = XtCreatePopupShell("transient", transientShellWidgetClass, father, args.list(), args.size());
2327  }
2328  }
2329 
2330  if (!p_global->main_widget) {
2331  p_global->main_widget = shell;
2332  p_global->main_aww = aww;
2333  }
2334  else {
2335  if (!p_global->main_aww->is_shown()) { // now i am the root window
2336  p_global->main_widget = shell;
2337  p_global->main_aww = aww;
2338  }
2339  }
2340 
2341  aw_set_delete_window_cb(aww, shell, allow_close);
2342 
2343  // set icon window (for window managers where iconified applications are dropped onto desktop or similar)
2344  {
2345  Window icon_window;
2346  XtVaGetValues(shell, XmNiconWindow, &icon_window, NULp);
2347 
2348  Display *dpy = XtDisplay(shell);
2349  if (!icon_window) {
2350  XSetWindowAttributes attr;
2351  attr.background_pixmap = icon_pixmap;
2352 
2353  int xpos, ypos;
2354  unsigned int xsize, ysize, borderwidth, depth;
2355  Window wroot;
2356 
2357  if (XGetGeometry(dpy, icon_pixmap, &wroot, &xpos, &ypos, &xsize, &ysize, &borderwidth, &depth)) {
2358  icon_window = XCreateWindow(dpy, wroot, 0, 0, xsize, ysize, 0, depth, CopyFromParent, CopyFromParent_AsPtr, CWBackPixmap, &attr);
2359  }
2360  }
2361  if (!icon_window) {
2362  XtVaSetValues(shell, XmNiconPixmap, icon_pixmap, NULp);
2363  }
2364  else {
2365  XtVaSetValues(shell, XmNiconWindow, icon_window, NULp);
2366  XSetWindowBackgroundPixmap(dpy, icon_window, icon_pixmap);
2367  XClearWindow(dpy, icon_window);
2368  }
2369  }
2370 
2371  return shell;
2372 }
2373 
2374 
2375 void aw_realize_widget(AW_window *aww) { // used externally from ../GL/glAW/AW_window_ogl.cxx
2376  if (p_aww(aww)->areas[AW_INFO_AREA] && p_aww(aww)->areas[AW_INFO_AREA]->get_form()) {
2377  XtManageChild(p_aww(aww)->areas[AW_INFO_AREA]->get_form());
2378  }
2379  if (p_aww(aww)->areas[AW_MIDDLE_AREA] && p_aww(aww)->areas[AW_MIDDLE_AREA]->get_form()) {
2380  XtManageChild(p_aww(aww)->areas[AW_MIDDLE_AREA]->get_form());
2381  }
2382  if (p_aww(aww)->areas[AW_BOTTOM_AREA] && p_aww(aww)->areas[AW_BOTTOM_AREA]->get_form()) {
2383  XtManageChild(p_aww(aww)->areas[AW_BOTTOM_AREA]->get_form());
2384  }
2385  XtRealizeWidget(p_aww(aww)->shell);
2386  p_aww(aww)->WM_top_offset = AW_CALC_OFFSET_ON_EXPOSE;
2387 }
2388 
2389 void AW_window_menu_modes::init(AW_root *root_in, const char *wid, const char *windowname, int width, int height) {
2390  Widget main_window;
2391  Widget help_popup;
2392  Widget help_label;
2393  Widget separator;
2394  Widget form1;
2395  Widget form2;
2396  const char *help_button = "HELP";
2397  const char *help_mnemonic = "H";
2398 
2399 #if defined(DUMP_MENU_LIST)
2400  initMenuListing(windowname);
2401 #endif // DUMP_MENU_LIST
2402  root = root_in; // for macro
2403  window_name = strdup(windowname);
2405 
2406  int posx = 50;
2407  int posy = 50;
2408 
2409  p_w->shell = aw_create_shell(this, true, true, width, height, posx, posy);
2410 
2411  main_window = XtVaCreateManagedWidget("mainWindow1",
2412  xmMainWindowWidgetClass, p_w->shell,
2413  NULp);
2414 
2415  p_w->menu_bar[0] = XtVaCreateManagedWidget("menu1", xmRowColumnWidgetClass,
2416  main_window,
2417  XmNrowColumnType, XmMENU_BAR,
2418  NULp);
2419 
2420  // create shell for help-cascade
2421  help_popup = XtVaCreatePopupShell("menu_shell", xmMenuShellWidgetClass,
2422  p_w->menu_bar[0],
2423  XmNwidth, 1,
2424  XmNheight, 1,
2425  XmNallowShellResize, true,
2426  XmNoverrideRedirect, true,
2427  NULp);
2428 
2429  // create row column in Pull-Down shell
2430  p_w->help_pull_down = XtVaCreateWidget("menu_row_column",
2431  xmRowColumnWidgetClass, help_popup,
2432  XmNrowColumnType, XmMENU_PULLDOWN,
2433  NULp);
2434 
2435  // create HELP-label in menu bar
2436  help_label = XtVaCreateManagedWidget("menu1_top_b1",
2437  xmCascadeButtonWidgetClass, p_w->menu_bar[0],
2438  RES_CONVERT(XmNlabelString, help_button),
2439  RES_CONVERT(XmNmnemonic, help_mnemonic),
2440  XmNsubMenuId, p_w->help_pull_down, NULp);
2441  XtVaSetValues(p_w->menu_bar[0], XmNmenuHelpWidget, help_label, NULp);
2442  root->make_sensitive(help_label, AWM_ALL);
2443 
2444  form1 = XtVaCreateManagedWidget("form1",
2445  xmFormWidgetClass,
2446  main_window,
2447  // XmNwidth, width,
2448  // XmNheight, height,
2449  XmNresizePolicy, XmRESIZE_NONE,
2450  // XmNx, 0,
2451  // XmNy, 0,
2452  NULp);
2453 
2454  p_w->mode_area = XtVaCreateManagedWidget("mode area",
2455  xmDrawingAreaWidgetClass,
2456  form1,
2457  XmNresizePolicy, XmRESIZE_NONE,
2458  XmNwidth, 38,
2459  XmNheight, height,
2460  XmNx, 0,
2461  XmNy, 0,
2462  XmNleftOffset, 0,
2463  XmNtopOffset, 0,
2464  XmNbottomAttachment, XmATTACH_FORM,
2465  XmNleftAttachment, XmATTACH_POSITION,
2466  XmNtopAttachment, XmATTACH_POSITION,
2467  XmNmarginHeight, 2,
2468  XmNmarginWidth, 1,
2469  NULp);
2470 
2471  separator = XtVaCreateManagedWidget("separator",
2472  xmSeparatorWidgetClass,
2473  form1,
2474  XmNx, 37,
2475  XmNshadowThickness, 4,
2476  XmNorientation, XmVERTICAL,
2477  XmNbottomAttachment, XmATTACH_FORM,
2478  XmNtopAttachment, XmATTACH_FORM,
2479  XmNleftAttachment, XmATTACH_NONE,
2480  XmNleftWidget, NULp,
2481  XmNrightAttachment, XmATTACH_NONE,
2482  XmNleftOffset, 70,
2483  XmNleftPosition, 0,
2484  NULp);
2485 
2486  form2 = XtVaCreateManagedWidget("form2",
2487  xmFormWidgetClass,
2488  form1,
2489  XmNwidth, width,
2490  XmNheight, height,
2491  XmNtopOffset, 0,
2492  XmNbottomOffset, 0,
2493  XmNleftOffset, 0,
2494  XmNrightOffset, 0,
2495  XmNrightAttachment, XmATTACH_FORM,
2496  XmNbottomAttachment, XmATTACH_FORM,
2497  XmNleftAttachment, XmATTACH_WIDGET,
2498  XmNleftWidget, separator,
2499  XmNtopAttachment, XmATTACH_POSITION,
2500  XmNresizePolicy, XmRESIZE_NONE,
2501  XmNx, 0,
2502  XmNy, 0,
2503  NULp);
2504  p_w->areas[AW_INFO_AREA] =
2505  new AW_area_management(form2, XtVaCreateManagedWidget("info_area",
2506  xmDrawingAreaWidgetClass,
2507  form2,
2508  XmNheight, 0,
2509  XmNbottomAttachment, XmATTACH_NONE,
2510  XmNtopAttachment, XmATTACH_FORM,
2511  XmNleftAttachment, XmATTACH_FORM,
2512  XmNrightAttachment, XmATTACH_FORM,
2513  XmNmarginHeight, 2,
2514  XmNmarginWidth, 2,
2515  NULp));
2516 
2518  new AW_area_management(form2, XtVaCreateManagedWidget("bottom_area",
2519  xmDrawingAreaWidgetClass,
2520  form2,
2521  XmNheight, 0,
2522  XmNbottomAttachment, XmATTACH_FORM,
2523  XmNtopAttachment, XmATTACH_NONE,
2524  XmNleftAttachment, XmATTACH_FORM,
2525  XmNrightAttachment, XmATTACH_FORM,
2526  NULp));
2527 
2528  p_w->scroll_bar_horizontal = XtVaCreateManagedWidget("scroll_bar_horizontal",
2529  xmScrollBarWidgetClass,
2530  form2,
2531  XmNheight, 15,
2532  XmNminimum, 0,
2533  XmNmaximum, AW_SCROLL_MAX,
2534  XmNincrement, 10,
2535  XmNsliderSize, AW_SCROLL_MAX,
2536  XmNrightAttachment, XmATTACH_FORM,
2537  XmNbottomAttachment, XmATTACH_FORM,
2538  XmNbottomOffset, 0,
2539  XmNleftAttachment, XmATTACH_FORM,
2540  XmNtopAttachment, XmATTACH_NONE,
2541  XmNorientation, XmHORIZONTAL,
2542  XmNrightOffset, 18,
2543  NULp);
2544 
2545  p_w->scroll_bar_vertical = XtVaCreateManagedWidget("scroll_bar_vertical",
2546  xmScrollBarWidgetClass,
2547  form2,
2548  XmNwidth, 15,
2549  XmNminimum, 0,
2550  XmNmaximum, AW_SCROLL_MAX,
2551  XmNincrement, 10,
2552  XmNsliderSize, AW_SCROLL_MAX,
2553  XmNrightAttachment, XmATTACH_FORM,
2554  XmNbottomAttachment, XmATTACH_WIDGET,
2555  XmNbottomWidget, p_w->scroll_bar_horizontal,
2556  XmNbottomOffset, 3,
2557  XmNleftOffset, 3,
2558  XmNrightOffset, 3,
2559  XmNleftAttachment, XmATTACH_NONE,
2560  XmNtopAttachment, XmATTACH_WIDGET,
2561  XmNtopWidget, INFO_WIDGET,
2562  NULp);
2563 
2564  p_w->frame = XtVaCreateManagedWidget("draw_area",
2565  xmFrameWidgetClass,
2566  form2,
2567  XmNshadowType, XmSHADOW_IN,
2568  XmNshadowThickness, 2,
2569  XmNleftOffset, 3,
2570  XmNtopOffset, 3,
2571  XmNbottomOffset, 3,
2572  XmNrightOffset, 3,
2573  XmNbottomAttachment, XmATTACH_WIDGET,
2574  XmNbottomWidget, p_w->scroll_bar_horizontal,
2575  XmNtopAttachment, XmATTACH_FORM,
2576  XmNtopOffset, 0,
2577  XmNleftAttachment, XmATTACH_FORM,
2578  XmNrightAttachment, XmATTACH_WIDGET,
2579  XmNrightWidget, p_w->scroll_bar_vertical,
2580  NULp);
2581 
2583  new AW_area_management(p_w->frame, XtVaCreateManagedWidget("draw area",
2584  xmDrawingAreaWidgetClass,
2585  p_w->frame,
2586  XmNmarginHeight, 0,
2587  XmNmarginWidth, 0,
2588  NULp));
2589 
2590  XmMainWindowSetAreas(main_window, p_w->menu_bar[0], Widget(NULp), Widget(NULp), Widget(NULp), form1);
2591 
2592  aw_realize_widget(this);
2593 
2594  create_devices();
2597 }
2598 
2599 void AW_window_menu::init(AW_root *root_in, const char *wid, const char *windowname, int width, int height) {
2600  Widget main_window;
2601  Widget help_popup;
2602  Widget help_label;
2603  Widget separator;
2604  Widget form1;
2605  Widget form2;
2606  const char *help_button = "HELP";
2607  const char *help_mnemonic = "H";
2608 
2609 #if defined(DUMP_MENU_LIST)
2610  initMenuListing(windowname);
2611 #endif // DUMP_MENU_LIST
2612  root = root_in; // for macro
2613  window_name = strdup(windowname);
2615 
2616  int posx = 50;
2617  int posy = 50;
2618 
2619  p_w->shell = aw_create_shell(this, true, true, width, height, posx, posy);
2620 
2621  main_window = XtVaCreateManagedWidget("mainWindow1",
2622  xmMainWindowWidgetClass, p_w->shell,
2623  NULp);
2624 
2625  p_w->menu_bar[0] = XtVaCreateManagedWidget("menu1", xmRowColumnWidgetClass,
2626  main_window,
2627  XmNrowColumnType, XmMENU_BAR,
2628  NULp);
2629 
2630  // create shell for help-cascade
2631  help_popup = XtVaCreatePopupShell("menu_shell", xmMenuShellWidgetClass,
2632  p_w->menu_bar[0],
2633  XmNwidth, 1,
2634  XmNheight, 1,
2635  XmNallowShellResize, true,
2636  XmNoverrideRedirect, true,
2637  NULp);
2638 
2639  // create row column in Pull-Down shell
2640  p_w->help_pull_down = XtVaCreateWidget("menu_row_column",
2641  xmRowColumnWidgetClass, help_popup,
2642  XmNrowColumnType, XmMENU_PULLDOWN,
2643  NULp);
2644 
2645  // create HELP-label in menu bar
2646  help_label = XtVaCreateManagedWidget("menu1_top_b1",
2647  xmCascadeButtonWidgetClass, p_w->menu_bar[0],
2648  RES_CONVERT(XmNlabelString, help_button),
2649  RES_CONVERT(XmNmnemonic, help_mnemonic),
2650  XmNsubMenuId, p_w->help_pull_down, NULp);
2651  XtVaSetValues(p_w->menu_bar[0], XmNmenuHelpWidget, help_label, NULp);
2652  root->make_sensitive(help_label, AWM_ALL);
2653 
2654  form1 = XtVaCreateManagedWidget("form1",
2655  xmFormWidgetClass,
2656  main_window,
2657  // XmNwidth, width,
2658  // XmNheight, height,
2659  XmNresizePolicy, XmRESIZE_NONE,
2660  // XmNx, 0,
2661  // XmNy, 0,
2662  NULp);
2663 
2664  p_w->mode_area = XtVaCreateManagedWidget("mode area",
2665  xmDrawingAreaWidgetClass,
2666  form1,
2667  XmNresizePolicy, XmRESIZE_NONE,
2668  XmNwidth, 17,
2669  XmNheight, height,
2670  XmNx, 0,
2671  XmNy, 0,
2672  XmNleftOffset, 0,
2673  XmNtopOffset, 0,
2674  XmNbottomAttachment, XmATTACH_FORM,
2675  XmNleftAttachment, XmATTACH_POSITION,
2676  XmNtopAttachment, XmATTACH_POSITION,
2677  XmNmarginHeight, 2,
2678  XmNmarginWidth, 1,
2679  NULp);
2680 
2681  separator = p_w->mode_area;
2682 
2683  form2 = XtVaCreateManagedWidget("form2",
2684  xmFormWidgetClass,
2685  form1,
2686  XmNwidth, width,
2687  XmNheight, height,
2688  XmNtopOffset, 0,
2689  XmNbottomOffset, 0,
2690  XmNleftOffset, 0,
2691  XmNrightOffset, 0,
2692  XmNrightAttachment, XmATTACH_FORM,
2693  XmNbottomAttachment, XmATTACH_FORM,
2694  XmNleftAttachment, XmATTACH_WIDGET,
2695  XmNleftWidget, separator,
2696  XmNtopAttachment, XmATTACH_POSITION,
2697  XmNresizePolicy, XmRESIZE_NONE,
2698  XmNx, 0,
2699  XmNy, 0,
2700  NULp);
2701  p_w->areas[AW_INFO_AREA] =
2702  new AW_area_management(form2, XtVaCreateManagedWidget("info_area",
2703  xmDrawingAreaWidgetClass,
2704  form2,
2705  XmNheight, 0,
2706  XmNbottomAttachment, XmATTACH_NONE,
2707  XmNtopAttachment, XmATTACH_FORM,
2708  XmNleftAttachment, XmATTACH_FORM,
2709  XmNrightAttachment, XmATTACH_FORM,
2710  XmNmarginHeight, 2,
2711  XmNmarginWidth, 2,
2712  NULp));
2713 
2715  new AW_area_management(form2, XtVaCreateManagedWidget("bottom_area",
2716  xmDrawingAreaWidgetClass,
2717  form2,
2718  XmNheight, 0,
2719  XmNbottomAttachment, XmATTACH_FORM,
2720  XmNtopAttachment, XmATTACH_NONE,
2721  XmNleftAttachment, XmATTACH_FORM,
2722  XmNrightAttachment, XmATTACH_FORM,
2723  NULp));
2724 
2725  p_w->scroll_bar_horizontal = XtVaCreateManagedWidget("scroll_bar_horizontal",
2726  xmScrollBarWidgetClass,
2727  form2,
2728  XmNheight, 15,
2729  XmNminimum, 0,
2730  XmNmaximum, AW_SCROLL_MAX,
2731  XmNincrement, 10,
2732  XmNsliderSize, AW_SCROLL_MAX,
2733  XmNrightAttachment, XmATTACH_FORM,
2734  XmNbottomAttachment, XmATTACH_FORM,
2735  XmNbottomOffset, 0,
2736  XmNleftAttachment, XmATTACH_FORM,
2737  XmNtopAttachment, XmATTACH_NONE,
2738  XmNorientation, XmHORIZONTAL,
2739  XmNrightOffset, 18,
2740  NULp);
2741 
2742  p_w->scroll_bar_vertical = XtVaCreateManagedWidget("scroll_bar_vertical",
2743  xmScrollBarWidgetClass,
2744  form2,
2745  XmNwidth, 15,
2746  XmNminimum, 0,
2747  XmNmaximum, AW_SCROLL_MAX,
2748  XmNincrement, 10,
2749  XmNsliderSize, AW_SCROLL_MAX,
2750  XmNrightAttachment, XmATTACH_FORM,
2751  XmNbottomAttachment, XmATTACH_WIDGET,
2752  XmNbottomWidget, p_w->scroll_bar_horizontal,
2753  XmNbottomOffset, 3,
2754  XmNleftOffset, 3,
2755  XmNrightOffset, 3,
2756  XmNleftAttachment, XmATTACH_NONE,
2757  XmNtopAttachment, XmATTACH_WIDGET,
2758  XmNtopWidget, INFO_WIDGET,
2759  NULp);
2760 
2761  p_w->frame = XtVaCreateManagedWidget("draw_area",
2762  xmFrameWidgetClass,
2763  form2,
2764  XmNshadowType, XmSHADOW_IN,
2765  XmNshadowThickness, 2,
2766  XmNleftOffset, 3,
2767  XmNtopOffset, 3,
2768  XmNbottomOffset, 3,
2769  XmNrightOffset, 3,
2770  XmNbottomAttachment, XmATTACH_WIDGET,
2771  XmNbottomWidget, p_w->scroll_bar_horizontal,
2772  XmNtopAttachment, XmATTACH_FORM,
2773  XmNtopOffset, 0,
2774  XmNleftAttachment, XmATTACH_FORM,
2775  XmNrightAttachment, XmATTACH_WIDGET,
2776  XmNrightWidget, p_w->scroll_bar_vertical,
2777  NULp);
2778 
2780  new AW_area_management(p_w->frame, XtVaCreateManagedWidget("draw area",
2781  xmDrawingAreaWidgetClass,
2782  p_w->frame,
2783  XmNmarginHeight, 0,
2784  XmNmarginWidth, 0,
2785  NULp));
2786 
2787  XmMainWindowSetAreas(main_window, p_w->menu_bar[0], Widget(NULp), Widget(NULp), Widget(NULp), form1);
2788 
2789  aw_realize_widget(this);
2790 
2791  create_devices();
2794 }
2795 
2796 void AW_window_simple::init(AW_root *root_in, const char *wid, const char *windowname) {
2797  root = root_in; // for macro
2798 
2799  int width = 100; // this is only the minimum size!
2800  int height = 100;
2801  int posx = 50;
2802  int posy = 50;
2803 
2804  window_name = strdup(windowname);
2805  window_defaults_name = GBS_string_2_key(wid);
2806 
2807  p_w->shell = aw_create_shell(this, true, true, width, height, posx, posy);
2808 
2809  // add this to disable resize or maximize in simple dialogs (avoids broken layouts)
2810  // XtVaSetValues(p_w->shell, XmNmwmFunctions, MWM_FUNC_MOVE | MWM_FUNC_CLOSE, NULp);
2811 
2812  Widget form1 = XtVaCreateManagedWidget("forms", xmFormWidgetClass,
2813  p_w->shell,
2814  NULp);
2815 
2816  p_w->areas[AW_INFO_AREA] =
2817  new AW_area_management(form1, XtVaCreateManagedWidget("info_area",
2818  xmDrawingAreaWidgetClass,
2819  form1,
2820  XmNbottomAttachment, XmATTACH_FORM,
2821  XmNtopAttachment, XmATTACH_FORM,
2822  XmNleftAttachment, XmATTACH_FORM,
2823  XmNrightAttachment, XmATTACH_FORM,
2824  XmNmarginHeight, 2,
2825  XmNmarginWidth, 2,
2826  NULp));
2827 
2828  aw_realize_widget(this);
2829  create_devices();
2830 }
2831 
2832 void AW_window_simple_menu::init(AW_root *root_in, const char *wid, const char *windowname) {
2833  root = root_in; // for macro
2834 
2835  const char *help_button = "HELP";
2836  const char *help_mnemonic = "H";
2837  window_name = strdup(windowname);
2839 
2840  int width = 100;
2841  int height = 100;
2842  int posx = 50;
2843  int posy = 50;
2844 
2845  p_w->shell = aw_create_shell(this, true, true, width, height, posx, posy);
2846 
2847  Widget main_window;
2848  Widget help_popup;
2849  Widget help_label;
2850  Widget form1;
2851 
2852  main_window = XtVaCreateManagedWidget("mainWindow1",
2853  xmMainWindowWidgetClass, p_w->shell,
2854  NULp);
2855 
2856  p_w->menu_bar[0] = XtVaCreateManagedWidget("menu1", xmRowColumnWidgetClass,
2857  main_window,
2858  XmNrowColumnType, XmMENU_BAR,
2859  NULp);
2860 
2861  // create shell for help-cascade
2862  help_popup = XtVaCreatePopupShell("menu_shell", xmMenuShellWidgetClass,
2863  p_w->menu_bar[0],
2864  XmNwidth, 1,
2865  XmNheight, 1,
2866  XmNallowShellResize, true,
2867  XmNoverrideRedirect, true,
2868  NULp);
2869 
2870  // create row column in Pull-Down shell
2871  p_w->help_pull_down = XtVaCreateWidget("menu_row_column",
2872  xmRowColumnWidgetClass, help_popup,
2873  XmNrowColumnType, XmMENU_PULLDOWN,
2874  NULp);
2875 
2876  // create HELP-label in menu bar
2877  help_label = XtVaCreateManagedWidget("menu1_top_b1",
2878  xmCascadeButtonWidgetClass, p_w->menu_bar[0],
2879  RES_CONVERT(XmNlabelString, help_button),
2880  RES_CONVERT(XmNmnemonic, help_mnemonic),
2881  XmNsubMenuId, p_w->help_pull_down, NULp);
2882  XtVaSetValues(p_w->menu_bar[0], XmNmenuHelpWidget, help_label, NULp);
2883  root->make_sensitive(help_label, AWM_ALL);
2884 
2885  form1 = XtVaCreateManagedWidget("form1",
2886  xmFormWidgetClass,
2887  main_window,
2888  XmNtopOffset, 10,
2889  XmNresizePolicy, XmRESIZE_NONE,
2890  NULp);
2891 
2892  p_w->areas[AW_INFO_AREA] =
2893  new AW_area_management(form1, XtVaCreateManagedWidget("info_area",
2894  xmDrawingAreaWidgetClass,
2895  form1,
2896  XmNbottomAttachment, XmATTACH_FORM,
2897  XmNtopAttachment, XmATTACH_FORM,
2898  XmNleftAttachment, XmATTACH_FORM,
2899  XmNrightAttachment, XmATTACH_FORM,
2900  XmNmarginHeight, 2,
2901  XmNmarginWidth, 2,
2902  NULp));
2903 
2904  aw_realize_widget(this);
2905 
2907  create_devices();
2908 }
2909 
2910 void AW_window_message::init(AW_root *root_in, const char *wid, const char *windowname, bool allow_close) {
2911  root = root_in; // for macro
2912 
2913  int width = 100;
2914  int height = 100;
2915  int posx = 50;
2916  int posy = 50;
2917 
2918  window_name = strdup(windowname);
2919  window_defaults_name = strdup(wid);
2920 
2921  // create shell for message box
2922  p_w->shell = aw_create_shell(this, true, allow_close, width, height, posx, posy);
2923 
2924  // disable resize or maximize in simple dialogs (avoids broken layouts)
2925  XtVaSetValues(p_w->shell, XmNmwmFunctions, MWM_FUNC_MOVE | MWM_FUNC_CLOSE,
2926  NULp);
2927 
2928  p_w->areas[AW_INFO_AREA] =
2929  new AW_area_management(p_w->shell, XtVaCreateManagedWidget("info_area",
2930  xmDrawingAreaWidgetClass,
2931  p_w->shell,
2932  XmNheight, 0,
2933  XmNbottomAttachment, XmATTACH_NONE,
2934  XmNtopAttachment, XmATTACH_FORM,
2935  XmNleftAttachment, XmATTACH_FORM,
2936  XmNrightAttachment, XmATTACH_FORM,
2937  NULp));
2938 
2939  aw_realize_widget(this);
2940 }
2941 void AW_window_message::init(AW_root *root_in, const char *windowname, bool allow_close) {
2942  char *wid = GBS_string_2_key(windowname);
2943  init(root_in, wid, windowname, allow_close);
2944  free(wid);
2945 }
2946 
2947 void AW_window::set_focus_policy(bool follow_mouse) {
2948  int focusPolicy = follow_mouse ? XmPOINTER : XmEXPLICIT;
2949  XtVaSetValues(p_w->shell, XmNkeyboardFocusPolicy, focusPolicy, NULp);
2950 }
2951 
2952 void AW_window::select_mode(int mode) {
2953  if (mode >= p_w->number_of_modes)
2954  return;
2955 
2956  Widget oldwidget = p_w->modes_widgets[p_w->selected_mode];
2957  p_w->selected_mode = mode;
2959  XtVaSetValues(oldwidget, XmNbackground, p_global->background, NULp);
2960  XtVaSetValues(widget, XmNbackground, p_global->foreground, NULp);
2961 }
2962 
2963 static void aw_mode_callback(AW_window *aww, short mode, AW_cb *cbs) {
2964  aww->select_mode(mode);
2965  cbs->run_callbacks();
2966 }
2967 
2968 #define MODE_BUTTON_OFFSET 34
2969 inline int yoffset_for_mode_button(int button_number) {
2970  return button_number*MODE_BUTTON_OFFSET + (button_number/4)*8 + 2;
2971 }
2972 
2973 int AW_window::create_mode(const char *pixmap, const char *helpText, AW_active mask, const WindowCallback& cb) {
2974  aw_assert(legal_mask(mask));
2975  Widget button;
2976 
2977  TuneBackground(p_w->mode_area, TUNE_BUTTON); // set background color for mode-buttons
2978 
2979  const char *path = AW_get_pixmapPath(pixmap);
2980 
2982  button = XtVaCreateManagedWidget("", xmPushButtonWidgetClass, p_w->mode_area,
2983  XmNx, 0,
2984  XmNy, y,
2985  XmNlabelType, XmPIXMAP,
2986  XmNshadowThickness, 1,
2987  XmNbackground, _at->background_color,
2988  NULp);
2989  XtVaSetValues(button, RES_CONVERT(XmNlabelPixmap, path), NULp);
2990  XtVaGetValues(button, XmNforeground, &p_global->foreground, NULp);
2991 
2992  AW_cb *cbs = new AW_cb(this, cb, NULp);
2993  AW_cb *cb2 = new AW_cb(this, makeWindowCallback(aw_mode_callback, p_w->number_of_modes, cbs), helpText, cbs);
2994  XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)AW_server_callback, (XtPointer)cb2);
2995 
2996  if (!p_w->modes_f_callbacks) ARB_calloc(p_w->modes_f_callbacks, AW_NUMBER_OF_F_KEYS); // valgrinders : never freed because AW_window never is freed
2998 
3001  p_w->modes_widgets[p_w->number_of_modes] = button;
3002  }
3003 
3004  root->make_sensitive(button, mask);
3005  p_w->number_of_modes++;
3006 
3008  if (ynext> _at->max_y_size) _at->max_y_size = ynext;
3009 
3010  return p_w->number_of_modes;
3011 }
3012 
3014  memset((char *)this, 0, sizeof(AW_area_management));
3015  form = formi;
3016  area = widget;
3017 }
3018 
3020  if (!device) device = new AW_device_Xm(common);
3021  return device;
3022 }
3023 
3025  if (!size_device) size_device = new AW_device_size(common);
3026  return size_device;
3027 }
3028 
3030  if (!print_device) print_device = new AW_device_print(common);
3031  return print_device;
3032 }
3033 
3035  if (!click_device) click_device = new AW_device_click(common);
3036  return click_device;
3037 }
3038 
3040  {
3041  Boolean iconic = False;
3042  XtVaGetValues(p_w->shell, XmNiconic, &iconic, NULp);
3043 
3044  if (iconic == True) {
3045  XtVaSetValues(p_w->shell, XmNiconic, False, NULp);
3046 
3047  XtMapWidget(p_w->shell);
3048  XRaiseWindow(XtDisplay(p_w->shell), XtWindow(p_w->shell));
3049  }
3050  }
3051 
3052  {
3053  Display *xdpy = XtDisplay(p_w->shell);
3054  Window window = XtWindow(p_w->shell);
3055  Atom netactivewindow = XInternAtom(xdpy, "_NET_ACTIVE_WINDOW", False);
3056 
3057  if (netactivewindow) {
3058 
3059  XClientMessageEvent ce;
3060  ce.type = ClientMessage;
3061  ce.display = xdpy;
3062  ce.window = window;
3063  ce.message_type = netactivewindow;
3064  ce.format = 32;
3065  ce.data.l[0] = 2;
3066  ce.data.l[1] = None;
3067  ce.data.l[2] = Above;
3068  ce.data.l[3] = 0;
3069  ce.data.l[4] = 0;
3070 
3071 #if defined(DEBUG)
3072  Status ret =
3073 #endif // DEBUG
3074  XSendEvent(xdpy, XDefaultRootWindow(xdpy),
3075  False,
3076  SubstructureRedirectMask | SubstructureNotifyMask,
3077  (XEvent *) &ce);
3078 
3079 #if defined(DEBUG)
3080  if (!ret) { fprintf(stderr, "Failed to send _NET_ACTIVE_WINDOW to WM (XSendEvent returns %i)\n", ret); }
3081 #endif // DEBUG
3082  XSync(xdpy, False);
3083  }
3084 #if defined(DEBUG)
3085  else {
3086  fputs("No such atom '_NET_ACTIVE_WINDOW'\n", stderr);
3087  }
3088 #endif // DEBUG
3089  }
3090 }
3091 
3093  if (_callback && (long)_callback != 1) {
3097  }
3098 
3099  XtAddCallback((Widget) widget, XmNactivateCallback,
3100  (XtCallbackProc) AW_server_callback, (XtPointer) _callback);
3101  }
3102  _callback = NULp;
3103 }
3104 
3105 
3106 void AW_window::set_background(const char *colorname, Widget parentWidget) {
3107  bool colorSet = false;
3108 
3109  if (colorname) {
3110  XColor unused, color;
3111 
3112  if (XAllocNamedColor(p_global->display, p_global->colormap, colorname, &color, &unused)
3113  == 0) {
3114  fprintf(stderr, "XAllocColor failed: %s\n", colorname);
3115  }
3116  else {
3117  _at->background_color = color.pixel;
3118  colorSet = true;
3119  }
3120  }
3121 
3122  if (!colorSet) {
3123  XtVaGetValues(parentWidget, XmNbackground, &(_at->background_color),
3124  NULp); // fallback to background color
3125  }
3126 }
3127 
3128 void AW_window::TuneOrSetBackground(Widget w, const char *color, int modStrength) {
3129  // Sets the background for the next created widget.
3130  //
3131  // If 'color' is specified, it may contain one of the following values:
3132  // "+" means: slightly increase color of parent widget 'w'
3133  // "-" means: slightly decrease color of parent widget 'w'
3134  // otherwise it contains a specific color ('name' or '#RGB')
3135  //
3136  // If color is not specified, the color of the parent widget 'w' is modified
3137  // by 'modStrength' (increased if positive, decreased if negative)
3138  //
3139  // If it's not possible to modify the color (e.g. we cannot increase 'white'),
3140  // the color will be modified in the opposite direction. For details see TuneBackground()
3141 
3142  if (color) {
3143  switch (color[0]) {
3144  case '+':
3146  break;
3147  case '-':
3149  break;
3150  default:
3151  set_background(color, w); // use explicit color
3152  }
3153  }
3154  else {
3155  TuneBackground(w, modStrength);
3156  }
3157 }
3158 
3159 void AW_window::TuneBackground(Widget w, int modStrength) {
3160  // Gets the Background Color, modifies the rgb values slightly and sets new background color
3161  // Intended to give buttons a nicer 3D-look.
3162  //
3163  // possible values for modStrength:
3164  //
3165  // 0 = do not modify (i.e. set to background color of parent widget)
3166  // 1 .. 127 = increase if background is bright, decrease if background is dark
3167  // -1 ..-127 = opposite behavior than above
3168  // 256 .. 383 = always increase
3169  // -256 ..-383 = always decrease
3170  //
3171  // if it's impossible to decrease or increase -> opposite direction is used.
3172 
3173  int col[3];
3174  {
3175  Pixel bg;
3176  XtVaGetValues(w, XmNbackground, &bg, NULp);
3177 
3178  XColor xc;
3179  xc.pixel = bg;
3180  XQueryColor(XtDisplay(w), p_global->colormap, &xc);
3181 
3182  col[0] = xc.red >> 8; // take MSB
3183  col[1] = xc.green >> 8;
3184  col[2] = xc.blue >> 8;
3185  }
3186 
3187  int mod = modStrength;
3188  int preferredDir = 0;
3189  bool invertedMod = false;
3190 
3191  if (modStrength>0) {
3192  if (modStrength>255) {
3193  mod -= 256;
3194  preferredDir = 1; // increase preferred
3195  }
3196  }
3197  else {
3198  if (modStrength<-255) {
3199  mod = -modStrength-256;
3200  preferredDir = -1; // decrease preferred
3201  }
3202  else {
3203  invertedMod = true;
3204  mod = -mod;
3205  }
3206  }
3207 
3208  aw_assert(mod >= 0 && mod < 128);
3209  // illegal modification
3210 
3211  bool incPossible[3]; // increment possible for color
3212  bool decPossible[3]; // decrement possible for color
3213  int incs = 0; // count possible increments
3214  int decs = 0; // count possible decrements
3215 
3216  for (int i = 0; i<3; ++i) {
3217  if ((incPossible[i] = ((col[i]+mod) <= 255)))
3218  incs++;
3219  if ((decPossible[i] = ((col[i]-mod) >= 0)))
3220  decs++;
3221  }
3222 
3223  aw_assert(incs||decs);
3224 
3225  switch (preferredDir) {
3226  case 0: // no direction preferred yet, need to decide
3227  if (invertedMod)
3228  preferredDir = decs ? -1 : 1;
3229  else
3230  preferredDir = incs ? 1 : -1;
3231  break;
3232  case 1:
3233  if (!incs)
3234  preferredDir = -1;
3235  break;
3236  case -1:
3237  if (!decs)
3238  preferredDir = 1;
3239  break;
3240  }
3241 
3242  aw_assert(preferredDir == 1 || preferredDir == -1); // no direction chosen above
3243 
3244  if (preferredDir == 1) {
3245  for (int i=0; i<3; ++i) col[i] += (incPossible[i] ? mod : 0);
3246  }
3247  else if (preferredDir == -1) {
3248  for (int i=0; i<3; ++i) col[i] -= (decPossible[i] ? mod : 0);
3249  }
3250 
3251 
3252  char hex_color[50];
3253  sprintf(hex_color, "#%2.2X%2.2X%2.2X", col[0], col[1], col[2]);
3254  aw_assert(strlen(hex_color) == 7);
3255  // otherwise some value overflowed
3256  set_background(hex_color, w);
3257 }
3258 
3260  // Don't call make_sensitive directly!
3261  //
3262  // Simply set sens_mask(AWM_EXP) and after creating the expert-mode-only widgets,
3263  // set it back using sens_mask(AWM_ALL)
3264 
3265  aw_assert(w);
3266  aw_assert(legal_mask(mask));
3267 
3268  prvt->set_last_widget(w);
3269 
3270  if (mask != AWM_ALL) { // no need to make widget sensitive, if its shown unconditionally
3271  button_sens_list = new AW_buttons_struct(mask, w, button_sens_list);
3272  if (!(mask & global_mask)) XtSetSensitive(w, False); // disable widget if mask doesn't match
3273  }
3274 }
3275 
3276 void AW_root::set_active(Widget w, bool active) {
3277  // only use for widgets NOT used with make_sensitive!
3278  // allows local control over widget
3279 
3280  XtSetSensitive(w, active);
3281 }
3282 
3284  aw_assert(w);
3285  aw_assert(legal_mask(maski));
3286 
3287  mask = maski;
3288  button = w;
3289  next = prev_button;
3290 }
3291 
3293  delete next;
3294 }
3295 
3297  bool removed = false;
3298  if (button_sens_list) {
3299  AW_buttons_struct *prev = NULp;
3300  AW_buttons_struct *bl = button_sens_list;
3301 
3302  while (bl) {
3303  if (bl->button == button) break; // found wanted widget
3304  prev = bl;
3305  bl = bl->next;
3306  }
3307 
3308  if (bl) {
3309  // remove from list
3310  if (prev) prev->next = bl->next;
3311  else button_sens_list = bl->next;
3312 
3313  bl->next = NULp;
3314  removed = true;
3315 
3316  delete bl;
3317  }
3318  }
3319  return removed;
3320 }
3321 
3322 AW_option_menu_struct::AW_option_menu_struct(int numberi, const char *variable_namei,
3323  AW_VARIABLE_TYPE variable_typei, Widget label_widgeti,
3324  Widget menu_widgeti, AW_pos xi, AW_pos yi, int correct) {
3325  option_menu_number = numberi;
3326  variable_name = strdup(variable_namei);
3327  variable_type = variable_typei;
3328  label_widget = label_widgeti;
3329  menu_widget = menu_widgeti;
3330  first_choice = NULp;
3331  last_choice = NULp;
3332  default_choice = NULp;
3333  next = NULp;
3334  x = xi;
3335  y = yi;
3336 
3337  correct_for_at_center_intern = correct;
3338 }
3339 
3341  const char *variable_namei, AW_VARIABLE_TYPE variable_typei,
3342  Widget label_widgeti, int correct) {
3343 
3344  toggle_field_number = toggle_field_numberi;
3345  variable_name = strdup(variable_namei);
3346  variable_type = variable_typei;
3347  label_widget = label_widgeti;
3348  first_toggle = NULp;
3349  last_toggle = NULp;
3350  default_toggle = NULp;
3351  next = NULp;
3352  correct_for_at_center_intern = correct;
3353 }
3354 
3356  : shell(NULp),
3357  scroll_bar_vertical(NULp),
3358  scroll_bar_horizontal(NULp),
3359  menu_deep(0),
3360  help_pull_down(NULp),
3361  mode_area(NULp),
3362  number_of_modes(0),
3363  modes_f_callbacks(NULp),
3364  modes_widgets(NULp),
3365  selected_mode(0),
3366  popup_cb(NULp),
3367  frame(NULp),
3368  toggle_field(NULp),
3369  toggle_label(NULp),
3370  toggle_field_var_name(NULp),
3371  toggle_field_var_type(AW_NONE),
3372  keymodifier(AW_KEYMODE_NONE),
3373  WM_top_offset(0),
3374  WM_left_offset(0)
3375 {
3376  for (int i = 0; i<AW_MAX_MENU_DEEP; ++i) {
3377  menu_bar[i] = NULp;
3378  }
3379  for (int i = 0; i<AW_MAX_AREA; ++i) {
3380  areas[i] = NULp;
3381  }
3382 }
3383 
void TuneBackground(Widget w, int modStrength)
Definition: AW_window.cxx:3159
void aw_realize_widget(AW_window *aww)
Definition: AW_window.cxx:2375
AW_widget_value_pair * first_toggle
#define arb_assert(cond)
Definition: arb_assert.h:245
static void aw_window_destroy_cb(Widget, AW_window *aww, XmAnyCallbackStruct *)
Definition: AW_window.cxx:1597
GB_HASH * action_hash
static void horizontal_scrollbar_redefinition_cb(AW_root *, AW_window *aw)
Definition: AW_window.cxx:956
bool is_resize_callback(AW_area area, AnyWinCB f)
Definition: AW_window.cxx:1520
enum AW_root::@65 color_mode
void set_input_callback(AW_window *aww, const WindowCallback &wcb)
Definition: AW_window.cxx:1974
virtual void clear(AW_bitset filteri)
Definition: AW_device.cxx:313
void update_scrollbar_settings_from_awars(AW_orientation orientation)
Definition: AW_window.cxx:2037
AW_device_print * get_print_device(AW_area area)
Definition: AW_window.cxx:547
AW_cb * _callback
Definition: aw_window.hxx:282
const char * GB_ERROR
Definition: arb_core.h:25
AW_bitset AW_active
Definition: aw_base.hxx:45
#define TUNE_BUTTON
Definition: aw_window.hxx:39
Arg * list()
Definition: aw_xargs.hxx:36
void set_resize_callback(AW_area area, const WindowCallback &wcb)
Definition: AW_window.cxx:816
#define AW_CALC_OFFSET_ON_EXPOSE
AW_cb * get_double_click_cb()
AW_active global_mask
Definition: aw_root.hxx:108
#define TUNE_SUBMENU
Definition: aw_window.hxx:41
void set_last_widget(Widget w)
void define_remote_command(class AW_cb *cbs)
Definition: AW_root.cxx:228
char * window_name
Definition: aw_window.hxx:337
#define LAYOUT_AWAR_ROOT
Definition: AW_window.cxx:1192
static void aw_loop_forget_window_geometry(const char *, long val, void *)
Definition: AW_window.cxx:2184
bool is_tracking() const
Definition: aw_root.hxx:179
#define TUNE_DARK
Definition: aw_window.hxx:44
AW_key_mod awmod
Definition: aw_xkey.hxx:12
AW_pos get_scrolled_picture_height() const
Definition: AW_window.cxx:841
void d_callback(const WindowCallback &cb)
Definition: AW_window.cxx:141
void sens_mask(AW_active mask)
Definition: AW_window.cxx:127
AW_device * get_device(AW_area area)
Definition: AW_window.cxx:537
static AW_window * find_or_createAndRegisterWindow(CreateWindowCallback *windowMaker)
Definition: AW_window.cxx:71
GBDATA * GB_child(GBDATA *father)
Definition: adquery.cxx:322
#define implicated(hypothesis, conclusion)
Definition: arb_assert.h:289
const AW_screen_area & get_screen() const
Definition: aw_common.hxx:241
static void AW_exposeCB(Widget, XtPointer aw_cb_struct, XmDrawingAreaCallbackStruct *call_data)
Definition: AW_window.cxx:1476
static char * y[maxsp+1]
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
Definition: adhash.cxx:457
STATIC_ASSERT_ANNOTATED(CopyFromParent==0,"value of CopyFromParent changed. Check use below")
return string(buffer, length)
AW_option_menu_struct * next
bool is_resize_callback(AnyWinCB f)
Definition: AW_window.cxx:1516
Widget menu_bar[AW_MAX_MENU_DEEP]
AW_widget_value_pair * default_choice
void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const WindowCallback &wcb)
Definition: AW_window.cxx:595
GB_HASH * hash_for_windows
Definition: aw_root.hxx:125
bool remove_button_from_sens_list(Widget button)
Definition: AW_window.cxx:3296
void load_xfig(const char *file, bool resize=true)
Definition: AW_window.cxx:720
AW_awar * label_is_awar(const char *label)
Definition: AW_root.cxx:218
const char * get_window_id() const
Definition: aw_window.hxx:366
#define TUNE_BRIGHT
Definition: aw_window.hxx:43
void set_popup_callback(const WindowCallback &wcb)
Definition: AW_window.cxx:792
void update_label(Widget widget, const char *var_value)
Definition: AW_button.cxx:740
#define ASSERT_NO_ERROR(errorExpr)
Definition: arb_assert.h:360
static void drag_scroll_bar_horizontal(Widget, XtPointer aw_cb_struct, XtPointer call_data)
Definition: AW_window.cxx:1026
const char * GBS_global_string_to_buffer(char *buffer, size_t bufsize, const char *templat,...)
Definition: arb_msg.cxx:177
void reset_scrolled_picture_size()
Definition: AW_window.cxx:845
void run_expose_callback()
Definition: AW_window.cxx:1472
virtual ~AW_window()
Definition: AW_window.cxx:1120
void on_hide(const WindowCallback &call_on_hide)
Definition: AW_window.cxx:1837
void set_vertical_scrollbar_top_indent(int indent)
Definition: AW_window.cxx:852
void _set_activate_callback(void *widget)
Definition: AW_window.cxx:3092
#define FALSE
Definition: defs.h:21
int max_y_size
Definition: aw_at.hxx:36
#define WIDER_THAN_SCREEN
Definition: aw_at.hxx:11
long
Definition: AW_awar.cxx:152
AW_ScalerType
Definition: aw_window.hxx:223
static void aw_loop_get_window_geometry(const char *, long val, void *)
Definition: AW_window.cxx:2177
static long destroy_awar(const char *, long val, void *)
Definition: AW_window.cxx:2008
static int WM_max_left_offset
#define MAP_ARAM(ar)
void add(int v)
Definition: ClustalV.cxx:461
void set_window_title_intern(char *title)
Definition: AW_window.cxx:1065
#define aw_awar_name_posx(aww)
Definition: AW_window.cxx:1209
AW_window * current_modal_window
Definition: aw_root.hxx:115
AW_VARIABLE_TYPE variable_type
Definition: aw_awar.hxx:102
AW_window * aw
Definition: aw_window.hxx:128
int maxx
Definition: aw_xfig.hxx:86
#define BUFSIZE
Definition: AW_window.cxx:1193
short shadow_thickness
Definition: aw_at.hxx:20
long read_int() const
Definition: AW_awar.cxx:184
AW_screen_area * picture
Definition: aw_window.hxx:345
long color_table_size
Definition: aw_window.hxx:278
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:202
void warning(int warning_num, const char *warning_message)
Definition: util.cxx:61
AW_SizeRecalc
Definition: aw_window.hxx:209
const char * title
Definition: readseq.c:22
void get_scrollarea_size(AW_screen_area *square)
Definition: AW_window.cxx:867
void GBK_terminatef(const char *templat,...)
Definition: arb_msg.cxx:464
void set_background(const char *colorname, Widget w)
Definition: AW_window.cxx:3106
void init(AW_root *root_in, const char *wid, const char *windowname, bool allow_close)
Definition: AW_window.cxx:2910
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
void allow_delete_window(bool allow_close)
Definition: AW_window.cxx:1630
char * id
Definition: aw_window.hxx:130
AW_root_Motif * prvt
Definition: aw_root.hxx:104
AW_area_management(Widget form, Widget widget)
Definition: AW_window.cxx:3013
void GBS_free_hash(GB_HASH *hs)
Definition: adhash.cxx:541
AW_color_idx
Definition: aw_base.hxx:83
Definition: aw_at.hxx:18
char * GBS_string_2_key(const char *str)
Definition: adstring.cxx:52
#define TUNE_MENUTOPIC
Definition: aw_window.hxx:42
#define aw_awar_name_width(aww)
Definition: AW_window.cxx:1211
void add_timed_callback(int ms, const TimedCallback &tcb)
Definition: AW_root.cxx:538
void _get_area_size(AW_area area, AW_screen_area *square)
Definition: AW_window.cxx:862
AW_pos get_scrolled_picture_width() const
Definition: AW_window.cxx:837
void wm_activate()
Definition: AW_window.cxx:3039
void set_offset(const AW::Vector &off)
Definition: aw_device.hxx:130
const AW_bitset AW_ALL_DEVICES
Definition: aw_device.hxx:44
char * window_defaults_name
window title
Definition: aw_window.hxx:338
#define EXIT_SUCCESS
Definition: arb_a2ps.c:154
int slider_pos_horizontal
current position of the vertical slider
Definition: aw_window.hxx:341
#define BOTTOM_WIDGET
short height_of_buttons
Definition: aw_at.hxx:22
static void aw_window_avoid_destroy_cb(Widget, AW_window *, XmAnyCallbackStruct *)
Definition: AW_window.cxx:1590
void set_window_title(const char *title)
Definition: AW_window.cxx:1069
char * program_name
Definition: aw_root.hxx:113
static Pixmap getIcon(Screen *screen, const char *iconName, Pixel foreground, Pixel background)
Definition: AW_window.cxx:2220
const char * AW_get_pixmapPath(const char *pixmapName)
Definition: AW_button.cxx:266
unsigned long time
Definition: aw_window.hxx:82
bool is_focus_callback(AnyWinCB f)
Definition: AW_window.cxx:1456
char buffer[MESSAGE_BUFFERSIZE]
Definition: seq_search.cxx:34
static void AW_xfigCB_info_area(AW_window *aww, AW_xfig *xfig)
Definition: AW_window.cxx:703
void activate()
Definition: aw_window.hxx:356
XmFontList fontlist
#define cb(action)
char character
Definition: aw_window.hxx:91
void set_motion_callback(AW_area area, const WindowCallback &wcb)
Definition: AW_window.cxx:811
AW_device_size * get_size_device(AW_area area)
Definition: AW_window.cxx:552
AW_widget_value_pair * first_choice
AW_common * get_common(AW_area area)
Definition: AW_window.cxx:564
#define MAXNAMELEN
AW_area
Definition: aw_base.hxx:76
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:231
GB_ERROR GB_delete(GBDATA *&source)
Definition: arbdb.cxx:1916
static void AW_inputCB_draw_area(Widget wgt, XtPointer aw_cb_struct, XmDrawingAreaCallbackStruct *call_data)
Definition: AW_window.cxx:1864
void create_window_variables()
Definition: AW_window.cxx:977
bool AW_IS_IMAGEREF(const char *label)
Definition: aw_localdef.hxx:13
const char * window_local_awarname(const char *localname, bool tmp=true)
Definition: AW_window.cxx:964
POS_TREE1 * father
Definition: probe_tree.h:39
static void value_changed_scroll_bar_vertical(Widget, XtPointer aw_cb_struct, XtPointer call_data)
Definition: AW_window.cxx:1007
#define SmartCustomPtr(type, deallocator)
Definition: smartptr.h:46
GB_HASH * hash_table_for_variables
Definition: aw_root.hxx:110
int create_mode(const char *pixmap, const char *help_text_, AW_active mask, const WindowCallback &cb)
Definition: AW_window.cxx:2973
static AW_root * SINGLETON
Definition: aw_root.hxx:102
void show()
Definition: AW_window.cxx:1670
double AW_pos
Definition: aw_base.hxx:29
AW_buttons_struct(AW_active maski, Widget w, AW_buttons_struct *next)
Definition: AW_window.cxx:3283
static unsigned timed_window_title_cb(AW_root *, char *title, AW_window *aw)
Definition: AW_window.cxx:221
const char * help_text
Definition: aw_window.hxx:129
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
Widget get_area() const
char * ARB_strduplen(const char *p, unsigned len)
Definition: arb_string.h:33
static int WM_max_top_offset
#define p_aww(aww)
bool contains(AnyWinCB g)
short font_height
Definition: aw_root.hxx:123
TYPE * ARB_alloc(size_t nelem)
Definition: arb_mem.h:56
bool highlight
Definition: aw_at.hxx:24
GB_CSTR GB_read_key_pntr(GBDATA *gbd)
Definition: arbdb.cxx:1656
bool is_expose_callback(AW_area area, AnyWinCB f)
Definition: AW_window.cxx:1497
Widget scroll_bar_horizontal
static const char * aw_size_awar_name(AW_window *aww, const char *sub_entry)
Definition: AW_window.cxx:1195
AW_VARIABLE_TYPE
Definition: aw_base.hxx:53
int miny
Definition: aw_xfig.hxx:85
AW_pos l
Definition: aw_base.hxx:32
void create_devices()
Definition: AW_window.cxx:2111
#define RES_LABEL_CONVERT(label)
void get_event(AW_event *eventi) const
Definition: AW_window.cxx:543
AW_MouseButton
Definition: aw_window.hxx:70
void set_double_click_callback(AW_area area, const WindowCallback &wcb)
Definition: AW_window.cxx:1984
void recalc_size_atShow(enum AW_SizeRecalc sr)
Definition: AW_window.cxx:1439
float scaler2awar(float scaler, AW_awar *awar)
Definition: AW_window.cxx:188
AW_default check_properties(AW_default aw_props)
Definition: aw_root.hxx:162
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
Definition: adhash.cxx:562
void force_expose()
Definition: AW_window.cxx:1502
void create_devices(AW_window *aww, AW_area ar)
Definition: AW_window.cxx:2053
AW_cb * _d_callback
Definition: aw_window.hxx:283
void set_double_click_callback(AW_window *aww, const WindowCallback &wcb)
Definition: AW_window.cxx:1980
AW_cb ** modes_f_callbacks
Display * get_display() const
static unsigned aw_calc_WM_offsets_delayed(AW_root *, AW_window *aww)
Definition: AW_window.cxx:1260
void calculate_scrollbars()
Definition: AW_window.cxx:873
#define MIDDLE_WIDGET
#define aw_assert(bed)
Definition: aw_position.hxx:29
AW_device_click * get_click_device(AW_area area, int mousex, int mousey, int max_distance)
Definition: AW_window.cxx:526
#define false
Definition: ureadseq.h:13
char * helptext_for_next_button
Definition: aw_at.hxx:26
float get_max() const
Definition: AW_awar.cxx:555
void show_modal()
Definition: AW_window.cxx:1816
const char * get_window_title() const
Definition: AW_window.cxx:1074
AW_root * root
Definition: aw_window.hxx:265
#define legal_mask(m)
Definition: aw_root.hxx:25
static double xi
void set_expose_callback(AW_area area, const WindowCallback &wcb)
Definition: AW_window.cxx:765
void create_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
Definition: AW_window.cxx:472
int number_of_timed_title_changes
Definition: aw_window.hxx:280
int yoffset_for_mode_button(int button_number)
Definition: AW_window.cxx:2969
void help_text(const char *id)
Definition: AW_window.cxx:116
AW_buttons_struct * next
static void error(const char *msg)
Definition: mkptypes.cxx:96
AW_event event
Definition: aw_window.hxx:276
void init(AW_root *root, const char *wid, const char *windowname, int width, int height)
Definition: AW_window.cxx:2389
void set_active(Widget w, bool active)
Definition: AW_window.cxx:3276
const char * mnemonic
fputc('\n', stderr)
AW_device_click * get_click_device()
Definition: AW_window.cxx:3034
void message(char *title, int ms)
Definition: AW_window.cxx:231
AW_toggle_field_struct * next
bool knows_WM_offset() const
AW_area_management * areas[AW_MAX_AREA]
static void vertical_scrollbar_redefinition_cb(AW_root *, AW_window *aw)
Definition: AW_window.cxx:960
void label(const char *label)
Definition: AW_window.cxx:102
void insert_help_topic(const char *labeli, const char *mnemonic, const char *helpText, AW_active mask, const WindowCallback &cb)
Definition: AW_window.cxx:569
static void value_changed_scroll_bar_horizontal(Widget, XtPointer aw_cb_struct, XtPointer call_data)
Definition: AW_window.cxx:1013
short font_width
Definition: aw_root.hxx:122
char * read_as_string() const
AW_VARIABLE_TYPE variable_type
void window_show()
Definition: AW_root.cxx:486
bool focus_follows_mouse
Definition: aw_root.hxx:109
bool window_is_shown
current position of the horizontal slider
Definition: aw_window.hxx:343
void TuneOrSetBackground(Widget w, const char *color, int modStrength)
Definition: AW_window.cxx:3128
#define NOWINWARN()
Definition: AW_window.cxx:64
GB_ERROR reset_to_default()
Definition: AW_awar.cxx:214
#define INFO_WIDGET
int max_x_size
Definition: aw_at.hxx:35
#define HIGHER_THAN_SCREEN
Definition: aw_at.hxx:12
Widget scroll_bar_vertical
AW_device_Xm * get_screen_device()
Definition: AW_window.cxx:3019
static Display * dpy
Label(const char *labeltext, AW_window *aww)
Definition: AW_window.cxx:2137
AW_orientation
Definition: aw_window.hxx:51
float awar2scaler(AW_awar *awar)
Definition: AW_window.cxx:197
const awXKeymap * aw_xkey_2_awkey(XKeyEvent *xkeyevent)
Definition: AW_xkey.cxx:196
static void aw_onExpose_calc_WM_offsets(AW_window *aww)
Definition: AW_window.cxx:1262
AW_pos r
Definition: aw_base.hxx:32
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
const int AW_NUMBER_OF_F_KEYS
void insert_sub_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
Definition: AW_window.cxx:645
AW_key_code keycode
Definition: aw_window.hxx:90
void window_fit()
Definition: AW_window.cxx:1086
AW_key_mod keymodifier
Definition: aw_window.hxx:83
Definition: arbdb.h:86
float get_min() const
Definition: AW_awar.cxx:544
void button_height(int height)
Definition: AW_window.cxx:1082
char * ARB_strupper(char *s)
Definition: arb_str.h:63
static void AW_motionCB(Widget, XtPointer aw_cb_struct, XEvent *ev, Boolean *)
Definition: AW_window.cxx:1994
static void aw_window_noexit_destroy_cb(Widget, AW_window *aww, XmAnyCallbackStruct *)
Definition: AW_window.cxx:1593
void create_user_geometry_awars(int posx, int posy, int width, int height)
Definition: AW_window.cxx:1214
void GBS_hash_do_loop(GB_HASH *hs, gb_hash_loop_type func, void *client_data)
Definition: adhash.cxx:548
void set_horizontal_scrollbar_left_indent(int indent)
Definition: AW_window.cxx:857
float read_float() const
Definition: AW_awar.cxx:177
AW_active widget_mask
Definition: aw_at.hxx:27
static const char * existingPixmap(const char *icon_relpath, const char *name)
Definition: AW_window.cxx:2210
int maxy
Definition: aw_xfig.hxx:86
AW_rgb * color_table
AW_pos b
Definition: aw_base.hxx:32
Widget aw_create_shell(AW_window *aww, bool allow_resize, bool allow_close, int width, int height, int posx, int posy)
Definition: AW_window.cxx:2245
WindowCallbackSimple AnyWinCB
Definition: aw_window.hxx:115
#define RES_CONVERT(res_name, res_value)
bool is_expose_callback(AnyWinCB f)
Definition: AW_window.cxx:1493
class AW_awar * window_local_awar(const char *localname, bool tmp=true)
Definition: AW_window.cxx:973
AW_PosRecalc
Definition: aw_window.hxx:216
void set_click_time(long click_time_)
void tell_scrolled_picture_size(AW_screen_area rectangle)
Definition: AW_window.cxx:823
bool aw_ask_sure(const char *unique_id, const char *msg)
static void set_focus_policy(const char *, long cl_aww, void *)
Definition: AW_root.cxx:251
void normal_cursor()
Definition: AW_window.cxx:1382
Widget * modes_widgets
void set_info_area_height(int height)
Definition: AW_window.cxx:796
AW_widget_value_pair * last_toggle
#define p_global
fputs(TRACE_PREFIX, stderr)
AW_rgb * color_table
Definition: aw_window.hxx:279
void create_gcs(AW_device *device, int screen_depth)
Definition: AW_xfig.cxx:504
AW_event_type type
Definition: aw_window.hxx:81
unsigned long int background_color
Definition: aw_at.hxx:29
void set_bottom_area_height(int height)
Definition: AW_window.cxx:801
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:580
AW_window_Motif * p_w
Definition: aw_window.hxx:281
TYPE * ARB_calloc(size_t nelem)
Definition: arb_mem.h:81
void draw_line(int x1, int y1, int x2, int y2, int width, bool resize)
Definition: AW_window.cxx:512
static void drag_scroll_bar_vertical(Widget, XtPointer aw_cb_struct, XtPointer call_data)
Definition: AW_window.cxx:1020
void AW_help_entry_pressed(AW_window *aww)
Definition: AW_root.cxx:37
void set_focus_callback(const WindowCallback &wcb)
Definition: AW_window.cxx:778
void AW_forget_all_window_geometry(AW_window *aww)
Definition: AW_window.cxx:2187
AW_option_menu_struct(int numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, Widget menu_widgeti, AW_pos xi, AW_pos yi, int correct)
Definition: AW_window.cxx:3322
AW_device_size * get_size_device()
Definition: AW_window.cxx:3024
Definition: output.h:122
static float apply_ScalerType(float val, AW_ScalerType scalerType, bool inverse)
Definition: AW_window.cxx:152
AW_pos t
Definition: aw_base.hxx:32
void set_resize_callback(AW_window *aww, const WindowCallback &cb)
Definition: AW_window.cxx:1851
AW_MouseButton button
Definition: aw_window.hxx:86
void run_resize_callback()
Definition: AW_window.cxx:1841
#define AW_SCROLL_MAX
void ARB_realloc(TYPE *&tgt, size_t nelem)
Definition: arb_mem.h:43
void make_sensitive(Widget w, AW_active mask)
Definition: AW_window.cxx:3259
void recalc_pos_atShow(AW_PosRecalc pr)
Definition: AW_window.cxx:1431
void set_horizontal_scrollbar_position(int position)
Definition: AW_window.cxx:998
void reset()
Definition: AW_device.cxx:280
char * strdup_getlen(const char *str, int &len)
Definition: AW_window.cxx:2133
void close_sub_menu()
Definition: AW_window.cxx:486
static ARB_init_perl_interface init
Definition: ARB_ext.c:101
bool is_shown() const
Definition: AW_window.cxx:1634
static void AW_resizeCB_draw_area(Widget, XtPointer aw_cb_struct, XtPointer)
Definition: AW_window.cxx:1845
AW_device_print * get_print_device()
Definition: AW_window.cxx:3029
void aw_message(const char *msg)
Definition: AW_status.cxx:1142
void hide()
Definition: AW_window.cxx:1822
void select_mode(int mode)
Definition: AW_window.cxx:2952
void highlight()
Definition: AW_window.cxx:122
AW_root * get_root()
Definition: aw_window.hxx:350
AW_common_Xm * get_common() const
Display * old_cursor_display
long get_click_time() const
void add_line(int x1, int y1, int x2, int y2, int width)
Definition: AW_xfig.cxx:533
static int is_resize_event(Display *display, XEvent *event, XPointer)
Definition: AW_window.cxx:1565
#define NULp
Definition: cxxforward.h:114
bool GB_is_regularfile(const char *path)
Definition: arb_file.cxx:76
AW_key_mod
Definition: aw_keysym.hxx:46
char * label_for_inputfield
Definition: aw_at.hxx:31
static void aw_mode_callback(AW_window *aww, short mode, AW_cb *cbs)
Definition: AW_window.cxx:2963
int size()
Definition: aw_xargs.hxx:37
Window old_cursor_window
void init(AW_root *root, const char *wid, const char *windowname, int width, int height)
Definition: AW_window.cxx:2599
void AW_help_popup(UNFIXED, const char *help_file)
Definition: AW_help.cxx:628
AW_VARIABLE_TYPE variable_type
void run_focus_callback()
Definition: AW_window.cxx:1452
void sep______________()
Definition: AW_window.cxx:753
void aw_uninstall_xkeys()
Definition: AW_xkey.cxx:178
void set_vertical_scrollbar_position(int position)
Definition: AW_window.cxx:989
AW_toggle_field_struct(int toggle_field_numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, int correct)
Definition: AW_window.cxx:3340
void AW_label_in_awar_list(AW_window *aww, Widget widget, const char *str)
Definition: AW_window.cxx:2159
const char * local_id(const char *id) const
Definition: AW_window.cxx:747
void set_cursor(Display *d, Window w, Cursor c)
Definition: AW_window.cxx:1364
#define AW_NO_COLOR
Definition: aw_base.hxx:50
#define aw_awar_name_posy(aww)
Definition: AW_window.cxx:1210
void AW_server_callback(Widget, XtPointer aw_cb_struct, XtPointer)
Definition: AW_window.cxx:1386
GBDATA * GB_nextChild(GBDATA *child)
Definition: adquery.cxx:326
#define AW_MAX_MENU_DEEP
AW_PosRecalc get_recalc_pos_atShow() const
Definition: AW_window.cxx:1435
GB_transaction ta(gb_var)
void run_callbacks()
void callback(const WindowCallback &cb)
Definition: AW_window.cxx:133
void set_horizontal_change_callback(const WindowCallback &wcb)
Definition: AW_window.cxx:1049
void set_vertical_change_callback(const WindowCallback &wcb)
Definition: AW_window.cxx:1033
static void aw_update_window_geometry_awars(AW_window *aww)
Definition: AW_window.cxx:1640
void run_popup_callbacks()
Definition: AW_window.cxx:1463
void aw_insert_default_help_entries(AW_window *aww)
Definition: AW_window.cxx:2126
void print(AW_device *device)
Definition: AW_xfig.cxx:461
bool GBS_string_matches(const char *str, const char *expr, GB_CASE case_sens)
Definition: admatch.cxx:193
#define MODE_BUTTON_OFFSET
Definition: AW_window.cxx:2968
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
Definition: adquery.cxx:531
void hide_or_notify(const char *error)
Definition: AW_window.cxx:1832
void shadow_width(int shadow_thickness)
Definition: AW_window.cxx:1078
void set_expose_callback(AW_window *aww, const WindowCallback &cb)
Definition: AW_window.cxx:1484
static void aw_set_delete_window_cb(AW_window *aww, Widget shell, bool allow_close)
Definition: AW_window.cxx:1608
#define aw_awar_name_height(aww)
Definition: AW_window.cxx:1212
int slider_pos_vertical
window id
Definition: aw_window.hxx:340
void add(String name, XtArgVal value)
Definition: aw_xargs.hxx:39
static void cleanupResizeEvents(Display *display)
Definition: AW_window.cxx:1574
void set_motion_callback(AW_window *aww, const WindowCallback &wcb)
Definition: AW_window.cxx:2004
int minx
Definition: aw_xfig.hxx:85
AW_key_code awkey
Definition: aw_xkey.hxx:13
#define CopyFromParent_AsPtr
Definition: AW_window.cxx:2243
#define CONSTEXPR
Definition: cxxforward.h:106
void aw_update_all_window_geometry_awars(AW_root *awr)
Definition: AW_window.cxx:2180
static void AW_focusCB(Widget, XtPointer cl_aww, XEvent *, Boolean *)
Definition: AW_window.cxx:770
void set_input_callback(AW_area area, const WindowCallback &wcb)
Definition: AW_window.cxx:806
GB_ERROR write_int(long aw_int)
char * awstr
Definition: aw_xkey.hxx:14
struct _WidgetRec * Widget
Definition: aw_base.hxx:48
long GBS_read_hash(const GB_HASH *hs, const char *key)
Definition: adhash.cxx:395
AW_color_idx alloc_named_data_color(int colnum, const char *colorname)
Definition: AW_window.cxx:2058
void window_hide(AW_window *aww)
Definition: AW_root.cxx:477
void get_window_size(int &width, int &height)
Definition: AW_window.cxx:109
void init(AW_root *root, const char *wid, const char *windowname)
Definition: AW_window.cxx:2832
void aw_message_if(GB_ERROR error)
Definition: aw_msg.hxx:21
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:193
void GB_close(GBDATA *gbd)
Definition: arbdb.cxx:655
static char aw_size_awar_name_buffer[BUFSIZE]
Definition: AW_window.cxx:1194
void tie_widget(AW_CL cd1, Widget widget, AW_widget_type type, AW_window *aww)
Definition: AW_awar.cxx:257
AW_widget_value_pair * default_toggle
void track_action(const char *action_id)
Definition: aw_root.hxx:176
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
Definition: adhash.cxx:253
AW_widget_value_pair * last_choice
#define max(a, b)
Definition: f2c.h:154