1 
2 struct string_table_record
3 {
string_table_recordstring_table_record4     string_table_record()
5     {
6         id_name = _T("");
7         strings = NULL;
8         notes = _T("");
9         font_id = 0;
10     }
11     CString id_name;
12     CString *strings;
13     CString notes;
14     int     font_id;
15 };
16 
17 class widget_info;
18 
19 struct string_reference_record
20 {
21     CString id_name;
22     CArray<widget_info *> reference_list;
23 };
24 
25 class FontCharMap
26 {
27     public:
28         FontCharMap();
29         ~FontCharMap();
GetMapSize()30         DWORD GetMapSize(){ return map_size; };
31         void SetMapSize(DWORD size);
32         void Clear();
33         void Set(DWORD index);
34         void Set(DWORD start, DWORD end);
35 
36         BOOL Test(DWORD index);
37         BOOL Test(DWORD start, DWORD end);
38 
39         BOOL TestAndSet(DWORD index);
40         BOOL AddToMap(CString &val);
41         void Overlay(FontCharMap *other);
42         BOOL IsEmpty();
43 
44     private:
45         unsigned char *map;
46         DWORD map_size;
47 };
48 
49 class string_table {
50     public:
51         string_table();
52         string_table(const string_table &other);     // copy constructor
53 
54         ~string_table();
55         static BOOL IsRight2LeftLanguage(int language_index);
56         static void EnableDisableRuntimeBidiText(int language_index);
57         static BOOL TestGenerateLanguageDirectionTable();
58         void Initialize(int num_languages, int num_strings);
59 
60         //import string from files
61         void ImportString(CString &id,
62             CString &src_string,
63             CString &target_string,
64             CString &notes,
65             int src_table_column,
66             int target_table_column);
67 
68         // this version is used by string table editor
69         int AddString();
70 
71         // this version is used when reading project
72         int AddString(CString &id_name, CString &str, bool update_guix = TRUE);
73 
74         // this version is used when user types in properties window
75         int  CheckAddString(CString &str, CString base_name = _T(""));
76 
77         int FindStringIndex(CString &id_name);
78 
79         void AddLanguage(void);
80 
81         void RemoveString(CString &id_name);
82         BOOL RemoveString(int string_index);
83         string_table_record &GetRecord(int string_index);
84         string_table_record &GetRecord(CString id_name);
85         CString &GetString(CString &id_name, int language = 0);
86         CString &GetString(int string_index, int language = 0);
87         CString &GetStringId(int string_index);
88         CString &GetNotes(int string_index);
89 
90         // assign id and string for given index and language
91         void SetString(int string_index, CString &id_name, int language, CString &str, bool update_guix = TRUE);
92 
93         // find id, assign string for given language
94         void SetString(CString &id_name, int language, CString &str, bool update_guix = TRUE);
95 
96         // assign only the string for index and language
97         void SetString(int string_index, int language, CString &str, bool update_guix = TRUE);
98 
99         // sort string table by ID name
100         void SortById();
101 
102         // sort string table by string
103         void SortByString();
104 
105         // sort string table by reference count
106         void SortByReferenceCount();
107 
108         void Sort();
109 
110         // assign only the string Id:
111         BOOL SetStringId(int string_index, CString &id_name);
112 
113         void SetNotes(int string_index, CString &notes);
114 
115         // assign font used to calculate string width
116         void SetDisplayFont(int string_index, int font_id);
117 
118         int CountStrings();
119         int CountLanguages();
120 
121         void CreateId(CString &id_name, CString base_name = _T(""));
122 
123         void UpdateGuixLanguageTable(GX_DISPLAY *display = GX_NULL, BOOL update_resource_view = GX_TRUE);
124         void SetActiveLanguage(int language);
GetActiveLanguage(void)125         int GetActiveLanguage(void) {return m_active_language;}
126         FontCharMap *GenerateCleanCharacterMap(void);
GetCharacterMap(void)127         FontCharMap *GetCharacterMap(void) {return &char_map;}
128         static void DeleteGuixLanguageTable(GX_STRING **pOldTable, int language_count,  int string_count);
129         static void DeleteGuixLanguageDirectionTable(GX_DISPLAY *display);
130 
131         void AddToDictionary(CString &id_name, int res_id = -1);
132         void RemoveFromDictionary(CString &id_name);
133         CString UpdateRichTextResourceName(CString& val, int res_type, CString old_id_name, CString new_id_name);
134         void UpdateStringTableRichTextResourceName(int res_type, CString& old_id_name, CString& new_id_name);
135         void UpdateDictionaryResourceName(CString &old_id_name, CString &new_id_name);
136         CString GetResourceIdName(int res_id, widget_info *info = NULL);
137         GX_RESOURCE_ID GetResourceId(CString &id_name);
138 
SetSortColumn(int sort_column)139         void SetSortColumn(int sort_column){ m_sort_column = sort_column; };
GetSortColumn()140         int GetSortColumn(){ return m_sort_column; };
141 
ClearStringTableCharMap()142         inline void ClearStringTableCharMap() { char_map.Clear(); };
143 
144         void MakeMLViewReferenceRecord(int display);
145         string_reference_record *GetMLViewReferenceRecord(CString &id_name);
146         CArray<widget_info *> *GetMLViewReferenceWidgetInfoList(CString& id_name);
147         int CountGeneratedStrings();
148 
149     private:
150         bool MakeMLViewReferenceRecord(widget_info* child);
151         void CleanUpMLViewRefereceRecord();
152 
153     private:
154         void CleanupStringTable();
155 
156         FontCharMap char_map;
157         int m_languages;
158         int m_active_language;
159         GX_CHAR ***language_table;
160         int m_sort_column;
161 
162         CArray<string_table_record> m_records;
163         CArray<CString> m_dictionary;
164         CArray<string_reference_record *> m_reference_records;
165 };
166 
167