提交 | 用户 | age
|
418cb3
|
1 |
// LCDDisplay1.cpp: 实现文件
|
Q |
2 |
//
|
|
3 |
|
|
4 |
#include "pch.h"
|
|
5 |
#include "LCDDisplay1.h"
|
|
6 |
|
|
7 |
|
|
8 |
#define WM_MENUST (WM_USER+1500)
|
|
9 |
// CMyPicDisp
|
|
10 |
|
|
11 |
IMPLEMENT_DYNAMIC(LCDDisplay1, CStatic)
|
|
12 |
static unsigned int font3_5[128] =
|
|
13 |
{
|
|
14 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
15 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
16 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x007720,0x002770, // ▲▼
|
|
17 |
|
|
18 |
0x000000,0x020222,0x000055,0x017574,0x036736,0x051245,0x053730,0x000122, // ! " # $ % & '
|
|
19 |
0x021112,0x024442,0x052725,0x022722,0x012200,0x000700,0x020000,0x012244, // ( ) * + , - . /
|
|
20 |
0x075557,0x022222,0x071747,0x074747,0x044755,0x074717,0x075717,0x044557, // 0 1 2 3 4 5 6 7
|
|
21 |
0x075757,0x074757,0x002020,0x012020,0x042124,0x007070,0x012421,0x020452, // 8 9 : ; < = > ?
|
|
22 |
0x025752,0x055752,0x035353,0x071117,0x035553,0x071717,0x011717,0x075517, // @ A B C D E F G
|
|
23 |
0x055755,0x072227,0x032227,0x055355,0x071111,0x055575,0x055535,0x025552, // H I J K L M N O
|
|
24 |
0x011353,0x065552,0x055353,0x034216,0x022227,0x075555,0x025555,0x057555, // P Q R S T U V W
|
|
25 |
0x055255,0x022255,0x071247,0x071117,0x042211,0x074447,0x000052,0x070000, // X Y Z [ \ ] ^ _
|
|
26 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,
|
|
27 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,
|
|
28 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,
|
|
29 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,
|
|
30 |
};
|
|
31 |
|
|
32 |
static unsigned long long font5_7[128] =
|
|
33 |
{
|
|
34 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
35 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
36 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ▲▼
|
|
37 |
|
|
38 |
0x000000000000,0x00400410e384,0x00000000a6db,0x00015f29f500, // ! " #
|
|
39 |
0x0043d4385784,0x0186421084c3,0x016255085080,0x00000000430c, // $ % & '
|
|
40 |
0x004081041084,0x004210410204,0x0112847c4291,0x0001047c4100, // ( ) * +
|
|
41 |
0x00230c000000,0x0000007c0000,0x00c300000000,0x000042108400, // , - . /
|
|
42 |
|
|
43 |
// ,
|
|
44 |
0x00e45355944e,0x00e104104184,0x01f08421044e,0x00e45039044e, // 0 1 2 3
|
|
45 |
0x01e21f24a308,0x00e45040f05f,0x00e4513c108c,0x00410410841f, // 4 5 6 7
|
|
46 |
0x00e45139144e,0x00e41079144e,0x00030c00c300,0x00330c00c300, // 8 9 : ;
|
|
47 |
0x008102042108,0x00001f01f000,0x002108408102,0x00400421044e, // < = > ?
|
|
48 |
0x01e04d55544e,0x01145f451284,0x00f4513d144f,0x00e44104144e, // @ A B C
|
|
49 |
0x00f45145144f,0x01f0413c105f,0x0010413c105f,0x00e45174144e, // D E F G
|
|
50 |
0x0114517d1451,0x00e10410410e,0x00614410410e,0x0112450c5251, // H I J K
|
|
51 |
0x01f041041041,0x0114555556d1,0x011459553451,0x00e45145144e, // L M N O
|
|
52 |
0x0010413d144f,0x01625545144e,0x0112453d144f,0x00e45038144e, // P Q R S
|
|
53 |
0x00410410411f,0x00e451451451,0x004291451451,0x00a555551451, // T U V W
|
|
54 |
0x01144a10a451,0x00410410a451,0x01f04210841f,0x00e08208208e, // X Y Z [
|
|
55 |
0x000408102040,0x00e20820820e,0x000000011284,0x01f000000000, // \ ] ^ _
|
|
56 |
0x000000204082,0x00058924e000,0x0003d144f041,0x00038104e000, // ` a b c
|
|
57 |
0x00079145e410,0x0003817d1380,0x00208208f08c,0x00620e249380, // d e f g
|
|
58 |
0x000249247041,0x000384106004,0x00614410e004,0x0002450c5241, // h i j k
|
|
59 |
0x000382082082,0x000451555280,0x0002492491c0,0x000391451380, // l m n o
|
|
60 |
0x0010472491c0,0x00820e249380,0x000082092340,0x000390302700, // p q r s
|
|
61 |
0x00070411e100,0x000389249000,0x000085249000,0x000295551000, // t u v w
|
|
62 |
0x00024a1c9000,0x00620e28a000,0x0003c210f000,0x008104084108, // x y z {
|
|
63 |
0x004104004104,0x002104204102,0x000000000352,0x000000000000, // | } ~
|
|
64 |
};
|
|
65 |
|
|
66 |
LCDDisplay1::LCDDisplay1()
|
|
67 |
{
|
|
68 |
m_nBkColor = 0xffc4d8d0;
|
|
69 |
m_nHideColor = m_nBkColor - 0x00080808;
|
|
70 |
m_nFntColor = 0xff404040;
|
|
71 |
m_nMouseWndX = 0;
|
|
72 |
m_nMouseWndY = 0;
|
|
73 |
m_nMouseMode = MouseModeCursor;
|
|
74 |
m_fDispOffsetX = 0;
|
|
75 |
m_fDispOffsetY = 0;
|
|
76 |
m_fScaleX = 1;
|
|
77 |
m_fScaleY = 1;
|
|
78 |
|
|
79 |
SetTextMode(TextModeDefault);
|
|
80 |
|
|
81 |
nExtMenuCount = 0;
|
|
82 |
nOldMenuSel = 0;
|
|
83 |
bViewMoving = 0;
|
|
84 |
m_menu1.CreatePopupMenu();
|
|
85 |
m_menu1.AppendMenu(MF_STRING | MF_CHECKED | MFT_RADIOCHECK, WM_MENUST + ID_Point, _T("指针(&P)"));
|
|
86 |
m_menu1.AppendMenu(MF_STRING | MFT_RADIOCHECK, WM_MENUST + ID_Move, _T("平移(&A)"));
|
|
87 |
m_menu1.AppendMenu(MF_STRING | MFT_RADIOCHECK, WM_MENUST + ID_ZoomIn, _T("放大(&I)"));
|
|
88 |
m_menu1.AppendMenu(MF_STRING | MFT_RADIOCHECK, WM_MENUST + ID_ZoomOut, _T("缩小(&O)"));
|
|
89 |
|
|
90 |
m_menu1.AppendMenu(MF_SEPARATOR);
|
|
91 |
m_menu1.AppendMenu(MF_STRING | MF_CHECKED, WM_MENUST + ID_PixelGrid, _T("像素网格(&G)"));
|
|
92 |
m_menu1.AppendMenu(MF_STRING | MF_CHECKED, WM_MENUST + ID_SubPixelGrid, _T("子像素网格(&S)"));
|
|
93 |
m_menu1.AppendMenu(MF_SEPARATOR);
|
|
94 |
|
|
95 |
|
|
96 |
m_menu1.AppendMenu(MF_STRING, WM_MENUST + ID_ZoomFit, _T("适合图像"));
|
|
97 |
m_menu1.AppendMenu(MF_STRING, WM_MENUST + ID_OrgScale, _T("原始尺寸100%"));
|
|
98 |
m_menu1.AppendMenu(MF_SEPARATOR);
|
|
99 |
m_menu1.AppendMenu(MF_STRING, WM_MENUST + ID_Seprate_Window, _T("分离窗口"));
|
|
100 |
//menu1.AppendMenu(MF_STRING, WM_MENUST + ID_Restore_Window, _T("恢复窗口"));
|
|
101 |
|
|
102 |
//menu1.AppendMenu(MF_SEPARATOR);
|
|
103 |
|
|
104 |
m_menu1.AppendMenu(MF_STRING, WM_MENUST + ID_LoadImage, _T("加载图片..."));
|
|
105 |
m_menu1.AppendMenu(MF_SEPARATOR);
|
|
106 |
m_menu1.AppendMenu(MF_STRING, WM_MENUST + ID_SaveImageAs, _T("图像另存为..."));
|
|
107 |
}
|
|
108 |
|
|
109 |
LCDDisplay1::~LCDDisplay1()
|
|
110 |
{
|
|
111 |
}
|
|
112 |
|
|
113 |
BEGIN_MESSAGE_MAP(LCDDisplay1, CStatic)
|
|
114 |
ON_WM_SIZE()
|
|
115 |
ON_WM_LBUTTONDOWN()
|
|
116 |
ON_WM_LBUTTONUP()
|
|
117 |
ON_WM_MOUSEWHEEL()
|
|
118 |
ON_WM_MOUSELEAVE()
|
|
119 |
ON_WM_MOUSEMOVE()
|
|
120 |
ON_WM_KILLFOCUS()
|
|
121 |
ON_CONTROL_REFLECT(STN_CLICKED, &LCDDisplay1::OnStnClicked)
|
|
122 |
ON_CONTROL_REFLECT(STN_DBLCLK, &LCDDisplay1::OnStnDblclick)
|
|
123 |
ON_WM_RBUTTONDOWN()
|
|
124 |
ON_WM_RBUTTONUP()
|
|
125 |
ON_WM_RBUTTONDBLCLK()
|
|
126 |
ON_WM_MBUTTONDOWN()
|
|
127 |
ON_WM_MBUTTONUP()
|
|
128 |
ON_WM_MBUTTONDBLCLK()
|
|
129 |
ON_WM_LBUTTONDBLCLK()
|
|
130 |
ON_WM_TIMER()
|
|
131 |
ON_WM_CONTEXTMENU()
|
|
132 |
|
|
133 |
ON_COMMAND_RANGE(WM_MENUST, WM_MENUST + ID_MenuItemCustom - 1, OnMenuS1)
|
|
134 |
ON_COMMAND_RANGE(WM_MENUST + ID_MenuItemCustom, WM_MENUST + ID_MenuItemCustom + 15, OnMenuS)
|
|
135 |
ON_WM_SETCURSOR()
|
|
136 |
END_MESSAGE_MAP()
|
|
137 |
|
|
138 |
|
|
139 |
// LCDDisplay1 消息处理程序
|
|
140 |
BOOL LCDDisplay1::PreTranslateMessage(MSG* pMsg)
|
|
141 |
{
|
|
142 |
// TODO: 在此添加专用代码和/或调用基类
|
|
143 |
if (NULL != m_tooltip.GetSafeHwnd() && pMsg->message == WM_MOUSEMOVE)
|
|
144 |
{
|
|
145 |
m_tooltip.RelayEvent(pMsg);
|
|
146 |
}
|
|
147 |
return CStatic::PreTranslateMessage(pMsg);
|
|
148 |
}
|
|
149 |
|
|
150 |
void LCDDisplay1::PreSubclassWindow()
|
|
151 |
{
|
|
152 |
// TODO: 在此添加专用代码和/或调用基类
|
|
153 |
this->ModifyStyle(SS_TYPEMASK, SS_OWNERDRAW | SS_NOTIFY);
|
|
154 |
|
|
155 |
if (m_tooltip.GetSafeHwnd() == NULL) m_tooltip.Create(this);
|
|
156 |
m_tooltip.AddTool(this);
|
|
157 |
|
|
158 |
// m_tooltip.AddTool(this);
|
|
159 |
|
|
160 |
// m_tooltip.Create(this); // , TTS_ALWAYSTIP);
|
|
161 |
m_tooltip.Activate(TRUE);
|
|
162 |
m_tooltip.EnableToolTips(TRUE);
|
|
163 |
this->EnableToolTips(TRUE);
|
|
164 |
m_tooltip.SetTipTextColor(RGB(0, 0, 255));//font color
|
|
165 |
m_tooltip.SetDelayTime(150);//delay time
|
|
166 |
m_tooltip.SetDelayTime(TTDT_AUTOPOP, -1);
|
|
167 |
m_tooltip.SetDelayTime(TTDT_INITIAL, 1);
|
|
168 |
m_tooltip.SetDelayTime(TTDT_RESHOW, 1);
|
|
169 |
m_tooltip.SetMaxTipWidth(1000);
|
|
170 |
// m_tooltip.AddTool(this, _T("这是一个测试"));
|
|
171 |
|
|
172 |
// m_tooltip.UpdateTipText(_T("提示??????"), this);
|
|
173 |
|
|
174 |
CStatic::PreSubclassWindow();
|
|
175 |
}
|
|
176 |
|
|
177 |
|
|
178 |
int LCDDisplay1::SetZoom(float fZoom)
|
|
179 |
{
|
|
180 |
m_fZoom = fZoom;
|
|
181 |
bHasChanged = 1;
|
|
182 |
this->RedrawWindow();
|
|
183 |
return 1;
|
|
184 |
}
|
|
185 |
|
|
186 |
//HWND CreateToolTip(int toolID, HWND hDlg, PTSTR pszText)
|
|
187 |
//{
|
|
188 |
// if (!toolID || !hDlg || !pszText)
|
|
189 |
// {
|
|
190 |
// return false;
|
|
191 |
// }
|
|
192 |
// HWND hwndTool = GetDlgItem(hDlg, toolID);
|
|
193 |
//
|
|
194 |
// HWND hwndTip = CreateWindowEx(NULL,
|
|
195 |
// TOOLTIPS_CLASS,
|
|
196 |
// NULL,
|
|
197 |
// WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,
|
|
198 |
// CW_USEDEFAULT,
|
|
199 |
// CW_USEDEFAULT,
|
|
200 |
// CW_USEDEFAULT,
|
|
201 |
// CW_USEDEFAULT,
|
|
202 |
// hDlg,
|
|
203 |
// NULL,
|
|
204 |
// AfxGetInstanceHandle(),
|
|
205 |
// NULL);
|
|
206 |
// if (!hwndTool || !hwndTip)
|
|
207 |
// {
|
|
208 |
// return (HWND)NULL;
|
|
209 |
// TOOLINFO toolInfo = { 0 };
|
|
210 |
// toolInfo.cbSize = sizeof(TOOLINFO);
|
|
211 |
// toolInfo.hwnd = hDlg;
|
|
212 |
// toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
|
|
213 |
// toolInfo.uId = (UINT_PTR)hwndTool;
|
|
214 |
// toolInfo.lpszText = pszText;
|
|
215 |
// SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
|
|
216 |
// return hwndTip;
|
|
217 |
// }
|
|
218 |
// return hwndTip;
|
|
219 |
//}
|
|
220 |
int LCDDisplay1::SetBkColor(COLORREF bkcolor)
|
|
221 |
{
|
|
222 |
Gdiplus::Color color1;
|
|
223 |
color1.SetFromCOLORREF(bkcolor);
|
|
224 |
|
|
225 |
m_nBkColor = color1.GetValue();
|
|
226 |
|
|
227 |
m_nHideColor = m_nBkColor - 0x00080808;
|
|
228 |
this->RedrawWindow();
|
|
229 |
return 0;
|
|
230 |
}
|
|
231 |
|
|
232 |
int LCDDisplay1::SetFontColor(COLORREF fntColor)
|
|
233 |
{
|
|
234 |
Gdiplus::Color color1;
|
|
235 |
color1.SetFromCOLORREF(fntColor);
|
|
236 |
|
|
237 |
m_nFntColor = color1.GetValue();
|
|
238 |
|
|
239 |
this->RedrawWindow();
|
|
240 |
return 0;
|
|
241 |
}
|
|
242 |
|
|
243 |
int LCDDisplay1::SetHideColor(COLORREF hideColor)
|
|
244 |
{
|
|
245 |
m_nHideColor = hideColor | 0xff000000;
|
|
246 |
this->RedrawWindow();
|
|
247 |
return 0;
|
|
248 |
}
|
|
249 |
|
|
250 |
void LCDDisplay1::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
|
251 |
{
|
|
252 |
using namespace Gdiplus;
|
|
253 |
UINT j = lpDrawItemStruct->itemState;
|
|
254 |
Gdiplus::Graphics gr0(lpDrawItemStruct->hDC);
|
|
255 |
|
|
256 |
CRect rect0 = lpDrawItemStruct->rcItem;
|
|
257 |
|
|
258 |
//CString s1;
|
|
259 |
//s1.Format(_T("Draw Button Stat %08X \r\n"), j);
|
|
260 |
//SysLog(s1);
|
|
261 |
m_nClientW = rect0.Width();
|
|
262 |
m_nClientH = rect0.Height();
|
|
263 |
|
|
264 |
Gdiplus::Bitmap bitmap1(m_nClientW, m_nClientH);
|
|
265 |
Gdiplus::Graphics gr1(&bitmap1);
|
|
266 |
// gr1.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
|
|
267 |
Rect rect1;
|
|
268 |
rect1.X = rect0.left; rect1.Y = rect0.top;
|
|
269 |
rect1.Width = rect0.Width(); rect1.Height = rect0.Height();
|
|
270 |
|
|
271 |
int mindisindex = -1;
|
|
272 |
float mindis = 999;
|
|
273 |
CString sHintStr;
|
|
274 |
|
|
275 |
{
|
|
276 |
gr1.Clear(m_nBkColor); //填充背景
|
|
277 |
m_nOffsetXMax = 0;
|
|
278 |
m_nOffsetYMax = 0;
|
|
279 |
}
|
|
280 |
pixelsizex = 8; pixelsizey = 8;
|
|
281 |
pixelsizex = int(m_nClientW / 128);
|
|
282 |
pixelsizey = int(m_nClientH / 64);
|
|
283 |
if (pixelsizex < 1) pixelsizex = 1;
|
|
284 |
if (pixelsizey < 1) pixelsizey = 1;
|
|
285 |
if (pixelsizex < 2) pixelgapx = 0; else pixelgapx = 1;
|
|
286 |
if (pixelsizey < 2) pixelgapy = 0; else pixelgapy = 1;
|
|
287 |
|
|
288 |
// pixelgapx = 0.3f;
|
|
289 |
// pixelgapy = 0.3f;
|
|
290 |
|
|
291 |
|
|
292 |
left_margin = (m_nClientW - 128 * pixelsizex) / 2;
|
|
293 |
if (left_margin < 0) left_margin = 0;
|
|
294 |
|
|
295 |
top_margin = (m_nClientH - 64 * pixelsizey) / 2;
|
|
296 |
if (top_margin < 0) top_margin = 0;
|
|
297 |
|
|
298 |
//显示外框
|
|
299 |
Pen pen0(m_nHideColor, 1);
|
|
300 |
gr1.DrawRectangle(&pen0, left_margin - 2, top_margin - 2, 128 * (int)pixelsizex + 2, 64 * (int)pixelsizey + 2);
|
|
301 |
|
|
302 |
SolidBrush brush0(m_nHideColor);
|
|
303 |
SolidBrush brush1(m_nFntColor);
|
|
304 |
|
|
305 |
for (int i = 0; i < 64; i++)
|
|
306 |
{
|
|
307 |
for (int j = 0; j < 128; j++)
|
|
308 |
{
|
|
309 |
if (displayarray[i][j]){
|
|
310 |
|
|
311 |
gr1.FillRectangle(&brush1, left_margin + j * pixelsizex, top_margin + i * pixelsizey, pixelsizex - pixelgapx, pixelsizey - pixelgapy);
|
|
312 |
//gr1.FillEllipse(&brush1, left_margin + j * pixelsizex, top_margin + i * yspace, pixelsizex - pixelgapx, yspace - pixelgapy);
|
|
313 |
}
|
|
314 |
else
|
|
315 |
gr1.FillRectangle(&brush0, left_margin + j * pixelsizex, top_margin + i * pixelsizey, pixelsizex - pixelgapx, pixelsizey - pixelgapy);
|
|
316 |
|
|
317 |
}
|
|
318 |
}
|
|
319 |
/*
|
|
320 |
for (int i = 0; i < m_nClientH; i += 4)
|
|
321 |
{
|
|
322 |
for (int j = 0; j < m_nClientW; j += 4)
|
|
323 |
{
|
|
324 |
gr1.FillRectangle(&brush0, j, i, 3, 3);
|
|
325 |
}
|
|
326 |
}
|
|
327 |
*/
|
|
328 |
|
|
329 |
//显示文字
|
|
330 |
CStringW sw1;
|
|
331 |
GetWindowText(sw1);
|
|
332 |
FontFamily fontfamily1(L"MS Shell Dlg");
|
|
333 |
float fontsizey = rect0.Height() / 2.2f;
|
|
334 |
float fontsizex = rect0.Width() / 2.8f;
|
|
335 |
float fontsize = 12;// min(fontsizex, fontsizey);
|
|
336 |
|
|
337 |
Gdiplus::Font font1(&fontfamily1, fontsize, 0);//::FontStyleBold);
|
|
338 |
SolidBrush brush11(Color::White);
|
|
339 |
SolidBrush brush12(Color::LightBlue);
|
|
340 |
|
|
341 |
StringFormat stringformat1;
|
|
342 |
stringformat1.SetAlignment(Gdiplus::StringAlignmentNear);
|
|
343 |
stringformat1.SetLineAlignment(Gdiplus::StringAlignmentNear);
|
|
344 |
RectF rect2;
|
|
345 |
rect2.X = (float)rect0.left; rect2.Y = rect0.top + 16.0f;
|
|
346 |
rect2.Width = (float)rect0.Width(); rect2.Height = (float)rect0.Height();
|
|
347 |
// gr1.DrawString(sw1, sw1.GetLength(), &font1, PointF(rect1.right / 2.0f, rect1.bottom / 2.0f), &stringformat1, &brush11);
|
|
348 |
gr1.DrawString(sw1, sw1.GetLength(), &font1, rect2, &stringformat1, &brush11);
|
|
349 |
|
|
350 |
//显示在窗口右上角
|
|
351 |
sw1.Format(L"%.2f %d %d ", m_fZoom, m_fDispOffsetX, m_fDispOffsetY);
|
|
352 |
Gdiplus::Font font2(&fontfamily1, 8, 0);//::FontStyleBold);
|
|
353 |
gr1.DrawString(sw1, sw1.GetLength(), &font1, PointF(rect0.right - 120.0f, 0), &stringformat1, &brush11);
|
|
354 |
|
|
355 |
float scrdis = mindis * m_fZoom;
|
|
356 |
//显示在鼠标右下角
|
|
357 |
sw1.Format(L"%d %d %.2f %.2f \r\n%d %.2f %.2f %s", m_nMouseWndX, m_nMouseWndY, m_MousePicX, m_MousePicY, mindisindex, mindis, scrdis, sHintStr);
|
|
358 |
// gr1.DrawString(sw1, sw1.GetLength(), &font1, PointF(m_nMouseWndX+8.0f, m_nMouseWndY+16.0f), &stringformat1, &brush12);
|
|
359 |
gr0.DrawImage(&bitmap1, 0, 0);
|
|
360 |
|
|
361 |
if (scrdis <= 5)
|
|
362 |
{
|
|
363 |
m_tooltip.UpdateTipText(sHintStr, this);
|
|
364 |
m_tooltip.Popup();
|
|
365 |
;
|
|
366 |
// CreateToolTip(this->GetDlgCtrlID(), this->GetParent()->GetSafeHwnd(), _T("这是二个测试"));
|
|
367 |
}
|
|
368 |
else
|
|
369 |
{
|
|
370 |
m_tooltip.UpdateTipText(_T(""), this);
|
|
371 |
m_tooltip.HideCaret();
|
|
372 |
}
|
|
373 |
|
|
374 |
// TODO: 添加您的代码以绘制指定项
|
|
375 |
}
|
|
376 |
|
|
377 |
void LCDDisplay1::OnKillFocus(CWnd* pNewWnd)
|
|
378 |
{
|
|
379 |
CStatic::OnKillFocus(pNewWnd);
|
|
380 |
CString s1;
|
|
381 |
// GetWindowText(s1);
|
|
382 |
// s1.Append(_T("KF "));
|
|
383 |
// SetWindowText(s1);
|
|
384 |
// TODO: 在此处添加消息处理程序代码
|
|
385 |
}
|
|
386 |
|
|
387 |
void LCDDisplay1::OnSize(UINT nType, int cx, int cy)
|
|
388 |
{
|
|
389 |
CStatic::OnSize(nType, cx, cy);
|
|
390 |
CString s1;
|
|
391 |
// GetWindowText(s1);
|
|
392 |
// s1.Append(_T("S "));
|
|
393 |
// SetWindowText(s1);
|
|
394 |
|
|
395 |
// TODO: 在此处添加消息处理程序代码
|
|
396 |
}
|
|
397 |
|
|
398 |
int LCDDisplay1::TranslatePTtoColRow(int x, int y, int& nCol, int& nRow)
|
|
399 |
{
|
|
400 |
// TODO: 在此处添加实现代码.
|
|
401 |
if (x < left_margin) return false;
|
|
402 |
if (y < top_margin) return false;
|
|
403 |
int refx, refy;
|
|
404 |
refx = x - left_margin;
|
|
405 |
refy = y - top_margin;
|
|
406 |
|
|
407 |
nCol = refx / pixelsizex;
|
|
408 |
nRow = refy / pixelsizey;
|
|
409 |
if (nCol >= 128) { return false; }
|
|
410 |
if (nRow >= 64) { return false; }
|
|
411 |
return true;
|
|
412 |
}
|
|
413 |
|
|
414 |
|
|
415 |
void LCDDisplay1::OnLButtonDown(UINT nFlags, CPoint point)
|
|
416 |
{
|
|
417 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
418 |
CString s1;
|
|
419 |
// GetWindowText(s1);
|
|
420 |
// s1.Append(_T("LD "));
|
|
421 |
// SetWindowText(s1);
|
|
422 |
SetFocus();
|
|
423 |
m_nLastMouseX = point.x;
|
|
424 |
m_nLastMouseY = point.y;
|
|
425 |
if (m_nMouseMode == MouseModeCursor)
|
|
426 |
{
|
|
427 |
int bFound = 0;
|
|
428 |
int nCol, nRow;
|
|
429 |
if (TranslatePTtoColRow(point.x, point.y, nCol, nRow)) {
|
|
430 |
if (displayarray[nRow][nCol])
|
|
431 |
displayarray[nRow][nCol] = 0;
|
|
432 |
else
|
|
433 |
displayarray[nRow][nCol] = 1;
|
|
434 |
this->RedrawWindow();
|
|
435 |
};
|
|
436 |
//*/
|
|
437 |
}
|
|
438 |
else if (m_nMouseMode == MouseModeHand)
|
|
439 |
{
|
|
440 |
bViewMoving = 1;
|
|
441 |
SetCapture();
|
|
442 |
}
|
|
443 |
else if (m_nMouseMode == MouseModeZoomIn)
|
|
444 |
{
|
|
445 |
|
|
446 |
}
|
|
447 |
else if (m_nMouseMode == MouseModeZoomOut)
|
|
448 |
{
|
|
449 |
|
|
450 |
}
|
|
451 |
CStatic::OnLButtonDown(nFlags, point);
|
|
452 |
}
|
|
453 |
|
|
454 |
|
|
455 |
void LCDDisplay1::OnLButtonUp(UINT nFlags, CPoint point)
|
|
456 |
{
|
|
457 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
458 |
CString s1;
|
|
459 |
// GetWindowText(s1);
|
|
460 |
// s1.Append(_T("LU "));
|
|
461 |
// SetWindowText(s1);
|
|
462 |
/*
|
|
463 |
if (pTargetShape != nullptr)
|
|
464 |
{
|
|
465 |
pTargetShape->EndDrag(nTargetPoint, fDragStartx,fDragStarty,m_MousePicX, m_MousePicY);
|
|
466 |
pTargetShape = nullptr;
|
|
467 |
this->RedrawWindow();
|
|
468 |
}
|
|
469 |
*/
|
|
470 |
bViewMoving = 0;
|
|
471 |
ReleaseCapture();
|
|
472 |
CStatic::OnLButtonUp(nFlags, point);
|
|
473 |
}
|
|
474 |
|
|
475 |
void LCDDisplay1::OnLButtonDblClk(UINT nFlags, CPoint point)
|
|
476 |
{
|
|
477 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
478 |
CString s1;
|
|
479 |
// GetWindowText(s1);
|
|
480 |
// s1.Append(_T("LDB "));
|
|
481 |
// SetWindowText(s1);
|
|
482 |
|
|
483 |
CStatic::OnLButtonDblClk(nFlags, point);
|
|
484 |
}
|
|
485 |
|
|
486 |
void LCDDisplay1::OnMouseMove(UINT nFlags, CPoint point)
|
|
487 |
{
|
|
488 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
489 |
//CString s1;
|
|
490 |
//GetWindowText(s1);
|
|
491 |
//s1.Append(_T("MM"));
|
|
492 |
//SetWindowText(s1);
|
|
493 |
if (bViewMoving)
|
|
494 |
{
|
|
495 |
int delX, delY;
|
|
496 |
delX = point.x - m_nLastMouseX;
|
|
497 |
delY = point.y - m_nLastMouseY;
|
|
498 |
|
|
499 |
m_fDispOffsetX += delX;
|
|
500 |
m_fDispOffsetY += delY;
|
|
501 |
if (m_fDispOffsetX > m_nOffsetXMax) { m_fDispOffsetX = m_nOffsetXMax; }
|
|
502 |
if (m_fDispOffsetX < -m_nOffsetXMax) { m_fDispOffsetX = -m_nOffsetXMax; }
|
|
503 |
|
|
504 |
if (m_fDispOffsetY > m_nOffsetYMax) { m_fDispOffsetY = m_nOffsetYMax; }
|
|
505 |
if (m_fDispOffsetY < -m_nOffsetYMax) { m_fDispOffsetY = -m_nOffsetYMax; }
|
|
506 |
}
|
|
507 |
m_nLastMouseX = point.x;
|
|
508 |
m_nLastMouseY = point.y;
|
|
509 |
m_nMouseWndX = point.x;
|
|
510 |
m_nMouseWndY = point.y;;
|
|
511 |
bHasChanged = 1;
|
|
512 |
// this->RedrawWindow();
|
|
513 |
/*
|
|
514 |
if (pTargetShape != nullptr)
|
|
515 |
{
|
|
516 |
pTargetShape->DragTo(nTargetPoint, fDragStartx,fDragStarty,m_MousePicX, m_MousePicY);
|
|
517 |
}
|
|
518 |
*/
|
|
519 |
// this->RedrawWindow();
|
|
520 |
|
|
521 |
//构造一个MSG
|
|
522 |
|
|
523 |
//MSG msg;
|
|
524 |
//msg.hwnd = m_hWnd;
|
|
525 |
//msg.message = WM_MOUSEMOVE;
|
|
526 |
//msg.wParam = LOWORD(point.x);
|
|
527 |
//msg.lParam = LOWORD(point.y);
|
|
528 |
//msg.time = 0;
|
|
529 |
//msg.pt.x = LOWORD(point.y);
|
|
530 |
//msg.pt.y = HIWORD(point.y);
|
|
531 |
//m_tooltip.RelayEvent(&msg);
|
|
532 |
//CStatic::OnMouseMove(nFlags, point);
|
|
533 |
|
|
534 |
}
|
|
535 |
|
|
536 |
|
|
537 |
BOOL LCDDisplay1::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
|
|
538 |
{
|
|
539 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
540 |
CString s1;
|
|
541 |
// GetWindowText(s1);
|
|
542 |
// s1.Append(_T("MW "));
|
|
543 |
// SetWindowText(s1);
|
|
544 |
// m_fDispOffX 居中是0,0
|
|
545 |
CRect rect0;
|
|
546 |
|
|
547 |
GetWindowRect(&rect0);
|
|
548 |
// CString s1;
|
|
549 |
//s1.Format(_T("Draw Button Stat %08X \r\n"), j);
|
|
550 |
//SysLog(s1);
|
|
551 |
int w = rect0.Width();
|
|
552 |
int h = rect0.Height();
|
|
553 |
ScreenToClient(&pt);
|
|
554 |
int ptx, pty;
|
|
555 |
ptx = pt.x; pty = pt.y;
|
|
556 |
|
|
557 |
if (zDelta > 0)
|
|
558 |
{
|
|
559 |
if (m_fZoom < 256)
|
|
560 |
{
|
|
561 |
m_fDispOffsetX = int(m_fDispOffsetX*1.41421356237f - (ptx - w / 2)*0.41421356237f);
|
|
562 |
m_fDispOffsetY = int(m_fDispOffsetY*1.41421356237f - (pty - h / 2)*0.41421356237f);
|
|
563 |
m_fZoom *= 1.41421356237f;
|
|
564 |
}
|
|
565 |
}
|
|
566 |
else if (zDelta < 0)
|
|
567 |
{
|
|
568 |
if (m_fZoom > 0.05)
|
|
569 |
{
|
|
570 |
m_fDispOffsetX = int(m_fDispOffsetX / 1.41421356237f + (ptx - w / 2)*0.292893218815f);
|
|
571 |
m_fDispOffsetY = int(m_fDispOffsetY / 1.41421356237f + (pty - h / 2)*0.292893218815f);
|
|
572 |
m_fZoom /= 1.41421356237f;
|
|
573 |
}
|
|
574 |
}
|
|
575 |
if (m_fDispOffsetX > m_nOffsetXMax) { m_fDispOffsetX = m_nOffsetXMax; }
|
|
576 |
if (m_fDispOffsetX < -m_nOffsetXMax) { m_fDispOffsetX = -m_nOffsetXMax; }
|
|
577 |
|
|
578 |
if (m_fDispOffsetY > m_nOffsetYMax) { m_fDispOffsetY = m_nOffsetYMax; }
|
|
579 |
if (m_fDispOffsetY < -m_nOffsetYMax) { m_fDispOffsetY = -m_nOffsetYMax; }
|
|
580 |
bHasChanged = 1;
|
|
581 |
// this->RedrawWindow();
|
|
582 |
return CStatic::OnMouseWheel(nFlags, zDelta, pt);
|
|
583 |
}
|
|
584 |
|
|
585 |
void LCDDisplay1::OnMouseLeave()
|
|
586 |
{
|
|
587 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
588 |
CString s1;
|
|
589 |
GetWindowText(s1);
|
|
590 |
s1.Append(_T("ML "));
|
|
591 |
SetWindowText(s1);
|
|
592 |
CStatic::OnMouseLeave();
|
|
593 |
}
|
|
594 |
|
|
595 |
|
|
596 |
|
|
597 |
void LCDDisplay1::OnStnClicked()
|
|
598 |
{
|
|
599 |
// TODO: 在此添加控件通知处理程序代码
|
|
600 |
// CString s1;
|
|
601 |
// GetWindowText(s1);
|
|
602 |
// s1.Append(_T("StnC "));
|
|
603 |
// SetWindowText(s1);
|
|
604 |
}
|
|
605 |
|
|
606 |
|
|
607 |
void LCDDisplay1::OnStnDblclick()
|
|
608 |
{
|
|
609 |
// TODO: 在此添加控件通知处理程序代码
|
|
610 |
CString s1;
|
|
611 |
// GetWindowText(s1);
|
|
612 |
// s1.Append(_T("StnDb "));
|
|
613 |
// SetWindowText(s1);
|
|
614 |
}
|
|
615 |
|
|
616 |
|
|
617 |
void LCDDisplay1::OnRButtonDown(UINT nFlags, CPoint point)
|
|
618 |
{
|
|
619 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
620 |
CString s1;
|
|
621 |
// GetWindowText(s1);
|
|
622 |
// s1.Append(_T("RD "));
|
|
623 |
// SetWindowText(s1);
|
|
624 |
CStatic::OnRButtonDown(nFlags, point);
|
|
625 |
}
|
|
626 |
|
|
627 |
|
|
628 |
void LCDDisplay1::OnRButtonUp(UINT nFlags, CPoint point)
|
|
629 |
{
|
|
630 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
631 |
CString s1;
|
|
632 |
// GetWindowText(s1);
|
|
633 |
// s1.Append(_T("RU "));
|
|
634 |
// SetWindowText(s1);
|
|
635 |
CStatic::OnRButtonUp(nFlags, point);
|
|
636 |
}
|
|
637 |
|
|
638 |
|
|
639 |
void LCDDisplay1::OnRButtonDblClk(UINT nFlags, CPoint point)
|
|
640 |
{
|
|
641 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
642 |
CString s1;
|
|
643 |
GetWindowText(s1);
|
|
644 |
s1.Append(_T("RDB "));
|
|
645 |
SetWindowText(s1);
|
|
646 |
CStatic::OnRButtonDblClk(nFlags, point);
|
|
647 |
}
|
|
648 |
|
|
649 |
|
|
650 |
void LCDDisplay1::OnMButtonDown(UINT nFlags, CPoint point)
|
|
651 |
{
|
|
652 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
653 |
CString s1;
|
|
654 |
GetWindowText(s1);
|
|
655 |
s1.Append(_T("MD "));
|
|
656 |
SetWindowText(s1);
|
|
657 |
CStatic::OnMButtonDown(nFlags, point);
|
|
658 |
}
|
|
659 |
|
|
660 |
|
|
661 |
void LCDDisplay1::OnMButtonUp(UINT nFlags, CPoint point)
|
|
662 |
{
|
|
663 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
664 |
CString s1;
|
|
665 |
GetWindowText(s1);
|
|
666 |
s1.Append(_T("MU "));
|
|
667 |
SetWindowText(s1);
|
|
668 |
CStatic::OnMButtonUp(nFlags, point);
|
|
669 |
}
|
|
670 |
|
|
671 |
|
|
672 |
void LCDDisplay1::OnMButtonDblClk(UINT nFlags, CPoint point)
|
|
673 |
{
|
|
674 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
675 |
CString s1;
|
|
676 |
GetWindowText(s1);
|
|
677 |
s1.Append(_T("MDB "));
|
|
678 |
SetWindowText(s1);
|
|
679 |
CStatic::OnMButtonDblClk(nFlags, point);
|
|
680 |
}
|
|
681 |
|
|
682 |
|
|
683 |
void LCDDisplay1::OnTimer(UINT_PTR nIDEvent)
|
|
684 |
{
|
|
685 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
686 |
if (nIDEvent == 0) {
|
|
687 |
|
|
688 |
}
|
|
689 |
else if (nIDEvent == 1) {
|
|
690 |
|
|
691 |
}
|
|
692 |
else {
|
|
693 |
|
|
694 |
}
|
|
695 |
CStatic::OnTimer(nIDEvent);
|
|
696 |
}
|
|
697 |
|
|
698 |
|
|
699 |
void LCDDisplay1::OnContextMenu(CWnd* pWnd, CPoint point)
|
|
700 |
{
|
|
701 |
// TODO: 在此处添加消息处理程序代码
|
|
702 |
CString s1;
|
|
703 |
// GetWindowText(s1);
|
|
704 |
// s1.Append(_T("CM "));
|
|
705 |
// SetWindowText(s1);
|
|
706 |
m_menu1.TrackPopupMenu(NULL, point.x, point.y, pWnd);
|
|
707 |
}
|
|
708 |
|
|
709 |
int LCDDisplay1::Clear(int bRedraw)
|
|
710 |
{
|
|
711 |
// MyGraphics.clear();
|
|
712 |
// MyShapeCollections.clear();
|
|
713 |
for (int i = 0; i < 64; i++) {
|
|
714 |
for (int j = 0; j < 128; j++) {
|
|
715 |
displayarray[i][j] = 0;
|
|
716 |
}
|
|
717 |
}
|
|
718 |
if (bRedraw) this->RedrawWindow();
|
|
719 |
return HvOk;
|
|
720 |
}
|
|
721 |
|
|
722 |
int LCDDisplay1::AddData(short * pData, int nSize, int bRedraw)
|
|
723 |
{
|
|
724 |
memcpy(FreqBuf1, pData, nSize);
|
|
725 |
memmove(pullBuf1[1], pullBuf1[0], 1023 * 256);
|
|
726 |
nDataSize = nSize;
|
|
727 |
for (int i = 0; i < nSize; i++)
|
|
728 |
{
|
|
729 |
int value = FreqBuf1[i] - 10;
|
|
730 |
if (FreqBuf1[i] < 0) { pullBuf1[0][i] = 0; }
|
|
731 |
else if (FreqBuf1[i] > 255) { pullBuf1[0][i] = 255; }
|
|
732 |
else { pullBuf1[0][i] = FreqBuf1[i]; }
|
|
733 |
}
|
|
734 |
// if (bRedraw) this->RedrawWindow();
|
|
735 |
return HvOk;
|
|
736 |
}
|
|
737 |
/*
|
|
738 |
int LCDDisplay1::UpdateData(short * pData, int nSize, int bRedraw)
|
|
739 |
{
|
|
740 |
memcpy(FreqBuf1, pData, nSize);
|
|
741 |
nDataSize = nSize ;
|
|
742 |
if (bRedraw) this->RedrawWindow();
|
|
743 |
return HvOk;
|
|
744 |
}
|
|
745 |
*/
|
|
746 |
/*
|
|
747 |
int LCDDisplay1::Add(pHvShape theshape, int bRedraw)
|
|
748 |
{
|
|
749 |
MyGraphics.push_back(theshape);
|
|
750 |
if (bRedraw) this->RedrawWindow();
|
|
751 |
return int(MyGraphics.size());
|
|
752 |
}
|
|
753 |
|
|
754 |
int LCDDisplay1::AddList(pHvShapeCollection theShapeColletion, int bRedraw)
|
|
755 |
{
|
|
756 |
MyShapeCollections.push_back(theShapeColletion);
|
|
757 |
if (bRedraw) this->RedrawWindow();
|
|
758 |
return int(MyShapeCollections.size());
|
|
759 |
}
|
|
760 |
|
|
761 |
int LCDDisplay1::Remove(pHvShape theshape, int bRedraw )
|
|
762 |
{
|
|
763 |
if (theshape == nullptr) return HvErr;
|
|
764 |
int n = MyGraphics.size();
|
|
765 |
for (int i = 0; i < n; i++)
|
|
766 |
{
|
|
767 |
if (theshape == MyGraphics[i])
|
|
768 |
{
|
|
769 |
MyGraphics.erase(MyGraphics.begin() + i);
|
|
770 |
break;
|
|
771 |
}
|
|
772 |
}
|
|
773 |
if (bRedraw) this->RedrawWindow();
|
|
774 |
return int(MyGraphics.size());
|
|
775 |
}
|
|
776 |
*/
|
|
777 |
BOOL LCDDisplay1::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
|
778 |
{
|
|
779 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
780 |
if (m_nMouseMode == MouseModeCursor)
|
|
781 |
{
|
|
782 |
HCURSOR hCur = LoadCursor(NULL, IDC_ARROW);
|
|
783 |
::SetCursor(hCur);
|
|
784 |
return TRUE;
|
|
785 |
}
|
|
786 |
else if (m_nMouseMode == MouseModeHand)
|
|
787 |
{
|
|
788 |
HCURSOR hCur = LoadCursor(NULL, IDC_HAND);
|
|
789 |
::SetCursor(hCur);
|
|
790 |
return TRUE;
|
|
791 |
}
|
|
792 |
else if (m_nMouseMode == MouseModeZoomIn)
|
|
793 |
{
|
|
794 |
//HCURSOR hCur = LoadCursor(NULL, IDC_UPARROW);
|
|
795 |
//::SetCursor(hCur);
|
|
796 |
//return TRUE;
|
|
797 |
}
|
|
798 |
else if (m_nMouseMode == MouseModeZoomOut)
|
|
799 |
{
|
|
800 |
//HCURSOR hCur = LoadCursor(NULL, IDC_ARROW);
|
|
801 |
//::SetCursor(hCur);
|
|
802 |
//return TRUE;
|
|
803 |
}
|
|
804 |
// return TRUE;
|
|
805 |
return CStatic::OnSetCursor(pWnd, nHitTest, message);
|
|
806 |
}
|
|
807 |
|
|
808 |
int LCDDisplay1::AddMenuItem(CString sMenuStr, pMenuCallBack pFunc, void * pParam)
|
|
809 |
{
|
|
810 |
if (nExtMenuCount >= 10) return HvErr;
|
|
811 |
if (nExtMenuCount == 0) m_menu1.InsertMenu(0, MF_BYPOSITION | MF_SEPARATOR);
|
|
812 |
|
|
813 |
myCallBack[nExtMenuCount].bIsSet = 1;
|
|
814 |
myCallBack[nExtMenuCount].pParam = pParam;
|
|
815 |
myCallBack[nExtMenuCount].pFunc = pFunc;
|
|
816 |
m_menu1.InsertMenu(nExtMenuCount, MF_BYPOSITION | MF_STRING, WM_MENUST + ID_MenuItemCustom + nExtMenuCount, sMenuStr);
|
|
817 |
nExtMenuCount++;
|
|
818 |
|
|
819 |
return HvOk;
|
|
820 |
}
|
|
821 |
|
|
822 |
void LCDDisplay1::OnMenuS1(UINT nId)
|
|
823 |
{
|
|
824 |
CString s1;
|
|
825 |
int nMenuId = nId - WM_MENUST;
|
|
826 |
GetWindowText(s1);
|
|
827 |
s1.AppendFormat(_T("M%d "), nId);
|
|
828 |
// SetWindowText(s1);
|
|
829 |
int j;
|
|
830 |
CRect rect1;
|
|
831 |
switch (nMenuId)
|
|
832 |
{
|
|
833 |
case ID_Point:
|
|
834 |
m_menu1.CheckMenuItem(WM_MENUST + nOldMenuSel, 0);
|
|
835 |
m_menu1.CheckMenuItem(WM_MENUST + ID_Point, MF_CHECKED);
|
|
836 |
m_nMouseMode = MouseModeCursor;
|
|
837 |
nOldMenuSel = ID_Point;
|
|
838 |
break;
|
|
839 |
case ID_Move:
|
|
840 |
m_menu1.CheckMenuItem(WM_MENUST + nOldMenuSel, 0);
|
|
841 |
m_menu1.CheckMenuItem(WM_MENUST + ID_Move, MF_CHECKED);
|
|
842 |
m_nMouseMode = MouseModeHand;
|
|
843 |
nOldMenuSel = ID_Move;
|
|
844 |
break;
|
|
845 |
case ID_ZoomIn:
|
|
846 |
m_menu1.CheckMenuItem(WM_MENUST + nOldMenuSel, 0);
|
|
847 |
m_menu1.CheckMenuItem(WM_MENUST + ID_ZoomIn, MF_CHECKED);
|
|
848 |
m_nMouseMode = MouseModeZoomIn;
|
|
849 |
nOldMenuSel = ID_ZoomIn;
|
|
850 |
break;
|
|
851 |
case ID_ZoomOut:
|
|
852 |
m_menu1.CheckMenuItem(WM_MENUST + nOldMenuSel, 0);
|
|
853 |
m_menu1.CheckMenuItem(WM_MENUST + ID_ZoomOut, MF_CHECKED);
|
|
854 |
m_nMouseMode = MouseModeZoomOut;
|
|
855 |
nOldMenuSel = ID_ZoomOut;
|
|
856 |
break;
|
|
857 |
case ID_PixelGrid:
|
|
858 |
j = m_menu1.GetMenuState(WM_MENUST + ID_PixelGrid, MF_CHECKED);
|
|
859 |
if (j) { m_menu1.CheckMenuItem(WM_MENUST + ID_PixelGrid, 0); }
|
|
860 |
else { m_menu1.CheckMenuItem(WM_MENUST + ID_PixelGrid, MF_CHECKED); }
|
|
861 |
|
|
862 |
break;
|
|
863 |
case ID_SubPixelGrid:
|
|
864 |
j = m_menu1.GetMenuState(WM_MENUST + ID_SubPixelGrid, MF_CHECKED);
|
|
865 |
if (j) { m_menu1.CheckMenuItem(WM_MENUST + ID_SubPixelGrid, 0); }
|
|
866 |
else { m_menu1.CheckMenuItem(WM_MENUST + ID_SubPixelGrid, MF_CHECKED); }
|
|
867 |
|
|
868 |
break;
|
|
869 |
case ID_ZoomFit:
|
|
870 |
// SetBestFitZoom();
|
|
871 |
break;
|
|
872 |
case ID_OrgScale:
|
|
873 |
SetZoom(1);
|
|
874 |
break;
|
|
875 |
case ID_Seprate_Window:
|
|
876 |
this->GetParent()->GetClientRect(&rect1);;
|
|
877 |
MoveWindow(&rect1);
|
|
878 |
break;
|
|
879 |
case ID_Restore_Window:
|
|
880 |
ModifyStyle(WS_POPUPWINDOW, WS_CHILDWINDOW);
|
|
881 |
break;
|
|
882 |
case ID_LoadImage:
|
|
883 |
// QLoadImage();
|
|
884 |
break;
|
|
885 |
case ID_SaveImageAs:
|
|
886 |
break;
|
|
887 |
// QSaveImage();
|
|
888 |
default:
|
|
889 |
break;
|
|
890 |
}
|
|
891 |
}
|
|
892 |
void LCDDisplay1::OnMenuS(UINT nId)
|
|
893 |
{
|
|
894 |
CString s1;
|
|
895 |
GetWindowText(s1);
|
|
896 |
s1.AppendFormat(_T("M%d "), nId);
|
|
897 |
SetWindowText(s1);
|
|
898 |
int nExtId = nId - WM_MENUST - ID_MenuItemCustom;
|
|
899 |
|
|
900 |
myCallBack[nExtId].pFunc(myCallBack[nExtId].pParam);
|
|
901 |
}
|
|
902 |
|
|
903 |
int LCDDisplay1::FFT(float *pBuf1, int nSize, float *pBufOut)
|
|
904 |
{
|
|
905 |
|
|
906 |
|
|
907 |
return HvOk;
|
|
908 |
}
|
|
909 |
|
|
910 |
|
|
911 |
int LCDDisplay1::SetTextMode(int nMode)
|
|
912 |
{
|
|
913 |
// TODO: 在此处添加实现代码.
|
|
914 |
if (nMode == TextModeDefault) {
|
|
915 |
char_width = 6;
|
|
916 |
char_height = 8;
|
|
917 |
text_cols = 21;
|
|
918 |
text_rows = 8;
|
|
919 |
m_TextMode = nMode;
|
|
920 |
m_cursor_x = 0;
|
|
921 |
m_cursor_y = 0;
|
|
922 |
}
|
|
923 |
else if (nMode == TextMode3_5) {
|
|
924 |
char_width = 4;
|
|
925 |
char_height = 6;
|
|
926 |
text_cols = 32;
|
|
927 |
text_rows = 10;
|
|
928 |
m_TextMode = nMode;
|
|
929 |
m_cursor_x = 0;
|
|
930 |
m_cursor_y = 0;
|
|
931 |
}
|
|
932 |
else if (nMode == TextMode5_7) {
|
|
933 |
char_width = 6;
|
|
934 |
char_height = 8;
|
|
935 |
text_cols = 21;
|
|
936 |
text_rows = 8;
|
|
937 |
m_TextMode = nMode;
|
|
938 |
m_cursor_x = 0;
|
|
939 |
m_cursor_y = 0;
|
|
940 |
|
|
941 |
}
|
|
942 |
else if (nMode == TextMode5_11) {
|
|
943 |
char_width = 6;
|
|
944 |
char_height = 12;
|
|
945 |
text_cols = 21;
|
|
946 |
text_rows = 5;
|
|
947 |
m_TextMode = nMode;
|
|
948 |
m_cursor_x = 0;
|
|
949 |
m_cursor_y = 0;
|
|
950 |
|
|
951 |
}
|
|
952 |
else if (nMode == TextMode7_11) {
|
|
953 |
char_width = 8;
|
|
954 |
char_height = 12;
|
|
955 |
text_cols = 16;
|
|
956 |
text_rows = 5;
|
|
957 |
m_TextMode = nMode;
|
|
958 |
m_cursor_x = 0;
|
|
959 |
m_cursor_y = 0;
|
|
960 |
|
|
961 |
}
|
|
962 |
else if (nMode == TextMode7_12) {
|
|
963 |
char_width = 8;
|
|
964 |
char_height = 13;
|
|
965 |
text_cols = 16;
|
|
966 |
text_rows = 5;
|
|
967 |
m_TextMode = nMode;
|
|
968 |
m_cursor_x = 0;
|
|
969 |
m_cursor_y = 0;
|
|
970 |
|
|
971 |
}
|
|
972 |
else if (nMode == TextMode7_15) {
|
|
973 |
char_width = 8;
|
|
974 |
char_height = 16;
|
|
975 |
text_cols = 16;
|
|
976 |
text_rows = 4;
|
|
977 |
m_TextMode = nMode;
|
|
978 |
m_cursor_x = 0;
|
|
979 |
m_cursor_y = 0;
|
|
980 |
|
|
981 |
}
|
|
982 |
else {
|
|
983 |
char_width = 6;
|
|
984 |
char_height = 8;
|
|
985 |
text_cols = 21;
|
|
986 |
text_rows = 8;
|
|
987 |
m_TextMode = nMode;
|
|
988 |
m_cursor_x = 0;
|
|
989 |
m_cursor_y = 0;
|
|
990 |
}
|
|
991 |
|
|
992 |
return 0;
|
|
993 |
}
|
|
994 |
|
|
995 |
int LCDDisplay1::putText(const char * text)
|
|
996 |
{
|
|
997 |
// TODO: 在此处添加实现代码.
|
|
998 |
int l = strlen(text);
|
|
999 |
for (int i = 0; i < l; i++) {
|
|
1000 |
int curx = m_cursor_x * char_width;
|
|
1001 |
int cury = m_cursor_y * char_height;
|
|
1002 |
char ch = text[i];
|
|
1003 |
long long dots = font5_7[ch];
|
|
1004 |
|
|
1005 |
for (int m = 0; m < 7; m++)
|
|
1006 |
{
|
|
1007 |
int line = dots & 0x3f;
|
|
1008 |
int mask = 1;
|
|
1009 |
for (int n = 0; n < 5; n++)
|
|
1010 |
{
|
|
1011 |
if (line&mask){
|
|
1012 |
displayarray[cury + m][curx + n] = 1;
|
|
1013 |
}
|
|
1014 |
else {
|
|
1015 |
displayarray[cury + m][curx + n] = 0;
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
mask <<= 1;
|
|
1019 |
}
|
|
1020 |
dots >>= 6;
|
|
1021 |
}
|
|
1022 |
m_cursor_x += 1;
|
|
1023 |
if (m_cursor_x >= text_cols) { m_cursor_x = 0; m_cursor_y += 1; }
|
|
1024 |
if (m_cursor_y >= text_rows) { m_cursor_y = 0; }
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
return 0;
|
|
1028 |
}
|
|
1029 |
|
|
1030 |
int LCDDisplay1::putTextXY(int x, int y, const char * text)
|
|
1031 |
{
|
|
1032 |
// TODO: 在此处添加实现代码.
|
|
1033 |
int l = strlen(text);
|
|
1034 |
m_cursor_x = x;
|
|
1035 |
m_cursor_y = y;
|
|
1036 |
for (int i = 0; i < l; i++) {
|
|
1037 |
int curx = m_cursor_x * char_width;
|
|
1038 |
int cury = m_cursor_y * char_height;
|
|
1039 |
char ch = text[i];
|
|
1040 |
long long dots = font5_7[ch];
|
|
1041 |
|
|
1042 |
for (int m = 0; m < 7; m++)
|
|
1043 |
{
|
|
1044 |
int line = dots & 0x3f;
|
|
1045 |
int mask = 1;
|
|
1046 |
for (int n = 0; n < 5; n++)
|
|
1047 |
{
|
|
1048 |
if (line&mask){
|
|
1049 |
displayarray[cury + m][curx + n] = 1;
|
|
1050 |
}
|
|
1051 |
else {
|
|
1052 |
displayarray[cury + m][curx + n] = 0;
|
|
1053 |
}
|
|
1054 |
mask <<= 1;
|
|
1055 |
}
|
|
1056 |
dots >>= 6;
|
|
1057 |
}
|
|
1058 |
m_cursor_x += 1;
|
|
1059 |
if (m_cursor_x >= text_cols) { m_cursor_x = 0; m_cursor_y += 1; }
|
|
1060 |
if (m_cursor_y >= text_rows) { m_cursor_y = 0; }
|
|
1061 |
}
|
|
1062 |
return 0;
|
|
1063 |
}
|
|
1064 |
|
|
1065 |
|
|
1066 |
|