ARB
aw_varupdate.hxx
Go to the documentation of this file.
1 // ============================================================== //
2 // //
3 // File : aw_varupdate.hxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // ============================================================== //
10 
11 #ifndef AW_VARUPDATE_HXX
12 #define AW_VARUPDATE_HXX
13 
14 #if defined(DEBUG)
15 // #define DUMP_BUTTON_CREATION
16 #endif // DEBUG
17 
18 class VarUpdateInfo : virtual Noncopyable { // used to refresh single items on change
19  AW_window *aw_parent;
20  Widget widget;
21  AW_widget_type widget_type;
22  AW_awar *awar;
23  AW_scalar value;
24  AW_cb *cbs;
25 
26  union TS { // AW_widget_type-specific
27  AW_selection_list *sellist; // only used for AW_WIDGET_SELECTION_LIST
28  AW_ScalerType scalerType; // only used for AW_WIDGET_SCALER
29  TS() : sellist(NULp) {}
30  } ts;
31 
32  void check_unwanted_callback() {
33 #if defined(DEVEL_RALF)
34  if (cbs) {
35  fprintf(stderr, "Warning: Unwanted user-callback bound to VarUpdateInfo. Should be rewritten using an awar-callback\n");
36  }
37  // aw_assert(!cbs); // @@@ generally unwanted (see #559)
38  // @@@ if this assertion stops failing -> remove cbs from VarUpdateInfo!
39 #endif
40 #if defined(ASSERTION_USED)
41  if (cbs) {
42  aw_assert(widget_type != AW_WIDGET_SELECTION_LIST); // binding callbacks to selection lists is obsolete (see #559)
43  }
44 #endif
45  }
46 
47 public:
49  : aw_parent(aw),
50  widget(w),
51  widget_type(wtype),
52  awar(a),
53  value(a),
54  cbs(cbs_)
55  {
56  check_unwanted_callback();
57  }
58  template<typename T>
60  : aw_parent(aw),
61  widget(w),
62  widget_type(wtype),
63  awar(a),
64  value(t),
65  cbs(cbs_)
66  {
67  check_unwanted_callback();
68  }
69 
70  void change_from_widget(XtPointer call_data);
71 
72  void set_widget(Widget w) { widget = w; }
73 
75  aw_assert(widget_type == AW_WIDGET_SELECTION_LIST);
76  ts.sellist = asl;
77  }
78  void set_scalerType(AW_ScalerType scalerType_) {
79  aw_assert(widget_type == AW_WIDGET_SCALER);
80  ts.scalerType = scalerType_;
81  }
82 
83  AW_awar *get_awar() { return awar; }
84 };
85 
86 #define SPACE_BEHIND_BUTTON 3
87 
88 void AW_variable_update_callback(Widget /*wgt*/, XtPointer variable_update_struct, XtPointer call_data);
89 void aw_attach_widget(Widget w, AW_at *_at, int default_width = -1);
90 
91 #else
92 #error aw_varupdate.hxx included twice
93 #endif // AW_VARUPDATE_HXX
void change_from_widget(XtPointer call_data)
Definition: AW_button.cxx:85
AW_ScalerType
Definition: aw_window.hxx:223
Definition: aw_at.hxx:18
#define aw_assert(bed)
Definition: aw_position.hxx:29
void aw_attach_widget(Widget w, AW_at *_at, int default_width=-1)
Definition: AW_button.cxx:186
void AW_variable_update_callback(Widget, XtPointer variable_update_struct, XtPointer call_data)
Definition: AW_button.cxx:34
AW_awar * get_awar()
VarUpdateInfo(AW_window *aw, Widget w, AW_widget_type wtype, AW_awar *a, AW_cb *cbs_)
void set_scalerType(AW_ScalerType scalerType_)
#define NULp
Definition: cxxforward.h:97
AW_widget_type
Definition: aw_awar.hxx:41
Definition: trnsprob.h:20
void set_widget(Widget w)
VarUpdateInfo(AW_window *aw, Widget w, AW_widget_type wtype, AW_awar *a, T t, AW_cb *cbs_)
struct _WidgetRec * Widget
Definition: aw_base.hxx:48
void set_sellist(AW_selection_list *asl)