source: tags/ms_r16q2/WINDOW/aw_varupdate.hxx

Last change on this file was 14737, checked in by westram, 8 years ago
  • add an assertion against callbacks bound to selection lists
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
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
18class 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(NULL) {}
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
47public:
48    VarUpdateInfo(AW_window *aw, Widget w, AW_widget_type wtype, AW_awar *a, AW_cb *cbs_)
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>
59    VarUpdateInfo(AW_window *aw, Widget w, AW_widget_type wtype, AW_awar *a, T t, AW_cb *cbs_)
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
74    void set_sellist(AW_selection_list *asl) {
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
88void AW_variable_update_callback(Widget /*wgt*/, XtPointer variable_update_struct, XtPointer call_data);
89void 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
Note: See TracBrowser for help on using the repository browser.