-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJamView.cpp
More file actions
executable file
·161 lines (130 loc) · 3.33 KB
/
Copy pathJamView.cpp
File metadata and controls
executable file
·161 lines (130 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// JamView.cpp : implementation file
//
#include "stdafx.h"
#include "careditor.h"
#include "JamView.h"
#include "CarEditorDoc.h"
#include "JAM.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CJamView
IMPLEMENT_DYNCREATE(CJamView, CScrollView)
CJamView::CJamView()
{
currentScale = 1.0;
rcrJam = TRUE;
showNumbers = FALSE;
}
CJamView::~CJamView() {}
BEGIN_MESSAGE_MAP(CJamView, CScrollView)
//{{AFX_MSG_MAP(CJamView)
ON_WM_CREATE()
ON_COMMAND(ID_SHOW_JAMNUMBERS, OnShowJamnumbers)
ON_UPDATE_COMMAND_UI(ID_SHOW_JAMNUMBERS, OnUpdateShowJamnumbers)
ON_WM_MOUSEMOVE()
ON_COMMAND(ID_ZOOM_IN, OnZoomIn)
ON_COMMAND(ID_ZOOM_OUT, OnZoomOut)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CJamView drawing
void
CJamView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = 512;
sizeTotal.cy = 2000;
SetScrollSizes(MM_TEXT, sizeTotal);
CCarEditorDoc* pDoc = (CCarEditorDoc*)GetDocument();
myjam = pDoc->getCurrentJam();
if (myjam == NULL) {
AfxMessageBox("You must select a JAM file from the tree first!", MB_OK);
}
}
void
CJamView::OnDraw(CDC* pDC)
{
CCarEditorDoc* pDoc = (CCarEditorDoc*)GetDocument();
if (myjam) {
//|myjam->DrawAllJams(pDC,currentScale,rcrJam,showNumbers);
if (myjam->rcr)
myjam->DrawSingleJams(pDC, currentScale, pDoc->currentJamBitmap,
myjam->rcr);
else
myjam->DrawAllJams(pDC, currentScale, rcrJam, showNumbers);
}
}
/////////////////////////////////////////////////////////////////////////////
// CJamView diagnostics
#ifdef _DEBUG
void
CJamView::AssertValid() const
{
CScrollView::AssertValid();
}
void
CJamView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CJamView message handlers
int
CJamView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CScrollView::OnCreate(lpCreateStruct) == -1) return -1;
// TODO: Add your specialized creation code here
return 0;
}
void
CJamView::Resize()
{
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = (int)(currentScale * 256);
SetScrollSizes(MM_TEXT, sizeTotal);
}
void
CJamView::OnShowJamnumbers()
{
showNumbers = !showNumbers;
InvalidateRect(NULL, FALSE);
}
void
CJamView::OnUpdateShowJamnumbers(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(showNumbers);
}
void
CJamView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDC* dc = GetDC();
COLORREF clr = dc->GetPixel(point.x, point.y);
if (myjam) {
int idx = myjam->GetPoint(point.x, point.y);
char msg[256];
wsprintf(msg, "[%d] = RGB(%d,%d,%d)", idx, GetRValue(clr), GetGValue(clr),
GetBValue(clr));
SetStatusText(msg);
}
CScrollView::OnMouseMove(nFlags, point);
}
void
CJamView::OnZoomIn()
{
currentScale *= 1.1;
InvalidateRect(NULL, FALSE);
}
void
CJamView::OnZoomOut()
{
currentScale *= 0.9;
InvalidateRect(NULL, FALSE);
}