SBSPSS/source/gui/gui.h

202 lines
4.9 KiB
C
Raw Normal View History

2000-10-31 17:20:53 +01:00
/*=========================================================================
gui.h
Author: PKG
Created:
Project: Spongebob
2000-11-20 18:28:21 +01:00
Purpose: NB: GUI ITEMS delete() THEMSELVES WHEN THEY ARE SHUTDOWN!
2000-10-31 17:20:53 +01:00
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
#ifndef __GUI_GUI_H__
#define __GUI_GUI_H__
/*----------------------------------------------------------------------
Includes
-------- */
2000-11-03 22:22:27 +01:00
#ifndef __FILE_EQUATES_H__
#include <biglump.h> // just to get the bloody def for FileEquate(!)
#endif
2000-10-31 17:20:53 +01:00
/* Std Lib
------- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
2000-11-03 22:22:27 +01:00
// PKG
// None of these clasess should ever really be instantiated, but they are the basis of all other GUI objects.
// Need a nice way to force this to be the case..
2000-10-31 17:20:53 +01:00
class CGUIObject
{
public:
typedef int GUIId;
2000-11-03 17:41:57 +01:00
static const GUIId noId=-1;
2000-10-31 17:20:53 +01:00
typedef enum
{
2000-11-02 18:16:10 +01:00
FLAG_NONE= 0,
2000-10-31 17:20:53 +01:00
FLAG_SELECTED= 1<<0,
2000-10-31 17:53:12 +01:00
FLAG_HIDDEN= 1<<2,
FLAG_DRAWBORDER= 1<<3,
2000-10-31 17:20:53 +01:00
} GUI_FLAGS;
enum
{
2001-04-19 23:11:46 +02:00
INITIAL_OT=5,
2000-10-31 17:20:53 +01:00
BORDERWIDTH=8,
BORDERHEIGHT=5,
};
2000-11-02 18:16:10 +01:00
2000-11-03 17:41:57 +01:00
virtual void init(CGUIObject *_parent,GUIId _id=noId);
2000-10-31 17:20:53 +01:00
virtual void shutdown();
2000-10-31 17:43:44 +01:00
void setObjectX(int _x) {m_x=_x;recalc();}
void setObjectY(int _y) {m_y=_y;recalc();}
void setObjectW(int _w) {m_w=_w;recalc();}
void setObjectH(int _h) {m_h=_h;recalc();}
2000-10-31 17:20:53 +01:00
void setObjectXY(int _x,int _y) {setObjectX(_x);setObjectY(_y);}
void setObjectWH(int _w,int _h) {setObjectW(_w);setObjectH(_h);}
void setObjectXYWH(int _x,int _y,int _w,int _h) {setObjectXY(_x,_y);setObjectWH(_w,_h);}
virtual void render();
virtual void think(int _frames);
2000-11-02 18:16:10 +01:00
virtual void setFlags(GUI_FLAGS _flags) {m_flags|=_flags;}
virtual void clearFlags(GUI_FLAGS _flags) {m_flags&=_flags^-1;}
2000-10-31 17:20:53 +01:00
int getFlags(GUI_FLAGS _flags) {return (m_flags&_flags)!=0;}
2000-10-31 17:43:44 +01:00
// Quick access functions to the most frequently used flags
void select() {setFlags(FLAG_SELECTED);}
void unselect() {clearFlags(FLAG_SELECTED);}
int isSelected() {return getFlags(FLAG_SELECTED);}
void hide() {setFlags(FLAG_HIDDEN);}
void unhide() {clearFlags(FLAG_HIDDEN);}
int isHidden() {return getFlags(FLAG_HIDDEN);}
2000-10-31 17:20:53 +01:00
2000-11-02 18:16:10 +01:00
CGUIObject *getChild() {return m_child;}
CGUIObject *getNext() {return m_next;}
2000-11-02 18:35:44 +01:00
virtual int isSelectable() {return false;}
2000-11-07 23:05:42 +01:00
virtual int isUnselectable() {return true;}
2000-11-02 18:16:10 +01:00
2000-11-07 23:05:42 +01:00
void setOt(int _ot) {m_ot=_ot;}
int getOt() {return m_ot;}
// PKG - Do we really need ids!?
2000-11-02 18:16:10 +01:00
int getId() {return m_id;}
2000-11-07 23:05:42 +01:00
2000-10-31 17:20:53 +01:00
protected:
2000-11-02 18:16:10 +01:00
virtual void recalc();
virtual GUI_FLAGS getInitialFlags() {return FLAG_NONE;}
2000-10-31 17:53:12 +01:00
2000-10-31 17:20:53 +01:00
int getX() {return m_x;}
int getY() {return m_y;}
int getW() {return m_w;}
int getH() {return m_h;}
2000-11-02 18:16:10 +01:00
int getParentX() {if(m_parent)return m_parent->getX()+m_parent->getParentX();else return 0;}
int getParentY() {if(m_parent)return m_parent->getY()+m_parent->getParentY();else return 0;}
2000-10-31 17:20:53 +01:00
private:
GUIId m_id;
int m_x,m_y,m_w,m_h;
int m_flags;
2000-11-02 18:16:10 +01:00
int m_ot;
CGUIObject *m_this; // Used to check that that the object has been initialised
CGUIObject *m_parent; // Parent object
CGUIObject *m_child; // First child
CGUIObject *m_next; // Next item at this level
};
2000-10-31 17:20:53 +01:00
2000-11-02 18:16:10 +01:00
class CGUIObjectWithFont : public CGUIObject
{
public:
2000-11-03 17:41:57 +01:00
virtual void init(CGUIObject *_parent,GUIId _id=noId);
2000-11-02 18:16:10 +01:00
virtual void shutdown();
2000-10-31 17:20:53 +01:00
2000-11-02 18:16:10 +01:00
virtual void setFlags(GUI_FLAGS _flags);
virtual void clearFlags(GUI_FLAGS _flags);
2000-11-07 23:05:42 +01:00
void setOt(int _ot);
2000-11-02 18:16:10 +01:00
protected:
enum
{
2000-11-03 22:22:27 +01:00
DEFAULT_FONT_R=110,
DEFAULT_FONT_G=110,
DEFAULT_FONT_B=110,
SELECTED_FONT_R=245,
SELECTED_FONT_G=245,
SELECTED_FONT_B=245,
2000-11-02 18:16:10 +01:00
};
2000-10-31 17:20:53 +01:00
2000-11-02 18:16:10 +01:00
virtual void recalc();
2000-10-31 17:20:53 +01:00
2000-11-02 18:16:10 +01:00
class FontBank *getFontBank() {return m_fontBank;}
2000-10-31 17:20:53 +01:00
2000-11-02 18:16:10 +01:00
private:
class FontBank *m_fontBank;
2000-10-31 17:20:53 +01:00
2000-11-02 18:16:10 +01:00
};
2000-10-31 17:20:53 +01:00
2000-11-03 22:22:27 +01:00
class CGUIObjectWithSpriteBank : public CGUIObject
{
public:
virtual void init(CGUIObject *_parent,GUIId _id=noId);
virtual void shutdown();
virtual void setSpriteBank(FileEquate _fe);
protected:
class SpriteBank *getSpriteBank() {return m_spriteBank;}
private:
class SpriteBank *m_spriteBank;
};
2000-10-31 17:20:53 +01:00
/*----------------------------------------------------------------------
Globals
------- */
/*----------------------------------------------------------------------
Functions
--------- */
2000-11-09 17:58:22 +01:00
extern void initGUIStuff();
extern void drawBambooBorder(int _x,int _y,int _w,int _h,int _ot);
2000-10-31 17:20:53 +01:00
/*---------------------------------------------------------------------- */
#endif /* __GUI_GUI_H__ */
/*===========================================================================
end */