1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Resource processing
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RESOURCEH__
13 #define _WX_RESOURCEH__
16 #include "wx/deprecated/setup.h"
18 #if wxUSE_WX_RESOURCES
20 #include "wx/bitmap.h"
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
28 #define RESOURCE_PLATFORM_WINDOWS 1
29 #define RESOURCE_PLATFORM_X 2
30 #define RESOURCE_PLATFORM_MAC 3
31 #define RESOURCE_PLATFORM_ANY 4
33 // Extended styles: for resource usage only
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
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))
52 class WXDLLEXPORT wxInputStream
;
55 * Internal format for control/panel item
58 class WXDLLIMPEXP_DEPRECATED wxItemResource
: public wxObject
60 DECLARE_DYNAMIC_CLASS(wxItemResource
)
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
; }
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
; }
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
; }
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
; }
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
; }
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
; }
112 inline void SetResourceStyle(long style
) { m_exStyle
= style
; }
113 inline wxInt32
GetResourceStyle() const { return m_exStyle
; }
118 int m_x
, m_y
, m_width
, m_height
;
122 long m_value1
, m_value2
, m_value3
, m_value5
;
125 wxStringList m_stringValues
; // Optional string values
127 wxColour m_backgroundColour
;
128 wxColour m_labelColour
;
129 wxColour m_buttonColour
;
131 long m_exStyle
; // Extended, resource-specific styles
135 * Resource table (normally only one of these)
138 class WXDLLIMPEXP_DEPRECATED wxResourceTable
: public wxHashTable
140 DECLARE_DYNAMIC_CLASS(wxResourceTable
)
145 wxHashTable identifiers
;
150 virtual wxItemResource
*FindResource(const wxString
& name
) const;
151 virtual void AddResource(wxItemResource
*item
);
152 virtual bool DeleteResource(const wxString
& name
);
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
);
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
);
163 virtual wxControl
*CreateItem(wxWindow
*panel
, const wxItemResource
* childResource
, const wxItemResource
* parentResource
) const;
165 virtual void ClearTable();
168 WXDLLIMPEXP_DEPRECATED
extern void wxInitializeResourceSystem();
169 WXDLLIMPEXP_DEPRECATED
extern void wxCleanUpResourceSystem();
171 WXDLLIMPEXP_DATA_DEPRECATED(extern wxResourceTable
*) wxDefaultResourceTable
;
172 WXDLLIMPEXP_DEPRECATED
extern long wxParseWindowStyle(const wxString
& style
);
174 class WXDLLEXPORT wxMenuBar
;
175 class WXDLLEXPORT wxMenu
;
176 class WXDLLEXPORT wxBitmap
;
177 class WXDLLEXPORT wxIcon
;
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
);
188 // Register XBM/XPM data
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
);
191 #define wxResourceRegisterIconData wxResourceRegisterBitmapData
194 * Resource identifer code: #define storage
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
);
200 // Used to be wxWindowBase::LoadFromResource
201 WXDLLIMPEXP_DEPRECATED
bool wxLoadFromResource(wxWindow
* thisWindow
, wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
203 // Used to be wxWindowBase::CreateItem
204 WXDLLIMPEXP_DEPRECATED wxControl
*wxCreateItem(wxWindow
* thisWindow
, const wxItemResource
*resource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
206 #if defined(__WXPM__)
207 #include "wx/os2/wxrsc.h"