RtB/src/gui/GuiElement.hpp

57 lines
1.8 KiB
C++

/* ================================================================
GuiElement
----------------
This file describes the GuiElement class. This is the base class for further GUI Elements such as buttons, text input, or otherwise.
================================================================ */
#ifndef GUIELEMENT_HPP
#define GUIELEMENT_HPP
#include <string>
#include <vector>
#include "RenderObject.hpp"
#include "RenderView.hpp"
class GuiElement {
friend class Gui;
public:
enum Type {
DEFAULT = 0,
BUTTON,
TEXT,
TEXTINPUT,
TEXTAREA,
CHECKBOX
};
enum Position {
VCENTER = (1 << 1),
HCENTER = (1 << 2),
LEFT = (1 << 3),
RIGHT = (1 << 4),
TOP = (1 << 5),
BOTTOM = (1 << 6)
};
GuiElement();
GuiElement(const char *string);
GuiElement(const char *string, GuiElement *parent_);
GuiElement(const char *string, int group_id, int this_id);
~GuiElement();
//
int setGeometry(float x, float y, float w, float h);
// int setText(const char *string);
GuiElement *getHit(float xhit, float yhit);
int addChild(GuiElement *child);
int setPFlags(int pflags);
virtual int doRender();
protected:
std::vector<GuiElement*> children; // children of this element
RenderView *view; // Ugh, we use FBOs for GUI elements cuz otherwise it's too annoying.
GuiElement *parent; // parent of this element
std::string text; // text of this element
int type; // flag for this type
int pflags; // positioning flags
int gid; // group id for this element
int id; // id for this element
RenderObject *object;// render object, as set by manager class, Gui
//
float x, y, w, h; // position and dimensions for this element
};
#endif