]> git.saurik.com Git - wxWidgets.git/blame - include/wx/resource.h
Bitmap button updates
[wxWidgets.git] / include / wx / resource.h
CommitLineData
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 14
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
145aa406
JS
16#pragma interface "resource.h"
17#endif
18
19#include "wx/setup.h"
20
47d67540 21#if wxUSE_WX_RESOURCES
43b2cccb
GRG
22
23#include "wx/bitmap.h"
145aa406
JS
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
fd71308f
JS
36// Extended styles: for resource usage only
37
38// Use dialog units instead of pixels
f6bcfd97 39#define wxRESOURCE_DIALOG_UNITS 0x0001
fd71308f 40// Use default system colour and font
f6bcfd97
BP
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
fd71308f
JS
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
ce3ed50d
JS
51#ifdef FindResource
52#undef FindResource
53#endif
54
0b9ab0bd
RL
55class WXDLLEXPORT wxInputStream;
56
145aa406
JS
57/*
58 * Internal format for control/panel item
59 */
a6f6393c 60
145aa406
JS
61class WXDLLEXPORT wxItemResource: public wxObject
62{
63 DECLARE_DYNAMIC_CLASS(wxItemResource)
64
145aa406 65 public:
a6f6393c 66
fd71308f
JS
67 wxItemResource();
68 ~wxItemResource();
145aa406 69
fd71308f
JS
70 inline void SetType(const wxString& type) { m_itemType = type; }
71 inline void SetStyle(long styl) { m_windowStyle = styl; }
145aa406 72 inline void SetId(int id) { m_windowId = id; }
fd71308f
JS
73 inline void SetBitmap(const wxBitmap& bm) { m_bitmap = bm; }
74 inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
75 inline void SetFont(const wxFont& font) { m_windowFont = font; }
76 inline wxFont& GetFont() const { return (wxFont&) m_windowFont; }
145aa406 77 inline void SetSize(int xx, int yy, int ww, int hh)
fd71308f
JS
78 { m_x = xx; m_y = yy; m_width = ww; m_height = hh; }
79 inline void SetTitle(const wxString& title) { m_title = title; }
80 inline void SetName(const wxString& name) { m_name = name; }
81 inline void SetValue1(long v) { m_value1 = v; }
82 inline void SetValue2(long v) { m_value2 = v; }
83 inline void SetValue3(long v) { m_value3 = v; }
84 inline void SetValue5(long v) { m_value5 = v; }
85 inline void SetValue4(const wxString& v) { m_value4 = v; }
86 inline void SetStringValues(const wxStringList& svalues) { m_stringValues = svalues; }
87
649ef4c6 88 inline const wxString& GetType() const { return m_itemType; }
fd71308f
JS
89 inline int GetX() const { return m_x; }
90 inline int GetY() const { return m_y; }
91 inline int GetWidth() const { return m_width; }
92 inline int GetHeight() const { return m_height; }
93
649ef4c6
BM
94 inline const wxString& GetTitle() const { return m_title; }
95 inline const wxString& GetName() const { return m_name; }
fd71308f
JS
96 inline long GetStyle() const { return m_windowStyle; }
97 inline int GetId() const { return m_windowId; }
98
e70f5e13
RR
99 inline wxInt32 GetValue1() const { return m_value1; }
100 inline wxInt32 GetValue2() const { return m_value2; }
101 inline wxInt32 GetValue3() const { return m_value3; }
102 inline wxInt32 GetValue5() const { return m_value5; }
fd71308f
JS
103 inline wxString GetValue4() const { return m_value4; }
104 inline wxList& GetChildren() const { return (wxList&) m_children; }
105 inline wxStringList& GetStringValues() const { return (wxStringList&) m_stringValues; }
106
107 inline void SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; }
108 inline void SetLabelColour(const wxColour& col) { m_labelColour = col; }
109 inline void SetButtonColour(const wxColour& col) { m_buttonColour = col; }
145aa406 110
fd71308f
JS
111 inline wxColour& GetBackgroundColour() const { return (wxColour&) m_backgroundColour; }
112 inline wxColour& GetLabelColour() const { return (wxColour&) m_labelColour; }
113 inline wxColour& GetButtonColour() const { return (wxColour&) m_buttonColour; }
114
115 inline void SetResourceStyle(long style) { m_exStyle = style; }
e70f5e13 116 inline wxInt32 GetResourceStyle() const { return m_exStyle; }
fd71308f
JS
117
118 protected:
119 wxList m_children;
120 wxString m_itemType;
121 int m_x, m_y, m_width, m_height;
122 wxString m_title;
123 wxString m_name;
124 long m_windowStyle;
125 long m_value1, m_value2, m_value3, m_value5;
126 wxString m_value4;
127 int m_windowId;
128 wxStringList m_stringValues; // Optional string values
129 wxBitmap m_bitmap;
130 wxColour m_backgroundColour;
131 wxColour m_labelColour;
132 wxColour m_buttonColour;
133 wxFont m_windowFont;
134 long m_exStyle; // Extended, resource-specific styles
145aa406
JS
135};
136
137/*
138 * Resource table (normally only one of these)
139 */
140
141class WXDLLEXPORT wxResourceTable: public wxHashTable
142{
143 DECLARE_DYNAMIC_CLASS(wxResourceTable)
144
145 protected:
146
147 public:
148 wxHashTable identifiers;
149
fd71308f
JS
150 wxResourceTable();
151 ~wxResourceTable();
152
145aa406
JS
153 virtual wxItemResource *FindResource(const wxString& name) const;
154 virtual void AddResource(wxItemResource *item);
155 virtual bool DeleteResource(const wxString& name);
156
fd71308f 157 virtual bool ParseResourceFile(const wxString& filename);
0b9ab0bd 158 virtual bool ParseResourceFile(wxInputStream *is);
fd71308f
JS
159 virtual bool ParseResourceData(const wxString& data);
160 virtual bool SaveResource(const wxString& filename);
145aa406
JS
161
162 // Register XBM/XPM data
fd71308f
JS
163 virtual bool RegisterResourceBitmapData(const wxString& name, char bits[], int width, int height);
164 virtual bool RegisterResourceBitmapData(const wxString& name, char **data);
145aa406 165
fd71308f 166 virtual wxControl *CreateItem(wxWindow *panel, const wxItemResource* childResource, const wxItemResource* parentResource) const;
145aa406 167
fd71308f 168 virtual void ClearTable();
145aa406
JS
169};
170
184b5d99
JS
171WXDLLEXPORT extern void wxInitializeResourceSystem();
172WXDLLEXPORT extern void wxCleanUpResourceSystem();
145aa406
JS
173
174WXDLLEXPORT_DATA(extern wxResourceTable*) wxDefaultResourceTable;
184b5d99 175WXDLLEXPORT extern long wxParseWindowStyle(const wxString& style);
145aa406
JS
176
177class WXDLLEXPORT wxMenuBar;
178class WXDLLEXPORT wxMenu;
179class WXDLLEXPORT wxBitmap;
180class WXDLLEXPORT wxIcon;
184b5d99
JS
181WXDLLEXPORT extern wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
182WXDLLEXPORT extern wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
183WXDLLEXPORT extern wxMenuBar* wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL, wxMenuBar *menuBar = (wxMenuBar *) NULL);
184WXDLLEXPORT extern wxMenu* wxResourceCreateMenu(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
185WXDLLEXPORT extern bool wxResourceParseData(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
186WXDLLEXPORT extern bool wxResourceParseFile(const wxString& filename, wxResourceTable *table = (wxResourceTable *) NULL);
187WXDLLEXPORT extern bool wxResourceParseString(char* s, wxResourceTable *table = (wxResourceTable *) NULL);
188WXDLLEXPORT extern void wxResourceClear(wxResourceTable *table = (wxResourceTable *) NULL);
145aa406 189// Register XBM/XPM data
184b5d99
JS
190WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL);
191WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceTable *table = (wxResourceTable *) NULL);
145aa406
JS
192#define wxResourceRegisterIconData wxResourceRegisterBitmapData
193
194/*
195 * Resource identifer code: #define storage
196 */
197
184b5d99
JS
198WXDLLEXPORT extern bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *table = (wxResourceTable *) NULL);
199WXDLLEXPORT extern int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table = (wxResourceTable *) NULL);
145aa406 200
28ff8c8f
SN
201#if defined(__WXPM__)
202#include "wx/os2/wxrsc.h"
203#endif
145aa406
JS
204#endif
205#endif
34138703 206 // _WX_RESOURCEH__