Removed auto-pan window.

This commit is contained in:
leo 2011-09-13 06:04:21 +00:00
parent c341f08c54
commit 23db126628
20 changed files with 9 additions and 361 deletions

View file

@ -7,7 +7,6 @@
#include "CADDoc.h"
#include "CADView.h"
#include "WheelWnd.h"
#include "Tools.h"
#include "project.h"
#include "globals.h"
@ -49,7 +48,6 @@ BEGIN_MESSAGE_MAP(CCADView, CView)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnDropDown)
ON_MESSAGE(WM_LC_SET_STEP, OnSetStep)
ON_MESSAGE(WM_LC_WHEEL_PAN, OnAutoPan)
ON_MESSAGE(WM_LC_SET_CURSOR, OnChangeCursor)
END_MESSAGE_MAP()
@ -58,15 +56,12 @@ END_MESSAGE_MAP()
CCADView::CCADView()
{
m_pPixels = NULL;
m_hCursor = NULL;
m_pView = NULL;
m_pView = NULL;
}
CCADView::~CCADView()
{
if (m_pPixels)
free (m_pPixels);
}
BOOL CCADView::PreCreateWindow(CREATESTRUCT& cs)
@ -660,28 +655,7 @@ BOOL CCADView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
void CCADView::OnMButtonDown(UINT nFlags, CPoint point)
{
BOOL bCtl = GetKeyState(VK_CONTROL) & 0x8000;
if(!bCtl && nFlags == MK_MBUTTON)
{
CWheelWnd *pwndPanWindow = new CWheelWnd(point);
if (!pwndPanWindow->Create(this))
delete pwndPanWindow;
}
else
CView::OnMButtonDown(nFlags, point);
}
// Notification from the auto-pan window
LONG CCADView::OnAutoPan(UINT lParam, LONG wParam)
{
CPoint pt1(lParam), pt2(wParam);
pt2 -= pt1;
pt2.y = -pt2.y;
unsigned long pt = ((short)pt2.x) | ((unsigned long)(((short)pt2.y) << 16));
lcGetActiveProject()->HandleCommand(LC_VIEW_AUTOPAN, pt);
return TRUE;
CView::OnMButtonDown(nFlags, point);
}
void CCADView::OnTimer(UINT nIDEvent)
@ -799,28 +773,6 @@ void CCADView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
void CCADView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
/*
if (IsWindowEnabled())
{
if (bActivate)
{
if (m_pPixels)
free (m_pPixels);
m_pPixels = NULL;
}
else
{
if (m_pPixels)
free (m_pPixels);
CCADDoc* pDoc = GetDocument();
m_pPixels = malloc(pDoc->m_szView.cx * pDoc->m_szView.cy * sizeof(GLubyte) * 4);
if (!m_pPixels)
return;
glReadPixels(0, 0, pDoc->m_szView.cx, pDoc->m_szView.cy, GL_RGBA, GL_UNSIGNED_BYTE, m_pPixels);
}
}
*/
}
LRESULT CCADView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)

View file

@ -48,9 +48,8 @@ public:
// Generated message map functions
protected:
HCURSOR m_hCursor;
View* m_pView;
View* m_pView;
void* m_pPixels;
//{{AFX_MSG(CCADView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
@ -65,7 +64,6 @@ protected:
//}}AFX_MSG
afx_msg void OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult);
afx_msg LONG OnSetStep(UINT lParam, LONG wParam);
afx_msg LONG OnAutoPan(UINT lParam, LONG wParam);
afx_msg LONG OnChangeCursor(UINT lParam, LONG wParam);
DECLARE_MESSAGE_MAP()

View file

@ -84,7 +84,6 @@ IDB_VIEWPORTS BITMAP "res\\views.bmp"
IDR_TOOLSBAR BITMAP "res\\toolsbar.bmp"
IDR_ANIMATORBAR BITMAP "res\\animator.bmp"
IDB_PARTICONS BITMAP "res\\particon.bmp"
IDB_AUTOPAN BITMAP "res\\autopan.bmp"
IDB_PIECE BITMAP "res\\piece.bmp"
IDB_CAMERA BITMAP "res\\camera.bmp"
IDB_LIGHT BITMAP "res\\light.bmp"
@ -1520,15 +1519,6 @@ IDC_ZOOM_REGION CURSOR "res\\Zoomrect.cur"
IDC_SELECT_GROUP CURSOR "res\\SelctGrp.cur"
IDC_SELECT CURSOR "res\\select.cur"
IDC_ROLL CURSOR "res\\roll.cur"
IDC_PAN_UP CURSOR "res\\panup.cur"
IDC_PAN_LEFT CURSOR "res\\panleft.cur"
IDC_PAN_DOWN CURSOR "res\\pandown.cur"
IDC_PAN_RIGHT CURSOR "res\\panright.cur"
IDC_PAN_ALL CURSOR "res\\panall.cur"
IDC_PAN_NE CURSOR "res\\pan_ne.cur"
IDC_PAN_NW CURSOR "res\\pan_nw.cur"
IDC_PAN_SE CURSOR "res\\pan_se.cur"
IDC_PAN_SW CURSOR "res\\pan_sw.cur"
IDC_ROTX CURSOR "res\\rotx.cur"
IDC_ROTY CURSOR "res\\roty.cur"

View file

@ -1357,7 +1357,6 @@ void CMainFrame::UpdateMenuAccelerators()
ID_CAMERA_FIRST + 6, // LC_VIEW_CAMERA_MAIN,
0, // LC_VIEW_CAMERA_MENU
ID_VIEW_CAMERAS_RESET, // LC_VIEW_CAMERA_RESET
0, // LC_VIEW_AUTOPAN
ID_APP_ABOUT, // LC_HELP_ABOUT
0, // LC_TOOLBAR_ANIMATION
0, // LC_TOOLBAR_ADDKEYS

View file

@ -40,7 +40,6 @@
#define WM_LC_UPDATE_STEP_RANGE (WM_USER+213)
#define WM_LC_SET_STEP (WM_USER+214)
// #define WM_LC_FRAMECLOSED (WM_USER+215)
#define WM_LC_WHEEL_PAN (WM_USER+216)
#define WM_LC_ADD_COMBO_STRING (WM_USER+217)
#define WM_LC_UPDATE_INFO (WM_USER+218) // wParam = object, lParam = type
#define WM_LC_UPDATE_SETTINGS (WM_USER+219) // Preferences changed

View file

@ -156,7 +156,6 @@
<ClCompile Include="texdlg.cpp" />
<ClCompile Include="Tools.cpp" />
<ClCompile Include="transdlg.cpp" />
<ClCompile Include="Wheelwnd.cpp" />
<ClCompile Include="win_gl.cpp" />
<ClCompile Include="..\common\algebra.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
@ -414,7 +413,7 @@
<None Include="..\docs\CHANGES.txt" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Leocad.rc" />
<ResourceCompile Include="LeoCAD.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AboutDlg.h" />
@ -467,7 +466,6 @@
<ClInclude Include="texdlg.h" />
<ClInclude Include="Tools.h" />
<ClInclude Include="transdlg.h" />
<ClInclude Include="WheelWnd.h" />
<ClInclude Include="win_gl.h" />
<ClInclude Include="..\common\array.h" />
<ClInclude Include="..\common\basewnd.h" />

View file

@ -179,9 +179,6 @@
<ClCompile Include="transdlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Wheelwnd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="win_gl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -582,11 +579,6 @@
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Leocad.rc">
<Filter>Source Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AboutDlg.h">
<Filter>Header Files</Filter>
@ -735,9 +727,6 @@
<ClInclude Include="transdlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WheelWnd.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="win_gl.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -855,4 +844,9 @@
<Filter>Source Files</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LeoCAD.rc">
<Filter>Source Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

View file

@ -62,12 +62,6 @@
#define IDD_HTML 159
#define IDD_PROGRESS 161
#define IDR_PARTFRAME 162
#define IDB_AUTOPAN 164
#define IDC_PAN_UP 165
#define IDC_PAN_LEFT 166
#define IDC_PAN_DOWN 167
#define IDC_PAN_RIGHT 168
#define IDC_PAN_ALL 169
#define IDD_GROUP 170
#define IDS_COLOR01 176
#define IDS_COLOR02 177
@ -106,12 +100,8 @@
#define IDD_SAVEPICTUREDLG_TEMPLATE 199
#define IDS_COLOR25 200
#define IDS_COLOR26 201
#define IDC_PAN_NE 201
#define IDS_COLOR27 202
#define IDC_PAN_NW 202
#define IDS_COLOR28 203
#define IDC_PAN_SE 203
#define IDC_PAN_SW 204
#define IDR_PIECEEDITOR 205
#define IDD_PIECEEDITOR 208
#define IDB_EDITOR_ICONS 209

View file

@ -1,211 +0,0 @@
// WheelWnd.cpp : implementation file
//
#include "stdafx.h"
#include "leocad.h"
#include "WheelWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWheelWnd
// One and only origin window, used by the one and only hook.
static CWheelWnd *g_pOriginWnd = NULL;
static HHOOK g_hdlHook = NULL;
CWheelWnd::CWheelWnd(CPoint ptOrigin)
{
VERIFY(m_bitmap.LoadBitmap(IDB_AUTOPAN));
BITMAP bmp;
VERIFY(m_bitmap.GetBitmap(&bmp));
m_sizeBitmap.cx = bmp.bmWidth;
m_sizeBitmap.cy = bmp.bmHeight;
m_ptOrigin = ptOrigin;
m_ptCursorPrevious = ptOrigin;
}
CWheelWnd::~CWheelWnd()
{
}
BEGIN_MESSAGE_MAP(CWheelWnd, CWnd)
//{{AFX_MSG_MAP(CWheelWnd)
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWheelWnd message handlers
void CWheelWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// Simple drawing code, all it does is blt the bitmap we have chosen onto our window.
CDC dcMem;
VERIFY(dcMem.CreateCompatibleDC(&dc));
CGdiObject *pOldBmp = dcMem.SelectObject(&m_bitmap);
VERIFY(dc.BitBlt(0, 0, m_sizeBitmap.cx, m_sizeBitmap.cy, &dcMem, 0, 0, SRCCOPY));
dcMem.SelectObject(pOldBmp);
}
void CWheelWnd::OnTimer(UINT nIDEvent)
{
if (nIDEvent == IDT_LC_WHEELTIMER)
{
CPoint ptCursor;
VERIFY(GetCursorPos(&ptCursor));
ASSERT_VALID(m_pParentWnd);
m_pParentWnd->ScreenToClient(&ptCursor);
CPoint pt = ptCursor;
// If the point is within one of our margins or we are doing one way scrolling then we correct the point
// by setting it's axis value to the same as our origin. This makes makes the cursor behaviour
// the same as IE.
CRgn rgn;
rgn.CreateEllipticRgn(0, 0, m_sizeBitmap.cx, m_sizeBitmap.cy);
rgn.OffsetRgn(m_ptOrigin.x-m_sizeBitmap.cx/2, m_ptOrigin.y-m_sizeBitmap.cy/2);
if (rgn.PtInRegion(pt))
pt = m_ptOrigin;
// if (pt.x > m_rcCursorMargin.left && pt.x < m_rcCursorMargin.right)
// pt.x = m_ptOrigin.x;
//
// if (pt.y > m_rcCursorMargin.top && pt.y < m_rcCursorMargin.bottom)
// pt.y = m_ptOrigin.y;
// Now that we have our distance from our origin and we have normalised it to be within our margins
// where necessary we now figure out which cursor to use, this is a simple lookup into a table again.
if (m_ptCursorPrevious != ptCursor)
{
m_ptCursorPrevious = ptCursor;
const int nHoriz = max(-1, min(1, pt.x - m_ptOrigin.x)) + 1;
const int nVert = max(-1, min(1, pt.y - m_ptOrigin.y)) + 1;
const UINT Cursors[3][3] = { IDC_PAN_NW, IDC_PAN_LEFT, IDC_PAN_SW,
IDC_PAN_UP, IDC_PAN_ALL, IDC_PAN_DOWN, IDC_PAN_NE, IDC_PAN_RIGHT, IDC_PAN_SE };
HCURSOR hc = theApp.LoadCursor(Cursors[nHoriz][nVert]);
SetCursor(hc);
}
if (m_ptOrigin != pt)
m_pParentWnd->PostMessage(WM_LC_WHEEL_PAN, MAKELPARAM(m_ptOrigin.x, m_ptOrigin.y), MAKELPARAM(pt.x, pt.y));
}
else
CWnd::OnTimer(nIDEvent);
}
void CWheelWnd::OnDestroy()
{
CWnd::OnDestroy();
VERIFY(UnhookWindowsHookEx(g_hdlHook));
g_hdlHook = NULL;
g_pOriginWnd = NULL;
KillTimer(IDT_LC_WHEELTIMER);
}
BOOL CWheelWnd::Create(CWnd* pParentWnd)
{
// Must be a valid parent window
ASSERT_VALID(pParentWnd);
CPoint pt = m_ptOrigin;
pParentWnd->ClientToScreen(&pt);
// We create the window, the centre of the window should be the origin point so when all of the startup is done the cursor
// will appear over the centre of the origin window.
const int nHalfHeight = m_sizeBitmap.cy / 2;
const int nHalfWidth = m_sizeBitmap.cx / 2;
if(CWnd::CreateEx(WS_EX_TOOLWINDOW, AfxRegisterWndClass(CS_SAVEBITS), NULL, WS_CLIPSIBLINGS | WS_POPUP, pt.x - nHalfWidth, pt.y - nHalfHeight, m_sizeBitmap.cx, m_sizeBitmap.cy, pParentWnd->GetSafeHwnd(), 0))
{
VERIFY(SetWindowPos(&wndTopMost, 0,0,0,0, SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE));
m_pParentWnd = pParentWnd;
// Determine the thresholds for the cursor changing, while the cursor is between these points the cursor does not
// change to one of the diagonal cursors. I think this is how IE does it - sure looks like it.
m_rcCursorMargin.SetRect(m_ptOrigin.x - nHalfWidth, m_ptOrigin.y - nHalfHeight, m_ptOrigin.x + nHalfWidth, m_ptOrigin.y + nHalfHeight);
// We want a circular(or as much as the bitmap allows) window, so do the usual
// thing of creating a region and assigning it to the window.
CRgn rgn;
VERIFY(rgn.CreateEllipticRgn(0, 0, m_sizeBitmap.cx, m_sizeBitmap.cy));
VERIFY(SetWindowRgn((HRGN)rgn.Detach(), TRUE));
// Set our mouse capture so that all mouse messages go to us and also set a timer
// so that we can periodically send our message to our parent.
SetCapture();
VERIFY(SetTimer(IDT_LC_WHEELTIMER, 25, NULL) == IDT_LC_WHEELTIMER);
g_pOriginWnd = this;
g_hdlHook = SetWindowsHookEx(WH_GETMESSAGE, HookProc, NULL, GetCurrentThreadId());
return TRUE;
}
TRACE0("Failed to create Origin window\n");
return FALSE;
}
LRESULT CWheelWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_LBUTTONDOWN:
case WM_CANCELMODE:
case WM_CAPTURECHANGED:
VERIFY(DestroyWindow());
break;
default:
return CWnd::WindowProc(message, wParam, lParam);
}
return 0;
}
void CWheelWnd::PostNcDestroy()
{
CWnd::PostNcDestroy();
delete this;
}
// Hook procedure to catch messages that should terminate our window.
LRESULT CALLBACK CWheelWnd::HookProc(int code, WPARAM wParam ,LPARAM lParam)
{
MSG* pMsg = (MSG*)lParam;
ASSERT_VALID(g_pOriginWnd);
ASSERT_VALID(g_pOriginWnd->m_pParentWnd);
if(pMsg->hwnd == g_pOriginWnd->m_pParentWnd->GetSafeHwnd())
{
switch(pMsg->message)
{
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
case WM_CHAR:
case WM_KILLFOCUS:
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_MOUSEWHEEL:
VERIFY(g_pOriginWnd->DestroyWindow());
break;
default:
// Intentionally do nothing
;
}
}
return CallNextHookEx( g_hdlHook, code, wParam, lParam );
}

View file

@ -1,61 +0,0 @@
#if !defined(AFX_WHEELWND_H__CA6A1DC2_7283_11D2_8203_8EEC36A08D1C__INCLUDED_)
#define AFX_WHEELWND_H__CA6A1DC2_7283_11D2_8203_8EEC36A08D1C__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// WheelWnd.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CWheelWnd window
class CWheelWnd : public CWnd
{
// Construction
public:
CWheelWnd(CPoint ptOrigin);
BOOL Create(CWnd* pParentWnd);
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWheelWnd)
protected:
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CWheelWnd();
// Generated message map functions
protected:
static LRESULT CALLBACK HookProc(int code, WPARAM wParam, LPARAM lParam);
CBitmap m_bitmap;
CWnd* m_pParentWnd;
CSize m_sizeBitmap;
CPoint m_ptOrigin;
CPoint m_ptCursorPrevious;
CRect m_rcCursorMargin;
//{{AFX_MSG(CWheelWnd)
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WHEELWND_H__CA6A1DC2_7283_11D2_8203_8EEC36A08D1C__INCLUDED_)