1 // font_path_dialog.cpp : implementation file
2 //
3
4 //#include "stdafx.h"
5 #include "studiox_includes.h"
6 #include "font_path_dialog.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #endif
11
12 #define ID_START_FIELD 4096
13 #define ID_END_FIELD 4097
14 #define ID_ENABLE_BOX 4098
15
16 #define RANGE_ROW_HEIGHT 26
17
18 BEGIN_MESSAGE_MAP(font_path_dialog, express_dialog)
19 ON_BN_CLICKED(IDC_CUSTOM_OUTPUT, &font_path_dialog::OnBnClickedCustomOutput)
20 ON_BN_CLICKED(IDC_BROWSE, &font_path_dialog::OnBnClickedBrowse)
21 ON_BN_CLICKED(IDCANCEL, &font_path_dialog::OnCancel)
22 ON_BN_CLICKED(IDOK, &font_path_dialog::OnBnClickedOk)
23 ON_WM_CREATE()
24 ON_BN_CLICKED(IDB_PATH_TYPE, &font_path_dialog::OnBnClickedPathType)
25 ON_COMMAND(ID_PATHTYPE_PROJECTRELATIVE, SetPathProjectRelative)
26 ON_COMMAND(ID_PATHTYPE_STUDIORELATIVE, SetPathStudioRelative)
27 ON_COMMAND(ID_PATHTYPE_ABSOLUTE, SetPathAbsolute)
28 ON_EN_KILLFOCUS(IDC_FONT_PATH, OnKillFontPathEdit)
29 ON_MESSAGE(STUDIO_TEST, OnTestMessage)
30 ON_WM_SIZE()
31 ON_BN_CLICKED(IDC_SUPPORT_EXTENDED_UNICODE, &font_path_dialog::OnBnClickedSupportExtendedUnicode)
32 ON_EN_KILLFOCUS(IDC_FONT_HEIGHT, &font_path_dialog::OnEnChangeFontHeight)
33 ON_WM_PAINT()
34 END_MESSAGE_MAP()
35
36 BEGIN_MESSAGE_MAP(range_list_win, CWnd)
37 ON_WM_CREATE()
38 ON_WM_VSCROLL()
39 ON_WM_MOUSEWHEEL()
40 ON_WM_SETFOCUS()
41 END_MESSAGE_MAP()
42
43 BEGIN_MESSAGE_MAP(font_range_row, CWnd)
44 ON_WM_CREATE()
45 ON_WM_PAINT()
46 ON_BN_CLICKED(ID_ENABLE_BOX, OnChangeEnabled)
47 ON_EN_KILLFOCUS(ID_START_FIELD, OnEditRangeField)
48 ON_EN_KILLFOCUS(ID_END_FIELD, OnEditRangeField)
49 END_MESSAGE_MAP()
50
51 extern CString target_class_name;
52
53 // font_path_dialog dialog
54
55 //IMPLEMENT_DYNAMIC(font_path_dialog, CDialog)
56
57 typedef struct {
58 int first_char;
59 int last_char;
60 char *name;
61 } GLYPH_RANGE;
62
63 ///////////////////////////////////////////////////////////////////////////////
64 GLYPH_RANGE DefaultGlyphRanges[NUM_FONT_CHAR_RANGES + 1] = {
65 { 0x0020, 0x007e, "Ascii"},
66 {0x0080, 0x017f, "Latin Extended-A"},
67 {0x0180, 0x0217, "Latin Extended-B"},
68 {0x0250, 0x02ab, "IPA Extensions"},
69 {0x02b0, 0x02e9, "Spacing Modifiers"},
70 {0x0300, 0x0345, "Combining Diacritics"},
71 {0x0374, 0x03f3, "Greek and Coptic"},
72 {0x0401, 0x04f9, "Cyrillic"},
73 {0x0531, 0x0589, "Armenian"},
74 {0x0591, 0x05f4, "Hebrew"},
75 {0x0600, 0x06ff, "Arabic"},
76 {0x0700, 0x074a, "Syriac"},
77 {0x0780, 0x07b0, "Thaana"},
78 {0x0901, 0x0970, "Devanagari"},
79 {0x0981, 0x09fa, "Bengali"},
80 {0x0a02, 0x0a74, "Gurmukhi"},
81 {0x0a81, 0x0aef, "Gujarati"},
82 {0x0b01, 0x0b70, "Oriya"},
83 {0x0b82, 0x0bf2, "Tamil"},
84 {0x0c01, 0x0c6f, "Telugu"},
85 {0x0c82, 0x0cef, "Kannada"},
86 {0x0d02, 0x0d6f, "Malayalam"},
87 {0x0d80, 0x0df4, "Sinhala"},
88 {0x0e01, 0x0e5b, "Thai"},
89 {0x0e81, 0x0edd, "Lao"},
90 {0x0f00, 0x0fb9, "Tibetan"},
91 {0x1000, 0x1059, "Myanmar"},
92 {0x10a0, 0x10fb, "Georgian"},
93 {0x1100, 0x11f9, "Hangul Jamo"},
94 {0x1800, 0x18a9, "Mongolian"},
95 {0x1e00, 0x1ef9, "Latin Ext. Additional"},
96 {0x1f00, 0x1ffe, "Greek Extended"},
97 {0x2000, 0x2046, "General Punctuation"},
98 {0x20a0, 0x20ac, "Currency Symbols"},
99 {0x2100, 0x2138, "Letterlike Symbols"},
100 {0x2153, 0x2182, "Number Forms"},
101 {0x2200, 0x22f1, "Mathematical Operators"},
102 {0x3041, 0x309e, "Hiragana"},
103 {0x30a1, 0x30fe, "Katakana"},
104 {0x3105, 0x312c, "Bopomofo"},
105 {0x3131, 0x318e, "Hangul Jamo"},
106 {0x3190, 0x319f, "Kanbun"},
107 {0x3300, 0x33fe, "CJK Compatibility"},
108 {0x4e00, 0x9fb0, "Kanji Ideographs"},
109 {0xac00, 0xd7af, "Hangul Syllables"},
110 {0xf900, 0xfa2d, "Kanji Composites"},
111 {-1, -1, NULL}
112 };
113
114 ///////////////////////////////////////////////////////////////////////////////
115 GLYPH_RANGE ExtendedGlyphRanges[NUM_FONT_EXTENDED_CHAR_RANGES + 1] = {
116 { 0, 0, "User Defined Page1" },
117 { 0, 0, "User Defined Page2" },
118 { 0, 0, "User Defined Page3" },
119 { 0, 0, "User Defined Page4" },
120 {-1, -1, NULL}
121 };
122
123 enum font_path_dlg_test_commands{
124 TEST_SET_FONT_PATH = 1,
125 TEST_SET_FONT_NAME,
126 TEST_SET_FONT_HEIGHT,
127 TEST_SET_FONT_HEIGHT_POST,
128 TEST_SET_FONT_FORMAT,
129 TEST_SET_FONT_COMPRESSION,
130 TEST_SET_FONT_GENERATE_KERNING,
131 TEST_SET_PAGE_RANGE,
132 TEST_CHECK_EXTENDED_UNICODE,
133 TEST_CHECK_CUSTOM_OUTPUT,
134 TEST_SET_CUSTOM_OUTPUT_FILE,
135 TEST_SAVE_FONT_EDIT,
136 TEST_CANCEL_FONT_EDIT
137 };
138
BEGIN_MESSAGE_MAP(font_range_header,CWnd)139 BEGIN_MESSAGE_MAP(font_range_header, CWnd)
140 ON_WM_PAINT()
141 END_MESSAGE_MAP()
142
143 ///////////////////////////////////////////////////////////////////////////////
144 void font_range_header::OnPaint()
145 {
146 CPaintDC dc(this); // device context for painting
147 // TODO: Add your message handler code here
148 // Do not call CWnd::OnPaint() for painting messages
149
150 CRect client;
151 GetClientRect(&client);
152
153 CBrush brush(GetSysColor(CTLCOLOR_DLG));
154 CPen line_pen;
155
156 line_pen.CreatePen(PS_SOLID, 0, GetSysColor(COLOR_WINDOWFRAME));
157
158 CPen* old_pen = dc.SelectObject(&line_pen);
159 CBrush* old_brush = dc.SelectObject(&brush);
160 dc.SelectObject(mpFont);
161
162 dc.FillRect(&client, &brush);
163 dc.MoveTo(client.left, client.top);
164 dc.LineTo(client.right, client.top);
165 dc.MoveTo(client.left, client.bottom - 1);
166 dc.LineTo(client.right, client.bottom - 1);
167 dc.MoveTo(client.left, client.top);
168 dc.LineTo(client.left, client.bottom - 1);
169 dc.MoveTo(client.right - 1, client.top);
170 dc.LineTo(client.right - 1, client.bottom - 1);
171
172 dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
173 dc.SetBkMode(TRANSPARENT);
174
175 int width = (client.Width() - ::GetSystemMetrics(SM_CXVSCROLL)) / 3;
176
177 CRect size = client;
178 size.right = width;
179
180 CSize sz = dc.GetTextExtent(_T("Name"));
181
182 CRect rect = size;
183 rect.top += (size.Height() - sz.cy) / 2;
184 dc.DrawText(_T("Font Page"), rect, DT_CENTER);
185 dc.MoveTo(size.right, size.top);
186 dc.LineTo(size.right, size.bottom);
187
188 size.OffsetRect(CPoint(width, 0));
189 rect = size;
190 rect.top += (size.Height() - sz.cy) / 2;
191
192 dc.DrawText(_T("<U> Page Start"), rect, DT_CENTER);
193 dc.MoveTo(size.right, size.top);
194 dc.LineTo(size.right, size.bottom);
195
196 size.OffsetRect(CPoint(width, 0));
197 rect = size;
198 rect.top += (size.Height() - sz.cy) / 2;
199
200 dc.DrawText(_T("<U> Page End"), rect, DT_CENTER);
201
202 dc.SelectObject(old_brush);
203 dc.SelectObject(old_pen);
204 }
205
206 ///////////////////////////////////////////////////////////////////////////////
range_list_win(res_info * info,CFont * font)207 range_list_win::range_list_win(res_info *info, CFont *font)
208 {
209 m_info = info;
210 mpFont = font;
211
212 page_count = NUM_FONT_CHAR_RANGES;
213 if (info->font_support_extended_unicode)
214 {
215 page_count += NUM_FONT_EXTENDED_CHAR_RANGES;
216 }
217 memcpy_s(mPageInfo, sizeof(mPageInfo), info->font_pages, sizeof(font_page_info) * page_count);
218
219 m_scroll_helper = new CScrollHelper;
220 m_scroll_helper->AttachWnd(this);
221
222 int dpi = GetSystemDPI();
223
224 m_range_row_height = MulDiv(RANGE_ROW_HEIGHT, dpi, DEFAULT_DPI_96);
225 }
226
227 ///////////////////////////////////////////////////////////////////////////////
~range_list_win()228 range_list_win::~range_list_win()
229 {
230 for (int loop = 0; loop < page_count; loop++)
231 {
232 delete range_entry[loop];
233 }
234
235 delete m_scroll_helper;
236 }
237
238 ///////////////////////////////////////////////////////////////////////////////
OnCreate(LPCREATESTRUCT lpcs)239 int range_list_win::OnCreate(LPCREATESTRUCT lpcs)
240 {
241 CWnd::OnCreate(lpcs);
242
243 GLYPH_RANGE *range = DefaultGlyphRanges;
244
245 CRect RangeListEntrySize;
246 GetClientRect(&RangeListEntrySize);
247
248 RangeListEntrySize.bottom = RangeListEntrySize.top + m_range_row_height;
249
250 CString name;
251
252 for (int loop = 0; loop < NUM_FONT_CHAR_RANGES; loop++)
253 {
254 name.Format(_T("%s range"), CString(range->name));
255 range_entry[loop] = new font_range_row(CString(range->name),
256 &mPageInfo[loop], FALSE, loop, mpFont);
257 range_entry[loop]->Create(target_class_name, name, WS_CHILD | WS_VISIBLE,
258 RangeListEntrySize, this, 0, NULL);
259
260 RangeListEntrySize.OffsetRect(0, m_range_row_height);
261 range++;
262 }
263
264 if (m_info->font_support_extended_unicode)
265 {
266 CreateExtendedRangeEntry();
267 }
268
269 // update scrollbar info
270 m_scroll_helper->SetDisplaySize(0, page_count * m_range_row_height);
271
272 return 0;
273 }
274
275 ///////////////////////////////////////////////////////////////////////////////
CreateExtendedRangeEntry()276 void range_list_win::CreateExtendedRangeEntry()
277 {
278 GLYPH_RANGE *range = ExtendedGlyphRanges;
279 memcpy_s(mPageInfo + NUM_FONT_CHAR_RANGES, sizeof(font_page_info) * NUM_FONT_EXTENDED_CHAR_RANGES, m_info->font_pages + NUM_FONT_CHAR_RANGES, sizeof(font_page_info) * NUM_FONT_EXTENDED_CHAR_RANGES);
280
281 CRect childsize;
282 GetClientRect(&childsize);
283
284 childsize.top -= (m_scroll_helper->GetScrollPos()).cy;
285 childsize.top += NUM_FONT_CHAR_RANGES * m_range_row_height;
286 childsize.bottom = childsize.top + m_range_row_height - 1;
287
288 page_count = NUM_FONT_CHAR_RANGES + NUM_FONT_EXTENDED_CHAR_RANGES;
289
290 CString name;
291
292 // Create extended range entries
293 for (int loop = NUM_FONT_CHAR_RANGES; loop < page_count; loop++)
294 {
295 name.Format(_T("%s range"), CString(range->name));
296 range_entry[loop] = new font_range_row(CString(range->name), &mPageInfo[loop], TRUE, loop, mpFont);
297 range_entry[loop]->Create(target_class_name, name, WS_CHILD | WS_VISIBLE,
298 childsize, this, 0, NULL);
299 range++;
300
301 childsize.top += m_range_row_height;
302 childsize.bottom += m_range_row_height;
303 }
304
305 m_scroll_helper->SetDisplaySize(0, page_count * m_range_row_height);
306 }
307
308 ///////////////////////////////////////////////////////////////////////////////
DeleteExtendedRangeEntry()309 void range_list_win::DeleteExtendedRangeEntry()
310 {
311 // Delete extended range entries
312 for (int loop = NUM_FONT_CHAR_RANGES; loop < page_count; loop++)
313 {
314 delete range_entry[loop];
315 }
316
317 page_count = NUM_FONT_CHAR_RANGES;
318
319 m_scroll_helper->SetDisplaySize(0, page_count * m_range_row_height);
320 }
321
322 ///////////////////////////////////////////////////////////////////////////////
Scroll(int delta)323 BOOL range_list_win::Scroll(int delta)
324 {
325 return m_scroll_helper->Scroll(SB_VERT, delta);
326 }
327
328 ///////////////////////////////////////////////////////////////////////////////
OnVScroll(UINT nSBCode,UINT nPos,CScrollBar * pScrollBar)329 void range_list_win::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
330 {
331 // Compute the desired change or delta in scroll position.
332 m_scroll_helper->OnVScroll(nSBCode, nPos, pScrollBar);
333 }
334
OnMouseWheel(UINT nFlags,short zDelta,CPoint pt)335 BOOL range_list_win::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
336 {
337 // TODO: Add your message handler code here and/or call default
338 BOOL wasScrolled = m_scroll_helper->OnMouseWheel(nFlags, zDelta, pt);
339 return wasScrolled;
340 }
341
342
SaveRangeInfo()343 void range_list_win::SaveRangeInfo()
344 {
345 memcpy_s(m_info->font_pages, sizeof(font_page_info) * page_count, mPageInfo, sizeof(font_page_info) * page_count);
346 }
347
OnSetFocus(CWnd * pOldWnd)348 void range_list_win::OnSetFocus(CWnd* pOldWnd)
349 {
350 CWnd::OnSetFocus(pOldWnd);
351
352 // TODO: Add your message handler code here
353 //pick first row
354 CWnd* child = GetWindow(GW_CHILD);
355 CRect list_client;
356 CRect rect;
357
358 GetClientRect(&list_client);
359 ClientToScreen(&list_client);
360
361 // set focus to the first visible child
362 while (child)
363 {
364 child->GetWindowRect(&rect);
365
366 if (rect.top < list_client.top)
367 {
368 child = child->GetWindow(GW_HWNDNEXT);
369 }
370 else
371 {
372 //pick first child of the row
373 child = child->GetWindow(GW_CHILD);
374
375 if (child)
376 {
377 child->SetFocus();
378 }
379 break;
380 }
381 }
382 }
383
384
385
386 ///////////////////////////////////////////////////////////////////////////////
387 ///////////////////////////////////////////////////////////////////////////////
388 // font_range_entry- the CWnd class that implements each row of glyph range table
389 ///////////////////////////////////////////////////////////////////////////////
390 ///////////////////////////////////////////////////////////////////////////////
font_range_row(CString & name,font_page_info * page_info,BOOL extended,INT row_id,CFont * font)391 font_range_row::font_range_row(CString &name, font_page_info *page_info, BOOL extended, INT row_id, CFont *font)
392 {
393 mNameText = name;
394 mpInfo = page_info;
395 mExtended = extended;
396 mRowId = row_id;
397 mpFont = font;
398 }
399
400 ///////////////////////////////////////////////////////////////////////////////
OnCreate(LPCREATESTRUCT lpcs)401 int font_range_row::OnCreate(LPCREATESTRUCT lpcs)
402 {
403 CRect size;
404 CRect fieldsize;
405 CString tval;
406 CString name;
407
408 express_table_row::OnCreate(lpcs);
409 GetClientRect(size);
410 fieldsize = size;
411 fieldsize.top++;
412 fieldsize.bottom--;
413
414 int width = size.Width() / 3;
415 fieldsize.left += 4;
416 fieldsize.right = width;
417
418 mEnabledBox.Create(NULL, WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|WS_VISIBLE, fieldsize, this, ID_ENABLE_BOX);
419 mEnabledBox.SetFont(mpFont);
420 mEnabledBox.SetWindowText(mNameText);
421 name.Format(_T("row %d, column 0, %s"), mRowId, mNameText);
422 SetControlAccessibleName(mEnabledBox.GetSafeHwnd(), name);
423
424 if (mpInfo->enabled)
425 {
426 mEnabledBox.SetCheck(TRUE);
427 }
428
429 fieldsize.left = fieldsize.right + 3;
430 fieldsize.right = fieldsize.left + width - 3;
431 mStartField.Create(WS_BORDER|WS_CHILD|WS_TABSTOP|SS_CENTER|ES_AUTOHSCROLL|WS_VISIBLE, fieldsize, this, ID_START_FIELD);
432 mStartField.SetFont(mpFont);
433 if (!mExtended)
434 {
435 tval.Format(_T("%04x"), mpInfo->first_char);
436 }
437 else
438 {
439 tval.Format(_T("%06x"), mpInfo->first_char);
440 }
441 mStartField.SetWindowText(tval);
442
443 name.Format(_T("row %d, column 1, %s Page Start"), mRowId, mNameText);
444 SetControlAccessibleName(mStartField.GetSafeHwnd(), name);
445 SetAccessibleHelpString(mStartField.GetSafeHwnd(), _T("Enter a Unicode value."));
446
447 fieldsize.OffsetRect(CPoint(width, 0));
448 mEndField.Create(WS_BORDER|WS_CHILD|WS_TABSTOP|SS_CENTER|ES_AUTOHSCROLL|WS_VISIBLE, fieldsize, this, ID_END_FIELD);
449 mEndField.SetFont(mpFont);
450 if (!mExtended)
451 {
452 tval.Format(_T("%04x"), mpInfo->last_char);
453 }
454 else
455 {
456 tval.Format(_T("%06x"), mpInfo->last_char);
457 }
458 mEndField.SetWindowText(tval);
459
460 name.Format(_T("row %d, column 2, %s Page End"), mRowId, mNameText);
461 SetControlAccessibleName(mEndField.GetSafeHwnd(), name);
462 SetAccessibleHelpString(mEndField.GetSafeHwnd(), _T("Enter a Unicode value."));
463
464 return 0;
465 }
466
467 ///////////////////////////////////////////////////////////////////////////////
OnPaint()468 void font_range_row::OnPaint()
469 {
470 express_table_row::OnPaint();
471 }
472
473 ///////////////////////////////////////////////////////////////////////////////
OnCommand(WPARAM wParam,LPARAM lParam)474 BOOL font_range_row::OnCommand(WPARAM wParam, LPARAM lParam)
475 {
476 if (wParam == IDOK)
477 {
478 CWnd *child = GetFocus();
479
480 if (child)
481 {
482 SetFocus();
483 child->SetFocus();
484 return TRUE;
485 }
486 }
487 return express_table_row::OnCommand(wParam, lParam);
488 }
489
490 ///////////////////////////////////////////////////////////////////////////////
OnChangeEnabled()491 void font_range_row::OnChangeEnabled()
492 {
493 if (mEnabledBox.GetCheck())
494 {
495 mpInfo->enabled = TRUE;
496 }
497 else
498 {
499 mpInfo->enabled = FALSE;
500 }
501 }
502
503 ///////////////////////////////////////////////////////////////////////////////
OnEditRangeField()504 void font_range_row::OnEditRangeField()
505 {
506 int val;
507 CString text;
508
509 mStartField.GetWindowText(text);
510 val = _tcstol(text.GetBuffer(), NULL, 16);
511
512 if (!mExtended)
513 {
514 if (val >= 0 && val <= mpInfo->last_char)
515 {
516 mpInfo->first_char = val;
517 }
518 else
519 {
520 text.Format(_T("%04x"), mpInfo->first_char);
521 mStartField.SetWindowText(text);
522 }
523 }
524 else
525 {
526 if (val >= 0 && val <= 0x10ffff)
527 {
528 mpInfo->first_char = val;
529 }
530 else
531 {
532 text.Format(_T("%06x"), mpInfo->first_char);
533 mStartField.SetWindowText(text);
534 }
535 }
536
537 mEndField.GetWindowText(text);
538 val = _tcstol(text.GetBuffer(), NULL, 16);
539
540 if (!mExtended)
541 {
542 if (val >= mpInfo->first_char && val < 0xffff)
543 {
544 mpInfo->last_char = val;
545 }
546 else
547 {
548 text.Format(_T("%04x"), mpInfo->last_char);
549 mEndField.SetWindowText(text);
550 }
551 }
552 else
553 {
554 if (val >= 0 && val <= 0x10ffff)
555 {
556 mpInfo->last_char = val;
557 }
558 else
559 {
560 text.Format(_T("%06x"), mpInfo->last_char);
561 mEndField.SetWindowText(text);
562 }
563 }
564 }
565
PreTranslateKeyDown(WPARAM keyvalue)566 BOOL font_range_row::PreTranslateKeyDown(WPARAM keyvalue)
567 {
568 CWnd* focus_owner = GetFocus();
569 CWnd* next_focus_owner = NULL;
570 range_list_win* list = (range_list_win*)GetParent();
571 CRect list_client;
572 CRect row_client;
573
574 list->GetClientRect(&list_client);
575 GetClientRect(&row_client);
576
577 switch (keyvalue)
578 {
579 case VK_LEFT:
580 case VK_RIGHT:
581 case VK_UP:
582 case VK_DOWN:
583 case VK_HOME:
584 case VK_END:
585 next_focus_owner = GetNextTabStopChild(focus_owner, keyvalue);
586 break;
587
588 case VK_PRIOR:
589 if (list->Scroll(-list_client.Height()))
590 {
591 int offset = list_client.Height() / row_client.Height();
592
593 if (mRowId - offset < 0)
594 {
595 offset = mRowId;
596 }
597
598 next_focus_owner = GetNextTabStopChild(focus_owner, keyvalue, offset);
599 }
600 break;
601
602 case VK_NEXT:
603 if(list->Scroll(list_client.Height()))
604 {
605 int offset = list_client.Height() / row_client.Height();
606 int max_row_id = NUM_FONT_CHAR_RANGES - 1;
607 if (mExtended)
608 {
609 max_row_id += NUM_FONT_EXTENDED_CHAR_RANGES;
610 }
611
612 if (mRowId + offset > max_row_id)
613 {
614 offset = max_row_id - mRowId;
615 }
616 next_focus_owner = GetNextTabStopChild(focus_owner, keyvalue, offset);
617 }
618 break;
619
620 default:
621 return FALSE;
622 }
623
624 if (next_focus_owner)
625 {
626 CRect rect;
627
628 list->GetClientRect(&list_client);
629 list->ClientToScreen(&list_client);
630
631 next_focus_owner->GetWindowRect(&rect);
632
633 if (rect.top < list_client.top)
634 {
635 list->Scroll(rect.top - list_client.top);
636 }
637 else if (rect.bottom > list_client.bottom)
638 {
639 list->Scroll(rect.bottom - list_client.bottom);
640 }
641
642 AssignFocus(next_focus_owner);
643 }
644
645 return TRUE;
646 }
647
PreTranslateMessage(MSG * pMsg)648 BOOL font_range_row::PreTranslateMessage(MSG* pMsg)
649 {
650 // TODO: Add your specialized code here and/or call the base class
651 if (pMsg->message == WM_KEYDOWN)
652 {
653 if (PreTranslateKeyDown(pMsg->wParam))
654 {
655 return TRUE;
656 }
657 }
658
659 return express_table_row::PreTranslateMessage(pMsg);
660 }
661
662
663 ///////////////////////////////////////////////////////////////////////////////
CreateDefaultFontPages(BOOL include_extended_unicode)664 font_page_info *font_path_dialog::CreateDefaultFontPages(BOOL include_extended_unicode)
665 {
666 int loop;
667 GLYPH_RANGE *range = DefaultGlyphRanges;
668
669 int font_count = NUM_FONT_CHAR_RANGES;
670
671 if (include_extended_unicode)
672 {
673 font_count += NUM_FONT_EXTENDED_CHAR_RANGES;
674 }
675
676 font_page_info *info = new font_page_info[font_count];
677 memset(info, 0, sizeof(font_page_info) * font_count);
678
679 for (loop = 0; loop < NUM_FONT_CHAR_RANGES; loop++)
680 {
681 info[loop].first_char = range->first_char;
682 info[loop].last_char = range->last_char;
683 range++;
684 }
685
686 if (include_extended_unicode)
687 {
688 range = ExtendedGlyphRanges;
689
690 for (loop = NUM_FONT_CHAR_RANGES; loop < font_count; loop++)
691 {
692 info[loop].first_char = range->first_char;
693 info[loop].last_char = range->last_char;
694 range++;
695 }
696 }
697 info[0].enabled = TRUE;
698 return info;
699 }
700
701
702 ///////////////////////////////////////////////////////////////////////////////
CreateExtendedFontPages()703 font_page_info *font_path_dialog::CreateExtendedFontPages()
704 {
705 int loop;
706 GLYPH_RANGE *range = ExtendedGlyphRanges;
707
708 font_page_info *info = new font_page_info[NUM_FONT_EXTENDED_CHAR_RANGES];
709 memset(info, 0, sizeof(font_page_info) * NUM_FONT_EXTENDED_CHAR_RANGES);
710
711 for (loop = 0; loop < NUM_FONT_EXTENDED_CHAR_RANGES; loop++)
712 {
713 info[loop].first_char = range->first_char;
714 info[loop].last_char = range->last_char;
715 range++;
716 }
717 return info;
718 }
719
720 ///////////////////////////////////////////////////////////////////////////////
font_path_dialog(int display_index,int color_format,res_info * info,CWnd * pParent)721 font_path_dialog::font_path_dialog(int display_index, int color_format, res_info *info, CWnd* pParent /*=NULL*/)
722 : express_dialog(font_path_dialog::IDD, pParent)
723 {
724 IconId = IDB_FONTS;
725 SetTitleText("Edit Font");
726
727 m_info = info;
728 pathinfo = m_info->pathinfo;
729 m_color_format = color_format;
730 m_display_index = display_index;
731
732 if (!m_info->font_pages)
733 {
734 m_info->font_pages = CreateDefaultFontPages();
735 }
736
737 int dpi = GetSystemDPI();
738 m_range_row_height = MulDiv(RANGE_ROW_HEIGHT, dpi, DEFAULT_DPI_96);
739 }
740
741 ///////////////////////////////////////////////////////////////////////////////
~font_path_dialog()742 font_path_dialog::~font_path_dialog()
743 {
744 mpRangeListWin->DestroyWindow();
745 delete mpRangeListWin;
746
747 mpRangeListHeader->DestroyWindow();
748 delete mpRangeListHeader;
749 }
750
751 ///////////////////////////////////////////////////////////////////////////////
DoDataExchange(CDataExchange * pDX)752 void font_path_dialog::DoDataExchange(CDataExchange* pDX)
753 {
754 //int aliased = m_info->anti_aliased;
755
756 express_dialog::DoDataExchange(pDX);
757 DDX_Text(pDX, IDC_FONT_HEIGHT, m_info->font_height);
758 DDX_Text(pDX, IDC_FONT_NAME, m_info->name);
759 DDX_Check(pDX, IDC_INCLUDE_STRING_TABLE, m_info->font_charset_include_string_table);
760 DDX_Check(pDX, IDC_SUPPORT_EXTENDED_UNICODE, m_info->font_support_extended_unicode);
761 DDX_Control(pDX, IDC_INCLUDE_RANGE_PROMPT, mPagesPrompt);
762 DDX_Check(pDX, IDC_COMPRESS, m_info->compress);
763 DDX_Check(pDX, IDC_KERNING, m_info->font_kerning);
764 DDX_Check(pDX, IDC_CUSTOM_OUTPUT, m_info->output_file_enabled);
765 DDX_Check(pDX, IDC_BINARY_MODE, m_info->binary_mode);
766 DDX_Control(pDX, IDC_OUTPUT_FILE, mCustomFile);
767 DDX_Control(pDX, IDC_BINARY_MODE, mBinaryMode);
768
769 CButton *pb;
770
771 mHeight = m_info->font_height;
772
773 pb = (CButton *)GetDlgItem(IDC_SUPPORT_EXTENDED_UNICODE);
774 if (m_info->font_support_extended_unicode)
775 {
776 pb->SetCheck(BST_CHECKED);
777 }
778 else
779 {
780 pb->SetCheck(BST_UNCHECKED);
781 }
782
783 if (m_color_format < GX_COLOR_FORMAT_4BIT_GRAY)
784 {
785 pb = (CButton *) GetDlgItem(IDC_4BIT_ALIASED);
786 pb->EnableWindow(FALSE);
787 m_info->font_bits = 1;
788 }
789
790 if (m_color_format <= GX_COLOR_FORMAT_8BIT_PACKED_PIXEL)
791 {
792 pb = (CButton *) GetDlgItem(IDC_8BIT_ALIASED);
793 pb->EnableWindow(FALSE);
794
795 if (m_info->font_bits == 8)
796 {
797 m_info->font_bits = 4;
798 }
799 }
800 if (pDX->m_bSaveAndValidate)
801 {
802 DDX_Text(pDX, IDC_FONT_PATH, pathinfo.pathname);
803
804 if (IsDlgButtonChecked(IDC_1BIT_MONO))
805 {
806 m_info->font_bits = 1;
807 }
808 else
809 {
810 if (IsDlgButtonChecked(IDC_4BIT_ALIASED))
811 {
812 m_info->font_bits = 4;
813 }
814 else
815 {
816 m_info->font_bits = 8;
817 }
818 }
819 }
820 else
821 {
822 if (m_info->output_file_enabled)
823 {
824 mCustomFile.ShowWindow(TRUE);
825 mCustomFile.SetWindowText(m_info->output_file);
826
827 mBinaryMode.ShowWindow(TRUE);
828 }
829
830 SetDlgItemText(IDC_FONT_PATH, pathinfo.pathname);
831 OnPathnameChange();
832
833 switch(m_info->font_bits)
834 {
835 case 1:
836 pb = (CButton *) GetDlgItem(IDC_1BIT_MONO);
837 break;
838
839 case 4:
840 pb = (CButton *) GetDlgItem(IDC_4BIT_ALIASED);
841 break;
842
843 case 8:
844 default:
845 pb = (CButton *) GetDlgItem(IDC_8BIT_ALIASED);
846 }
847 if (pb)
848 {
849 pb->SetCheck(BST_CHECKED);
850 }
851 }
852
853 CEdit* edit = (CEdit*)GetDlgItem(IDC_FONT_NAME);
854
855 if (m_info->is_default)
856 {
857 edit->SetReadOnly(TRUE);
858
859 GetDlgItem(IDC_REQUIRED_FIELD_LEGEND)->ShowWindow(FALSE);
860 }
861 else
862 {
863 SetAccessibleFullDescription(edit->GetSafeHwnd(), L"Required");
864 SetAccessibleDescription(edit->GetSafeHwnd(), L"Required");
865 }
866 DDX_Control(pDX, IDB_PATH_TYPE, mPathTypeButton);
867
868 if (!pDX->m_bSaveAndValidate)
869 {
870 mPathBitmap.LoadBitmap(IDB_DOWN_ARROW);
871 mPathTypeButton.SetBitmap(mPathBitmap);
872 SetPathPrefix();
873
874 SetControlAccessibleName(GetDlgItem(IDC_OUTPUT_FILE)->GetSafeHwnd(), L"Custom Output File");
875 }
876 }
877
878 // font_path_dialog message handlers
879
880 ///////////////////////////////////////////////////////////////////////////////
OnBnClickedBrowse()881 void font_path_dialog::OnBnClickedBrowse()
882 {
883 // TODO: Add your control notification handler code here
884 CString pathname;
885 CString oldname = pathname;
886 BrowseForSingleFile(_T("Select font file"),
887 _T("Font Files (*.ttf; *.otf)\0*.ttf;*.otf\0"), _T("ttf"), pathname, this);
888 if (pathname.IsEmpty() || oldname == pathname)
889 {
890 return;
891 }
892
893 SaveToPathInfo(pathinfo, pathname);
894
895 SetDlgItemText(IDC_FONT_PATH, pathinfo.pathname);
896 OnPathnameChange();
897 }
898
899 ///////////////////////////////////////////////////////////////////////////////
OnCommand(WPARAM wParam,LPARAM lParam)900 BOOL font_path_dialog::OnCommand(WPARAM wParam, LPARAM lParam)
901 {
902 CWnd *parent1;
903 CWnd *parent2;
904
905 if (wParam == IDOK)
906 {
907 /* figure out if they hit return while on an edit field */
908 CWnd *child = GetFocus();
909
910 if (child)
911 {
912 if (child->GetDlgCtrlID() == ID_START_FIELD ||
913 child->GetDlgCtrlID() == ID_END_FIELD)
914 {
915 parent1 = child->GetParent(); // could be range row?
916
917 if (parent1)
918 {
919 parent2 = parent1->GetParent(); // could be range list win?
920
921 if (parent2 == mpRangeListWin)
922 {
923 // tell the row to save it's data
924 font_range_row *row = (font_range_row *) parent1;
925 row->OnEditRangeField();
926 return TRUE;
927 }
928 }
929 }
930 }
931 }
932 return CWnd::OnCommand(wParam, lParam);
933 }
934
935 ///////////////////////////////////////////////////////////////////////////////
OnBnClickedOk()936 void font_path_dialog::OnBnClickedOk()
937 {
938 // TODO: Add your control notification handler code here
939 CEdit* edit = (CEdit *)GetDlgItem(IDC_FONT_NAME);
940 CString font_name;
941
942 if (!m_info->is_default)
943 {
944 if (pathinfo.pathname.IsEmpty())
945 {
946 Notify("Please set the font path.", this);
947 return;
948 }
949
950 GetDlgItemText(IDC_FONT_NAME, font_name);
951 if (m_info->parent == NULL)
952 {
953 if (NameExists(m_display_index, RES_TYPE_FONT, font_name))
954 {
955 ErrorMsg("Font Name already Exists.", this);
956 return;
957 }
958 }
959 else
960 {
961 if (_tcscmp(font_name, m_info->name))
962 {
963 if (NameExists(m_display_index, RES_TYPE_FONT, font_name))
964 {
965 ErrorMsg("Font Name already Exists.", this);
966 SetDlgItemText(IDC_FONT_NAME, m_info->name);
967 return;
968 }
969 }
970 }
971 }
972
973 if (TestInputName(edit, "Font Name", m_info->name, this))
974 {
975 m_info->pathinfo = pathinfo;
976 mpRangeListWin->SaveRangeInfo();
977
978 mCustomFile.GetWindowText(m_info->output_file);
979
980 if (m_info->output_file.IsEmpty())
981 {
982 m_info->output_file_enabled = FALSE;
983 }
984
985 OnOK();
986 }
987 }
988
OnBnClickedPathType()989 void font_path_dialog::OnBnClickedPathType()
990 {
991 // TODO: Add your control notification handler code here
992 CMenu menu;
993 CMenu *pPopup;
994 CPoint pos;
995 CRect buttonsize;
996 mPathTypeButton.GetWindowRect(&buttonsize);
997
998 pos.x = buttonsize.left;
999 pos.y = buttonsize.bottom + 2;
1000
1001 menu.LoadMenu(IDR_PATHTYPE);
1002 pPopup = menu.GetSubMenu(0);
1003 //ClientToScreen(&pos);
1004 pPopup->TrackPopupMenu(TPM_LEFTALIGN, pos.x, pos.y, this);
1005 }
1006
OnBnClickedCustomOutput()1007 void font_path_dialog::OnBnClickedCustomOutput()
1008 {
1009 // TODO: Add your control notification handler code here
1010 CButton* pb = (CButton*)GetDlgItem(IDC_CUSTOM_OUTPUT);
1011
1012 if (pb->GetCheck() == BST_CHECKED)
1013 {
1014 mCustomFile.ShowWindow(SW_SHOW);
1015 mBinaryMode.ShowWindow(SW_SHOW);
1016 }
1017 else
1018 {
1019 mCustomFile.ShowWindow(SW_HIDE);
1020 mBinaryMode.ShowWindow(SW_HIDE);
1021 }
1022 }
1023
SetPathPrefix()1024 void font_path_dialog::SetPathPrefix()
1025 {
1026 switch(pathinfo.pathtype)
1027 {
1028 case PATH_TYPE_PROJECT_RELATIVE:
1029 SetDlgItemText(IDC_PATH_PREFIX, _T("<Project Relative Path>"));
1030 break;
1031
1032 case PATH_TYPE_INSTALL_RELATIVE:
1033 SetDlgItemText(IDC_PATH_PREFIX, _T("<GUIX Repo Relative Path>"));
1034 break;
1035
1036 case PATH_TYPE_ABSOLUTE:
1037 default:
1038 SetDlgItemText(IDC_PATH_PREFIX, _T("<Absolute Path>"));
1039 break;
1040
1041 }
1042 }
1043
SetPathProjectRelative()1044 void font_path_dialog::SetPathProjectRelative()
1045 {
1046 if (!pathinfo.pathname.IsEmpty())
1047 {
1048 CString abspath = MakeAbsolutePathname(pathinfo);
1049 pathinfo.pathtype = PATH_TYPE_PROJECT_RELATIVE;
1050 SaveToPathInfo(pathinfo, abspath);
1051 SetDlgItemText(IDC_FONT_PATH, pathinfo.pathname);
1052 SetPathPrefix();
1053 }
1054 }
1055
SetPathStudioRelative()1056 void font_path_dialog::SetPathStudioRelative()
1057 {
1058 if (!pathinfo.pathname.IsEmpty())
1059 {
1060 CString abspath = MakeAbsolutePathname(pathinfo);
1061 pathinfo.pathtype = PATH_TYPE_INSTALL_RELATIVE;
1062 SaveToPathInfo(pathinfo, abspath);
1063 SetDlgItemText(IDC_FONT_PATH, pathinfo.pathname);
1064 SetPathPrefix();
1065 }
1066 }
1067
SetPathAbsolute()1068 void font_path_dialog::SetPathAbsolute()
1069 {
1070 if (!pathinfo.pathname.IsEmpty())
1071 {
1072 CString abspath = MakeAbsolutePathname(pathinfo);
1073 pathinfo.pathtype = PATH_TYPE_ABSOLUTE;
1074 SaveToPathInfo(pathinfo, abspath);
1075 SetDlgItemText(IDC_FONT_PATH, pathinfo.pathname);
1076 SetPathPrefix();
1077 }
1078 }
1079
OnKillFontPathEdit()1080 void font_path_dialog::OnKillFontPathEdit()
1081 {
1082 GetDlgItemText(IDC_FONT_PATH, pathinfo.pathname);
1083 OnPathnameChange();
1084 }
1085
OnPathnameChange()1086 void font_path_dialog::OnPathnameChange()
1087 {
1088 CEdit *edit = (CEdit*)GetDlgItem(IDC_FONT_HEIGHT);
1089 CButton *button = (CButton*)GetDlgItem(IDC_KERNING);
1090 CButton *custom_output_check = (CButton*)GetDlgItem(IDC_CUSTOM_OUTPUT);
1091
1092 if (m_info->is_default && pathinfo.pathname.IsEmpty())
1093 {
1094 edit->EnableWindow(FALSE);
1095 button->EnableWindow(FALSE);
1096 custom_output_check->SetCheck(0);
1097 GetDlgItem(IDC_OUTPUT_FILE)->ShowWindow(FALSE);
1098 GetDlgItem(IDC_BINARY_MODE)->ShowWindow(FALSE);
1099 custom_output_check->EnableWindow(FALSE);
1100 return;
1101 }
1102 else
1103 {
1104 edit->EnableWindow(TRUE);
1105 button->EnableWindow(TRUE);
1106 custom_output_check->EnableWindow(TRUE);
1107 }
1108 Invalidate();
1109 }
1110
OnEnChangeFontHeight()1111 void font_path_dialog::OnEnChangeFontHeight()
1112 {
1113 int val = GetDlgItemInt(IDC_FONT_HEIGHT);
1114 if (val >= 0 && val <= 255)
1115 {
1116 mHeight = val;
1117 }
1118 else
1119 {
1120 Notify("Invalid value for font height. Valid range is from 0 to 255.", this);
1121 SetDlgItemInt(IDC_FONT_HEIGHT, mHeight);
1122 }
1123 }
1124
OnInitDialog()1125 BOOL font_path_dialog::OnInitDialog()
1126 {
1127 express_dialog::OnInitDialog();
1128
1129 CRect RangeListSize;
1130 CRect Size;
1131
1132 GetClientRect(&RangeListSize);
1133
1134 GetDlgItem(IDC_INCLUDE_RANGE_PROMPT)->GetWindowRect(&Size);
1135 ScreenToClient(&Size);
1136
1137 // Postion include range prompt
1138 RangeListSize.top = Size.bottom + m_range_row_height + 8;
1139
1140 GetDlgItem(IDC_FONT_FORMAT_GROUP)->GetWindowRect(&Size);
1141 ScreenToClient(&Size);
1142 RangeListSize.right = Size.left - 10;
1143
1144 RangeListSize.left += 12;
1145 RangeListSize.bottom -= (m_status_bar_height + 8);
1146
1147 CFont* font = GetDlgItem(IDC_FONT_NAME)->GetFont();
1148 mpRangeListWin = new range_list_win(m_info, font);
1149 mpRangeListWin->Create(target_class_name, _T("Character Pages"), WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | WS_TABSTOP,
1150 RangeListSize, this, 0);
1151 mpRangeListWin->SetWindowPos(GetDlgItem(IDC_FONT_FORMAT_GROUP), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
1152
1153 Size.left = RangeListSize.left;
1154 Size.top = RangeListSize.top - m_range_row_height - 4;
1155 Size.right = Size.left + RangeListSize.Width();
1156 Size.bottom = RangeListSize.top - 1;
1157
1158 mpRangeListHeader = new font_range_header(font);
1159 mpRangeListHeader->Create(target_class_name, _T("Character Page Header"), WS_CHILD | WS_VISIBLE, Size, this, 0);
1160
1161 studiox_project *project = GetOpenProject();
1162 if ((!IsRenesasDave2D(project))|
1163 (project->mHeader.guix_version < 50207) ||
1164 (project->mDisplays[m_display_index].colorformat <= GX_COLOR_FORMAT_8BIT_PALETTE))
1165 {
1166 // Add checkbox to allow the user to specify RLE compression enabled only for synergy.
1167 GetDlgItem(IDC_COMPRESS)->ShowWindow(GX_FALSE);
1168 }
1169
1170 if ((IsRenesasDave2D(project)) || (project->mHeader.guix_version < 50304))
1171 {
1172 GetDlgItem(IDC_KERNING)->ShowWindow(FALSE);
1173 }
1174
1175 AddCancelButton();
1176 AddSaveButton();
1177
1178 return TRUE; // return TRUE unless you set the focus to a control
1179 // EXCEPTION: OCX Property Pages should return FALSE
1180 }
1181
OnPaint()1182 void font_path_dialog::OnPaint()
1183 {
1184 CPaintDC dc(this); // device context for painting
1185 // TODO: Add your message handler code here
1186 // Do not call express_dialog::OnPaint() for painting messages
1187
1188 if (!m_info->is_default)
1189 {
1190 PaintRequiredAsterisk(IDC_FONT_NAME);
1191 PaintRequiredAsterisk(IDC_REQUIRED_FIELD_LEGEND);
1192 }
1193 }
1194
1195
OnTestMessage(WPARAM wParam,LPARAM lParam)1196 LRESULT font_path_dialog::OnTestMessage(WPARAM wParam, LPARAM lParam)
1197 {
1198 CWnd *pWnd;
1199 int ctrl_id;
1200 CStringArray param;
1201 int page_index;
1202 int check;
1203 CString range_start;
1204 CString range_end;
1205
1206 switch (wParam)
1207 {
1208 case TEST_SET_FONT_PATH:
1209 //set font path
1210 SetDlgItemText(IDC_FONT_PATH, GetTestingParam(0));
1211 pWnd = GetDlgItem(IDC_FONT_PATH);
1212 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_FONT_PATH, EN_KILLFOCUS), (LPARAM)pWnd->m_hWnd);
1213 break;
1214
1215 case TEST_SET_FONT_NAME:
1216 //set font name
1217 SetDlgItemText(IDC_FONT_NAME, GetTestingParam(0));
1218 pWnd = GetDlgItem(IDC_FONT_NAME);
1219 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_FONT_NAME, EN_KILLFOCUS), (LPARAM)pWnd->m_hWnd);
1220 break;
1221
1222 case TEST_SET_FONT_HEIGHT:
1223 //set font height
1224 SetDlgItemText(IDC_FONT_HEIGHT, GetTestingParam(0));
1225 pWnd = GetDlgItem(IDC_FONT_HEIGHT);
1226 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_FONT_HEIGHT, EN_KILLFOCUS), (LPARAM)pWnd->m_hWnd);
1227 break;
1228
1229 case TEST_SET_FONT_HEIGHT_POST:
1230 //set font height
1231 SetDlgItemText(IDC_FONT_HEIGHT, GetTestingParam(1));
1232 pWnd = GetDlgItem(IDC_FONT_HEIGHT);
1233 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_FONT_HEIGHT, EN_KILLFOCUS), (LPARAM)pWnd->m_hWnd);
1234 break;
1235
1236 case TEST_SET_FONT_FORMAT:
1237 //set font format
1238 switch (lParam)
1239 {
1240 case GX_FONT_FORMAT_1BPP:
1241 ctrl_id = IDC_1BIT_MONO;
1242 break;
1243
1244 case GX_FONT_FORMAT_4BPP:
1245 ctrl_id = IDC_4BIT_ALIASED;
1246 break;
1247
1248 case GX_FONT_FORMAT_8BPP:
1249 ctrl_id = IDC_8BIT_ALIASED;
1250 break;
1251
1252 default:
1253 return 0;
1254 }
1255
1256 CheckRadioButton(IDC_1BIT_MONO, IDC_8BIT_ALIASED, ctrl_id);
1257 break;
1258
1259 case TEST_SET_FONT_COMPRESSION:
1260 //set compression property
1261 pWnd = GetDlgItem(IDC_COMPRESS);
1262 ((CButton *)pWnd)->SetCheck(lParam);
1263 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_COMPRESS, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
1264 break;
1265
1266 case TEST_SET_FONT_GENERATE_KERNING:
1267 pWnd = GetDlgItem(IDC_KERNING);
1268 ((CButton *)pWnd)->SetCheck(lParam);
1269 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_KERNING, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
1270 break;
1271
1272 case TEST_SET_PAGE_RANGE:
1273 //set range info
1274 SplitString(GetTestingParam(0), ',', ¶m);
1275 page_index = _tstoi(param.GetAt(0));
1276 check = _tstoi(param.GetAt(1));
1277 range_start = param.GetAt(2);
1278 range_end = param.GetAt(3);
1279
1280 if ((page_index >= 0) && (page_index < NUM_FONT_CHAR_RANGES + NUM_FONT_EXTENDED_CHAR_RANGES))
1281 {
1282 font_range_row *row = (font_range_row *)mpRangeListWin->GetWindow(GW_CHILD);
1283
1284 while (page_index && row)
1285 {
1286 row = (font_range_row *)row->GetWindow(GW_HWNDNEXT);
1287 page_index--;
1288 }
1289
1290 if (row)
1291 {
1292 //check page range
1293 pWnd = row->GetDlgItem(ID_ENABLE_BOX);
1294 ((CButton *)pWnd)->SetCheck(check);
1295 row->SendMessage(WM_COMMAND, MAKEWPARAM(ID_ENABLE_BOX, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
1296
1297 //set range start
1298 row->SetDlgItemText(ID_START_FIELD, range_start);
1299 pWnd = row->GetDlgItem(ID_START_FIELD);
1300 row->SendMessage(WM_COMMAND, MAKEWPARAM(ID_START_FIELD, EN_KILLFOCUS), (LPARAM)pWnd->m_hWnd);
1301
1302 //set range end
1303 row->SetDlgItemText(ID_END_FIELD, range_end);
1304 pWnd = row->GetDlgItem(ID_END_FIELD);
1305 row->SendMessage(WM_COMMAND, MAKEWPARAM(ID_END_FIELD, EN_KILLFOCUS), (LPARAM)pWnd->m_hWnd);
1306 }
1307 break;
1308 }
1309 break;
1310
1311 case TEST_CHECK_EXTENDED_UNICODE:
1312 pWnd = GetDlgItem(IDC_SUPPORT_EXTENDED_UNICODE);
1313 ((CButton *)pWnd)->SetCheck(lParam);
1314 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_SUPPORT_EXTENDED_UNICODE, BN_CLICKED), (LPARAM)((CButton *)pWnd)->m_hWnd);
1315 break;
1316
1317 case TEST_CHECK_CUSTOM_OUTPUT:
1318 pWnd = GetDlgItem(IDC_CUSTOM_OUTPUT);
1319 ((CButton*)pWnd)->SetCheck(lParam);
1320 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_CUSTOM_OUTPUT, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
1321 break;
1322
1323 case TEST_SET_CUSTOM_OUTPUT_FILE:
1324 pWnd = GetDlgItem(IDC_OUTPUT_FILE);
1325 ((CEdit*)pWnd)->SetWindowText(GetTestingParam(0));
1326 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_OUTPUT_FILE, EN_KILLFOCUS), (LPARAM)((CEdit*)pWnd)->m_hWnd);
1327 break;
1328
1329 case TEST_SAVE_FONT_EDIT:
1330 //save modifications
1331 OnBnClickedOk();
1332 break;
1333
1334 case TEST_CANCEL_FONT_EDIT:
1335 //cancel modifications
1336 OnCancel();
1337 break;
1338 }
1339
1340 return 0;
1341 }
1342
OnBnClickedSupportExtendedUnicode()1343 void font_path_dialog::OnBnClickedSupportExtendedUnicode()
1344 {
1345 // TODO: Add your control notification handler code here
1346 CButton *pb = (CButton *)GetDlgItem(IDC_SUPPORT_EXTENDED_UNICODE);
1347
1348 if (pb->GetCheck())
1349 {
1350 font_page_info *extended_font_pages = CreateExtendedFontPages();
1351 font_page_info *new_pages = new font_page_info[NUM_FONT_CHAR_RANGES + NUM_FONT_EXTENDED_CHAR_RANGES];
1352 memcpy_s(new_pages, sizeof(font_page_info) * NUM_FONT_CHAR_RANGES, m_info->font_pages, sizeof(font_page_info) * NUM_FONT_CHAR_RANGES);
1353 memcpy_s(new_pages + NUM_FONT_CHAR_RANGES, sizeof(font_page_info) * NUM_FONT_EXTENDED_CHAR_RANGES, extended_font_pages, sizeof(font_page_info) * NUM_FONT_EXTENDED_CHAR_RANGES);
1354 delete[] extended_font_pages;
1355 delete[] m_info->font_pages;
1356 m_info->font_pages = new_pages;
1357 mpRangeListWin->CreateExtendedRangeEntry();
1358 }
1359 else
1360 {
1361 font_page_info *new_pages = new font_page_info[NUM_FONT_CHAR_RANGES];
1362 memcpy_s(new_pages, sizeof(font_page_info) * NUM_FONT_CHAR_RANGES, m_info->font_pages, sizeof(font_page_info) * NUM_FONT_CHAR_RANGES);
1363 delete[] m_info->font_pages;
1364 m_info->font_pages = new_pages;
1365 mpRangeListWin->DeleteExtendedRangeEntry();
1366 }
1367 }