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