--- a/src/intro_gui.cpp Sat Mar 03 16:11:18 2007 +0000
+++ b/src/intro_gui.cpp Sat Mar 03 20:25:37 2007 +0000
@@ -164,7 +164,7 @@
gui::WidgetPtr m_button1;
WindowT()
- : BaseWindow(WC_TEST1)
+ : BaseWindow(WC_TEST1, STR_015B_OPENTTD, COLOUR_BROWN, gui::FF_NONE)
{
}
@@ -173,25 +173,14 @@
/* set common window properties */
SetTopLeft(Point16(140, 40));
SetSize(Point16(336, 195));
- desc_flags = WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS;
- m_color = COLOUR_BROWN;
-
- /* add caption bar (later this will be done automatically by window core */
- gui::CaptionBar *capt_bar = new gui::CaptionBar(this, -100, RESIZE_LR, COLOUR_BROWN, 0x84, STR_0282_CONSTRUCT_BUBBLE_GENERATOR, STR_015B_OPENTTD);
- AddWidget(capt_bar);
-
- /* add resize box (later this will be done automatically by window core */
- gui::ResizeBox *resize_box = new gui::ResizeBox(this);
- AddWidget(resize_box);
/* add controls */
- m_button1 = new gui::TextButton(this, 22, RESIZE_NONE, COLOUR_YELLOW, Rect16(104, 175, 231, 186), STR_0305_QUIT_OPENTTD, STR_0304_QUIT);
+ m_button1 = new gui::TextButton(this, 22, gui::FF_NONE, COLOUR_YELLOW, Rect16(104, 175, 231, 186), STR_0305_QUIT_OPENTTD, STR_0304_QUIT);
m_button1->SetAnchors(PIN_RIGHT | PIN_BOTTOM);
AddWidget(m_button1);
/* connect control callbacks */
m_button1->AddReflectHandlerT(&WindowT::Button1_OnClick);
-// m_button1->AddOnClickHandlerT(&WindowT::Button1_OnClick);
}
void Button1_OnClick(gui::EvtLeftClick &e)
--- a/src/widget/widget.h Sat Mar 03 16:11:18 2007 +0000
+++ b/src/widget/widget.h Sat Mar 03 20:25:37 2007 +0000
@@ -38,6 +38,17 @@
namespace gui {
+enum FeatureFlags {
+ FF_NONE = 0,
+ FF_NO_CAPTION_BAR = (1 << 0),
+ FF_NO_CLOSE_BOX = (1 << 1),
+ FF_NO_STICKY_BOX = (1 << 2),
+ FF_NO_RESIZE_BOX = (1 << 3),
+ FF_UNMOVABLE = (1 << 4),
+};
+
+DECLARE_ENUM_AS_BIT_SET(FeatureFlags);
+
struct Widget;
typedef CCountedPtr<Widget> WidgetPtr;
@@ -54,7 +65,7 @@
WidgetId m_id; ///< Widget id in its container
Rect16 m_rect; ///< The position offsets relative to the container
uint16 m_data; ///< The String/Image or special code (list-matrices) of a widget
- byte m_display_flags; ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags
+ FeatureFlags m_feature_flags; ///< @see FeatureFlags
byte m_color; ///< Widget color, see docs/ottd-colourtext-palette.png
bool m_is_closing : 1; ///< Widget was logically destroyed
bool m_dont_clip : 1; ///< should not be clipped by parent (container)
@@ -63,16 +74,16 @@
Handlers m_handlers; ///< dynamically registered event handlers
Widget()
- : m_container(NULL), m_id(0), m_rect(), m_data(0), m_display_flags(0), m_color(0)
+ : m_container(NULL), m_id(0), m_rect(), m_data(0), m_feature_flags(FF_NONE), m_color(0)
, m_is_closing(false), m_tooltips(0), m_anchors(PIN_NONE)
{}
- Widget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
+ Widget(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips)
: m_container(container)
, m_id(id)
, m_rect(rect)
, m_data(0)
- , m_display_flags(display_flags)
+ , m_feature_flags(feature_flags)
, m_color(color)
, m_is_closing(false)
, m_dont_clip(false)
@@ -186,8 +197,8 @@
: Widget()
{}
- CompositeWidget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
- : Widget(container, id, display_flags, color, rect, tooltips)
+ CompositeWidget(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips)
+ : Widget(container, id, feature_flags, color, rect, tooltips)
{}
void AddWidget(Widget *wd);
@@ -196,6 +207,7 @@
/*virtual*/ Widget* WidgetFromPt(const Point16 &pt);
+ virtual void CreateNcWidgets() {};
virtual void CreateWidgets() = 0;
virtual void Close();
@@ -219,8 +231,8 @@
, m_pushed(false)
{}
- Button(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
- : Widget(container, id, display_flags, color, rect, tooltips)
+ Button(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips)
+ : Widget(container, id, feature_flags, color, rect, tooltips)
, m_pushed(false)
{}
@@ -242,8 +254,8 @@
: Button()
{}
- TextButton(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips, StringID text)
- : Button(container, id, display_flags, color, rect, tooltips)
+ TextButton(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips, StringID text)
+ : Button(container, id, feature_flags, color, rect, tooltips)
, m_text(text)
{}
@@ -262,7 +274,7 @@
{}
CloseBox(CompositeWidget *container)
- : Button(container, -102, 0, container->m_color, Rect16(), 0)
+ : Button(container, -102, FF_NONE, container->m_color, Rect16(), 0)
{}
/*virtual*/ void OnCreate(EvtCreate &ev);
@@ -274,27 +286,20 @@
typedef Widget super;
protected:
- StringID m_text;
- byte m_text_color;
Point16 m_moving_offset;
CaptureTicket m_ticket_moving;
public:
Caption()
: Widget()
- , m_text(0)
- , m_text_color(0xFF)
{}
- Caption(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 rect, byte text_color, StringID tooltips, StringID text)
- : Widget(container, id, display_flags, color, rect, tooltips)
- , m_text(text)
- , m_text_color(text_color)
+ Caption(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 rect, byte text_color, StringID tooltips, StringID text)
+ : Widget(container, id, feature_flags, color, rect, tooltips)
{}
/*virtual*/ void DrawBackground(EvtPaint &ev);
- /*virtual*/ void OnCreate(EvtCreate &ev);
/*virtual*/ void OnPaint(EvtPaint &ev);
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev);
void OnCaptureMoving(EvtMouseOver &e);
@@ -305,28 +310,16 @@
static const int16 DEFAULT_HEIGHT = 14;
-protected:
- StringID m_text;
- byte m_text_color;
- Point16 m_moving_offset;
- CaptureTicket m_ticket_moving;
-
public:
CaptionBar()
: CompositeWidget()
- , m_text(0)
- , m_text_color(0xFF)
{}
- CaptionBar(CompositeWidget *container, WidgetId id, byte display_flags, byte color, byte text_color, StringID tooltips, StringID text)
- : CompositeWidget(container, id, display_flags, color, Rect16(0, 0, container->Width() - 1, DEFAULT_HEIGHT - 1), tooltips)
- , m_text(text)
- , m_text_color(text_color)
+ CaptionBar(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color)
+ : CompositeWidget(container, id, feature_flags, color, Rect16(0, 0, container->Right(), DEFAULT_HEIGHT - 1), 0)
{}
/*virtual*/ void CreateWidgets();
-
- /*virtual*/ void OnCreate(EvtCreate &ev);
};
@@ -346,7 +339,7 @@
{}
ResizeBox(CompositeWidget *container)
- : Widget(container, -101, 0, container->m_color, Rect16(), 0)
+ : Widget(container, -101, FF_NONE, container->m_color, Rect16(), 0)
{}
/*virtual*/ void DrawBackground(EvtPaint &ev);