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