]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/bobtoolz/DTreePlanter.h
- Radiant is now Vista compatible (Aero must be disabled)
[xonotic/netradiant.git] / contrib / bobtoolz / DTreePlanter.h
index 87d0d6c8b71e76c084e0dbff99fa7e7c586f4b2d..104216608a1739c249ecba6091b626311ac7a68a 100644 (file)
@@ -20,6 +20,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #ifndef __DTREE_H__
 #define __DTREE_H__
 
 #ifndef __DTREE_H__
 #define __DTREE_H__
 
+#include "qerplugin.h"
+#include "signal/isignal.h"
+#include "string/string.h"
+
+#include "DEntity.h"
+#include "ScriptParser.h"
+#include "mathlib.h"
+#include "misc.h"
 
 #define MAX_QPATH 64
 
 
 #define MAX_QPATH 64
 
@@ -29,23 +37,20 @@ typedef struct treeModel_s {
 
 #define MAX_TP_MODELS 256
 
 
 #define MAX_TP_MODELS 256
 
-class DTreePlanter : public IWindowListener {
+class DTreePlanter {
+  MouseEventHandlerId m_mouseDown;
+  SignalHandlerId m_destroyed;
 public:
 public:
-       virtual bool OnMouseMove(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnLButtonDown(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnMButtonDown(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnRButtonDown(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnLButtonUp(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnMButtonUp(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnRButtonUp(guint32 nFlags, gdouble x, gdouble y);
-       virtual bool OnKeyPressed(char *s) { return false; }
-       virtual bool Paint() { return true; }
-       virtual void Close() { }
-       
-       DTreePlanter() {
-               m_refCount =    1;
-               m_hooked =              false;
-               m_XYWrapper =   NULL;
+       SignalHandlerResult mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers);
+  typedef Member3<DTreePlanter, const WindowVector&, ButtonIdentifier, ModifierFlags, SignalHandlerResult, &DTreePlanter::mouseDown> MouseDownCaller;
+       void destroyed()
+  {
+    m_mouseDown = MouseEventHandlerId();
+    m_destroyed = SignalHandlerId();
+  }
+  typedef Member<DTreePlanter, void, &DTreePlanter::destroyed> DestroyedCaller;
+
+  DTreePlanter() {
                m_numModels =   0;
                m_offset =              0;
                m_maxPitch =    0;
                m_numModels =   0;
                m_offset =              0;
                m_maxPitch =    0;
@@ -57,8 +62,6 @@ public:
                m_autoLink =    false;
                m_linkNum =             0;
 
                m_autoLink =    false;
                m_linkNum =             0;
 
-               Register();
-
                m_world.LoadSelectedBrushes();
 
                char buffer[256];
                m_world.LoadSelectedBrushes();
 
                char buffer[256];
@@ -85,9 +88,24 @@ public:
 
                        fclose( file );
                }
 
                        fclose( file );
                }
+
+    m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect(makeSignalHandler3(MouseDownCaller(), *this));
+    m_destroyed = GlobalRadiant().XYWindowDestroyed_connect(makeSignalHandler(DestroyedCaller(), *this));
        }
 
        }
 
-#define MT(t)  !stricmp( pToken, t )
+  virtual ~DTreePlanter()
+  {
+    if(!m_mouseDown.isNull())
+    {
+      GlobalRadiant().XYWindowMouseDown_disconnect(m_mouseDown);
+    }
+    if(!m_destroyed.isNull())
+    {
+      GlobalRadiant().XYWindowDestroyed_disconnect(m_destroyed);
+    }
+  }
+
+#define MT(t)  string_equal_nocase( pToken, t )
 #define GT             pToken = pScriptParser->GetToken( true )
 #define CT             if(!*pToken) { return; }
 
 #define GT             pToken = pScriptParser->GetToken( true )
 #define CT             if(!*pToken) { return; }
 
@@ -161,41 +179,16 @@ public:
                } while( true );
        }
 
                } while( true );
        }
 
-       virtual ~DTreePlanter() {
-               UnRegister();
-       }
-
-       virtual void IncRef() { m_refCount++; }
-       virtual void DecRef() { m_refCount--; if (m_refCount <= 0) delete this; }
-
-       void Register() {
-               if(!m_hooked) {
-                       g_MessageTable.m_pfnHookWindow( this );
-                       m_XYWrapper = g_MessageTable.m_pfnGetXYWndWrapper();
-                       m_hooked = true;
-               }
-       }
-
-       void UnRegister() {
-               if(m_hooked) {
-                       g_MessageTable.m_pfnUnHookWindow( this );
-                       m_XYWrapper = NULL;
-                       m_hooked = false;
-               }
-       }
-
        bool FindDropPoint(vec3_t in, vec3_t out);
        void DropEntsToGround( void );
        void MakeChain( void );
        void SelectChain( void );
 
 private:
        bool FindDropPoint(vec3_t in, vec3_t out);
        void DropEntsToGround( void );
        void MakeChain( void );
        void SelectChain( void );
 
 private:
-       IXYWndWrapper*  m_XYWrapper;
        DEntity                 m_world;
 
        treeModel_t             m_trees[MAX_TP_MODELS];
 
        DEntity                 m_world;
 
        treeModel_t             m_trees[MAX_TP_MODELS];
 
-       int                             m_refCount;
        int                             m_numModels;
        int                             m_offset;
        int                             m_maxPitch;
        int                             m_numModels;
        int                             m_offset;
        int                             m_maxPitch;
@@ -210,7 +203,6 @@ private:
        float                   m_minScale;
        float                   m_maxScale;
 
        float                   m_minScale;
        float                   m_maxScale;
 
-       bool                    m_hooked;
        bool                    m_useScale;
        bool                    m_setAngles;
        bool                    m_autoLink;
        bool                    m_useScale;
        bool                    m_setAngles;
        bool                    m_autoLink;