2003-11-06 01:21:45 +01:00
|
|
|
/*
|
|
|
|
GUI Core, stuff that the whole GUI uses
|
|
|
|
by Gustav Larsson
|
|
|
|
gee@pyro.nu
|
|
|
|
|
|
|
|
--Overview--
|
|
|
|
|
|
|
|
Contains defines, includes, types etc that the whole
|
|
|
|
GUI should have included.
|
|
|
|
|
|
|
|
--More info--
|
|
|
|
|
2003-11-25 03:47:12 +01:00
|
|
|
Check GUI.h
|
2003-11-06 01:21:45 +01:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUIbase_H
|
|
|
|
#define GUIbase_H
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// Includes / Compiler directives
|
|
|
|
//--------------------------------------------------------
|
|
|
|
|
2004-08-31 04:09:58 +02:00
|
|
|
// I would like to just forward declare CSize, but it doesn't
|
|
|
|
// seem to be defined anywhere in the predefined header.
|
|
|
|
#include "Overlay.h"
|
|
|
|
|
2003-11-06 01:21:45 +01:00
|
|
|
//--------------------------------------------------------
|
|
|
|
// Forward declarations
|
|
|
|
//--------------------------------------------------------
|
2003-11-24 03:18:41 +01:00
|
|
|
class IGUIObject;
|
2003-11-06 01:21:45 +01:00
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// Macros
|
|
|
|
//--------------------------------------------------------
|
2003-11-06 12:54:46 +01:00
|
|
|
|
|
|
|
// Global CGUI
|
|
|
|
#define g_GUI CGUI::GetSingleton()
|
|
|
|
|
2003-12-27 07:26:03 +01:00
|
|
|
// Object settings setups
|
2003-11-06 01:21:45 +01:00
|
|
|
|
|
|
|
// Setup an object's ConstructObject function
|
|
|
|
#define GUI_OBJECT(obj) \
|
|
|
|
public: \
|
2003-11-24 03:18:41 +01:00
|
|
|
static IGUIObject *ConstructObject() { return new obj(); }
|
2003-11-06 01:21:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// Types
|
|
|
|
//--------------------------------------------------------
|
2003-11-24 03:18:41 +01:00
|
|
|
/**
|
|
|
|
* @enum EGUIMessage
|
2003-12-27 07:26:03 +01:00
|
|
|
* Message types
|
|
|
|
*
|
|
|
|
* @see SGUIMessage
|
2003-11-18 11:00:57 +01:00
|
|
|
*/
|
2003-12-27 07:26:03 +01:00
|
|
|
enum EGUIMessageType
|
2003-11-06 01:21:45 +01:00
|
|
|
{
|
2003-11-25 03:47:12 +01:00
|
|
|
GUIM_PREPROCESS, // questionable
|
|
|
|
GUIM_POSTPROCESS, // questionable
|
2003-11-06 01:21:45 +01:00
|
|
|
GUIM_MOUSE_OVER,
|
|
|
|
GUIM_MOUSE_ENTER,
|
|
|
|
GUIM_MOUSE_LEAVE,
|
|
|
|
GUIM_MOUSE_PRESS_LEFT,
|
|
|
|
GUIM_MOUSE_PRESS_RIGHT,
|
|
|
|
GUIM_MOUSE_DOWN_LEFT,
|
|
|
|
GUIM_MOUSE_DOWN_RIGHT,
|
|
|
|
GUIM_MOUSE_RELEASE_LEFT,
|
|
|
|
GUIM_MOUSE_RELEASE_RIGHT,
|
2003-12-27 07:26:03 +01:00
|
|
|
GUIM_MOUSE_WHEEL_UP,
|
|
|
|
GUIM_MOUSE_WHEEL_DOWN,
|
|
|
|
GUIM_SETTINGS_UPDATED, // SGUIMessage.m_Value = name of setting
|
|
|
|
GUIM_PRESSED,
|
2004-05-29 06:06:50 +02:00
|
|
|
GUIM_MOUSE_MOTION,
|
|
|
|
GUIM_LOAD // Called when an object is added to the GUI.
|
2003-12-27 07:26:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2004-05-29 06:06:50 +02:00
|
|
|
* @author Gustav Larsson
|
|
|
|
*
|
2003-12-27 07:26:03 +01:00
|
|
|
* Message send to IGUIObject::HandleMessage() in order
|
|
|
|
* to give life to Objects manually with
|
|
|
|
* a derived HandleMessage().
|
|
|
|
*/
|
|
|
|
struct SGUIMessage
|
|
|
|
{
|
|
|
|
SGUIMessage() {}
|
|
|
|
SGUIMessage(const EGUIMessageType &_type) : type(_type) {}
|
2004-06-18 16:07:06 +02:00
|
|
|
SGUIMessage(const EGUIMessageType &_type, const CStr& _value) : type(_type), value(_value) {}
|
2003-12-27 07:26:03 +01:00
|
|
|
~SGUIMessage() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Describes what the message regards
|
|
|
|
*/
|
|
|
|
EGUIMessageType type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional data
|
|
|
|
*/
|
|
|
|
CStr value;
|
2003-11-06 01:21:45 +01:00
|
|
|
};
|
|
|
|
|
2003-11-18 11:00:57 +01:00
|
|
|
/**
|
|
|
|
* Recurse restrictions, when we recurse, if an object
|
|
|
|
* is hidden for instance, you might want it to skip
|
|
|
|
* the children also
|
|
|
|
* Notice these are flags! and we don't really need one
|
|
|
|
* for no restrictions, because then you'll just enter 0
|
|
|
|
*/
|
2003-11-06 01:21:45 +01:00
|
|
|
enum
|
|
|
|
{
|
2003-12-27 07:26:03 +01:00
|
|
|
GUIRR_HIDDEN = 0x00000001,
|
|
|
|
GUIRR_DISABLED = 0x00000010,
|
|
|
|
GUIRR_GHOST = 0x00000100
|
2003-11-06 01:21:45 +01:00
|
|
|
};
|
|
|
|
|
2003-12-01 08:06:55 +01:00
|
|
|
/**
|
|
|
|
* @enum EGUISettingsStruct
|
2003-12-27 07:26:03 +01:00
|
|
|
*
|
|
|
|
* Stored in SGUISetting, tells us in which struct
|
|
|
|
* the setting is located, that way we can query
|
|
|
|
* for the structs address.
|
2003-12-01 08:06:55 +01:00
|
|
|
*/
|
|
|
|
enum EGUISettingsStruct
|
|
|
|
{
|
|
|
|
GUISS_BASE,
|
|
|
|
GUISS_EXTENDED
|
|
|
|
};
|
|
|
|
|
2003-11-06 01:21:45 +01:00
|
|
|
// Typedefs
|
2003-11-24 03:18:41 +01:00
|
|
|
typedef std::map<CStr, IGUIObject*> map_pObjects;
|
2003-11-24 18:13:37 +01:00
|
|
|
typedef std::vector<IGUIObject*> vector_pObjects;
|
2003-11-06 01:21:45 +01:00
|
|
|
|
2004-08-31 04:09:58 +02:00
|
|
|
// Smaller structs that don't deserve their own files :)
|
|
|
|
|
|
|
|
// Icon, you create them in the XML file with root element <setup>
|
|
|
|
// you use them in text owned by different objects... Such as CText.
|
|
|
|
struct SGUIIcon
|
|
|
|
{
|
|
|
|
// Texture name of icon
|
|
|
|
CStr m_TextureName;
|
|
|
|
|
|
|
|
// Size
|
|
|
|
CSize m_Size;
|
|
|
|
};
|
|
|
|
|
2003-11-06 01:21:45 +01:00
|
|
|
//--------------------------------------------------------
|
|
|
|
// Error declarations
|
|
|
|
//--------------------------------------------------------
|
2004-06-11 04:14:18 +02:00
|
|
|
DECLARE_ERROR(PS_NAME_TAKEN);
|
|
|
|
DECLARE_ERROR(PS_OBJECT_FAIL);
|
|
|
|
DECLARE_ERROR(PS_SETTING_FAIL);
|
|
|
|
DECLARE_ERROR(PS_VALUE_INVALID);
|
|
|
|
DECLARE_ERROR(PS_NEEDS_PGUI);
|
|
|
|
DECLARE_ERROR(PS_NAME_AMBIGUITY);
|
|
|
|
DECLARE_ERROR(PS_NEEDS_NAME);
|
|
|
|
|
|
|
|
DECLARE_ERROR(PS_LEXICAL_FAIL);
|
|
|
|
DECLARE_ERROR(PS_SYNTACTICAL_FAIL);
|
2003-11-06 01:21:45 +01:00
|
|
|
|
2003-11-24 18:13:37 +01:00
|
|
|
#endif
|