summaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
authorleo2006-01-24 04:48:40 +0000
committerleo2006-01-24 04:48:40 +0000
commit3cf202f177cffb3b962420933ab8d9481b0d8f32 (patch)
treebb3b66c0f6948443b4b6230841d8e39ad737cafd /win
parent8773592dd2a7f096b29d91b750437ac60b4584f8 (diff)
Added the ability to zoom and rotate the Piece Preview.
git-svn-id: http://svn.leocad.org/trunk@460 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win')
-rw-r--r--win/Cadview.cpp39
-rw-r--r--win/Pieceprv.cpp19
-rw-r--r--win/Pieceprv.h1
-rw-r--r--win/glwindow.cpp23
4 files changed, 45 insertions, 37 deletions
diff --git a/win/Cadview.cpp b/win/Cadview.cpp
index 58fe3ff..9e26db1 100644
--- a/win/Cadview.cpp
+++ b/win/Cadview.cpp
@@ -114,36 +114,6 @@ BOOL CCADView::PreCreateWindow(CREATESTRUCT& cs)
void CCADView::OnDraw(CDC* /*pDC*/)
{
- static int added = 0;
-
- if (!added)
- {
- m_pView->OnInitialUpdate ();
- added = 1;
- }
-
-// m_pView->OnDraw ();
-// project->Render(false);
-/*
- CCADDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- if (m_pPixels)
- {
- glViewport(0, 0, pDoc->m_szView.cx, pDoc->m_szView.cy);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluOrtho2D(0, pDoc->m_szView.cx, 0, pDoc->m_szView.cy);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glRasterPos2i(0, 0);
- glDrawPixels(pDoc->m_szView.cx, pDoc->m_szView.cy, GL_RGBA, GL_UNSIGNED_BYTE, m_pPixels);
- }
- else
- pDoc->Render(FALSE);
-
- pfnwglSwapBuffers (pfnwglGetCurrentDC());
-*/
}
/////////////////////////////////////////////////////////////////////////////
@@ -769,7 +739,7 @@ int CCADView::OnCreate(LPCREATESTRUCT lpCreateStruct)
m_pView = new View (project, NULL);
m_pView->Create (m_hWnd);
-// m_pView->OnInitialUpdate ();
+ m_pView->OnInitialUpdate ();
SetTimer (IDT_LC_SAVETIMER, 5000, NULL);
@@ -1052,10 +1022,13 @@ LRESULT CCADView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
if (m_pView)
{
MSG msg;
- msg.message = message;
+
+ msg.message = message;
msg.wParam = wParam;
msg.lParam = lParam;
- GLWindowPreTranslateMessage (m_pView, &msg);
+
+ if (GLWindowPreTranslateMessage(m_pView, &msg))
+ return TRUE;
}
return CView::WindowProc(message, wParam, lParam);
diff --git a/win/Pieceprv.cpp b/win/Pieceprv.cpp
index bf1a714..c07cea9 100644
--- a/win/Pieceprv.cpp
+++ b/win/Pieceprv.cpp
@@ -53,7 +53,7 @@ void CPiecePreview::OnPaint()
if (!IsWindowEnabled() || (m_Preview == NULL))
return;
- m_Preview->OnDraw();
+// m_Preview->OnDraw();
}
void CPiecePreview::OnSize(UINT nType, int cx, int cy)
@@ -95,3 +95,20 @@ PieceInfo* CPiecePreview::GetPieceInfo() const
{
return m_Preview->GetCurrentPiece();
}
+
+BOOL GLWindowPreTranslateMessage (GLWindow *wnd, MSG *pMsg);
+LRESULT CPiecePreview::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ if (m_Preview)
+ {
+ MSG msg;
+ msg.message = message;
+ msg.wParam = wParam;
+ msg.lParam = lParam;
+
+ if (GLWindowPreTranslateMessage(m_Preview, &msg))
+ return TRUE;
+ }
+
+ return CWnd::WindowProc(message, wParam, lParam);
+}
diff --git a/win/Pieceprv.h b/win/Pieceprv.h
index 8de9d21..16b9646 100644
--- a/win/Pieceprv.h
+++ b/win/Pieceprv.h
@@ -48,6 +48,7 @@ protected:
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};
/////////////////////////////////////////////////////////////////////////////
diff --git a/win/glwindow.cpp b/win/glwindow.cpp
index baa5186..670eb0c 100644
--- a/win/glwindow.cpp
+++ b/win/glwindow.cpp
@@ -21,8 +21,13 @@ BOOL GLWindowPreTranslateMessage (GLWindow *wnd, MSG *pMsg)
switch (pMsg->message)
{
case WM_PAINT:
+ {
+ GLWindowPrivate* prv = (GLWindowPrivate*)wnd->GetData();
+ PAINTSTRUCT ps;
+ BeginPaint(prv->m_hWnd, &ps);
wnd->OnDraw ();
- break;
+ EndPaint(prv->m_hWnd, &ps);
+ } break;
case WM_SIZE:
wnd->OnSize (LOWORD (pMsg->lParam), HIWORD (pMsg->lParam));
break;
@@ -74,11 +79,13 @@ BOOL GLWindowPreTranslateMessage (GLWindow *wnd, MSG *pMsg)
InvalidateRect (prv->m_hWnd, NULL, TRUE);
}
}
- return TRUE;
} break;
+
+ default:
+ return FALSE;
}
- return FALSE;
+ return TRUE;
}
LRESULT CALLBACK GLWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -247,3 +254,13 @@ void GLWindow::Redraw ()
InvalidateRect (prv->m_hWnd, NULL, FALSE);
}
+void GLWindow::CaptureMouse()
+{
+ GLWindowPrivate* prv = (GLWindowPrivate*)m_pData;
+ SetCapture(prv->m_hWnd);
+}
+
+void GLWindow::ReleaseMouse()
+{
+ ReleaseCapture();
+}