]> git.saurik.com Git - wxWidgets.git/blame - include/wx/resource.h
wxTextFile::Type changed to ::wxTextFileType (portability)
[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
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
145aa406
JS
45/*
46 * Internal format for control/panel item
47 */
a6f6393c 48
145aa406
JS
49class WXDLLEXPORT wxItemResource: public wxObject
50{
51 DECLARE_DYNAMIC_CLASS(wxItemResource)
52
145aa406 53 public:
a6f6393c 54
fd71308f
JS
55 wxItemResource();
56 ~wxItemResource();
145aa406 57
fd71308f
JS
58 inline void SetType(const wxString& type) { m_itemType = type; }
59 inline void SetStyle(long styl) { m_windowStyle = styl; }
145aa406 60 inline void SetId(int id) { m_windowId = id; }
fd71308f
JS
61 inline void SetBitmap(const wxBitmap& bm) { m_bitmap = bm; }
62 inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
63 inline void SetFont(const wxFont& font) { m_windowFont = font; }
64 inline wxFont& GetFont() const { return (wxFont&) m_windowFont; }
145aa406 65 inline void SetSize(int xx, int yy, int ww, int hh)
fd71308f
JS
66 { m_x = xx; m_y = yy; m_width = ww; m_height = hh; }
67 inline void SetTitle(const wxString& title) { m_title = title; }
68 inline void SetName(const wxString& name) { m_name = name; }
69 inline void SetValue1(long v) { m_value1 = v; }
70 inline void SetValue2(long v) { m_value2 = v; }
71 inline void SetValue3(long v) { m_value3 = v; }
72 inline void SetValue5(long v) { m_value5 = v; }
73 inline void SetValue4(const wxString& v) { m_value4 = v; }
74 inline void SetStringValues(const wxStringList& svalues) { m_stringValues = svalues; }
75
76 inline wxString GetType() const { return m_itemType; }
77 inline int GetX() const { return m_x; }
78 inline int GetY() const { return m_y; }
79 inline int GetWidth() const { return m_width; }
80 inline int GetHeight() const { return m_height; }
81
82 inline wxString GetTitle() const { return m_title; }
83 inline wxString GetName() const { return m_name; }
84 inline long GetStyle() const { return m_windowStyle; }
85 inline int GetId() const { return m_windowId; }
86
87 inline long GetValue1() const { return m_value1; }
88 inline long GetValue2() const { return m_value2; }
89 inline long GetValue3() const { return m_value3; }
90 inline long GetValue5() const { return m_value5; }
91 inline wxString GetValue4() const { return m_value4; }
92 inline wxList& GetChildren() const { return (wxList&) m_children; }
93 inline wxStringList& GetStringValues() const { return (wxStringList&) m_stringValues; }
94
95 inline void SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; }
96 inline void SetLabelColour(const wxColour& col) { m_labelColour = col; }
97 inline void SetButtonColour(const wxColour& col) { m_buttonColour = col; }
145aa406 98
fd71308f
JS
99 inline wxColour& GetBackgroundColour() const { return (wxColour&) m_backgroundColour; }
100 inline wxColour& GetLabelColour() const { return (wxColour&) m_labelColour; }
101 inline wxColour& GetButtonColour() const { return (wxColour&) m_buttonColour; }
102
103 inline void SetResourceStyle(long style) { m_exStyle = style; }
104 inline long GetResourceStyle() const { return m_exStyle; }
105
106 protected:
107 wxList m_children;
108 wxString m_itemType;
109 int m_x, m_y, m_width, m_height;
110 wxString m_title;
111 wxString m_name;
112 long m_windowStyle;
113 long m_value1, m_value2, m_value3, m_value5;
114 wxString m_value4;
115 int m_windowId;
116 wxStringList m_stringValues; // Optional string values
117 wxBitmap m_bitmap;
118 wxColour m_backgroundColour;
119 wxColour m_labelColour;
120 wxColour m_buttonColour;
121 wxFont m_windowFont;
122 long m_exStyle; // Extended, resource-specific styles
145aa406
JS
123};
124
125/*
126 * Resource table (normally only one of these)
127 */
128
129class WXDLLEXPORT wxResourceTable: public wxHashTable
130{
131 DECLARE_DYNAMIC_CLASS(wxResourceTable)
132
133 protected:
134
135 public:
136 wxHashTable identifiers;
137
fd71308f
JS
138 wxResourceTable();
139 ~wxResourceTable();
140
145aa406
JS
141 virtual wxItemResource *FindResource(const wxString& name) const;
142 virtual void AddResource(wxItemResource *item);
143 virtual bool DeleteResource(const wxString& name);
144
fd71308f
JS
145 virtual bool ParseResourceFile(const wxString& filename);
146 virtual bool ParseResourceData(const wxString& data);
147 virtual bool SaveResource(const wxString& filename);
145aa406
JS
148
149 // Register XBM/XPM data
fd71308f
JS
150 virtual bool RegisterResourceBitmapData(const wxString& name, char bits[], int width, int height);
151 virtual bool RegisterResourceBitmapData(const wxString& name, char **data);
145aa406 152
fd71308f 153 virtual wxControl *CreateItem(wxWindow *panel, const wxItemResource* childResource, const wxItemResource* parentResource) const;
145aa406 154
fd71308f 155 virtual void ClearTable();
145aa406
JS
156};
157
184b5d99
JS
158WXDLLEXPORT extern void wxInitializeResourceSystem();
159WXDLLEXPORT extern void wxCleanUpResourceSystem();
145aa406
JS
160
161WXDLLEXPORT_DATA(extern wxResourceTable*) wxDefaultResourceTable;
184b5d99 162WXDLLEXPORT extern long wxParseWindowStyle(const wxString& style);
145aa406
JS
163
164class WXDLLEXPORT wxMenuBar;
165class WXDLLEXPORT wxMenu;
166class WXDLLEXPORT wxBitmap;
167class WXDLLEXPORT wxIcon;
184b5d99
JS
168WXDLLEXPORT extern wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
169WXDLLEXPORT extern wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
170WXDLLEXPORT extern wxMenuBar* wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL, wxMenuBar *menuBar = (wxMenuBar *) NULL);
171WXDLLEXPORT extern wxMenu* wxResourceCreateMenu(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
172WXDLLEXPORT extern bool wxResourceParseData(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
173WXDLLEXPORT extern bool wxResourceParseFile(const wxString& filename, wxResourceTable *table = (wxResourceTable *) NULL);
174WXDLLEXPORT extern bool wxResourceParseString(char* s, wxResourceTable *table = (wxResourceTable *) NULL);
175WXDLLEXPORT extern void wxResourceClear(wxResourceTable *table = (wxResourceTable *) NULL);
145aa406 176// Register XBM/XPM data
184b5d99
JS
177WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL);
178WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceTable *table = (wxResourceTable *) NULL);
145aa406
JS
179#define wxResourceRegisterIconData wxResourceRegisterBitmapData
180
181/*
182 * Resource identifer code: #define storage
183 */
184
184b5d99
JS
185WXDLLEXPORT extern bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *table = (wxResourceTable *) NULL);
186WXDLLEXPORT extern int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table = (wxResourceTable *) NULL);
145aa406
JS
187
188#endif
189#endif
34138703 190 // _WX_RESOURCEH__