summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleo2001-01-07 15:38:34 +0000
committerleo2001-01-07 15:38:34 +0000
commit8ca5cc51bcdcb00cead46a655a646cc8c8e85b7d (patch)
tree2188be6c1c5fe28943cecf92745be47659a2d21d
parent0e8a9c168323bbf8bbf67ffe16aef6089effed99 (diff)
New view class
git-svn-id: http://svn.leocad.org/trunk@222 c7d43263-9d01-0410-8a33-9dba5d9f93d6
-rw-r--r--common/view.cpp70
-rw-r--r--common/view.h32
2 files changed, 102 insertions, 0 deletions
diff --git a/common/view.cpp b/common/view.cpp
new file mode 100644
index 0000000..abd8435
--- /dev/null
+++ b/common/view.cpp
@@ -0,0 +1,70 @@
+//
+// View the project contents
+//
+
+#include "view.h"
+#include "project.h"
+
+View::View (Project *pProject, GLWindow *share)
+ : GLWindow (share)
+{
+ m_pProject = pProject;
+}
+
+View::~View ()
+{
+ if (m_pProject != NULL)
+ m_pProject->RemoveView (this);
+}
+
+void View::OnDraw ()
+{
+ MakeCurrent ();
+
+ m_pProject->SetViewSize (m_nWidth, m_nHeight);
+ m_pProject->Render (false);
+
+ SwapBuffers ();
+}
+
+void View::OnInitialUpdate ()
+{
+ GLWindow::OnInitialUpdate ();
+ m_pProject->AddView (this);
+}
+
+void View::OnLeftButtonDown (int x, int y, bool bControl, bool bShift)
+{
+ m_pProject->SetViewSize (m_nWidth, m_nHeight);
+ m_pProject->OnLeftButtonDown (x, y, bControl, bShift);
+}
+
+void View::OnLeftButtonUp (int x, int y, bool bControl, bool bShift)
+{
+ m_pProject->SetViewSize (m_nWidth, m_nHeight);
+ m_pProject->OnLeftButtonUp (x, y, bControl, bShift);
+}
+
+void View::OnLeftButtonDoubleClick (int x, int y, bool bControl, bool bShift)
+{
+ m_pProject->SetViewSize (m_nWidth, m_nHeight);
+ m_pProject->OnLeftButtonDoubleClick (x, y, bControl, bShift);
+}
+
+void View::OnRightButtonDown (int x, int y, bool bControl, bool bShift)
+{
+ m_pProject->SetViewSize (m_nWidth, m_nHeight);
+ m_pProject->OnRightButtonDown (x, y, bControl, bShift);
+}
+
+void View::OnRightButtonUp (int x, int y, bool bControl, bool bShift)
+{
+ m_pProject->SetViewSize (m_nWidth, m_nHeight);
+ m_pProject->OnRightButtonUp (x, y, bControl, bShift);
+}
+
+void View::OnMouseMove (int x, int y, bool bControl, bool bShift)
+{
+ m_pProject->SetViewSize (m_nWidth, m_nHeight);
+ m_pProject->OnMouseMove (x, y, bControl, bShift);
+}
diff --git a/common/view.h b/common/view.h
new file mode 100644
index 0000000..3a1bcac
--- /dev/null
+++ b/common/view.h
@@ -0,0 +1,32 @@
+#ifndef _VIEW_H_
+#define _VIEW_H_
+
+#include "glwindow.h"
+
+class Project;
+
+class View : public GLWindow
+{
+ public:
+ View (Project *pProject, GLWindow *share);
+ virtual ~View ();
+
+ void OnDraw ();
+ void OnInitialUpdate ();
+ void OnLeftButtonDown (int x, int y, bool bControl, bool bShift);
+ void OnLeftButtonUp (int x, int y, bool bControl, bool bShift);
+ void OnLeftButtonDoubleClick (int x, int y, bool bControl, bool bShift);
+ void OnRightButtonDown (int x, int y, bool bControl, bool bShift);
+ void OnRightButtonUp (int x, int y, bool bControl, bool bShift);
+ void OnMouseMove (int x, int y, bool bControl, bool bShift);
+
+ Project* GetProject () const
+ { return m_pProject; }
+
+ protected:
+ Project* m_pProject;
+
+ // virtual void OnInitialUpdate (); // called first time after construct
+};
+
+#endif // _VIEW_H_