| 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 |  | 
|---|
| 22 | enum awt_reorder_mode { | 
|---|
| 23 | ARM_TOP, | 
|---|
| 24 | ARM_UP, | 
|---|
| 25 | ARM_DOWN, | 
|---|
| 26 | ARM_BOTTOM, | 
|---|
| 27 | }; | 
|---|
| 28 |  | 
|---|
| 29 | enum awt_collect_mode { | 
|---|
| 30 | ACM_ADD, | 
|---|
| 31 | ACM_FILL, // aka "add all" | 
|---|
| 32 | ACM_REMOVE, | 
|---|
| 33 | ACM_EMPTY, | 
|---|
| 34 | }; | 
|---|
| 35 |  | 
|---|
| 36 | namespace 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: | 
|---|
| 46 | template<typename T> | 
|---|
| 47 | inline 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 | } | 
|---|
| 51 | inline 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 |  | 
|---|
| 56 | template<typename T> | 
|---|
| 57 | inline 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 | } | 
|---|
| 61 | inline 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 | 
|---|