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

FXDelegator.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                       D e l e g a t o r   T a r g e t                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2000,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXDelegator.h,v 1.19 2009/01/06 13:07:22 fox Exp $                       *
00022 ********************************************************************************/
00023 #ifndef FXDELEGATOR_H
00024 #define FXDELEGATOR_H
00025 
00026 #ifndef FXOBJECT_H
00027 #include "FXObject.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /**
00034 * A delegator forwards messages to a delegate object.
00035 * Delegators are used when you need to multiplex messages
00036 * toward any number of target objects.
00037 * For example, many controls may be connected to FXDelegator,
00038 * instead of directly to the document object.  Changing the
00039 * delegate in FXDelegator will then reconnect the controls with their
00040 * new target.
00041 */
00042 class FXAPI FXDelegator : public FXObject {
00043   FXDECLARE(FXDelegator)
00044 protected:
00045   FXObject   *delegate;
00046 private:
00047   FXDelegator(const FXDelegator&);
00048   FXDelegator &operator=(const FXDelegator&);
00049 public:
00050   virtual long onDefault(FXObject*,FXSelector,void*);
00051 public:
00052 
00053   /// Construct a delegator
00054   FXDelegator(FXObject* target=NULL):delegate(target){ }
00055 
00056   /// Return delegate object
00057   FXObject* getDelegate() const { return delegate; }
00058 
00059   /// Change delegate object
00060   void setDelegate(FXObject* target){ delegate=target; }
00061 
00062   /// Always trash during detroy
00063   virtual ~FXDelegator(){ delegate=(FXObject*)-1L; }
00064   };
00065 
00066 }
00067 
00068 #endif

Copyright © 1997-2009 Jeroen van der Zijp