![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * D e l e g a t o r T a r g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2000,2010 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 #ifndef FXDELEGATOR_H 00022 #define FXDELEGATOR_H 00023 00024 #ifndef FXOBJECT_H 00025 #include "FXObject.h" 00026 #endif 00027 00028 namespace FX { 00029 00030 00031 /** 00032 * A delegator forwards messages to a delegate object. 00033 * Delegators are used when you need to multiplex messages 00034 * toward any number of target objects. 00035 * For example, many controls may be connected to FXDelegator, 00036 * instead of directly to the document object. Changing the 00037 * delegate in FXDelegator will then reconnect the controls with their 00038 * new target. 00039 */ 00040 class FXAPI FXDelegator : public FXObject { 00041 FXDECLARE(FXDelegator) 00042 protected: 00043 FXObject *delegate; 00044 private: 00045 FXDelegator(const FXDelegator&); 00046 FXDelegator &operator=(const FXDelegator&); 00047 public: 00048 virtual long onDefault(FXObject*,FXSelector,void*); 00049 public: 00050 00051 /// Construct a delegator 00052 FXDelegator(FXObject* target=NULL):delegate(target){ } 00053 00054 /// Return delegate object 00055 FXObject* getDelegate() const { return delegate; } 00056 00057 /// Change delegate object 00058 void setDelegate(FXObject* target){ delegate=target; } 00059 00060 /// Always trash during detroy 00061 virtual ~FXDelegator(){ delegate=(FXObject*)-1L; } 00062 }; 00063 00064 } 00065 00066 #endif
|
|