KUDr@6258: /* $Id$ */ KUDr@6258: KUDr@6258: #include "../stdafx.h" KUDr@6258: #include KUDr@6258: #include "../openttd.h" KUDr@6258: #include "../debug.h" KUDr@6258: #include "../functions.h" KUDr@6258: #include "../map.h" KUDr@6258: #include "../player.h" KUDr@6258: #include "../window.h" KUDr@6258: #include "../gfx.h" KUDr@6258: #include "../viewport.h" KUDr@6258: #include "../console.h" KUDr@6258: #include "../variables.h" KUDr@6258: #include "../table/sprites.h" KUDr@6258: #include "../genworld.h" KUDr@6258: #include "../helpers.hpp" KUDr@6264: #include "window_events.hpp" KUDr@6289: #include "widget_types.h" KUDr@6258: KUDr@6278: namespace gui { KUDr@6258: KUDr@6278: /*virtual*/ void ResizeBox::DrawBackground(EvtPaint &ev) KUDr@6278: { KUDr@6281: bool sizing = m_ticket_sizing.IsActive(); KUDr@6278: DrawFrameRect(Left(), Top(), Right(), Bottom(), m_color, sizing ? FR_LOWERED : FR_NONE); KUDr@6278: } KUDr@6278: KUDr@6278: void ResizeBox::OnCaptureSizing(EvtMouseOver &e) KUDr@6278: { KUDr@6278: if (!_left_button_down) { KUDr@6278: m_ticket_sizing.Release(); KUDr@6278: KUDr@6282: EvtLeftClick ev(Point(0, 0)); KUDr@6278: ev.m_widget = this; KUDr@6278: CallHandlers(ev); KUDr@6278: return; KUDr@6278: } KUDr@6278: BaseWindow *w = GetWindow(); KUDr@6278: w->SetDirty(); KUDr@6293: Point16 size = e.m_pt - w->TopLeft() + m_sizing_offset; KUDr@6293: size.x = max(size.x, DEFAULT_WIDTH); KUDr@6293: size.y = max(size.y, DEFAULT_HEIGHT); KUDr@6293: w->SetSize(size); KUDr@6278: e.SetHandled(); KUDr@6278: w->SetDirty(); KUDr@6278: } KUDr@6278: KUDr@6278: /*virtual*/ void ResizeBox::OnCreate(EvtCreate &ev) KUDr@6278: { KUDr@6278: Point16 size(DEFAULT_WIDTH, DEFAULT_HEIGHT); KUDr@6278: SetTopLeft(m_container->BottomRight() - size + Point16(1, 1)); KUDr@6278: SetBottomRight(m_container->BottomRight()); KUDr@6278: KUDr@6278: SetAnchors(PIN_RIGHT | PIN_BOTTOM); KUDr@6282: super::OnCreate(ev); KUDr@6278: } KUDr@6278: KUDr@6278: /*virtual*/ void ResizeBox::OnPaint(EvtPaint &ev) KUDr@6278: { KUDr@6282: assert(Size() == Point16(DEFAULT_WIDTH, DEFAULT_HEIGHT)); KUDr@6278: KUDr@6278: DrawBackground(ev); KUDr@6281: bool sizing = m_ticket_sizing.IsActive(); KUDr@6290: DrawSprite(SPR_WINDOW_RESIZE, PAL_NONE, sizing ? Point16(4, 4) : Point16(3, 3)); KUDr@6278: ev.SetHandled(); KUDr@6278: } KUDr@6278: KUDr@6282: /*virtual*/ void ResizeBox::OnLeftButtonDown(EvtLeftButtonDown &ev) KUDr@6278: { KUDr@6278: BaseWindow *w = GetWindow(); KUDr@6278: m_sizing_offset = w->Size() - ev.m_pt; KUDr@6278: m_ticket_sizing = CaptureEventsT(this, &ResizeBox::OnCaptureSizing); KUDr@6278: Invalidate(); KUDr@6278: ev.SetHandled(); KUDr@6278: } KUDr@6278: KUDr@6278: /*virtual*/ void ResizeBox::OnResizeParent(EvtResizeParent &ev) KUDr@6278: { KUDr@6278: //SetTopLeft(TopLeft() + ev.m_change); KUDr@6278: //ev.SetHandled(); KUDr@6278: super::OnResizeParent(ev); KUDr@6278: } KUDr@6278: KUDr@6278: KUDr@6278: }; // namespace gui