]> git.saurik.com Git - wxWidgets.git/blame - include/wx/resource.h
Fixed Fontdialog
[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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __RESOURCEH__
13#define __RESOURCEH__
14
15#ifdef __GNUG__
16#pragma interface "resource.h"
17#endif
18
19#include "wx/setup.h"
20
21#if USE_WX_RESOURCES
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
34/*
35 * Internal format for control/panel item
36 */
37
38class WXDLLEXPORT wxItemResource: public wxObject
39{
40 DECLARE_DYNAMIC_CLASS(wxItemResource)
41
42 protected:
43 wxList children;
44 char *itemType;
45 int x, y, width, height;
46 char *title;
47 char *name;
48 long windowStyle;
49 long value1, value2, value3, value5;
50 char *value4;
51 int m_windowId;
52 wxStringList *stringValues; // Optional string values
53 wxBitmap *bitmap;
54 wxColour *backgroundColour;
55 wxColour *labelColour;
56 wxColour *buttonColour;
57 wxFont *windowFont;
58 public:
59
60 wxItemResource(void);
61 ~wxItemResource(void);
62
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);
80
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; }
86
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; }
91
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; }
99
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; }
103
104 inline wxColour *GetBackgroundColour(void) { return backgroundColour; }
105 inline wxColour *GetLabelColour(void) { return labelColour; }
106 inline wxColour *GetButtonColour(void) { return buttonColour; }
107};
108
109/*
110 * Resource table (normally only one of these)
111 */
112
113class WXDLLEXPORT wxResourceTable: public wxHashTable
114{
115 DECLARE_DYNAMIC_CLASS(wxResourceTable)
116
117 protected:
118
119 public:
120 wxHashTable identifiers;
121
122 wxResourceTable(void);
123 ~wxResourceTable(void);
124
125 virtual wxItemResource *FindResource(const wxString& name) const;
126 virtual void AddResource(wxItemResource *item);
127 virtual bool DeleteResource(const wxString& name);
128
129 virtual bool ParseResourceFile(char *filename);
130 virtual bool ParseResourceData(char *data);
131 virtual bool SaveResource(char *filename);
132
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);
136
137 virtual wxControl *CreateItem(wxWindow *panel, wxItemResource *childResource) const;
138
139 virtual void ClearTable(void);
140};
141
142extern void WXDLLEXPORT wxInitializeResourceSystem(void);
143extern void WXDLLEXPORT wxCleanUpResourceSystem(void);
144
145WXDLLEXPORT_DATA(extern wxResourceTable*) wxDefaultResourceTable;
146extern long WXDLLEXPORT wxParseWindowStyle(char *style);
147
148class WXDLLEXPORT wxMenuBar;
149class WXDLLEXPORT wxMenu;
150class WXDLLEXPORT wxBitmap;
151class WXDLLEXPORT wxIcon;
152extern wxBitmap* WXDLLEXPORT wxResourceCreateBitmap(char *resource, wxResourceTable *table = NULL);
153extern wxIcon* WXDLLEXPORT wxResourceCreateIcon(char *resource, wxResourceTable *table = NULL);
154extern wxMenuBar* WXDLLEXPORT wxResourceCreateMenuBar(char *resource, wxResourceTable *table = NULL, wxMenuBar *menuBar = NULL);
155extern wxMenu* WXDLLEXPORT wxResourceCreateMenu(char *resource, wxResourceTable *table = NULL);
156extern bool WXDLLEXPORT wxResourceParseData(char *resource, wxResourceTable *table = NULL);
157extern bool WXDLLEXPORT wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
158extern bool WXDLLEXPORT wxResourceParseString(char *s, wxResourceTable *table = NULL);
159extern void WXDLLEXPORT wxResourceClear(wxResourceTable *table = NULL);
160// Register XBM/XPM data
161extern bool WXDLLEXPORT wxResourceRegisterBitmapData(char *name, char bits[], int width, int height, wxResourceTable *table = NULL);
162extern bool WXDLLEXPORT wxResourceRegisterBitmapData(char *name, char **data, wxResourceTable *table = NULL);
163#define wxResourceRegisterIconData wxResourceRegisterBitmapData
164
165/*
166 * Resource identifer code: #define storage
167 */
168
169extern bool WXDLLEXPORT wxResourceAddIdentifier(char *name, int value, wxResourceTable *table = NULL);
170extern int WXDLLEXPORT wxResourceGetIdentifier(char *name, wxResourceTable *table = NULL);
171
172#endif
173#endif
174 // __RESOURCEH__