]>
Commit | Line | Data |
---|---|---|
4a3bdee6 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: resource.h | |
3 | // Purpose: Resource processing | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_RESOURCEH__ | |
13 | #define _WX_RESOURCEH__ | |
14 | ||
4a3bdee6 JS |
15 | #include "wx/setup.h" |
16 | #include "wx/deprecated/setup.h" | |
17 | ||
18 | #if wxUSE_WX_RESOURCES | |
19 | ||
20 | #include "wx/bitmap.h" | |
21 | #include <stdio.h> | |
22 | ||
23 | // A few further types not in wx_types.h | |
24 | #define wxRESOURCE_TYPE_SEPARATOR 1000 | |
25 | #define wxRESOURCE_TYPE_XBM_DATA 1001 | |
26 | #define wxRESOURCE_TYPE_XPM_DATA 1002 | |
27 | ||
28 | #define RESOURCE_PLATFORM_WINDOWS 1 | |
29 | #define RESOURCE_PLATFORM_X 2 | |
30 | #define RESOURCE_PLATFORM_MAC 3 | |
31 | #define RESOURCE_PLATFORM_ANY 4 | |
32 | ||
33 | // Extended styles: for resource usage only | |
34 | ||
35 | // Use dialog units instead of pixels | |
36 | #define wxRESOURCE_DIALOG_UNITS 0x0001 | |
37 | // Use default system colour and font | |
38 | #define wxRESOURCE_USE_DEFAULTS 0x0002 | |
39 | // Old-style vertical label | |
40 | #define wxRESOURCE_VERTICAL_LABEL 0x0004 | |
41 | // Old-style horizontal label | |
42 | #define wxRESOURCE_HORIZONTAL_LABEL 0x0008 | |
43 | ||
44 | // Macros to help use dialog units | |
45 | #define wxDLG_POINT(x, y, parent, useDlgUnits) (useDlgUnits ? parent->ConvertDialogToPixel(wxPoint(x, y)) : wxPoint(x, y)) | |
46 | #define wxDLG_SIZE(x, y, parent, useDlgUnits) (useDlgUnits ? parent->ConvertDialogToPixel(wxSize(x, y)) : wxSize(x, y)) | |
47 | ||
48 | #ifdef FindResource | |
49 | #undef FindResource | |
50 | #endif | |
51 | ||
52 | class WXDLLEXPORT wxInputStream; | |
53 | ||
54 | /* | |
55 | * Internal format for control/panel item | |
56 | */ | |
57 | ||
15e8daec | 58 | class WXDLLIMPEXP_DEPRECATED wxItemResource: public wxObject |
4a3bdee6 JS |
59 | { |
60 | DECLARE_DYNAMIC_CLASS(wxItemResource) | |
61 | ||
62 | public: | |
63 | ||
64 | wxItemResource(); | |
65 | ~wxItemResource(); | |
66 | ||
67 | inline void SetType(const wxString& type) { m_itemType = type; } | |
68 | inline void SetStyle(long styl) { m_windowStyle = styl; } | |
69 | inline void SetId(int id) { m_windowId = id; } | |
70 | inline void SetBitmap(const wxBitmap& bm) { m_bitmap = bm; } | |
71 | inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; } | |
72 | inline void SetFont(const wxFont& font) { m_windowFont = font; } | |
73 | inline wxFont& GetFont() const { return (wxFont&) m_windowFont; } | |
74 | inline void SetSize(int xx, int yy, int ww, int hh) | |
75 | { m_x = xx; m_y = yy; m_width = ww; m_height = hh; } | |
76 | inline void SetTitle(const wxString& title) { m_title = title; } | |
77 | inline void SetName(const wxString& name) { m_name = name; } | |
78 | inline void SetValue1(long v) { m_value1 = v; } | |
79 | inline void SetValue2(long v) { m_value2 = v; } | |
80 | inline void SetValue3(long v) { m_value3 = v; } | |
81 | inline void SetValue5(long v) { m_value5 = v; } | |
82 | inline void SetValue4(const wxString& v) { m_value4 = v; } | |
83 | inline void SetStringValues(const wxStringList& svalues) { m_stringValues = svalues; } | |
84 | ||
85 | inline const wxString& GetType() const { return m_itemType; } | |
86 | inline int GetX() const { return m_x; } | |
87 | inline int GetY() const { return m_y; } | |
88 | inline int GetWidth() const { return m_width; } | |
89 | inline int GetHeight() const { return m_height; } | |
90 | ||
91 | inline const wxString& GetTitle() const { return m_title; } | |
92 | inline const wxString& GetName() const { return m_name; } | |
93 | inline long GetStyle() const { return m_windowStyle; } | |
94 | inline int GetId() const { return m_windowId; } | |
95 | ||
96 | inline wxInt32 GetValue1() const { return m_value1; } | |
97 | inline wxInt32 GetValue2() const { return m_value2; } | |
98 | inline wxInt32 GetValue3() const { return m_value3; } | |
99 | inline wxInt32 GetValue5() const { return m_value5; } | |
100 | inline wxString GetValue4() const { return m_value4; } | |
101 | inline wxList& GetChildren() const { return (wxList&) m_children; } | |
102 | inline wxStringList& GetStringValues() const { return (wxStringList&) m_stringValues; } | |
103 | ||
104 | inline void SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; } | |
105 | inline void SetLabelColour(const wxColour& col) { m_labelColour = col; } | |
106 | inline void SetButtonColour(const wxColour& col) { m_buttonColour = col; } | |
318c5e9f | 107 | |
4a3bdee6 JS |
108 | inline wxColour& GetBackgroundColour() const { return (wxColour&) m_backgroundColour; } |
109 | inline wxColour& GetLabelColour() const { return (wxColour&) m_labelColour; } | |
110 | inline wxColour& GetButtonColour() const { return (wxColour&) m_buttonColour; } | |
111 | ||
112 | inline void SetResourceStyle(long style) { m_exStyle = style; } | |
113 | inline wxInt32 GetResourceStyle() const { return m_exStyle; } | |
114 | ||
115 | protected: | |
116 | wxList m_children; | |
117 | wxString m_itemType; | |
118 | int m_x, m_y, m_width, m_height; | |
119 | wxString m_title; | |
120 | wxString m_name; | |
121 | long m_windowStyle; | |
122 | long m_value1, m_value2, m_value3, m_value5; | |
123 | wxString m_value4; | |
124 | int m_windowId; | |
125 | wxStringList m_stringValues; // Optional string values | |
126 | wxBitmap m_bitmap; | |
127 | wxColour m_backgroundColour; | |
128 | wxColour m_labelColour; | |
129 | wxColour m_buttonColour; | |
130 | wxFont m_windowFont; | |
131 | long m_exStyle; // Extended, resource-specific styles | |
132 | }; | |
133 | ||
134 | /* | |
135 | * Resource table (normally only one of these) | |
136 | */ | |
318c5e9f | 137 | |
15e8daec | 138 | class WXDLLIMPEXP_DEPRECATED wxResourceTable: public wxHashTable |
4a3bdee6 JS |
139 | { |
140 | DECLARE_DYNAMIC_CLASS(wxResourceTable) | |
141 | ||
142 | protected: | |
318c5e9f | 143 | |
4a3bdee6 JS |
144 | public: |
145 | wxHashTable identifiers; | |
318c5e9f | 146 | |
4a3bdee6 JS |
147 | wxResourceTable(); |
148 | ~wxResourceTable(); | |
149 | ||
150 | virtual wxItemResource *FindResource(const wxString& name) const; | |
151 | virtual void AddResource(wxItemResource *item); | |
152 | virtual bool DeleteResource(const wxString& name); | |
153 | ||
154 | virtual bool ParseResourceFile(const wxString& filename); | |
155 | virtual bool ParseResourceFile(wxInputStream *is); | |
156 | virtual bool ParseResourceData(const wxString& data); | |
157 | virtual bool SaveResource(const wxString& filename); | |
158 | ||
159 | // Register XBM/XPM data | |
160 | virtual bool RegisterResourceBitmapData(const wxString& name, char bits[], int width, int height); | |
161 | virtual bool RegisterResourceBitmapData(const wxString& name, char **data); | |
162 | ||
163 | virtual wxControl *CreateItem(wxWindow *panel, const wxItemResource* childResource, const wxItemResource* parentResource) const; | |
164 | ||
165 | virtual void ClearTable(); | |
166 | }; | |
167 | ||
15e8daec VS |
168 | WXDLLIMPEXP_DEPRECATED extern void wxInitializeResourceSystem(); |
169 | WXDLLIMPEXP_DEPRECATED extern void wxCleanUpResourceSystem(); | |
4a3bdee6 | 170 | |
15e8daec VS |
171 | WXDLLIMPEXP_DATA_DEPRECATED(extern wxResourceTable*) wxDefaultResourceTable; |
172 | WXDLLIMPEXP_DEPRECATED extern long wxParseWindowStyle(const wxString& style); | |
4a3bdee6 JS |
173 | |
174 | class WXDLLEXPORT wxMenuBar; | |
175 | class WXDLLEXPORT wxMenu; | |
176 | class WXDLLEXPORT wxBitmap; | |
177 | class WXDLLEXPORT wxIcon; | |
15e8daec VS |
178 | WXDLLIMPEXP_DEPRECATED extern wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL); |
179 | WXDLLIMPEXP_DEPRECATED extern wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL); | |
180 | WXDLLIMPEXP_DEPRECATED extern wxMenuBar* wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL, wxMenuBar *menuBar = (wxMenuBar *) NULL); | |
181 | WXDLLIMPEXP_DEPRECATED extern wxMenu* wxResourceCreateMenu(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL); | |
182 | WXDLLIMPEXP_DEPRECATED extern bool wxResourceParseData(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL); | |
183 | WXDLLIMPEXP_DEPRECATED extern bool wxResourceParseData(const char* resource, wxResourceTable *table = (wxResourceTable *) NULL); | |
184 | WXDLLIMPEXP_DEPRECATED extern bool wxResourceParseFile(const wxString& filename, wxResourceTable *table = (wxResourceTable *) NULL); | |
185 | WXDLLIMPEXP_DEPRECATED extern bool wxResourceParseString(char* s, wxResourceTable *table = (wxResourceTable *) NULL); | |
186 | WXDLLIMPEXP_DEPRECATED extern bool wxResourceParseString(const wxString& s, wxResourceTable *table = (wxResourceTable *) NULL); | |
187 | WXDLLIMPEXP_DEPRECATED extern void wxResourceClear(wxResourceTable *table = (wxResourceTable *) NULL); | |
4a3bdee6 | 188 | // Register XBM/XPM data |
15e8daec VS |
189 | WXDLLIMPEXP_DEPRECATED extern bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL); |
190 | WXDLLIMPEXP_DEPRECATED extern bool wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceTable *table = (wxResourceTable *) NULL); | |
4a3bdee6 JS |
191 | #define wxResourceRegisterIconData wxResourceRegisterBitmapData |
192 | ||
193 | /* | |
194 | * Resource identifer code: #define storage | |
195 | */ | |
196 | ||
15e8daec VS |
197 | WXDLLIMPEXP_DEPRECATED extern bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *table = (wxResourceTable *) NULL); |
198 | WXDLLIMPEXP_DEPRECATED extern int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table = (wxResourceTable *) NULL); | |
4a3bdee6 | 199 | |
c6dafd93 | 200 | // Used to be wxWindowBase::LoadFromResource |
172df1f0 | 201 | WXDLLIMPEXP_DEPRECATED bool wxLoadFromResource(wxWindow* thisWindow, wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = (const wxResourceTable *) NULL); |
c6dafd93 JS |
202 | |
203 | // Used to be wxWindowBase::CreateItem | |
172df1f0 | 204 | WXDLLIMPEXP_DEPRECATED wxControl *wxCreateItem(wxWindow* thisWindow, const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table = (const wxResourceTable *) NULL); |
c6dafd93 | 205 | |
4a3bdee6 JS |
206 | #if defined(__WXPM__) |
207 | #include "wx/os2/wxrsc.h" | |
208 | #endif | |
209 | #endif | |
210 | #endif | |
211 | // _WX_RESOURCEH__ |