1
2
3 #include "studiox_includes.h"
4
5 #ifdef _DEBUG
6 #define new DEBUG_NEW
7 #endif
8
9 //#define TEST_WIDGET_COPY
10
11 extern UINT StudioClipboardFormat;
12
13 ///////////////////////////////////////////////////////////////////////////////
copy_paste_info()14 copy_paste_info::copy_paste_info()
15 {
16 template_dependencies = NULL;
17 copied_widgets = NULL;
18 }
19
20 ///////////////////////////////////////////////////////////////////////////////
~copy_paste_info()21 copy_paste_info::~copy_paste_info()
22 {
23 if (template_dependencies)
24 {
25 delete template_dependencies;
26 }
27
28 if (copied_widgets)
29 {
30 delete copied_widgets;
31 }
32 }
33
34 ///////////////////////////////////////////////////////////////////////////////
copy_paste_engine()35 copy_paste_engine::copy_paste_engine()
36 {
37 write_color_list.SetSize(0, 10);
38 write_font_list.SetSize(0, 10);
39 write_pixelmap_list.SetSize(0, 10);
40 write_string_list.SetSize(0, 10);
41
42 color_trans.SetSize(0, 10);
43 string_trans.SetSize(0, 10);
44
45 mProject = GetOpenProject();
46 }
47
48 ///////////////////////////////////////////////////////////////////////////////
~copy_paste_engine()49 copy_paste_engine::~copy_paste_engine()
50 {
51 }
52
53 ///////////////////////////////////////////////////////////////////////////////
SetProject(studiox_project * project)54 void copy_paste_engine::SetProject(studiox_project *project)
55 {
56 if (project)
57 {
58 mProject = project;
59 }
60 }
61
62 ///////////////////////////////////////////////////////////////////////////////
CopyToClipboard(CArray<widget_info * > & info_list,HWND hWnd,folder_info * folder)63 BOOL copy_paste_engine::CopyToClipboard(CArray<widget_info *> &info_list, HWND hWnd, folder_info *folder)
64 {
65 if ((!mProject) || (info_list.IsEmpty() && !folder))
66 {
67 return FALSE;
68 }
69
70 xml_writer writer;
71 CSharedFile *pMemFile = new CSharedFile();
72
73 ClearResourceList();
74
75 if (folder)
76 {
77 mDisplay = mProject->GetDisplayIndex(folder);
78 }
79 else
80 {
81 mDisplay = mProject->GetDisplayIndex(info_list.GetAt(0));
82 }
83
84 widget_info *info;
85
86 for (int index = 0; index < info_list.GetCount(); index++)
87 {
88 info = info_list.GetAt(index);
89
90 BuildBaseList(info);
91 }
92
93 writer.OpenMemFile(pMemFile);
94
95 writer.OpenTag("GUIX_Studio_Copy");
96 WriteColorDependencies(writer);
97 WriteFontDependencies(writer);
98 WritePixelmapDependencies(writer);
99 WriteStringDependencies(writer);
100
101 if (base_list.GetCount())
102 {
103 writer.OpenTag("template_dependencies");
104 for (int index = base_list.GetCount() - 1; index >= 0; index--)
105 {
106 widget_writer::WriteWidgets(writer, mProject, mDisplay, base_list.GetAt(index), FALSE);
107 }
108 writer.CloseTag("template_dependencies");
109 }
110
111 writer.OpenTag("copied_widgets");
112
113 if (folder)
114 {
115 //write folder information
116 writer.WriteString("folder_name", folder->folder_name);
117 }
118
119 if (info_list.GetCount())
120 {
121 for (int index = 0; index < info_list.GetCount(); index++)
122 {
123 widget_writer::WriteWidgets(writer, mProject, mDisplay, info_list.GetAt(index), FALSE);
124 }
125 }
126
127 writer.CloseTag("copied_widgets");
128
129
130 writer.CloseTag("GUIX_Studio_Copy");
131
132 HANDLE hMem = pMemFile->Detach();
133 delete pMemFile;
134 if (OpenClipboard(hWnd))
135 {
136 SetClipboardData(StudioClipboardFormat, hMem);
137 CloseClipboard();
138 return TRUE;
139 }
140
141 return FALSE;
142 }
143
144 ///////////////////////////////////////////////////////////////////////////////
CopyToClipboard(widget_info * info,HWND hWnd)145 BOOL copy_paste_engine::CopyToClipboard(widget_info *info, HWND hWnd)
146 {
147 CArray<widget_info *> info_list;
148 info_list.Add(info);
149
150 return CopyToClipboard(info_list, hWnd);
151 }
152
153 ///////////////////////////////////////////////////////////////////////////////
154 /* Note of Copy folder: Since only one folder can be selceted at same time, so just consider copy one folder here.
155 Import project use the logic copy-paste widgets. */
CopyToClipboard(folder_info * folder,HWND hWnd)156 BOOL copy_paste_engine::CopyToClipboard(folder_info *folder, HWND hWnd)
157 {
158 CArray<widget_info *> info_list;
159 widget_info *screen = folder->GetFirstChildWidget();
160
161 while (screen)
162 {
163 info_list.Add(screen);
164 screen = screen->GetNextWidgetInfo();
165 }
166
167 return CopyToClipboard(info_list, hWnd, folder);
168 }
169
170
171 ///////////////////////////////////////////////////////////////////////////////
ClearResourceList()172 void copy_paste_engine::ClearResourceList()
173 {
174 write_color_list.RemoveAll();
175 write_font_list.RemoveAll();
176 write_pixelmap_list.RemoveAll();
177 write_string_list.RemoveAll();
178
179 base_list.RemoveAll();
180 }
181
ClearResourceTransList()182 void copy_paste_engine::ClearResourceTransList()
183 {
184 color_trans.RemoveAll();
185 string_trans.RemoveAll();
186 }
187
188 ///////////////////////////////////////////////////////////////////////////////
ReadWidgets(xml_reader & reader,const char * tagname)189 folder_info *copy_paste_engine::ReadWidgets(xml_reader &reader, const char *tagname)
190 {
191 folder_info *new_folder = NULL;
192
193 if (reader.EnterSection(tagname))
194 {
195 new_folder = new folder_info();
196
197 reader.ReadString("folder_name", new_folder->folder_name);
198
199 widget_info *new_widget = NULL;
200 widget_info *pre = NULL;
201
202 while (reader.EnterSection(CT2A(widget_factory::WidgetTypeToString(GX_TYPE_WIDGET))))
203 {
204 new_widget = widget_reader::ReadOneWidget(reader, mProject, mDisplay);
205
206 if (new_widget)
207 {
208 if (!new_folder->GetFirstChildWidget())
209 {
210 new_folder->SetFirstChildWidget(new_widget);
211 }
212
213 if (pre)
214 {
215 pre->SetNextWidgetInfo(new_widget);
216 }
217 pre = new_widget;
218 widget_reader::ReadChildWidgets(reader, mProject, mDisplay, new_widget);
219 }
220
221 reader.CloseSection(TRUE, TRUE);
222 }
223 TranslateWidgetResourceIds(new_folder->GetFirstChildWidget());
224
225 reader.CloseSection(TRUE, TRUE);
226 }
227
228 return new_folder;
229 }
230
231 ///////////////////////////////////////////////////////////////////////////////
PasteFromClipboard(HWND hWnd,int Display)232 copy_paste_info *copy_paste_engine::PasteFromClipboard(HWND hWnd, int Display)
233 {
234 if (!mProject)
235 {
236 return NULL;
237 }
238
239 copy_paste_info *paste_info = NULL;
240 mDisplay = Display;
241
242 if (OpenClipboard(hWnd))
243 {
244 HANDLE hMem = GetClipboardData(StudioClipboardFormat);
245
246 if (!hMem)
247 {
248 CloseClipboard();
249 ErrorMsg("Unknown clipboard data format.");
250 return NULL;
251 }
252 CSharedFile *pFile = new CSharedFile;
253 pFile->SetHandle(hMem);
254 xml_reader reader;
255 reader.ReadFile(pFile);
256
257 if (reader.EnterSection("GUIX_Studio_Copy"))
258 {
259 mProject->mHeader.warn_missing_font = TRUE;
260 mProject->mHeader.warn_missing_image = TRUE;
261 ClearResourceTransList();
262
263 if (ReadColorDependencies(reader) &&
264 ReadFontDependencies(reader) &&
265 ReadPixelmapDependencies(reader) &&
266 ReadStringDependencies(reader))
267 {
268 GetResourceView()->FinalizePasteResources();
269
270 paste_info = new copy_paste_info;
271 paste_info->template_dependencies = ReadWidgets(reader, "template_dependencies");
272 paste_info->copied_widgets = ReadWidgets(reader, "copied_widgets");
273 }
274 reader.CloseSection(TRUE, TRUE);
275 }
276
277 pFile->Detach();
278 delete pFile;
279 CloseClipboard();
280 }
281
282 return paste_info;
283 }
284
285 ///////////////////////////////////////////////////////////////////////////////
WriteColorDependencies(xml_writer & writer)286 void copy_paste_engine::WriteColorDependencies(xml_writer &writer)
287 {
288 int index;
289 int active_theme;
290
291 writer.OpenTag("colors");
292
293 for (index = 0; index < write_color_list.GetCount(); index++)
294 {
295 active_theme = mProject->mDisplays[mDisplay].active_theme;
296
297 res_info *color_info = mProject->FindResource(mDisplay, active_theme, RES_TYPE_COLOR, write_color_list.GetAt(index));
298
299 if (color_info)
300 {
301 if (color_info->is_default == FALSE)
302 {
303 writer.OpenTag("resource");
304 //always write RGB color
305 GX_COLOR color_value = color_info->colorval;
306 theme_info *theme = &mProject->mDisplays[mDisplay].themes[active_theme];
307 color_info->colorval = ProjectConfigDlg::GetRGBColor(color_info->colorval,
308 theme->palette,
309 theme->palette_predefined,
310 mProject->mDisplays[mDisplay].colorformat);
311 mProject->WriteOneResource(writer, color_info);
312 color_info->colorval = color_value;
313 writer.CloseTag("resource");
314 }
315 }
316 }
317 writer.CloseTag("colors");
318 }
319
320 ///////////////////////////////////////////////////////////////////////////////
ReadColorDependencies(xml_reader & reader)321 BOOL copy_paste_engine::ReadColorDependencies(xml_reader &reader)
322 {
323 res_info *newres;
324 CString res_type_name;
325 resource_view *res_view = GetResourceView();
326 int conflict_option = 0;
327
328 if (reader.EnterSection("colors"))
329 {
330 while(reader.EnterSection("resource"))
331 {
332 resource_trans_entry entry;
333
334 newres = NULL;
335 reader.ReadString("type", res_type_name);
336 int restype = mProject->ResStringToType(res_type_name);
337
338 if (restype == RES_TYPE_COLOR)
339 {
340 newres = new res_info(RES_TYPE_COLOR);
341 mProject->ReadOneResource(reader, mDisplay, newres);
342 }
343 reader.CloseSection(TRUE, TRUE);
344
345 if (newres)
346 {
347 entry.source_id_name = newres->name;
348 conflict_option = res_view->PasteResource(newres, conflict_option);
349 entry.translated_id_name = newres->name;
350 color_trans.Add(entry);
351
352 delete newres;
353
354 if (conflict_option == PASTE_CONFLICT_OPTION_ABORT)
355 {
356 return FALSE;
357 }
358 }
359 }
360 reader.CloseSection(TRUE, TRUE);
361
362 return TRUE;
363 }
364 return FALSE;
365 }
366
367
368 ///////////////////////////////////////////////////////////////////////////////
WriteFontDependencies(xml_writer & writer)369 void copy_paste_engine::WriteFontDependencies(xml_writer &writer)
370 {
371 int index;
372 int active_theme = mProject->mDisplays[mDisplay].active_theme;
373
374 writer.OpenTag("fonts");
375 for (index = 0; index < write_font_list.GetCount(); index++)
376 {
377 res_info *font_info = mProject->FindResource(mDisplay, active_theme, RES_TYPE_FONT, write_font_list.GetAt(index));
378 if (font_info)
379 {
380 if (font_info->is_default == FALSE)
381 {
382 writer.OpenTag("resource");
383 mProject->WriteOneResource(writer, font_info);
384 writer.CloseTag("resource");
385 }
386 }
387 }
388 writer.CloseTag("fonts");
389 }
390
391 ///////////////////////////////////////////////////////////////////////////////
ReadFontDependencies(xml_reader & reader)392 BOOL copy_paste_engine::ReadFontDependencies(xml_reader &reader)
393 {
394 res_info *newres;
395 CString res_type_name;
396 resource_view *res_view = GetResourceView();
397
398 if (reader.EnterSection("fonts"))
399 {
400 while(reader.EnterSection("resource"))
401 {
402 newres = NULL;
403 reader.ReadString("type", res_type_name);
404 int restype = mProject->ResStringToType(res_type_name);
405
406 if (restype == RES_TYPE_FONT)
407 {
408 newres = new res_info(RES_TYPE_FONT);
409 mProject->ReadOneResource(reader, mDisplay, newres);
410 }
411 reader.CloseSection(TRUE, TRUE);
412
413 if (newres)
414 {
415 res_view->PasteResource(newres);
416 delete newres;
417 }
418 }
419 reader.CloseSection(TRUE, TRUE);
420
421 return TRUE;
422 }
423 return FALSE;
424 }
425
426
427 ///////////////////////////////////////////////////////////////////////////////
WritePixelmapDependencies(xml_writer & writer)428 void copy_paste_engine::WritePixelmapDependencies(xml_writer &writer)
429 {
430 int index;
431 int active_theme = mProject->mDisplays[mDisplay].active_theme;
432
433 writer.OpenTag("pixelmaps");
434 for (index = 0; index < write_pixelmap_list.GetCount(); index++)
435 {
436 res_info *pix_info = mProject->FindResource(mDisplay, active_theme, RES_TYPE_PIXELMAP, write_pixelmap_list.GetAt(index));
437 if (pix_info)
438 {
439 if (pix_info->is_default == FALSE)
440 {
441 writer.OpenTag("resource");
442 mProject->WriteOneResource(writer, pix_info);
443 writer.CloseTag("resource");
444 }
445 }
446 }
447 writer.CloseTag("pixelmaps");
448 }
449
450 ///////////////////////////////////////////////////////////////////////////////
ReadPixelmapDependencies(xml_reader & reader)451 BOOL copy_paste_engine::ReadPixelmapDependencies(xml_reader &reader)
452 {
453 res_info *newres;
454 CString res_type_name;
455 resource_view *res_view = GetResourceView();
456
457 if (reader.EnterSection("pixelmaps"))
458 {
459 while(reader.EnterSection("resource"))
460 {
461 newres = NULL;
462 reader.ReadString("type", res_type_name);
463 int restype = mProject->ResStringToType(res_type_name);
464
465 if (restype == RES_TYPE_PIXELMAP)
466 {
467 newres = new res_info(RES_TYPE_PIXELMAP);
468 mProject->ReadOneResource(reader, mDisplay, newres);
469 }
470 reader.CloseSection(TRUE, TRUE);
471
472 if (newres)
473 {
474 res_view->PasteResource(newres);
475 delete newres;
476 }
477 }
478 reader.CloseSection(TRUE, TRUE);
479
480 return TRUE;
481 }
482 return FALSE;
483 }
484
485 ///////////////////////////////////////////////////////////////////////////////
WriteStringDependencies(xml_writer & writer)486 void copy_paste_engine::WriteStringDependencies(xml_writer &writer)
487 {
488 int index;
489 int string_id;
490 int language;
491 CString id_name;
492 string_table_record record;
493
494 string_table *table = mProject->mDisplays[mDisplay].stable;
495
496 writer.OpenTag("string_table");
497
498 if (table && write_string_list.GetCount() > 0)
499 {
500 writer.WriteInt("num_strings", write_string_list.GetCount());
501 writer.WriteInt("num_languages", table->CountLanguages());
502
503 if (table->CountLanguages() != mProject->mHeader.num_languages)
504 {
505 ErrorMsg("Internal Error: Language count discrepency");
506 writer.CloseTag("string_table");
507 return;
508 }
509
510 for (index = 0; index < write_string_list.GetCount(); index++)
511 {
512 string_id = write_string_list.GetAt(index);
513 id_name = table->GetResourceIdName(string_id);
514 record = table->GetRecord(id_name);
515 writer.OpenTag("string_record");
516 writer.WriteString("id_name", record.id_name);
517 writer.WriteInt("font", record.font_id);
518 writer.WriteString("notes", record.notes);
519
520 for (language = 0; language < table->CountLanguages(); language++)
521 {
522 writer.WriteString("val", table->GetString(id_name, language), TRUE);
523 }
524 writer.CloseTag("string_record");
525 }
526 }
527 writer.CloseTag("string_table");
528 }
529
530 ///////////////////////////////////////////////////////////////////////////////
ReadStringDependencies(xml_reader & reader)531 BOOL copy_paste_engine::ReadStringDependencies(xml_reader &reader)
532 {
533 int index;
534 int num_strings;
535 int num_languages;
536 int language;
537 string_table_record record;
538 int conflict_option = 0;
539
540 resource_view *res_view = GetResourceView();
541 string_table *table = mProject->mDisplays[mDisplay].stable;
542
543 if (!table)
544 {
545 return FALSE;
546 }
547 if (reader.EnterSection("string_table"))
548 {
549 reader.ReadInt("num_strings", num_strings);
550 reader.ReadInt("num_languages", num_languages);
551
552 if (num_strings && num_languages != mProject->mHeader.num_languages)
553 {
554 ErrorMsg("Source and Destination projects have inconsistent langauge count.");
555 reader.CloseSection();
556 return FALSE;
557 }
558
559 for (index = 0; index < num_strings; index++)
560 {
561 if (reader.EnterSection("string_record"))
562 {
563 resource_trans_entry entry;
564
565 reader.ReadString("id_name", record.id_name);
566 reader.ReadInt("font", record.font_id);
567 reader.ReadString("notes", record.notes);
568
569 entry.source_id_name = record.id_name;
570
571 record.strings = new CString[num_languages];
572
573 for (language = 0; language < table->CountLanguages(); language++)
574 {
575 reader.ReadString("val", record.strings[language]);
576 }
577 reader.CloseSection(TRUE, TRUE);
578 if (record.strings)
579 {
580 conflict_option = res_view->PasteResource(record, conflict_option);
581 entry.translated_id_name = record.id_name;
582 string_trans.Add(entry);
583
584 if (conflict_option == PASTE_CONFLICT_OPTION_ABORT)
585 {
586 delete[] record.strings;
587 return FALSE;
588 }
589
590 delete[] record.strings;
591 }
592 }
593 }
594 reader.CloseSection(TRUE, TRUE);
595 return TRUE;
596 }
597 return FALSE;
598 }
599
600 ///////////////////////////////////////////////////////////////////////////////
CheckAddToList(CArray<int> & list,int res_id)601 void copy_paste_engine::CheckAddToList(CArray<int> &list, int res_id)
602 {
603 if (!IsItemInArray<int>(list, res_id))
604 {
605 list.Add(res_id);
606 }
607 }
608
609 ///////////////////////////////////////////////////////////////////////////////
BuildResourceList(widget_info * info,BOOL entry)610 void copy_paste_engine::BuildResourceList(widget_info *info, BOOL entry)
611 {
612 int index;
613
614 // Go through info adding his resources to the resource lists.
615 // Call recursively to add child resources
616
617 while(info)
618 {
619 for (index = 0; index < NUM_WIDGET_COLORS; index++)
620 {
621 if (info->color_id[index] != 0)
622 {
623 CheckAddToList(write_color_list, info->color_id[index]);
624 }
625 }
626
627 for (index = 0; index < NUM_WIDGET_FONTS; index++)
628 {
629 if (info->font_id[index] != 0)
630 {
631 CheckAddToList(write_font_list, info->font_id[index]);
632 }
633 }
634
635
636 for (index = 0; index < NUM_WIDGET_PIXELMAPS; index++)
637 {
638 if (info->pixelmap_id[index] != 0)
639 {
640 CheckAddToList(write_pixelmap_list, info->pixelmap_id[index]);
641 }
642 }
643
644 if (info->basetype == GX_TYPE_STRING_SCROLL_WHEEL)
645 {
646 if (info->ewi.string_scroll_wheel.string_id_list)
647 {
648 for (index = 0; index < info->ewi.string_scroll_wheel.base.total_rows; index++)
649 {
650 if (info->ewi.string_scroll_wheel.string_id_list[index] != 0)
651 {
652 CheckAddToList(write_string_list, info->ewi.string_scroll_wheel.string_id_list[index]);
653 }
654 }
655 }
656 }
657 else
658 {
659 for (index = 0; index < NUM_WIDGET_STRINGS; index++)
660 {
661 if (info->string_id[index] != 0)
662 {
663 CheckAddToList(write_string_list, info->string_id[index]);
664 }
665 }
666 }
667
668
669 // scrollbar and sprite have additional pixelmaps:
670 if (info->basetype == GX_TYPE_VERTICAL_SCROLL ||
671 info->basetype == GX_TYPE_HORIZONTAL_SCROLL)
672 {
673 if (info->ewi.scroll.gx_scroll_down_pixelmap)
674 {
675 CheckAddToList(write_pixelmap_list, info->ewi.scroll.gx_scroll_down_pixelmap);
676 }
677 if (info->ewi.scroll.gx_scroll_up_pixelmap)
678 {
679 CheckAddToList(write_pixelmap_list, info->ewi.scroll.gx_scroll_up_pixelmap);
680 }
681 if (info->ewi.scroll.gx_scroll_fill_pixelmap)
682 {
683 CheckAddToList(write_pixelmap_list, info->ewi.scroll.gx_scroll_fill_pixelmap);
684 }
685 if (info->ewi.scroll.gx_scroll_thumb_pixelmap)
686 {
687 CheckAddToList(write_pixelmap_list, info->ewi.scroll.gx_scroll_thumb_pixelmap);
688 }
689 }
690 else
691 {
692 if (info->basetype == GX_TYPE_SPRITE)
693 {
694 GX_SPRITE_FRAME *frame = info->ewi.sprite.framelist;
695
696 for (index = 0; index < info->ewi.sprite.frame_count; index++)
697 {
698 if (frame->gx_sprite_frame_pixelmap)
699 {
700 CheckAddToList(write_pixelmap_list, frame->gx_sprite_frame_pixelmap);
701 }
702 frame++;
703 }
704 }
705 }
706
707 if (info->GetChildWidgetInfo())
708 {
709 BuildResourceList(info->GetChildWidgetInfo());
710 }
711 if (entry)
712 {
713 info = NULL;
714 }
715 else
716 {
717 info = info->GetNextWidgetInfo();
718 }
719 }
720 }
721
722 ///////////////////////////////////////////////////////////////////////////////
BuildBaseList(widget_info * base)723 void copy_paste_engine::BuildBaseList(widget_info *base)
724 {
725 if (!base->is_template)
726 {
727 BuildResourceList(base, TRUE);
728 }
729
730 folder_info *folder = mProject->mDisplays[mDisplay].GetFirstChildFolder();
731
732 while (base->basetype == GX_TYPE_TEMPLATE)
733 {
734 base = mProject->FindWidgetInfo(folder, base->base_name, FALSE);
735
736 CheckAddToBaseList(base);
737 }
738 }
739
740 ///////////////////////////////////////////////////////////////////////////////
CheckAddToBaseList(widget_info * base)741 void copy_paste_engine::CheckAddToBaseList(widget_info *base)
742 {
743 if (IsItemInArray<widget_info *>(base_list, base))
744 {
745 return;
746 }
747
748 BuildResourceList(base, TRUE);
749 base_list.Add(base);
750 }
751
752 ///////////////////////////////////////////////////////////////////////////////
TranslateId(CArray<resource_trans_entry> & list,int res_type,int res_id)753 int copy_paste_engine::TranslateId(CArray<resource_trans_entry> &list, int res_type, int res_id)
754 {
755 int index;
756 CString source_name;
757 CString translate_name;
758 string_table *table;
759 int translate_id = res_id;
760
761 switch (res_type)
762 {
763 case RES_TYPE_COLOR:
764 mProject->GetResourceName(mDisplay, res_type, res_id, source_name);
765 break;
766 case RES_TYPE_STRING:
767 table = mProject->mDisplays[mDisplay].stable;
768 if (table)
769 {
770 source_name = table->GetResourceIdName(res_id);
771 }
772 break;
773 }
774
775 for (index = 0; index < list.GetCount(); index++)
776 {
777 if (list.GetAt(index).source_id_name == source_name)
778 {
779 translate_name = list.GetAt(index).translated_id_name;
780 break;
781 }
782 }
783
784 if (translate_name.IsEmpty())
785 {
786 //default color id
787 translate_name = source_name;
788 }
789
790 if (translate_name != source_name)
791 {
792 switch (res_type)
793 {
794 case RES_TYPE_COLOR:
795 translate_id = mProject->GetResourceId(mDisplay, res_type, translate_name);
796 break;
797 case RES_TYPE_STRING:
798 if (table)
799 {
800 translate_id = table->GetResourceId(translate_name);
801 }
802 break;
803 }
804 }
805
806 return translate_id;
807 }
808
809 ///////////////////////////////////////////////////////////////////////////////
TranslateWidgetResourceIds(widget_info * info)810 void copy_paste_engine::TranslateWidgetResourceIds(widget_info *info)
811 {
812 int index;
813 CString name;
814 CString translate_name;
815
816 while (info)
817 {
818 for (index = 0; index < NUM_WIDGET_COLORS; index++)
819 {
820 if (info->color_id[index] != 0)
821 {
822 info->color_id[index] = TranslateId(color_trans, RES_TYPE_COLOR, info->color_id[index]);
823 }
824 }
825
826 for (index = 0; index < NUM_WIDGET_STRINGS; index++)
827 {
828 if (info->string_id[index] != 0)
829 {
830 info->string_id[index] = TranslateId(string_trans, RES_TYPE_STRING, info->string_id[index]);
831 }
832 }
833
834 if (info->GetChildWidgetInfo())
835 {
836 TranslateWidgetResourceIds(info->GetChildWidgetInfo());
837 }
838 info = info->GetNextWidgetInfo();
839 }
840 }
841
842