source: tags/arb-7.0/AWT/awt_modules.hxx

Last change on this file was 16986, checked in by westram, 7 years ago

Update: continued by [17178]

File size: 2.6 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    // implementation uses untyped (casted) callbacks:
41    void awt_create_order_buttons(AW_window *aws, awt_orderfun reorder_cb, AW_CL cl_user);
42    void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, awt_collectfun collect_cb, AW_CL cl_user);
43};
44
45// provide interface with typed callbacks:
46template<typename T>
47inline void awt_create_order_buttons(AW_window *aws, void (*reorder_cb)(AW_window*, awt_reorder_mode, T), T t) {
48    disallow_type<T, AW_CL>::here();
49    UNTYPED::awt_create_order_buttons(aws, CASTSIG(UNTYPED::awt_orderfun, reorder_cb), AW_CL(t));
50}
51inline void awt_create_order_buttons(AW_window *aws, void (*reorder_cb)(AW_window*, awt_reorder_mode)) {
52    UNTYPED::awt_create_order_buttons(aws, CASTSIG(UNTYPED::awt_orderfun, reorder_cb), 0);
53}
54
55
56template<typename T>
57inline void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, void (*collect_cb)(AW_window*, awt_collect_mode, T), T t) {
58    disallow_type<T, AW_CL>::here();
59    UNTYPED::awt_create_collect_buttons(aws, collect_rightwards, CASTSIG(UNTYPED::awt_collectfun, collect_cb), AW_CL(t));
60}
61inline void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, void (*collect_cb)(AW_window*, awt_collect_mode)) {
62    UNTYPED::awt_create_collect_buttons(aws, collect_rightwards, CASTSIG(UNTYPED::awt_collectfun, collect_cb), 0);
63}
64
65
66#else
67#error awt_modules.hxx included twice
68#endif // AWT_MODULES_HXX
Note: See TracBrowser for help on using the repository browser.