1 
2 #ifndef _RESOURCE_GEN_
3 #define _RESOURCE_GEN_
4 
5 #define ENABLE_RENESAS_DAVE2D_DISPLAY_ROTATION
6 
7 class binary_resource_gen;
8 
9 class resource_gen : public studio_source_writer {
10     public:
11         resource_gen(studiox_project *project);
12         BOOL GenerateResourceFile(int display);
13         void InitOptimizedFonts();
14         void DestroyOptimizedFonts();
15         void CloseOutputFiles();
16         GX_FONT *GetPageHead(res_info* info, int theme_id, int font_id);
17 
18         static TCHAR** GetColorFormatTable(studiox_project *project);
19         static TCHAR* GetColorFormatName(int color_format);
20         static int GetColorFormatVal(CString name);
21         static void MakeUtf8String(studiox_project* project, CString val, int language_index, GX_STRING *string, int display, BOOL gen, widget_info *info = NULL);
22         static CString RichTextResIdName2ResId(studiox_project* project, int display, CString& val);
23         static BOOL IsRotatedResourceSupported(studiox_project *project, int display);
24         VOID RotateGlyphData(GX_CONST GX_GLYPH* glyph, GX_UBYTE font_format, GX_UBYTE** rotated_map, INT* rotated_map_size);
25         GX_PIXELMAP* RotatePixelmap(res_info* pixinfo, int theme_id, GX_PIXELMAP *map, int frame_id);
26 
27     private:
28         static bool GetMlTextDisplayInfo(widget_info* info, int *font_id, GX_VALUE* display_width);
29         static void MakeReorderedBidiText(GX_STRING *utf8str, GX_STRING *out_string, int display, widget_info *info = NULL);
30         static void MakeAdjustedThaiString(GX_STRING *utf8str, GX_STRING *out_string);
31         BOOL IsStringReferencedbyMlView(widget_info* info, GX_RESOURCE_ID resource_id);
32 
33     private:
34         BOOL  mUsingDefault8BitFont;
35         BOOL  mUsingDefault4BitFont;
36         BOOL  mUsingDefaultMonoFont;
37         BOOL  mDefaultPaletteWritten;
38         BOOL  mPrivatePaletteWritten;
39         GX_PIXELMAP *m_map;
40         CString      m_ThemeName;
41 
42         BOOL GenerateResourceData();
43 
44         void WriteDisplayDefines();
45         void WriteThemeDefines();
46         void WriteLanguageDefines();
47 
48         void WriteColorDefines(void);
49         void WriteFontDefines(void);
50         void WritePixelmapDefines(void);
51         void WriteStringDefines(void);
52 
53         void WriteColorTable(void);
54         void WritePalette(int theme);
55         void WritePalette(int palette_size, GX_COLOR *palette,
56             CString &pal_name);
57 
58         void WriteFontData(void);
59         void WriteFontTable(void);
60         void WritePixelmapStructure(res_info *info, int frame_id);
61         void WriteRawPixelmap(res_info *info, int frame_id);
62         void WritePixelmapData(void);
63         void WritePixelmapTable(void);
64         void WriteStringData(void);
65         void WriteOneStringData(CString &display_name, int language_index, int string_id);
66 
67         void WriteStringTable(void);
68         void WriteLanguageTable(CString display_name, INT language_count);
69         void WriteLanguageTableExt(CString display_name, INT language_count);
70         void WriteLanguageDirectionTable(CString display_name, INT language_count);
71         void WriteOneStringTable(CString &display_name, CString &language_name, int language_index, string_table *stable, int num_strings);
72         void WriteOneStringTableExt(CString &display_name, CString &language_name, int language_index, string_table* stable, int num_strings);
73         void WriteScrollbarAppearance(GX_SCROLLBAR_APPEARANCE &appear);
74         void WriteThemes(void);
75 
76         CString UpperProjectName();
77         CString UpperDisplayName();
78         CString UpperProjDisplayName();
79 
80         GX_PIXELMAP *ConvertPixelmapOutputFormat(res_info *info);
81 
82         GX_UBYTE* Rotate8bitGlyphData(GX_CONST GX_UBYTE* map, INT width, INT height);
83         GX_UBYTE* Rotate4bitGlyphData(GX_CONST GX_UBYTE* map, INT width, INT height);
84         GX_UBYTE* Rotate1bitGlyphData(GX_CONST GX_UBYTE* map, INT width, INT height);
85         GX_UBYTE* RotateUIntData(GX_CONST GX_UBYTE* data, INT width, INT height);
86         GX_UBYTE* RotateUShortData(GX_CONST GX_UBYTE* data, INT width, INT height);
87         GX_UBYTE* RotateUCharData(GX_CONST GX_UBYTE* data, INT width, INT height);
88         VOID RotatePixelmap(GX_PIXELMAP* map);
89 
90         void WriteFont(res_info *info, int theme_id, int font_id);
91         void WriteFontPage(const GX_FONT *font, CString &name, int page, BOOL lastpage, BOOL custom_file_enabled);
92         void WriteKerningTable(GX_UBYTE *kerning_table, CString &name, GX_CHAR_CODE charval);
93         void WritePixelmapData(res_info *pixinfo, int theme_id, int frame_id);
94         BOOL CheckLineFeed(CString &out);
95         void WriteUintData(res_info *info, int frame_id);
96         void WriteUshortData(res_info *info, int frame_id);
97         void WriteCCRXCompatibleTargaStream(res_info *info, int frame_id);
98         void WriteBigEndianCompressedUshortData(res_info *info, int frame_id);
99         void WriteUcharData(res_info *info, int frame_id);
100         void WriteUcharAuxData(res_info *info, int frame_id);
101         void WriteUintAuxData(res_info *info, int frame_id);
102         BOOL SetOutFile(CString filename, BOOL binary_mode = 0);
103 
104         VOID WriteErrorDirectives();
105 
106     protected:
107         studiox_project *m_project;
108         BOOL m_warn_on_error;
109         int   m_display;
110         int   m_num_displays;
111         int   m_color_table_size;
112         int   m_font_table_size;
113         int   m_pixelmap_table_size;
114         BOOL  m_big_endian;
115         CArray<CString> m_pixelmap_dictionary;
116         CArray<CFile *> outfile_list;
117         CArray<GX_FONT *> m_optimized_fonts[MAX_THEMES];
118         binary_resource_gen* mp_bin_generater;
119         void CalculateTableSizes();
120         BOOL GenerateResourceHeader();
121         BOOL FontPageCompare(res_info *info_1, res_info* info_2);
122         int  FindResourceReferenceTheme(res_info *info, int theme);
123         CString GetResourceFileName();
124         BOOL IsSystemPixelmap(INT pixelmap_id);
125         BOOL IsResEnabled(res_info* info);
126 };
127 
128 #endif
129