Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXDelegator.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * D e l e g a t o r T a r g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2000,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXDelegator.h,v 1.15 2006/01/22 17:58:00 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXDELEGATOR_H
25 #define FXDELEGATOR_H
26 
27 #ifndef FXOBJECT_H
28 #include "FXObject.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /**
35 * A delegator forwards messages to a delegate object.
36 * Delegators are used when you need to multiplex messages
37 * toward any number of target objects.
38 * For example, many controls may be connected to FXDelegator,
39 * instead of directly to the document object. Changing the
40 * delegate in FXDelegator will then reconnect the controls with their
41 * new target.
42 */
43 class FXAPI FXDelegator : public FXObject {
45 protected:
46  FXObject *delegate;
47 private:
48  FXDelegator(const FXDelegator&);
49  FXDelegator &operator=(const FXDelegator&);
50 public:
51  virtual long onDefault(FXObject*,FXSelector,void*);
52 public:
53 
54  /// Construct a delegator
55  FXDelegator(FXObject* target=NULL):delegate(target){ }
56 
57  /// Return delegate object
58  FXObject* getDelegate() const { return delegate; }
59 
60  /// Change delegate object
61  void setDelegate(FXObject* target){ delegate=target; }
62 
63  /// Always trash during detroy
64  virtual ~FXDelegator(){ delegate=(FXObject*)-1L; }
65  };
66 
67 }
68 
69 #endif
A delegator forwards messages to a delegate object.
Definition: FXDelegator.h:43
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
#define NULL
Definition: fxdefs.h:41
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92

Copyright © 1997-2005 Jeroen van der Zijp