KUDr@6264: /* $Id$ */ KUDr@6264: KUDr@6289: #ifndef WIDGET_TYPES_H KUDr@6289: #define WIDGET_TYPES_H KUDr@6264: KUDr@6289: #include "widget.h" KUDr@6289: #include "table/strings.h" KUDr@6264: KUDr@6264: namespace gui { KUDr@6264: KUDr@6286: struct Label : public Widget { KUDr@6286: typedef Widget super; KUDr@6286: KUDr@6286: protected: KUDr@6286: StringID m_text; KUDr@6286: KUDr@6286: public: KUDr@6286: Label() KUDr@6286: : Widget() KUDr@6286: {} KUDr@6286: KUDr@6286: Label(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, const Rect16 &rect, StringID text, StringID tooltip = 0, int color = COLOUR_NONE) KUDr@6286: : Widget(container, id, feature_flags, (byte)color, rect, tooltip) KUDr@6286: , m_text(text) KUDr@6286: { KUDr@6286: /* make the label transparent (no background) if color not provided */ KUDr@6286: if (color == COLOUR_NONE) m_feature_flags |= FF_TRANSPARENT; KUDr@6286: } KUDr@6286: KUDr@6286: /*virtual*/ void DrawBackground(EvtPaint &ev); KUDr@6286: KUDr@6286: /*virtual*/ void OnPaint(EvtPaint &ev); KUDr@6286: }; KUDr@6286: KUDr@6264: struct Button : public Widget { KUDr@6264: typedef Widget super; KUDr@6264: KUDr@6264: protected: KUDr@6264: bool m_pushed; KUDr@6271: CaptureTicket m_ticket_pressed; KUDr@6264: KUDr@6264: public: KUDr@6264: Button() KUDr@6264: : Widget() KUDr@6264: , m_pushed(false) KUDr@6264: {} KUDr@6264: KUDr@6283: Button(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips) KUDr@6283: : Widget(container, id, feature_flags, color, rect, tooltips) KUDr@6264: , m_pushed(false) KUDr@6264: {} KUDr@6264: KUDr@6271: void OnCapturePressed(EvtMouseOver &e); KUDr@6271: KUDr@6264: /*virtual*/ void DrawBackground(EvtPaint &ev); KUDr@6264: KUDr@6282: /*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); KUDr@6264: }; KUDr@6264: KUDr@6290: struct ImageButton : public Button { KUDr@6290: typedef Button super; KUDr@6290: KUDr@6290: protected: KUDr@6290: SpriteID m_sprite; KUDr@6290: Point16 m_sprite_offset; KUDr@6290: KUDr@6290: public: KUDr@6290: ImageButton() KUDr@6290: : Button() KUDr@6290: , m_sprite(0) KUDr@6290: {} KUDr@6290: KUDr@6290: ImageButton(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips, SpriteID sprite, Point16 sprite_offset) KUDr@6290: : Button(container, id, feature_flags, color, rect, tooltips) KUDr@6290: , m_sprite(sprite) KUDr@6290: , m_sprite_offset(sprite_offset) KUDr@6290: {} KUDr@6290: KUDr@6290: /*virtual*/ void OnPaint(EvtPaint &ev); KUDr@6290: }; KUDr@6290: KUDr@6290: struct ImageButton2 : public ImageButton { KUDr@6290: typedef ImageButton super; KUDr@6290: KUDr@6290: protected: KUDr@6290: SpriteID m_sprite_pushed; KUDr@6290: Point16 m_sprite_offset_pushed; KUDr@6290: KUDr@6290: public: KUDr@6290: ImageButton2() KUDr@6290: : ImageButton() KUDr@6290: , m_sprite_pushed(0) KUDr@6290: {} KUDr@6290: KUDr@6290: ImageButton2(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips, SpriteID sprite, Point16 sprite_offset, SpriteID sprite_pushed, Point16 sprite_offset_pushed) KUDr@6290: : ImageButton(container, id, feature_flags, color, rect, tooltips, sprite, sprite_offset) KUDr@6290: , m_sprite_pushed(sprite_pushed) KUDr@6290: , m_sprite_offset_pushed(sprite_offset_pushed) KUDr@6290: {} KUDr@6290: KUDr@6290: /*virtual*/ void OnPaint(EvtPaint &ev); KUDr@6290: }; KUDr@6290: KUDr@6264: struct TextButton : public Button { KUDr@6264: typedef Button super; KUDr@6264: KUDr@6264: protected: KUDr@6264: StringID m_text; KUDr@6264: KUDr@6264: public: KUDr@6264: TextButton() KUDr@6264: : Button() KUDr@6264: {} KUDr@6264: KUDr@6283: TextButton(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips, StringID text) KUDr@6283: : Button(container, id, feature_flags, color, rect, tooltips) KUDr@6264: , m_text(text) KUDr@6264: {} KUDr@6264: KUDr@6264: /*virtual*/ void OnPaint(EvtPaint &ev); KUDr@6264: }; KUDr@6264: KUDr@6282: struct CloseBox : public Button { KUDr@6282: typedef Button super; KUDr@6278: KUDr@6278: static const int16 DEFAULT_WIDTH = 11; KUDr@6282: static const int16 DEFAULT_HEIGHT = 14; KUDr@6282: KUDr@6282: public: KUDr@6282: CloseBox() KUDr@6282: : Button() KUDr@6282: {} KUDr@6282: KUDr@6282: CloseBox(CompositeWidget *container) KUDr@6289: : Button(container, -102, FF_NONE, container->m_color, Rect16(), STR_018B_CLOSE_WINDOW) KUDr@6289: {} KUDr@6289: KUDr@6289: /*virtual*/ void OnCreate(EvtCreate &ev); KUDr@6289: /*virtual*/ void OnPaint(EvtPaint &ev); KUDr@6289: /*virtual*/ void OnLeftClick(EvtLeftClick &ev); KUDr@6289: }; KUDr@6289: KUDr@6290: struct StickyBox : public ImageButton2 { KUDr@6290: typedef ImageButton2 super; KUDr@6289: KUDr@6289: static const int16 DEFAULT_WIDTH = 12; KUDr@6289: static const int16 DEFAULT_HEIGHT = 14; KUDr@6289: KUDr@6289: public: KUDr@6289: StickyBox() KUDr@6290: : ImageButton2() KUDr@6289: {} KUDr@6289: KUDr@6289: StickyBox(CompositeWidget *container) KUDr@6290: : ImageButton2(container, -103, FF_TOGGLE_BUTTON, container->m_color, Rect16(), STR_STICKY_BUTTON, SPR_PIN_DOWN, Point(0, 1), SPR_PIN_UP, Point(0, 1)) KUDr@6282: {} KUDr@6282: KUDr@6282: /*virtual*/ void OnCreate(EvtCreate &ev); KUDr@6290: // /*virtual*/ void OnPaint(EvtPaint &ev); KUDr@6282: /*virtual*/ void OnLeftClick(EvtLeftClick &ev); KUDr@6282: }; KUDr@6282: KUDr@6282: struct Caption : public Widget { KUDr@6282: typedef Widget super; KUDr@6278: KUDr@6278: protected: KUDr@6282: Point16 m_moving_offset; KUDr@6282: CaptureTicket m_ticket_moving; KUDr@6278: KUDr@6278: public: KUDr@6282: Caption() KUDr@6278: : Widget() KUDr@6278: {} KUDr@6278: KUDr@6283: Caption(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 rect, byte text_color, StringID tooltips, StringID text) KUDr@6283: : Widget(container, id, feature_flags, color, rect, tooltips) KUDr@6278: {} KUDr@6278: KUDr@6278: /*virtual*/ void DrawBackground(EvtPaint &ev); KUDr@6278: KUDr@6278: /*virtual*/ void OnPaint(EvtPaint &ev); KUDr@6282: /*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); KUDr@6282: void OnCaptureMoving(EvtMouseOver &e); KUDr@6278: }; KUDr@6278: KUDr@6273: struct CaptionBar : public CompositeWidget { KUDr@6273: typedef CompositeWidget super; KUDr@6273: KUDr@6273: static const int16 DEFAULT_HEIGHT = 14; KUDr@6273: KUDr@6273: public: KUDr@6273: CaptionBar() KUDr@6273: : CompositeWidget() KUDr@6273: {} KUDr@6273: KUDr@6283: CaptionBar(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color) KUDr@6283: : CompositeWidget(container, id, feature_flags, color, Rect16(0, 0, container->Right(), DEFAULT_HEIGHT - 1), 0) KUDr@6273: {} KUDr@6273: KUDr@6279: /*virtual*/ void CreateWidgets(); KUDr@6282: }; KUDr@6282: KUDr@6282: KUDr@6282: struct ResizeBox : public Widget { KUDr@6282: typedef Widget super; KUDr@6282: KUDr@6282: static const int16 DEFAULT_WIDTH = 11; KUDr@6282: static const int16 DEFAULT_HEIGHT = 11; KUDr@6282: KUDr@6282: protected: KUDr@6282: Point16 m_sizing_offset; KUDr@6282: CaptureTicket m_ticket_sizing; KUDr@6282: KUDr@6282: public: KUDr@6282: ResizeBox() KUDr@6282: : Widget() KUDr@6282: {} KUDr@6282: KUDr@6282: ResizeBox(CompositeWidget *container) KUDr@6289: : Widget(container, -101, FF_NONE, container->m_color, Rect16(), STR_RESIZE_BUTTON) KUDr@6282: {} KUDr@6282: KUDr@6273: /*virtual*/ void DrawBackground(EvtPaint &ev); KUDr@6282: void OnCaptureSizing(EvtMouseOver &e); KUDr@6273: KUDr@6278: /*virtual*/ void OnCreate(EvtCreate &ev); KUDr@6273: /*virtual*/ void OnPaint(EvtPaint &ev); KUDr@6282: /*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); KUDr@6282: /*virtual*/ void OnResizeParent(EvtResizeParent &ev); KUDr@6282: KUDr@6273: }; KUDr@6273: KUDr@6264: }; // namespace gui KUDr@6264: KUDr@6289: #endif /* WIDGET_TYPES_H */