Use POSIX macros for linux
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / wwl / include / WWL / WCallback.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23
24 /*
25  *      WWL             (c) Copyright LRI 1990
26  *      Copyright (c) 1990, 1991 Jean-Daniel Fekete
27  *      Copyright (c) 1990, 1991 LRI, Universitee de Paris-Sud (France)
28  *
29  *      Permission to use, copy, modify and distribute this software
30  *      and its documentation for any purpose and without fee is hereby
31  *      granted, provided that the above copyright notice appears in
32  *      all copies of the software. This software is provided "as-is"
33  *      without express or implied warranty.
34  *
35  *      C++ Callbacks
36  *
37  *      $XConsortium: WCallback.h /main/4 1996/06/11 16:58:00 cde-hal $
38  */
39
40 #ifndef _WCallback_h
41 #define _WCallback_h
42
43 class WWL;
44 class WCallback;
45 class WObject;
46 typedef void (WWL::* WWL_FUN) (WCallback*);
47
48 class WWL {
49 protected:
50         WCallback*      cbList;
51 public:
52         WWL ();
53         virtual ~WWL ();
54         
55         void            AddCb (WCallback *);
56         Boolean         RemoveCb (WCallback *);
57         void            removeCallbacks();
58 private:
59
60         virtual void __dummy();
61         /* Without a virtual function in the WWL base class, the C++
62            translator cfront will not generate the correct code to
63            call virtual callback functions because it doesn't think
64            that virtuals can be called and only generates code to
65            call non-virtual memebers. */
66 };
67
68 class WCallback {
69 protected:
70         WCallback*      next;
71         Widget          widget;
72         const char*     name;
73         WWL*            object;
74         WWL_FUN         fun;
75         caddr_t         call_data;
76         caddr_t         client_data;
77         WObject*        wobject;
78         
79 public:
80         WCallback (Widget, const char*, WWL*, WWL_FUN, void* client=0);
81         WCallback (WObject&, const char*, WWL*, WWL_FUN, void* client=0);
82         WCallback (Widget, Atom, WWL*, WWL_FUN, void* client=0);
83         WCallback (WObject&, Atom, WWL*, WWL_FUN, void* client=0);
84         ~WCallback ();
85         
86         void    Call (caddr_t);
87         
88 inline  WWL_FUN Fun ()                  { return fun; }
89 inline  void            Fun (WWL_FUN f) { fun = f; }
90 inline  WWL*            Obj ()                  { return object; }
91 inline  void            Obj (WWL* o)            { o->AddCb (this); }
92 inline  caddr_t         CallData ()             { return call_data; }
93 inline  caddr_t         ClientData ()           { return client_data; }
94 inline  Widget          GetWidget ()            { return widget; }
95 //  inline Widget       Widget()                { return widget; }      
96 inline  WObject*        GetWObject ()           { return wobject; }
97 //  inline  WObject*    WObject()               { return wobject; }
98 friend  class WWL;
99 };
100
101 #endif