source: tags/old_import_filter/WINDOW/aw_nawar.hxx

Last change on this file was 8447, checked in by westram, 12 years ago
  • added function to test for global/window-local focus-callbacks
    • handle window-local focus-callbacks in a list
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : aw_nawar.hxx                                      //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef AW_NAWAR_HXX
12#define AW_NAWAR_HXX
13
14#ifndef CB_H
15#include <cb.h>
16#endif
17#ifndef _GLIBCXX_CSTDDEF
18#include <cstddef>
19#endif
20#ifndef ARBTOOLS_H
21#include <arbtools.h>
22#endif
23
24class AW_root_callback {
25    AW_RCB cb;
26    AW_CL  cd1;
27    AW_CL  cd2;
28public:
29    AW_root_callback(AW_RCB cb_, AW_CL cd1_, AW_CL cd2_) : cb(cb_), cd1(cd1_), cd2(cd2_) {}
30
31    void call(AW_root *root) const { cb(root, cd1, cd2); }
32    bool equals(const AW_root_callback& other) const {
33        return cb == other.cb && cd1 == other.cd1 && cd2 == other.cd2;
34    }
35};
36
37inline bool operator == (const AW_root_callback& cb1, const AW_root_callback& cb2) { return cb1.equals(cb2); }
38
39class AW_root_cblist : virtual Noncopyable {
40    AW_root_callback  callback;
41    AW_root_cblist   *next;
42
43    AW_root_cblist(AW_root_cblist *next_, const AW_root_callback& cb) : callback(cb), next(next_) {}
44    ~AW_root_cblist() { delete next; }
45
46    AW_root_cblist *unlink(const AW_root_callback& cb, AW_root_cblist*& found) {
47        if (callback == cb) {
48            AW_root_cblist *rest = next;
49           
50            found = this;
51            next  = NULL;
52
53            return rest;
54        }
55
56        if (next) next = next->unlink(cb, found);
57        return this;
58    }
59
60    void call(AW_root *root) {          // runs the whole list in FIFO order
61        if (next) next->call(root);
62        callback.call(root);
63    }
64   
65public:
66
67    static void add(AW_root_cblist*& listhead, const AW_root_callback& cb) {
68        remove(listhead, cb); // first remove duplicated callbacks
69        listhead = new AW_root_cblist(listhead, cb);
70    }
71    static void remove(AW_root_cblist*& listhead, const AW_root_callback& cb) {
72        AW_root_cblist *found = NULL;
73        if (listhead) listhead = listhead->unlink(cb, found);
74        delete found;
75    }
76    static void clear(AW_root_cblist*& listhead) {
77        if (listhead) {
78            delete listhead;
79            listhead = NULL;
80        }
81    }
82    static void call(AW_root_cblist*& listhead, AW_root *root) {
83        if (listhead) listhead->call(root);
84    }
85
86    bool contains(const AW_root_callback& cb) const {
87        return (cb == callback) || (next && next->contains(cb));
88    }
89    static bool contains(const AW_root_cblist*& listhead, const AW_root_callback& cb) {
90        return listhead && listhead->contains(cb);
91    }
92};
93
94struct AW_var_target {
95    AW_var_target(void *pntr, AW_var_target *next);
96
97    void          *pointer;
98    AW_var_target *next;
99};
100
101void aw_update_all_window_geometry_awars(AW_root *awr);
102
103#else
104#error aw_nawar.hxx included twice
105#endif // AW_NAWAR_HXX
106
Note: See TracBrowser for help on using the repository browser.