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