1 #include "studiox_includes.h"
2 #ifdef _DEBUG
3 #define new DEBUG_NEW
4 #endif
5
6
7 STRING_VAL_PAIR PredefinedWidgetIds[] =
8 {
9 { _T("ID_DROP_LIST_BUTTON"), ID_DROP_LIST_BUTTON},
10 };
11
12 CString SourceHeaderCommentStart(""
13 "/*******************************************************************************/\n"
14 "/* This file is auto-generated by Azure RTOS GUIX Studio. Do not edit this */\n"
15 "/* file by hand. Modifications to this file should only be made by running */\n"
16 "/* the Azure RTOS GUIX Studio application and re-generating the application */\n"
17 "/* specification file(s). For more information please refer to the Azure RTOS */\n"
18 "/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */\n"
19 "/* */\n"
20
21
22 );
23
24 extern CString SCREEN_STACK_POP_STRING;
25
26
27 ///////////////////////////////////////////////////////////////////////////////
screen_generator(studiox_project * project)28 screen_generator::screen_generator(studiox_project *project)
29 {
30 m_project = project;
31 m_display = 0;
32 }
33
34 ///////////////////////////////////////////////////////////////////////////////
~screen_generator()35 screen_generator::~screen_generator()
36 {
37 }
38
39 ///////////////////////////////////////////////////////////////////////////////
GenerateScreens(int display)40 BOOL screen_generator::GenerateScreens(int display)
41 {
42
43 /* Pickup command info. */
44 CCommandInfo *pCmdInfo = GetCmdInfo();
45
46 CString file_name;
47 GotoProjectDirectory();
48
49 file_name = m_project->mHeader.header_path;
50 if (!file_name.IsEmpty())
51 {
52 if (file_name.GetAt(file_name.GetLength() - 1) != '\\')
53 {
54 file_name += "\\";
55 }
56 }
57
58 if(pCmdInfo->GetSpecificationFileName().IsEmpty())
59 {
60 file_name += m_project->mHeader.project_name;
61 file_name += "_specifications.h";
62 }
63 else
64 {
65 file_name += pCmdInfo->GetSpecificationFileName() + _T(".h");
66 }
67
68 if (m_outfile)
69 {
70 delete m_outfile;
71 }
72
73 m_outfile = new CFile();
74
75 /* Generate head file. */
76 if (!m_outfile->Open(file_name, CFile::modeCreate | CFile::modeWrite))
77 {
78 ErrorMsg("Count not open output file. Please check header file path.");
79 delete m_outfile;
80 m_outfile = NULL;
81 return FALSE;
82 }
83
84 // make sure we don't have any empty screen flow:
85
86 m_project->CheckEmptyScreenFlow();
87
88 GenerateScreenHeader();
89 m_outfile->Close();
90 delete m_outfile;
91 m_outfile = NULL;
92
93 /* Generate c file. */
94 file_name = m_project->mHeader.source_path;
95 if (!file_name.IsEmpty())
96 {
97 if (file_name.GetAt(file_name.GetLength() - 1) != '\\')
98 {
99 file_name += "\\";
100 }
101 }
102
103 m_output_filepath = file_name;
104
105 if(pCmdInfo->GetSpecificationFileName().IsEmpty())
106 {
107 file_name = m_project->mHeader.project_name;
108 file_name += "_specifications";
109 }
110 else
111 {
112 file_name += pCmdInfo->GetSpecificationFileName();
113 }
114
115 if (!SetOutFile(file_name))
116 {
117 return FALSE;
118 }
119
120 GenerateScreenSource();
121
122 for (int index = 0; index < output_file_list.GetCount(); index++)
123 {
124 m_outfile = output_file_list.GetAt(index);
125 CString out(_T("#undef GUIX_STUDIO_GENERATED_FILE\n"));
126 FileWrite(out);
127
128 m_outfile->Close();
129 delete m_outfile;
130 }
131 m_outfile = NULL;
132 output_file_list.RemoveAll();
133
134 return TRUE;
135 }
136
WriteErrorDirectives()137 void screen_generator::WriteErrorDirectives()
138 {
139 CString out;
140
141 if (project_lib_version() < GX_VERSION_3BIT_GLYPH_DRAW_SUPPORT)
142 {
143 return;
144 }
145
146 for (int display = 0; display < m_project->mHeader.num_displays; display++)
147 {
148
149 if (IsDave2dFontFormat(m_project, display))
150 {
151 continue;
152 }
153
154 if (m_project->mDisplays[display].colorformat == GX_COLOR_FORMAT_8BIT_PALETTE)
155 {
156 out.Format(_T("\n#if GX_PALETTE_MODE_AA_TEXT_COLORS != %d\n"), m_project->mHeader.palette_mode_aa_text_colors);
157 out += _T("#error \"The symbol GX_PALETTE_MODE_AA_TEXT_COLORS does not match the setting in the Studio project.\"\n");
158 out += _T("#endif\n");
159
160 FileWrite(out);
161 return;
162 }
163 }
164 }
165
DeclareScreenFlowStructures()166 void screen_generator::DeclareScreenFlowStructures()
167 {
168 CString out;
169
170 out = "#define GX_ACTION_FLAG_DYNAMIC_TARGET 0x01\n";
171 out += "#define GX_ACTION_FLAG_DYNAMIC_PARENT 0x02\n";
172
173 if (project_lib_version() > 50402)
174 {
175 out += "#define GX_ACTION_FLAG_POP_TARGET 0x04\n";
176 out += "#define GX_ACTION_FLAG_POP_PARENT 0x08\n\n";
177 }
178
179 FileWrite(out);
180
181 out = "typedef struct GX_STUDIO_ACTION_STRUCT\n";
182 out += "{\n";
183 out += " GX_UBYTE opcode;\n";
184 out += " GX_UBYTE flags;\n";
185 out += " GX_CONST VOID *parent;\n";
186 out += " GX_CONST VOID *target;\n";
187 out += " GX_CONST GX_ANIMATION_INFO *animation;\n";
188 out += "} GX_STUDIO_ACTION;\n\n";
189 FileWrite(out);
190
191 out = "typedef struct GX_STUDIO_EVENT_ENTRY_STRUCT\n";
192 out += "{\n";
193 out += " ULONG event_type;\n";
194 out += " USHORT event_sender;\n";
195 out += " GX_CONST GX_STUDIO_ACTION *action_list;\n";
196 out += "} GX_STUDIO_EVENT_ENTRY;\n\n";
197
198 FileWrite(out);
199
200 out = "typedef struct GX_STUDIO_EVENT_PROCESS_STRUCT \n";
201 out += "{\n";
202 out += " GX_CONST GX_STUDIO_EVENT_ENTRY *event_table;\n";
203 out += " UINT (*chain_event_handler)(GX_WIDGET *, GX_EVENT *);\n";
204 out += "} GX_STUDIO_EVENT_PROCESS;\n";
205
206 FileWrite(out);
207 }
208
209 ///////////////////////////////////////////////////////////////////////////////
ProjectHasScreenFlow()210 BOOL screen_generator::ProjectHasScreenFlow()
211 {
212 for (int display = 0; display < m_project->mHeader.num_displays; display++)
213 {
214 if (m_project->mDisplays[display].screenflow)
215 {
216 return TRUE;
217 }
218 }
219 return FALSE;
220 }
221
222 ///////////////////////////////////////////////////////////////////////////////
GenerateScreenHeader()223 void screen_generator::GenerateScreenHeader()
224 {
225 CString out;
226 CString name = m_project->mHeader.project_name;
227 name.MakeUpper();
228 folder_info *folder;
229 int display;
230
231 WriteCommentBlock(SourceHeaderCommentStart);
232
233 // write the sentry
234 out.Format(_T("#ifndef _%s_SPECIFICATIONS_H_\n#define _%s_SPECIFICATIONS_H_\n\n"),
235 name, name);
236 FileWrite(out);
237 FileWrite(CString("#include \"gx_api.h\"\n\n"));
238
239 // write the "extern C"
240 out = "/* Determine if C++ compiler is being used, if so use standard C. */\n";
241 out += "#ifdef __cplusplus\n";
242 out += "extern \"C\" {\n";
243 out += "#endif\n";
244 FileWrite(out);
245
246 WriteErrorDirectives();
247
248 name_list.RemoveAll();
249 m_widget_id = 1;
250 WriteComment("Define widget ids");
251
252 for (display = 0; display < m_project->mHeader.num_displays; display++)
253 {
254 folder = m_project->mDisplays[display].GetFirstChildFolder();
255
256 /*Wtite predefined widget ids.*/
257 for (UINT index = 0; index < (UINT)(sizeof(PredefinedWidgetIds) / sizeof(STRING_VAL_PAIR)); index++)
258 {
259 name_list.Add(PredefinedWidgetIds[index].name);
260 }
261
262 WriteWidgetIds(folder);
263 }
264 BlankLine();
265
266 WriteComment("Define animation ids");
267
268 int index = 0;
269 CArray<id_info> id_dictionary;
270 id_info ani_info;
271 for (display = 0; display < m_project->mHeader.num_displays; display++)
272 {
273 m_project->CopyIdDictionary(display, ID_TYPE_ANIMATION, &id_dictionary);
274 m_project->SortIdDictionary(&id_dictionary);
275 for (index = 1; index < id_dictionary.GetCount(); index++)
276 {
277 ani_info = id_dictionary.GetAt(index);
278 out.Format(_T("#define %s %d\n"), ani_info.id_name, index);
279 FileWrite(out);
280 }
281 }
282
283 out.Format(_T("#define GX_NEXT_ANIMATION_ID %d\n"), index);
284 FileWrite(out);
285
286 BlankLine();
287
288 WriteComment("Define user event ids");
289 name_list.RemoveAll();
290 int id = 0;
291 for (display = 0; display < m_project->mHeader.num_displays; display++)
292 {
293 screen_flow *flow = m_project->mDisplays[display].screenflow;
294 flow_item *item;
295 trigger_info *trigger;
296
297 if (flow)
298 {
299 for (index = 0; index < flow->GetFlowListCount(); index++)
300 {
301 item = flow->GetFlowItem(index);
302 trigger = item->trigger_list;
303
304 while (trigger)
305 {
306 name = trigger->user_event_id_name;
307 if ((!name.IsEmpty()) && (!IsItemInArray<CString>(name_list, name)))
308 {
309 name_list.Add(name);
310 if (id == 0)
311 {
312 out.Format(_T("enum user_defined_events{\n")
313 _T(" %s = GX_FIRST_USER_EVENT,\n"), name);
314 }
315 else
316 {
317 out.Format(_T(" %s,\n"), name);
318 }
319 id++;
320 FileWrite(out);
321 }
322 trigger = trigger->next;
323 }
324 }
325 }
326 }
327 if (id)
328 {
329 out = _T(" GX_NEXT_USER_EVENT_ID\n};\n");
330 }
331 else
332 {
333 out = _T("#define GX_NEXT_USER_EVENT_ID GX_FIRST_USER_EVENT\n");
334 }
335 FileWrite(out);
336 BlankLine();
337
338
339 if (ProjectHasScreenFlow())
340 {
341 DeclareScreenFlowStructures();
342 }
343
344 // declare the properties stuctures for each used widget type
345
346 WriteComment("Declare properties structures for each utilized widget type");
347 index = 0;
348
349 while(1)
350 {
351 int widget_type = widget_factory::GetWidgetType(index);
352 if (widget_type <= 0)
353 {
354 break;
355 }
356 if (widget_type == GX_TYPE_WIDGET ||
357 widget_type == GX_TYPE_BUTTON ||
358 widget_type == GX_TYPE_WINDOW ||
359 IsWidgetUsed(widget_type))
360 {
361 widget_service_provider *provider = widget_factory::GetServiceProvider(widget_type);
362 CString props = provider->DeclarePropertiesStruct();
363
364 if (!props.IsEmpty())
365 {
366 FileWrite(props);
367 }
368 }
369 index++;
370 }
371
372 WriteComment("Declare top-level control blocks");
373
374 /* Continue writing control blocks, keeping track of those written,
375 until we are able to write them all */
376
377 name_list.RemoveAll();
378
379 m_screen_name_prefix = _T("");
380 for (display = 0; display < m_project->mHeader.num_displays; display++)
381 {
382 BOOL completed = FALSE;
383 if (m_project->mHeader.num_displays > 1)
384 {
385 m_screen_name_prefix = m_project->mDisplays[display].name + _T("_");
386 }
387
388 while (!completed)
389 {
390 folder = m_project->mDisplays[display].GetFirstChildFolder();
391 if (folder == NULL)
392 {
393 break;
394 }
395 completed = TypedefControlBlock(folder);
396 }
397 }
398
399 if (IsCpuWithDave2D(m_project) && m_project->mHeader.guix_version >= 50300)
400 {
401 DeclareSynergyDriverFunctions();
402 }
403
404 WriteComment("Declare event process functions, draw functions, and callback functions");
405 name_list.RemoveAll();
406
407 for (display = 0; display < m_project->mHeader.num_displays; display++)
408 {
409 folder = m_project->mDisplays[display].GetFirstChildFolder();
410 while (folder)
411 {
412 PrototypeCallbacks(folder->GetFirstChildWidget());
413 folder = folder->GetNextFolder();
414 }
415 }
416
417 WriteComment("Declare the GX_STUDIO_DISPLAY_INFO structure");
418
419 if (m_project->mHeader.guix_version <= 50302)
420 {
421 FileWrite(CString("\n"
422 "typedef struct GX_STUDIO_DISPLAY_INFO_STRUCT \n"
423 "{\n"
424 " GX_CONST GX_CHAR *name;\n"
425 " GX_CONST GX_CHAR *canvas_name;\n"
426 " GX_CONST GX_THEME **theme_table;\n"
427 " GX_CONST GX_CHAR ***language_table;\n"
428 " UINT language_table_size;\n"
429 " UINT string_table_size;\n"
430 " UINT x_resolution;\n"
431 " UINT y_resolution;\n"
432 " GX_DISPLAY *display;\n"
433 " GX_CANVAS *canvas;\n"
434 " GX_WINDOW_ROOT *root_window;\n"
435 " GX_COLOR *canvas_memory;\n"
436 " ULONG canvas_memory_size;\n"
437 "} GX_STUDIO_DISPLAY_INFO;\n"));
438 }
439 else if(m_project->mHeader.guix_version < GX_VERSION_STRING_LENGTH_FIX)
440 {
441 // Add a new member variable "theme_table_size"
442 FileWrite(CString("\n"
443 "typedef struct GX_STUDIO_DISPLAY_INFO_STRUCT \n"
444 "{\n"
445 " GX_CONST GX_CHAR *name;\n"
446 " GX_CONST GX_CHAR *canvas_name;\n"
447 " GX_CONST GX_THEME **theme_table;\n"
448 " GX_CONST GX_CHAR ***language_table;\n"
449 " USHORT theme_table_size;\n"
450 " USHORT language_table_size;\n"
451 " UINT string_table_size;\n"
452 " UINT x_resolution;\n"
453 " UINT y_resolution;\n"
454 " GX_DISPLAY *display;\n"
455 " GX_CANVAS *canvas;\n"
456 " GX_WINDOW_ROOT *root_window;\n"
457 " GX_COLOR *canvas_memory;\n"
458 " ULONG canvas_memory_size;\n"
459 "} GX_STUDIO_DISPLAY_INFO;\n"));
460 }
461 else if(m_project->mHeader.guix_version < GX_VERSION_DISPLAY_ROTATION)
462 {
463 // Add a new member variable "theme_table_size"
464 FileWrite(CString("\n"
465 "typedef struct GX_STUDIO_DISPLAY_INFO_STRUCT \n"
466 "{\n"
467 " GX_CONST GX_CHAR *name;\n"
468 " GX_CONST GX_CHAR *canvas_name;\n"
469 " GX_CONST GX_THEME **theme_table;\n"
470 " GX_CONST GX_STRING **language_table;\n"
471 " USHORT theme_table_size;\n"
472 " USHORT language_table_size;\n"
473 " UINT string_table_size;\n"
474 " UINT x_resolution;\n"
475 " UINT y_resolution;\n"
476 " GX_DISPLAY *display;\n"
477 " GX_CANVAS *canvas;\n"
478 " GX_WINDOW_ROOT *root_window;\n"
479 " GX_COLOR *canvas_memory;\n"
480 " ULONG canvas_memory_size;\n"
481 "} GX_STUDIO_DISPLAY_INFO;\n"));
482 }
483 else
484 {
485 CString out;
486 CString language_direction_table("");
487
488 if (string_table::TestGenerateLanguageDirectionTable())
489 {
490 language_direction_table = _T(" GX_CONST GX_UBYTE *language_direction_table;\n");
491 }
492
493 // Add a new member variable "theme_table_size"
494 out.Format(_T("\n")
495 _T("typedef struct GX_STUDIO_DISPLAY_INFO_STRUCT \n")
496 _T("{\n")
497 _T(" GX_CONST GX_CHAR *name;\n")
498 _T(" GX_CONST GX_CHAR *canvas_name;\n")
499 _T(" GX_CONST GX_THEME **theme_table;\n")
500 _T(" GX_CONST GX_STRING **language_table;\n%s")
501 _T(" USHORT theme_table_size;\n")
502 _T(" USHORT language_table_size;\n")
503 _T(" UINT string_table_size;\n")
504 _T(" UINT x_resolution;\n")
505 _T(" UINT y_resolution;\n")
506 _T(" GX_DISPLAY *display;\n")
507 _T(" GX_CANVAS *canvas;\n")
508 _T(" GX_WINDOW_ROOT *root_window;\n")
509 _T(" GX_COLOR *canvas_memory;\n")
510 _T(" ULONG canvas_memory_size;\n")
511 _T(" USHORT rotation_angle;\n")
512 _T("} GX_STUDIO_DISPLAY_INFO;\n"), language_direction_table);
513
514 FileWrite(out);
515 }
516
517 /* write out the two function prototypes */
518 BlankLine();
519 WriteComment("Declare Studio-generated functions for creating top-level widgets");
520 index = 0;
521
522 while(1)
523 {
524 int widget_type = widget_factory::GetWidgetType(index);
525
526 if (!widget_type)
527 {
528 break;
529 }
530 if (IsWidgetUsed(widget_type))
531 {
532 widget_service_provider *provider = widget_factory::GetServiceProvider(widget_type);
533 if (provider)
534 {
535 out.Format(_T("UINT %s(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent);\n"), provider->GetCreateFromDefFunctionName());
536 FileWrite(out);
537 }
538 }
539 index++;
540 }
541
542 if (project_lib_version() < 50100)
543 {
544 FileWrite(CString("GX_WIDGET *gx_studio_widget_create(GX_STUDIO_WIDGET *definition, GX_WIDGET *parent);\n"
545 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget);\n"
546 "UINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *), USHORT language, USHORT theme, GX_WINDOW_ROOT **return_root);\n"));
547 }
548 else if (project_lib_version() < 50402)
549 {
550 FileWrite(CString("GX_WIDGET *gx_studio_widget_create(GX_BYTE *storage, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent);\n"
551 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget);\n"
552 "UINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *), USHORT language, USHORT theme, GX_WINDOW_ROOT **return_root);\n"));
553 }
554 else
555 {
556 FileWrite(CString("GX_WIDGET *gx_studio_widget_create(GX_BYTE *storage, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent);\n"
557 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget);\n"
558 "UINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *), GX_UBYTE language, USHORT theme, GX_WINDOW_ROOT **return_root);\n"));
559 }
560
561 if (ProjectHasScreenFlow())
562 {
563 /* Write screen flow auto event handler function. */
564 out = "UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CONST GX_STUDIO_EVENT_PROCESS *record);\n";
565 FileWrite(out);
566 }
567
568 // terminate the extern 'C'
569 out = "\n/* Determine if a C++ compiler is being used. If so, complete the standard\n";
570 out += " C conditional started above. */\n";
571 out += "#ifdef __cplusplus\n";
572 out += "}\n";
573 out += "#endif\n";
574 FileWrite(out);
575
576 // terminate the sentry
577 FileWrite(CString("\n#endif /* sentry */\n"));
578
579 }
580
581 ///////////////////////////////////////////////////////////////////////////////
WriteDisplayConfigure()582 void screen_generator::WriteDisplayConfigure()
583 {
584 CString out;
585
586 if (project_lib_version() < 50402)
587 {
588 FileWrite(CString("\nUINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *),\n"
589 " USHORT language, USHORT theme, GX_WINDOW_ROOT **return_root)\n"
590 "{\n"
591 " GX_CONST GX_THEME *theme_ptr;\n"
592 " GX_RECTANGLE size;\n"
593 "\n"));
594 }
595 else
596 {
597 FileWrite(CString("\nUINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *),\n"
598 " GX_UBYTE language, USHORT theme, GX_WINDOW_ROOT **return_root)\n"
599 "{\n"
600 " GX_CONST GX_THEME *theme_ptr;\n"
601 " GX_RECTANGLE size;\n"
602 "\n"));
603 }
604
605 out.Format(_T(" GX_STUDIO_DISPLAY_INFO *display_info = &%s_display_table[display];\n"),
606 m_project->mHeader.project_name);
607 FileWrite(out);
608
609 //CString upper_display_name = m_project->mDisplays[m_display].name;
610 //upper_display_name.MakeUpper();
611
612 out.Format(_T("\n\n")
613 _T("/* create the requested display */\n\n")
614 _T(" gx_display_create(display_info->display,\n")
615 _T(" display_info->name,\n")
616 _T(" driver,\n")
617 _T(" (GX_VALUE) display_info->x_resolution,\n")
618 _T(" (GX_VALUE) display_info->y_resolution);\n"));
619 FileWrite(out);
620
621 CCommandInfo *pCmdInfo = GetCmdInfo();
622
623 out.Format(_T("\n\n/* install the request theme */\n\n")
624 _T(" if(display_info->theme_table)\n")
625 _T(" {\n")
626 _T(" theme_ptr = display_info->theme_table[theme];\n")
627 _T(" if(theme_ptr)\n")
628 _T(" {\n")
629 _T(" gx_display_color_table_set(display_info->display, theme_ptr->theme_color_table, theme_ptr->theme_color_table_size);\n")
630 _T(" \n/* install the color palette if required */\n")
631 _T(" if (display_info->display->gx_display_driver_palette_set &&\n")
632 _T(" theme_ptr->theme_palette != NULL)\n")
633 _T(" {\n")
634 _T(" display_info->display->gx_display_driver_palette_set(display_info->display, theme_ptr->theme_palette, theme_ptr->theme_palette_size);\n")
635 _T(" }\n\n")
636 _T(" gx_display_font_table_set(display_info->display, theme_ptr->theme_font_table, theme_ptr->theme_font_table_size);\n")
637 _T(" gx_display_pixelmap_table_set(display_info->display, theme_ptr->theme_pixelmap_table, theme_ptr->theme_pixelmap_table_size);\n")
638 _T(" gx_system_scroll_appearance_set(theme_ptr->theme_vertical_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_vertical_scrollbar_appearance);\n")
639 _T(" gx_system_scroll_appearance_set(theme_ptr->theme_horizontal_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_horizontal_scrollbar_appearance);\n"));
640 FileWrite(out);
641
642 out.Format(
643 _T(" }\n")
644 _T(" }\n"));
645 FileWrite(out);
646
647 WriteComment("Install the language table.");
648
649 if (project_lib_version() < 50402)
650 {
651 out.Format(
652 _T(" if(display_info->language_table)\n")
653 _T(" {\n")
654 _T(" gx_system_language_table_set((GX_CHAR ***) display_info->language_table, display_info->language_table_size, display_info->string_table_size);\n")
655 _T(" gx_system_active_language_set(language);\n")
656 _T(" }\n"));
657 }
658 else if (project_lib_version() < GX_VERSION_STRING_LENGTH_FIX)
659 {
660 out.Format(
661 _T(" if(display_info->language_table)\n")
662 _T(" {\n")
663 _T(" gx_display_language_table_set(display_info->display, (GX_CHAR ***) display_info->language_table, (GX_UBYTE) display_info->language_table_size, display_info->string_table_size);\n")
664 _T(" gx_display_active_language_set(display_info->display, language);\n")
665 _T(" }\n"));
666 }
667 else
668 {
669 out.Format(
670 _T(" if(display_info->language_table)\n")
671 _T(" {\n")
672 _T(" gx_display_language_table_set_ext(display_info->display, display_info->language_table, (GX_UBYTE) display_info->language_table_size, display_info->string_table_size);\n")
673 _T(" gx_display_active_language_set(display_info->display, language);\n")
674 _T(" }\n"));
675 }
676
677 FileWrite(out);
678
679 if (string_table::TestGenerateLanguageDirectionTable())
680 {
681 WriteComment("Install the language direction table.");
682
683 out.Format(
684 _T(" if(display_info->language_direction_table)\n")
685 _T(" {\n")
686 _T(" gx_display_language_direction_table_set(display_info->display, display_info->language_direction_table, (GX_UBYTE) display_info->language_table_size);\n")
687 _T(" }\n"));
688
689 FileWrite(out);
690 }
691
692 if (project_lib_version() >= GX_VERSION_DISPLAY_ROTATION)
693 {
694 WriteComment("Set screen rotation angle.");
695 out = _T(" display_info->display->gx_display_rotation_angle = display_info->rotation_angle;");
696 FileWrite(out);
697 }
698
699 out.Format(_T("\n\n")
700 _T("/* create the canvas for this display */\n\n")
701 _T(" gx_canvas_create(display_info->canvas,\n")
702 _T(" display_info->canvas_name,\n")
703 _T(" display_info->display,\n")
704 _T(" GX_CANVAS_MANAGED | GX_CANVAS_VISIBLE,\n")
705 _T(" display_info->x_resolution,\n")
706 _T(" display_info->y_resolution,\n")
707 _T(" display_info->canvas_memory,\n")
708 _T(" display_info->canvas_memory_size);\n"));
709 FileWrite(out);
710
711 WriteComment("Create the root window for this canvas");
712
713 FileWrite(CString(" gx_utility_rectangle_define(&size,\n"
714 " 0, 0,\n"
715 " (GX_VALUE) (display_info->x_resolution - 1),\n"
716 " (GX_VALUE) (display_info->y_resolution - 1));\n"));
717 out.Format(_T("\n")
718 _T(" gx_window_root_create(display_info->root_window,\n")
719 _T(" display_info->name,\n")
720 _T(" display_info->canvas, GX_STYLE_NONE, 0, &size);\n")
721 _T(" if (return_root)\n")
722 _T(" {\n")
723 _T(" *return_root = display_info->root_window;\n")
724 _T(" }\n")
725 _T(" return GX_SUCCESS;\n")
726 _T("}\n"));
727 FileWrite(out);
728 }
729
730 ///////////////////////////////////////////////////////////////////////////////
CheckDependencies(widget_info * info,BOOL top_level) const731 BOOL screen_generator::CheckDependencies(widget_info *info, BOOL top_level) const
732 {
733 CString upper_name;
734 CString check_name;
735
736 while(info)
737 {
738 if (info->basetype == GX_TYPE_TEMPLATE)
739 {
740 template_service_provider *tp = (template_service_provider *) widget_factory::GetServiceProvider(GX_TYPE_TEMPLATE);
741 widget_info *base_info = tp->GetBaseInfo(info);
742
743 if (!base_info)
744 {
745 ErrorMsg("Internal Error: Could not locate template base");
746 return TRUE;
747 }
748
749 if (GetProjectView() && GetProjectView()->IsTopLevelWidget(base_info))
750 {
751 check_name = m_screen_name_prefix + base_info->app_name;
752 }
753 else
754 {
755 check_name = base_info->app_name;
756 }
757
758 if (!IsItemInArray<CString>(name_list, check_name))
759 {
760 // can't write this one out yet, base is not written
761 return FALSE;
762 }
763 }
764 if (info->GetChildWidgetInfo())
765 {
766 if (!CheckDependencies(info->GetChildWidgetInfo()))
767 {
768 return FALSE;
769 }
770 }
771 if (top_level)
772 {
773 return TRUE;
774 }
775 else
776 {
777 info = info->GetNextWidgetInfo();
778 }
779 }
780 return TRUE;
781 }
782
783 ///////////////////////////////////////////////////////////////////////////////
SetOutFile(CString & requested_file)784 bool screen_generator::SetOutFile(CString &requested_file)
785 {
786 CString pathname;
787 CString outfile;
788 PATHINFO info;
789 int display;
790 CFile *testfile;
791
792 if (requested_file.IsEmpty())
793 {
794 if (output_file_list.GetCount() != 0)
795 {
796 m_outfile = output_file_list.GetAt(0);
797 return TRUE;
798 }
799 else
800 {
801 ErrorMsg("Internal error: Invalid output file request.");
802 return FALSE;
803 }
804 }
805 else
806 {
807 outfile = m_output_filepath + requested_file + _T(".c"); /* output_file_list not 0 means we are specifying output for folders.*/
808
809 if (output_file_list.GetCount() != 0)
810 {
811 CCommandInfo *pCmdInfo = GetCmdInfo();
812
813 if (!pCmdInfo->GetSpecificationFileName().IsEmpty())
814 {
815 outfile = requested_file;
816 outfile += CString("_") + pCmdInfo->GetSpecificationFileName();
817 outfile = m_output_filepath + outfile + _T(".c"); /* output_file_list not 0 means we are specifying output for folders.*/
818 }
819 }
820 }
821
822 if (outfile.GetAt(1) != ':')
823 {
824
825 ConvertToProjectRelativePath(outfile);
826
827 info.pathname = outfile;
828 info.pathtype = PATH_TYPE_PROJECT_RELATIVE;
829 outfile = MakeAbsolutePathname(info);
830 }
831
832 for (int index = 0; index < output_file_list.GetCount(); index++)
833 {
834 testfile = output_file_list.GetAt(index);
835
836 pathname = testfile->GetFilePath();
837
838 if (!outfile.Compare(pathname))
839 {
840 m_outfile = testfile;
841 return TRUE;
842 }
843 }
844
845 if (!CheckOutputFileSecurity(outfile))
846 {
847 return FALSE;
848 }
849
850 testfile = new CFile();
851 if (!testfile->Open(outfile, CFile::modeCreate | CFile::modeWrite))
852 {
853 CString msg;
854 msg.Format(_T("Could not open output file:\n%s\nPlease check resource file path."), outfile);
855 ErrorMsg(msg);
856 delete testfile;
857 return FALSE;
858 }
859 output_file_list.Add(testfile);
860 m_outfile = testfile;
861
862 WriteCommentBlock(SourceHeaderCommentStart);
863 CString out;
864 out.Format(_T("#define GUIX_STUDIO_GENERATED_FILE\n"));
865 FileWrite(out);
866
867 if (m_project->mHeader.insert_headers_before)
868 {
869 //Include additional headers
870 WriteAdditionalHeaders(m_project->mHeader.additional_headers);
871 }
872
873 out.Format(_T("#include <stddef.h>\n"));
874 FileWrite(out);
875
876 if (m_project->mHeader.num_displays > 1)
877 {
878 for (display = 0; display < m_project->mHeader.num_displays; display++)
879 {
880 // primary specs needs all resources for display table
881 out.Format(_T("#include \"%s_%s_resources.h\"\n"), m_project->mHeader.project_name, m_project->mDisplays[display].name);
882 FileWrite(out);
883 }
884 }
885 else
886 {
887 out.Format(_T("#include \"%s_resources.h\"\n"), m_project->mHeader.project_name);
888 FileWrite(out);
889 }
890 out.Format(_T("#include \"%s_specifications.h\"\n"), m_project->mHeader.project_name);
891 FileWrite(out);
892
893 if (!m_project->mHeader.insert_headers_before)
894 {
895 //Include additional headers
896 WriteAdditionalHeaders(m_project->mHeader.additional_headers);
897 }
898
899 FileWrite(CString("\n"));
900
901 if (m_outfile == output_file_list.GetAt(0))
902 {
903 out = _T("static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent);\n");
904 FileWrite(out);
905 }
906 else
907 {
908 /* if not default file, extern root window. */
909 for (int display = 0; display < m_project->mHeader.num_displays; display++)
910 {
911 out.Format(_T("extern GX_WINDOW_ROOT %s_root_window;\n"), m_project->mDisplays[display].name);
912 FileWrite(out);
913 }
914 }
915
916 return TRUE;
917 }
918
919 ///////////////////////////////////////////////////////////////////////////////
DeclareDisplayControlBlock()920 void screen_generator::DeclareDisplayControlBlock()
921 {
922 CString display_name;
923 CString out("");
924
925 /* Set output file to the default file: Empty means default output file. */
926 SetOutFile(out);
927
928 for (int display = 0; display < m_project->mHeader.num_displays; display++)
929 {
930 display_name = m_project->mDisplays[display].name;
931 out.Format(
932 _T("GX_DISPLAY %s_control_block;\n")
933 _T("GX_WINDOW_ROOT %s_root_window;\n")
934 _T("GX_CANVAS %s_canvas_control_block;\n"),
935 display_name, display_name, display_name);
936 FileWrite(out);
937
938 if (m_project->mDisplays[display].allocate_canvas)
939 {
940 out.Format(_T("ULONG %s_canvas_memory[%d];\n\n"),
941 display_name, (CalculateCanvasSizeBytes(display) / 4));
942
943 FileWrite(out);
944 }
945 }
946 }
947
948 ///////////////////////////////////////////////////////////////////////////////
949 /* Display table and setup define. */
GenerateDisplayConfigBlock()950 void screen_generator::GenerateDisplayConfigBlock()
951 {
952 WriteDisplayConfigure();
953
954 if (IsCpuWithDave2D(m_project) && m_project->mHeader.guix_version >= 50300)
955 {
956 WriteComment("Provide display driver setup function");
957 for (int display = 0; display < m_project->mHeader.num_displays; display++)
958 {
959 WriteDave2DSetupFunction(display);
960 }
961 }
962 }
963
964 ///////////////////////////////////////////////////////////////////////////////
965 /* Write widgets properties by folder. */
WriteWidgetsInfo()966 void screen_generator::WriteWidgetsInfo()
967 {
968 name_list.RemoveAll();
969
970 for (int display = 0; display < m_project->mHeader.num_displays; display++)
971 {
972 m_project->mDisplays[display].stable->MakeMLViewReferenceRecord(display);
973 m_display = display;
974 bool completed = FALSE;
975
976 if (m_project->mHeader.num_displays > 1)
977 {
978 m_screen_name_prefix = m_project->mDisplays[display].name + _T("_");
979 }
980
981 while (!completed)
982 {
983 completed = TRUE;
984 folder_info *folder = m_project->mDisplays[display].GetFirstChildFolder();
985
986 while (folder)
987 {
988 if (SetOutFile(folder->output_filename))
989 {
990 widget_info *info = folder->GetFirstChildWidget();
991
992 while (info)
993 {
994 if (IsItemInArray<CString>(name_list, m_screen_name_prefix + info->app_name))
995 {
996 // already wrote this one out, continue
997 info = info->GetNextWidgetInfo();
998 continue;
999 }
1000
1001 if (!CheckDependencies(info, TRUE))
1002 {
1003 info = info->GetNextWidgetInfo();
1004 completed = FALSE;
1005 continue;
1006 }
1007
1008 name_list.Add(m_screen_name_prefix + info->app_name);
1009
1010 CString out = m_screen_name_prefix + info->app_name + _T("_");
1011 WriteWidgetProperties(out, info, TRUE);
1012
1013 WriteChildDefine(m_screen_name_prefix + info->app_name, info->GetChildWidgetInfo());
1014
1015 //child definition might be referenced
1016 CheckWriteScreenFlow(display, info);
1017
1018 WriteParentDefine(info);
1019 info = info->GetNextWidgetInfo();
1020 }
1021 }
1022 folder = folder->GetNextFolder();
1023 }
1024 }
1025 }
1026 }
1027
1028 ///////////////////////////////////////////////////////////////////////////////
1029 /* Get base screen to make sure it will be defined or declared before this screen. */
WriteExternBaseDefines(folder_info * folder)1030 void screen_generator::WriteExternBaseDefines(folder_info *folder)
1031 {
1032 CFile *default_file = output_file_list.GetAt(0);
1033
1034 if (!default_file)
1035 {
1036 return;
1037 }
1038
1039 CString default_filename = default_file->GetFileName();
1040 CString base_ofilename;
1041 CString derived_ofilename;
1042
1043 widget_info *base;
1044 folder_info *base_folder;
1045 CString out;
1046 CString name;
1047
1048 widget_info *screen = folder->GetFirstChildWidget();
1049
1050 while (screen)
1051 {
1052 if (screen->basetype == GX_TYPE_TEMPLATE)
1053 {
1054 base = GetOpenProject()->FindWidgetInfo(folder, screen->base_name, FALSE);
1055 base_folder = GetOpenProject()->FindParentFolderInfo(base);
1056
1057 if (base_folder)
1058 {
1059 if (base_folder->output_filename.IsEmpty())
1060 {
1061 base_ofilename = default_filename;
1062 }
1063 else
1064 {
1065 base_ofilename = base_folder->output_filename + _T(".c");
1066 }
1067
1068 derived_ofilename = folder->output_filename + _T(".c");
1069
1070 if (base_ofilename != derived_ofilename)
1071 {
1072 // extern base that has different output filename than
1073 // the derived widget
1074 name.Format(_T("%s%s"), m_screen_name_prefix, screen->base_name);
1075
1076 if (!IsItemInArray<CString>(name_list, name))
1077 {
1078 out.Format(_T("extern GX_CONST GX_STUDIO_WIDGET %s_define;\n"), name);
1079 FileWrite(out);
1080
1081 name_list.Add(name);
1082 }
1083 }
1084 }
1085
1086 }
1087 screen = screen->GetNextWidgetInfo();
1088 }
1089 }
1090
1091 ///////////////////////////////////////////////////////////////////////////////
WriteExternBaseDefines()1092 void screen_generator::WriteExternBaseDefines()
1093 {
1094 BOOL completed = FALSE;
1095 CString current_output_filename;
1096 CArray<folder_info *> folder_list;
1097
1098 m_screen_name_prefix = _T("");
1099
1100 CFile *default_file = output_file_list.GetAt(0);
1101 if (!default_file)
1102 {
1103 return;
1104 }
1105
1106 CString default_filename = default_file->GetFileName();
1107 CString custom_filename;
1108
1109 while (!completed)
1110 {
1111 completed = TRUE;
1112 name_list.RemoveAll();
1113 current_output_filename.Empty();
1114
1115 for (int display = 0; display < m_project->mHeader.num_displays; display++)
1116 {
1117 if (m_project->mHeader.num_displays > 1)
1118 {
1119 m_screen_name_prefix = m_project->mDisplays[display].name + _T("_");
1120 }
1121
1122 folder_info *folder = m_project->mDisplays[display].GetFirstChildFolder();
1123
1124 while (folder)
1125 {
1126 if (folder->output_filename.IsEmpty())
1127 {
1128 custom_filename = default_filename;
1129 }
1130 else
1131 {
1132 custom_filename = folder->output_filename + _T(".c");
1133 }
1134
1135 if (custom_filename != default_filename &&
1136 !IsItemInArray<folder_info *>(folder_list, folder))
1137 {
1138 if (current_output_filename.IsEmpty())
1139
1140 {
1141 current_output_filename = folder->output_filename;
1142 SetOutFile(folder->output_filename);
1143 }
1144
1145 if (folder->output_filename == current_output_filename)
1146 {
1147 WriteExternBaseDefines(folder);
1148 folder_list.Add(folder);
1149 }
1150 else
1151 {
1152 completed = FALSE;
1153 }
1154 }
1155
1156 folder = folder->GetNextFolder();
1157 }
1158 }
1159 }
1160 }
1161
1162 ///////////////////////////////////////////////////////////////////////////////
GenerateScreenSource()1163 void screen_generator::GenerateScreenSource()
1164 {
1165 // declare control blocks
1166 DeclareControlBlocks();
1167
1168 // extern base defines that has been referenced
1169 WriteExternBaseDefines();
1170
1171 // Declare canvas and display.
1172 DeclareDisplayControlBlock();
1173
1174 // Write extern widgets to the default output file
1175 WriteExternWidgetsToDefaultFile();
1176
1177 DeclareDisplayTable();
1178
1179
1180 /* Write Screen flow functions. */
1181 /* Write universal function */
1182 if (ProjectHasScreenFlow())
1183 {
1184 /* Write extern screens for screen flow*/
1185 WriteExternWidgetsUsedByScreenFlow();
1186
1187 /* Write static auto event functions. */
1188 WriteAutoEventHandler();
1189 }
1190
1191 /* Write generic widget create functions. */
1192 WriteCreateFunctions();
1193
1194 /* Write widgets properties. */
1195 WriteWidgetsInfo();
1196
1197 /* Following should be generated in default file. */
1198 if (SetOutFile(CString("")))
1199 {
1200 DeclareWidgetTable();
1201 /* Display control block defines. */
1202 GenerateDisplayConfigBlock();
1203 }
1204 }
1205
1206
1207 ///////////////////////////////////////////////////////////////////////////////
GenerateAnimationInfoName(flow_item * item,CString & name,int index)1208 void screen_generator::GenerateAnimationInfoName(flow_item *item, CString &name, int index)
1209 {
1210 name.Format(_T("%s_animation_%d"), m_screen_name_prefix + item->screen_name, index);
1211 }
1212
1213 ///////////////////////////////////////////////////////////////////////////////
GenerateAnimationInfo(flow_item * item,trigger_info * trigger,action_info * action,int index)1214 void screen_generator::GenerateAnimationInfo(flow_item *item, trigger_info *trigger, action_info *action, int index)
1215 {
1216 CString name;
1217 CString out;
1218 CString target_name;
1219 CString parent_name;
1220 widget_info *target_info = NULL;
1221 widget_info *parent_info = NULL;
1222 GX_ANIMATION_INFO *info = action->animation;
1223 folder_info *folder = m_project->mDisplays[m_display].GetFirstChildFolder();
1224
1225 if (info)
1226 {
1227 GenerateAnimationInfoName(item, name, index);
1228 out.Format(_T("\nGX_ANIMATION_INFO %s = {\n"), name);
1229 FileWrite(out);
1230
1231 target_name = _T("GX_NULL");
1232
1233 if (action->target_widget_name.GetLength() > 0)
1234 {
1235 if (action->target_show_child_widgets)
1236 {
1237 //find the top level widget
1238 target_info = m_project->FindWidgetInfo(folder, item->screen_name, FALSE);
1239
1240 //search the target widget under the top level widget
1241 target_info = m_project->FindWidgetInfo(target_info->GetChildWidgetInfo(), action->target_widget_name, TRUE);
1242 }
1243 else
1244 {
1245 //search the target widget through top level widgets
1246 target_info = m_project->FindWidgetInfo(folder, action->target_widget_name, FALSE);
1247 }
1248
1249 if (target_info)
1250 {
1251 if (target_info->allocation == STATICALLY_ALLOCATED)
1252 {
1253 target_name = GetWidgetReferenceName(target_info);
1254 target_name = _T("(GX_WIDGET *) &") + m_screen_name_prefix + target_name;
1255 }
1256 }
1257 }
1258
1259 parent_name = _T("GX_NULL");
1260
1261 if (action->parent_widget_name.IsEmpty())
1262 {
1263 //action parent is not set
1264
1265 //get the parent of the target widget
1266 parent_info = m_project->FindParentInfo(target_info);
1267
1268 if (parent_info)
1269 {
1270 //set action parent to target's parent
1271 if (parent_info->allocation == STATICALLY_ALLOCATED)
1272 {
1273 parent_name = GetWidgetReferenceName(parent_info);
1274 parent_name = _T("(GX_WIDGET *) &") + m_screen_name_prefix + parent_name;
1275 }
1276 }
1277 else
1278 {
1279 //set action parent to root
1280 /* See if we can resolve to the root window name */
1281 parent_name = _T("(GX_WIDGET *) &") + m_project->mDisplays[m_display].name;
1282 parent_name += "_root_window";
1283 }
1284 }
1285 else
1286 {
1287 if (action->parent_show_child_widgets)
1288 {
1289 //find the top level widget
1290 parent_info = m_project->FindWidgetInfo(folder, item->screen_name, FALSE);
1291
1292 //search the parent widget under the top level widget
1293 parent_info = m_project->FindWidgetInfo(parent_info->GetChildWidgetInfo(), action->parent_widget_name, TRUE);
1294 }
1295 else
1296 {
1297 //search the parent widget through top level widgets
1298 parent_info = m_project->FindWidgetInfo(folder, action->parent_widget_name, FALSE);
1299 }
1300
1301 if (parent_info)
1302 {
1303 if (parent_info->allocation == STATICALLY_ALLOCATED)
1304 {
1305 parent_name = GetWidgetReferenceName(parent_info);
1306 parent_name = _T("(GX_WIDGET *) &") + m_screen_name_prefix + parent_name;
1307 }
1308 }
1309 }
1310
1311 CString animation_id_name("0");
1312 CString animation_style_string("0");
1313
1314 if (!action->animation_id_name.IsEmpty())
1315 {
1316 animation_id_name = action->animation_id_name;
1317 }
1318
1319 GetAnimationStyles(info, animation_style_string);
1320
1321 /*
1322 GX_WIDGET *gx_animation_target;
1323 GX_WIDGET *gx_animation_parent;
1324 GX_WIDGET **gx_animation_slide_screen_list;
1325 USHORT gx_animation_style;
1326 USHORT gx_animation_id;
1327 USHORT gx_animation_delay_before;
1328 USHORT gx_animation_tick_rate;
1329 GX_POINT gx_animation_start_position;
1330 GX_POINT gx_animation_end_position;
1331 GX_UBYTE gx_animation_start_alpha;
1332 GX_UBYTE gx_animation_end_alpha;
1333 GX_UBYTE gx_animation_steps;
1334
1335 */
1336
1337 out.Format(_T(" %s,\n") // target
1338 _T(" %s,\n") // parent
1339 _T(" GX_NULL,\n") // screen_list
1340 _T(" %s, %s, %d, %d,\n") // animation style, animation id, delay before, delay
1341 _T(" {%d, %d}, {%d, %d}, %d, %d, %d\n") // start pos, end pos, start alpha, end_alpha, steps
1342 _T("};\n\n"),
1343
1344 target_name,
1345 parent_name,
1346 animation_style_string,
1347 animation_id_name,
1348 info->gx_animation_start_delay,
1349 info->gx_animation_frame_interval,
1350 info->gx_animation_start_position.gx_point_x,
1351 info->gx_animation_start_position.gx_point_y,
1352 info->gx_animation_end_position.gx_point_x,
1353 info->gx_animation_end_position.gx_point_y,
1354 info->gx_animation_start_alpha,
1355 info->gx_animation_end_alpha,
1356 info->gx_animation_steps);
1357
1358 FileWrite(out);
1359 }
1360 }
1361
1362 ///////////////////////////////////////////////////////////////////////////////
GenerateActionListName(flow_item * item,trigger_info * trigger,CString & name)1363 void screen_generator::GenerateActionListName(flow_item *item, trigger_info *trigger, CString &name)
1364 {
1365 CString trigger_name_as_c = trigger->trigger_name;
1366 trigger_name_as_c.Remove(' ');
1367 trigger_name_as_c.Replace(_T("on_gx_signal"), _T(""));
1368 trigger_name_as_c.Replace(',', '_');
1369 trigger_name_as_c.Replace('(', '_');
1370 trigger_name_as_c.Replace(')', '_');
1371 trigger_name_as_c.Replace(_T("__"), _T("_"));
1372 name.Format(_T("%s_%sactions"), m_screen_name_prefix + item->screen_name, trigger_name_as_c);
1373 }
1374
1375
1376
1377 ///////////////////////////////////////////////////////////////////////////////
WriteAutoEventHandler()1378 void screen_generator::WriteAutoEventHandler()
1379 {
1380 CString out("");
1381
1382 /* Set output file to the default file: Empty means default output file. */
1383 SetOutFile(out);
1384
1385 out = "static GX_WIDGET *gx_studio_action_target_get(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)\n"
1386 "{\n"
1387 " GX_WIDGET *parent = GX_NULL;\n"
1388 " GX_WIDGET *target = GX_NULL;\n"
1389 " INT search_depth;\n"
1390 " GX_STUDIO_WIDGET *widget_define;\n\n"
1391 " if (action->flags & GX_ACTION_FLAG_DYNAMIC_TARGET)\n"
1392 " {\n"
1393 " /* dynamically create the target widget */\n"
1394 " widget_define = (GX_STUDIO_WIDGET *) action->target;\n"
1395 " if(action->flags & GX_ACTION_FLAG_DYNAMIC_PARENT)\n"
1396 " {\n"
1397 " gx_window_root_find(current, (GX_WINDOW_ROOT **)&parent);\n"
1398 " search_depth = GX_SEARCH_DEPTH_INFINITE;\n"
1399 " }\n"
1400 " else\n"
1401 " {\n"
1402 " parent = (GX_WIDGET *)action->parent;\n"
1403 " search_depth = 1;\n"
1404 " }\n"
1405 " gx_widget_find(parent, widget_define->widget_id, search_depth, &target);\n"
1406 " if (target == GX_NULL)\n"
1407 " {\n"
1408 " target = gx_studio_widget_create(GX_NULL, widget_define, GX_NULL);\n"
1409 " }\n"
1410 " if (target)\n"
1411 " {\n"
1412 " target->gx_widget_status |= GX_STATUS_STUDIO_CREATED;\n"
1413 " }\n"
1414 " }\n"
1415 " else\n"
1416 " {\n"
1417 " target = (GX_WIDGET *) action->target;\n"
1418 " }\n"
1419 " return target;\n"
1420 "}\n\n";
1421 FileWrite(out);
1422
1423 out = "static GX_WIDGET *gx_studio_action_target_find(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)\n"
1424 "{\n"
1425 " GX_WIDGET *parent = GX_NULL;\n"
1426 " GX_WIDGET *target = GX_NULL;\n"
1427 " GX_STUDIO_WIDGET *widget_define;\n\n"
1428 " if (action->flags & GX_ACTION_FLAG_DYNAMIC_TARGET)\n"
1429 " {\n"
1430 " /* Find the dynamically created target */\n"
1431 " widget_define = (GX_STUDIO_WIDGET *) action->target;\n"
1432 " if(action->flags & GX_ACTION_FLAG_DYNAMIC_PARENT)\n"
1433 " {\n"
1434 " gx_window_root_find(current, (GX_WINDOW_ROOT **)&parent);\n"
1435 " }\n"
1436 " else\n"
1437 " {\n"
1438 " parent = (GX_WIDGET *)action->parent;\n"
1439 " }\n"
1440 " gx_widget_find(parent, widget_define->widget_id, GX_SEARCH_DEPTH_INFINITE, &target);\n"
1441 " }\n"
1442 " else\n"
1443 " {\n"
1444 " target = (GX_WIDGET *) action->target;\n"
1445 " }\n"
1446 " return target;\n"
1447 "}\n\n";
1448 FileWrite(out);
1449
1450 out = "static GX_WIDGET *gx_studio_action_parent_find(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)\n"
1451 "{\n"
1452 "GX_WIDGET *parent = GX_NULL;\n"
1453 "GX_STUDIO_WIDGET *widget_define;\n\n"
1454 " if (action->flags & GX_ACTION_FLAG_DYNAMIC_PARENT)\n"
1455 " {\n"
1456 " /* Find the dynamically created target */\n"
1457 " widget_define = (GX_STUDIO_WIDGET *)action->parent; \n"
1458 " gx_window_root_find(current, (GX_WINDOW_ROOT **)&parent); \n"
1459 " gx_widget_find(parent, widget_define->widget_id, GX_SEARCH_DEPTH_INFINITE, &parent); \n"
1460 " }\n"
1461 " else\n"
1462 " {\n"
1463 " parent = (GX_WIDGET *)action->parent; \n"
1464 " }\n"
1465 " return parent; \n"
1466 "}\n\n";
1467 FileWrite(out);
1468
1469 out = "static VOID gx_studio_animation_execute(GX_WIDGET *current, GX_CONST GX_STUDIO_ACTION *action)\n"
1470 "{\n"
1471 " GX_ANIMATION *animation;\n"
1472 " GX_ANIMATION_INFO animation_info;\n";
1473 if (project_lib_version() > 50402)
1474 {
1475
1476 out +=
1477 " GX_WIDGET *parent = GX_NULL;\n";
1478 }
1479 out +=
1480 " GX_WIDGET *target = GX_NULL;\n"
1481 " gx_system_animation_get(&animation);\n"
1482 " if (animation)\n"
1483 " {\n"
1484 " animation_info = *action->animation;\n\n";
1485 if (project_lib_version() > 50402)
1486 {
1487 out +=
1488 " if((action->flags & GX_ACTION_FLAG_POP_TARGET) ||\n"
1489 " (action->flags & GX_ACTION_FLAG_POP_PARENT))\n"
1490 " {\n"
1491 " gx_system_screen_stack_get((GX_WIDGET **)&parent, &target);\n"
1492 " }\n\n"
1493 " if(action->flags & GX_ACTION_FLAG_POP_TARGET)\n"
1494 " {\n"
1495 " animation_info.gx_animation_target = target;\n"
1496 " }\n\n"
1497 " if(action->flags & GX_ACTION_FLAG_POP_PARENT)\n"
1498 " {\n"
1499 " animation_info.gx_animation_parent = (GX_WIDGET *)parent;\n"
1500 " }\n\n";
1501 }
1502
1503 out +=
1504 " if ((!animation_info.gx_animation_target) &&\n"
1505 " (action->flags & GX_ACTION_FLAG_DYNAMIC_TARGET))\n"
1506 " {\n"
1507 " target = gx_studio_action_target_get(current, action);\n"
1508 " animation_info.gx_animation_target = target;\n"
1509 " }\n\n"
1510 " if (!animation_info.gx_animation_parent)\n"
1511 " {\n"
1512 " animation_info.gx_animation_parent = gx_studio_action_parent_find(current, action);\n"
1513 " }\n\n"
1514 " if (animation_info.gx_animation_target &&\n"
1515 " animation_info.gx_animation_parent)\n"
1516 " {\n"
1517 " gx_animation_start(animation, &animation_info);\n"
1518 " }\n"
1519 " }\n"
1520 "}\n\n";
1521 FileWrite(out);
1522
1523 out = "UINT gx_studio_auto_event_handler(GX_WIDGET *widget, GX_EVENT *event_ptr, GX_CONST GX_STUDIO_EVENT_PROCESS *record)\n"
1524 "{\n"
1525 " UINT status = GX_SUCCESS;\n"
1526 " GX_CONST GX_STUDIO_ACTION *action;\n"
1527 " GX_CONST GX_WIDGET *parent = GX_NULL;\n"
1528 " GX_WIDGET *target = GX_NULL;\n"
1529 " GX_CONST GX_STUDIO_EVENT_ENTRY *entry = record->event_table;\n\n"
1530 " while(entry->event_type)\n"
1531 " {\n"
1532 " if (entry->event_type == event_ptr->gx_event_type)\n"
1533 " {\n"
1534 " if((entry->event_type == GX_EVENT_ANIMATION_COMPLETE) &&\n"
1535 " (entry->event_sender != event_ptr->gx_event_sender))\n"
1536 " {\n"
1537 " entry++;\n"
1538 " continue;\n"
1539 " }\n"
1540 " action = entry->action_list;\n\n"
1541 " while(action->opcode)\n"
1542 " {\n"
1543 " switch(action->opcode)\n"
1544 " {\n";
1545
1546 if (project_lib_version() <= 50402)
1547 {
1548 out +=
1549 " case GX_ACTION_TYPE_ATTACH:\n"
1550 " parent = action->parent;\n"
1551 " target = gx_studio_action_target_get(widget, action);\n"
1552 " if (parent && target)\n"
1553 " {\n"
1554 " gx_widget_attach(parent, target);\n"
1555 " }\n"
1556 " break;\n\n"
1557 " case GX_ACTION_TYPE_DETACH:\n"
1558 " target = gx_studio_action_target_find(widget, action);\n"
1559 " if (target)\n"
1560 " {\n"
1561 " gx_widget_detach(target);\n"
1562 " if (target->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
1563 " {\n"
1564 " if (widget == target)\n"
1565 " {\n"
1566 " widget = GX_NULL;\n"
1567 " }\n\n"
1568 " gx_widget_delete(target);\n"
1569 " }\n"
1570 " }\n"
1571 " break;\n\n"
1572 " case GX_ACTION_TYPE_TOGGLE:\n"
1573 " target = gx_studio_action_target_get(widget, action);\n"
1574 " parent = widget->gx_widget_parent;\n"
1575 " if (parent)\n"
1576 " {\n"
1577 " gx_widget_detach(widget);\n"
1578 " gx_widget_attach(parent, target);\n"
1579 " if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
1580 " {\n"
1581 " gx_widget_delete(widget);\n"
1582 " widget = GX_NULL;\n"
1583 " }\n"
1584 " }\n"
1585 " break;\n\n"
1586 " case GX_ACTION_TYPE_SHOW:\n"
1587 " target = gx_studio_action_target_get(widget, action);\n"
1588 " if(target)\n"
1589 " {\n"
1590 " gx_widget_show(target);\n"
1591 " }\n"
1592 " break;\n\n"
1593 " case GX_ACTION_TYPE_HIDE:\n"
1594 " target = gx_studio_action_target_find(widget, action);\n"
1595 " if(target)\n"
1596 " {\n"
1597 " gx_widget_hide(target);\n"
1598 " }\n"
1599 " break;\n\n"
1600 " case GX_ACTION_TYPE_ANIMATION:\n"
1601 " gx_studio_animation_execute(widget, action);\n"
1602 " break;\n\n"
1603 " case GX_ACTION_TYPE_WINDOW_EXECUTE:\n"
1604 " parent = widget->gx_widget_parent;\n"
1605 " target = gx_studio_action_target_get(widget, action);\n"
1606 " if (parent && target)\n"
1607 " {\n"
1608 " gx_widget_attach(parent, target);\n"
1609 " gx_window_execute((GX_WINDOW *) target, GX_NULL);\n"
1610 " }\n"
1611 " break;\n\n"
1612 " case GX_ACTION_TYPE_WINDOW_EXECUTE_STOP:\n"
1613 " return event_ptr->gx_event_sender;\n\n";
1614 }
1615 else
1616 {
1617 out +=
1618 " case GX_ACTION_TYPE_ATTACH:\n"
1619 " if((action->flags & GX_ACTION_FLAG_POP_TARGET) ||\n"
1620 " (action->flags & GX_ACTION_FLAG_POP_PARENT))\n"
1621 " {\n"
1622 " gx_system_screen_stack_get((GX_WIDGET **)&parent, &target);\n"
1623 " }\n\n"
1624 " if(!(action->flags & GX_ACTION_FLAG_POP_PARENT))\n"
1625 " {\n"
1626 " parent = action->parent;\n"
1627 " }\n"
1628 " if(!(action->flags & GX_ACTION_FLAG_POP_TARGET))\n"
1629 " {\n"
1630 " target = gx_studio_action_target_get(widget, action);\n"
1631 " }\n"
1632 " if (parent && target)\n"
1633 " {\n"
1634 " gx_widget_attach(parent, target);\n"
1635 " }\n"
1636 " break;\n\n"
1637 " case GX_ACTION_TYPE_DETACH:\n"
1638 " target = gx_studio_action_target_find(widget, action);\n"
1639 " if (target)\n"
1640 " {\n"
1641 " gx_widget_detach(target);\n"
1642 " if (target->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
1643 " {\n"
1644 " if (widget == target)\n"
1645 " {\n"
1646 " widget = GX_NULL;\n"
1647 " }\n\n"
1648 " gx_widget_delete(target);\n"
1649 " }\n"
1650 " }\n"
1651 " break;\n\n"
1652 " case GX_ACTION_TYPE_TOGGLE:\n"
1653 " if(action->flags & GX_ACTION_FLAG_POP_TARGET)\n"
1654 " {\n"
1655 " gx_system_screen_stack_get(GX_NULL, &target);\n"
1656 " }\n"
1657 " else\n"
1658 " {\n"
1659 " target = gx_studio_action_target_get(widget, action);\n"
1660 " }\n"
1661 " parent = widget->gx_widget_parent;\n"
1662 " if (parent)\n"
1663 " {\n"
1664 " gx_widget_detach(widget);\n"
1665 " gx_widget_attach(parent, target);\n"
1666 " if (widget->gx_widget_status & GX_STATUS_STUDIO_CREATED)\n"
1667 " {\n"
1668 " gx_widget_delete(widget);\n"
1669 " widget = GX_NULL;\n"
1670 " }\n"
1671 " }\n"
1672 " break;\n\n"
1673 " case GX_ACTION_TYPE_SHOW:\n"
1674 " target = gx_studio_action_target_get(widget, action);\n"
1675 " if(target)\n"
1676 " {\n"
1677 " gx_widget_show(target);\n"
1678 " }\n"
1679 " break;\n\n"
1680 " case GX_ACTION_TYPE_HIDE:\n"
1681 " target = gx_studio_action_target_find(widget, action);\n"
1682 " if(target)\n"
1683 " {\n"
1684 " gx_widget_hide(target);\n"
1685 " }\n"
1686 " break;\n\n"
1687 " case GX_ACTION_TYPE_ANIMATION:\n"
1688 " gx_studio_animation_execute(widget, action);\n"
1689 " break;\n\n"
1690 " case GX_ACTION_TYPE_WINDOW_EXECUTE:\n"
1691 " if((action->flags & GX_ACTION_FLAG_POP_TARGET) ||\n"
1692 " (action->flags & GX_ACTION_FLAG_POP_PARENT))\n"
1693 " {\n"
1694 " gx_system_screen_stack_get((GX_WIDGET **)&parent, &target);\n"
1695 " }\n\n"
1696 " if(!(action->flags & GX_ACTION_FLAG_POP_PARENT))\n"
1697 " {\n"
1698 " parent = widget->gx_widget_parent;\n"
1699 " }\n"
1700 " if(!(action->flags & GX_ACTION_FLAG_POP_TARGET))\n"
1701 " {\n"
1702 " target = gx_studio_action_target_get(widget, action);\n"
1703 " }\n"
1704 " if (parent && target)\n"
1705 " {\n"
1706 " gx_widget_attach(parent, target);\n"
1707 " gx_window_execute((GX_WINDOW *) target, GX_NULL);\n"
1708 " }\n"
1709 " break;\n\n"
1710 " case GX_ACTION_TYPE_WINDOW_EXECUTE_STOP:\n"
1711 " return event_ptr->gx_event_sender;\n\n"
1712 " case GX_ACTION_TYPE_SCREEN_STACK_PUSH:\n"
1713 " target = gx_studio_action_target_get(widget, action);\n"
1714 " if(target)\n"
1715 " {\n"
1716 " gx_system_screen_stack_push(target);\n"
1717 " }\n"
1718 " break;\n\n"
1719 " case GX_ACTION_TYPE_SCREEN_STACK_POP:\n"
1720 " gx_system_screen_stack_pop();\n"
1721 " break;\n\n"
1722 " case GX_ACTION_TYPE_SCREEN_STACK_RESET:\n"
1723 " gx_system_screen_stack_reset();\n"
1724 " break;\n\n";
1725 }
1726 out +=
1727 " default:\n"
1728 " break;\n"
1729 " }\n"
1730 " action++;\n"
1731 " }\n"
1732 " }\n"
1733 " entry++;\n"
1734 " }\n\n"
1735
1736 " if (widget && record->chain_event_handler)\n"
1737 " {\n"
1738 " status = record->chain_event_handler(widget, event_ptr);\n"
1739 " }\n"
1740 " return status;\n"
1741 "}\n\n";
1742 FileWrite(out);
1743 }
1744
1745
1746 ///////////////////////////////////////////////////////////////////////////////
WriteEventTable(flow_item * item)1747 void screen_generator::WriteEventTable(flow_item *item)
1748 {
1749 CString out;
1750 CString action_name;
1751 CString list_name;
1752 CString trigger_animation_id;
1753
1754 out.Format(_T("static GX_STUDIO_EVENT_ENTRY gx_studio_%s_event_table[] = {\n"), m_screen_name_prefix + item->screen_name);
1755 FileWrite(out);
1756
1757 trigger_info *trigger = item->trigger_list;
1758 while(trigger)
1759 {
1760 GenerateActionListName(item, trigger, list_name);
1761 if (trigger->system_event_animat_id_name.IsEmpty())
1762 {
1763 trigger_animation_id = _T("0");
1764 }
1765 else
1766 {
1767 trigger_animation_id = trigger->system_event_animat_id_name;
1768 }
1769
1770 switch(trigger->trigger_type)
1771 {
1772 case TRIGGER_TYPE_SYSTEM_EVENT:
1773 out.Format(_T(" { %s, %s, %s},\n"),
1774 trigger_edit_dlg::GetEventTypeName(trigger->event_type),
1775 trigger_animation_id,
1776 list_name);
1777 FileWrite(out);
1778 break;
1779
1780 case TRIGGER_TYPE_CHILD_SIGNAL:
1781 out.Format(_T(" {GX_SIGNAL(%s, %s), %s, %s},\n"), trigger->signal_id_name,
1782 trigger_edit_dlg::GetEventTypeName(trigger->event_type),
1783 trigger_animation_id,
1784 list_name);
1785 FileWrite(out);
1786 break;
1787
1788 case TRIGGER_TYPE_USER_EVENT:
1789 out.Format(_T(" { %s, %s, %s},\n"),
1790 trigger->user_event_id_name,
1791 trigger_animation_id,
1792 list_name);
1793 FileWrite(out);
1794 break;
1795 }
1796
1797 trigger = trigger->next;
1798 }
1799
1800 FileWrite(CString(" {0, 0, GX_NULL}\n};\n\n"));
1801 };
1802
1803 ///////////////////////////////////////////////////////////////////////////////
GetTempateEventFuncName(widget_info * info)1804 CString screen_generator::GetTempateEventFuncName(widget_info *info)
1805 {
1806 widget_info *base_info = info;
1807 widget_info *derived;
1808
1809 while (base_info->basetype == GX_TYPE_TEMPLATE)
1810 {
1811 derived = base_info;
1812 base_info = template_service_provider::GetBaseInfo(derived);
1813 if (base_info)
1814 {
1815 if (!base_info->event_func.IsEmpty())
1816 {
1817 return base_info->event_func;
1818 }
1819 }
1820 }
1821
1822 return widget_service_provider::GetDefaultEventProcess(base_info->basetype);
1823 }
1824
1825 ///////////////////////////////////////////////////////////////////////////////
GetWidgetReferenceName(widget_info * info)1826 CString screen_generator::GetWidgetReferenceName(widget_info *info)
1827 {
1828 project_view *project_view = GetProjectView();
1829 CString name("");
1830
1831 if (project_view)
1832 {
1833 widget_info *parent_info = project_view->FindTopLevelWidget(info);
1834 if (parent_info && parent_info != info)
1835 {
1836 name.Format(_T("%s.%s_%s"), parent_info->app_name, parent_info->app_name, info->app_name);
1837 }
1838 else
1839 {
1840 name = info->app_name;
1841 }
1842 }
1843 return name;
1844 }
1845
1846 ///////////////////////////////////////////////////////////////////////////////
CheckWriteScreenFlow(int display,widget_info * info)1847 BOOL screen_generator::CheckWriteScreenFlow(int display, widget_info *info)
1848 {
1849 flow_item *item;
1850 trigger_info *trigger;
1851 action_info *action;
1852 widget_info *target_info;
1853 widget_info *parent_info;
1854 int action_count;
1855 int action_index;
1856 int animation_index;
1857 CString out;
1858 CString action_list_name;
1859
1860 screen_flow *flow = m_project->mDisplays[display].screenflow;
1861 folder_info *folder = m_project->mDisplays[display].GetFirstChildFolder();
1862
1863 if (!flow)
1864 {
1865 return FALSE;
1866 }
1867 item = flow->GetFlowItem(info->app_name);
1868
1869 if (!item)
1870 {
1871 return FALSE;
1872 }
1873
1874 // generate animation info for any actions that have animation
1875 trigger = item->trigger_list;
1876
1877 if (!trigger)
1878 {
1879 return FALSE;
1880 }
1881
1882 animation_index = 1;
1883
1884 while(trigger)
1885 {
1886 action_count = trigger->action_list.GetCount();
1887
1888 for (action_index = 0; action_index < action_count; action_index++)
1889 {
1890 action = trigger->action_list[action_index];
1891
1892 if (action->animation)
1893 {
1894 GenerateAnimationInfo(item, trigger, action, animation_index);
1895 animation_index++;
1896 }
1897 }
1898 trigger = trigger->next;
1899 }
1900
1901 // now generate the action array for each trigger:
1902 trigger = item->trigger_list;
1903 animation_index = 1;
1904
1905 while(trigger)
1906 {
1907 GenerateActionListName(item, trigger, action_list_name);
1908 out.Format(_T("\nGX_STUDIO_ACTION %s[%d] = {\n"),
1909 action_list_name, trigger->action_list.GetCount() + 1);
1910 FileWrite(out);
1911
1912 action_count = trigger->action_list.GetCount();
1913
1914 for (action_index = 0; action_index < action_count; action_index++)
1915 {
1916 action = trigger->action_list[action_index];
1917 CString parent_name(_T("GX_NULL"));
1918 CString target_name(parent_name);
1919 CString animation_name(parent_name);
1920 CString action_name;
1921 CString action_flags(_T("0"));
1922
1923 //search target widget info
1924 if (action->target_widget_name.IsEmpty())
1925 {
1926 target_info = NULL;
1927 }
1928 else if (action->target_widget_name == SCREEN_STACK_POP_STRING)
1929 {
1930 //get target from screen stack
1931 target_info = NULL;
1932 action_flags = "GX_ACTION_FLAG_POP_TARGET";
1933 }
1934 else
1935 {
1936 if (action->target_show_child_widgets)
1937 {
1938 target_info = m_project->FindWidgetInfo(folder, item->screen_name, FALSE);
1939 target_info = m_project->FindWidgetInfo(target_info->GetChildWidgetInfo(), action->target_widget_name, TRUE);
1940 }
1941 else
1942 {
1943 target_info = m_project->FindWidgetInfo(folder, action->target_widget_name, FALSE);
1944 }
1945 }
1946
1947 if (action->parent_widget_name.IsEmpty())
1948 {
1949 if (target_info)
1950 {
1951 parent_info = m_project->FindParentInfo(target_info);
1952 }
1953 else
1954 {
1955 parent_info = NULL;
1956 }
1957
1958 if (!parent_info)
1959 {
1960 /* See if we can resolve to the root window name */
1961 parent_name = _T("&") + m_project->mDisplays[m_display].name + _T("_root_window");
1962 }
1963 }
1964 else if (action->parent_widget_name == SCREEN_STACK_POP_STRING)
1965 {
1966 //get parent from screen stack
1967 parent_info = GX_NULL;
1968 if (action_flags == "0")
1969 {
1970 action_flags = "GX_ACTION_FLAG_POP_PARENT";
1971 }
1972 else
1973 {
1974 action_flags += "|GX_ACTION_FLAG_POP_PARENT";
1975 }
1976
1977 }
1978 else
1979 {
1980 if (action->parent_show_child_widgets)
1981 {
1982 //find the top level widget
1983 parent_info = m_project->FindWidgetInfo(folder, item->screen_name, FALSE);
1984
1985 //search the parent widget under the top level widget
1986 parent_info = m_project->FindWidgetInfo(parent_info->GetChildWidgetInfo(), action->parent_widget_name, TRUE);
1987 }
1988 else
1989 {
1990 //search the parent widget through top level widgets
1991 parent_info = m_project->FindWidgetInfo(folder, action->parent_widget_name, FALSE);
1992 }
1993 }
1994
1995 if (parent_info)
1996 {
1997 parent_name = GetWidgetReferenceName(parent_info);
1998
1999 if (parent_info->allocation == STATICALLY_ALLOCATED)
2000 {
2001 parent_name = _T("&") + m_screen_name_prefix + parent_name;
2002 }
2003 else
2004 {
2005 int index = parent_name.Find('.');
2006 parent_name = parent_name.Mid(index + 1);
2007 if (action_flags == "0")
2008 {
2009 action_flags = "GX_ACTION_FLAG_DYNAMIC_PARENT";
2010 }
2011 else
2012 {
2013 action_flags += "|GX_ACTION_FLAG_DYNAMIC_PARENT";
2014 }
2015 parent_name = _T(" &") + m_screen_name_prefix + parent_name + _T("_define");
2016 }
2017 }
2018
2019 if (target_info)
2020 {
2021 target_name = GetWidgetReferenceName(target_info);
2022
2023 if (target_info->allocation == STATICALLY_ALLOCATED)
2024 {
2025 target_name = _T("&") + m_screen_name_prefix + target_name;
2026 }
2027 else
2028 {
2029 if (action_flags == "0")
2030 {
2031 action_flags = "GX_ACTION_FLAG_DYNAMIC_TARGET";
2032 }
2033 else
2034 {
2035 action_flags += "|GX_ACTION_FLAG_DYNAMIC_TARGET";
2036 }
2037
2038 int index = target_name.Find('.');
2039 target_name = target_name.Mid(index + 1);
2040 target_name = _T(" &") + m_screen_name_prefix + target_name + _T("_define");
2041 }
2042 }
2043 if (action->animation)
2044 {
2045 GenerateAnimationInfoName(item, animation_name, animation_index);
2046 animation_name = CString(_T("&")) + animation_name;
2047 animation_index++;
2048 }
2049
2050 action_name = _T("GX_ACTION_TYPE_") + trigger_action_select_dlg::GetActionTypeName(action->action_type).MakeUpper();
2051 action_name.Replace(' ', '_');
2052
2053 out.Format(_T(" {%s, %s, %s, %s, %s},\n"),
2054 action_name, action_flags,
2055 parent_name, target_name, animation_name);
2056 FileWrite(out);
2057 }
2058 out.Format(_T(" {0, 0, GX_NULL, GX_NULL, GX_NULL}\n};\n\n"));
2059 FileWrite(out);
2060 trigger = trigger->next;
2061 }
2062
2063 WriteEventTable(item);
2064
2065 // Generate the event chaining record
2066
2067 out.Format(_T("GX_STUDIO_EVENT_PROCESS %s_event_chain = {"), m_screen_name_prefix + item->screen_name);
2068 FileWrite(out);
2069
2070 out.Format(_T("gx_studio_%s_event_table, "), m_screen_name_prefix + item->screen_name);
2071 FileWrite(out);
2072
2073 CString event_func_name;
2074
2075 if (info->event_func.IsEmpty())
2076 {
2077 if (info->basetype == GX_TYPE_TEMPLATE)
2078 {
2079 event_func_name = GetTempateEventFuncName(info);
2080 }
2081 else
2082 {
2083 event_func_name = widget_service_provider::GetDefaultEventProcess(info->basetype);
2084 }
2085 }
2086 else
2087 {
2088 event_func_name = info->event_func;
2089 }
2090 out.Format(_T("(UINT (*)(GX_WIDGET *, GX_EVENT *))%s};\n"), event_func_name);
2091 FileWrite(out);
2092
2093 /* write out the studio-generated event process function */
2094
2095 out.Format(_T("static UINT gx_studio_%s_event_process(GX_WIDGET *target, GX_EVENT *event_ptr)\n{\n"), m_screen_name_prefix + item->screen_name);
2096 FileWrite(out);
2097
2098 out.Format(_T(" return (gx_studio_auto_event_handler(target, event_ptr, &%s_event_chain));\n}\n\n"), m_screen_name_prefix + item->screen_name);
2099 FileWrite(out);
2100 return TRUE;
2101 }
2102
2103 ///////////////////////////////////////////////////////////////////////////////
IsTextType(widget_info * info)2104 BOOL screen_generator::IsTextType(widget_info *info)
2105 {
2106 BOOL texttype = FALSE;
2107 switch(info->basetype)
2108 {
2109 case GX_TYPE_TEXT_BUTTON:
2110 case GX_TYPE_MULTI_LINE_TEXT_BUTTON:
2111 case GX_TYPE_RADIO_BUTTON:
2112 case GX_TYPE_CHECKBOX:
2113 case GX_TYPE_PROMPT:
2114 case GX_TYPE_MENU:
2115 case GX_TYPE_NUMERIC_PROMPT:
2116 case GX_TYPE_PIXELMAP_PROMPT:
2117 case GX_TYPE_NUMERIC_PIXELMAP_PROMPT:
2118 case GX_TYPE_SINGLE_LINE_TEXT_INPUT:
2119 //case GX_TYPE_PIXELMAP_TEXT_INPUT:
2120 case GX_TYPE_MULTI_LINE_TEXT_VIEW:
2121 case GX_TYPE_MULTI_LINE_TEXT_INPUT:
2122 case GX_TYPE_RICH_TEXT_VIEW:
2123 case GX_TYPE_NUMERIC_SCROLL_WHEEL:
2124 case GX_TYPE_STRING_SCROLL_WHEEL:
2125 texttype = TRUE;
2126 break;
2127
2128 default:
2129 break;
2130 }
2131
2132 return texttype;
2133 }
2134
2135 ///////////////////////////////////////////////////////////////////////////////
GetWidgetTypeName(widget_info * info)2136 CString screen_generator::GetWidgetTypeName(widget_info *info)
2137 {
2138 widget_service_provider *provider = widget_factory::GetServiceProvider(info->basetype);
2139
2140 if (provider)
2141 {
2142 return (provider->GetTypeName(info));
2143 }
2144 return CString("");
2145 }
2146
2147 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetType(widget_info * info)2148 void screen_generator::WriteWidgetType(widget_info *info)
2149 {
2150 CString type_name = GetWidgetTypeName(info);
2151 CString out;
2152 out.Format(_T(" %s, /* widget type */\n"), type_name);
2153 FileWrite(out);
2154 }
2155
2156 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetId(widget_info * info)2157 void screen_generator::WriteWidgetId(widget_info *info)
2158 {
2159 CString out;
2160 if (info->id_name.IsEmpty())
2161 {
2162 FileWrite(CString(" GX_ID_NONE, /* widget id */\n"));
2163 }
2164 else
2165 {
2166 out.Format(_T(" %s, /* widget id */\n"), info->id_name);
2167 FileWrite(out);
2168 }
2169 }
2170
2171 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetUserData(widget_info * info)2172 void screen_generator::WriteWidgetUserData(widget_info *info)
2173 {
2174 CString out;
2175 CString temp;
2176
2177 out = CString(" #if defined(GX_WIDGET_USER_DATA)\n");
2178
2179 if (info->user_data.IsEmpty())
2180 {
2181 out += " 0, /* user data */\n";
2182 }
2183 else
2184 {
2185 temp.Format(_T(" %s, /* user data */\n"), info->user_data);
2186 out += temp;
2187 }
2188 out += " #endif\n";
2189 FileWrite(out);
2190 }
2191
2192
2193 ///////////////////////////////////////////////////////////////////////////////
AddButtonStyles(widget_info * info,CString & out)2194 void screen_generator::AddButtonStyles(widget_info *info, CString &out)
2195 {
2196 if (info->style & GX_STYLE_BUTTON_PUSHED)
2197 {
2198 out += CString("|GX_STYLE_BUTTON_PUSHED");
2199 }
2200 if (info->style & GX_STYLE_BUTTON_TOGGLE)
2201 {
2202 out += CString("|GX_STYLE_BUTTON_TOGGLE");
2203 }
2204 if (info->style & GX_STYLE_BUTTON_RADIO)
2205 {
2206 out += CString("|GX_STYLE_BUTTON_RADIO");
2207 }
2208 if (info->style & GX_STYLE_BUTTON_EVENT_ON_PUSH)
2209 {
2210 out += CString("|GX_STYLE_BUTTON_EVENT_ON_PUSH");
2211 }
2212 if (info->style & GX_STYLE_BUTTON_REPEAT)
2213 {
2214 out += CString("|GX_STYLE_BUTTON_REPEAT");
2215 }
2216 }
2217
2218 ///////////////////////////////////////////////////////////////////////////////
AddButtonAlignmentStyles(widget_info * info,CString & out)2219 void screen_generator::AddButtonAlignmentStyles(widget_info *info, CString &out)
2220 {
2221 switch(info->style & GX_PIXELMAP_HALIGN_MASK)
2222 {
2223 case GX_STYLE_HALIGN_CENTER:
2224 out += CString("|GX_STYLE_HALIGN_CENTER");
2225 break;
2226 case GX_STYLE_HALIGN_LEFT:
2227 out += CString("|GX_STYLE_HALIGN_LEFT");
2228 break;
2229 case GX_STYLE_HALIGN_RIGHT:
2230 out += CString("|GX_STYLE_HALIGN_RIGHT");
2231 break;
2232 }
2233
2234 switch(info->style & GX_PIXELMAP_VALIGN_MASK)
2235 {
2236 case GX_STYLE_VALIGN_CENTER:
2237 out += CString("|GX_STYLE_VALIGN_CENTER");
2238 break;
2239 case GX_STYLE_VALIGN_TOP:
2240 out += CString("|GX_STYLE_VALIGN_TOP");
2241 break;
2242 case GX_STYLE_VALIGN_BOTTOM:
2243 out += CString("|GX_STYLE_VALIGN_BOTTOM");
2244 break;
2245 }
2246 }
2247
2248 ///////////////////////////////////////////////////////////////////////////////
AddListStyles(widget_info * info,CString & out)2249 void screen_generator::AddListStyles(widget_info *info, CString &out)
2250 {
2251 if (info->style & GX_STYLE_CENTER_SELECTED)
2252 {
2253 out += CString("|GX_STYLE_CENTER_SELECTED");
2254 }
2255 if (info->style & GX_STYLE_WRAP)
2256 {
2257 out += CString("|GX_STYLE_WRAP");
2258 }
2259 if (info->style & GX_STYLE_REPEAT_SELECT)
2260 {
2261 out += CString("|GX_STYLE_REPEAT_SELECT");
2262 }
2263 if (info->style & GX_STYLE_FLICKABLE)
2264 {
2265 out += CString("|GX_STYLE_FLICKABLE");
2266 }
2267 }
2268
2269 ///////////////////////////////////////////////////////////////////////////////
AddSliderStyles(widget_info * info,CString & out)2270 void screen_generator::AddSliderStyles(widget_info *info, CString &out)
2271 {
2272 if (info->style & GX_STYLE_SHOW_NEEDLE)
2273 {
2274 out += CString("|GX_STYLE_SHOW_NEEDLE");
2275 }
2276 if (info->style & GX_STYLE_SHOW_TICKMARKS)
2277 {
2278 out += CString("|GX_STYLE_SHOW_TICKMARKS");
2279 }
2280 if (info->style & GX_STYLE_SLIDER_VERTICAL)
2281 {
2282 out += CString("|GX_STYLE_SLIDER_VERTICAL");
2283 }
2284 }
2285
2286 ///////////////////////////////////////////////////////////////////////////////
AddPixelmapSliderStyles(widget_info * info,CString & out)2287 void screen_generator::AddPixelmapSliderStyles(widget_info *info, CString &out)
2288 {
2289 if (info->style & GX_STYLE_TILE_BACKGROUND)
2290 {
2291 out += CString("|GX_STYLE_TILE_BACKGROUND");
2292 }
2293 }
2294
2295 ///////////////////////////////////////////////////////////////////////////////
AddDropListStyles(widget_info * info,CString & out)2296 void screen_generator::AddDropListStyles(widget_info *info, CString &out)
2297 {
2298 if (info->style & GX_STYLE_TILE_WALLPAPER)
2299 {
2300 out += CString("|GX_STYLE_TILE_WALLPAPER");
2301 }
2302 if (info->style & GX_STYLE_TILE_BACKGROUND)
2303 {
2304 out += CString("|GX_STYLE_TILE_BACKGROUND");
2305 }
2306 }
2307
2308 ///////////////////////////////////////////////////////////////////////////////
AddTextAlignStyle(widget_info * info,CString & out)2309 void screen_generator::AddTextAlignStyle(widget_info *info, CString &out)
2310 {
2311 switch(info->style & GX_STYLE_TEXT_ALIGNMENT_MASK)
2312 {
2313 case GX_STYLE_TEXT_LEFT:
2314 out += CString("|GX_STYLE_TEXT_LEFT");
2315 break;
2316
2317 case GX_STYLE_TEXT_RIGHT:
2318 out += CString("|GX_STYLE_TEXT_RIGHT");
2319 break;
2320
2321 case GX_STYLE_TEXT_CENTER:
2322 out += CString("|GX_STYLE_TEXT_CENTER");
2323 break;
2324 }
2325 if (info->basetype == GX_TYPE_MULTI_LINE_TEXT_VIEW)
2326 {
2327 if (info->style & GX_STYLE_VALIGN_CENTER)
2328 {
2329 out += CString("|GX_STYLE_VALIGN_CENTER");
2330 }
2331 }
2332 }
2333
2334 ///////////////////////////////////////////////////////////////////////////////
AddScrollbarStyles(ULONG style,CString & out)2335 void screen_generator::AddScrollbarStyles(ULONG style, CString &out)
2336 {
2337 /* Define Scroll Bar styles. */
2338 if (style & GX_STYLE_TILE_BACKGROUND)
2339 {
2340 out += CString("|GX_STYLE_TILE_BACKGROUND");
2341 }
2342 if (style & GX_SCROLLBAR_RELATIVE_THUMB)
2343 {
2344 out += CString("|GX_SCROLLBAR_RELATIVE_THUMB");
2345 }
2346 if (style & GX_SCROLLBAR_END_BUTTONS)
2347 {
2348 out += CString("|GX_SCROLLBAR_END_BUTTONS");
2349 }
2350 if (style & GX_SCROLLBAR_VERTICAL)
2351 {
2352 out += CString("|GX_SCROLLBAR_VERTICAL");
2353 }
2354 if (style & GX_SCROLLBAR_HORIZONTAL)
2355 {
2356 out += CString("|GX_SCROLLBAR_HORIZONTAL");
2357 }
2358 }
2359
2360 ///////////////////////////////////////////////////////////////////////////////
AddScrollbarStyles(widget_info * info,CString & out)2361 void screen_generator::AddScrollbarStyles(widget_info *info, CString &out)
2362 {
2363 AddScrollbarStyles(info->style, out);
2364 }
2365
2366 ///////////////////////////////////////////////////////////////////////////////
AddProgressBarStyles(widget_info * info,CString & out)2367 void screen_generator::AddProgressBarStyles(widget_info *info, CString &out)
2368 {
2369 ULONG style = info->style;
2370
2371 /* Define Progress Bar styles. */
2372 if (style & GX_STYLE_PROGRESS_PERCENT)
2373 {
2374 out += CString("|GX_STYLE_PROGRESS_PERCENT");
2375 }
2376 if (style & GX_STYLE_PROGRESS_TEXT_DRAW)
2377 {
2378 out += CString("|GX_STYLE_PROGRESS_TEXT_DRAW");
2379 }
2380 if (style & GX_STYLE_PROGRESS_VERTICAL)
2381 {
2382 out += CString("|GX_STYLE_PROGRESS_VERTICAL");
2383 }
2384 if (style & GX_STYLE_PROGRESS_SEGMENTED_FILL)
2385 {
2386 out += CString("|GX_STYLE_PROGRESS_SEGMENTED_FILL");
2387 }
2388 if (style & GX_STYLE_RADIAL_PROGRESS_NO_BACKTRACK)
2389 {
2390 out += CString("|GX_STYLE_RADIAL_PROGRESS_NO_BACKTRACK");
2391 }
2392 if (style & GX_STYLE_RADIAL_PROGRESS_ALIAS)
2393 {
2394 out += CString("|GX_STYLE_RADIAL_PROGRESS_ALIAS");
2395 }
2396 if (style & GX_STYLE_RADIAL_PROGRESS_ROUND)
2397 {
2398 out += CString("|GX_STYLE_RADIAL_PROGRESS_ROUND");
2399 }
2400 }
2401
2402 ///////////////////////////////////////////////////////////////////////////////
AddSpriteStyles(widget_info * info,CString & out)2403 void screen_generator::AddSpriteStyles(widget_info *info, CString &out)
2404 {
2405 ULONG style = info->style;
2406
2407 /* Define Progress Bar styles. */
2408 if (style & GX_STYLE_SPRITE_AUTO)
2409 {
2410 out += CString("|GX_STYLE_SPRITE_AUTO");
2411 }
2412 if (style & GX_STYLE_SPRITE_LOOP)
2413 {
2414 out += CString("|GX_STYLE_SPRITE_LOOP");
2415 }
2416 }
2417
2418 ///////////////////////////////////////////////////////////////////////////////
AddWindowStyles(widget_info * info,CString & out)2419 void screen_generator::AddWindowStyles(widget_info *info, CString &out)
2420 {
2421 /* Define Window styles. */
2422 if (info->style & GX_STYLE_TILE_WALLPAPER)
2423 {
2424 out += CString("|GX_STYLE_TILE_WALLPAPER");
2425 }
2426 }
2427
2428 ///////////////////////////////////////////////////////////////////////////////
AddTextScrollWheelStyles(widget_info * info,CString & out)2429 void screen_generator::AddTextScrollWheelStyles(widget_info *info, CString &out)
2430 {
2431 if (info->style & GX_STYLE_WRAP)
2432 {
2433 out += CString("|GX_STYLE_WRAP");
2434 }
2435 if (info->style & GX_STYLE_TEXT_SCROLL_WHEEL_ROUND)
2436 {
2437 out += CString("|GX_STYLE_TEXT_SCROLL_WHEEL_ROUND");
2438 }
2439 }
2440
2441 ///////////////////////////////////////////////////////////////////////////////
AddWidgetScrollWheelStyles(widget_info * info,CString & out)2442 void screen_generator::AddWidgetScrollWheelStyles(widget_info* info, CString& out)
2443 {
2444 if (info->style & GX_STYLE_WRAP)
2445 {
2446 out += CString("|GX_STYLE_WRAP");
2447 }
2448 }
2449
2450 ///////////////////////////////////////////////////////////////////////////////
AddTreeViewStyles(widget_info * info,CString & out)2451 void screen_generator::AddTreeViewStyles(widget_info *info, CString &out)
2452 {
2453 if (info->style & GX_STYLE_TREE_VIEW_SHOW_ROOT_LINES)
2454 {
2455 out += CString("|GX_STYLE_TREE_VIEW_SHOW_ROOT_LINES");
2456 }
2457 }
2458
2459 ///////////////////////////////////////////////////////////////////////////////
AddTextInputStyles(widget_info * info,CString & out)2460 void screen_generator::AddTextInputStyles(widget_info *info, CString &out)
2461 {
2462 if (info->style & GX_STYLE_TEXT_INPUT_READONLY)
2463 {
2464 out += CString("|GX_STYLE_TEXT_INPUT_READONLY");
2465 }
2466 }
2467
2468 ///////////////////////////////////////////////////////////////////////////////
GetAnimationStyles(GX_ANIMATION_INFO * info,CString & out)2469 void screen_generator::GetAnimationStyles(GX_ANIMATION_INFO *info, CString &out)
2470 {
2471 if (info->gx_animation_style | GX_ANIMATION_TRANSLATE)
2472 {
2473 out = CString("GX_ANIMATION_TRANSLATE");
2474
2475 if (info->gx_animation_style & GX_ANIMATION_DETACH)
2476 {
2477 out += CString("|GX_ANIMATION_DETACH");
2478 }
2479
2480 if (info->gx_animation_style & GX_ANIMATION_PUSH_STACK)
2481 {
2482 out += CString("|GX_ANIMATION_PUSH_STACK");
2483 }
2484
2485 switch (info->gx_animation_style & GX_ANIMATION_EASING_FUNC_MASK)
2486 {
2487 case GX_ANIMATION_BACK_EASE_IN:
2488 out += CString("|GX_ANIMATION_BACK_EASE_IN");
2489 break;
2490 case GX_ANIMATION_BACK_EASE_OUT:
2491 out += CString("|GX_ANIMATION_BACK_EASE_OUT");
2492 break;
2493 case GX_ANIMATION_BACK_EASE_IN_OUT:
2494 out += CString("|GX_ANIMATION_BACK_EASE_IN_OUT");
2495 break;
2496 case GX_ANIMATION_BOUNCE_EASE_IN:
2497 out += CString("|GX_ANIMATION_BOUNCE_EASE_IN");
2498 break;
2499 case GX_ANIMATION_BOUNCE_EASE_OUT:
2500 out += CString("|GX_ANIMATION_BOUNCE_EASE_OUT");
2501 break;
2502 case GX_ANIMATION_BOUNCE_EASE_IN_OUT:
2503 out += CString("|GX_ANIMATION_BOUNCE_EASE_IN_OUT");
2504 break;
2505 case GX_ANIMATION_CIRC_EASE_IN:
2506 out += CString("|GX_ANIMATION_CIRC_EASE_IN");
2507 break;
2508 case GX_ANIMATION_CIRC_EASE_OUT:
2509 out += CString("|GX_ANIMATION_CIRC_EASE_OUT");
2510 break;
2511 case GX_ANIMATION_CIRC_EASE_IN_OUT:
2512 out += CString("|GX_ANIMATION_CIRC_EASE_IN_OUT");
2513 break;
2514 case GX_ANIMATION_CUBIC_EASE_IN:
2515 out += CString("|GX_ANIMATION_CUBIC_EASE_IN");
2516 break;
2517 case GX_ANIMATION_CUBIC_EASE_OUT:
2518 out += CString("|GX_ANIMATION_CUBIC_EASE_OUT");
2519 break;
2520 case GX_ANIMATION_CUBIC_EASE_IN_OUT:
2521 out += CString("|GX_ANIMATION_CUBIC_EASE_IN_OUT");
2522 break;
2523 case GX_ANIMATION_ELASTIC_EASE_IN:
2524 out += CString("|GX_ANIMATION_ELASTIC_EASE_IN");
2525 break;
2526 case GX_ANIMATION_ELASTIC_EASE_OUT:
2527 out += CString("|GX_ANIMATION_ELASTIC_EASE_OUT");
2528 break;
2529 case GX_ANIMATION_ELASTIC_EASE_IN_OUT:
2530 out += CString("|GX_ANIMATION_ELASTIC_EASE_IN_OUT");
2531 break;
2532 case GX_ANIMATION_EXPO_EASE_IN:
2533 out += CString("|GX_ANIMATION_EXPO_EASE_IN");
2534 break;
2535 case GX_ANIMATION_EXPO_EASE_OUT:
2536 out += CString("|GX_ANIMATION_EXPO_EASE_OUT");
2537 break;
2538 case GX_ANIMATION_EXPO_EASE_IN_OUT:
2539 out += CString("|GX_ANIMATION_EXPO_EASE_IN_OUT");
2540 break;
2541 case GX_ANIMATION_QUAD_EASE_IN:
2542 out += CString("|GX_ANIMATION_QUAD_EASE_IN");
2543 break;
2544 case GX_ANIMATION_QUAD_EASE_OUT:
2545 out += CString("|GX_ANIMATION_QUAD_EASE_OUT");
2546 break;
2547 case GX_ANIMATION_QUAD_EASE_IN_OUT:
2548 out += CString("|GX_ANIMATION_QUAD_EASE_IN_OUT");
2549 break;
2550 case GX_ANIMATION_QUART_EASE_IN:
2551 out += CString("|GX_ANIMATION_QUART_EASE_IN");
2552 break;
2553 case GX_ANIMATION_QUART_EASE_OUT:
2554 out += CString("|GX_ANIMATION_QUART_EASE_OUT");
2555 break;
2556 case GX_ANIMATION_QUART_EASE_IN_OUT:
2557 out += CString("|GX_ANIMATION_QUART_EASE_IN_OUT");
2558 break;
2559 case GX_ANIMATION_QUINT_EASE_IN:
2560 out += CString("|GX_ANIMATION_QUINT_EASE_IN");
2561 break;
2562 case GX_ANIMATION_QUINT_EASE_OUT:
2563 out += CString("|GX_ANIMATION_QUINT_EASE_OUT");
2564 break;
2565 case GX_ANIMATION_QUINT_EASE_IN_OUT:
2566 out += CString("|GX_ANIMATION_QUINT_EASE_IN_OUT");
2567 break;
2568 case GX_ANIMATION_SINE_EASE_IN:
2569 out += CString("|GX_ANIMATION_SINE_EASE_IN");
2570 break;
2571 case GX_ANIMATION_SINE_EASE_OUT:
2572 out += CString("|GX_ANIMATION_SINE_EASE_OUT");
2573 break;
2574 case GX_ANIMATION_SINE_EASE_IN_OUT:
2575 out += CString("|GX_ANIMATION_SINE_EASE_IN_OUT");
2576 break;
2577 }
2578 }
2579 else if (info->gx_animation_style | GX_ANIMATION_SCREEN_DRAG)
2580 {
2581 out = CString("GX_ANIMATION_SCREEN_DRAG");
2582
2583 if (info->gx_animation_style & GX_ANIMATION_WRAP)
2584 {
2585 out += CString("|GX_ANIMATION_WRAP");
2586 }
2587
2588 if (info->gx_animation_style & GX_ANIMATION_HORIZONTAL)
2589 {
2590 out += CString("|GX_ANIMATION_HORIZONTAL");
2591 }
2592 else if (info->gx_animation_style & GX_ANIMATION_VERTICAL)
2593 {
2594 out += CString("|GX_ANIMATION_VERTICAL");
2595 }
2596 }
2597 }
2598
2599 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetStyleFlags(widget_info * info)2600 void screen_generator::WriteWidgetStyleFlags(widget_info *info)
2601 {
2602 CString out(" ");
2603
2604 switch(info->style & GX_STYLE_BORDER_MASK)
2605 {
2606 case GX_STYLE_BORDER_RAISED:
2607 out += CString("GX_STYLE_BORDER_RAISED");
2608 break;
2609
2610 case GX_STYLE_BORDER_RECESSED:
2611 out += CString("GX_STYLE_BORDER_RECESSED");
2612 break;
2613
2614 case GX_STYLE_BORDER_THIN:
2615 out += CString("GX_STYLE_BORDER_THIN");
2616 break;
2617
2618 case GX_STYLE_BORDER_THICK:
2619 out += CString("GX_STYLE_BORDER_THICK");
2620 break;
2621
2622 case GX_STYLE_BORDER_NONE:
2623 default:
2624 out += CString("GX_STYLE_BORDER_NONE");
2625 break;
2626 }
2627
2628 /* Define global style flags. */
2629 if (info->style & GX_STYLE_TRANSPARENT)
2630 {
2631 out += CString("|GX_STYLE_TRANSPARENT");
2632 }
2633 if (info->style & GX_STYLE_DRAW_SELECTED)
2634 {
2635 out += CString("|GX_STYLE_DRAW_SELECTED");
2636 }
2637 if (info->style & GX_STYLE_ENABLED)
2638 {
2639 out += CString("|GX_STYLE_ENABLED");
2640 }
2641 if (info->style & GX_STYLE_TEXT_COPY)
2642 {
2643 out += CString("|GX_STYLE_TEXT_COPY");
2644 }
2645
2646 if (m_project->mHeader.guix_version > 50000)
2647 {
2648 // templates cannot be dynamically allocated,
2649 // only widgets based on the template can be dynamically allocated
2650 if (!info->is_template)
2651 {
2652 if (info->allocation != STATICALLY_ALLOCATED)
2653 {
2654 out += CString("|GX_STYLE_DYNAMICALLY_ALLOCATED");
2655 }
2656 }
2657 }
2658
2659 switch(info->basetype)
2660 {
2661 case GX_TYPE_ICON:
2662 case GX_TYPE_BUTTON:
2663 case GX_TYPE_RADIO_BUTTON:
2664 case GX_TYPE_CHECKBOX:
2665 case GX_TYPE_ICON_BUTTON:
2666 case GX_TYPE_TEXT_BUTTON:
2667 case GX_TYPE_PIXELMAP_BUTTON:
2668 case GX_TYPE_MULTI_LINE_TEXT_BUTTON:
2669 AddButtonStyles(info, out);
2670
2671 if (info->basetype == GX_TYPE_ICON ||
2672 info->basetype == GX_TYPE_ICON_BUTTON ||
2673 info->basetype == GX_TYPE_PIXELMAP_BUTTON)
2674 {
2675 AddButtonAlignmentStyles(info, out);
2676 }
2677 break;
2678
2679 case GX_TYPE_VERTICAL_LIST:
2680 case GX_TYPE_HORIZONTAL_LIST:
2681 AddListStyles(info, out);
2682 break;
2683
2684 case GX_TYPE_VERTICAL_SCROLL:
2685 case GX_TYPE_HORIZONTAL_SCROLL:
2686 AddScrollbarStyles(info, out);
2687 break;
2688
2689 case GX_TYPE_SLIDER:
2690 case GX_TYPE_PIXELMAP_SLIDER:
2691 /* Define Slider style flags. */
2692 AddSliderStyles(info, out);
2693
2694 if (info->basetype == GX_TYPE_PIXELMAP_SLIDER)
2695 {
2696 AddPixelmapSliderStyles(info, out);
2697 }
2698 break;
2699
2700 case GX_TYPE_DROP_LIST:
2701 AddDropListStyles(info, out);
2702 break;
2703
2704 case GX_TYPE_PROGRESS_BAR:
2705 case GX_TYPE_RADIAL_PROGRESS_BAR:
2706 AddProgressBarStyles(info, out);
2707 break;
2708
2709 case GX_TYPE_SPRITE:
2710 AddSpriteStyles(info, out);
2711 break;
2712
2713 case GX_TYPE_STRING_SCROLL_WHEEL:
2714 case GX_TYPE_NUMERIC_SCROLL_WHEEL:
2715 AddTextScrollWheelStyles(info, out);
2716 break;
2717
2718 case GX_TYPE_GENERIC_SCROLL_WHEEL:
2719 AddWidgetScrollWheelStyles(info, out);
2720 break;
2721
2722 case GX_TYPE_TREE_VIEW:
2723 AddTreeViewStyles(info, out);
2724 break;
2725
2726 case GX_TYPE_SINGLE_LINE_TEXT_INPUT:
2727 case GX_TYPE_MULTI_LINE_TEXT_INPUT:
2728 AddTextInputStyles(info, out);
2729 break;
2730 }
2731
2732 if (IsTextType(info))
2733 {
2734 AddTextAlignStyle(info, out);
2735 }
2736
2737 if (info->basetype >= GX_TYPE_WINDOW)
2738 {
2739 AddWindowStyles(info, out);
2740 }
2741
2742 out += CString(", /* style flags */\n");
2743 FileWrite(out);
2744 }
2745
2746 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetStatusFlags(widget_info * info)2747 void screen_generator::WriteWidgetStatusFlags(widget_info *info)
2748 {
2749 CString out(" ");
2750 BOOL gen_reordered_bidi = FALSE;
2751
2752 if ((info->basetype == GX_TYPE_MULTI_LINE_TEXT_VIEW) && (project_lib_version() >= GX_VERSION_GEN_LINE_BREAK_STATUS))
2753 {
2754 for (int lang = 0; lang < m_project->mHeader.num_languages; lang++)
2755 {
2756 if (m_project->mHeader.languages[lang].support_bidi_text &&
2757 m_project->mHeader.languages[lang].gen_reordered_bidi_text)
2758 {
2759 gen_reordered_bidi = TRUE;
2760 break;
2761 }
2762 }
2763 }
2764
2765 if (info->accepts_focus || gen_reordered_bidi)
2766 {
2767 if (info->accepts_focus)
2768 {
2769 out += "GX_STATUS_ACCEPTS_FOCUS";
2770 }
2771
2772 if (gen_reordered_bidi)
2773 {
2774 if (info->accepts_focus)
2775 {
2776 out += "|";
2777 }
2778 out += "GX_STATUS_LINE_BREAK_PROCESSED";
2779 }
2780 }
2781 else
2782 {
2783 out += "0";
2784 }
2785
2786 out += ", /* status flags */\n";
2787 FileWrite(out);
2788 }
2789
2790 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetControlBlockSize(widget_info * info,BOOL bTop)2791 void screen_generator::WriteWidgetControlBlockSize(widget_info *info, BOOL bTop)
2792 {
2793 CString out;
2794 CString upper_name;
2795
2796 if (bTop)
2797 {
2798 upper_name = m_screen_name_prefix + info->app_name;
2799 upper_name.MakeUpper();
2800 out = CString(" sizeof(") + upper_name + CString("_CONTROL_BLOCK), /* control block size */\n");
2801 }
2802 else
2803 {
2804 widget_service_provider *provider = widget_factory::GetServiceProvider(info->basetype);
2805
2806 if (provider)
2807 {
2808 if (info->basetype == GX_TYPE_TEMPLATE)
2809 {
2810 upper_name = m_screen_name_prefix + info->base_name;
2811 upper_name.MakeUpper();
2812 out = CString(" sizeof(") + upper_name + CString("_CONTROL_BLOCK), /* control block size */\n");
2813 }
2814 else
2815 {
2816 out = CString(" sizeof(") + provider->GetControlBlockName() + CString("), /* control block size */\n");
2817 }
2818 }
2819 }
2820 FileWrite(out);
2821 }
2822
2823 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetColors(widget_info * info)2824 void screen_generator::WriteWidgetColors(widget_info *info)
2825 {
2826 CString out;
2827 out.Format(_T(" %s, /* normal color id */\n"), GetColorIdName(info->color_id[NORMAL_FILL_COLOR_INDEX]));
2828 FileWrite(out);
2829 out.Format(_T(" %s, /* selected color id */\n"), GetColorIdName(info->color_id[SELECTED_FILL_COLOR_INDEX]));
2830 FileWrite(out);
2831
2832 if (project_lib_version() > 50400)
2833 {
2834 out.Format(_T(" %s, /* disabled color id */\n"), GetColorIdName(info->color_id[DISABLED_FILL_COLOR_INDEX]));
2835 FileWrite(out);
2836 }
2837 }
2838
2839 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetSize(widget_info * info)2840 void screen_generator::WriteWidgetSize(widget_info *info)
2841 {
2842 CString out;
2843 out.Format(_T(" {%d, %d, %d, %d}, /* widget size */\n"),
2844 info->size.gx_rectangle_left,
2845 info->size.gx_rectangle_top,
2846 info->size.gx_rectangle_right,
2847 info->size.gx_rectangle_bottom);
2848 FileWrite(out);
2849 }
2850
2851
2852 ///////////////////////////////////////////////////////////////////////////////
WriteCreateFunctionName(widget_info * info)2853 void screen_generator::WriteCreateFunctionName(widget_info *info)
2854 {
2855 CString out;
2856 widget_service_provider *provider = NULL;
2857
2858 provider = widget_factory::GetServiceProvider(info->basetype);
2859
2860 if (provider)
2861 {
2862 out.Format(_T(" %s, /* create function */\n"), provider->GetCreateFromDefFunctionName());
2863 FileWrite(out);
2864 }
2865 }
2866
2867 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetOverrides(widget_info * info)2868 void screen_generator::WriteWidgetOverrides(widget_info *info)
2869 {
2870 CString out;
2871
2872 if (info->draw_func.IsEmpty())
2873 {
2874 FileWrite(CString(" GX_NULL, /* drawing function override */\n")); // no drawing override
2875 }
2876 else
2877 {
2878 out.Format(_T(" (VOID (*)(GX_WIDGET *)) %s, /* drawing function override */\n"), info->draw_func);
2879 FileWrite(out);
2880 }
2881
2882 /* write out the event process function */
2883
2884 BOOL bHasScreenFlow = FALSE;
2885
2886 /* We only create screen flow records for top-level widgets today */
2887 if (GetProjectView() && GetProjectView()->IsTopLevelWidget(info))
2888 {
2889 screen_flow *flow = m_project->mDisplays[m_display].screenflow;
2890
2891 if (flow)
2892 {
2893 flow_item *item = flow->GetFlowItem(info->app_name);
2894 if (item)
2895 {
2896 if (item->trigger_list)
2897 {
2898 bHasScreenFlow = TRUE;
2899 out.Format(_T(" (UINT (*)(GX_WIDGET *, GX_EVENT *)) gx_studio_%s_event_process, /* event function override */\n"), m_screen_name_prefix + info->app_name);
2900 FileWrite(out);
2901 }
2902 }
2903 }
2904 }
2905
2906 if (!bHasScreenFlow)
2907 {
2908 if (info->event_func.IsEmpty())
2909 {
2910 FileWrite(CString(" GX_NULL, /* event function override */\n")); // no event override
2911 }
2912 else
2913 {
2914 out.Format(_T(" (UINT (*)(GX_WIDGET *, GX_EVENT *)) %s, /* event function override */\n"), info->event_func);
2915 FileWrite(out);
2916 }
2917 }
2918 }
2919
2920 ///////////////////////////////////////////////////////////////////////////////
WriteChildDefine(CString & parent_name,widget_info * info)2921 void screen_generator::WriteChildDefine(CString &parent_name, widget_info *info)
2922 {
2923 CString out;
2924 CString upper_name;
2925 widget_info *stop = NULL;
2926
2927 if (!info)
2928 {
2929 return;
2930 }
2931 if (info->GetChildWidgetInfo())
2932 {
2933 WriteChildDefine(parent_name, info->GetChildWidgetInfo());
2934 }
2935
2936 if (info->GetNextWidgetInfo())
2937 {
2938 // only do one level of next, because next will do it's own next
2939 WriteChildDefine(parent_name, info->GetNextWidgetInfo());
2940 }
2941
2942 if (m_project->mHeader.guix_version < 50100)
2943 {
2944 out.Format(_T("\nGX_STUDIO_WIDGET %s_%s_define =\n{\n"), parent_name, info->app_name);
2945 }
2946 else
2947 {
2948 out.Format(_T("\nGX_CONST GX_STUDIO_WIDGET %s_%s_define =\n{\n"), parent_name, info->app_name);
2949 }
2950 FileWrite(out);
2951
2952 // Write the app name
2953 out.Format(_T(" \"%s\",\n"), info->app_name);
2954 FileWrite(out);
2955
2956 // write the widget type id
2957 WriteWidgetType(info);
2958 WriteWidgetId(info);
2959 if (m_project->mHeader.guix_version > 50205)
2960 {
2961 WriteWidgetUserData(info);
2962 }
2963 WriteWidgetStyleFlags(info);
2964 WriteWidgetStatusFlags(info);
2965 WriteWidgetControlBlockSize(info);
2966 WriteWidgetColors(info);
2967 WriteCreateFunctionName(info);
2968 WriteWidgetOverrides(info);
2969 WriteWidgetSize(info);
2970
2971 if (info->GetNextWidgetInfo())
2972 {
2973 out.Format(_T(" &%s_%s_define, /* next widget definition */\n"), parent_name, info->GetNextWidgetInfo()->app_name);
2974 FileWrite(out);
2975 }
2976 else
2977 {
2978 FileWrite(CString(" GX_NULL, /* no next widget */\n"));
2979 }
2980
2981 if (info->GetChildWidgetInfo())
2982 {
2983 out.Format(_T(" &%s_%s_define, /* child widget definition */\n"), parent_name, info->GetChildWidgetInfo()->app_name);
2984 FileWrite(out);
2985 }
2986 else
2987 {
2988 FileWrite(CString(" GX_NULL, /* no child widgets */ \n"));
2989 }
2990 if (m_project->mHeader.guix_version < 50100 ||
2991 info->allocation == STATICALLY_ALLOCATED)
2992 {
2993 upper_name = parent_name;
2994 upper_name.MakeUpper();
2995 out.Format(_T(" offsetof(%s_CONTROL_BLOCK, %s_%s), /* control block */\n"), upper_name, parent_name, info->app_name);
2996 }
2997 else
2998 {
2999 out.Format(_T(" 0, /* runtime control block */\n"));
3000 }
3001 FileWrite(out);
3002
3003 // check to see if this widget has any extended properties
3004 out = _T(" (void *) GX_NULL /* no extended properties */\n};\n");
3005
3006 widget_service_provider *provider = widget_factory::GetServiceProvider(info->basetype);
3007 if (provider)
3008 {
3009 CString write_string = provider->WriteExtendedProperties(this, CString("---"), info);
3010 if (!write_string.IsEmpty())
3011 {
3012 out.Format(_T(" (void *) &%s_%s_properties /* extended properties */\n};\n"), parent_name, info->app_name);
3013 }
3014 }
3015 FileWrite(out);
3016 }
3017
3018 ///////////////////////////////////////////////////////////////////////////////
WriteParentDefine(widget_info * info)3019 void screen_generator::WriteParentDefine(widget_info *info)
3020 {
3021 CString out;
3022
3023 if (m_project->mHeader.guix_version < 50100)
3024 {
3025 out.Format(_T("\nGX_STUDIO_WIDGET %s_define =\n{\n"), info->app_name);
3026 }
3027 else
3028 {
3029 out.Format(_T("\nGX_CONST GX_STUDIO_WIDGET %s%s_define =\n{\n"), m_screen_name_prefix, info->app_name);
3030 }
3031 FileWrite(out);
3032
3033 // Write the app name
3034 out.Format(_T(" \"%s\",\n"), m_screen_name_prefix + info->app_name);
3035 FileWrite(out);
3036
3037 // write the widget type id
3038 WriteWidgetType(info);
3039 WriteWidgetId(info);
3040 if (m_project->mHeader.guix_version > 50205)
3041 {
3042 WriteWidgetUserData(info);
3043 }
3044 WriteWidgetStyleFlags(info);
3045 WriteWidgetStatusFlags(info);
3046 WriteWidgetControlBlockSize(info, TRUE);
3047 WriteWidgetColors(info);
3048 WriteCreateFunctionName(info);
3049 WriteWidgetOverrides(info);
3050 WriteWidgetSize(info);
3051
3052 FileWrite(CString(" GX_NULL, /* next widget */\n")); // next
3053
3054 if (info->GetChildWidgetInfo())
3055 {
3056 out.Format(_T(" &%s%s_%s_define, /* child widget */\n"), m_screen_name_prefix, info->app_name, info->GetChildWidgetInfo()->app_name);
3057 FileWrite(out);
3058 }
3059 else
3060 {
3061 FileWrite(CString(" GX_NULL, /* child widget */\n"));
3062 }
3063
3064
3065 out.Format(_T(" 0, /* control block */\n")); // control block
3066 FileWrite(out);
3067
3068 // check to see if this widget has any extended properties
3069 out = " (void *) GX_NULL /* extended properties */\n};\n";
3070
3071 widget_service_provider *provider = widget_factory::GetServiceProvider(info->basetype);
3072 if (provider)
3073 {
3074 CString write_string = provider->WriteExtendedProperties(this, CString("---"), info);
3075 if (!write_string.IsEmpty())
3076 {
3077 out.Format(_T(" (void *) &%s%s_properties /* extended properties */\n};\n"), m_screen_name_prefix, info->app_name);
3078 }
3079 }
3080 FileWrite(out);
3081
3082 }
3083
3084 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetIds(folder_info * folder)3085 void screen_generator::WriteWidgetIds(folder_info *folder)
3086 {
3087 while (folder)
3088 {
3089 WriteWidgetIds(folder->GetFirstChildWidget());
3090 folder = folder->GetNextFolder();
3091 }
3092 }
3093
3094 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetIds(widget_info * info)3095 void screen_generator::WriteWidgetIds(widget_info *info)
3096 {
3097 CString out;
3098
3099 while(info)
3100 {
3101 if (!info->id_name.IsEmpty())
3102 {
3103 if (!IsItemInArray<CString>(name_list, info->id_name))
3104 {
3105 out.Format(_T("#define %s %d\n"), info->id_name, m_widget_id);
3106 FileWrite(out);
3107 m_widget_id++;
3108 name_list.Add(info->id_name);
3109 }
3110 }
3111 if (info->GetChildWidgetInfo())
3112 {
3113 WriteWidgetIds(info->GetChildWidgetInfo());
3114 }
3115 info = info->GetNextWidgetInfo();
3116 }
3117 }
3118
3119 ///////////////////////////////////////////////////////////////////////////////
TypedefControlBlock(folder_info * folder)3120 BOOL screen_generator::TypedefControlBlock(folder_info *folder)
3121 {
3122 CString out;
3123 folder_info *start_folder;
3124 widget_info *start_widget;
3125 CString upper_name;
3126 BOOL completed = TRUE;
3127
3128 start_folder = folder;
3129 while (start_folder)
3130 {
3131 start_widget = start_folder->GetFirstChildWidget();
3132 while (start_widget)
3133 {
3134 if (IsItemInArray<CString>(name_list, m_screen_name_prefix + start_widget->app_name))
3135 {
3136 start_widget = start_widget->GetNextWidgetInfo();
3137 continue;
3138 }
3139
3140 if (!CheckDependencies(start_widget, TRUE))
3141 {
3142 completed = FALSE;
3143 start_widget = start_widget->GetNextWidgetInfo();
3144 continue;
3145 }
3146
3147 name_list.Add(m_screen_name_prefix + start_widget->app_name);
3148 upper_name = m_screen_name_prefix + start_widget->app_name;
3149 upper_name.MakeUpper();
3150
3151 out.Format(_T("typedef struct %s_CONTROL_BLOCK_STRUCT\n{\n"), upper_name);
3152 FileWrite(out);
3153
3154 DeclareBaseMembers(start_widget);
3155
3156 if (m_project->mHeader.guix_version < 50100 ||
3157 start_widget->allocation == STATICALLY_ALLOCATED)
3158 {
3159 DeclareChildMembers(m_screen_name_prefix + start_widget->app_name, start_widget->GetChildWidgetInfo());
3160 }
3161
3162 out.Format(_T("} %s_CONTROL_BLOCK;\n\n"), upper_name);
3163 FileWrite(out);
3164 start_widget = start_widget->GetNextWidgetInfo();
3165 }
3166
3167 start_folder = start_folder->GetNextFolder();
3168 }
3169
3170 if (completed)
3171 {
3172 WriteComment("extern statically defined control blocks");
3173 out.Format(_T("#ifndef GUIX_STUDIO_GENERATED_FILE\n"));
3174 FileWrite(out);
3175 start_folder = folder;
3176 while (start_folder)
3177 {
3178 start_widget = start_folder->GetFirstChildWidget();
3179 while (start_widget)
3180 {
3181 upper_name = m_screen_name_prefix + start_widget->app_name;
3182 upper_name.MakeUpper();
3183 if (m_project->mHeader.guix_version < 50100 ||
3184 start_widget->allocation == STATICALLY_ALLOCATED)
3185 {
3186 out.Format(_T("extern %s_CONTROL_BLOCK %s%s;\n"), upper_name, m_screen_name_prefix, start_widget->app_name);
3187 FileWrite(out);
3188 }
3189 start_widget = start_widget->GetNextWidgetInfo();
3190 }
3191 start_folder = start_folder->GetNextFolder();
3192 }
3193 out.Format(_T("#endif\n"));
3194 FileWrite(out);
3195 }
3196
3197 return completed;
3198 }
3199
3200 ///////////////////////////////////////////////////////////////////////////////
PrototypeCallbacks(widget_info * info)3201 void screen_generator::PrototypeCallbacks(widget_info *info)
3202 {
3203 CString out;
3204 while(info)
3205 {
3206 if (!info->callback_func.IsEmpty())
3207 {
3208 switch(info->basetype)
3209 {
3210 case GX_TYPE_VERTICAL_LIST:
3211 case GX_TYPE_DROP_LIST:
3212 out.Format(_T("VOID %s(GX_VERTICAL_LIST *, GX_WIDGET *, INT);\n"), info->callback_func);
3213
3214 if (!IsItemInArray<CString>(name_list, out))
3215 {
3216 FileWrite(out);
3217 name_list.Add(out);
3218 }
3219 break;
3220
3221 case GX_TYPE_HORIZONTAL_LIST:
3222 out.Format(_T("VOID %s(GX_HORIZONTAL_LIST *, GX_WIDGET *, INT);\n"), info->callback_func);
3223
3224 if (!IsItemInArray<CString>(name_list, out))
3225 {
3226 FileWrite(out);
3227 name_list.Add(out);
3228 }
3229 break;
3230 case GX_TYPE_STRING_SCROLL_WHEEL:
3231 out.Format(_T("GX_CONST GX_CHAR *%s(GX_STRING_SCROLL_WHEEL *wheel, INT row);\n"), info->callback_func);
3232 if (!IsItemInArray<CString>(name_list, out))
3233 {
3234 FileWrite(out);
3235 name_list.Add(out);
3236 }
3237 break;
3238
3239 case GX_TYPE_NUMERIC_SCROLL_WHEEL:
3240 if (project_lib_version() >= GX_VERSION_STRING_LENGTH_FIX)
3241 {
3242 out.Format(_T("UINT %s(GX_NUMERIC_SCROLL_WHEEL *wheel, INT row, GX_STRING *string);\n"), info->callback_func);
3243 }
3244 else
3245 {
3246 out.Format(_T("GX_CONST GX_CHAR *%s(GX_NUMERIC_SCROLL_WHEEL *wheel, INT row);\n"), info->callback_func);
3247 }
3248
3249 if (!IsItemInArray<CString>(name_list, out))
3250 {
3251 FileWrite(out);
3252 name_list.Add(out);
3253 }
3254 break;
3255
3256 case GX_TYPE_GENERIC_SCROLL_WHEEL:
3257 out.Format(_T("VOID %s(GX_GENERIC_SCROLL_WHEEL *wheel, GX_WIDGET *widget, INT);\n"), info->callback_func);
3258
3259 if (!IsItemInArray<CString>(name_list, out))
3260 {
3261 FileWrite(out);
3262 name_list.Add(out);
3263 }
3264 break;
3265
3266 case GX_TYPE_RADIAL_SLIDER:
3267 out.Format(_T("VOID %s(GX_RADIAL_SLIDER *slider);\n"), info->callback_func);
3268 if (!IsItemInArray<CString>(name_list, out))
3269 {
3270 FileWrite(out);
3271 name_list.Add(out);
3272 }
3273 break;
3274
3275 default:
3276 break;
3277
3278 }
3279 }
3280
3281 if (!info->format_func.IsEmpty())
3282 {
3283 switch ( info->basetype)
3284 {
3285 case GX_TYPE_NUMERIC_PROMPT:
3286 out.Format(_T("VOID %s(GX_NUMERIC_PROMPT *, INT);\n"), info->format_func);
3287
3288 if (!IsItemInArray<CString>(name_list, out))
3289 {
3290 FileWrite(out);
3291 name_list.Add(out);
3292 }
3293 break;
3294
3295 case GX_TYPE_NUMERIC_PIXELMAP_PROMPT:
3296 out.Format(_T("VOID %s(GX_NUMERIC_PIXELMAP_PROMPT *, INT);\n"), info->format_func);
3297
3298 if (!IsItemInArray<CString>(name_list, out))
3299 {
3300 FileWrite(out);
3301 name_list.Add(out);
3302 }
3303 break;
3304 default:
3305 break;
3306 }
3307 }
3308
3309 CString widget_type("GX_WIDGET");
3310
3311 widget_service_provider *provider;
3312
3313 if (info->basetype == GX_TYPE_TEMPLATE)
3314 {
3315 widget_info *base = template_service_provider::GetBaseInfo(info);
3316
3317 while (base->basetype == GX_TYPE_TEMPLATE)
3318 {
3319 base = template_service_provider::GetBaseInfo(base);
3320 }
3321
3322 if (base)
3323 {
3324 provider = widget_factory::GetServiceProvider(base->basetype);
3325 }
3326 }
3327 else
3328 {
3329 provider = widget_factory::GetServiceProvider(info->basetype);
3330 }
3331
3332 if (provider)
3333 {
3334 widget_type = provider->GetControlBlockName();
3335 }
3336
3337 if (!info->event_func.IsEmpty())
3338 {
3339 out.Format(_T("UINT %s(%s *widget, GX_EVENT *event_ptr);\n"),
3340 info->event_func, widget_type);
3341 if (!IsItemInArray<CString>(name_list, out))
3342 {
3343 FileWrite(out);
3344 name_list.Add(out);
3345 }
3346 }
3347 if (!info->draw_func.IsEmpty())
3348 {
3349 out.Format(_T("VOID %s(%s *widget);\n"),
3350 info->draw_func, widget_type);
3351 if (!IsItemInArray<CString>(name_list, out))
3352 {
3353 FileWrite(out);
3354 name_list.Add(out);
3355 }
3356 }
3357 if (info->GetChildWidgetInfo())
3358 {
3359 PrototypeCallbacks(info->GetChildWidgetInfo());
3360 }
3361 info = info->GetNextWidgetInfo();
3362 }
3363 }
3364
3365 ///////////////////////////////////////////////////////////////////////////////
WriteExternWidgetsUsedByScreenFlow(folder_info * folder,int display_index)3366 void screen_generator::WriteExternWidgetsUsedByScreenFlow(folder_info *folder, int display_index)
3367 {
3368 widget_info *info = NULL;
3369 widget_info *target = NULL;
3370 folder_info *first_folder;
3371 flow_item *item;
3372 screen_flow *flow;
3373 trigger_info *trigger;
3374 action_info *action;
3375 folder_info *parent_folder;
3376 CString target_name;
3377
3378 flow = m_project->mDisplays[display_index].screenflow;
3379 first_folder = m_project->mDisplays[display_index].GetFirstChildFolder();
3380
3381 /* Create extern screen list. */
3382 if (flow && SetOutFile(folder->output_filename))
3383 {
3384 info = folder->GetFirstChildWidget();
3385 while (info)
3386 {
3387 /* Get action target. */
3388 item = flow->GetFlowItem(info->app_name);
3389 if (item)
3390 {
3391 trigger = item->trigger_list;
3392 while (trigger)
3393 {
3394 int action_count = trigger->action_list.GetCount();
3395
3396 for (int action_index = 0; action_index < action_count; action_index++)
3397 {
3398 action = trigger->action_list[action_index];
3399
3400 /* Get action parent. */
3401 target_name.Format(_T("%d_"), display_index);
3402 target_name += action->parent_widget_name;
3403 if (!IsItemInArray<CString>(name_list, target_name))
3404 {
3405 name_list.Add(target_name);
3406 if (action->parent_show_child_widgets)
3407 {
3408 target = m_project->FindWidgetInfo(first_folder, item->screen_name, FALSE);
3409 target = m_project->FindWidgetInfo(target->GetChildWidgetInfo(), action->parent_widget_name, TRUE);
3410 }
3411 else
3412 {
3413 target = m_project->FindWidgetInfo(first_folder, action->parent_widget_name, FALSE);
3414 }
3415
3416 if (target)
3417 {
3418 parent_folder = m_project->FindParentFolderInfo(target);
3419 if (parent_folder->output_filename != folder->output_filename)
3420 {
3421 /* If target not in current file. extern it. */
3422 WriteExternWidget(target);
3423 }
3424 }
3425 }
3426
3427 /* Get action target. */
3428 target_name.Format(_T("%d_"), display_index);
3429 target_name += action->target_widget_name;
3430 if (!IsItemInArray<CString>(name_list, target_name))
3431 {
3432 name_list.Add(target_name);
3433
3434 if (action->target_show_child_widgets)
3435 {
3436 target = m_project->FindWidgetInfo(first_folder, item->screen_name, FALSE);
3437 target = m_project->FindWidgetInfo(target->GetChildWidgetInfo(), action->target_widget_name, TRUE);
3438 }
3439 else
3440 {
3441 target = m_project->FindWidgetInfo(first_folder, action->target_widget_name, FALSE);
3442 }
3443
3444 if (target)
3445 {
3446 parent_folder = m_project->FindParentFolderInfo(target);
3447 if (parent_folder->output_filename != folder->output_filename)
3448 {
3449 /* If target not in current file. extern it. */
3450 WriteExternWidget(target);
3451 }
3452 }
3453 }
3454 }
3455 trigger = trigger->next;
3456 }
3457 }
3458 info = info->GetNextWidgetInfo();
3459 }
3460 }
3461 }
3462
3463 ///////////////////////////////////////////////////////////////////////////////
WriteExternWidget(widget_info * & info)3464 void screen_generator::WriteExternWidget(widget_info *&info)
3465 {
3466 CString out;
3467 /* Upper for extern control block. */
3468 CString upper_name = m_screen_name_prefix + info->app_name;
3469 upper_name.MakeUpper();
3470
3471 /* extern window define. */
3472 if (m_project->mHeader.guix_version < 50100)
3473 {
3474 out.Format(_T("extern GX_CONST GX_STUDIO_WIDGET %s_define;\n"), info->app_name);
3475 FileWrite(out);
3476 out.Format(_T("extern %s_CONTROL_BLOCK %s;\n"), upper_name, info->app_name);
3477 FileWrite(out);
3478 }
3479 else
3480 {
3481 out.Format(_T("extern GX_CONST GX_STUDIO_WIDGET %s%s_define;\n"), m_screen_name_prefix, info->app_name);
3482 FileWrite(out);
3483 if (info->allocation == STATICALLY_ALLOCATED && (!info->is_template))
3484 {
3485 out.Format(_T("extern %s_CONTROL_BLOCK %s%s;\n"), upper_name, m_screen_name_prefix, info->app_name);
3486 FileWrite(out);
3487 }
3488 }
3489 }
3490
3491 ///////////////////////////////////////////////////////////////////////////////////////////
3492 // This function externs the widgets that are written to custom output files
3493 // to the default output file, so that we can build the widget table in the default output
3494 // file.
3495 //
WriteExternWidgetsToDefaultFile()3496 void screen_generator::WriteExternWidgetsToDefaultFile()
3497 {
3498 int display;
3499 folder_info *folder;
3500 widget_info *info;
3501 CFile *testfile;
3502
3503 /* First, write extern list for default file, which is used by widget table. */
3504 if (SetOutFile(CString("")))
3505 {
3506 m_screen_name_prefix = _T("");
3507
3508 for (display = 0; display < m_project->mHeader.num_displays; display++)
3509 {
3510 if (m_project->mHeader.num_displays > 1)
3511 {
3512 m_screen_name_prefix = m_project->mDisplays[display].name + _T("_");
3513 }
3514
3515 folder = m_project->mDisplays[display].GetFirstChildFolder();
3516 testfile = output_file_list.GetAt(0);
3517
3518 if (!testfile)
3519 {
3520 return;
3521 }
3522
3523 CString default_filename = testfile->GetFileName();
3524 CString folder_filename;
3525
3526 while (folder)
3527 {
3528 if (!folder->output_filename.IsEmpty())
3529 {
3530 folder_filename = folder->output_filename + _T(".c");
3531 if (folder_filename != default_filename)
3532 {
3533 info = folder->GetFirstChildWidget();
3534 while (info)
3535 {
3536 WriteExternWidget(info);
3537 info = info->GetNextWidgetInfo();
3538 }
3539 }
3540 }
3541 folder = folder->GetNextFolder();
3542 }
3543 }
3544 }
3545 }
3546
3547 ///////////////////////////////////////////////////////////////////////////////
WriteExternWidgetsUsedByScreenFlow()3548 void screen_generator::WriteExternWidgetsUsedByScreenFlow()
3549 {
3550 // extern widgets that needed by screen flows
3551
3552 folder_info *folder;
3553 CArray<folder_info *> written_folder_list;
3554 BOOL completed = FALSE;
3555 CString current_output_filename;
3556 CFile *default_file = output_file_list.GetAt(0);
3557
3558 if (!default_file)
3559 {
3560 return;
3561 }
3562
3563 // get default specification file name
3564 CString default_filename = default_file->GetFileName();
3565 CString custom_filename;
3566
3567 while (!completed)
3568 {
3569 completed = TRUE;
3570 name_list.RemoveAll();
3571 current_output_filename.Empty();
3572 m_screen_name_prefix = _T("");
3573
3574 for (int display = 0; display < m_project->mHeader.num_displays; display++)
3575 {
3576 if (m_project->mHeader.num_displays > 1)
3577 {
3578 m_screen_name_prefix = m_project->mDisplays[display].name + _T("_");
3579 }
3580
3581 folder = m_project->mDisplays[display].GetFirstChildFolder();
3582
3583 while (folder)
3584 {
3585 if (folder->output_filename.IsEmpty())
3586 {
3587 custom_filename = default_filename;
3588 }
3589 else
3590 {
3591 custom_filename = folder->output_filename + _T(".c");
3592 }
3593
3594 if ((custom_filename != default_filename) &&
3595 !IsItemInArray<folder_info *>(written_folder_list, folder))
3596 {
3597 // test folder that has custom output specification name.
3598
3599 if (current_output_filename.IsEmpty())
3600 {
3601 // set current output filename
3602 current_output_filename = folder->output_filename;
3603 }
3604
3605 if (folder->output_filename == current_output_filename)
3606 {
3607 // extern widgets that used by screen flows
3608 // owned by widgets under all folders that has the same output filename.
3609 WriteExternWidgetsUsedByScreenFlow(folder, display);
3610 written_folder_list.Add(folder);
3611 }
3612 else
3613 {
3614 // still need to check from first folder
3615 completed = FALSE;
3616 }
3617 }
3618
3619 folder = folder->GetNextFolder();
3620 }
3621 }
3622 }
3623 }
3624
3625 ///////////////////////////////////////////////////////////////////////////////
DeclareControlBlocks()3626 void screen_generator::DeclareControlBlocks()
3627 {
3628 m_screen_name_prefix = _T("");
3629
3630 for (int display = 0; display < m_project->mHeader.num_displays; display++)
3631 {
3632 if (m_project->mHeader.num_displays > 1)
3633 {
3634 m_screen_name_prefix = m_project->mDisplays[display].name + _T("_");
3635 }
3636 folder_info *folder = m_project->mDisplays[display].GetFirstChildFolder();
3637
3638 while (folder)
3639 {
3640 /* Check file. */
3641 if (SetOutFile(folder->output_filename))
3642 {
3643 DeclareControlBlocks(folder->GetFirstChildWidget());
3644 }
3645 folder = folder->GetNextFolder();
3646 }
3647 }
3648 }
3649
3650 ///////////////////////////////////////////////////////////////////////////////
DeclareControlBlocks(widget_info * info)3651 void screen_generator::DeclareControlBlocks(widget_info *info)
3652 {
3653 CString out;
3654 widget_info *current = info;
3655
3656 while(current)
3657 {
3658 CString upper_name = m_screen_name_prefix + current->app_name;
3659 upper_name.MakeUpper();
3660
3661 if (m_project->mHeader.guix_version < 50100)
3662 {
3663 out.Format(_T("%s_CONTROL_BLOCK %s;\n"), upper_name, current->app_name);
3664 FileWrite(out);
3665 }
3666 else
3667 {
3668 if (current->allocation == STATICALLY_ALLOCATED &&
3669 !current->is_template)
3670 {
3671 out.Format(_T("%s_CONTROL_BLOCK %s%s;\n"), upper_name, m_screen_name_prefix, current->app_name);
3672 FileWrite(out);
3673 }
3674 }
3675 current = current->GetNextWidgetInfo();
3676 }
3677
3678 /* forward reference for dynamically allocated control blocks */
3679 current = info;
3680
3681 while(current)
3682 {
3683 if (current->allocation != STATICALLY_ALLOCATED &&
3684 !current->is_template)
3685 {
3686 out.Format(_T("GX_CONST GX_STUDIO_WIDGET %s%s_define;\n"), m_screen_name_prefix, current->app_name);
3687 FileWrite(out);
3688 }
3689 current = current->GetNextWidgetInfo();
3690 }
3691 }
3692
3693 char *widget_loaders_542 = "\n"
3694
3695
3696
3697 "static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
3698 "{\n"
3699 " UINT status = GX_SUCCESS;\n"
3700 " GX_WIDGET *widget = GX_NULL;\n"
3701 " GX_VALUE list_count = 0;\n"
3702 " GX_VALUE list_total_count = 0;\n"
3703 "\n"
3704 " if(parent && (parent->gx_widget_type == GX_TYPE_MENU))\n"
3705 " {\n"
3706 " list_total_count = ((GX_MENU *)parent)->gx_menu_list_total_count;\n"
3707 " }\n"
3708 "\n"
3709 " while(definition && status == GX_SUCCESS)\n"
3710 " {\n"
3711 " if (definition->create_function)\n"
3712 " {\n"
3713 " if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)\n"
3714 " {\n"
3715 " status = gx_widget_allocate(&widget, definition->control_block_size);\n"
3716 " if (status != GX_SUCCESS)\n"
3717 " {\n"
3718 " return GX_NULL;\n"
3719 " }\n"
3720 " }\n"
3721 " else\n"
3722 " {\n"
3723 " if (control == GX_NULL)\n"
3724 " {\n"
3725 " return GX_NULL;\n"
3726 " }\n"
3727 " widget = (GX_WIDGET *) (control + definition->control_block_offset);\n"
3728 " }\n"
3729 "\n"
3730 " status = definition->create_function(definition, widget, parent);\n"
3731 "\n"
3732 " if(list_count < list_total_count)\n"
3733 " {\n"
3734 " gx_menu_insert((GX_MENU *)parent, widget);\n"
3735 " ((GX_MENU *)parent)->gx_menu_list_total_count--;\n"
3736 " list_count++;\n"
3737 " }\n"
3738 "\n"
3739 " if (status == GX_SUCCESS)\n"
3740 " {\n"
3741 " if (definition->widget_type != GX_TYPE_TEMPLATE)\n"
3742 " {\n"
3743 "#if defined(GUIX_5_4_0_COMPATIBILITY)\n"
3744 " gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);\n"
3745 "#else\n"
3746 " gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id, definition->disabled_fill_color_id);\n"
3747 "#endif\n"
3748 " }\n"
3749 "\n"
3750 " if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))\n"
3751 " {\n"
3752 " gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);\n"
3753 " }\n"
3754 "\n"
3755 " if (definition->draw_function)\n"
3756 " {\n"
3757 " gx_widget_draw_set(widget, definition->draw_function);\n"
3758 " }\n"
3759 " if (definition->event_function)\n"
3760 " {\n"
3761 " gx_widget_event_process_set(widget, definition->event_function);\n"
3762 " }\n"
3763 "\n"
3764 " #if defined(GX_WIDGET_USER_DATA)\n"
3765 " widget->gx_widget_user_data = definition->user_data;\n"
3766 " #endif\n"
3767 "\n"
3768 " if (definition->child_widget)\n"
3769 " {\n"
3770 " gx_studio_nested_widget_create(control, definition->child_widget, widget);\n"
3771 " }\n"
3772 " }\n"
3773 " definition = definition->next_widget;\n"
3774 " }\n"
3775 " }\n"
3776 " return widget;\n"
3777 "}\n"
3778 "\n"
3779 "GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
3780 "{\n"
3781 " GX_WIDGET *widget;\n"
3782 " widget = gx_studio_nested_widget_create(control, definition, GX_NULL);\n"
3783 "\n"
3784 " if (parent && widget)\n"
3785 " {\n"
3786 " gx_widget_attach(parent, widget);\n"
3787 " }\n"
3788 " return widget;\n"
3789 "}\n"
3790 "\n"
3791 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)\n"
3792 "{\n"
3793 " UINT status = GX_FAILURE;\n"
3794 " GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = %s_widget_table;\n"
3795 " GX_WIDGET *widget = GX_NULL;\n"
3796 "\n"
3797 " while(entry->widget_information)\n"
3798 " {\n"
3799 " if (!strcmp(name, entry->widget_information->widget_name))\n"
3800 " {\n"
3801 " widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);\n"
3802 " if (widget)\n"
3803 " {\n"
3804 " status = GX_SUCCESS;\n"
3805 " }\n"
3806 " break;\n"
3807 " }\n"
3808 " entry++;\n"
3809 " }\n"
3810 "\n"
3811 " if (new_widget)\n"
3812 " {\n"
3813 " *new_widget = widget;\n"
3814 " }\n"
3815 " return status;\n"
3816 "}\n\n";
3817
3818 char *widget_loaders_54 = "\n"
3819
3820
3821
3822 "static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
3823 "{\n"
3824 " UINT status = GX_SUCCESS;\n"
3825 " GX_WIDGET *widget = GX_NULL;\n"
3826 " GX_VALUE list_count = 0;\n"
3827 " GX_VALUE list_total_count = 0;\n"
3828 "\n"
3829 " if(parent && (parent->gx_widget_type == GX_TYPE_MENU))\n"
3830 " {\n"
3831 " list_total_count = ((GX_MENU *)parent)->gx_menu_list_total_count;\n"
3832 " }\n"
3833 "\n"
3834 " while(definition && status == GX_SUCCESS)\n"
3835 " {\n"
3836 " if (definition->create_function)\n"
3837 " {\n"
3838 " if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)\n"
3839 " {\n"
3840 " status = gx_widget_allocate(&widget, definition->control_block_size);\n"
3841 " if (status != GX_SUCCESS)\n"
3842 " {\n"
3843 " return GX_NULL;\n"
3844 " }\n"
3845 " }\n"
3846 " else\n"
3847 " {\n"
3848 " if (control == GX_NULL)\n"
3849 " {\n"
3850 " return GX_NULL;\n"
3851 " }\n"
3852 " widget = (GX_WIDGET *) (control + definition->control_block_offset);\n"
3853 " }\n"
3854 "\n"
3855 " status = definition->create_function(definition, widget, parent);\n"
3856 "\n"
3857 " if(list_count < list_total_count)\n"
3858 " {\n"
3859 " gx_menu_insert((GX_MENU *)parent, widget);\n"
3860 " ((GX_MENU *)parent)->gx_menu_list_total_count--;\n"
3861 " list_count++;\n"
3862 " }\n"
3863 "\n"
3864 " if (status == GX_SUCCESS)\n"
3865 " {\n"
3866 " if (definition->widget_type != GX_TYPE_TEMPLATE)\n"
3867 " {\n"
3868 " gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);\n"
3869 " }\n"
3870 "\n"
3871 " if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))\n"
3872 " {\n"
3873 " gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);\n"
3874 " }\n"
3875 "\n"
3876 " if (definition->draw_function)\n"
3877 " {\n"
3878 " gx_widget_draw_set(widget, definition->draw_function);\n"
3879 " }\n"
3880 " if (definition->event_function)\n"
3881 " {\n"
3882 " gx_widget_event_process_set(widget, definition->event_function);\n"
3883 " }\n"
3884 "\n"
3885 " #if defined(GX_WIDGET_USER_DATA)\n"
3886 " widget->gx_widget_user_data = definition->user_data;\n"
3887 " #endif\n"
3888 "\n"
3889 " if (definition->child_widget)\n"
3890 " {\n"
3891 " gx_studio_nested_widget_create(control, definition->child_widget, widget);\n"
3892 " }\n"
3893 " }\n"
3894 " definition = definition->next_widget;\n"
3895 " }\n"
3896 " }\n"
3897 " return widget;\n"
3898 "}\n"
3899 "\n"
3900 "GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
3901 "{\n"
3902 " GX_WIDGET *widget;\n"
3903 " widget = gx_studio_nested_widget_create(control, definition, GX_NULL);\n"
3904 "\n"
3905 " if (parent && widget)\n"
3906 " {\n"
3907 " gx_widget_attach(parent, widget);\n"
3908 " }\n"
3909 " return widget;\n"
3910 "}\n"
3911 "\n"
3912 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)\n"
3913 "{\n"
3914 " UINT status = GX_FAILURE;\n"
3915 " GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = %s_widget_table;\n"
3916 " GX_WIDGET *widget = GX_NULL;\n"
3917 "\n"
3918 " while(entry->widget_information)\n"
3919 " {\n"
3920 " if (!strcmp(name, entry->widget_information->widget_name))\n"
3921 " {\n"
3922 " widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);\n"
3923 " if (widget)\n"
3924 " {\n"
3925 " status = GX_SUCCESS;\n"
3926 " }\n"
3927 " break;\n"
3928 " }\n"
3929 " entry++;\n"
3930 " }\n"
3931 "\n"
3932 " if (new_widget)\n"
3933 " {\n"
3934 " *new_widget = widget;\n"
3935 " }\n"
3936 " return status;\n"
3937 "}\n\n";
3938
3939 char *widget_loaders_53 = "\n"
3940
3941
3942
3943 "static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
3944 "{\n"
3945 " UINT status = GX_SUCCESS;\n"
3946 " GX_WIDGET *widget = GX_NULL;\n"
3947 "\n"
3948 " while(definition && status == GX_SUCCESS)\n"
3949 " {\n"
3950 " if (definition->create_function)\n"
3951 " {\n"
3952 " if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)\n"
3953 " {\n"
3954 " status = gx_widget_allocate(&widget, definition->control_block_size);\n"
3955 " if (status != GX_SUCCESS)\n"
3956 " {\n"
3957 " return GX_NULL;\n"
3958 " }\n"
3959 " }\n"
3960 " else\n"
3961 " {\n"
3962 " if (control == GX_NULL)\n"
3963 " {\n"
3964 " return GX_NULL;\n"
3965 " }\n"
3966 " widget = (GX_WIDGET *) (control + definition->control_block_offset);\n"
3967 " }\n"
3968 "\n"
3969 " status = definition->create_function(definition, widget, parent);\n"
3970 "\n"
3971 " if (status == GX_SUCCESS)\n"
3972 " {\n"
3973 " if (definition->widget_type != GX_TYPE_TEMPLATE)\n"
3974 " {\n"
3975 " gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);\n"
3976 " }\n"
3977 "\n"
3978 " if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))\n"
3979 " {\n"
3980 " gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);\n"
3981 " }\n"
3982 "\n"
3983 " if (definition->draw_function)\n"
3984 " {\n"
3985 " gx_widget_draw_set(widget, definition->draw_function);\n"
3986 " }\n"
3987 " if (definition->event_function)\n"
3988 " {\n"
3989 " gx_widget_event_process_set(widget, definition->event_function);\n"
3990 " }\n"
3991 "\n"
3992 " #if defined(GX_WIDGET_USER_DATA)\n"
3993 " widget->gx_widget_user_data = definition->user_data;\n"
3994 " #endif\n"
3995 "\n"
3996 " if (definition->child_widget)\n"
3997 " {\n"
3998 " gx_studio_nested_widget_create(control, definition->child_widget, widget);\n"
3999 " }\n"
4000 " }\n"
4001 " definition = definition->next_widget;\n"
4002 " }\n"
4003 " }\n"
4004 " return widget;\n"
4005 "}\n"
4006 "\n"
4007 "GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
4008 "{\n"
4009 " GX_WIDGET *widget;\n"
4010 " widget = gx_studio_nested_widget_create(control, definition, GX_NULL);\n"
4011 "\n"
4012 " if (parent && widget)\n"
4013 " {\n"
4014 " gx_widget_attach(parent, widget);\n"
4015 " }\n"
4016 " return widget;\n"
4017 "}\n"
4018 "\n"
4019 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)\n"
4020 "{\n"
4021 " UINT status = GX_FAILURE;\n"
4022 " GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = %s_widget_table;\n"
4023 " GX_WIDGET *widget = GX_NULL;\n"
4024 "\n"
4025 " while(entry->widget_information)\n"
4026 " {\n"
4027 " if (!strcmp(name, entry->widget_information->widget_name))\n"
4028 " {\n"
4029 " widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);\n"
4030 " if (widget)\n"
4031 " {\n"
4032 " status = GX_SUCCESS;\n"
4033 " }\n"
4034 " break;\n"
4035 " }\n"
4036 " entry++;\n"
4037 " }\n"
4038 "\n"
4039 " if (new_widget)\n"
4040 " {\n"
4041 " *new_widget = widget;\n"
4042 " }\n"
4043 " return status;\n"
4044 "}\n\n";
4045
4046 char *widget_loaders_52 = "\n"
4047 "GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
4048 "{\n"
4049 " UINT status = GX_SUCCESS;\n"
4050 " GX_WIDGET *widget = GX_NULL;\n"
4051 "\n"
4052 " while(definition && status == GX_SUCCESS)\n"
4053 " {\n"
4054 " if (definition->create_function)\n"
4055 " {\n"
4056 " if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)\n"
4057 " {\n"
4058 " status = gx_widget_allocate(&widget, definition->control_block_size);\n"
4059 " if (status != GX_SUCCESS)\n"
4060 " {\n"
4061 " return GX_NULL;\n"
4062 " }\n"
4063 " }\n"
4064 " else\n"
4065 " {\n"
4066 " if(!control)\n"
4067 " {\n"
4068 " return GX_NULL;\n"
4069 " }\n"
4070 "\n"
4071 " widget = (GX_WIDGET *) (control + definition->control_block_offset);\n"
4072 " }\n"
4073 "\n"
4074 " status = definition->create_function(definition, widget, parent);\n"
4075 "\n"
4076 " if (status == GX_SUCCESS)\n"
4077 " {\n"
4078 " gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);\n"
4079 "\n"
4080 " if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))\n"
4081 " {\n"
4082 " gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);\n"
4083 " }\n"
4084 "\n"
4085 " if (definition->draw_function)\n"
4086 " {\n"
4087 " gx_widget_draw_set(widget, definition->draw_function);\n"
4088 " }\n"
4089 " if (definition->event_function)\n"
4090 " {\n"
4091 " gx_widget_event_process_set(widget, definition->event_function);\n"
4092 " }\n"
4093 "\n"
4094 " #if defined(GX_WIDGET_USER_DATA)\n"
4095 " widget->gx_widget_user_data = definition->user_data;\n"
4096 " #endif\n"
4097 "\n"
4098 " if (definition->child_widget)\n"
4099 " {\n"
4100 " gx_studio_widget_create(control, definition->child_widget, widget);\n"
4101 " }\n"
4102 " }\n"
4103 " definition = definition->next_widget;\n"
4104 " }\n"
4105 " }\n"
4106 " return widget;\n"
4107 "}\n"
4108 "\n"
4109 "\n"
4110 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)\n"
4111 "{\n"
4112 " UINT status = GX_FAILURE;\n"
4113 " GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = %s_widget_table;\n"
4114 " GX_WIDGET *widget = GX_NULL;\n"
4115 "\n"
4116 " while(entry->widget_information)\n"
4117 " {\n"
4118 " if (!strcmp(name, entry->widget_information->widget_name))\n"
4119 " {\n"
4120 " widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);\n"
4121 " if (widget)\n"
4122 " {\n"
4123 " status = GX_SUCCESS;\n"
4124 " }\n"
4125 " break;\n"
4126 " }\n"
4127 " entry++;\n"
4128 " }\n"
4129 "\n"
4130 " if (new_widget)\n"
4131 " {\n"
4132 " *new_widget = widget;\n"
4133 " }\n"
4134 " return status;\n"
4135 "}\n"
4136 "\n";
4137
4138
4139 char *widget_loaders_525 = "\n"
4140 "GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
4141 "{\n"
4142 " UINT status = GX_SUCCESS;\n"
4143 " GX_WIDGET *widget = GX_NULL;\n"
4144 "\n"
4145 " while(definition && status == GX_SUCCESS)\n"
4146 " {\n"
4147 " if (definition->create_function)\n"
4148 " {\n"
4149 " if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)\n"
4150 " {\n"
4151 " status = gx_widget_allocate(&widget, definition->control_block_size);\n"
4152 " if (status != GX_SUCCESS)\n"
4153 " {\n"
4154 " return GX_NULL;\n"
4155 " }\n"
4156 " }\n"
4157 " else\n"
4158 " {\n"
4159 " if(!control)\n"
4160 " {\n"
4161 " return GX_NULL;\n"
4162 " }\n"
4163 "\n"
4164 " widget = (GX_WIDGET *) (control + definition->control_block_offset);\n"
4165 " }\n"
4166 "\n"
4167 " status = definition->create_function(definition, widget, parent);\n"
4168 "\n"
4169 " if (status == GX_SUCCESS)\n"
4170 " {\n"
4171 " gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);\n"
4172 "\n"
4173 " if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))\n"
4174 " {\n"
4175 " gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);\n"
4176 " }\n"
4177 "\n"
4178 " if (definition->draw_function)\n"
4179 " {\n"
4180 " gx_widget_draw_set(widget, definition->draw_function);\n"
4181 " }\n"
4182 " if (definition->event_function)\n"
4183 " {\n"
4184 " gx_widget_event_process_set(widget, definition->event_function);\n"
4185 " }\n"
4186 "\n"
4187 " if (definition->child_widget)\n"
4188 " {\n"
4189 " gx_studio_widget_create(control, definition->child_widget, widget);\n"
4190 " }\n"
4191 " }\n"
4192 " definition = definition->next_widget;\n"
4193 " }\n"
4194 " }\n"
4195 " return widget;\n"
4196 "}\n"
4197 "\n"
4198 "\n"
4199 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)\n"
4200 "{\n"
4201 " UINT status = GX_FAILURE;\n"
4202 " GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = %s_widget_table;\n"
4203 " GX_WIDGET *widget = GX_NULL;\n"
4204 "\n"
4205 " while(entry->widget_information)\n"
4206 " {\n"
4207 " if (!strcmp(name, entry->widget_information->widget_name))\n"
4208 " {\n"
4209 " widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);\n"
4210 " if (widget)\n"
4211 " {\n"
4212 " status = GX_SUCCESS;\n"
4213 " }\n"
4214 " break;\n"
4215 " }\n"
4216 " entry++;\n"
4217 " }\n"
4218 "\n"
4219 " if (new_widget)\n"
4220 " {\n"
4221 " *new_widget = widget;\n"
4222 " }\n"
4223 " return status;\n"
4224 "}\n"
4225 "\n";
4226
4227
4228 ///////////////////////////////////////////////////////////////////////////////
4229 char *widget_loaders_50 = "\n"
4230 "GX_WIDGET *gx_studio_widget_create(GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)\n"
4231 "{\n"
4232 " UINT status = GX_SUCCESS;\n"
4233 " GX_WIDGET *widget = GX_NULL;\n"
4234 "\n"
4235 " while(definition && status == GX_SUCCESS)\n"
4236 " {\n"
4237 " if (definition->create_function)\n"
4238 " {\n"
4239 " widget = definition->control_block;\n"
4240 " status = definition->create_function(definition, widget, parent);\n"
4241 "\n"
4242 " if (status == GX_SUCCESS)\n"
4243 " {\n"
4244 " gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);\n"
4245 "\n"
4246 " if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))\n"
4247 " {\n"
4248 " gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);\n"
4249 " }\n"
4250 "\n"
4251 " if (definition->draw_function)\n"
4252 " {\n"
4253 " gx_widget_draw_set(widget, definition->draw_function);\n"
4254 " }\n"
4255 " if (definition->event_function)\n"
4256 " {\n"
4257 " gx_widget_event_process_set(widget, definition->event_function);\n"
4258 " }\n"
4259 " if (definition->child_widget)\n"
4260 " {\n"
4261 " gx_studio_widget_create(definition->child_widget, widget);\n"
4262 " }\n"
4263 " }\n"
4264 " }\n"
4265 " definition = definition->next_widget;\n"
4266 " }\n"
4267 " return widget;\n"
4268 "}\n"
4269
4270 "\n"
4271 "UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)\n"
4272 "{\n"
4273 " UINT status = GX_FAILURE;\n"
4274 " UINT index = 0;\n"
4275 " GX_STUDIO_WIDGET *entry;\n"
4276 " GX_WIDGET *control_block = GX_NULL;\n"
4277 "\n"
4278 " while(1)\n"
4279 " {\n"
4280 " entry = %s_widget_table[index];\n"
4281 " if (!entry)\n"
4282 " {\n"
4283 " break;\n"
4284 " }\n"
4285 " if (!strcmp(name, entry->widget_name))\n"
4286 " {\n"
4287 " control_block = gx_studio_widget_create(0, entry, parent);\n"
4288 " break;\n"
4289 " }\n"
4290 " index++;\n"
4291 " }\n"
4292 "\n"
4293 " if (new_widget)\n"
4294 " {\n"
4295 " *new_widget = control_block;\n"
4296 " }\n"
4297 " if (control_block != GX_NULL)\n"
4298 " {\n"
4299 " status = GX_SUCCESS;\n"
4300 " }\n"
4301 "\n"
4302 " return status;\n"
4303 "}\n"
4304 "\n";
4305
4306
4307 ///////////////////////////////////////////////////////////////////////////////
DeclareWidgetTable()4308 void screen_generator::DeclareWidgetTable()
4309 {
4310 CString out("");
4311 char *loader_string;
4312 int display;
4313 folder_info *folder;
4314 widget_info *info;
4315 CString display_name;
4316
4317 /* Define widget table. */
4318 if (m_project->mHeader.guix_version < 50100)
4319 {
4320 out.Format(_T("GX_STUDIO_WIDGET_ENTRY %s_widget_table[] =\n{\n"), m_project->mHeader.project_name);
4321 }
4322 else
4323 {
4324 out.Format(_T("GX_CONST GX_STUDIO_WIDGET_ENTRY %s_widget_table[] =\n{\n"), m_project->mHeader.project_name);
4325 }
4326 FileWrite(out);
4327
4328 for (display = 0; display < m_project->mHeader.num_displays; display++)
4329 {
4330 folder = m_project->mDisplays[display].GetFirstChildFolder();
4331
4332 display_name.Format(_T(""));
4333 if (m_project->mHeader.num_displays > 1)
4334 {
4335 display_name = m_project->mDisplays[display].name + _T("_");
4336 }
4337
4338 while (folder)
4339 {
4340 info = folder->GetFirstChildWidget();
4341 while (info)
4342 {
4343 if (m_project->mHeader.guix_version < 50100)
4344 {
4345 out.Format(_T(" { &%s_define, (GX_WIDGET *) &%s },\n"), info->app_name, info->app_name);
4346 FileWrite(out);
4347 }
4348 else
4349 {
4350 if (info->is_template == FALSE)
4351 {
4352 if (info->allocation == STATICALLY_ALLOCATED)
4353 {
4354 out.Format(_T(" { &%s%s_define, (GX_WIDGET *) &%s%s },\n"), display_name, info->app_name, display_name, info->app_name);
4355 }
4356 else
4357 {
4358 out.Format(_T(" { &%s%s_define, GX_NULL },\n"), display_name, info->app_name);
4359 }
4360 FileWrite(out);
4361 }
4362 }
4363 info = info->GetNextWidgetInfo();
4364 }
4365 folder = folder->GetNextFolder();
4366 }
4367
4368 }
4369 FileWrite(CString(" {GX_NULL, GX_NULL}\n};\n"));
4370
4371 if (m_project->mHeader.guix_version < 50100)
4372 {
4373 loader_string = widget_loaders_50;
4374 }
4375 else
4376 {
4377 if (m_project->mHeader.guix_version < 50206)
4378 {
4379 loader_string = widget_loaders_525;
4380 }
4381 else if (m_project->mHeader.guix_version < 50300)
4382 {
4383 loader_string = widget_loaders_52;
4384 }
4385 else if (m_project->mHeader.guix_version < 50400)
4386 {
4387 loader_string = widget_loaders_53;
4388 }
4389 else if (m_project->mHeader.guix_version < 50402)
4390 {
4391 loader_string = widget_loaders_54;
4392 }
4393 else
4394 {
4395 loader_string = widget_loaders_542;
4396 }
4397 }
4398 out.Format(CA2T(loader_string), m_project->mHeader.project_name, m_project->mHeader.project_name);
4399 FileWrite(out);
4400 }
4401
4402 ///////////////////////////////////////////////////////////////////////////////
CalculateCanvasSizeBytes(int display)4403 ULONG screen_generator::CalculateCanvasSizeBytes(int display)
4404 {
4405 ULONG bytes = m_project->mDisplays[display].xres;
4406
4407 switch(m_project->mDisplays[display].bits_per_pix)
4408 {
4409 case 1:
4410 bytes += 7;
4411 bytes /= 8;
4412 break;
4413
4414 case 2:
4415 bytes += 3;
4416 bytes /= 4;
4417 break;
4418
4419 case 4:
4420 bytes++;
4421 bytes /= 2;
4422 break;
4423
4424 case 8:
4425 break;
4426
4427 case 16:
4428 bytes *= 2;
4429 break;
4430
4431 case 24:
4432 //bytes *= 3;
4433 // for now only supporting unpacked format:
4434 bytes *= 4;
4435 break;
4436
4437 case 32:
4438 bytes *= 4;
4439 break;
4440 }
4441 bytes *= m_project->mDisplays[display].yres;
4442 return bytes;
4443 }
4444
4445 ///////////////////////////////////////////////////////////////////////////////
DeclareDisplayTable()4446 void screen_generator::DeclareDisplayTable()
4447 {
4448 CString out;
4449
4450 int display;
4451 int xres;
4452 int yres;
4453 CString display_name;
4454 CString upper_display_name;
4455 CString theme_table_name;
4456 CString language_table_name;
4457 CString language_direction_table_name;
4458 CString theme_table_size;
4459 CString language_table_size;
4460 CString string_table_size;
4461
4462 CCommandInfo *pCmdInfo = GetCmdInfo();
4463
4464 for (display = 0; display < m_project->mHeader.num_displays; display++)
4465 {
4466 display_name = m_project->mDisplays[display].name;
4467
4468 if (m_project->CountStaticallyDefinedThemes(display))
4469 {
4470 out.Format(_T("extern GX_CONST GX_THEME *%s_theme_table[];\n"), display_name);
4471 FileWrite(out);
4472 }
4473
4474
4475 if (m_project->CountStaticallyDefinedLanguages())
4476 {
4477 if (project_lib_version() < GX_VERSION_STRING_LENGTH_FIX)
4478 {
4479 out.Format(_T("extern GX_CONST GX_CHAR **%s_language_table[];\n"), display_name);
4480 }
4481 else
4482 {
4483 out.Format(_T("extern GX_CONST GX_STRING *%s_language_table[];\n"), display_name);
4484 }
4485
4486 FileWrite(out);
4487
4488 if (string_table::TestGenerateLanguageDirectionTable())
4489 {
4490 out.Format(_T("extern GX_CONST GX_UBYTE %s_language_direction_table[];\n"), display_name);
4491 FileWrite(out);
4492 }
4493 }
4494 }
4495
4496 out.Format(_T("\nGX_STUDIO_DISPLAY_INFO %s_display_table[%d] =\n{\n"), m_project->mHeader.project_name, m_project->mHeader.num_displays);
4497 FileWrite(out);
4498
4499 for (display = 0; display < m_project->mHeader.num_displays; display++)
4500 {
4501 display_name = m_project->mDisplays[display].name;
4502 upper_display_name = display_name;
4503 upper_display_name.MakeUpper();
4504
4505 xres = m_project->mDisplays[display].xres;
4506 yres = m_project->mDisplays[display].yres;
4507
4508 if (m_project->mDisplays[display].rotation_angle == GX_SCREEN_ROTATION_CW ||
4509 m_project->mDisplays[display].rotation_angle == GX_SCREEN_ROTATION_CCW)
4510 {
4511 GX_SWAP_VALS(xres, yres);
4512 }
4513
4514 if (m_project->mHeader.guix_version <= 50302)
4515 {
4516 out.Format(_T(" {\n")
4517 _T(" \"%s\",\n")
4518 _T(" \"%s_canvas\",\n")
4519 _T(" %s_theme_table,\n")
4520 _T(" %s_language_table,\n")
4521 _T(" %s_LANGUAGE_TABLE_SIZE,\n")
4522 _T(" %s_STRING_TABLE_SIZE,\n")
4523 _T(" %d, /* x resolution */\n")
4524 _T(" %d, /* y resolution */\n")
4525 _T(" &%s_control_block,\n")
4526 _T(" &%s_canvas_control_block,\n")
4527 _T(" &%s_root_window,\n"),
4528 display_name,
4529 display_name,
4530 display_name,
4531 display_name,
4532 upper_display_name,
4533 upper_display_name,
4534 xres,
4535 yres,
4536 display_name,
4537 display_name,
4538 display_name);
4539 }
4540 else
4541 {
4542 if (m_project->CountStaticallyDefinedThemes(display))
4543 {
4544 theme_table_name.Format(_T("%s_theme_table"), display_name);
4545 theme_table_size.Format(_T("%s_THEME_TABLE_SIZE"), upper_display_name);
4546 }
4547 else
4548 {
4549 theme_table_name = _T("GX_NULL");
4550 theme_table_size = _T("0");
4551 }
4552
4553 if (m_project->CountStaticallyDefinedLanguages())
4554 {
4555 language_table_name.Format(_T("%s_language_table"), display_name);
4556 language_table_size.Format(_T("%s_LANGUAGE_TABLE_SIZE"), upper_display_name);
4557 string_table_size.Format(_T("%s_STRING_TABLE_SIZE"), upper_display_name);
4558 }
4559 else
4560 {
4561 language_table_name = _T("GX_NULL");
4562 language_table_size = _T("0");
4563 string_table_size = _T("0");
4564 }
4565
4566 if (string_table::TestGenerateLanguageDirectionTable())
4567 {
4568 language_direction_table_name.Format(_T(" %s_language_direction_table,\n"), display_name);
4569 }
4570 else
4571 {
4572 language_direction_table_name = _T("");
4573 }
4574
4575 if (m_project->mHeader.guix_version < GX_VERSION_STRING_LENGTH_FIX)
4576 {
4577 out.Format(_T(" {\n")
4578 _T(" \"%s\",\n")
4579 _T(" \"%s_canvas\",\n")
4580 _T(" %s,\n")
4581 _T(" %s,\n")
4582 _T(" %s,\n")
4583 _T(" %s,\n")
4584 _T(" %s,\n")
4585 _T(" %d, /* x resolution */\n")
4586 _T(" %d, /* y resolution */\n")
4587 _T(" &%s_control_block,\n")
4588 _T(" &%s_canvas_control_block,\n")
4589 _T(" &%s_root_window,\n"),
4590 display_name,
4591 display_name,
4592 theme_table_name,
4593 language_table_name,
4594 theme_table_size,
4595 language_table_size,
4596 string_table_size,
4597 xres,
4598 yres,
4599 display_name,
4600 display_name,
4601 display_name);
4602 }
4603 else
4604 {
4605 out.Format(_T(" {\n")
4606 _T(" \"%s\",\n")
4607 _T(" \"%s_canvas\",\n")
4608 _T(" %s,\n")
4609 _T(" %s,\n")
4610 _T("%s")
4611 _T(" %s,\n")
4612 _T(" %s,\n")
4613 _T(" %s,\n")
4614 _T(" %d, /* x resolution */\n")
4615 _T(" %d, /* y resolution */\n")
4616 _T(" &%s_control_block,\n")
4617 _T(" &%s_canvas_control_block,\n")
4618 _T(" &%s_root_window,\n"),
4619 display_name,
4620 display_name,
4621 theme_table_name,
4622 language_table_name,
4623 language_direction_table_name,
4624 theme_table_size,
4625 language_table_size,
4626 string_table_size,
4627 xres,
4628 yres,
4629 display_name,
4630 display_name,
4631 display_name);
4632 }
4633 }
4634
4635 FileWrite(out);
4636
4637 if (m_project->mDisplays[display].allocate_canvas)
4638 {
4639 out.Format(_T(" %s_canvas_memory, /* canvas memory area */\n"),
4640 display_name);
4641 FileWrite(out);
4642 }
4643 else
4644 {
4645 FileWrite(CString(" GX_NULL, /* canvas memory area */\n"));
4646 }
4647
4648 if (project_lib_version() >= GX_VERSION_DISPLAY_ROTATION)
4649 {
4650 CString rotation;
4651 switch (m_project->mDisplays[display].rotation_angle)
4652 {
4653 case GX_SCREEN_ROTATION_CW:
4654 rotation = _T("GX_SCREEN_ROTATION_CW");
4655 break;
4656
4657 case GX_SCREEN_ROTATION_CCW:
4658 rotation = _T("GX_SCREEN_ROTATION_CCW");
4659 break;
4660
4661 case GX_SCREEN_ROTATION_FLIP:
4662 if (project_lib_version() >= GX_VERSION_SCREEN_ROTATION_DEFS)
4663 {
4664 rotation = _T("GX_SCREEN_ROTATION_FLIP");
4665 }
4666 else
4667 {
4668 rotation = _T("180");
4669 }
4670 break;
4671
4672 default:
4673 if (project_lib_version() >= GX_VERSION_SCREEN_ROTATION_DEFS)
4674 {
4675 rotation = _T("GX_SCREEN_ROTATION_NONE");
4676 }
4677 else
4678 {
4679 rotation = _T("0");
4680 }
4681 break;
4682 }
4683 out.Format(_T(" %d, /* canvas memory size in bytes */\n")
4684 _T(" %s /* rotation angle */\n")
4685 _T(" }"),
4686 CalculateCanvasSizeBytes(display), rotation);
4687 }
4688 else
4689 {
4690 out.Format(_T(" %d /* canvas memory size in bytes */\n")
4691 _T(" }"),
4692 CalculateCanvasSizeBytes(display));
4693 }
4694
4695 FileWrite(out);
4696 if (display < m_project->mHeader.num_displays - 1)
4697 {
4698 FileWrite(CString(",\n"));
4699 }
4700 else
4701 {
4702 FileWrite(CString("\n"));
4703 }
4704 }
4705 FileWrite(CString("};\n\n"));
4706 }
4707
4708 ///////////////////////////////////////////////////////////////////////////////
DeclareBaseMembers(widget_info * info)4709 void screen_generator::DeclareBaseMembers(widget_info *info)
4710 {
4711 CString out;
4712 CString upper_name;
4713 widget_service_provider *provider = widget_factory::GetServiceProvider(info->basetype);
4714
4715 if (provider)
4716 {
4717 if (info->basetype == GX_TYPE_TEMPLATE)
4718 {
4719 template_service_provider *tp = (template_service_provider *) provider;
4720 widget_info *base = tp->GetBaseInfo(info);
4721
4722 if (base)
4723 {
4724 /* declare an instance of the base control block type */
4725 upper_name = m_screen_name_prefix + base->app_name;
4726 upper_name.MakeUpper();
4727 out.Format(_T(" %s_CONTROL_BLOCK base;\n"), upper_name);
4728 FileWrite(out);
4729 }
4730 }
4731 else
4732 {
4733 out.Format(_T(" %s\n"), provider->GetVarDeclaration());
4734 FileWrite(out);
4735 }
4736 }
4737 }
4738
4739 ///////////////////////////////////////////////////////////////////////////////
DeclareChildMembers(CString & parent_name,widget_info * info)4740 void screen_generator::DeclareChildMembers(CString &parent_name, widget_info *info)
4741 {
4742 CString out;
4743
4744 while(info)
4745 {
4746 if (m_project->mHeader.guix_version < 50100 ||
4747 info->allocation == STATICALLY_ALLOCATED)
4748 {
4749 if (info->basetype == GX_TYPE_TEMPLATE)
4750 {
4751 CString cbname = m_screen_name_prefix + info->base_name;
4752 cbname.MakeUpper();
4753
4754 /* a child template. The control block type is app_name */
4755 out.Format(_T(" %s_CONTROL_BLOCK %s_%s;\n"), cbname, parent_name, info->app_name);
4756 FileWrite(out);
4757 }
4758 else
4759 {
4760 widget_service_provider *provider = widget_factory::GetServiceProvider(info->basetype);
4761
4762 if (provider)
4763 {
4764 out.Format(_T(" %s %s_%s;\n"), provider->GetControlBlockName(), parent_name, info->app_name);
4765 FileWrite(out);
4766 }
4767 }
4768 }
4769
4770 if (info->GetChildWidgetInfo())
4771 {
4772 DeclareChildMembers(parent_name, info->GetChildWidgetInfo());
4773 }
4774 info = info->GetNextWidgetInfo();
4775 }
4776 }
4777
4778
4779 ///////////////////////////////////////////////////////////////////////////////
WriteWidgetProperties(CString & prefix,widget_info * info,BOOL TopLevel)4780 void screen_generator::WriteWidgetProperties(CString &prefix, widget_info *info, BOOL TopLevel)
4781 {
4782 CString scope_name("");
4783
4784 if (TopLevel)
4785 {
4786 CString app_name = _T("_") + info->app_name;
4787 scope_name = prefix.Left(prefix.GetLength() - app_name.GetLength());
4788 }
4789 else
4790 {
4791 scope_name = prefix;
4792 }
4793
4794 while(info)
4795 {
4796 widget_service_provider *provider = widget_factory::GetServiceProvider(info->basetype);
4797
4798 if (provider)
4799 {
4800 CString write_string = provider->WriteExtendedProperties(this, scope_name, info);
4801 if (!write_string.IsEmpty())
4802 {
4803 FileWrite(write_string);
4804 }
4805 }
4806
4807 if (info->GetChildWidgetInfo())
4808 {
4809 WriteWidgetProperties(prefix, info->GetChildWidgetInfo());
4810 }
4811
4812 if (TopLevel)
4813 {
4814 info = NULL;
4815 }
4816 else
4817 {
4818 info = info->GetNextWidgetInfo();
4819 }
4820 }
4821 }
4822
4823 ///////////////////////////////////////////////////////////////////////////////
GetColorIdName(studiox_project * project,int display,int color_id)4824 CString screen_generator::GetColorIdName(studiox_project *project, int display, int color_id)
4825 {
4826 CString val("0");
4827
4828 int active_theme = project->mDisplays[display].active_theme;
4829 res_info *info = project->FindResource(display, active_theme, RES_TYPE_COLOR, color_id);
4830
4831 if (info)
4832 {
4833 CString upper_name("");
4834
4835 if (!info->is_default && project->mHeader.num_displays > 1)
4836 {
4837 upper_name += project ->mDisplays[display].name;
4838 upper_name += "_";
4839 }
4840 upper_name += info->name;
4841 upper_name.MakeUpper();
4842 val = CString("GX_COLOR_ID_") + upper_name;
4843 }
4844 return val;
4845 }
4846 ///////////////////////////////////////////////////////////////////////////////
GetColorIdName(int color_id) const4847 CString screen_generator::GetColorIdName(int color_id) const
4848 {
4849 return GetColorIdName(m_project, m_display, color_id);
4850 }
4851
4852 ///////////////////////////////////////////////////////////////////////////////
GetFontIdName(studiox_project * project,int display,int font_id)4853 CString screen_generator::GetFontIdName(studiox_project *project, int display, int font_id)
4854 {
4855 CString val("0");
4856 int active_theme = project->mDisplays[display].active_theme;
4857 res_info *info = project->FindResource(display, active_theme, RES_TYPE_FONT, font_id);
4858
4859 if (info)
4860 {
4861 CString upper_name("");
4862
4863 if (!info->is_default && project->mHeader.num_displays > 1)
4864 {
4865 upper_name += project ->mDisplays[display].name;
4866 upper_name += "_";
4867 }
4868 upper_name += info->name;
4869 upper_name.MakeUpper();
4870 val = CString("GX_FONT_ID_") + upper_name;
4871 }
4872 return val;
4873 }
4874 ///////////////////////////////////////////////////////////////////////////////
GetFontIdName(int font_id) const4875 CString screen_generator::GetFontIdName(int font_id) const
4876 {
4877 return GetFontIdName(m_project, m_display, font_id);
4878 }
4879
4880 ///////////////////////////////////////////////////////////////////////////////
GetPixelmapIdName(studiox_project * proj,int display,int pixelmap_id,int frame_id)4881 CString screen_generator::GetPixelmapIdName(studiox_project *proj, int display, int pixelmap_id, int frame_id)
4882 {
4883 CString val("0");
4884 if (proj)
4885 {
4886 int active_theme = proj->mDisplays[display].active_theme;
4887
4888 res_info *info = proj->FindResource(display, active_theme, RES_TYPE_PIXELMAP, pixelmap_id);
4889
4890 if (info)
4891 {
4892 CString upper_name("");
4893
4894 if (!info->is_default &&
4895 (proj->mHeader.num_displays > 1))
4896 {
4897 upper_name += proj->mDisplays[display].name;
4898 upper_name += "_";
4899 }
4900 upper_name += MakePixelmapName(info, frame_id);
4901 upper_name.MakeUpper();
4902 val = CString("GX_PIXELMAP_ID_") + upper_name;
4903 }
4904 }
4905 return val;
4906 }
4907
4908 ///////////////////////////////////////////////////////////////////////////////
GetString(int string_id,int language) const4909 CString screen_generator::GetString(int string_id, int language) const
4910 {
4911 string_table *table = m_project->mDisplays[m_display].stable;
4912
4913 if (table)
4914 {
4915 CString id_name = table->GetResourceIdName(string_id);
4916 return table->GetString(id_name, language);
4917 }
4918
4919 return _T("");
4920 }
4921
4922 ///////////////////////////////////////////////////////////////////////////////
GetPixelmapIdName(int pixelmap_id,int frame_id) const4923 CString screen_generator::GetPixelmapIdName(int pixelmap_id, int frame_id) const
4924 {
4925 return GetPixelmapIdName(m_project, m_display, pixelmap_id, frame_id);
4926 }
4927
4928 ///////////////////////////////////////////////////////////////////////////////
GetStringIdName(studiox_project * proj,int display,int string_id,widget_info * info)4929 CString screen_generator::GetStringIdName(studiox_project *proj, int display, int string_id, widget_info *info)
4930 {
4931 CString val("0");
4932
4933 if (string_id)
4934 {
4935 string_table *pt = proj->mDisplays[display].stable;
4936
4937 if (pt)
4938 {
4939 CString id_name = pt->GetResourceIdName(string_id, info);
4940
4941 if (!id_name.IsEmpty())
4942 {
4943 CString upper_name("");
4944
4945 if (proj->mHeader.num_displays > 1)
4946 {
4947 upper_name += proj->mDisplays[display].name;
4948 upper_name += "_";
4949 upper_name.MakeUpper();
4950 }
4951 upper_name += id_name;
4952
4953 val = CString("GX_STRING_ID_") + upper_name;
4954 }
4955 }
4956 }
4957 return val;
4958 }
4959
4960 ///////////////////////////////////////////////////////////////////////////////
GetStringIdName(int string_id,widget_info * info) const4961 CString screen_generator::GetStringIdName(int string_id, widget_info *info) const
4962 {
4963 return GetStringIdName(m_project, m_display, string_id, info);
4964 }
4965 ///////////////////////////////////////////////////////////////////////////////
IsWidgetUsed(widget_info * start,int type) const4966 BOOL screen_generator::IsWidgetUsed(widget_info *start, int type) const
4967 {
4968 BOOL status = FALSE;
4969 while(start)
4970 {
4971 if (start->basetype == type)
4972 {
4973 return TRUE;
4974 }
4975 if (start->GetChildWidgetInfo())
4976 {
4977 status = IsWidgetUsed(start->GetChildWidgetInfo(), type);
4978 if (status)
4979 {
4980 return status;
4981 }
4982 }
4983 start = start->GetNextWidgetInfo();
4984 }
4985 return FALSE;
4986 }
4987
4988
4989 ///////////////////////////////////////////////////////////////////////////////
IsWidgetUsed(int type) const4990 BOOL screen_generator::IsWidgetUsed(int type) const
4991 {
4992 int display;
4993
4994 for (display = 0; display < m_project->mHeader.num_displays; display++)
4995 {
4996 folder_info *info = m_project->mDisplays[display].GetFirstChildFolder();
4997
4998 while (info)
4999 {
5000 if (IsWidgetUsed(info->GetFirstChildWidget(), type))
5001 {
5002 return TRUE;
5003 }
5004 info = info->GetNextFolder();
5005
5006 }
5007 }
5008 return FALSE;
5009 }
5010
5011 ///////////////////////////////////////////////////////////////////////////////
WriteCreateFunctions()5012 void screen_generator::WriteCreateFunctions()
5013 {
5014 int index = 0;
5015 int version = m_project->mHeader.guix_version;
5016
5017 while(1)
5018 {
5019 int widget_type = widget_factory::GetWidgetType(index);
5020
5021 if (!widget_type)
5022 {
5023 break;
5024 }
5025 if (IsWidgetUsed(widget_type))
5026 {
5027 widget_service_provider *provider = widget_factory::GetServiceProvider(widget_type);
5028 if (provider)
5029 {
5030 FileWrite(provider->GetCreateFromDefFunction(version));
5031 }
5032 }
5033 index++;
5034 }
5035 }
5036
5037
5038 ///////////////////////////////////////////////////////////////////////////////
WriteDave2D8bppPaletteSetup()5039 void screen_generator::WriteDave2D8bppPaletteSetup()
5040 {
5041 CString out;
5042 CString toggle_func;
5043 /* perform standard GUIX setup */
5044
5045 if (IsRenesasDave2D(m_project))
5046 {
5047 toggle_func = " _gx_dave2d_buffer_toggle_8bpp);\n";
5048 }
5049 else
5050 {
5051 switch(m_project->mHeader.target_cpu)
5052 {
5053 case CPU_RA:
5054 toggle_func = " _gx_ra_buffer_toggle_8bpp);\n";
5055 break;
5056
5057 case CPU_RX:
5058 toggle_func = " _gx_rx_buffer_toggle_8bpp);\n";
5059 break;
5060
5061 default: // synergy
5062 toggle_func = " _gx_synergy_buffer_toggle_8bpp);\n";
5063 break;
5064 }
5065 }
5066 out = " _gx_display_driver_8bit_palette_setup(display, GX_NULL,";
5067 out += toggle_func;
5068
5069 out += " display->gx_display_handle = 0;\n";
5070 out += " display -> gx_display_driver_palette_set = _gx_display_driver_8bit_palette_assign;\n";
5071
5072 /* override drawing functions if using Dave2D accelerator */
5073
5074 if (IsRenesasDave2D(m_project))
5075 {
5076 out += " display -> gx_display_driver_drawing_initiate = _gx_dave2d_drawing_initiate_8bpp;\n";
5077 out += " display -> gx_display_driver_drawing_complete = _gx_dave2d_drawing_complete_8bpp;\n";
5078 out += " display -> gx_display_driver_horizontal_pattern_line_draw = _gx_dave2d_horizontal_pattern_line_draw_8bpp;\n";
5079 out += " display -> gx_display_driver_vertical_pattern_line_draw = _gx_dave2d_vertical_pattern_line_draw_8bpp;\n";
5080 out += " display -> gx_display_driver_pixel_write = _gx_dave2d_pixel_write_8bpp;\n";
5081 out += " display -> gx_display_driver_canvas_copy = _gx_dave2d_canvas_copy;\n";
5082 out += " display -> gx_display_driver_simple_line_draw = _gx_dave2d_simple_line_draw_8bpp;\n";
5083 out += " display -> gx_display_driver_horizontal_line_draw = _gx_dave2d_horizontal_line_8bpp;\n";
5084 out += " display -> gx_display_driver_vertical_line_draw = _gx_dave2d_vertical_line_8bpp;\n";
5085 out += " display -> gx_display_driver_polygon_draw = _gx_dave2d_polygon_draw_8bpp;\n";
5086 out += " display -> gx_display_driver_polygon_fill = _gx_dave2d_polygon_fill_8bpp;\n";
5087 out += " display -> gx_display_driver_block_move = _gx_dave2d_block_move_8bpp;\n";
5088 out += " display -> gx_display_driver_pixelmap_draw = _gx_dave2d_pixelmap_draw_8bpp;\n";
5089 out += " display -> gx_display_driver_simple_wide_line_draw = _gx_dave2d_simple_wide_line_8bpp;\n";
5090
5091 out += " display -> gx_display_driver_1bit_glyph_draw = _gx_dave2d_glyph_1bit_draw_8bpp;\n";
5092 if (project_lib_version() >= GX_VERSION_SYNERGY_GLYPH_GEN_CHANGE)
5093 {
5094 out += "#if(GX_PALETTE_MODE_AA_TEXT_COLORS == 8)\n";
5095 out += " display -> gx_display_driver_4bit_glyph_draw = _gx_dave2d_glyph_3bit_draw_8bpp;\n";
5096 out += "#else\n";
5097 }
5098 out += " display -> gx_display_driver_4bit_glyph_draw = _gx_dave2d_glyph_4bit_draw_8bpp;\n";
5099
5100 if (project_lib_version() >= GX_VERSION_SYNERGY_GLYPH_GEN_CHANGE)
5101 {
5102 out += "#endif\n";
5103 }
5104
5105 out += " #if defined(GX_ARC_DRAWING_SUPPORT)\n";
5106 out += " display -> gx_display_driver_circle_draw = _gx_dave2d_circle_draw_8bpp;\n";
5107 out += " display -> gx_display_driver_circle_fill = _gx_dave2d_circle_fill_8bpp;\n";
5108 out += " display -> gx_display_driver_pie_fill = _gx_dave2d_pie_fill_8bpp;\n";
5109 out += " display -> gx_display_driver_arc_draw = _gx_dave2d_arc_draw_8bpp;\n";
5110 out += " display -> gx_display_driver_arc_fill = _gx_dave2d_arc_fill_8bpp;\n";
5111 out += " display -> gx_display_driver_ellipse_draw = _gx_dave2d_ellipse_draw_8bpp;\n";
5112 out += " display -> gx_display_driver_ellipse_fill = _gx_dave2d_ellipse_fill_8bpp;\n";
5113 if (project_lib_version() > 50500)
5114 {
5115 out += " display -> gx_display_driver_wide_circle_draw = _gx_dave2d_circle_draw_8bpp;\n";
5116 out += " display -> gx_display_driver_wide_arc_draw = _gx_dave2d_arc_draw_8bpp;\n";
5117 out += " display -> gx_display_driver_wide_ellipse_draw = _gx_dave2d_wide_ellipse_draw_8bpp;\n";
5118 }
5119 out += " #endif\n";
5120 }
5121
5122 if (m_project->mHeader.renesas_jpeg_decoder == DECODER_TYPE_HW)
5123 {
5124 if (m_project->mHeader.target_cpu == CPU_SYNERGY)
5125 {
5126 out += " display -> gx_display_driver_jpeg_draw = _gx_synergy_jpeg_draw;\n";
5127 }
5128 else
5129 {
5130 out += " display -> gx_display_driver_jpeg_draw = _gx_renesas_jpeg_draw;\n";
5131 }
5132 }
5133 FileWrite(out);
5134 }
5135
5136 ///////////////////////////////////////////////////////////////////////////////
WriteDave2D8bppPaletteRotatedSetup()5137 void screen_generator::WriteDave2D8bppPaletteRotatedSetup()
5138 {
5139 CString out;
5140 CString toggle_func("");
5141
5142 /* perform standard GUIX setup */
5143
5144 if (IsRenesasDave2D(m_project))
5145 {
5146 toggle_func = " _gx_dave2d_rotated_buffer_toggle_8bpp);\n";
5147 }
5148 else
5149 {
5150 switch (m_project->mHeader.target_cpu)
5151 {
5152 case CPU_RA:
5153 toggle_func = " _gx_ra_rotated_buffer_toggle_8bpp);\n";
5154 break;
5155
5156 case CPU_RX:
5157 toggle_func = " _gx_rx_rotated_buffer_toggle_8bpp);\n";
5158 break;
5159
5160 default: // synergy
5161 toggle_func = " _gx_synergy_rotated_buffer_toggle_8bpp);\n";
5162 break;
5163 }
5164 }
5165
5166 out = " _gx_display_driver_8bit_palette_rotated_setup(display, GX_NULL,";
5167 out += toggle_func;
5168
5169 out += " display -> gx_display_handle = 0;\n";
5170 out += " display -> gx_display_driver_palette_set = _gx_display_driver_8bit_palette_assign;\n";
5171
5172 /* override drawing functions if using Dave2D accelerator */
5173
5174 if (IsRenesasDave2D(m_project))
5175 {
5176 out += " display -> gx_display_driver_drawing_initiate = _gx_dave2d_drawing_initiate_8bpp;\n";
5177 out += " display -> gx_display_driver_drawing_complete = _gx_dave2d_drawing_complete_8bpp;\n";
5178 out += " display -> gx_display_driver_horizontal_pattern_line_draw = _gx_dave2d_rotated_horizontal_pattern_line_draw_8bpp;\n";
5179 out += " display -> gx_display_driver_vertical_pattern_line_draw = _gx_dave2d_rotated_vertical_pattern_line_draw_8bpp;\n";
5180 out += " display -> gx_display_driver_pixel_write = _gx_dave2d_rotated_pixel_write_8bpp;\n";
5181 out += " display -> gx_display_driver_canvas_copy = _gx_dave2d_rotated_canvas_copy;\n";
5182 out += " display -> gx_display_driver_simple_line_draw = _gx_dave2d_rotated_simple_line_draw_8bpp;\n";
5183 out += " display -> gx_display_driver_horizontal_line_draw = _gx_dave2d_rotated_horizontal_line_8bpp;\n";
5184 out += " display -> gx_display_driver_vertical_line_draw = _gx_dave2d_rotated_vertical_line_8bpp;\n";
5185 out += " display -> gx_display_driver_polygon_draw = _gx_dave2d_rotated_polygon_draw_8bpp;\n";
5186 out += " display -> gx_display_driver_polygon_fill = _gx_dave2d_rotated_polygon_fill_8bpp;\n";
5187 out += " display -> gx_display_driver_block_move = _gx_dave2d_rotated_block_move_8bpp;\n";
5188 out += " display -> gx_display_driver_pixelmap_draw = _gx_dave2d_rotated_pixelmap_draw_8bpp;\n";
5189 out += " display -> gx_display_driver_simple_wide_line_draw = _gx_dave2d_rotated_simple_wide_line_8bpp;\n";
5190 out += " display -> gx_display_driver_1bit_glyph_draw = _gx_dave2d_rotated_glyph_1bit_draw_8bpp;\n";
5191 out += "#if(GX_PALETTE_MODE_AA_TEXT_COLORS == 8)\n";
5192 out += " display -> gx_display_driver_4bit_glyph_draw = _gx_dave2d_rotated_glyph_3bit_draw_8bpp;\n";
5193 out += "#else\n";
5194 out += " display -> gx_display_driver_4bit_glyph_draw = _gx_dave2d_rotated_glyph_4bit_draw_8bpp;\n";
5195 out += "#endif\n";
5196 out += " #if defined(GX_ARC_DRAWING_SUPPORT)\n";
5197 out += " display -> gx_display_driver_circle_draw = _gx_dave2d_rotated_circle_draw_8bpp;\n";
5198 out += " display -> gx_display_driver_circle_fill = _gx_dave2d_rotated_circle_fill_8bpp;\n";
5199 out += " display -> gx_display_driver_pie_fill = _gx_dave2d_rotated_pie_fill_8bpp;\n";
5200 out += " display -> gx_display_driver_arc_draw = _gx_dave2d_rotated_arc_draw_8bpp;\n";
5201 out += " display -> gx_display_driver_arc_fill = _gx_dave2d_rotated_arc_fill;\n";
5202 out += " display -> gx_display_driver_ellipse_draw = _gx_dave2d_rotated_ellipse_draw;\n";
5203 out += " display -> gx_display_driver_ellipse_fill = _gx_dave2d_rotated_ellipse_fill;\n";
5204 out += " display -> gx_display_driver_wide_circle_draw = _gx_dave2d_rotated_circle_draw_8bpp;\n";
5205 out += " display -> gx_display_driver_wide_arc_draw = _gx_dave2d_rotated_arc_draw_8bpp;\n";
5206 out += " display -> gx_display_driver_wide_ellipse_draw = _gx_dave2d_rotated_ellipse_draw;\n";
5207 out += " #endif\n";
5208 }
5209 FileWrite(out);
5210 }
5211
5212 ///////////////////////////////////////////////////////////////////////////////
WriteDave2D16_32_Setup(UINT color_format)5213 void screen_generator::WriteDave2D16_32_Setup(UINT color_format)
5214 {
5215 CString out("");
5216 CString toggle_func("");
5217
5218 if (IsRenesasDave2D(m_project))
5219 {
5220 toggle_func = " _gx_dave2d_buffer_toggle);\n";
5221 }
5222 else
5223 {
5224 switch (m_project->mHeader.target_cpu)
5225 {
5226 case CPU_RA:
5227 toggle_func = " _gx_ra_buffer_toggle);\n";
5228 break;
5229
5230 case CPU_RX:
5231 toggle_func = " _gx_rx_buffer_toggle);\n";
5232 break;
5233
5234 default: // synergy
5235 toggle_func = " _gx_synergy_buffer_toggle);\n";
5236 break;
5237 }
5238 }
5239
5240 /* perform standard GUIX setup */
5241 if (color_format == GX_COLOR_FORMAT_565RGB)
5242 {
5243 out += " _gx_display_driver_565rgb_setup(display, GX_NULL,";
5244 out += toggle_func;
5245 }
5246 else
5247 {
5248 if (IsRenesasDave2D(m_project))
5249 {
5250 out += " _gx_display_driver_32argb_setup(display, GX_NULL,";
5251 }
5252 else
5253 {
5254 if (color_format == GX_COLOR_FORMAT_24XRGB)
5255 {
5256 out += " _gx_display_driver_24xrgb_setup(display, GX_NULL,";
5257 }
5258 else
5259 {
5260 out += " _gx_display_driver_32argb_setup(display, GX_NULL,";
5261 }
5262 }
5263 out += toggle_func;
5264 }
5265 out += " display->gx_display_handle = 0;\n";
5266
5267 /* override drawing functions if using Dave2D accelerator */
5268
5269 if (IsRenesasDave2D(m_project))
5270 {
5271 if (color_format == GX_COLOR_FORMAT_565RGB)
5272 {
5273 out += " display -> gx_display_driver_horizontal_pattern_line_draw = _gx_dave2d_horizontal_pattern_line_draw_565;\n";
5274 out += " display -> gx_display_driver_vertical_pattern_line_draw = _gx_dave2d_vertical_pattern_line_draw_565;\n";
5275 out += " display -> gx_display_driver_pixel_write = _gx_dave2d_pixel_write_565;\n";
5276 out += " display -> gx_display_driver_pixel_blend = _gx_dave2d_pixel_blend_565;\n";
5277 if (m_project->mHeader.guix_version > 50303)
5278 {
5279 out += " display -> gx_display_driver_pixelmap_rotate = _gx_dave2d_pixelmap_rotate_16bpp;\n";
5280 }
5281 }
5282 else
5283 {
5284 out += " display -> gx_display_driver_horizontal_pattern_line_draw = _gx_dave2d_horizontal_pattern_line_draw_888;\n";
5285 out += " display -> gx_display_driver_vertical_pattern_line_draw = _gx_dave2d_vertical_pattern_line_draw_888;\n";
5286 out += " display -> gx_display_driver_pixel_write = _gx_dave2d_pixel_write_888;\n";
5287 out += " display -> gx_display_driver_pixel_blend = _gx_dave2d_pixel_blend_888;\n";
5288 }
5289
5290 // override those functions for which we are going to provide accelerated implementations
5291 out += " display -> gx_display_driver_drawing_initiate = _gx_dave2d_drawing_initiate;\n";
5292 out += " display -> gx_display_driver_drawing_complete = _gx_dave2d_drawing_complete;\n";
5293
5294 out += " display -> gx_display_driver_canvas_copy = _gx_dave2d_canvas_copy;\n";
5295 out += " display -> gx_display_driver_canvas_blend = _gx_dave2d_canvas_blend;\n";
5296 out += " display -> gx_display_driver_simple_line_draw = _gx_dave2d_simple_line_draw;\n";
5297 out += " display -> gx_display_driver_horizontal_line_draw = _gx_dave2d_horizontal_line;\n";
5298 out += " display -> gx_display_driver_vertical_line_draw = _gx_dave2d_vertical_line;\n";
5299
5300 out += " display -> gx_display_driver_polygon_draw = _gx_dave2d_polygon_draw;\n";
5301 out += " display -> gx_display_driver_polygon_fill = _gx_dave2d_polygon_fill;\n";
5302
5303 out += " display -> gx_display_driver_block_move = _gx_dave2d_block_move;\n";
5304
5305 out += " display -> gx_display_driver_pixelmap_draw = _gx_dave2d_pixelmap_draw;\n";
5306 out += " display -> gx_display_driver_horizontal_pixelmap_line_draw = _gx_dave2d_horizontal_pixelmap_line_draw;\n";
5307 out += " display -> gx_display_driver_alphamap_draw = _gx_dave2d_alphamap_draw;\n";
5308 out += " display -> gx_display_driver_simple_wide_line_draw = _gx_dave2d_simple_wide_line;\n";
5309 out += " display -> gx_display_driver_anti_aliased_line_draw = _gx_dave2d_aliased_line;\n";
5310 out += " display -> gx_display_driver_anti_aliased_wide_line_draw = _gx_dave2d_aliased_wide_line;\n";
5311
5312 out += " display -> gx_display_driver_pixelmap_blend = _gx_dave2d_pixelmap_blend;\n";
5313
5314 if (m_project->mHeader.guix_version < 50303)
5315 {
5316 out += " display -> gx_display_driver_8bit_glyph_draw = _gx_dave2d_glyph_8bit_draw;\n";
5317 out += " display -> gx_display_driver_4bit_glyph_draw = _gx_dave2d_glyph_4bit_draw;\n";
5318 out += " display -> gx_display_driver_1bit_glyph_draw = _gx_dave2d_glyph_1bit_draw;\n";
5319 }
5320 else
5321 {
5322 out += " display -> gx_display_driver_8bit_glyph_draw = _gx_dave2d_raw_glyph_8bit_draw;\n";
5323 out += " display -> gx_display_driver_4bit_glyph_draw = _gx_dave2d_raw_glyph_4bit_draw;\n";
5324 out += " display -> gx_display_driver_1bit_glyph_draw = _gx_dave2d_raw_glyph_1bit_draw;\n";
5325 out += " display -> gx_display_driver_8bit_compressed_glyph_draw = _gx_dave2d_compressed_glyph_8bit_draw;\n";
5326 out += " display -> gx_display_driver_4bit_compressed_glyph_draw = _gx_dave2d_compressed_glyph_4bit_draw;\n";
5327 out += " display -> gx_display_driver_1bit_compressed_glyph_draw = _gx_dave2d_compressed_glyph_1bit_draw;\n";
5328 }
5329 out += " #if defined(GX_ARC_DRAWING_SUPPORT)\n";
5330 out += " display -> gx_display_driver_anti_aliased_circle_draw = _gx_dave2d_aliased_circle_draw;\n";
5331 out += " display -> gx_display_driver_anti_aliased_wide_circle_draw = _gx_dave2d_aliased_circle_draw;\n";
5332 out += " display -> gx_display_driver_circle_draw = _gx_dave2d_circle_draw;\n";
5333 out += " display -> gx_display_driver_circle_fill = _gx_dave2d_circle_fill;\n";
5334 out += " display -> gx_display_driver_pie_fill = _gx_dave2d_pie_fill;\n";
5335 out += " display -> gx_display_driver_anti_aliased_arc_draw = _gx_dave2d_aliased_arc_draw;\n";
5336 out += " display -> gx_display_driver_arc_draw = _gx_dave2d_arc_draw;\n";
5337 out += " display -> gx_display_driver_arc_fill = _gx_dave2d_arc_fill;\n";
5338 out += " display -> gx_display_driver_anti_aliased_ellipse_draw = _gx_dave2d_aliased_ellipse_draw;\n";
5339 out += " display -> gx_display_driver_ellipse_draw = _gx_dave2d_ellipse_draw;\n";
5340 out += " display -> gx_display_driver_ellipse_fill = _gx_dave2d_ellipse_fill;\n";
5341 out += " display -> gx_display_driver_wide_circle_draw = _gx_dave2d_circle_draw;\n";
5342 out += " display -> gx_display_driver_anti_aliased_wide_arc_draw = _gx_dave2d_aliased_arc_draw;\n";
5343 out += " display -> gx_display_driver_wide_arc_draw = _gx_dave2d_arc_draw;\n";
5344
5345 if (project_lib_version() > 50500)
5346 {
5347 out += " display -> gx_display_driver_anti_aliased_wide_ellipse_draw= _gx_dave2d_aliased_ellipse_draw;\n";
5348 out += " display -> gx_display_driver_wide_ellipse_draw = _gx_dave2d_ellipse_draw;\n";
5349 }
5350
5351 out += " #endif\n";
5352 }
5353
5354 if (m_project->mHeader.renesas_jpeg_decoder == DECODER_TYPE_HW)
5355 {
5356 if (m_project->mHeader.target_cpu == CPU_SYNERGY)
5357 {
5358 out += " display -> gx_display_driver_jpeg_draw = _gx_synergy_jpeg_draw;\n";
5359 }
5360 else
5361 {
5362 out += " display -> gx_display_driver_jpeg_draw = _gx_renesas_jpeg_draw;\n";
5363 }
5364 }
5365
5366
5367 if((m_project->mHeader.renesas_png_decoder == DECODER_TYPE_SW) &&
5368 IsRenesasDave2D(m_project) && (project_lib_version() >= GX_VERSION_USE_DAVE2D_PNG_DRAW))
5369 {
5370 out +=" display -> gx_display_driver_png_draw = _gx_dave2d_png_draw;\n";
5371 }
5372
5373 FileWrite(out);
5374 }
5375
5376 ///////////////////////////////////////////////////////////////////////////////
WriteDave2D16_32_RotatedSetup(UINT color_format)5377 void screen_generator::WriteDave2D16_32_RotatedSetup(UINT color_format)
5378 {
5379 CString out("");
5380 CString toggle_func("");
5381
5382 if (IsRenesasDave2D(m_project))
5383 {
5384 toggle_func = " _gx_dave2d_rotated_buffer_toggle);\n";
5385 }
5386 else
5387 {
5388 switch (m_project->mHeader.target_cpu)
5389 {
5390 case CPU_RA:
5391 toggle_func = " _gx_ra_rotated_buffer_toggle);\n";
5392 break;
5393
5394 case CPU_RX:
5395 toggle_func = " _gx_rx_rotated_buffer_toggle);\n";
5396 break;
5397
5398 default: // synergy
5399 toggle_func = " _gx_synergy_rotated_buffer_toggle);\n";
5400 break;
5401 }
5402 }
5403
5404 /* perform standard GUIX setup */
5405
5406 switch(color_format)
5407 {
5408 case GX_COLOR_FORMAT_565RGB:
5409 out += " _gx_display_driver_565rgb_rotated_setup(display, GX_NULL,";
5410 break;
5411
5412 case GX_COLOR_FORMAT_24XRGB:
5413 out += " _gx_display_driver_24xrgb_rotated_setup(display, GX_NULL,";
5414 break;
5415
5416 default:
5417 out += " _gx_display_driver_32argb_rotated_setup(display, GX_NULL,";
5418 break;
5419 }
5420 out += toggle_func;
5421 out += " display->gx_display_handle = 0;\n";
5422
5423 /* override drawing functions if using Dave2D accelerator */
5424
5425 if (IsRenesasDave2D(m_project))
5426 {
5427 if (color_format == GX_COLOR_FORMAT_565RGB)
5428 {
5429 out += " display -> gx_display_driver_horizontal_pattern_line_draw = _gx_dave2d_rotated_horizontal_pattern_line_draw_565;\n";
5430 out += " display -> gx_display_driver_vertical_pattern_line_draw = _gx_dave2d_rotated_vertical_pattern_line_draw_565;\n";
5431 out += " display -> gx_display_driver_pixel_write = _gx_dave2d_rotated_pixel_write_565;\n";
5432 out += " display -> gx_display_driver_pixel_blend = _gx_dave2d_rotated_pixel_blend_565;\n";
5433 out += " display -> gx_display_driver_pixelmap_rotate = _gx_dave2d_rotated_pixelmap_rotate_16bpp;\n";
5434
5435 }
5436 else
5437 {
5438 out += " display -> gx_display_driver_horizontal_pattern_line_draw = _gx_dave2d_rotated_horizontal_pattern_line_draw_888;\n";
5439 out += " display -> gx_display_driver_vertical_pattern_line_draw = _gx_dave2d_rotated_vertical_pattern_line_draw_888;\n";
5440 out += " display -> gx_display_driver_pixel_write = _gx_dave2d_rotated_pixel_write_888;\n";
5441 out += " display -> gx_display_driver_pixel_blend = _gx_dave2d_rotated_pixel_blend_888;\n";
5442 }
5443
5444 // override those functions for which we are going to provide accelerated implementations
5445 out += " display -> gx_display_driver_drawing_initiate = _gx_dave2d_rotated_drawing_initiate;\n";
5446 out += " display -> gx_display_driver_drawing_complete = _gx_dave2d_rotated_drawing_complete;\n";
5447
5448 out += " display -> gx_display_driver_canvas_copy = _gx_dave2d_rotated_canvas_copy;\n";
5449 out += " display -> gx_display_driver_canvas_blend = _gx_dave2d_rotated_canvas_blend;\n";
5450 out += " display -> gx_display_driver_simple_line_draw = _gx_dave2d_rotated_simple_line_draw;\n";
5451 out += " display -> gx_display_driver_horizontal_line_draw = _gx_dave2d_rotated_horizontal_line;\n";
5452 out += " display -> gx_display_driver_vertical_line_draw = _gx_dave2d_rotated_vertical_line;\n";
5453
5454 out += " display -> gx_display_driver_polygon_draw = _gx_dave2d_rotated_polygon_draw;\n";
5455 out += " display -> gx_display_driver_polygon_fill = _gx_dave2d_rotated_polygon_fill;\n";
5456
5457 out += " display -> gx_display_driver_block_move = _gx_dave2d_rotated_block_move;\n";
5458
5459 out += " display -> gx_display_driver_pixelmap_draw = _gx_dave2d_rotated_pixelmap_draw;\n";
5460 out += " display -> gx_display_driver_horizontal_pixelmap_line_draw = _gx_dave2d_rotated_horizontal_pixelmap_line_draw;\n";
5461 out += " display -> gx_display_driver_alphamap_draw = _gx_dave2d_rotated_alphamap_draw;\n";
5462 out += " display -> gx_display_driver_simple_wide_line_draw = _gx_dave2d_rotated_simple_wide_line;\n";
5463 out += " display -> gx_display_driver_anti_aliased_line_draw = _gx_dave2d_rotated_aliased_line;\n";
5464 out += " display -> gx_display_driver_anti_aliased_wide_line_draw = _gx_dave2d_rotated_aliased_wide_line;\n";
5465
5466 out += " display -> gx_display_driver_pixelmap_blend = _gx_dave2d_rotated_pixelmap_blend;\n";
5467
5468 out += " display -> gx_display_driver_8bit_glyph_draw = _gx_dave2d_rotated_raw_glyph_8bit_draw;\n";
5469 out += " display -> gx_display_driver_4bit_glyph_draw = _gx_dave2d_rotated_raw_glyph_4bit_draw;\n";
5470 out += " display -> gx_display_driver_1bit_glyph_draw = _gx_dave2d_rotated_raw_glyph_1bit_draw;\n";
5471 out += " display -> gx_display_driver_8bit_compressed_glyph_draw = _gx_dave2d_rotated_compressed_glyph_8bit_draw;\n";
5472 out += " display -> gx_display_driver_4bit_compressed_glyph_draw = _gx_dave2d_rotated_compressed_glyph_4bit_draw;\n";
5473 out += " display -> gx_display_driver_1bit_compressed_glyph_draw = _gx_dave2d_rotated_compressed_glyph_1bit_draw;\n";
5474
5475 out += " #if defined(GX_ARC_DRAWING_SUPPORT)\n";
5476 out += " display -> gx_display_driver_anti_aliased_circle_draw = _gx_dave2d_rotated_aliased_circle_draw;\n";
5477 out += " display -> gx_display_driver_anti_aliased_wide_circle_draw = _gx_dave2d_rotated_aliased_circle_draw;\n";
5478 out += " display -> gx_display_driver_circle_draw = _gx_dave2d_rotated_circle_draw;\n";
5479 out += " display -> gx_display_driver_circle_fill = _gx_dave2d_rotated_circle_fill;\n";
5480 out += " display -> gx_display_driver_pie_fill = _gx_dave2d_rotated_pie_fill;\n";
5481 out += " display -> gx_display_driver_anti_aliased_arc_draw = _gx_dave2d_rotated_aliased_arc_draw;\n";
5482 out += " display -> gx_display_driver_arc_draw = _gx_dave2d_rotated_arc_draw;\n";
5483 out += " display -> gx_display_driver_arc_fill = _gx_dave2d_rotated_arc_fill;\n";
5484 out += " display -> gx_display_driver_anti_aliased_ellipse_draw = _gx_dave2d_rotated_aliased_ellipse_draw;\n";
5485 out += " display -> gx_display_driver_ellipse_draw = _gx_dave2d_rotated_ellipse_draw;\n";
5486 out += " display -> gx_display_driver_ellipse_fill = _gx_dave2d_rotated_ellipse_fill;\n";
5487 out += " display -> gx_display_driver_wide_circle_draw = _gx_dave2d_rotated_circle_draw;\n";
5488 out += " display -> gx_display_driver_anti_aliased_wide_arc_draw = _gx_dave2d_rotated_aliased_arc_draw;\n";
5489 out += " display -> gx_display_driver_wide_arc_draw = _gx_dave2d_rotated_arc_draw;\n";
5490
5491 out += " display -> gx_display_driver_anti_aliased_wide_ellipse_draw= _gx_dave2d_rotated_aliased_ellipse_draw;\n";
5492 out += " display -> gx_display_driver_wide_ellipse_draw = _gx_dave2d_rotated_ellipse_draw;\n";
5493
5494 out += " #endif\n";
5495 }
5496
5497 FileWrite(out);
5498 }
5499
5500 ///////////////////////////////////////////////////////////////////////////////
WriteDave2DSetupFunction(int display)5501 void screen_generator::WriteDave2DSetupFunction(int display)
5502 {
5503 // Fixme:gx_synergy_display_driver_setup function will generated once for every display,
5504 // just generate this function definition when display is 0 to fix the issue temporarily
5505 // This won't work when multi display have different color format
5506 if (display > 0)
5507 {
5508 return;
5509 }
5510
5511 CString out;
5512 FileWrite(CString("#if defined(GX_TARGET_WIN32) || defined(GX_TARGET_LINUX)\n"));
5513
5514 switch(m_project->mHeader.target_cpu)
5515 {
5516 case CPU_RA:
5517 out.Format(_T("\nUINT _gx_ra_display_driver_setup(GX_DISPLAY *display)\n{\n"));
5518 break;
5519
5520 case CPU_RX:
5521 out.Format(_T("\nUINT _gx_rx_display_driver_setup(GX_DISPLAY *display)\n{\n"));
5522 break;
5523
5524 default: // synergy
5525 out.Format(_T("\nUINT _gx_synergy_display_driver_setup(GX_DISPLAY *display)\n{\n"));
5526 break;
5527 }
5528
5529 /* prototype the driver setup function */
5530 switch(m_project->mDisplays[display].colorformat)
5531 {
5532 case GX_COLOR_FORMAT_8BIT_PALETTE:
5533 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5534 {
5535 out += " win32_graphics_driver_setup_8bit_palette_rotated(display);\n";
5536 }
5537 else
5538 {
5539 if (IsDave2dFontFormat(m_project, display))
5540 {
5541 out += " win32_dave2d_graphics_driver_setup_8bit_palette(display);\n";
5542 }
5543 else
5544 {
5545 out += " win32_graphics_driver_setup_8bit_palette(display);\n";
5546 }
5547 }
5548
5549 out += " return GX_SUCCESS;\n}\n";
5550
5551 switch (m_project->mHeader.target_cpu)
5552 {
5553 case CPU_RA:
5554 out += "#else\nUINT _gx_ra_display_driver_setup(GX_DISPLAY *display)\n{\n";
5555 break;
5556
5557 case CPU_RX:
5558 out += "#else\nUINT _gx_rx_display_driver_setup(GX_DISPLAY *display)\n{\n";
5559 break;
5560
5561 default: // synergy
5562 out += "#else\nUINT _gx_synergy_display_driver_setup(GX_DISPLAY *display)\n{\n";
5563 break;
5564 }
5565
5566 FileWrite(out);
5567
5568 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5569 {
5570 WriteDave2D8bppPaletteRotatedSetup();
5571 }
5572 else
5573 {
5574 WriteDave2D8bppPaletteSetup();
5575 }
5576 break;
5577
5578 case GX_COLOR_FORMAT_565RGB:
5579 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5580 {
5581 if (IsRenesasDave2D(m_project))
5582 {
5583 out += " win32_dave2d_graphics_driver_setup_565rgb_rotated(display);\n";
5584 }
5585 else
5586 {
5587 out += " win32_graphics_driver_setup_565rgb_rotated(display);\n";
5588 }
5589 }
5590 else
5591 {
5592 if (IsRenesasDave2D(m_project))
5593 {
5594 out += " win32_dave2d_graphics_driver_setup_565rgb(display);\n";
5595 }
5596 else
5597 {
5598 out += " win32_graphics_driver_setup_565rgb(display);\n";
5599 }
5600 }
5601
5602 out += " return GX_SUCCESS;\n}\n";
5603 switch (m_project->mHeader.target_cpu)
5604 {
5605 case CPU_RA:
5606 out += "#else\nUINT _gx_ra_display_driver_setup(GX_DISPLAY *display)\n{\n";
5607 break;
5608
5609 case CPU_RX:
5610 out += "#else\nUINT _gx_rx_display_driver_setup(GX_DISPLAY *display)\n{\n";
5611 break;
5612
5613 default: // synergy
5614 out += "#else\nUINT _gx_synergy_display_driver_setup(GX_DISPLAY *display)\n{\n";
5615 break;
5616 }
5617 FileWrite(out);
5618 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5619 {
5620 WriteDave2D16_32_RotatedSetup(m_project->mDisplays[display].colorformat);
5621 }
5622 else
5623 {
5624 WriteDave2D16_32_Setup(m_project->mDisplays[display].colorformat);
5625 }
5626 break;
5627
5628 default:
5629 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5630 {
5631 if (IsRenesasDave2D(m_project))
5632 {
5633 out += " win32_dave2d_graphics_driver_setup_24xrgb_rotated(display);\n";
5634 }
5635 else
5636 {
5637 out += " win32_graphics_driver_setup_24xrgb_rotated(display);\n";
5638 }
5639 }
5640 else
5641 {
5642 if (IsRenesasDave2D(m_project))
5643 {
5644 out += " win32_dave2d_graphics_driver_setup_24xrgb(display);\n";
5645 }
5646 else
5647 {
5648 out += " win32_graphics_driver_setup_24xrgb(display);\n";
5649 }
5650 }
5651 out += " return GX_SUCCESS;\n}\n";
5652 switch (m_project->mHeader.target_cpu)
5653 {
5654 case CPU_RA:
5655 out += "#else\nUINT _gx_ra_display_driver_setup(GX_DISPLAY *display)\n{\n";
5656 break;
5657
5658 case CPU_RX:
5659 out += "#else\nUINT _gx_rx_display_driver_setup(GX_DISPLAY *display)\n{\n";
5660 break;
5661
5662 default: // synergy
5663 out += "#else\nUINT _gx_synergy_display_driver_setup(GX_DISPLAY *display)\n{\n";
5664 break;
5665 }
5666 FileWrite(out);
5667 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5668 {
5669 WriteDave2D16_32_RotatedSetup(m_project->mDisplays[display].colorformat);
5670 }
5671 else
5672 {
5673 WriteDave2D16_32_Setup(m_project->mDisplays[display].colorformat);
5674 }
5675 break;
5676
5677 }
5678 out.Format(_T(" return GX_SUCCESS;\n}\n#endif\n"));
5679 FileWrite(out);
5680 }
5681
5682 ///////////////////////////////////////////////////////////////////////////////
DeclareSynergyDriverFunctions(void)5683 void screen_generator::DeclareSynergyDriverFunctions(void)
5684 {
5685 CString out;
5686 int display;
5687 BOOL bNeed8bit = FALSE;
5688 BOOL bNeed16bit = FALSE;
5689 BOOL bNeed24bit = FALSE;
5690 BOOL bNeed32bit = FALSE;
5691 BOOL bNeed32bitRotated = FALSE;
5692 BOOL bNeed24bitRotated = FALSE;
5693 BOOL bNeed16bitRotated = FALSE;
5694 BOOL bNeed8bitRotated = FALSE;
5695
5696 WriteComment("Prototype Dave2D display driver specific functions");
5697
5698 for (display = 0; display < m_project->mHeader.num_displays; display++)
5699 {
5700 switch(m_project->mDisplays[display].colorformat)
5701 {
5702 case GX_COLOR_FORMAT_565RGB:
5703 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5704 {
5705 bNeed16bitRotated = TRUE;
5706 }
5707 else
5708 {
5709 bNeed16bit = TRUE;
5710 }
5711 break;
5712
5713 case GX_COLOR_FORMAT_8BIT_PALETTE:
5714 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5715 {
5716 bNeed8bitRotated = TRUE;
5717 }
5718 else
5719 {
5720 bNeed8bit = TRUE;
5721 }
5722 break;
5723
5724 case GX_COLOR_FORMAT_24XRGB:
5725 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5726 {
5727 bNeed24bitRotated = TRUE;
5728 }
5729 else
5730 {
5731 bNeed24bit = TRUE;
5732 }
5733 break;
5734
5735 case GX_COLOR_FORMAT_32ARGB:
5736 if (resource_gen::IsRotatedResourceSupported(m_project, m_display))
5737 {
5738 bNeed32bitRotated = TRUE;
5739 }
5740 else
5741 {
5742 bNeed32bit = TRUE;
5743 }
5744 break;
5745 }
5746 }
5747
5748 switch(m_project->mHeader.target_cpu)
5749 {
5750 case CPU_RA:
5751 out = "UINT _gx_ra_display_driver_setup(GX_DISPLAY *display);\n";
5752 break;
5753
5754 case CPU_RX:
5755 out = "UINT _gx_rx_display_driver_setup(GX_DISPLAY *display);\n";
5756 break;
5757
5758 default:
5759 out = "UINT _gx_synergy_display_driver_setup(GX_DISPLAY *display);\n";
5760 break;
5761 }
5762 FileWrite(out);
5763
5764 out = "#if defined(GX_TARGET_WIN32) || defined(GX_TARGET_LINUX)\n";
5765 if (IsDave2dFontFormat(m_project, display))
5766 {
5767 if (bNeed8bit)
5768 {
5769 out += "UINT win32_dave2d_graphics_driver_setup_8bit_palette(GX_DISPLAY *display);\n";
5770 }
5771
5772 if (bNeed16bit)
5773 {
5774 out += "UINT win32_dave2d_graphics_driver_setup_565rgb(GX_DISPLAY *display);\n";
5775 }
5776 if (bNeed16bitRotated)
5777 {
5778 out += "UINT win32_dave2d_graphics_driver_setup_565rgb_rotated(GX_DISPLAY *display);\n";
5779 }
5780 if (bNeed24bit || bNeed32bit)
5781 {
5782 out += "UINT win32_dave2d_graphics_driver_setup_24xrgb(GX_DISPLAY *display);\n";
5783 }
5784 if (bNeed24bitRotated || bNeed32bitRotated)
5785 {
5786 out += "UINT win32_dave2d_graphics_driver_setup_24xrgb_rotated(GX_DISPLAY *display);\n";
5787 }
5788 }
5789 else
5790 {
5791 if (bNeed8bit)
5792 {
5793 out += "UINT win32_graphics_driver_setup_8bit_palette(GX_DISPLAY *display);\n";
5794 }
5795
5796 if (bNeed16bit)
5797 {
5798 out += "UINT win32_graphics_driver_setup_565rgb(GX_DISPLAY *display);\n";
5799 }
5800 if (bNeed16bitRotated)
5801 {
5802 out += "UINT win32_graphics_driver_setup_565rgb_rotated(GX_DISPLAY *display);\n";
5803 }
5804 if (bNeed24bit || bNeed32bit)
5805 {
5806 out += "UINT win32_graphics_driver_setup_24xrgb(GX_DISPLAY *display);\n";
5807 }
5808 if (bNeed24bitRotated || bNeed32bitRotated)
5809 {
5810 out += "UINT win32_graphics_driver_setup_24xrgb_rotated(GX_DISPLAY *display);\n";
5811 }
5812 }
5813
5814 if (bNeed8bitRotated)
5815 {
5816 out += "UINT win32_graphics_driver_setup_8bit_palette_rotated(GX_DISPLAY *display);\n";
5817 }
5818
5819 out += "#else\n";
5820 FileWrite(out);
5821
5822 if (bNeed8bit)
5823 {
5824 out = "VOID _gx_display_driver_8bit_palette_setup(GX_DISPLAY *display, VOID *aux_data,\n"
5825 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
5826 " GX_RECTANGLE *dirty_area));\n";
5827 out += "VOID _gx_display_driver_8bit_palette_assign(GX_DISPLAY *display, GX_COLOR *palette, INT count);\n";
5828 FileWrite(out);
5829
5830 if (IsRenesasDave2D(m_project))
5831 {
5832 out = "VOID _gx_dave2d_drawing_initiate_8bpp(GX_DISPLAY *display, GX_CANVAS *canvas);\n";
5833 out += "VOID _gx_dave2d_drawing_complete_8bpp(GX_DISPLAY *display, GX_CANVAS *canvas);\n";
5834 out += "VOID _gx_dave2d_horizontal_line_8bpp(GX_DRAW_CONTEXT *context,\n"
5835 " INT xstart, INT xend, INT ypos, INT width, GX_COLOR color);\n";
5836 out += "VOID _gx_dave2d_vertical_line_8bpp(GX_DRAW_CONTEXT *context,\n"
5837 " INT ystart, INT yend, INT xpos, INT width, GX_COLOR color);\n";
5838 out += "VOID _gx_dave2d_simple_line_draw_8bpp(GX_DRAW_CONTEXT *context, INT xstart, INT ystart, INT xend, INT yend);\n";
5839 out += "VOID _gx_dave2d_simple_wide_line_8bpp(GX_DRAW_CONTEXT *context, INT xstart, INT ystart,\n"
5840 " INT xend, INT yend);\n";
5841 out += "VOID _gx_dave2d_horizontal_pattern_line_draw_8bpp(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos);\n";
5842 out += "VOID _gx_dave2d_vertical_pattern_line_draw_8bpp(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos);\n";
5843 out += "VOID _gx_dave2d_pixelmap_draw_8bpp(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);\n";
5844 out += "VOID _gx_dave2d_polygon_draw_8bpp(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num);\n";
5845 out += "VOID _gx_dave2d_polygon_fill_8bpp(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num);\n";
5846 out += "VOID _gx_dave2d_pixel_write_8bpp(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color);\n";
5847 out += "VOID _gx_dave2d_block_move_8bpp(GX_DRAW_CONTEXT *context,\n"
5848 " GX_RECTANGLE *block, INT xshift, INT yshift);\n";
5849 out += "VOID _gx_dave2d_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite);\n";
5850 out += "VOID _gx_dave2d_glyph_1bit_draw_8bpp(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
5851 if (project_lib_version() >= GX_VERSION_SYNERGY_GLYPH_GEN_CHANGE)
5852 {
5853 out += "VOID _gx_dave2d_glyph_3bit_draw_8bpp(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
5854 }
5855 out += "VOID _gx_dave2d_glyph_4bit_draw_8bpp(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
5856 out += "#if defined(GX_ARC_DRAWING_SUPPORT)\n";
5857 out += "VOID _gx_dave2d_circle_draw_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
5858 out += "VOID _gx_dave2d_circle_fill_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
5859 out += "VOID _gx_dave2d_arc_draw_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
5860 out += "VOID _gx_dave2d_arc_fill_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
5861 out += "VOID _gx_dave2d_pie_fill_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
5862 out += "VOID _gx_dave2d_ellipse_draw_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
5863 out += "VOID _gx_dave2d_wide_ellipse_draw_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
5864 out += "VOID _gx_dave2d_ellipse_fill_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
5865 out += "#endif\n";
5866 out += "VOID _gx_dave2d_buffer_toggle_8bpp(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
5867 }
5868 else
5869 {
5870 switch(m_project->mHeader.target_cpu)
5871 {
5872 case CPU_RA:
5873 out = "VOID _gx_ra_buffer_toggle_8bpp(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
5874 break;
5875
5876 case CPU_RX:
5877 out = "VOID _gx_rx_buffer_toggle_8bpp(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
5878 break;
5879
5880 default:
5881 out = "VOID _gx_synergy_buffer_toggle_8bpp(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
5882 break;
5883 }
5884 }
5885 FileWrite(out);
5886 }
5887
5888 if (bNeed8bitRotated)
5889 {
5890 out = "VOID _gx_display_driver_8bit_palette_rotated_setup(GX_DISPLAY *display, VOID *aux_data,\n"
5891 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
5892 " GX_RECTANGLE *dirty_area));\n";
5893 out += "VOID _gx_display_driver_8bit_palette_assign(GX_DISPLAY *display, GX_COLOR *palette, INT count);\n";
5894 FileWrite(out);
5895
5896 if (IsRenesasDave2D(m_project))
5897 {
5898 out = "VOID _gx_dave2d_drawing_initiate_8bpp(GX_DISPLAY *display, GX_CANVAS *canvas);\n";
5899 out += "VOID _gx_dave2d_drawing_complete_8bpp(GX_DISPLAY *display, GX_CANVAS *canvas);\n";
5900 out += "VOID _gx_dave2d_rotated_horizontal_line_8bpp(GX_DRAW_CONTEXT *context,\n"
5901 " INT xstart, INT xend, INT ypos, INT width, GX_COLOR color);\n";
5902 out += "VOID _gx_dave2d_rotated_vertical_line_8bpp(GX_DRAW_CONTEXT *context,\n"
5903 " INT ystart, INT yend, INT xpos, INT width, GX_COLOR color);\n";
5904 out += "VOID _gx_dave2d_rotated_simple_line_draw_8bpp(GX_DRAW_CONTEXT *context, INT xstart, INT ystart, INT xend, INT yend);\n";
5905 out += "VOID _gx_dave2d_rotated_simple_wide_line_8bpp(GX_DRAW_CONTEXT *context, INT xstart, INT ystart,\n"
5906 " INT xend, INT yend);\n";
5907 out += "VOID _gx_dave2d_rotated_horizontal_pattern_line_draw_8bpp(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos);\n";
5908 out += "VOID _gx_dave2d_rotated_vertical_pattern_line_draw_8bpp(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos);\n";
5909 out += "VOID _gx_dave2d_rotated_pixelmap_draw_8bpp(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);\n";
5910 out += "VOID _gx_dave2d_rotated_polygon_draw_8bpp(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num);\n";
5911 out += "VOID _gx_dave2d_rotated_polygon_fill_8bpp(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num);\n";
5912 out += "VOID _gx_dave2d_rotated_pixel_write_8bpp(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color);\n";
5913 out += "VOID _gx_dave2d_rotated_block_move_8bpp(GX_DRAW_CONTEXT *context,\n"
5914 " GX_RECTANGLE *block, INT xshift, INT yshift);\n";
5915 out += "VOID _gx_dave2d_rotated_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite);\n";
5916 out += "VOID _gx_dave2d_rotated_glyph_1bit_draw_8bpp(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
5917 out += "VOID _gx_dave2d_rotated_glyph_3bit_draw_8bpp(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
5918 out += "VOID _gx_dave2d_rotated_glyph_4bit_draw_8bpp(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
5919 out += "#if defined(GX_ARC_DRAWING_SUPPORT)\n";
5920 out += "VOID _gx_dave2d_rotated_circle_draw_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
5921 out += "VOID _gx_dave2d_rotated_circle_fill_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
5922 out += "VOID _gx_dave2d_rotated_arc_draw_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
5923 out += "VOID _gx_dave2d_rotated_arc_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
5924 out += "VOID _gx_dave2d_rotated_pie_fill_8bpp(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
5925 out += "VOID _gx_dave2d_rotated_ellipse_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
5926 out += "VOID _gx_dave2d_rotated_ellipse_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
5927 out += "#endif\n";
5928 out += "VOID _gx_dave2d_rotated_buffer_toggle_8bpp(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
5929 }
5930 else
5931 {
5932 switch (m_project->mHeader.target_cpu)
5933 {
5934 case CPU_RA:
5935 out = "VOID _gx_ra_rotated_buffer_toggle_8bpp(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
5936 break;
5937
5938 case CPU_RX:
5939 out = "VOID _gx_rx_rotated_buffer_toggle_8bpp(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
5940 break;
5941
5942 default:
5943 out = "VOID _gx_synergy_rotated_buffer_toggle_8bpp(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
5944 break;
5945 }
5946 }
5947 FileWrite(out);
5948 }
5949
5950 if (bNeed16bit)
5951 {
5952 out = "VOID _gx_display_driver_565rgb_setup(GX_DISPLAY *display, VOID *aux_data,\n"
5953 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
5954 " GX_RECTANGLE *dirty_area));\n";
5955 if (IsRenesasDave2D(m_project))
5956 {
5957 out += "VOID _gx_dave2d_horizontal_pattern_line_draw_565(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos);\n";
5958 out += "VOID _gx_dave2d_vertical_pattern_line_draw_565(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos);\n";
5959 out += "VOID _gx_dave2d_pixel_write_565(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color);\n";
5960 out += "VOID _gx_dave2d_pixel_blend_565(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);\n";
5961 if (m_project->mHeader.guix_version > 50303)
5962 {
5963 out += "VOID _gx_dave2d_pixelmap_rotate_16bpp(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, INT angle, INT rot_cx, INT rot_cy);\n";
5964 }
5965 }
5966
5967 FileWrite(out);
5968 }
5969
5970 if (bNeed16bitRotated)
5971 {
5972 out = "VOID _gx_display_driver_565rgb_rotated_setup(GX_DISPLAY *display, VOID *aux_data,\n"
5973 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
5974 " GX_RECTANGLE *dirty_area));\n";
5975 if (IsRenesasDave2D(m_project))
5976 {
5977 out += "VOID _gx_dave2d_rotated_horizontal_pattern_line_draw_565(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos);\n";
5978 out += "VOID _gx_dave2d_rotated_vertical_pattern_line_draw_565(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos);\n";
5979 out += "VOID _gx_dave2d_rotated_pixel_write_565(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color);\n";
5980 out += "VOID _gx_dave2d_rotated_pixel_blend_565(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);\n";
5981 out += "VOID _gx_dave2d_rotated_pixelmap_rotate_16bpp(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, INT angle, INT rot_cx, INT rot_cy);\n";
5982 }
5983
5984 FileWrite(out);
5985 }
5986
5987 if (bNeed24bit || bNeed32bit)
5988 {
5989 out = "";
5990
5991 if (IsRenesasDave2D(m_project))
5992 {
5993 out += "VOID _gx_display_driver_32argb_setup(GX_DISPLAY *display, VOID *aux_data,\n"
5994 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
5995 " GX_RECTANGLE *dirty_area));\n";
5996
5997 out += "VOID _gx_dave2d_horizontal_pattern_line_draw_888(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos);\n";
5998 out += "VOID _gx_dave2d_vertical_pattern_line_draw_888(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos);\n";
5999 out += "VOID _gx_dave2d_pixel_write_888(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color);\n";
6000 out += "VOID _gx_dave2d_pixel_blend_888(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);\n";
6001 }
6002 else
6003 {
6004 if (bNeed24bit)
6005 {
6006 out += "VOID _gx_display_driver_24xrgb_setup(GX_DISPLAY *display, VOID *aux_data,\n"
6007 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
6008 " GX_RECTANGLE *dirty_area));\n";
6009 }
6010 if (bNeed32bit)
6011 {
6012 out += "VOID _gx_display_driver_32argb_setup(GX_DISPLAY *display, VOID *aux_data,\n"
6013 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
6014 " GX_RECTANGLE *dirty_area));\n";
6015 }
6016 }
6017
6018 FileWrite(out);
6019 }
6020
6021 if (bNeed24bitRotated || bNeed32bitRotated)
6022 {
6023 out = "";
6024
6025 if (bNeed24bitRotated)
6026 {
6027 out += "VOID _gx_display_driver_24xrgb_rotated_setup(GX_DISPLAY *display, VOID *aux_data,\n"
6028 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
6029 " GX_RECTANGLE *dirty_area));\n";
6030 }
6031 if (bNeed32bitRotated)
6032 {
6033 out += "VOID _gx_display_driver_32argb_rotated_setup(GX_DISPLAY *display, VOID *aux_data,\n"
6034 " VOID (*toggle_function)(struct GX_CANVAS_STRUCT *canvas,\n"
6035 " GX_RECTANGLE *dirty_area));\n";
6036 }
6037
6038 if (IsRenesasDave2D(m_project))
6039 {
6040 out += "VOID _gx_dave2d_rotated_horizontal_pattern_line_draw_888(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos);\n";
6041 out += "VOID _gx_dave2d_rotated_vertical_pattern_line_draw_888(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos);\n";
6042 out += "VOID _gx_dave2d_rotated_pixel_write_888(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color);\n";
6043 out += "VOID _gx_dave2d_rotated_pixel_blend_888(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha);\n";
6044 }
6045
6046 FileWrite(out);
6047 }
6048
6049 if (bNeed16bit || bNeed24bit || bNeed32bit)
6050 {
6051 if (IsRenesasDave2D(m_project))
6052 {
6053 out = "VOID _gx_dave2d_drawing_initiate(GX_DISPLAY *display, GX_CANVAS *canvas);\n";
6054 out += "VOID _gx_dave2d_drawing_complete(GX_DISPLAY *display, GX_CANVAS *canvas);\n";
6055 out += "VOID _gx_dave2d_horizontal_line(GX_DRAW_CONTEXT *context,\n";
6056 out += " INT xstart, INT xend, INT ypos, INT width, GX_COLOR color);\n";
6057 out += "VOID _gx_dave2d_vertical_line(GX_DRAW_CONTEXT *context,\n";
6058 out += " INT ystart, INT yend, INT xpos, INT width, GX_COLOR color);\n";
6059
6060 out += "VOID _gx_dave2d_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite);\n";
6061 out += "VOID _gx_dave2d_canvas_blend(GX_CANVAS *canvas, GX_CANVAS *composite);\n";
6062 out += "VOID _gx_dave2d_simple_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT ystart, INT xend, INT yend);\n";
6063 out += "VOID _gx_dave2d_simple_wide_line(GX_DRAW_CONTEXT *context, INT xstart, INT ystart,\n";
6064 out += " INT xend, INT yend);\n";
6065 out += "VOID _gx_dave2d_aliased_line(GX_DRAW_CONTEXT *context, INT xstart, INT ystart, INT xend, INT yend);\n";
6066 out += "VOID _gx_dave2d_aliased_wide_line(GX_DRAW_CONTEXT *context, INT xstart,\n";
6067 out += " INT ystart, INT xend, INT yend);\n";
6068 out += "VOID _gx_dave2d_pixelmap_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);\n";
6069 if (m_project->mHeader.guix_version < 50400)
6070 {
6071 out += "VOID _gx_dave2d_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, INT xstart, INT xend, INT y, GX_PIXELMAP *pixelmap);\n";
6072 }
6073 else if (m_project->mHeader.guix_version <= 50500)
6074 {
6075 out += "VOID _gx_dave2d_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info);\n";
6076 }
6077 else
6078 {
6079 out += "VOID _gx_dave2d_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info);\n";
6080 }
6081 out += "VOID _gx_dave2d_pixelmap_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos,\n";
6082 out += " GX_PIXELMAP *pixelmap, GX_UBYTE alpha);\n";
6083 out += "VOID _gx_dave2d_polygon_draw(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num);\n";
6084 out += "VOID _gx_dave2d_polygon_fill(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num);\n";
6085 out += "VOID _gx_dave2d_block_move(GX_DRAW_CONTEXT *context,\n";
6086 out += " GX_RECTANGLE *block, INT xshift, INT yshift);\n";
6087 out += "VOID _gx_dave2d_alphamap_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);\n";
6088 if (m_project->mHeader.guix_version < 50303)
6089 {
6090 out += "VOID _gx_dave2d_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6091 out += "VOID _gx_dave2d_glyph_4bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6092 out += "VOID _gx_dave2d_glyph_1bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6093 }
6094 else
6095 {
6096 out += "VOID _gx_dave2d_compressed_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6097 out += "VOID _gx_dave2d_raw_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6098 out += "VOID _gx_dave2d_compressed_glyph_4bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6099 out += "VOID _gx_dave2d_raw_glyph_4bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6100 out += "VOID _gx_dave2d_compressed_glyph_1bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6101 out += "VOID _gx_dave2d_raw_glyph_1bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6102 }
6103 out += "VOID _gx_dave2d_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
6104 out += "#if defined(GX_ARC_DRAWING_SUPPORT)\n";
6105 out += "VOID _gx_dave2d_aliased_circle_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
6106 out += "VOID _gx_dave2d_circle_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
6107 out += "VOID _gx_dave2d_circle_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
6108 out += "VOID _gx_dave2d_pie_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
6109 out += "VOID _gx_dave2d_aliased_arc_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
6110 out += "VOID _gx_dave2d_arc_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
6111 out += "VOID _gx_dave2d_arc_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
6112 out += "VOID _gx_dave2d_aliased_ellipse_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
6113 out += "VOID _gx_dave2d_ellipse_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
6114 out += "VOID _gx_dave2d_ellipse_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
6115 out += "#endif\n";
6116 }
6117 else
6118 {
6119 switch (m_project->mHeader.target_cpu)
6120 {
6121 case CPU_RA:
6122 out = "VOID _gx_ra_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
6123 break;
6124
6125 case CPU_RX:
6126 out = "VOID _gx_rx_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
6127 break;
6128
6129 default:
6130 out = "VOID _gx_synergy_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
6131 break;
6132 }
6133 }
6134
6135 FileWrite(out);
6136 }
6137
6138 if ((bNeed16bitRotated || bNeed24bitRotated || bNeed32bitRotated) && IsRenesasDave2D(m_project))
6139 {
6140 out = "VOID _gx_dave2d_rotated_drawing_initiate(GX_DISPLAY *display, GX_CANVAS *canvas);\n";
6141 out += "VOID _gx_dave2d_rotated_drawing_complete(GX_DISPLAY *display, GX_CANVAS *canvas);\n";
6142 out += "VOID _gx_dave2d_rotated_horizontal_line(GX_DRAW_CONTEXT *context,\n";
6143 out += " INT xstart, INT xend, INT ypos, INT width, GX_COLOR color);\n";
6144 out += "VOID _gx_dave2d_rotated_vertical_line(GX_DRAW_CONTEXT *context,\n";
6145 out += " INT ystart, INT yend, INT xpos, INT width, GX_COLOR color);\n";
6146
6147 out += "VOID _gx_dave2d_rotated_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite);\n";
6148 out += "VOID _gx_dave2d_rotated_canvas_blend(GX_CANVAS *canvas, GX_CANVAS *composite);\n";
6149 out += "VOID _gx_dave2d_rotated_simple_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT ystart, INT xend, INT yend);\n";
6150 out += "VOID _gx_dave2d_rotated_simple_wide_line(GX_DRAW_CONTEXT *context, INT xstart, INT ystart,\n";
6151 out += " INT xend, INT yend);\n";
6152 out += "VOID _gx_dave2d_rotated_aliased_line(GX_DRAW_CONTEXT *context, INT xstart, INT ystart, INT xend, INT yend);\n";
6153 out += "VOID _gx_dave2d_rotated_aliased_wide_line(GX_DRAW_CONTEXT *context, INT xstart,\n";
6154 out += " INT ystart, INT xend, INT yend);\n";
6155 out += "VOID _gx_dave2d_rotated_pixelmap_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);\n";
6156 out += "VOID _gx_dave2d_rotated_horizontal_pixelmap_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT y, GX_FILL_PIXELMAP_INFO *info);\n";
6157 out += "VOID _gx_dave2d_rotated_pixelmap_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos,\n";
6158 out += " GX_PIXELMAP *pixelmap, GX_UBYTE alpha);\n";
6159 out += "VOID _gx_dave2d_rotated_polygon_draw(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num);\n";
6160 out += "VOID _gx_dave2d_rotated_polygon_fill(GX_DRAW_CONTEXT *context, GX_POINT *vertex, INT num);\n";
6161 out += "VOID _gx_dave2d_rotated_block_move(GX_DRAW_CONTEXT *context,\n";
6162 out += " GX_RECTANGLE *block, INT xshift, INT yshift);\n";
6163 out += "VOID _gx_dave2d_rotated_alphamap_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);\n";
6164 out += "VOID _gx_dave2d_rotated_compressed_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6165 out += "VOID _gx_dave2d_rotated_raw_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6166 out += "VOID _gx_dave2d_rotated_compressed_glyph_4bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6167 out += "VOID _gx_dave2d_rotated_raw_glyph_4bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6168 out += "VOID _gx_dave2d_rotated_compressed_glyph_1bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6169 out += "VOID _gx_dave2d_rotated_raw_glyph_1bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, const GX_GLYPH *glyph);\n";
6170 out += "VOID _gx_dave2d_rotated_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
6171 out += "#if defined(GX_ARC_DRAWING_SUPPORT)\n";
6172 out += "VOID _gx_dave2d_rotated_aliased_circle_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
6173 out += "VOID _gx_dave2d_rotated_circle_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
6174 out += "VOID _gx_dave2d_rotated_circle_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r);\n";
6175 out += "VOID _gx_dave2d_rotated_pie_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
6176 out += "VOID _gx_dave2d_rotated_aliased_arc_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
6177 out += "VOID _gx_dave2d_rotated_arc_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
6178 out += "VOID _gx_dave2d_rotated_arc_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, UINT r, INT start_angle, INT end_angle);\n";
6179 out += "VOID _gx_dave2d_rotated_aliased_ellipse_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
6180 out += "VOID _gx_dave2d_rotated_ellipse_draw(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
6181 out += "VOID _gx_dave2d_rotated_ellipse_fill(GX_DRAW_CONTEXT *context, INT xcenter, INT ycenter, INT a, INT b);\n";
6182 out += "#endif\n";
6183
6184 FileWrite(out);
6185 }
6186
6187 if ((bNeed16bitRotated || bNeed24bitRotated || bNeed32bitRotated) && !IsRenesasDave2D(m_project))
6188 {
6189 switch (m_project->mHeader.target_cpu)
6190 {
6191 case CPU_RA:
6192 out = "VOID _gx_ra_rotated_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
6193 break;
6194
6195 case CPU_RX:
6196 out = "VOID _gx_rx_rotated_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
6197 break;
6198
6199 default:
6200 out = "VOID _gx_synergy_rotated_buffer_toggle(GX_CANVAS *canvas, GX_RECTANGLE *dirty);\n";
6201 break;
6202 }
6203 FileWrite(out);
6204 }
6205
6206 if (m_project->mHeader.renesas_jpeg_decoder == DECODER_TYPE_HW)
6207 {
6208 if (m_project->mHeader.target_cpu == CPU_SYNERGY)
6209 {
6210 out = "VOID _gx_synergy_jpeg_draw (GX_DRAW_CONTEXT *p_context, INT x, INT y, GX_PIXELMAP *p_pixelmap);\n";
6211 }
6212 else
6213 {
6214 out = "VOID _gx_renesas_jpeg_draw (GX_DRAW_CONTEXT *p_context, INT x, INT y, GX_PIXELMAP *p_pixelmap);\n";
6215 }
6216 FileWrite(out);
6217 }
6218
6219 if (m_project->mHeader.renesas_png_decoder == DECODER_TYPE_SW &&
6220 IsRenesasDave2D(m_project) && (project_lib_version() >= GX_VERSION_USE_DAVE2D_PNG_DRAW))
6221 {
6222 if (bNeed16bit || bNeed24bit || bNeed32bit)
6223 {
6224 out = "VOID _gx_dave2d_png_draw(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap);\n";
6225 FileWrite(out);
6226 }
6227 }
6228 FileWrite(CString("\n#endif\n"));
6229 }
6230
6231