source: tags/ms_r16q3/AWT/awt_modules.hxx

Last change on this file was 14451, checked in by westram, 8 years ago
  • use typed callbacks (partial binding)
    • move untyped code into namespace UNTYPED
    • added template wrappers (doing the type checks)
    • added template-helper-struct disallow_type
  • revealed wrong enum-types used in awt_create_collect_buttons
File size: 2.5 KB
Line 
1// ============================================================= //
2//                                                               //
3//   File      : awt_modules.hxx                                 //
4//   Purpose   : small modules for GUI construction              //
5//                                                               //
6//   Coded by Ralf Westram (coder@reallysoft.de) in April 2012   //
7//   Institute of Microbiology (Technical University Munich)     //
8//   http://www.arb-home.de/                                     //
9//                                                               //
10// ============================================================= //
11
12#ifndef AWT_MODULES_HXX
13#define AWT_MODULES_HXX
14
15#ifndef AW_BASE_HXX
16#include <aw_base.hxx>
17#endif
18#ifndef ARBTOOLS_H
19#include <arbtools.h>
20#endif
21
22enum awt_reorder_mode {
23    ARM_TOP, 
24    ARM_UP, 
25    ARM_DOWN, 
26    ARM_BOTTOM, 
27};
28
29enum awt_collect_mode {
30    ACM_ADD, 
31    ACM_FILL, // aka "add all"
32    ACM_REMOVE, 
33    ACM_EMPTY, 
34};
35
36namespace UNTYPED {
37    typedef void(*awt_orderfun)  (AW_window *aww, awt_reorder_mode pos,  AW_CL cl_user);
38    typedef void(*awt_collectfun)(AW_window *aww, awt_collect_mode what, AW_CL cl_user);
39
40    void awt_create_order_buttons(AW_window *aws, awt_orderfun reorder_cb, AW_CL cl_user);
41    void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, awt_collectfun collect_cb, AW_CL cl_user);
42};
43
44template<typename T>
45inline void awt_create_order_buttons(AW_window *aws, void (*reorder_cb)(AW_window*, awt_reorder_mode, T), T t) {
46    disallow_type<T, AW_CL>::here();
47    UNTYPED::awt_create_order_buttons(aws, (UNTYPED::awt_orderfun)reorder_cb, AW_CL(t));
48}
49inline void awt_create_order_buttons(AW_window *aws, void (*reorder_cb)(AW_window*, awt_reorder_mode)) {
50    UNTYPED::awt_create_order_buttons(aws, (UNTYPED::awt_orderfun)reorder_cb, 0);
51}
52
53
54template<typename T>
55inline void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, void (*collect_cb)(AW_window*, awt_collect_mode, T), T t) {
56    disallow_type<T, AW_CL>::here();
57    UNTYPED::awt_create_collect_buttons(aws, collect_rightwards, (UNTYPED::awt_collectfun)collect_cb, AW_CL(t));
58}
59inline void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, void (*collect_cb)(AW_window*, awt_collect_mode)) {
60    UNTYPED::awt_create_collect_buttons(aws, collect_rightwards, (UNTYPED::awt_collectfun)collect_cb, 0);
61}
62
63
64#else
65#error awt_modules.hxx included twice
66#endif // AWT_MODULES_HXX
Note: See TracBrowser for help on using the repository browser.