1998-05-21 10:33:06 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: resource.h
|
|
|
|
// Purpose: Resource processing
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart and Markus Holzem
|
1998-11-29 17:21:32 -05:00
|
|
|
// Licence: wxWindows licence
|
1998-05-21 10:33:06 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_RESOURCEH__
|
|
|
|
#define _WX_RESOURCEH__
|
1998-05-21 10:33:06 -04:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "resource.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/setup.h"
|
|
|
|
|
1998-09-25 09:28:52 -04:00
|
|
|
#if wxUSE_WX_RESOURCES
|
2000-02-28 08:15:44 -05:00
|
|
|
|
|
|
|
#include "wx/bitmap.h"
|
1998-05-21 10:33:06 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
// A few further types not in wx_types.h
|
|
|
|
#define wxRESOURCE_TYPE_SEPARATOR 1000
|
|
|
|
#define wxRESOURCE_TYPE_XBM_DATA 1001
|
|
|
|
#define wxRESOURCE_TYPE_XPM_DATA 1002
|
|
|
|
|
|
|
|
#define RESOURCE_PLATFORM_WINDOWS 1
|
|
|
|
#define RESOURCE_PLATFORM_X 2
|
|
|
|
#define RESOURCE_PLATFORM_MAC 3
|
|
|
|
#define RESOURCE_PLATFORM_ANY 4
|
|
|
|
|
1998-10-09 08:01:58 -04:00
|
|
|
// Extended styles: for resource usage only
|
|
|
|
|
|
|
|
// Use dialog units instead of pixels
|
2000-07-15 15:51:35 -04:00
|
|
|
#define wxRESOURCE_DIALOG_UNITS 0x0001
|
1998-10-09 08:01:58 -04:00
|
|
|
// Use default system colour and font
|
2000-07-15 15:51:35 -04:00
|
|
|
#define wxRESOURCE_USE_DEFAULTS 0x0002
|
|
|
|
// Old-style vertical label
|
|
|
|
#define wxRESOURCE_VERTICAL_LABEL 0x0004
|
|
|
|
// Old-style horizontal label
|
|
|
|
#define wxRESOURCE_HORIZONTAL_LABEL 0x0008
|
1998-10-09 08:01:58 -04:00
|
|
|
|
|
|
|
// Macros to help use dialog units
|
|
|
|
#define wxDLG_POINT(x, y, parent, useDlgUnits) (useDlgUnits ? parent->ConvertDialogToPixel(wxPoint(x, y)) : wxPoint(x, y))
|
|
|
|
#define wxDLG_SIZE(x, y, parent, useDlgUnits) (useDlgUnits ? parent->ConvertDialogToPixel(wxSize(x, y)) : wxSize(x, y))
|
|
|
|
|
1999-01-19 06:00:22 -05:00
|
|
|
#ifdef FindResource
|
|
|
|
#undef FindResource
|
|
|
|
#endif
|
|
|
|
|
2001-12-19 02:09:58 -05:00
|
|
|
class WXDLLEXPORT wxInputStream;
|
|
|
|
|
1998-05-21 10:33:06 -04:00
|
|
|
/*
|
|
|
|
* Internal format for control/panel item
|
|
|
|
*/
|
1998-11-29 17:21:32 -05:00
|
|
|
|
1998-05-21 10:33:06 -04:00
|
|
|
class WXDLLEXPORT wxItemResource: public wxObject
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxItemResource)
|
|
|
|
|
|
|
|
public:
|
1998-11-29 17:21:32 -05:00
|
|
|
|
1998-10-09 08:01:58 -04:00
|
|
|
wxItemResource();
|
|
|
|
~wxItemResource();
|
1998-05-21 10:33:06 -04:00
|
|
|
|
1998-10-09 08:01:58 -04:00
|
|
|
inline void SetType(const wxString& type) { m_itemType = type; }
|
|
|
|
inline void SetStyle(long styl) { m_windowStyle = styl; }
|
1998-05-21 10:33:06 -04:00
|
|
|
inline void SetId(int id) { m_windowId = id; }
|
1998-10-09 08:01:58 -04:00
|
|
|
inline void SetBitmap(const wxBitmap& bm) { m_bitmap = bm; }
|
|
|
|
inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
|
|
|
|
inline void SetFont(const wxFont& font) { m_windowFont = font; }
|
|
|
|
inline wxFont& GetFont() const { return (wxFont&) m_windowFont; }
|
1998-05-21 10:33:06 -04:00
|
|
|
inline void SetSize(int xx, int yy, int ww, int hh)
|
1998-10-09 08:01:58 -04:00
|
|
|
{ m_x = xx; m_y = yy; m_width = ww; m_height = hh; }
|
|
|
|
inline void SetTitle(const wxString& title) { m_title = title; }
|
|
|
|
inline void SetName(const wxString& name) { m_name = name; }
|
|
|
|
inline void SetValue1(long v) { m_value1 = v; }
|
|
|
|
inline void SetValue2(long v) { m_value2 = v; }
|
|
|
|
inline void SetValue3(long v) { m_value3 = v; }
|
|
|
|
inline void SetValue5(long v) { m_value5 = v; }
|
|
|
|
inline void SetValue4(const wxString& v) { m_value4 = v; }
|
|
|
|
inline void SetStringValues(const wxStringList& svalues) { m_stringValues = svalues; }
|
|
|
|
|
1999-05-08 17:21:10 -04:00
|
|
|
inline const wxString& GetType() const { return m_itemType; }
|
1998-10-09 08:01:58 -04:00
|
|
|
inline int GetX() const { return m_x; }
|
|
|
|
inline int GetY() const { return m_y; }
|
|
|
|
inline int GetWidth() const { return m_width; }
|
|
|
|
inline int GetHeight() const { return m_height; }
|
|
|
|
|
1999-05-08 17:21:10 -04:00
|
|
|
inline const wxString& GetTitle() const { return m_title; }
|
|
|
|
inline const wxString& GetName() const { return m_name; }
|
1998-10-09 08:01:58 -04:00
|
|
|
inline long GetStyle() const { return m_windowStyle; }
|
|
|
|
inline int GetId() const { return m_windowId; }
|
|
|
|
|
1999-08-05 16:38:51 -04:00
|
|
|
inline wxInt32 GetValue1() const { return m_value1; }
|
|
|
|
inline wxInt32 GetValue2() const { return m_value2; }
|
|
|
|
inline wxInt32 GetValue3() const { return m_value3; }
|
|
|
|
inline wxInt32 GetValue5() const { return m_value5; }
|
1998-10-09 08:01:58 -04:00
|
|
|
inline wxString GetValue4() const { return m_value4; }
|
|
|
|
inline wxList& GetChildren() const { return (wxList&) m_children; }
|
|
|
|
inline wxStringList& GetStringValues() const { return (wxStringList&) m_stringValues; }
|
|
|
|
|
|
|
|
inline void SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; }
|
|
|
|
inline void SetLabelColour(const wxColour& col) { m_labelColour = col; }
|
|
|
|
inline void SetButtonColour(const wxColour& col) { m_buttonColour = col; }
|
1998-05-21 10:33:06 -04:00
|
|
|
|
1998-10-09 08:01:58 -04:00
|
|
|
inline wxColour& GetBackgroundColour() const { return (wxColour&) m_backgroundColour; }
|
|
|
|
inline wxColour& GetLabelColour() const { return (wxColour&) m_labelColour; }
|
|
|
|
inline wxColour& GetButtonColour() const { return (wxColour&) m_buttonColour; }
|
|
|
|
|
|
|
|
inline void SetResourceStyle(long style) { m_exStyle = style; }
|
1999-08-05 16:38:51 -04:00
|
|
|
inline wxInt32 GetResourceStyle() const { return m_exStyle; }
|
1998-10-09 08:01:58 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
wxList m_children;
|
|
|
|
wxString m_itemType;
|
|
|
|
int m_x, m_y, m_width, m_height;
|
|
|
|
wxString m_title;
|
|
|
|
wxString m_name;
|
|
|
|
long m_windowStyle;
|
|
|
|
long m_value1, m_value2, m_value3, m_value5;
|
|
|
|
wxString m_value4;
|
|
|
|
int m_windowId;
|
|
|
|
wxStringList m_stringValues; // Optional string values
|
|
|
|
wxBitmap m_bitmap;
|
|
|
|
wxColour m_backgroundColour;
|
|
|
|
wxColour m_labelColour;
|
|
|
|
wxColour m_buttonColour;
|
|
|
|
wxFont m_windowFont;
|
|
|
|
long m_exStyle; // Extended, resource-specific styles
|
1998-05-21 10:33:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Resource table (normally only one of these)
|
|
|
|
*/
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxResourceTable: public wxHashTable
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxResourceTable)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxHashTable identifiers;
|
|
|
|
|
1998-10-09 08:01:58 -04:00
|
|
|
wxResourceTable();
|
|
|
|
~wxResourceTable();
|
|
|
|
|
1998-05-21 10:33:06 -04:00
|
|
|
virtual wxItemResource *FindResource(const wxString& name) const;
|
|
|
|
virtual void AddResource(wxItemResource *item);
|
|
|
|
virtual bool DeleteResource(const wxString& name);
|
|
|
|
|
1998-10-09 08:01:58 -04:00
|
|
|
virtual bool ParseResourceFile(const wxString& filename);
|
2001-12-19 02:09:58 -05:00
|
|
|
virtual bool ParseResourceFile(wxInputStream *is);
|
1998-10-09 08:01:58 -04:00
|
|
|
virtual bool ParseResourceData(const wxString& data);
|
|
|
|
virtual bool SaveResource(const wxString& filename);
|
1998-05-21 10:33:06 -04:00
|
|
|
|
|
|
|
// Register XBM/XPM data
|
1998-10-09 08:01:58 -04:00
|
|
|
virtual bool RegisterResourceBitmapData(const wxString& name, char bits[], int width, int height);
|
|
|
|
virtual bool RegisterResourceBitmapData(const wxString& name, char **data);
|
1998-05-21 10:33:06 -04:00
|
|
|
|
1998-10-09 08:01:58 -04:00
|
|
|
virtual wxControl *CreateItem(wxWindow *panel, const wxItemResource* childResource, const wxItemResource* parentResource) const;
|
1998-05-21 10:33:06 -04:00
|
|
|
|
1998-10-09 08:01:58 -04:00
|
|
|
virtual void ClearTable();
|
1998-05-21 10:33:06 -04:00
|
|
|
};
|
|
|
|
|
1998-11-22 17:32:53 -05:00
|
|
|
WXDLLEXPORT extern void wxInitializeResourceSystem();
|
|
|
|
WXDLLEXPORT extern void wxCleanUpResourceSystem();
|
1998-05-21 10:33:06 -04:00
|
|
|
|
|
|
|
WXDLLEXPORT_DATA(extern wxResourceTable*) wxDefaultResourceTable;
|
1998-11-22 17:32:53 -05:00
|
|
|
WXDLLEXPORT extern long wxParseWindowStyle(const wxString& style);
|
1998-05-21 10:33:06 -04:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxMenuBar;
|
|
|
|
class WXDLLEXPORT wxMenu;
|
|
|
|
class WXDLLEXPORT wxBitmap;
|
|
|
|
class WXDLLEXPORT wxIcon;
|
1998-11-22 17:32:53 -05:00
|
|
|
WXDLLEXPORT extern wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
|
|
|
WXDLLEXPORT extern wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
|
|
|
WXDLLEXPORT extern wxMenuBar* wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL, wxMenuBar *menuBar = (wxMenuBar *) NULL);
|
|
|
|
WXDLLEXPORT extern wxMenu* wxResourceCreateMenu(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
|
|
|
WXDLLEXPORT extern bool wxResourceParseData(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
|
|
|
WXDLLEXPORT extern bool wxResourceParseFile(const wxString& filename, wxResourceTable *table = (wxResourceTable *) NULL);
|
|
|
|
WXDLLEXPORT extern bool wxResourceParseString(char* s, wxResourceTable *table = (wxResourceTable *) NULL);
|
|
|
|
WXDLLEXPORT extern void wxResourceClear(wxResourceTable *table = (wxResourceTable *) NULL);
|
1998-05-21 10:33:06 -04:00
|
|
|
// Register XBM/XPM data
|
1998-11-22 17:32:53 -05:00
|
|
|
WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL);
|
|
|
|
WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceTable *table = (wxResourceTable *) NULL);
|
1998-05-21 10:33:06 -04:00
|
|
|
#define wxResourceRegisterIconData wxResourceRegisterBitmapData
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Resource identifer code: #define storage
|
|
|
|
*/
|
|
|
|
|
1998-11-22 17:32:53 -05:00
|
|
|
WXDLLEXPORT extern bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *table = (wxResourceTable *) NULL);
|
|
|
|
WXDLLEXPORT extern int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table = (wxResourceTable *) NULL);
|
1998-05-21 10:33:06 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_RESOURCEH__
|