1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Resource processing
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RESOURCEH__
13 #define _WX_RESOURCEH__
16 #pragma interface "resource.h"
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
29 #define RESOURCE_PLATFORM_WINDOWS 1
30 #define RESOURCE_PLATFORM_X 2
31 #define RESOURCE_PLATFORM_MAC 3
32 #define RESOURCE_PLATFORM_ANY 4
35 * Internal format for control/panel item
38 class WXDLLEXPORT wxItemResource
: public wxObject
40 DECLARE_DYNAMIC_CLASS(wxItemResource
)
45 int x
, y
, width
, height
;
49 long value1
, value2
, value3
, value5
;
52 wxStringList
*stringValues
; // Optional string values
54 wxColour
*backgroundColour
;
55 wxColour
*labelColour
;
56 wxColour
*buttonColour
;
61 ~wxItemResource(void);
63 void SetType(char *typ
);
64 inline void SetStyle(long styl
) { windowStyle
= styl
; }
65 inline void SetId(int id
) { m_windowId
= id
; }
66 inline void SetBitmap(wxBitmap
*bm
) { bitmap
= bm
; }
67 inline wxBitmap
*GetBitmap(void) { return bitmap
; }
68 inline void SetFont(wxFont
*font
) { windowFont
= font
; }
69 inline wxFont
*GetFont(void) { return windowFont
; }
70 inline void SetSize(int xx
, int yy
, int ww
, int hh
)
71 { x
= xx
; y
= yy
; width
= ww
; height
= hh
; }
72 void SetTitle(char *t
);
73 void SetName(char *n
);
74 inline void SetValue1(long v
) { value1
= v
; }
75 inline void SetValue2(long v
) { value2
= v
; }
76 inline void SetValue3(long v
) { value3
= v
; }
77 inline void SetValue5(long v
) { value5
= v
; }
78 void SetValue4(char *v
);
79 void SetStringValues(wxStringList
*svalues
);
81 inline char *GetType(void) { return itemType
; }
82 inline int GetX(void) { return x
; }
83 inline int GetY(void) { return y
; }
84 inline int GetWidth(void) { return width
; }
85 inline int GetHeight(void) { return height
; }
87 inline char *GetTitle(void) { return title
; }
88 inline char *GetName(void) { return name
; }
89 inline long GetStyle(void) { return windowStyle
; }
90 inline int GetId(void) { return m_windowId
; }
92 inline long GetValue1(void) { return value1
; }
93 inline long GetValue2(void) { return value2
; }
94 inline long GetValue3(void) { return value3
; }
95 inline long GetValue5(void) { return value5
; }
96 inline char *GetValue4(void) { return value4
; }
97 inline wxList
& GetChildren(void) { return children
; }
98 inline wxStringList
*GetStringValues(void) { return stringValues
; }
100 inline void SetBackgroundColour(wxColour
*col
) { if (backgroundColour
) delete backgroundColour
; backgroundColour
= col
; }
101 inline void SetLabelColour(wxColour
*col
) { if (labelColour
) delete labelColour
; labelColour
= col
; }
102 inline void SetButtonColour(wxColour
*col
) { if (buttonColour
) delete buttonColour
; buttonColour
= col
; }
104 inline wxColour
*GetBackgroundColour(void) { return backgroundColour
; }
105 inline wxColour
*GetLabelColour(void) { return labelColour
; }
106 inline wxColour
*GetButtonColour(void) { return buttonColour
; }
110 * Resource table (normally only one of these)
113 class WXDLLEXPORT wxResourceTable
: public wxHashTable
115 DECLARE_DYNAMIC_CLASS(wxResourceTable
)
120 wxHashTable identifiers
;
122 wxResourceTable(void);
123 ~wxResourceTable(void);
125 virtual wxItemResource
*FindResource(const wxString
& name
) const;
126 virtual void AddResource(wxItemResource
*item
);
127 virtual bool DeleteResource(const wxString
& name
);
129 virtual bool ParseResourceFile(char *filename
);
130 virtual bool ParseResourceData(char *data
);
131 virtual bool SaveResource(char *filename
);
133 // Register XBM/XPM data
134 virtual bool RegisterResourceBitmapData(char *name
, char bits
[], int width
, int height
);
135 virtual bool RegisterResourceBitmapData(char *name
, char **data
);
137 virtual wxControl
*CreateItem(wxWindow
*panel
, wxItemResource
*childResource
) const;
139 virtual void ClearTable(void);
142 extern void WXDLLEXPORT
wxInitializeResourceSystem(void);
143 extern void WXDLLEXPORT
wxCleanUpResourceSystem(void);
145 WXDLLEXPORT_DATA(extern wxResourceTable
*) wxDefaultResourceTable
;
146 extern long WXDLLEXPORT
wxParseWindowStyle(char *style
);
148 class WXDLLEXPORT wxMenuBar
;
149 class WXDLLEXPORT wxMenu
;
150 class WXDLLEXPORT wxBitmap
;
151 class WXDLLEXPORT wxIcon
;
152 extern wxBitmap
* WXDLLEXPORT
wxResourceCreateBitmap(char *resource
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
153 extern wxIcon
* WXDLLEXPORT
wxResourceCreateIcon(char *resource
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
154 extern wxMenuBar
* WXDLLEXPORT
wxResourceCreateMenuBar(char *resource
, wxResourceTable
*table
= (wxResourceTable
*) NULL
, wxMenuBar
*menuBar
= (wxMenuBar
*) NULL
);
155 extern wxMenu
* WXDLLEXPORT
wxResourceCreateMenu(char *resource
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
156 extern bool WXDLLEXPORT
wxResourceParseData(char *resource
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
157 extern bool WXDLLEXPORT
wxResourceParseFile(char *filename
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
158 extern bool WXDLLEXPORT
wxResourceParseString(char *s
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
159 extern void WXDLLEXPORT
wxResourceClear(wxResourceTable
*table
= (wxResourceTable
*) NULL
);
160 // Register XBM/XPM data
161 extern bool WXDLLEXPORT
wxResourceRegisterBitmapData(char *name
, char bits
[], int width
, int height
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
162 extern bool WXDLLEXPORT
wxResourceRegisterBitmapData(char *name
, char **data
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
163 #define wxResourceRegisterIconData wxResourceRegisterBitmapData
166 * Resource identifer code: #define storage
169 extern bool WXDLLEXPORT
wxResourceAddIdentifier(char *name
, int value
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
170 extern int WXDLLEXPORT
wxResourceGetIdentifier(char *name
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);