00001 //--- < MESSAGE.H > -------------| ViewGraph - A Flexible Graph view Framework | 00002 // 00003 // Messages are like events except that the 00004 // recipient is known. 00005 // Messages can also have a limited scope of 00006 // action. 00007 // 00008 // Defines the base message class and a few 00009 // preset messages required by ViewGraph 00010 // 00011 // $Author: botik32 $ 00012 // $Revision: 1.2 $ 00013 // $Date: 2004/05/03 21:02:01 $ 00014 //-----------------------------------------------------------------------------/ 00015 00016 #ifndef MESSAGE_H 00017 #define MESSAGE_H 00018 00019 class Camera; 00020 class BaseSceneNode; 00021 00022 typedef const char* MessageScope; 00023 typedef const char* const ConstMessageScope; 00024 00025 /// Messages are like events except that the 00026 /// recipient is known. Messages cand be sent 00027 /// to all recipients via BROADCAST. 00028 class Message{ 00029 protected: 00030 Camera *context; 00031 MessageScope scope; 00032 const char *msg; 00033 BaseSceneNode *recipient; 00034 public: 00035 /// Broadcast address to set recipient 00036 /// to 00037 static BaseSceneNode* const BROADCAST; 00038 /// Set scope to ALL_CAMERAS to affect 00039 /// nodes visible in all cameras. 00040 static ConstMessageScope ALL_CAMERAS; 00041 /// Set scope to THIS_WINDOW to affect 00042 /// nodes visible in this GraphWindow only 00043 static ConstMessageScope THIS_WINDOW; 00044 /// Set scope to THIS_CAMERA to affect 00045 /// nodes visible in the context camera only 00046 static ConstMessageScope THIS_CAMERA; 00047 00048 Message( Message * ); 00049 Message( const char *, BaseSceneNode * ); 00050 Message( Camera *, const char *, BaseSceneNode * ); 00051 void assign_context( Camera * ); 00052 void assign_scope( MessageScope ); 00053 00054 Camera* get_context( void ); 00055 MessageScope get_scope( void ); 00056 const char* get_msg( void ); 00057 BaseSceneNode* get_recipient( void ); 00058 00059 virtual bool is_type( const char * ); 00060 00061 }; 00062 00063 /// MouseInMessage is used internally by ActiveLeaf 00064 /// to repaint on hover. 00065 class MouseInMessage : public Message 00066 { 00067 public: 00068 static const char *type; 00069 MouseInMessage( Camera *, BaseSceneNode * ); 00070 }; 00071 00072 /// MouseOutMessage is used internally by ActiveLeaf 00073 /// to repaint on hover. 00074 class MouseOutMessage : public Message 00075 { 00076 public: 00077 static const char *type; 00078 MouseOutMessage( Camera *, BaseSceneNode * ); 00079 }; 00080 00081 /// NodeTranslateMessage is no longer used anywhere. 00082 /// Used to be sent to all the children of a HUDGroupNode. 00083 class NodeTranslateMessage : public Message 00084 { 00085 protected: 00086 double dx, dy; 00087 public: 00088 static const char *type; 00089 NodeTranslateMessage( Camera *, BaseSceneNode *, 00090 double, double ); 00091 double get_dx( void ); 00092 double get_dy( void ); 00093 }; 00094 00095 /// CameraScrollerMessage is no longer used anywhere. 00096 /// Used to be sent to all the children of a HUDGroupNode. 00097 class CameraScrolledMessage : public Message 00098 { 00099 protected: 00100 double dx, dy; 00101 public: 00102 static const char *type; 00103 CameraScrolledMessage( Camera *, BaseSceneNode *, 00104 double, double ); 00105 double get_dx( void ); 00106 double get_dy( void ); 00107 }; 00108 00109 /// CameraZoomedMessage is no longer used anywhere. 00110 /// Used to be sent to all the children of a HUDGroupNode. 00111 class CameraZoomedMessage : public Message 00112 { 00113 protected: 00114 double new_zoom; 00115 public: 00116 static const char *type; 00117 CameraZoomedMessage( Camera *, BaseSceneNode *, 00118 double ); 00119 double get_zoom( void ); 00120 }; 00121 00122 /// CameraRepaintLeafMessage is no longer used. 00123 /// It used to be sent on hover repaints before 00124 /// the logic was changed. 00125 class CameraRepaintLeafMessage : public Message 00126 { 00127 protected: 00128 // data are passed through and 00129 // should be freed by the caller upon 00130 // return 00131 void *data; 00132 public: 00133 static const char *type; 00134 CameraRepaintLeafMessage( Camera *, 00135 BaseSceneNode *, void* ); 00136 void* get_data( void ); 00137 }; 00138 00139 /// SelectMessage is used in ContainerNode to 00140 /// let the selected node know it has been selected. 00141 /// ActiveLeaf is aware of SelectMessages and will 00142 /// change the display if the paint_selected function is 00143 /// specified. 00144 class SelectMessage : public Message 00145 { 00146 protected: 00147 public: 00148 static const char *type; 00149 SelectMessage( Camera *, 00150 BaseSceneNode* ); 00151 }; 00152 00153 /// This is the pair event to SelectMessage, is used in 00154 /// ContainerNode to let the selected node know it has 00155 /// been selected. 00156 /// ActiveLeaf is aware of Select/UnselectMessages and will 00157 /// change the display if the paint_selected function is 00158 /// specified. 00159 class UnselectMessage : public Message 00160 { 00161 protected: 00162 public: 00163 static const char *type; 00164 UnselectMessage( Camera *, 00165 BaseSceneNode* ); 00166 }; 00167 00168 #endif 00169 00170 /// $Log: message.h,v $ 00171 /// Revision 1.2 2004/05/03 21:02:01 botik32 00172 /// Significant changes and many bugfixes. 00173 /// ScrollableView now has a background color used to 00174 /// tell SurfaceDriver to clear with. 00175 /// SurfaceDriver's clear() requires a color now 00176 /// Added SceneEvents for all node additions/removals 00177 /// in GroupNode and Camera. 00178 /// Added paint_selected and paint_selected_invalid 00179 /// to ActiveLeaf 00180 /// Modified ActiveLeaf's mouse_down and mouse_up 00181 /// handler signatures to accept an Event* instead of 00182 /// Camera* 00183 /// - Many more bugfixes 00184 /// 00185 /// Revision 1.1.1.1 2004/03/26 10:50:23 botik32 00186 /// Initial release 00187 /// 00188 /// Revision 1.1.1.1 2004/03/26 08:53:33 botik 00189 /// initial import 00190 /// 00191 /// 00192 /// Revision 1.6 2003/11/25 13:01:03 botik 00193 /// Changed the flawed way scene node's requests were 00194 /// handled in ZoomableSurfaceView. This fixes a bad bug 00195 /// with HUD nodes moving all over the place. 00196 /// Added CameraZoomedMessage and CameraScrolledMessage 00197 /// Replaced the TranslateNodeMEssage with 00198 /// CameraScrolledMessage in HUDGroupNode. This fixed 00199 /// a HUD flicker bug. 00200 /// Simplified repaint and clear handling in GraphWindow. 00201 /// This fixed a few bugs in repainting. 00202 /// Added rect bounds checking in ScrollableView's 00203 /// clear_rect and repaint_rect. This fixed cameras to only 00204 /// clear their rectangle even if the view holds a larger 00205 /// area. 00206 /// Changed ActiveLeaf to use default paint function if 00207 /// the payload of CameraRepaintLeafMessage is empty. This 00208 /// will allow repaints of moved nodes. 00209 /// Changed LayerNode to allow CameraMovement events even 00210 /// if the layer is inactive. This will update existing HUD 00211 /// controls' position on inactive layers so they do not move 00212 /// astray during scrolls. 00213 /// This is an intermediate change; mouseover checks do not work. 00214 /// 00215 /// Revision 1.5 2003/11/19 16:14:52 botik 00216 /// Got repaint_rect to work right and changed ActiveLeaf 00217 /// accordingly. 00218 /// 00219 /// Revision 1.4 2003/11/19 13:38:47 botik 00220 /// Added emptymessage class 00221 /// 00222 /// Revision 1.3 2003/11/17 16:22:41 botik 00223 /// bugfixes in layernode 00224 /// 00225 /// Revision 1.2 2003/11/17 13:46:34 botik 00226 /// Removed default cursor from scrollableview 00227 /// Changed message handling behaviour for GroupNode 00228 /// to recognize broadcast messages 00229 /// Changed message handling behaviour for BaseSceneNode 00230 /// to recognize broadcast messages 00231 /// Added NodeTranslateMessage to message module 00232 /// Added handling of NodeTranslateMessage for LeafNode 00233 /// 00234 /// Revision 1.1 2003/11/13 18:50:36 botik 00235 /// Initial check-in 00236 /// 00237