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@6258: KUDr@6258: KUDr@6273: namespace gui { KUDr@6273: KUDr@6279: /*virtual*/ void CaptionBar::CreateWidgets() KUDr@6279: { KUDr@6279: KUDr@6279: } KUDr@6279: KUDr@6273: /*virtual*/ void CaptionBar::DrawBackground(EvtPaint &ev) KUDr@6273: { KUDr@6273: BaseWindow *w = GetWindow(); KUDr@6273: assert(w != NULL); KUDr@6273: KUDr@6273: byte caption_color = w->caption_color; KUDr@6273: assert(Height() == 14); // XXX - to ensure the same sizes are used everywhere! KUDr@6273: DrawFrameRect(Left(), Top(), Right(), Bottom(), m_color, FR_BORDERONLY); KUDr@6273: DrawFrameRect(Left() + 1, Top() + 1, Right() - 1, Bottom() - 1, m_color, (caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY); KUDr@6273: if (caption_color != 0xFF) { KUDr@6273: GfxFillRect(Left() + 2, Top() + 2, Right() - 2, Bottom() - 2, _colour_gradient[_player_colors[caption_color]][4]); KUDr@6273: } KUDr@6273: } KUDr@6273: KUDr@6278: /*virtual*/ void CaptionBar::OnCreate(EvtCreate &ev) KUDr@6278: { KUDr@6278: SetAnchors(PIN_LEFT | PIN_TOP | PIN_RIGHT); KUDr@6278: } KUDr@6278: KUDr@6273: /*virtual*/ void CaptionBar::OnPaint(EvtPaint &ev) KUDr@6273: { KUDr@6273: DrawBackground(ev); KUDr@6273: DrawStringCenteredTruncated(Left() + 2, Right() - 2, Top() + 2, m_text, m_text_color); KUDr@6273: ev.SetHandled(); KUDr@6273: } KUDr@6273: KUDr@6275: /*virtual*/ void CaptionBar::OnLeftClick(EvtClick &ev) KUDr@6275: { KUDr@6276: m_moving_offset = ev.m_pt; KUDr@6275: ev.SetHandled(); KUDr@6277: m_ticket_moving = CaptureEventsT(this, &CaptionBar::OnCaptureMoving); KUDr@6275: Invalidate(); KUDr@6275: } KUDr@6275: KUDr@6277: void CaptionBar::OnCaptureMoving(EvtMouseOver &e) KUDr@6275: { KUDr@6275: if (!_left_button_down) { KUDr@6275: m_ticket_moving.Release(); KUDr@6275: KUDr@6275: EvtClick ev(Point(0, 0)); KUDr@6275: ev.m_widget = this; KUDr@6275: CallHandlers(ev); KUDr@6275: return; KUDr@6275: } KUDr@6275: GetWindow()->SetTopLeft(e.m_pt - m_moving_offset); KUDr@6275: e.SetHandled(); KUDr@6275: Invalidate(); KUDr@6275: } KUDr@6275: KUDr@6275: KUDr@6273: }; // namespace gui