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,2005 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.14 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXDELEGATOR_H 00025 #define FXDELEGATOR_H 00026 00027 #ifndef FXOBJECT_H 00028 #include "FXObject.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /** 00035 * A delegator forwards messages to a delegate object. 00036 * Delegators are used when you need to multiplex messages 00037 * toward any number of target objects. 00038 * For example, many controls may be connected to FXDelegator, 00039 * instead of directly to the document object. Changing the 00040 * delegate in FXDelegator will then reconnect the controls with their 00041 * new target. 00042 */ 00043 class FXAPI FXDelegator : public FXObject { 00044 FXDECLARE(FXDelegator) 00045 protected: 00046 FXObject *delegate; 00047 private: 00048 FXDelegator(const FXDelegator&); 00049 FXDelegator &operator=(const FXDelegator&); 00050 public: 00051 virtual long onDefault(FXObject*,FXSelector,void*); 00052 public: 00053 00054 /// Construct a delegator 00055 FXDelegator(FXObject* target=NULL):delegate(target){ } 00056 00057 /// Return delegate object 00058 FXObject* getDelegate() const { return delegate; } 00059 00060 /// Change delegate object 00061 void setDelegate(FXObject* target){ delegate=target; } 00062 00063 /// Always trash during detroy 00064 virtual ~FXDelegator(){ delegate=(FXObject*)-1L; } 00065 }; 00066 00067 } 00068 00069 #endif

Copyright © 1997-2005 Jeroen van der Zijp