/* $Id$ */
#ifndef WIDGET_TYPES_H
#define WIDGET_TYPES_H
#include "widget.h"
#include "table/strings.h"
#include <string>
namespace gui {
struct Label : public Widget {
typedef Widget super;
static const FeatureFlags DEFAULT_FEATURES = FF_NONE;
protected:
StringID m_text;
public:
Label()
: Widget()
{}
Label(CompositeWidget *container, StringID text, FeatureFlags feature_flags = DEFAULT_FEATURES, StringID tooltips = 0, uint16 color = COLOUR_PARENT)
: Widget(container, feature_flags, tooltips, color)
, m_text(text)
{
}
/*virtual*/ void DrawBackground(EvtPaint &ev);
/*virtual*/ void OnPaint(EvtPaint &ev);
};
struct Button : public Widget {
typedef Widget super;
protected:
bool m_pushed;
CaptureTicket m_ticket_pressed;
public:
Button()
: Widget()
, m_pushed(false)
{}
Button(CompositeWidget *container, FeatureFlags feature_flags, StringID tooltips = 0, uint16 color = COLOUR_PARENT)
: Widget(container, feature_flags, tooltips, color)
, m_pushed(false)
{}
void OnCapturePressed(EvtMouseOver &e);
/*virtual*/ void DrawBackground(EvtPaint &ev);
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev);
};
struct ImageButton : public Button {
typedef Button super;
static const FeatureFlags DEFAULT_FEATURES = FF_NONE;
protected:
SpriteID m_sprite;
Point16 m_sprite_offset;
public:
ImageButton()
: Button()
, m_sprite(0)
{}
ImageButton(CompositeWidget *container, SpriteID sprite, Point16 sprite_offset, FeatureFlags feature_flags = DEFAULT_FEATURES, StringID tooltips = 0, uint16 color = COLOUR_PARENT)
: Button(container, feature_flags, tooltips, color)
, m_sprite(sprite)
, m_sprite_offset(sprite_offset)
{}
/*virtual*/ void OnPaint(EvtPaint &ev);
};
struct ImageButton2 : public ImageButton {
typedef ImageButton super;
static const FeatureFlags DEFAULT_FEATURES = FF_NONE;
protected:
SpriteID m_sprite_pushed;
Point16 m_sprite_offset_pushed;
public:
ImageButton2()
: ImageButton()
, m_sprite_pushed(0)
{}
ImageButton2(CompositeWidget *container, SpriteID sprite, Point16 sprite_offset, SpriteID sprite_pushed, Point16 sprite_offset_pushed, FeatureFlags feature_flags = DEFAULT_FEATURES, StringID tooltips = 0, uint16 color = COLOUR_PARENT)
: ImageButton(container, sprite, sprite_offset, feature_flags, tooltips, color)
, m_sprite_pushed(sprite_pushed)
, m_sprite_offset_pushed(sprite_offset_pushed)
{}
/*virtual*/ void OnPaint(EvtPaint &ev);
};
struct TextButton : public Button {
typedef Button super;
static const FeatureFlags DEFAULT_FEATURES = FF_NONE;
protected:
StringID m_text_id;
public:
::std::string m_text;
public:
TextButton()
: Button()
{}
TextButton(CompositeWidget *container, StringID text_id, FeatureFlags feature_flags = DEFAULT_FEATURES, StringID tooltips = 0, uint16 color = COLOUR_PARENT)
: Button(container, feature_flags, tooltips, color)
, m_text_id(text_id)
{}
StringID GetTextId();
/*virtual*/ void QuerySizes();
/*virtual*/ void OnPaint(EvtPaint &ev);
};
struct CaptionBar : public Panel {
typedef Panel super;
static const int16 DEFAULT_HEIGHT = 14;
public:
CaptionBar()
: super()
{}
CaptionBar(CompositeWidget *container, FeatureFlags feature_flags, uint16 color = COLOUR_PARENT)
: super(container, feature_flags, 0, color)
{
m_feature_flags |= FF_NO_FRAME | FF_IGNORE_PARENT_FRAME;
}
/*virtual*/ void CreateWidgets();
};
struct ResizeBox : public Widget {
typedef Widget super;
static const int16 DEFAULT_WIDTH = 11;
static const int16 DEFAULT_HEIGHT = 11;
static FeatureFlags DEFAULT_FEATURES() {return FF_MIN_SIZE | FF_ALIGN_RIGHT | FF_ALIGN_BOTTOM;}
protected:
Point16 m_sizing_offset;
CaptureTicket m_ticket_sizing;
public:
ResizeBox()
: Widget()
{}
ResizeBox(CompositeWidget *container)
: Widget(container, DEFAULT_FEATURES(), STR_RESIZE_BUTTON, COLOUR_PARENT)
{
m_min_size = m_max_size = Size16(DEFAULT_WIDTH, DEFAULT_HEIGHT);
}
/*virtual*/ void DrawBackground(EvtPaint &ev);
void OnCaptureSizing(EvtMouseOver &e);
/*virtual*/ void OnCreate(EvtCreate &ev);
/*virtual*/ void OnPaint(EvtPaint &ev);
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev);
/*virtual*/ void OnResizeParent(EvtResizeParent &ev);
};
}; // namespace gui
#endif /* WIDGET_TYPES_H */