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

FXDelegator.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                       D e l e g a t o r   T a r g e t                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2000,2002 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (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 GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXDelegator.h,v 1.8 2002/01/18 22:42:52 jeroen Exp $                     *
00023 ********************************************************************************/
00024 #ifndef FXDELEGATOR_H
00025 #define FXDELEGATOR_H
00026 
00027 #ifndef FXOBJECT_H
00028 #include "FXObject.h"
00029 #endif
00030 
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*)-1; }
00064   };
00065 
00066 
00067 
00068 
00069 #endif