1 // ProjectConfigDlg.cpp : implementation file
2 //
3
4 #include "studiox_includes.h"
5 #include "afxdd_.h"
6 #include "ProjectConfigDlg.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #else
11 #define STUDIOX_EVAL_BUILD
12 #endif
13
14 #define MIN_PROJECT_CONFIGURE_DLG_WIDTH 400
15 #define MIN_PROJECT_CONFIGURE_DLG_HEIGHT 400
16
17 extern COLOR_RECORD DEFAULT_COLOR_TABLE[];
18 extern COLOR_RECORD DEFAULT_COLOR_TABLE_GRAYSCALE[];
19 extern COLOR_RECORD DEFAULT_COLOR_TABLE_MONOCHROME[];
20
21
22 STRING_VAL_PAIR cpu_list[] = {
23 { _T("Generic"), CPU_GENERIC },
24 { _T("Renesas Synergy"), CPU_SYNERGY },
25 { _T("Renesas RA"), CPU_RA },
26 { _T("Renesas RX"), CPU_RX },
27 { _T("Renesas RZ"), CPU_RZ },
28 { _T("ST ChromeArt"), CPU_ST_CHROMEART },
29 { _T(""), 0 }
30 };
31
32 STRING_VAL_PAIR compiler_list[] = {
33 { _T("Generic"), TOOLS_GENERIC },
34 { _T("IAR"), TOOLS_IAR },
35 { _T("GNU"), TOOLS_GNU },
36 { _T("CCRX"), TOOLS_CCRX},
37 { _T(""), 0 }
38 };
39
40 STRING_VAL_PAIR screen_rotation_list[] = {
41 { _T("None"), GX_SCREEN_ROTATION_NONE },
42 { _T("CW"), GX_SCREEN_ROTATION_CW },
43 { _T("CCW"), GX_SCREEN_ROTATION_CCW },
44 { _T("FLIP"), GX_SCREEN_ROTATION_FLIP},
45 // Backward compatibility
46 { _T("0"), GX_SCREEN_ROTATION_NONE },
47 { _T("90"), GX_SCREEN_ROTATION_CW },
48 { _T("270"), GX_SCREEN_ROTATION_CCW },
49 { _T("180"), GX_SCREEN_ROTATION_FLIP},
50 { _T(""), 0 }
51 };
52
53 enum project_configure_dlg_test_commands{
54 TEST_CONFIGURE_SOURCE_PATH = 1,
55 TEST_CONFIGURE_HEADER_PATH,
56 TEST_CONFIGURE_RESOURCE_PATH,
57 TEST_CONFIGURE_X_RES,
58 TEST_CONFIGURE_Y_RES,
59 TEST_CONFIGURE_DISPLAY_NUM,
60 TEST_SELECT_DISPLAY_INDEX,
61 TEST_CONFIGURE_DISPLAY_NAME,
62 TEST_CONFIGURE_DISPLAY_COLOR_FORMAT,
63 TEST_CONFIGURE_DISPLAY_COLOR_DEPTH,
64 TEST_CONFIGURE_DISPLAY_RGB_BITS,
65 TEST_CONFIGURE_MINOR_VERSION,
66 TEST_CONFIGURE_SERVICE_PACK,
67 TEST_CONFIGURE_CANVAS_ALLOCATE,
68 TEST_CONFIGURE_CPU_TYPE,
69 TEST_CONFIGURE_BIG_ENDIAN,
70 TEST_SAVE_PROJECT_CONFIGURE,
71 TEST_CANCEL_PROJECT_CONFIGURE,
72 TEST_IS_DEFAULT_MAP_FORMAT,
73 TEST_GET_CPU_TYPE,
74 TEST_GET_DISPLAY_COLOR_FORMAT,
75 TEST_GET_DISPLAY_COLOR_DEPTH,
76 TEST_IS_1555_FORMAT,
77 TEST_IS_4444_FORAMT,
78 TEST_IS_332_FORMAT,
79 TEST_IS_NEW_PROJECT,
80 TEST_OPEN_ADVANCED_SETTINGS,
81 TEST_SET_AA_TEXT_COLORS
82 };
83
84 // ProjectConfigWin dialog
85
IMPLEMENT_DYNAMIC(ProjectConfigWin,CDialog)86 IMPLEMENT_DYNAMIC(ProjectConfigWin, CDialog)
87
88 BEGIN_MESSAGE_MAP(ProjectConfigWin, CDialog)
89 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_NUM_SCREENS, &ProjectConfigWin::OnDeltaposSpinNumScreens)
90 ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SCREEN_SELECT, &ProjectConfigWin::OnDeltaposSpinScreenSelect)
91 ON_EN_KILLFOCUS(IDC_NUM_DISPLAYS, &ProjectConfigWin::OnEnEditNumScreens)
92 ON_EN_KILLFOCUS(IDC_SELECTED_DISPLAY, &ProjectConfigWin::OnEnEditSelectedDisplay)
93 ON_EN_KILLFOCUS(IDC_MAJOR_VERSION, &ProjectConfigWin::OnEnEditMajorVersion)
94 ON_EN_KILLFOCUS(IDC_MINOR_VERSION, &ProjectConfigWin::OnEnEditMinorVersion)
95 ON_EN_KILLFOCUS(IDC_SERVICE_PACK, &ProjectConfigWin::OnEnEditServicePack)
96 ON_BN_CLICKED(IDC_BROWSE_SOURCE, &ProjectConfigWin::OnBnClickedBrowseSource)
97 ON_BN_CLICKED(IDC_BROWSE_HEADER, &ProjectConfigWin::OnBnClickedBrowseHeader)
98 ON_BN_CLICKED(IDC_BROWSE_RESOURCE, &ProjectConfigWin::OnBnClickedBrowseResource)
99 ON_BN_CLICKED(IDC_RADIO_1BPP, &ProjectConfigWin::BitDepthChanged)
100 ON_BN_CLICKED(IDC_RADIO_2BPP, &ProjectConfigWin::BitDepthChanged)
101 ON_BN_CLICKED(IDC_RADIO_4BPP, &ProjectConfigWin::BitDepthChanged)
102 ON_BN_CLICKED(IDC_RADIO_8BPP, &ProjectConfigWin::BitDepthChanged)
103 ON_BN_CLICKED(IDC_RADIO_16BPP, &ProjectConfigWin::BitDepthChanged)
104 ON_BN_CLICKED(IDC_RADIO_24BPP, &ProjectConfigWin::BitDepthChanged)
105 ON_BN_CLICKED(IDC_RADIO_32BPP, &ProjectConfigWin::BitDepthChanged)
106 ON_BN_CLICKED(IDC_CHECK_555FORMAT, &ProjectConfigWin::Format1555Clicked)
107 ON_BN_CLICKED(IDC_CHECK_4444FORMAT, &ProjectConfigWin::Format4444Clicked)
108 ON_BN_CLICKED(IDC_CHECK_332FORMAT, &ProjectConfigWin::Format332Clicked)
109 ON_BN_CLICKED(IDC_ADVANCED_SETTINGS, &ProjectConfigWin::OnAdvancedSettings)
110 ON_CBN_SELCHANGE(IDC_CPU_COMBO, &ProjectConfigWin::OnChangeSelectedCPU)
111 ON_EN_KILLFOCUS(IDC_X_RESOLUTION, &ProjectConfigWin::OnEditXRes)
112 ON_EN_KILLFOCUS(IDC_Y_RESOLUTION, &ProjectConfigWin::OnEditYRes)
113 ON_WM_VSCROLL()
114 ON_WM_HSCROLL()
115 ON_WM_SIZE()
116 ON_WM_MOUSEHWHEEL()
117 ON_MESSAGE(STUDIO_TEST, OnTestMessage)
118 END_MESSAGE_MAP()
119
120 ///////////////////////////////////////////////////////////////////////////////
121 ProjectConfigWin::ProjectConfigWin(CWnd* pParent, int current_display)
122 : CDialog(ProjectConfigWin::IDD, pParent)
123 {
124 mpProject = GetOpenProject();
125
126 if (current_display >= 0)
127 {
128 m_current_display = current_display;
129 }
130 else
131 {
132 m_current_display = 0;
133 }
134
135 mpParent = pParent;
136
137 m_scroll_helper = new CScrollHelper;
138 m_scroll_helper->AttachWnd(this);
139
140 // Change dialog font size according to text scaller
141 // Create the modeless dialog box from a dialol-box template
142 CDialogTemplate dlt;
143
144 if (!dlt.Load(MAKEINTRESOURCE(IDD_CONFIGURE_PROJECT_WIN)))
145 {
146 return;
147 }
148
149 int m_text_scaler = GetTextScaler();
150
151 int point_size = DEFAULT_DLG_FONT_POINT_SIZE * m_text_scaler / DEFAULT_TEXT_SCALER;
152
153 dlt.SetFont(L"MS Shell Dlg", point_size);
154 LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
155 m_lpszTemplateName = NULL;
156 CDialog::CreateIndirect(pdata, pParent);
157 GlobalUnlock(dlt.m_hTemplate);
158 }
159
160 ///////////////////////////////////////////////////////////////////////////////
~ProjectConfigWin()161 ProjectConfigWin::~ProjectConfigWin()
162 {
163 delete m_scroll_helper;
164 }
165
166 ///////////////////////////////////////////////////////////////////////////////
OnInitDialog()167 BOOL ProjectConfigWin::OnInitDialog()
168 {
169 CDialog::OnInitDialog();
170
171 // Set unique accessible name for browse button
172 SetControlAccessibleName(GetDlgItem(IDC_BROWSE_SOURCE)->GetSafeHwnd(), _T("browse source path"));
173 SetControlAccessibleName(GetDlgItem(IDC_BROWSE_HEADER)->GetSafeHwnd(), _T("browse header path"));
174 SetControlAccessibleName(GetDlgItem(IDC_BROWSE_RESOURCE)->GetSafeHwnd(), _T("browse reosurce path"));
175
176 CString description(L"pixels");
177 SetAccessibleFullDescription(GetDlgItem(IDC_X_RESOLUTION)->GetSafeHwnd(), description);
178 SetAccessibleFullDescription(GetDlgItem(IDC_Y_RESOLUTION)->GetSafeHwnd(), description);
179 SetAccessibleDescription(GetDlgItem(IDC_X_RESOLUTION)->GetSafeHwnd(), description);
180 SetAccessibleDescription(GetDlgItem(IDC_Y_RESOLUTION)->GetSafeHwnd(), description);
181
182 if (mpProject)
183 {
184 m_spin_num_screens.SetRange(1, 4);
185 m_spin_num_screens.SetBuddy(GetDlgItem(IDC_NUM_DISPLAYS));
186
187 m_spin_current_screen.SetRange(1, mpProject->mHeader.num_displays);
188 m_spin_current_screen.SetBuddy(GetDlgItem(IDC_SELECTED_DISPLAY));
189 m_spin_current_screen.SetPos(m_current_display + 1);
190
191 mSpinMajorVersion.SetRange(5, GUIX_MAJOR_VERSION + 1);
192 mSpinMajorVersion.SetBuddy(GetDlgItem(IDC_MAJOR_VERSION));
193
194 mSpinMinorVersion.SetRange(0, 99);
195 mSpinMinorVersion.SetBuddy(GetDlgItem(IDC_MINOR_VERSION));
196
197 mSpinServicePack.SetRange(0, 99);
198 mSpinServicePack.SetBuddy(GetDlgItem(IDC_SERVICE_PACK));
199
200 int major, minor, service_pack;
201 GuixVersionNumberToVersionFields(mpProject->mHeader.guix_version, major, minor, service_pack);
202
203 mSpinMajorVersion.SetPos(major);
204 mSpinMinorVersion.SetPos(minor);
205 mSpinServicePack.SetPos(service_pack);
206 }
207
208 CRect client;
209 GetClientRect(&client);
210
211 m_scroll_helper->SetDisplaySize(client.Width(), client.Height());
212 return TRUE;
213 }
214
215 ///////////////////////////////////////////////////////////////////////////////
DoDataExchange(CDataExchange * pDX)216 void ProjectConfigWin::DoDataExchange(CDataExchange* pDX)
217 {
218 int index;
219
220 if (!mpProject)
221 {
222 return;
223 }
224
225 CDialog::DoDataExchange(pDX);
226 DDX_Text(pDX, IDC_NUM_DISPLAYS, mpProject->mHeader.num_displays);
227 DDV_MinMaxInt(pDX, mpProject->mHeader.num_displays, 1, 4);
228 DDX_Text(pDX, IDC_SOURCE_PATH, mpProject->mHeader.source_path);
229 DDX_Text(pDX, IDC_HEADER_PATH, mpProject->mHeader.header_path);
230 DDX_Text(pDX, IDC_RESOURCE_PATH, mpProject->mHeader.resource_path);
231 DDX_Text(pDX, IDC_ADDITIONAL_HEADERS, mpProject->mHeader.additional_headers);
232
233 DDX_Control(pDX, IDC_SPIN_SCREEN_SELECT, m_spin_current_screen);
234 DDX_Control(pDX, IDC_SPIN_NUM_SCREENS, m_spin_num_screens);
235 DDX_Control(pDX, IDC_SPIN_MAJOR_VERSION, mSpinMajorVersion);
236 DDX_Control(pDX, IDC_SPIN_MINOR_VERSION, mSpinMinorVersion);
237 DDX_Control(pDX, IDC_SPIN_SERVICE_PACK, mSpinServicePack);
238 DDX_Control(pDX, IDC_CPU_COMBO, mCpuCombo);
239 DDX_Control(pDX, IDC_TOOLS_COMBO, mToolsCombo);
240 DDX_Control(pDX, IDC_AA_TEXT_COLORS_COMBO, mAATextColorsCombo);
241
242 DDX_Check(pDX, IDC_BIG_ENDIAN, mpProject->mHeader.big_endian);
243 DDX_Check(pDX, IDC_INSERT_BEFORE, mpProject->mHeader.insert_headers_before);
244
245 EnableDisableAdvancedSettings(mpProject->mHeader.target_cpu);
246
247 if (pDX->m_bSaveAndValidate)
248 {
249 DDX_Text(pDX, IDC_SELECTED_DISPLAY, m_current_display);
250 m_current_display -= 1;
251 SaveDisplayConfig(m_current_display);
252
253 int major = GetDlgItemInt(IDC_MAJOR_VERSION);
254 int minor = GetDlgItemInt(IDC_MINOR_VERSION);
255 int service = GetDlgItemInt(IDC_SERVICE_PACK);
256
257 mGuixVersion = GuixVersionFieldsToVersionNumber(major, minor, service);
258 }
259 else
260 {
261 mOldHeader = mpProject->mHeader;
262
263 // retrieve values from project and init dialog
264 int major, minor, service_pack;
265 GuixVersionNumberToVersionFields(mpProject->mHeader.guix_version, major, minor, service_pack);
266
267 SetDlgItemInt(IDC_MAJOR_VERSION, major);
268 SetDlgItemInt(IDC_MINOR_VERSION, minor);
269 SetDlgItemInt(IDC_SERVICE_PACK, service_pack);
270
271 STRING_VAL_PAIR*pEntry = cpu_list;
272
273 while(!pEntry->name.IsEmpty())
274 {
275 index = mCpuCombo.AddString(pEntry->name);
276 mCpuCombo.SetItemData(index, pEntry->val);
277 pEntry++;
278 }
279
280 pEntry = compiler_list;
281
282 while(!pEntry->name.IsEmpty())
283 {
284 index = mToolsCombo.AddString(pEntry->name);
285 mToolsCombo.SetItemData(index, pEntry->val);
286 pEntry++;
287 }
288 SelectDropListItem(&mCpuCombo, mpProject->mHeader.target_cpu);
289 SelectDropListItem(&mToolsCombo, mpProject->mHeader.target_tools);
290
291 InitDisplayConfig(m_current_display);
292 }
293 }
294
295
296 ///////////////////////////////////////////////////////////////////////////////
InitDisplayConfig(int display_index)297 void ProjectConfigWin::InitDisplayConfig(int display_index)
298 {
299 int radio_index = 0;
300 int display_num = display_index + 1;
301
302 CDataExchange nx(this, FALSE);
303
304 DDX_Text(&nx, IDC_SELECTED_DISPLAY, display_num);
305 DDX_Text(&nx, IDC_SCREEN_NAME, mpProject->mDisplays[display_index].name);
306 DDX_Text(&nx, IDC_X_RESOLUTION, mpProject->mDisplays[display_index].xres);
307 DDX_Text(&nx, IDC_Y_RESOLUTION, mpProject->mDisplays[display_index].yres);
308
309 DDX_Check(&nx, IDC_CHECK_GRAYSCALE, mpProject->mDisplays[display_index].grayscale);
310 DDX_Check(&nx, IDC_CHECK_555FORMAT, mpProject->mDisplays[display_index].format_555);
311 DDX_Check(&nx, IDC_CHECK_4444FORMAT, mpProject->mDisplays[display_index].format_4444);
312 DDX_Check(&nx, IDC_CHECK_332FORMAT, mpProject->mDisplays[display_index].format_332);
313 DDX_Check(&nx, IDC_CHECK_REVERSE_ORDER, mpProject->mDisplays[display_index].reverse_order);
314 DDX_Check(&nx, IDC_CHECK_PACKED, mpProject->mDisplays[display_index].packed_format);
315 DDX_Check(&nx, IDC_ALLOCATE_CANVAS, mpProject->mDisplays[display_index].allocate_canvas);
316
317 switch(mpProject->mDisplays[display_index].bits_per_pix)
318 {
319 case 1:
320 radio_index = 0;
321 break;
322
323 case 2:
324 radio_index = 1;
325 break;
326
327 case 4:
328 radio_index = 2;
329 break;
330
331 case 8:
332 radio_index = 3;
333 break;
334
335 case 16:
336 radio_index = 4;
337 break;
338
339 case 24:
340 radio_index = 5;
341 break;
342
343 case 32:
344 radio_index = 6;
345 break;
346 }
347
348 DDX_Radio(&nx, IDC_RADIO_1BPP, radio_index);
349
350 EnableDisable(mpProject->mDisplays[display_index].bits_per_pix, mpProject);
351 InitAATextColorsCombobox();
352 InitRotationAnglesCombobox(display_index);
353 }
354
355 ///////////////////////////////////////////////////////////////////////////////
SaveDisplayConfig(int display_index)356 void ProjectConfigWin::SaveDisplayConfig(int display_index)
357 {
358 int theme;
359 int radio_index = 0;
360 int display_num = display_index + 1;
361
362 CDataExchange nx(this, TRUE);
363
364 DDX_Text(&nx, IDC_SCREEN_NAME, mpProject->mDisplays[display_index].name);
365 DDX_Text(&nx, IDC_X_RESOLUTION, mpProject->mDisplays[display_index].xres);
366 DDX_Text(&nx, IDC_Y_RESOLUTION, mpProject->mDisplays[display_index].yres);
367
368 DDX_Check(&nx, IDC_CHECK_GRAYSCALE, mpProject->mDisplays[display_index].grayscale);
369 DDX_Check(&nx, IDC_CHECK_555FORMAT, mpProject->mDisplays[display_index].format_555);
370 DDX_Check(&nx, IDC_CHECK_4444FORMAT, mpProject->mDisplays[display_index].format_4444);
371 DDX_Check(&nx, IDC_CHECK_332FORMAT, mpProject->mDisplays[display_index].format_332);
372 DDX_Check(&nx, IDC_CHECK_REVERSE_ORDER, mpProject->mDisplays[display_index].reverse_order);
373
374 #if defined(_DEBUG)
375 DDX_Check(&nx, IDC_CHECK_PACKED, mpProject->mDisplays[display_index].packed_format);
376 #else
377 mpProject->mDisplays[display_index].packed_format = FALSE;
378 #endif
379
380 DDX_Check(&nx, IDC_ALLOCATE_CANVAS, mpProject->mDisplays[display_index].allocate_canvas);
381 DDX_Radio(&nx, IDC_RADIO_1BPP, radio_index);
382
383 int old_cpu_type = mpProject->mHeader.target_cpu;
384 int old_color_format = mpProject->mDisplays[display_index].colorformat;
385
386 mpProject->mHeader.target_cpu = mCpuCombo.GetItemData(mCpuCombo.GetCurSel());
387 mpProject->mHeader.target_tools = mToolsCombo.GetItemData(mToolsCombo.GetCurSel());
388
389 #if defined(STUDIOX_EVAL_BUILD)
390 // force 16 or 24 bit unpackedcolor depth for evaluation build
391 if (radio_index == 1)
392 {
393 radio_index = 3;
394 }
395 #endif
396 switch(radio_index)
397 {
398 case 0:
399 mpProject->mDisplays[display_index].bits_per_pix = 1;
400 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_MONOCHROME;
401 break;
402
403 case 1:
404 mpProject->mDisplays[display_index].bits_per_pix = 2;
405 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_2BIT_GRAY;
406 break;
407
408 case 2:
409 mpProject->mDisplays[display_index].bits_per_pix = 4;
410 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_4BIT_GRAY;
411 break;
412
413 case 3:
414 mpProject->mDisplays[display_index].bits_per_pix = 8;
415 if (mpProject->mDisplays[display_index].format_332)
416 {
417 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_8BIT_PACKED_PIXEL;
418 }
419 else
420 {
421 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_8BIT_PALETTE;
422
423 CComboBox *box = (CComboBox *)GetDlgItem(IDC_AA_TEXT_COLORS_COMBO);
424 int sel = box->GetCurSel();
425 mpProject->mHeader.palette_mode_aa_text_colors = box->GetItemData(sel);
426 }
427 break;
428
429 case 4:
430 mpProject->mDisplays[display_index].bits_per_pix = 16;
431 if (mpProject->mDisplays[display_index].format_4444 == TRUE)
432 {
433 if (mpProject->mDisplays[display_index].reverse_order)
434 {
435 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_4444BGRA;
436 }
437 else
438 {
439 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_4444ARGB;
440 }
441 }
442 else if (mpProject->mDisplays[display_index].format_555 == TRUE)
443 {
444 if (mpProject->mDisplays[display_index].reverse_order)
445 {
446 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_5551BGRX;
447 }
448 else
449 {
450 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_1555XRGB;
451 }
452 }
453 else
454 {
455 if (mpProject->mDisplays[display_index].reverse_order)
456 {
457 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_565BGR;
458 }
459 else
460 {
461 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_565RGB;
462 }
463 }
464 break;
465
466 case 5:
467 mpProject->mDisplays[display_index].bits_per_pix = 24;
468
469 #if defined(_DEBUG)
470 if (mpProject->mDisplays[display_index].packed_format)
471 {
472 if (mpProject->mDisplays[display_index].reverse_order)
473 {
474 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_24BGR;
475 }
476 else
477 {
478 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_24RGB;
479 }
480 }
481 else
482 #endif
483
484 {
485 // 24-bit unpacked format
486 if (mpProject->mDisplays[display_index].reverse_order)
487 {
488 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_24BGRX;
489 }
490 else
491 {
492 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_24XRGB;
493 }
494 }
495 break;
496
497 case 6:
498 mpProject->mDisplays[display_index].bits_per_pix = 32;
499 if (mpProject->mDisplays[display_index].reverse_order)
500 {
501 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_32BGRA;
502 }
503 else
504 {
505 mpProject->mDisplays[display_index].colorformat = GX_COLOR_FORMAT_32ARGB;
506 }
507 break;
508 }
509
510 GX_BOOL color_format_changed = FALSE;
511
512 if (old_color_format != mpProject->mDisplays[display_index].colorformat)
513 {
514 color_format_changed = TRUE;
515 }
516
517 if (color_format_changed)
518 {
519 GX_BOOL ChangeColorTable = FALSE;
520 GX_BOOL ConvertCustomColorGroup = FALSE;
521
522 if (!mpProject->mHeader.b_new_project)
523 {
524 Notify("The output color format has changed. The system color table will be remapped to the nearest match colors.", mpParent);
525 }
526
527 for (theme = 0; theme < MAX_THEMES; theme++)
528 {
529 GX_COLOR *old_pal = NULL;
530 int old_palsize = 0;
531
532 if(mpProject->mDisplays[display_index].themes[theme].palette)
533 {
534 /* Save old palette info. */
535 old_pal = mpProject->mDisplays[display_index].themes[theme].palette;
536 old_palsize = mpProject->mDisplays[display_index].themes[theme].palette_predefined;
537
538 mpProject->mDisplays[display_index].themes[theme].palette = NULL;
539 mpProject->mDisplays[display_index].themes[theme].palette_total_size = 0;
540 }
541
542 res_info *info = mpProject->mDisplays[display_index].themes[theme].GetFirstResourceInfo();
543
544
545 if (info)
546 {
547 // If we are running at 8 bit palette mode, then we need to create a default palette
548 if (mpProject->mDisplays[display_index].colorformat == GX_COLOR_FORMAT_8BIT_PALETTE)
549 {
550 ProjectConfigDlg::CreateDefaultPalette(mpProject, display_index, theme);
551 }
552
553 // Convert the custom colors to the best match in the new output format.
554 ProjectConfigDlg:: ColorTableConvert(info,
555 old_pal,
556 old_palsize,
557 old_color_format,
558 mpProject->mDisplays[display_index].themes[theme].palette,
559 mpProject->mDisplays[display_index].themes[theme].palette_predefined,
560 mpProject->mDisplays[display_index].colorformat);
561 }
562
563 if(old_pal)
564 {
565 delete [] old_pal;
566 old_pal = NULL;
567 }
568 }
569 }
570
571 GX_BOOL cpu_type_changed = FALSE;
572 GX_BOOL accelerator_disabled = FALSE;
573 if (old_cpu_type != mpProject->mHeader.target_cpu)
574 {
575 cpu_type_changed = TRUE;
576 }
577 else
578 {
579 if ((IsCpuWithDave2D(mpProject->mHeader.target_cpu)) &&
580 (mOldHeader.dave2d_graph_accelerator == TRUE) &&
581 (mpProject->mHeader.dave2d_graph_accelerator == FALSE))
582 {
583 accelerator_disabled = TRUE;
584 }
585 }
586
587 CComboBox* box = (CComboBox*)GetDlgItem(IDC_ROTATION_ANGLE_COMBO);
588 if (box)
589 {
590 int sel = box->GetCurSel();
591 mpProject->mDisplays[display_index].rotation_angle = box->GetItemData(sel);
592
593 // This is just a double-safety check, we really should ever get here
594 // but just to make sure we don't set flip rotation unless cpu_type is Renesas/Dave2D
595
596 if (!IsCpuWithDave2D(mpProject))
597 {
598 if (mpProject->mDisplays[display_index].rotation_angle == GX_SCREEN_ROTATION_FLIP)
599 {
600 mpProject->mDisplays[display_index].rotation_angle = GX_SCREEN_ROTATION_NONE;
601 }
602 }
603 }
604
605 if (cpu_type_changed || color_format_changed || accelerator_disabled)
606 {
607 if (!mpProject->mDisplays[display_index].default_map_format)
608 {
609 // check to see if we have any pixelmaps that cannot be supported in new format:
610 if (color_format_changed)
611 {
612 Notify("The output color format has been changed, resetting all the pixelmap formats to the default.", mpParent);
613 }
614 else if (cpu_type_changed)
615 {
616 Notify("The cpu type has been changed, resetting all the pixelmap formats to the default.", mpParent);
617 }
618 else
619 {
620 Notify("Graphic accelerator has been disabled, resetting all the pixelmap formats to the default.", mpParent);
621 }
622
623 for (theme = 0; theme < MAX_THEMES; theme++)
624 {
625 ProjectConfigDlg::ResetPixelmapFormat(mpProject->mDisplays[display_index].themes[theme].GetFirstResourceInfo(), display_index);
626 }
627 }
628 }
629
630 if (cpu_type_changed ||
631 (color_format_changed && (mpProject->mDisplays[display_index].bits_per_pix <= 8)))
632 {
633 // check to see if we have any fonts that cannot be supported in new format:
634 for (theme = 0; theme < MAX_THEMES; theme++)
635 {
636 ProjectConfigDlg::CheckFontFormat(mpProject->mDisplays[display_index].themes[theme].GetFirstResourceInfo(), display_index);
637 }
638 }
639
640 if (color_format_changed && (mpProject->mDisplays[display_index].colorformat <= GX_COLOR_FORMAT_8BIT_PALETTE))
641 {
642 // Text scroll wheel widget does not support rounding transform style when color depth is less than or equal to 8
643 // Disable rounding style for text scroll wheel widgets
644 folder_info *folder = mpProject->mDisplays[display_index].GetFirstChildFolder();
645
646 while (folder)
647 {
648 ProjectConfigDlg::DisableTextScrollWheelRoundStyle(folder->GetFirstChildWidget());
649 folder = folder->GetNextFolder();
650 }
651 }
652 }
653
654 ///////////////////////////////////////////////////////////////////////////////
GetBitsSelected()655 int ProjectConfigWin::GetBitsSelected()
656 {
657 int bits = 0;
658
659 if (IsDlgButtonChecked(IDC_RADIO_1BPP))
660 {
661 bits = 1;
662 }
663 else if (IsDlgButtonChecked(IDC_RADIO_2BPP))
664 {
665 bits = 2;
666 }
667 else if (IsDlgButtonChecked(IDC_RADIO_4BPP))
668 {
669 bits = 4;
670 }
671 else if (IsDlgButtonChecked(IDC_RADIO_8BPP))
672 {
673 bits = 8;
674 }
675 else if (IsDlgButtonChecked(IDC_RADIO_16BPP))
676 {
677 bits = 16;
678 }
679 else if (IsDlgButtonChecked(IDC_RADIO_24BPP))
680 {
681 bits = 24;
682 }
683 else if (IsDlgButtonChecked(IDC_RADIO_32BPP))
684 {
685 bits = 32;
686 }
687 return bits;
688 }
689
690 ///////////////////////////////////////////////////////////////////////////////
Format4444Clicked()691 void ProjectConfigWin::Format4444Clicked()
692 {
693 if (GetBitsSelected() == 16)
694 {
695 if (((CButton *)GetDlgItem(IDC_CHECK_4444FORMAT))->GetCheck() == BST_CHECKED)
696 {
697 CheckDlgButton(IDC_CHECK_555FORMAT, FALSE);
698 }
699
700 EnableDisable(GetBitsSelected(), mpProject);
701 }
702 }
703
704 ///////////////////////////////////////////////////////////////////////////////
Format1555Clicked()705 void ProjectConfigWin::Format1555Clicked()
706 {
707 if (GetBitsSelected() == 16)
708 {
709 if (((CButton *)GetDlgItem(IDC_CHECK_555FORMAT))->GetCheck() == BST_CHECKED)
710 {
711 CheckDlgButton(IDC_CHECK_4444FORMAT, FALSE);
712 }
713
714 EnableDisable(GetBitsSelected(), mpProject);
715 }
716 }
717
718 ///////////////////////////////////////////////////////////////////////////////
Format332Clicked()719 void ProjectConfigWin::Format332Clicked()
720 {
721 EnableDisableAATextColorsSetting();
722 }
723
724
725 ///////////////////////////////////////////////////////////////////////////////
BitDepthChanged()726 void ProjectConfigWin::BitDepthChanged()
727 {
728 EnableDisable(GetBitsSelected(), mpProject);
729 }
730
731 ///////////////////////////////////////////////////////////////////////////////
OffAndDisable(int id)732 void ProjectConfigWin::OffAndDisable(int id)
733 {
734 GetDlgItem(id)->EnableWindow(FALSE);
735 CheckDlgButton(id, FALSE);
736 }
737
738 ///////////////////////////////////////////////////////////////////////////////
EnableDisableCCRX(int cpu_type)739 void ProjectConfigWin::EnableDisableCCRX(int cpu_type)
740 {
741 int index;
742
743 if (cpu_type == CPU_RX)
744 {
745 // make sure CCRX is in the tools list:
746 for (index = 0; index < mToolsCombo.GetCount(); index++)
747 {
748 if (mToolsCombo.GetItemData(index) == TOOLS_CCRX)
749 {
750 return;
751 }
752 }
753
754 // Did not find CCRX, append it:
755 index = mToolsCombo.InsertString(-1, _T("CCRX"));
756 mToolsCombo.SetItemData(index, TOOLS_CCRX);
757 }
758 else
759 {
760 // If ccrx was selected, reset to generic
761 if (mToolsCombo.GetItemData(mToolsCombo.GetCurSel()) == TOOLS_CCRX)
762 {
763 mpProject->mHeader.target_tools = TOOLS_GENERIC;
764 SelectDropListItem(&mToolsCombo, mpProject->mHeader.target_tools);
765 }
766
767 // delete CCRX from the drop-down list:
768 for (index = 0; index < mToolsCombo.GetCount(); index++)
769 {
770 if (mToolsCombo.GetItemData(index) == TOOLS_CCRX)
771 {
772 mToolsCombo.DeleteString(index);
773 break;
774 }
775 }
776 }
777 }
778
779 ///////////////////////////////////////////////////////////////////////////////
EnableDisable(int bits,studiox_project * proj)780 void ProjectConfigWin::EnableDisable(int bits, studiox_project *proj)
781 {
782 int box_index = mCpuCombo.GetCurSel();
783 int cpu_type = mCpuCombo.GetItemData(box_index);
784
785 /* Disable 2bpp radio button. Because we don't support this for now.
786 Diable it to avoid unforeseeing bug. */
787 OffAndDisable(IDC_RADIO_2BPP);
788
789 EnableDisableCCRX(cpu_type);
790
791 if (cpu_type == CPU_SYNERGY)
792 {
793 OffAndDisable(IDC_RADIO_1BPP);
794 OffAndDisable(IDC_RADIO_2BPP);
795 OffAndDisable(IDC_RADIO_4BPP);
796 OffAndDisable(IDC_CHECK_INVERTED);
797 OffAndDisable(IDC_CHECK_PACKED);
798 OffAndDisable(IDC_CHECK_555FORMAT);
799 OffAndDisable(IDC_CHECK_4444FORMAT);
800 OffAndDisable(IDC_CHECK_332FORMAT);
801 }
802 else
803 {
804 GetDlgItem(IDC_RADIO_1BPP)->EnableWindow(TRUE);
805 GetDlgItem(IDC_RADIO_4BPP)->EnableWindow(TRUE);
806 }
807
808 BOOL disable_reverse_order = TRUE;
809
810 switch(bits)
811 {
812 case 1:
813 case 2:
814 GetDlgItem(IDC_CHECK_GRAYSCALE)->EnableWindow(FALSE);
815 OffAndDisable(IDC_CHECK_PACKED);
816 OffAndDisable(IDC_CHECK_555FORMAT);
817 OffAndDisable(IDC_CHECK_4444FORMAT);
818 OffAndDisable(IDC_CHECK_332FORMAT);
819 CheckDlgButton(IDC_CHECK_GRAYSCALE, TRUE);
820 if (cpu_type != CPU_SYNERGY)
821 {
822 GetDlgItem(IDC_CHECK_INVERTED)->EnableWindow(TRUE);
823 }
824 break;
825
826 case 4:
827 /* Disable grayscale and inverted button.
828 4bpp only support grayscale for now. */
829 CheckDlgButton(IDC_CHECK_INVERTED, FALSE);
830 CheckDlgButton(IDC_CHECK_GRAYSCALE, TRUE);
831 GetDlgItem(IDC_CHECK_GRAYSCALE)->EnableWindow(FALSE);
832 GetDlgItem(IDC_CHECK_INVERTED)->EnableWindow(FALSE);
833 OffAndDisable(IDC_CHECK_PACKED);
834 OffAndDisable(IDC_CHECK_555FORMAT);
835 OffAndDisable(IDC_CHECK_4444FORMAT);
836 OffAndDisable(IDC_CHECK_332FORMAT);
837 break;
838
839 case 8:
840 GetDlgItem(IDC_CHECK_INVERTED)->EnableWindow(FALSE);
841 OffAndDisable(IDC_CHECK_PACKED);
842 OffAndDisable(IDC_CHECK_555FORMAT);
843 OffAndDisable(IDC_CHECK_4444FORMAT);
844 OffAndDisable(IDC_CHECK_GRAYSCALE);
845
846 if (cpu_type != CPU_SYNERGY)
847 {
848 GetDlgItem(IDC_CHECK_332FORMAT)->EnableWindow(TRUE);
849 }
850 break;
851
852 case 16:
853 OffAndDisable(IDC_CHECK_GRAYSCALE);
854 OffAndDisable(IDC_CHECK_INVERTED);
855 OffAndDisable(IDC_CHECK_PACKED);
856 OffAndDisable(IDC_CHECK_332FORMAT);
857
858 if (cpu_type != CPU_SYNERGY)
859 {
860 if ((!IsDlgButtonChecked(IDC_CHECK_4444FORMAT)) &&
861 (!IsDlgButtonChecked(IDC_CHECK_555FORMAT)))
862 {
863 // Only 565rgb color format support reverse byte order feature
864 GetDlgItem(IDC_CHECK_REVERSE_ORDER)->EnableWindow(TRUE);
865 disable_reverse_order = FALSE;
866 }
867
868 GetDlgItem(IDC_CHECK_555FORMAT)->EnableWindow(TRUE);
869 GetDlgItem(IDC_CHECK_4444FORMAT)->EnableWindow(TRUE);
870 }
871 break;
872
873 case 24:
874 OffAndDisable(IDC_CHECK_GRAYSCALE);
875 OffAndDisable(IDC_CHECK_INVERTED);
876 OffAndDisable(IDC_CHECK_PACKED);
877 OffAndDisable(IDC_CHECK_555FORMAT);
878 OffAndDisable(IDC_CHECK_4444FORMAT);
879 OffAndDisable(IDC_CHECK_332FORMAT);
880 #if defined(_DEBUG)
881 if (cpu_type != CPU_SYNERGY)
882 {
883 GetDlgItem(IDC_CHECK_REVERSE_ORDER)->EnableWindow(TRUE);
884 GetDlgItem(IDC_CHECK_PACKED)->EnableWindow(TRUE);
885 }
886 #endif
887 break;
888
889 case 32:
890 OffAndDisable(IDC_CHECK_GRAYSCALE);
891 OffAndDisable(IDC_CHECK_INVERTED);
892 OffAndDisable(IDC_CHECK_PACKED);
893 OffAndDisable(IDC_CHECK_555FORMAT);
894 OffAndDisable(IDC_CHECK_4444FORMAT);
895 OffAndDisable(IDC_CHECK_332FORMAT);
896 break;
897 }
898
899 if (disable_reverse_order)
900 {
901 OffAndDisable(IDC_CHECK_REVERSE_ORDER);
902 }
903
904 /* override the above logic for now, if we are not building in
905 Debug mode, disable the IDC_CHECK_PACKED because this format
906 is not supported today. Remove this override once we add this
907 support.
908
909 Same is true for REVERSE_ORDER, this option is not truly supported by the
910 resource generation logic today. 16/24/32 bit display data needs to be
911 reversed, and we don't do that today, even though logic is in studiox_display_driver
912 to instantiate reverse order display driver.
913 */
914
915 #if !defined(_DEBUG)
916 OffAndDisable(IDC_CHECK_PACKED);
917 #endif
918
919 EnableDisableAATextColorsSetting();
920 }
921
922
923 // ProjectConfigWin message handlers
924
925 ///////////////////////////////////////////////////////////////////////////////
OnEnEditNumScreens()926 void ProjectConfigWin::OnEnEditNumScreens()
927 {
928 int val = GetDlgItemInt(IDC_NUM_DISPLAYS);
929
930 if (val > 0 && val < 5)
931 {
932 int SelectedDisplay;
933
934 SelectedDisplay = GetDlgItemInt(IDC_SELECTED_DISPLAY);
935 if (SelectedDisplay > val)
936 {
937 m_current_display = val - 1;
938 InitDisplayConfig(m_current_display);
939 }
940 m_spin_current_screen.SetRange(1, val);
941 m_spin_current_screen.Invalidate();
942
943 }
944 else
945 {
946 Notify("Invalid value for Number of Displays. Valid range is from 1 to 4.", mpParent);
947 SetDlgItemInt(IDC_NUM_DISPLAYS, mpProject->mHeader.num_displays);
948 }
949 }
950
951 ///////////////////////////////////////////////////////////////////////////////
OnEnEditSelectedDisplay()952 void ProjectConfigWin::OnEnEditSelectedDisplay()
953 {
954 //Check name when switch display.
955 if (!TestInputName((CEdit*)GetDlgItem(IDC_SCREEN_NAME), "Name", mpProject->mDisplays[m_current_display].name, mpParent))
956 {
957 SetDlgItemInt(IDC_SELECTED_DISPLAY, m_current_display);
958 return;
959 }
960
961 SaveDisplayConfig(m_current_display);
962
963 int new_display = GetDlgItemInt(IDC_SELECTED_DISPLAY);
964 int num_displays = GetDlgItemInt(IDC_NUM_DISPLAYS);
965
966 if (new_display >= 1 && new_display <= num_displays)
967 {
968 m_current_display = new_display - 1;
969 InitDisplayConfig(m_current_display);
970 }
971 else
972 {
973 ErrorMsg("Selected display must be between 1 and the total number of displays", mpParent);
974 SetDlgItemInt(IDC_SELECTED_DISPLAY, m_current_display + 1);
975 }
976 }
977
978 ///////////////////////////////////////////////////////////////////////////////
OnEnEditMajorVersion()979 void ProjectConfigWin::OnEnEditMajorVersion()
980 {
981 int major_version = GetDlgItemInt(IDC_MAJOR_VERSION);
982 int minor_version;
983 int service_pack;
984
985 if (major_version != 5 && major_version != 6)
986 {
987 ErrorMsg("Invalid major version number. Must be 5 or 6", mpParent);
988 GuixVersionNumberToVersionFields(mpProject->mHeader.guix_version, major_version, minor_version, service_pack);
989 SetDlgItemInt(IDC_MAJOR_VERSION, major_version);
990 }
991 }
992
993 ///////////////////////////////////////////////////////////////////////////////
OnEnEditMinorVersion()994 void ProjectConfigWin::OnEnEditMinorVersion()
995 {
996 int minor_version = GetDlgItemInt(IDC_MINOR_VERSION);
997 int major_version;
998 int service_pack;
999
1000 if (minor_version < 0 || minor_version > 99)
1001 {
1002 ErrorMsg("Invalid minor version number. Must be a value between 0 and 99", mpParent);
1003 GuixVersionNumberToVersionFields(mpProject->mHeader.guix_version, major_version, minor_version, service_pack);
1004
1005 SetDlgItemInt(IDC_MINOR_VERSION, minor_version);
1006 }
1007 }
1008
1009 ///////////////////////////////////////////////////////////////////////////////
OnEnEditServicePack()1010 void ProjectConfigWin::OnEnEditServicePack()
1011 {
1012 int service_pack = GetDlgItemInt(IDC_SERVICE_PACK);
1013 int major_version;
1014 int minor_version;
1015
1016 if (service_pack < 0 || service_pack > 99)
1017 {
1018 ErrorMsg("Invalid service pack number. Must be a value between 0 and 99", mpParent);
1019 GuixVersionNumberToVersionFields(mpProject->mHeader.guix_version, major_version, minor_version, service_pack);
1020
1021 SetDlgItemInt(IDC_SERVICE_PACK, service_pack);
1022 }
1023
1024 }
1025
1026 int bad_range = 0;
1027
1028 ///////////////////////////////////////////////////////////////////////////////
OnVScroll(UINT nSBCode,UINT nPos,CScrollBar * pScrollBar)1029 void ProjectConfigWin::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
1030 {
1031 if (pScrollBar)
1032 {
1033 // The message is not sent by a standard scrollbar, return directly.
1034 return;
1035 }
1036
1037 m_scroll_helper->OnVScroll(nSBCode, nPos, pScrollBar);
1038 }
1039
1040 ///////////////////////////////////////////////////////////////////////////////
OnHScroll(UINT nSBCode,UINT nPos,CScrollBar * pScrollBar)1041 void ProjectConfigWin::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
1042 {
1043 if (pScrollBar)
1044 {
1045 // The message is not sent by a standard scrollbar, return directly.
1046 return;
1047 }
1048
1049 m_scroll_helper->OnHScroll(nSBCode, nPos, pScrollBar);
1050 }
1051
1052 ///////////////////////////////////////////////////////////////////////////////
OnSize(UINT nType,int cx,int cy)1053 void ProjectConfigWin::OnSize(UINT nType, int cx, int cy)
1054 {
1055 CDialog::OnSize(nType, cx, cy);
1056 m_scroll_helper->OnSize(nType, cx, cy);
1057 }
1058
1059 ///////////////////////////////////////////////////////////////////////////////
OnMouseHWheel(UINT nFlags,short zDelta,CPoint pt)1060 void ProjectConfigWin::OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt)
1061 {
1062 m_scroll_helper->OnMouseWheel(nFlags, zDelta, pt);
1063 }
1064
1065 ///////////////////////////////////////////////////////////////////////////////
OnDeltaposSpinNumScreens(NMHDR * pNMHDR,LRESULT * pResult)1066 void ProjectConfigWin::OnDeltaposSpinNumScreens(NMHDR *pNMHDR, LRESULT *pResult)
1067 {
1068 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
1069 // TODO: Add your control notification handler code here
1070
1071 int upper;
1072 int lower;
1073
1074 m_spin_num_screens.GetRange(lower, upper);
1075
1076 int iVal = pNMUpDown ->iPos + pNMUpDown->iDelta;
1077 if (iVal >= lower && iVal <= upper)
1078 {
1079 m_spin_current_screen.SetRange(1, iVal);
1080
1081 m_spin_current_screen.Invalidate();
1082
1083 int SelectedDisplay;
1084
1085 SelectedDisplay = GetDlgItemInt(IDC_SELECTED_DISPLAY);
1086 if (SelectedDisplay > iVal)
1087 {
1088 m_current_display = iVal - 1;
1089 InitDisplayConfig(m_current_display);
1090 }
1091 *pResult = 0;
1092 }
1093 else
1094 {
1095 *pResult = 1;
1096 }
1097 }
1098
1099 ///////////////////////////////////////////////////////////////////////////////
OnDeltaposSpinScreenSelect(NMHDR * pNMHDR,LRESULT * pResult)1100 void ProjectConfigWin::OnDeltaposSpinScreenSelect(NMHDR *pNMHDR, LRESULT *pResult)
1101 {
1102 int upper;
1103 int lower;
1104
1105 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
1106 // TODO: Add your control notification handler code here
1107 m_spin_current_screen.GetRange(lower, upper);
1108 int iVal = pNMUpDown ->iPos;
1109
1110 if (iVal <= upper && iVal >= lower)
1111 {
1112 //Check name when switch display.
1113 if (!TestInputName((CEdit *)GetDlgItem(IDC_SCREEN_NAME), "Name", mpProject->mDisplays[iVal - 1].name, mpParent))
1114 {
1115 *pResult = 1;
1116 return;
1117 }
1118
1119 SaveDisplayConfig(iVal - 1);
1120
1121 iVal += pNMUpDown->iDelta;
1122
1123 if (iVal <= upper && iVal >= lower)
1124 {
1125 m_current_display = iVal - 1;
1126 InitDisplayConfig(m_current_display);
1127 *pResult = 0;
1128 }
1129 else
1130 {
1131 *pResult = 1;
1132 }
1133 }
1134 else
1135 {
1136 *pResult = 1;
1137 }
1138 }
1139
1140 ///////////////////////////////////////////////////////////////////////////////
OnBnClickedBrowseSource()1141 void ProjectConfigWin::OnBnClickedBrowseSource()
1142 {
1143 // TODO: Add your control notification handler code here
1144 TCHAR path[MAX_PATH];
1145 CString relativepath;
1146 if (BrowseForFolder(m_hWnd, NULL, NULL, path))
1147 {
1148 relativepath = CString(path);
1149 ConvertToProjectRelativePath(relativepath);
1150 SetDlgItemText(IDC_SOURCE_PATH, relativepath);
1151 }
1152 }
1153
1154 ///////////////////////////////////////////////////////////////////////////////
OnBnClickedBrowseHeader()1155 void ProjectConfigWin::OnBnClickedBrowseHeader()
1156 {
1157 TCHAR path[MAX_PATH];
1158 CString relativepath;
1159 if (BrowseForFolder(m_hWnd, NULL, NULL, path))
1160 {
1161 relativepath = CString(path);
1162 ConvertToProjectRelativePath(relativepath);
1163 SetDlgItemText(IDC_HEADER_PATH, relativepath);
1164 }
1165 }
1166
1167 ///////////////////////////////////////////////////////////////////////////////
OnBnClickedBrowseResource()1168 void ProjectConfigWin::OnBnClickedBrowseResource()
1169 {
1170 TCHAR path[MAX_PATH];
1171 CString relativepath;
1172
1173 if (BrowseForFolder(m_hWnd, NULL, NULL, path))
1174 {
1175 relativepath = CString(path);
1176 ConvertToProjectRelativePath(relativepath);
1177 SetDlgItemText(IDC_RESOURCE_PATH, relativepath);
1178 }
1179 }
1180
1181
1182 ///////////////////////////////////////////////////////////////////////////////
GetGuixVersion()1183 int ProjectConfigWin::GetGuixVersion()
1184 {
1185 return mGuixVersion;
1186 }
1187
1188 ///////////////////////////////////////////////////////////////////////////////
OnAdvancedSettings()1189 void ProjectConfigWin::OnAdvancedSettings()
1190 {
1191 int box_index = mCpuCombo.GetCurSel();
1192 int cpu_type = mCpuCombo.GetItemData(box_index);
1193
1194 if (IsCpuWithDave2D(cpu_type))
1195 {
1196 synergy_settings_dlg dlg(mpParent, m_current_display);
1197
1198 dlg.SetOwner(mpParent);
1199
1200 if (dlg.DoModal() == IDOK)
1201 {
1202 Invalidate();
1203 mpProject->SetModified();
1204 }
1205 }
1206
1207 EnableDisableAATextColorsSetting();
1208 }
1209
1210 ///////////////////////////////////////////////////////////////////////////////
OnChangeSelectedCPU()1211 void ProjectConfigWin::OnChangeSelectedCPU()
1212 {
1213 int box_index = mCpuCombo.GetCurSel();
1214 int cpu_type = mCpuCombo.GetItemData(box_index);
1215
1216 EnableDisableAdvancedSettings(cpu_type);
1217 EnableDisableFlipRotation(cpu_type);
1218
1219 EnableDisableCCRX(cpu_type);
1220
1221 if (IsCpuWithDave2D(cpu_type))
1222 {
1223 switch(GetBitsSelected())
1224 {
1225 case 8:
1226 case 16:
1227 case 24:
1228 case 32:
1229 break;
1230
1231 default:
1232 CheckDlgButton(IDC_RADIO_16BPP, TRUE);
1233 break;
1234 }
1235 mpProject->mHeader.dave2d_graph_accelerator = TRUE;
1236 mpProject->mHeader.renesas_jpeg_decoder = DECODER_TYPE_HW;
1237 mpProject->mHeader.renesas_png_decoder = DECODER_TYPE_NONE;
1238
1239 }
1240 else
1241 {
1242 mpProject->mHeader.dave2d_graph_accelerator = FALSE;
1243 mpProject->mHeader.renesas_jpeg_decoder = DECODER_TYPE_NONE;
1244 mpProject->mHeader.renesas_png_decoder = DECODER_TYPE_NONE;
1245 }
1246
1247 // run this to enable/disable fields that CPU does or does not support
1248 BitDepthChanged();
1249 }
1250
1251 ///////////////////////////////////////////////////////////////////////////////
OnEditXRes()1252 void ProjectConfigWin::OnEditXRes()
1253 {
1254 int xres;
1255
1256 xres = GetDlgItemInt(IDC_X_RESOLUTION);
1257
1258 if (xres > GX_MAX_DISPLAY_RESOLUTION)
1259 {
1260 Notify("X resolution is out of range, revert to previous value.", mpParent);
1261 SetDlgItemInt(IDC_X_RESOLUTION, mpProject->mDisplays[m_current_display].xres);
1262 }
1263 }
1264
1265 ///////////////////////////////////////////////////////////////////////////////
OnEditYRes()1266 void ProjectConfigWin::OnEditYRes()
1267 {
1268 int yres;
1269
1270 yres = GetDlgItemInt(IDC_Y_RESOLUTION);
1271
1272 if (yres > GX_MAX_DISPLAY_RESOLUTION)
1273 {
1274 Notify("Y resolution is out of range, revert to previous value.", mpParent);
1275 SetDlgItemInt(IDC_Y_RESOLUTION, mpProject->mDisplays[m_current_display].yres);
1276 }
1277 }
1278
1279 ///////////////////////////////////////////////////////////////////////////////
EnableDisableAdvancedSettings(int cpu_type)1280 void ProjectConfigWin::EnableDisableAdvancedSettings(int cpu_type)
1281 {
1282 if (IsCpuWithDave2D(cpu_type))
1283 {
1284 GetDlgItem(IDC_ADVANCED_SETTINGS)->EnableWindow(TRUE);
1285 }
1286 else
1287 {
1288 GetDlgItem(IDC_ADVANCED_SETTINGS)->EnableWindow(FALSE);
1289 }
1290 }
1291
1292 ///////////////////////////////////////////////////////////////////////////////
EnableDisableAATextColorsSetting()1293 void ProjectConfigWin::EnableDisableAATextColorsSetting()
1294 {
1295 int bits = GetBitsSelected();
1296 int box_index = mCpuCombo.GetCurSel();
1297 int cpu_type = mCpuCombo.GetItemData(box_index);
1298 int enable = FALSE;
1299
1300 if ((bits == 8) && (!IsDlgButtonChecked(IDC_CHECK_332FORMAT)))
1301 {
1302 if ((!IsDave2dFontFormat(mpProject, m_current_display)) ||
1303 (!mpProject->mHeader.dave2d_graph_accelerator))
1304 {
1305 enable = TRUE;
1306 }
1307 }
1308
1309 GetDlgItem(IDC_AA_TEXT_COLORS_COMBO)->EnableWindow(enable);
1310 GetDlgItem(IDC_AA_TEXT_COLORS_LABEL)->EnableWindow(enable);
1311 }
1312
1313 ///////////////////////////////////////////////////////////////////////////////
InitAATextColorsCombobox()1314 void ProjectConfigWin::InitAATextColorsCombobox()
1315 {
1316 CComboBox *box = (CComboBox *)GetDlgItem(IDC_AA_TEXT_COLORS_COMBO);
1317
1318 if (!box->GetCount())
1319 {
1320 box->InsertString(0, _T("16"));
1321 box->SetItemData(0, 16);
1322
1323 box->InsertString(1, _T("8"));
1324 box->SetItemData(1, 8);
1325 }
1326
1327 CString text;
1328 text.Format(_T("%d"), mpProject->mHeader.palette_mode_aa_text_colors);
1329 box->SelectString(0, text);
1330 }
1331
1332 ///////////////////////////////////////////////////////////////////////////////
EnableDisableFlipRotation(int cpu_type)1333 void ProjectConfigWin::EnableDisableFlipRotation(int cpu_type)
1334 {
1335 CComboBox* box = (CComboBox*)GetDlgItem(IDC_ROTATION_ANGLE_COMBO);
1336
1337 if (box)
1338 {
1339 if (IsCpuWithDave2D(cpu_type))
1340 {
1341 if (box->GetCount() < 4)
1342 {
1343 box->InsertString(3, _T("FLIP"));
1344 box->SetItemData(3, GX_SCREEN_ROTATION_FLIP);
1345 }
1346 }
1347 else
1348 {
1349 if (box->GetCount() > 3)
1350 {
1351 box->DeleteString(3);
1352 box->SetCurSel(0);
1353 }
1354 }
1355 }
1356 }
1357
1358 ///////////////////////////////////////////////////////////////////////////////
InitRotationAnglesCombobox(int display)1359 void ProjectConfigWin::InitRotationAnglesCombobox(int display)
1360 {
1361 int box_index = mCpuCombo.GetCurSel();
1362 int cpu_type = mCpuCombo.GetItemData(box_index);
1363
1364 CComboBox* box = (CComboBox*)GetDlgItem(IDC_ROTATION_ANGLE_COMBO);
1365
1366 if (box)
1367 {
1368 if (!box->GetCount())
1369 {
1370 box->InsertString(0, ProjectConfigDlg::FindScreenRotationName(GX_SCREEN_ROTATION_NONE));
1371 box->SetItemData(0, 0);
1372
1373 box->InsertString(1, ProjectConfigDlg::FindScreenRotationName(GX_SCREEN_ROTATION_CW));
1374 box->SetItemData(1, GX_SCREEN_ROTATION_CW);
1375
1376 box->InsertString(2, ProjectConfigDlg::FindScreenRotationName(GX_SCREEN_ROTATION_CCW));
1377 box->SetItemData(2, GX_SCREEN_ROTATION_CCW);
1378 }
1379
1380 if (IsCpuWithDave2D(cpu_type))
1381 {
1382 if (box->GetCount() < 4)
1383 {
1384 box->InsertString(3, ProjectConfigDlg::FindScreenRotationName(GX_SCREEN_ROTATION_FLIP));
1385 box->SetItemData(3, GX_SCREEN_ROTATION_FLIP);
1386 }
1387 }
1388 else
1389 {
1390 if (box->GetCount() > 3)
1391 {
1392 box->DeleteString(3);
1393 if (mpProject->mDisplays[display].rotation_angle == GX_SCREEN_ROTATION_FLIP)
1394 {
1395 mpProject->mDisplays[display].rotation_angle = GX_SCREEN_ROTATION_NONE;
1396 }
1397 }
1398 }
1399
1400 switch (mpProject->mDisplays[display].rotation_angle)
1401 {
1402 case GX_SCREEN_ROTATION_CW:
1403 box->SetCurSel(1);
1404 break;
1405
1406 case GX_SCREEN_ROTATION_CCW:
1407 box->SetCurSel(2);
1408 break;
1409
1410 case GX_SCREEN_ROTATION_FLIP:
1411 box->SetCurSel(3);
1412 break;
1413
1414 default:
1415 box->SetCurSel(0);
1416 break;
1417 }
1418 }
1419 }
1420
1421 ///////////////////////////////////////////////////////////////////////////////
Save()1422 BOOL ProjectConfigWin::Save()
1423 {
1424 CWnd* child = GetFocus();
1425 if (child)
1426 {
1427 // if an edit field has input focus, move focus so that
1428 // value validation runs
1429 int id = child->GetDlgCtrlID();
1430 switch (id)
1431 {
1432 case IDC_NUM_DISPLAYS:
1433 case IDC_SELECTED_DISPLAY:
1434 case IDC_MAJOR_VERSION:
1435 case IDC_MINOR_VERSION:
1436 case IDC_SERVICE_PACK:
1437 SetFocus();
1438 return FALSE;
1439
1440 default:
1441 break;
1442 }
1443 }
1444
1445 CEdit* edit = (CEdit *)GetDlgItem(IDC_SCREEN_NAME);
1446 INT display_index = GetDlgItemInt(IDC_SELECTED_DISPLAY, NULL, GX_TRUE) - 1;
1447
1448 if (TestInputName(edit, "Name", mpProject->mDisplays[display_index].name, mpParent))
1449 {
1450 CDialog::OnOK();
1451 return TRUE;
1452 }
1453
1454 return FALSE;
1455 }
1456
1457 ///////////////////////////////////////////////////////////////////////////////
Cancel()1458 BOOL ProjectConfigWin::Cancel()
1459 {
1460 mpProject->mHeader = mOldHeader;
1461 CDialog::OnCancel();
1462 return TRUE;
1463 }
1464
1465 ///////////////////////////////////////////////////////////////////////////////
1466
PreTranslateMessage(MSG * pMsg)1467 BOOL ProjectConfigWin::PreTranslateMessage(MSG *pMsg)
1468 {
1469 // TODO: Add your specialized code here and/or call the base class
1470
1471 CWnd *focus_owner = GetFocus();
1472
1473 if (focus_owner)
1474 {
1475 int ctrl_id = focus_owner->GetDlgCtrlID();
1476
1477 switch (ctrl_id)
1478 {
1479 case IDC_NUM_DISPLAYS:
1480 case IDC_SELECTED_DISPLAY:
1481 case IDC_MAJOR_VERSION:
1482 case IDC_MINOR_VERSION:
1483 case IDC_SERVICE_PACK:
1484 case IDC_X_RESOLUTION:
1485 case IDC_Y_RESOLUTION:
1486 if (pMsg->message == WM_CHAR)
1487 {
1488 if (isprint(pMsg->wParam))
1489 {
1490 if (pMsg->wParam < '0' || pMsg->wParam > '9')
1491 {
1492 ErrorMsg("Unacceptable Character. You can only type a number here.", mpParent);
1493 return TRUE;
1494 }
1495 }
1496 }
1497 break;
1498 }
1499 }
1500
1501 return CDialog::PreTranslateMessage(pMsg);
1502 }
1503
1504 ///////////////////////////////////////////////////////////////////////////////
OnTestMessage(WPARAM wParam,LPARAM lParam)1505 LRESULT ProjectConfigWin::OnTestMessage(WPARAM wParam, LPARAM lParam)
1506 {
1507 CWnd *pWnd;
1508 INT ctrl_id;
1509 studiox_project *project;
1510 NMUPDOWN NMUpDown;
1511 NMHDR hdr;
1512
1513 switch (wParam)
1514 {
1515 case TEST_CONFIGURE_DISPLAY_NUM:
1516 hdr.hwndFrom = m_spin_num_screens.m_hWnd;
1517 hdr.idFrom = IDC_SPIN_NUM_SCREENS;
1518 hdr.code = UDN_DELTAPOS;
1519
1520 NMUpDown.hdr = hdr;
1521 NMUpDown.iPos = m_spin_num_screens.GetPos();
1522 NMUpDown.iDelta = lParam - NMUpDown.iPos;
1523
1524 m_spin_num_screens.SetPos(lParam);
1525 SetDlgItemInt(IDC_LANGUAGE_INDEX, lParam);
1526 SendMessage(WM_NOTIFY, IDC_SPIN_NUM_SCREENS, (LPARAM)&NMUpDown);
1527 break;
1528
1529 case TEST_SELECT_DISPLAY_INDEX:
1530 hdr.hwndFrom = m_spin_current_screen.m_hWnd;
1531 hdr.idFrom = IDC_SPIN_NUM_SCREENS;
1532 hdr.code = UDN_DELTAPOS;
1533
1534 NMUpDown.hdr = hdr;
1535 NMUpDown.iPos = m_spin_current_screen.GetPos();
1536 NMUpDown.iDelta = lParam - NMUpDown.iPos;
1537
1538 m_spin_current_screen.SetPos(lParam);
1539 SetDlgItemInt(IDC_LANGUAGE_INDEX, lParam);
1540 SendMessage(WM_NOTIFY, IDC_SPIN_NUM_SCREENS, (LPARAM)&NMUpDown);
1541 break;
1542
1543 case TEST_CONFIGURE_SOURCE_PATH:
1544 SetDlgItemText(IDC_SOURCE_PATH, GetTestingParam(0));
1545 break;
1546
1547 case TEST_CONFIGURE_HEADER_PATH:
1548 SetDlgItemText(IDC_HEADER_PATH, GetTestingParam(0));
1549 break;
1550
1551 case TEST_CONFIGURE_RESOURCE_PATH:
1552 SetDlgItemText(IDC_RESOURCE_PATH, GetTestingParam(0));
1553 break;
1554
1555 case TEST_CONFIGURE_X_RES:
1556 SetDlgItemText(IDC_X_RESOLUTION, GetTestingParam(0));
1557 break;
1558
1559 case TEST_CONFIGURE_Y_RES:
1560 SetDlgItemText(IDC_Y_RESOLUTION, GetTestingParam(0));
1561 break;
1562
1563 case TEST_CONFIGURE_DISPLAY_NAME:
1564 SetDlgItemText(IDC_SCREEN_NAME, GetTestingParam(0));
1565 break;
1566
1567 case TEST_CONFIGURE_DISPLAY_COLOR_FORMAT:
1568 switch (lParam)
1569 {
1570 case GX_COLOR_FORMAT_MONOCHROME:
1571 ctrl_id = IDC_RADIO_1BPP;
1572 break;
1573
1574 case GX_COLOR_FORMAT_4BIT_GRAY:
1575 ctrl_id = IDC_RADIO_4BPP;
1576 break;
1577
1578 case GX_COLOR_FORMAT_8BIT_PALETTE:
1579 ctrl_id = IDC_RADIO_8BPP;
1580 break;
1581
1582 case GX_COLOR_FORMAT_565RGB:
1583 case GX_COLOR_FORMAT_4444ARGB:
1584 ctrl_id = IDC_RADIO_16BPP;
1585 break;
1586
1587 case GX_COLOR_FORMAT_24XRGB:
1588 ctrl_id = IDC_RADIO_24BPP;
1589 break;
1590
1591 case GX_COLOR_FORMAT_32ARGB:
1592 ctrl_id = IDC_RADIO_32BPP;
1593 break;
1594 }
1595 CheckRadioButton(IDC_RADIO_1BPP, IDC_RADIO_32BPP, ctrl_id);
1596
1597 if (lParam == GX_COLOR_FORMAT_4444ARGB)
1598 {
1599 pWnd = (CButton *)GetDlgItem(IDC_CHECK_4444FORMAT);
1600 ((CButton *)pWnd)->SetCheck(TRUE);
1601 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_ALLOCATE_CANVAS, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
1602 }
1603 break;
1604
1605 case TEST_CONFIGURE_DISPLAY_COLOR_DEPTH:
1606 {
1607 ULONG id_control = 0;
1608 switch (lParam)
1609 {
1610 case 1:
1611 id_control = IDC_RADIO_1BPP;
1612 break;
1613
1614 case 2:
1615 id_control = IDC_RADIO_2BPP;
1616 break;
1617
1618 case 4:
1619 id_control = IDC_RADIO_4BPP;
1620 break;
1621
1622 case 8:
1623 id_control = IDC_RADIO_8BPP;
1624 break;
1625
1626 case 16:
1627 id_control = IDC_RADIO_16BPP;
1628 break;
1629
1630 case 24:
1631 id_control = IDC_RADIO_24BPP;
1632 break;
1633
1634 case 32:
1635 id_control = IDC_RADIO_32BPP;
1636 break;
1637 }
1638 if (id_control)
1639 {
1640 CheckRadioButton(IDC_RADIO_1BPP, IDC_RADIO_32BPP, id_control);
1641 SendMessage(WM_COMMAND, MAKEWPARAM(id_control, BN_CLICKED), 0);
1642 }
1643
1644 int id = GetCheckedRadioButton(IDC_RADIO_1BPP, IDC_RADIO_32BPP);
1645 if (id != id_control)
1646 {
1647 return GX_FAILURE;
1648 }
1649 }
1650 break;
1651
1652 case TEST_CONFIGURE_DISPLAY_RGB_BITS:
1653 {
1654 ULONG id_control = 0;
1655 switch (lParam)
1656 {
1657 case 4444:
1658 id_control = IDC_CHECK_4444FORMAT;
1659 break;
1660
1661 case 1555:
1662 id_control = IDC_CHECK_555FORMAT;
1663 break;
1664
1665 case 332:
1666 id_control = IDC_CHECK_332FORMAT;
1667 break;
1668
1669 default:
1670 break;
1671 }
1672 if (id_control)
1673 {
1674 pWnd = (CButton *)GetDlgItem(id_control);
1675 if (((CButton *)pWnd)->IsWindowEnabled())
1676 {
1677 if (((CButton *)pWnd)->GetCheck() == BST_CHECKED)
1678 {
1679 ((CButton *)pWnd)->SetCheck(BST_UNCHECKED);
1680 }
1681 else
1682 {
1683 ((CButton *)pWnd)->SetCheck(BST_CHECKED);
1684 }
1685 SendMessage(WM_COMMAND, MAKEWPARAM(id_control, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
1686 }
1687 else
1688 {
1689 return GX_FAILURE;
1690 }
1691 }
1692 }
1693 break;
1694
1695 case TEST_CONFIGURE_MINOR_VERSION:
1696 mSpinMinorVersion.SetPos(lParam);
1697 SetDlgItemInt(IDC_MINOR_VERSION, lParam);
1698 break;
1699
1700 case TEST_CONFIGURE_SERVICE_PACK:
1701 mSpinServicePack.SetPos(lParam);
1702 SetDlgItemInt(IDC_SERVICE_PACK, lParam);
1703 break;
1704
1705 case TEST_CONFIGURE_CANVAS_ALLOCATE:
1706 pWnd = (CButton *)GetDlgItem(IDC_ALLOCATE_CANVAS);
1707 ((CButton *)pWnd)->SetCheck(lParam);
1708 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_ALLOCATE_CANVAS, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
1709 break;
1710
1711 case TEST_CONFIGURE_CPU_TYPE:
1712 {
1713 pWnd = GetDlgItem(IDC_CPU_COMBO);
1714 STRING_VAL_PAIR*pEntry = cpu_list;
1715
1716 while (!pEntry->name.IsEmpty())
1717 {
1718 if (pEntry->val == lParam)
1719 {
1720 ((CComboBox *)pWnd)->SelectString(0, pEntry->name);
1721 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_CPU_COMBO, CBN_SELCHANGE), (LPARAM)((CComboBox *)pWnd)->m_hWnd);
1722 }
1723 pEntry++;
1724 }
1725 break;
1726 }
1727
1728 case TEST_CONFIGURE_BIG_ENDIAN:
1729 pWnd = (CButton *)GetDlgItem(IDC_BIG_ENDIAN);
1730 ((CButton *)pWnd)->SetCheck(lParam);
1731 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_BIG_ENDIAN, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
1732 break;
1733
1734 case TEST_IS_DEFAULT_MAP_FORMAT:
1735 project = GetOpenProject();
1736 return project->mDisplays[m_current_display].default_map_format;
1737
1738 case TEST_GET_CPU_TYPE:
1739 project = GetOpenProject();
1740 return project->mHeader.target_cpu;
1741
1742 case TEST_GET_DISPLAY_COLOR_FORMAT:
1743 project = GetOpenProject();
1744 return project->mDisplays[m_current_display].colorformat;
1745
1746 case TEST_GET_DISPLAY_COLOR_DEPTH:
1747 project = GetOpenProject();
1748 return project->mDisplays[m_current_display].bits_per_pix;
1749
1750 case TEST_IS_1555_FORMAT:
1751 project = GetOpenProject();
1752 return project->mDisplays[m_current_display].format_555;
1753 break;
1754
1755 case TEST_IS_4444_FORAMT:
1756 project = GetOpenProject();
1757 return project->mDisplays[m_current_display].format_4444;
1758 break;
1759
1760 case TEST_IS_332_FORMAT:
1761 project = GetOpenProject();
1762 return project->mDisplays[m_current_display].format_332;
1763 break;
1764
1765 case TEST_IS_NEW_PROJECT:
1766 project = GetOpenProject();
1767 return project->mHeader.b_new_project;
1768
1769 case TEST_OPEN_ADVANCED_SETTINGS:
1770 OnAdvancedSettings();
1771 break;
1772
1773 case TEST_SET_AA_TEXT_COLORS:
1774 pWnd = GetDlgItem(IDC_AA_TEXT_COLORS_COMBO);
1775 ((CComboBox *)pWnd)->SelectString(0, GetTestingParam(0));
1776 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_AA_TEXT_COLORS_COMBO, CBN_SELCHANGE), (LPARAM)pWnd->m_hWnd);
1777 break;
1778 }
1779
1780 return 0;
1781 }
1782
1783 // ProjectConfigDlg dialog
1784
IMPLEMENT_DYNAMIC(ProjectConfigDlg,express_dialog)1785 IMPLEMENT_DYNAMIC(ProjectConfigDlg, express_dialog)
1786
1787 BEGIN_MESSAGE_MAP(ProjectConfigDlg, express_dialog)
1788 ON_WM_SIZE()
1789 ON_WM_GETMINMAXINFO()
1790 ON_MESSAGE(STUDIO_TEST, OnTestMessage)
1791 END_MESSAGE_MAP()
1792
1793 ///////////////////////////////////////////////////////////////////////////////
1794 ProjectConfigDlg::ProjectConfigDlg(CWnd* pParent, int current_display)
1795 : express_dialog(ProjectConfigDlg::IDD, pParent)
1796 {
1797 IconId = IDB_CONFIGURE_PROJECTS;
1798 SetTitleText("Configure Project");
1799
1800 if (current_display >= 0)
1801 {
1802 mCurrentDisplay = current_display;
1803 }
1804 else
1805 {
1806 mCurrentDisplay = 0;
1807 }
1808
1809 mpProjectConfigWin = NULL;
1810 }
1811
1812 ///////////////////////////////////////////////////////////////////////////////
~ProjectConfigDlg()1813 ProjectConfigDlg::~ProjectConfigDlg()
1814 {
1815 if (mpProjectConfigWin)
1816 {
1817 delete mpProjectConfigWin;
1818 }
1819 }
1820
1821
1822 /////////////////////////////////////////////////////////////////////////////
GetDefaultColorTable(int color_format)1823 COLOR_RECORD* ProjectConfigDlg::GetDefaultColorTable(int color_format)
1824 {
1825 COLOR_RECORD* default_record = GX_NULL;
1826
1827
1828 if (color_format <= GX_COLOR_FORMAT_4BIT_VGA)
1829 {
1830 if (color_format == GX_COLOR_FORMAT_MONOCHROME)
1831 {
1832 default_record = DEFAULT_COLOR_TABLE_MONOCHROME;
1833 }
1834 else
1835 {
1836 default_record = DEFAULT_COLOR_TABLE_GRAYSCALE;
1837 }
1838 }
1839 else
1840 {
1841 default_record = DEFAULT_COLOR_TABLE;
1842 }
1843
1844 return default_record;
1845 }
1846
1847 /////////////////////////////////////////////////////////////////////////////
ColorTableConvert(res_info * info,GX_COLOR * old_pal,int old_palsize,int old_color_format,GX_COLOR * new_pal,int new_palsize,int new_color_format)1848 void ProjectConfigDlg::ColorTableConvert(res_info* info, GX_COLOR* old_pal, int old_palsize, int old_color_format, GX_COLOR* new_pal, int new_palsize, int new_color_format)
1849 {
1850 // find the color resource with a system id, set them to our default
1851 // system color rgb values
1852 studiox_project* project = GetOpenProject();
1853
1854 if (!project)
1855 {
1856 return;
1857 }
1858
1859 INT res_id;
1860 INT display_index = project->GetDisplayIndex(info);
1861 COLOR_RECORD* new_default_record = GetDefaultColorTable(new_color_format);
1862 COLOR_RECORD* old_default_record = GetDefaultColorTable(old_color_format);
1863 COLOR_RECORD* new_record;
1864 COLOR_RECORD* old_record;
1865
1866 if (!new_default_record || !old_default_record)
1867 {
1868 return;
1869 }
1870
1871 GX_COLOR rgb_color = 0;
1872 GX_COLOR colorval = 0;
1873
1874 while (info)
1875 {
1876 if (info->type == RES_TYPE_COLOR)
1877 {
1878 res_id = project->GetResourceId(display_index, info);
1879
1880 if (res_id < GX_MAX_DEFAULT_COLORS)
1881 {
1882 new_record = new_default_record;
1883 old_record = old_default_record;
1884
1885 while (new_record->name)
1886 {
1887 if (res_id == new_record->color_id)
1888 {
1889 rgb_color = new_record->rgb_val;
1890
1891 // Get system rgb color.
1892 if (new_default_record == old_default_record)
1893 {
1894 colorval = GetColorVal(old_record->rgb_val, old_pal, old_palsize, old_color_format);
1895
1896 if (colorval != info->colorval)
1897 {
1898 // If system color is modified.
1899 rgb_color = GetRGBColor(info->colorval, old_pal, old_palsize, old_color_format);
1900 }
1901 }
1902 break;
1903 }
1904
1905 new_record++;
1906 old_record++;
1907 }
1908
1909 }
1910 else
1911 {
1912 // Get custom rgb color.
1913 rgb_color = GetRGBColor(info->colorval, old_pal, old_palsize, old_color_format);
1914 }
1915
1916 // Convert rgb color to colorval.
1917 info->colorval = GetColorVal(rgb_color, new_pal, new_palsize, new_color_format);
1918 }
1919 if (info->child)
1920 {
1921 ColorTableConvert(info->child, old_pal, old_palsize, old_color_format, new_pal, new_palsize, new_color_format);
1922 }
1923 info = info->next;
1924 }
1925 }
1926
1927 ///////////////////////////////////////////////////////////////////////////////
CreateDefault1BppPalette(palette_info & info)1928 void ProjectConfigDlg::CreateDefault1BppPalette(palette_info& info)
1929 {
1930 INT pixel = 0;
1931
1932 info.palette = new GX_COLOR[2];
1933 info.palette[0] = 0xff000000;
1934 info.palette[1] = 0xffffffff;
1935
1936 info.total_size = 2;
1937 info.used_size = 2;
1938 }
1939
1940
1941 ///////////////////////////////////////////////////////////////////////////////
CreateDefault4BppPalette(palette_info & info)1942 void ProjectConfigDlg::CreateDefault4BppPalette(palette_info& info)
1943 {
1944 INT pixel = 0;
1945 GX_COLOR val;
1946
1947 info.palette = new GX_COLOR[16];
1948 GX_COLOR* put = info.palette;
1949 memset(put, 0, 16 * sizeof(GX_COLOR));
1950
1951 for (pixel = 0; pixel <= 0xff; pixel += 0x11)
1952 {
1953 val = ((0xff000000) | (pixel << 16) | (pixel << 8) | pixel);
1954 *put++ = val;
1955 }
1956
1957 info.total_size = 16;
1958 info.used_size = 16;
1959 }
1960
1961 ///////////////////////////////////////////////////////////////////////////////
CreateDefault8BppPalette(palette_info & info)1962 void ProjectConfigDlg::CreateDefault8BppPalette(palette_info& info)
1963 {
1964 ULONG gray;
1965 GX_COLOR val;
1966 int pre_def_size = 0;
1967 COLOR_RECORD* def_record = DEFAULT_COLOR_TABLE;
1968
1969 info.palette = new GX_COLOR[256];
1970 GX_COLOR* put = info.palette;
1971 memset(put, 0, 256 * sizeof(GX_COLOR));
1972
1973 // 16 shades of gray:
1974 for (gray = 0; gray <= 0xff; gray += 0x11)
1975 {
1976 val = ((0xff000000) | (gray << 16) | (gray << 8) | gray);
1977 *put++ = val;
1978 pre_def_size++;
1979 }
1980
1981 while (def_record->name)
1982 {
1983 *put++ = def_record->rgb_val;
1984 pre_def_size++;
1985 def_record++;
1986 }
1987
1988 info.total_size = 256;
1989 info.used_size = pre_def_size;
1990 }
1991
1992
1993 ///////////////////////////////////////////////////////////////////////////////
CreateDefault332RGBPalette(palette_info & info)1994 void ProjectConfigDlg::CreateDefault332RGBPalette(palette_info& info)
1995 {
1996 INT r = 0;
1997 INT g = 0;
1998 INT b = 0;
1999 INT red;
2000 INT green;
2001 INT blue;
2002
2003 info.palette = new GX_COLOR[256];
2004 GX_COLOR* put = info.palette;
2005 memset(put, 0, 256 * sizeof(GX_COLOR));
2006
2007 for (r = 0; r < 8; r++)
2008 {
2009 red = r << 21;
2010 if (red & 0x200000) { red |= 0x1f0000; }
2011 for (g = 0; g < 8; g++)
2012 {
2013 green = g << 13;
2014 if (green & 0x2000) { green |= 0x1f00; }
2015 for (b = 0; b < 4; b++)
2016 {
2017 blue = b << 6;
2018 if (blue & 0x40) { blue |= 0x3f; }
2019 *put++ = red | green | blue | 0xff000000;
2020 }
2021 }
2022 }
2023
2024 info.total_size = 256;
2025 info.used_size = 256;
2026 }
2027
2028 ///////////////////////////////////////////////////////////////////////////////
CreateDefaultPalette(studiox_project * project,int display,int theme)2029 void ProjectConfigDlg::CreateDefaultPalette(studiox_project* project,
2030 int display, int theme)
2031 {
2032 palette_info info;
2033
2034 if (project->mDisplays[display].themes[theme].palette)
2035 {
2036 delete[] project->mDisplays[display].themes[theme].palette;
2037 project->mDisplays[display].themes[theme].palette = NULL;
2038 project->mDisplays[display].themes[theme].palette_total_size = 0;
2039 project->mDisplays[display].themes[theme].palette_predefined = 0;
2040 }
2041
2042 switch (project->mDisplays[display].colorformat)
2043 {
2044 case GX_COLOR_FORMAT_565RGB:
2045 case GX_COLOR_FORMAT_4444ARGB:
2046 case GX_COLOR_FORMAT_4444BGRA:
2047 case GX_COLOR_FORMAT_565BGR:
2048 case GX_COLOR_FORMAT_24RGB:
2049 case GX_COLOR_FORMAT_24BGR:
2050 case GX_COLOR_FORMAT_24XRGB:
2051 case GX_COLOR_FORMAT_24BGRX:
2052 case GX_COLOR_FORMAT_32ARGB:
2053 case GX_COLOR_FORMAT_32RGBA:
2054 case GX_COLOR_FORMAT_32ABGR:
2055 case GX_COLOR_FORMAT_32BGRA:
2056 if (project->mDisplays[display].themes[theme].palette)
2057 {
2058 delete[] project->mDisplays[display].themes[theme].palette;
2059 project->mDisplays[display].themes[theme].palette = GX_NULL;
2060 }
2061
2062 project->mDisplays[display].themes[theme].palette = new GX_COLOR[255];
2063 memset(project->mDisplays[display].themes[theme].palette, 0, 255 * sizeof(GX_COLOR));
2064 project->mDisplays[display].themes[theme].palette_total_size = 255;
2065 project->mDisplays[display].themes[theme].palette_predefined = 0;
2066 break;
2067
2068 case GX_COLOR_FORMAT_8BIT_PALETTE:
2069 CreateDefault8BppPalette(info);
2070 project->mDisplays[display].themes[theme].palette = info.palette;
2071 project->mDisplays[display].themes[theme].palette_total_size = info.total_size;
2072 project->mDisplays[display].themes[theme].palette_predefined = info.used_size;
2073 break;
2074
2075 case GX_COLOR_FORMAT_MONOCHROME:
2076 case GX_COLOR_FORMAT_4BIT_GRAY:
2077 default:
2078 break;
2079 }
2080 }
2081
2082 /////////////////////////////////////////////////////////////////////////////////
GetRGBColor(GX_COLOR colorval,GX_COLOR * old_pal,int old_palsize,int old_color_format)2083 GX_COLOR ProjectConfigDlg::GetRGBColor(GX_COLOR colorval, GX_COLOR* old_pal, int old_palsize, int old_color_format)
2084 {
2085 GX_COLOR rgb_color = 0xff000000;
2086
2087 switch (old_color_format)
2088 {
2089 case GX_COLOR_FORMAT_MONOCHROME_INVERTED:
2090 case GX_COLOR_FORMAT_2BIT_GRAY:
2091 case GX_COLOR_FORMAT_2BIT_GRAY_INVERTED:
2092 case GX_COLOR_FORMAT_4BIT_VGA:
2093 case GX_COLOR_FORMAT_8BIT_GRAY:
2094 case GX_COLOR_FORMAT_8BIT_GRAY_INVERTED:
2095 case GX_COLOR_FORMAT_8BIT_PALETTE:
2096 if (old_pal && ((INT)colorval < old_palsize))
2097 {
2098 rgb_color |= old_pal[colorval];
2099 }
2100 break;
2101
2102 case GX_COLOR_FORMAT_MONOCHROME:
2103 case GX_COLOR_FORMAT_4BIT_GRAY:
2104 case GX_COLOR_FORMAT_8BIT_PACKED_PIXEL:
2105 case GX_COLOR_FORMAT_5551BGRX:
2106 case GX_COLOR_FORMAT_1555XRGB:
2107 case GX_COLOR_FORMAT_565RGB:
2108 case GX_COLOR_FORMAT_565BGR:
2109 case GX_COLOR_FORMAT_24RGB:
2110 case GX_COLOR_FORMAT_24BGR:
2111 case GX_COLOR_FORMAT_24XRGB:
2112 case GX_COLOR_FORMAT_24BGRX:
2113 rgb_color |= colorval;
2114 break;
2115
2116 case GX_COLOR_FORMAT_4444ARGB:
2117 case GX_COLOR_FORMAT_4444BGRA:
2118 case GX_COLOR_FORMAT_32ARGB:
2119 case GX_COLOR_FORMAT_32RGBA:
2120 case GX_COLOR_FORMAT_32ABGR:
2121 case GX_COLOR_FORMAT_32BGRA:
2122 rgb_color = colorval;
2123 break;
2124 }
2125
2126 return rgb_color;
2127 }
2128
2129 ///////////////////////////////////////////////////////////////////////////////////
GetColorVal(GX_COLOR rgb_color,GX_COLOR * new_pal,int new_palsize,int new_color_format)2130 GX_COLOR ProjectConfigDlg::GetColorVal(GX_COLOR rgb_color, GX_COLOR* new_pal, int new_palsize, int new_color_format)
2131 {
2132 GX_COLOR colorval = 0;
2133
2134 switch (new_color_format)
2135 {
2136 case GX_COLOR_FORMAT_MONOCHROME_INVERTED:
2137 case GX_COLOR_FORMAT_2BIT_GRAY:
2138 case GX_COLOR_FORMAT_2BIT_GRAY_INVERTED:
2139 case GX_COLOR_FORMAT_4BIT_VGA:
2140 case GX_COLOR_FORMAT_8BIT_GRAY:
2141 case GX_COLOR_FORMAT_8BIT_GRAY_INVERTED:
2142 case GX_COLOR_FORMAT_8BIT_PALETTE:
2143 if (new_pal)
2144 {
2145 colorval = image_reader::GetNearestPaletteColor(rgb_color, new_pal, new_palsize);
2146 }
2147 break;
2148
2149 case GX_COLOR_FORMAT_MONOCHROME:
2150 image_reader::ConvertRGBToGray(rgb_color, (GX_UBYTE*)&colorval);
2151 if ((colorval & 0xff) < 128)
2152 {
2153 colorval = 0x00;
2154 }
2155 else
2156 {
2157 colorval = 0xffffff;
2158 }
2159 break;
2160
2161 case GX_COLOR_FORMAT_4BIT_GRAY:
2162 image_reader::ConvertRGBToGray(rgb_color, (GX_UBYTE*)&colorval);
2163 colorval |= colorval << 4;
2164 colorval = (colorval << 16) | (colorval << 8) | colorval;
2165 break;
2166
2167 case GX_COLOR_FORMAT_8BIT_PACKED_PIXEL:
2168 colorval = rgb_color;
2169
2170 if (colorval & 0x200000) { colorval |= 0x1f0000; } // extend red value, extend last bit of red of 332 mode to the rest red-bits.
2171 if (colorval & 0x2000) { colorval |= 0x1f00; } // set green value;
2172 if (colorval & 0x40) { colorval |= 0x3f; } // set blue value;
2173 break;
2174
2175 case GX_COLOR_FORMAT_565RGB:
2176 case GX_COLOR_FORMAT_4444ARGB:
2177 case GX_COLOR_FORMAT_4444BGRA:
2178 case GX_COLOR_FORMAT_565BGR:
2179 case GX_COLOR_FORMAT_24RGB:
2180 case GX_COLOR_FORMAT_24BGR:
2181 case GX_COLOR_FORMAT_24XRGB:
2182 case GX_COLOR_FORMAT_24BGRX:
2183 case GX_COLOR_FORMAT_32ARGB:
2184 case GX_COLOR_FORMAT_32RGBA:
2185 case GX_COLOR_FORMAT_32ABGR:
2186 case GX_COLOR_FORMAT_32BGRA:
2187 case GX_COLOR_FORMAT_5551BGRX:
2188 case GX_COLOR_FORMAT_1555XRGB:
2189 colorval = rgb_color;
2190 break;
2191 }
2192 return colorval;
2193 }
2194
2195 ///////////////////////////////////////////////////////////////////////////////
CheckFontFormat(res_info * start,int m_display)2196 void ProjectConfigDlg::CheckFontFormat(res_info* start, int m_display)
2197 {
2198 studiox_project* project = GetOpenProject();
2199
2200 int display_bits_per_pix = project->mDisplays[m_display].bits_per_pix;
2201
2202 while (start)
2203 {
2204 if (start->child)
2205 {
2206 CheckFontFormat(start->child, m_display);
2207 }
2208
2209 if (start->type == RES_TYPE_FONT)
2210 {
2211 if ((!IsRenesasDave2D(project)) ||
2212 (project->mDisplays[m_display].colorformat <= GX_COLOR_FORMAT_8BIT_PALETTE))
2213 {
2214 if (start->compress)
2215 {
2216 start->compress = FALSE;
2217 }
2218 }
2219
2220 switch (start->font_bits)
2221 {
2222 case 8:
2223 if (display_bits_per_pix < 16)
2224 {
2225 start->font_bits = 1;
2226 }
2227 break;
2228
2229 case 4:
2230 if (display_bits_per_pix < 8)
2231 {
2232 start->font_bits = 1;
2233 }
2234 break;
2235
2236 default:
2237 break;
2238 }
2239 }
2240 start = start->next;
2241 }
2242 }
2243
2244 ///////////////////////////////////////////////////////////////////////////////
DisableTextScrollWheelRoundStyle(widget_info * start)2245 void ProjectConfigDlg::DisableTextScrollWheelRoundStyle(widget_info* start)
2246 {
2247 widget_info* child;
2248
2249 while (start)
2250 {
2251 child = start->GetChildWidgetInfo();
2252
2253 if (child)
2254 {
2255 DisableTextScrollWheelRoundStyle(child);
2256 }
2257
2258 if (start->basetype == GX_TYPE_STRING_SCROLL_WHEEL ||
2259 start->basetype == GX_TYPE_NUMERIC_SCROLL_WHEEL)
2260 {
2261 start->style &= (~GX_STYLE_TEXT_SCROLL_WHEEL_ROUND);
2262 }
2263
2264 start = start->GetNextWidgetInfo();
2265 }
2266 }
2267
2268 ///////////////////////////////////////////////////////////////////////////////
GetGuixVersion()2269 int ProjectConfigDlg::GetGuixVersion()
2270 {
2271 return mpProjectConfigWin->GetGuixVersion();
2272 }
2273
2274 ///////////////////////////////////////////////////////////////////////////////
ResetPixelmapFormat(res_info * start,int m_display)2275 void ProjectConfigDlg::ResetPixelmapFormat(res_info* start, int m_display)
2276 {
2277 studiox_project* project = GetOpenProject();
2278 if (project)
2279 {
2280 while (start)
2281 {
2282 if (start->child)
2283 {
2284 ResetPixelmapFormat(start->child, m_display);
2285 }
2286
2287 if (start->type == RES_TYPE_PIXELMAP)
2288 {
2289 start->output_color_format = 0;
2290 if (project->mDisplays[m_display].colorformat == GX_COLOR_FORMAT_8BIT_PALETTE)
2291 {
2292 start->palette_type = PALETTE_TYPE_SHARED;
2293 }
2294 else
2295 {
2296 start->palette_type = PALETTE_TYPE_NONE;
2297 }
2298 }
2299 start = start->next;
2300 }
2301 project->mDisplays[m_display].default_map_format = TRUE;
2302 }
2303 }
2304
2305 ///////////////////////////////////////////////////////////////////////////////
FindTargetCPUName(int val)2306 CString ProjectConfigDlg::FindTargetCPUName(int val)
2307 {
2308 return FindPairString(cpu_list, val);
2309 }
2310
FindTargetCPUVal(CString name)2311 int ProjectConfigDlg::FindTargetCPUVal(CString name)
2312 {
2313 return FindPairVal(cpu_list, name);
2314 }
2315
2316 ///////////////////////////////////////////////////////////////////////////////
FindTargetCompilerName(int val)2317 CString ProjectConfigDlg::FindTargetCompilerName(int val)
2318 {
2319 return FindPairString(compiler_list, val);
2320 }
2321
2322 ///////////////////////////////////////////////////////////////////////////////
FindTargetCompilerVal(CString name)2323 int ProjectConfigDlg::FindTargetCompilerVal(CString name)
2324 {
2325 return FindPairVal(compiler_list, name);
2326 }
2327
2328 ///////////////////////////////////////////////////////////////////////////////
FindScreenRotationName(int val)2329 CString ProjectConfigDlg::FindScreenRotationName(int val)
2330 {
2331 return FindPairString(screen_rotation_list, val);
2332 }
2333
2334 ///////////////////////////////////////////////////////////////////////////////
FindScreenRotationVal(CString name)2335 int ProjectConfigDlg::FindScreenRotationVal(CString name)
2336 {
2337 return FindPairVal(screen_rotation_list, name);
2338 }
2339
2340 ///////////////////////////////////////////////////////////////////////////////
PositionChildren()2341 void ProjectConfigDlg::PositionChildren()
2342 {
2343 if (mpProjectConfigWin)
2344 {
2345 CRect size;
2346 GetClientRect(size);
2347
2348 size.top += m_title_bar_height;
2349 size.bottom -= m_status_bar_height;
2350
2351 mpProjectConfigWin->MoveWindow(&size);
2352 }
2353 }
2354
2355 ///////////////////////////////////////////////////////////////////////////////
OnInitDialog()2356 BOOL ProjectConfigDlg::OnInitDialog()
2357 {
2358 CDialog::OnInitDialog();
2359
2360 mpProjectConfigWin = new ProjectConfigWin(this, mCurrentDisplay);
2361
2362 AddCancelButton();
2363 AddSaveButton();
2364
2365 PositionChildren();
2366 return TRUE;
2367 }
2368
2369 ///////////////////////////////////////////////////////////////////////////////
OnOK()2370 void ProjectConfigDlg::OnOK()
2371 {
2372 if (mpProjectConfigWin->Save())
2373 {
2374
2375 express_dialog::OnOK();
2376 }
2377 }
2378
2379 ///////////////////////////////////////////////////////////////////////////////
OnCancel()2380 void ProjectConfigDlg::OnCancel()
2381 {
2382 if (mpProjectConfigWin->Cancel())
2383 {
2384
2385 express_dialog::OnCancel();
2386 }
2387 }
2388
2389 ///////////////////////////////////////////////////////////////////////////////
OnSize(UINT nType,int cx,int cy)2390 void ProjectConfigDlg::OnSize(UINT nType, int cx, int cy)
2391 {
2392 express_dialog::OnSize(nType, cx, cy);
2393
2394 PositionChildren();
2395
2396 Invalidate();
2397 }
2398
2399 ///////////////////////////////////////////////////////////////////////////////
OnGetMinMaxInfo(MINMAXINFO * lpMMI)2400 void ProjectConfigDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
2401 {
2402 express_dialog::OnGetMinMaxInfo(lpMMI);
2403 CRect client;
2404 GetClientRect(&client);
2405
2406 lpMMI->ptMinTrackSize.x = MIN_PROJECT_CONFIGURE_DLG_WIDTH;
2407 lpMMI->ptMinTrackSize.y = MIN_PROJECT_CONFIGURE_DLG_HEIGHT;
2408 }
2409
2410 ///////////////////////////////////////////////////////////////////////////////
OnTestMessage(WPARAM wParam,LPARAM lParam)2411 LRESULT ProjectConfigDlg::OnTestMessage(WPARAM wParam, LPARAM lParam)
2412 {
2413 switch (wParam)
2414 {
2415 case TEST_SAVE_PROJECT_CONFIGURE:
2416 OnOK();
2417 break;
2418
2419 case TEST_CANCEL_PROJECT_CONFIGURE:
2420 OnCancel();
2421 break;
2422
2423 default:
2424 return mpProjectConfigWin->OnTestMessage(wParam, lParam);
2425 }
2426
2427 return 0;
2428 }
2429