1 
2 
3 #pragma once
4 
5 #include <afxcview.h>
6 
7 class resource_view_provider;
8 struct IMAGE_INFO;
9 
10 struct COLOR_RECORD {
11     char *name;
12     int color_id;
13     ULONG rgb_val;
14 };
15 
16 struct FONT_RECORD {
17     char *name;
18     int  font_id;
19     GX_FONT *font;
20 };
21 
22 struct PIXELMAP_RECORD {
23     char *name;
24     int  pixelmap_id;
25     BOOL include_alpha;
26     IMAGE_INFO *image_info;
27 };
28 
29 struct font_table {
30     GX_FONT **fonts;
31     int     num_fonts;
32 };
33 
34 struct color_table {
35     GX_COLOR *colors;
36     int      num_colors;
37 };
38 
39 struct pixelmap_table {
40     GX_PIXELMAP **maps;
41     int     num_maps;
42 };
43 
44 class resource_view : public CScrollView
45 {
46     protected:
47         DECLARE_DYNCREATE(resource_view)
48 
49     public:
50         resource_view();
51         ~resource_view();
52         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
53 	    virtual void OnDraw(CDC* pDC);
54 
55         void OnCloseProject();
56         void OnOpenProject();
57         void OnDisplaySelect(int DisplayIndex, BOOL bReload = FALSE);
58 
59         void OnTreeSizeChange();
60         virtual void OnInitialUpdate();
61         void RebuildStringItems(BOOL update_GUIX = TRUE);
62         void UpdateStringTableFonts(FontCharMap *map, res_info *start = NULL);
63         static GX_COLOR GetNativeColor(GX_COLOR rgb_color, int color_format);
64         static COLORREF GetColorRef(GX_COLOR gx_color, int color_format, GX_COLOR *palette, int palsize);
65 
66         //these functions are used in macro record and macro playback
67         //to save and reload the layout of resource view
68         BOOL IsOpen(int res_id);
69         void SetResFolderStatus(int res_id, int open_status);
70 
71         int  PasteResource(res_info *info, int conflict_option = 0);
72         int  PasteResource(string_table_record &record, int conflict_option = 0);
73         void FinalizePasteResources();
74         void InstallResources(int DisplayIndex);
75         void BuildResourceTables(int DisplayIndex, GX_DISPLAY *display, BOOL update_resource_view = GX_TRUE);
76         void CreateUniqueResourceName(res_info *info);
77         void SetCurrentItem(resource_item* item);
GetCurrentItem()78         resource_item* GetCurrentItem() { return mpCurrentItem; }
79 
80         static void CleanupDisplayResources(GX_DISPLAY *display);
81 
GetResTree()82         resource_tree* GetResTree() { return mpTree; }
83         resource_view_provider* GetResViewProvider();
84         static int CreateUniqueId();
85         void ScrollIntoView(resource_item *item);
86         void TaskAddPixelmaps(resource_item *parent, CStringArray *patharray);
87         void TaskInitializePixelmaps(resource_item *item);
88 
89     // Generated message map functions
90     protected:
91         void Scroll(int delta, BOOL redraw = TRUE);
92         void InsertTreeResources(resource_item *parent, res_info *start);
93         void AddStringItems(resource_item *parent);
94 
95         void InstallColorTable(int DisplayIndex, GX_DISPLAY *display = NULL);
96         void InstallFontTable(int DisplayIndex, GX_DISPLAY *display = NULL);
97         void InstallPixelmapTable(int DisplayIndex, GX_DISPLAY *display = NULL);
98         void CheckInstallPalette(int DisplayIndex, GX_DISPLAY *display);
99 
100 
101         void OnSetActiveLanguage(int delta);
102         void OnSetActiveTheme(int delta);
103 
104         int BuildColorTable(int DisplayIndex, int ThemeIndex, int color_format, color_table *table);
105         int BuildFontTable(int DisplayIndex, int ThemeIndex, font_table *table);
106         int BuildPixelmapTable(int DisplayIndex, int ThemeIndex, pixelmap_table *table);
107         void RestoreStringIdsFromBackup(widget_info *write, widget_info *read);
108         void RestoreStringIdsFromBackup(folder_info *write, folder_info *read);
109 
110         void PopupMenu(int MenuId, CPoint &pos);
111 
112         afx_msg BOOL OnEraseBkgnd(CDC *pDC);
113         afx_msg int OnCreate(LPCREATESTRUCT lpcs);
114         afx_msg void OnSize(UINT nType, int cx, int cy);
115         afx_msg void OnLButtonDown(UINT di, CPoint cp);
116         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
117         afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
118         afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
119         afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
120 
121         afx_msg void OnAddCustomColor();
122         afx_msg void OnEditCustomColor();
123         afx_msg void OnEditSystemColor();
124 
125         afx_msg void OnAddFont();
126         afx_msg void OnEditFont();
127         afx_msg void OnEditStringTable();
128         afx_msg void OnEditLanguages();
129         afx_msg void OnDeleteCustomColor();
130         afx_msg void OnDeleteFont();
131 
132         afx_msg void OnAddPixelmaps();
133         afx_msg void OnEditPixelmaps();
134         afx_msg void OnAddPixelmapFolder();
135         afx_msg void OnRemovePixelmapFolder();
136         afx_msg void OnRenamePixelmapFolder();
137         afx_msg void OnEnablePixelmapFolder();
138         afx_msg void OnDisablePixelmapFolder();
139         afx_msg void OnEditPixelmap();
140         afx_msg void OnDeletePixelmap();
141         afx_msg void OnEnablePixelmap();
142         afx_msg void OnDisablePixelmap();
143         afx_msg void OnGenerateXML();
144         afx_msg void OnTimer(UINT_PTR nIDEvent);
145         afx_msg LRESULT OnRebuildStringItems(WPARAM, LPARAM);
146         afx_msg LRESULT OnUpdateStringTableFonts(WPARAM, LPARAM);
147         afx_msg LRESULT OnOpenResourceItem(WPARAM, LPARAM);
148         afx_msg LRESULT OnTestMessage(WPARAM, LPARAM);
149         afx_msg void OnSetFocus(CWnd* pOldWnd);
150         afx_msg void OnKillFocus(CWnd* pNewWnd);
151         afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
152 
153         BOOL OnReturnKey(int item_type);
154         BOOL OnTabKey(int item_type);
155         BOOL OnDirectionKey(int item_type, int key);
156         void OnPageDonw(int item_type);
157         void OnPageUp(int item_type);
158         void OnHome(int item_type);
159         void OnEnd(int item_type);
160         virtual BOOL PreTranslateMessage(MSG* pMsg);
161         virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
162 
163         void SelectNextItem();
164         void SelectPreviousItem();
165 
166         void AddColor(GX_COLOR color, CString name, resource_item *parent);
167 
168         void AddPixelmap(resource_item *parent, res_info *info, BOOL palette_mode);
169         void AddPixelmaps(resource_item *parent, CStringArray *patharray);
170         void InitializePixelmaps(resource_item *item);
171         void EditPixelmaps(resource_item *item);
172         void AddFont(resource_item *parent, res_info *info);
173         void EditFont(resource_item *item, CString &old_font_path);
174 
175         res_info *InitFontInfo();
176 
177         DECLARE_MESSAGE_MAP()
178 
179         int mDisplayIndex;
180 
181         resource_tree *mpTree;
182         resource_item *mpCurrentItem;
183         resource_item *mpDragItem;
184         GX_COLOR      *mpPalette;
185         int            mTimerTicks;
186         BOOL           mNewResourcePasted;
187 
188         resource_view_provider* m_pResViewProvider;
189 
190     private:
191         void DeleteResourceChildren(res_info *parent);
192         void SyncResourceName(CString &old_name, res_info *info);
193         void SyncResourceAdd(res_info *info);
194         void SyncResourceDelete(res_info *info);
195         void SyncResourcePath(res_info *info);
196         void ChangeItemParent(resource_item *item, resource_item *new_parent);
197         void EnableDisableChild(res_info *parent, int target_child_type, GX_BOOL enable);
198         int  GetFolderEnableDisableState(res_info* parent);
199 };