Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * S i g n a l G U I T h r e a d * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2005,2006 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: FXGUISignal.h,v 1.6 2006/01/22 17:58:04 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXGUISIGNAL_H 00025 #define FXGUISIGNAL_H 00026 00027 #ifndef FXOBJECT_H 00028 #include "FXObject.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 class FXApp; 00034 00035 00036 /** 00037 * A GUI Signal is an object used by a worker thread to signal the 00038 * user interface thread of some event; it wakes up the user interface 00039 * thread from the blocking state and causes it to send the given message 00040 * to the GUI Signal object's target. 00041 */ 00042 class FXAPI FXGUISignal : public FXObject { 00043 FXDECLARE(FXGUISignal) 00044 private: 00045 FXApp *app; // Application 00046 protected: 00047 FXObject *target; // Target object 00048 void *data; // User data 00049 FXSelector message; // Message id 00050 private: 00051 #ifndef WIN32 00052 FXInputHandle fd[2]; 00053 #else 00054 FXInputHandle event; 00055 #endif 00056 protected: 00057 FXGUISignal(); 00058 private: 00059 FXGUISignal(const FXGUISignal&); 00060 FXGUISignal& operator=(const FXGUISignal&); 00061 public: 00062 enum{ 00063 ID_IO_READ=0, 00064 ID_LAST 00065 }; 00066 public: 00067 long onSignal(FXObject*,FXSelector,void*); 00068 public: 00069 00070 /// Constructor 00071 FXGUISignal(FXApp* a,FXObject* tgt=NULL,FXSelector sel=0,void* ptr=NULL); 00072 00073 /// Get application 00074 FXApp* getApp() const { return app; } 00075 00076 /// Set the message target object 00077 void setTarget(FXObject *t){ target=t; } 00078 00079 /// Get the message target object, if any 00080 FXObject* getTarget() const { return target; } 00081 00082 /// Set the message identifier 00083 void setSelector(FXSelector sel){ message=sel; } 00084 00085 /// Get the message identifier 00086 FXSelector getSelector() const { return message; } 00087 00088 /// Set user data pointer 00089 void setData(void *ptr){ data=ptr; } 00090 00091 /// Get user data pointer 00092 void* getData() const { return data; } 00093 00094 /** 00095 * Signal the event; this API may be called by the worker thread 00096 * to send a message to the user-interface thread. 00097 */ 00098 void signal(); 00099 00100 /// Destructor 00101 virtual ~FXGUISignal(); 00102 }; 00103 00104 } 00105 00106 #endif 00107 00108
Copyright © 1997-2005 Jeroen van der Zijp |