src/widget/widget_closebox.cpp
author KUDr
Sat, 10 Mar 2007 08:53:59 +0000
branchcpp_gui
changeset 6295 a88d8c2cff6e
parent 6289 be3d8bd9fb02
child 6301 e0251f797d59
permissions -rw-r--r--
(svn r9091) [cpp_gui] -Codechange: Widgets now use container's coordinate space instead of window's space
/* $Id$ */

#include "../stdafx.h"
#include <stdarg.h>
#include "../openttd.h"
#include "../debug.h"
#include "../functions.h"
#include "../map.h"
#include "../player.h"
#include "../window.h"
#include "../gfx.h"
#include "../viewport.h"
#include "../console.h"
#include "../variables.h"
#include "../table/sprites.h"
#include "../genworld.h"
#include "../helpers.hpp"
#include "window_events.hpp"
#include "widget_types.h"

namespace gui {

/*virtual*/ void CloseBox::OnCreate(EvtCreate &ev)
{
	Point16 size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	// move itself to the left of the parent
	SetTopLeft(m_container->TopLeft());
	SetBottomRight(TopLeft() +  size - Point16(1, 1));

	SetAnchors(PIN_LEFT | PIN_TOP);
	super::OnCreate(ev);
}

/*virtual*/ void CloseBox::OnPaint(EvtPaint &ev)
{
	assert(Size() == Point16(DEFAULT_WIDTH, DEFAULT_HEIGHT));

	DrawBackground(ev);
	DrawString(Left() + 2, Top() + 2, STR_00C5, 0);
}

/*virtual*/ void CloseBox::OnLeftClick(EvtLeftClick &ev)
{
	BaseWindow *w = GetWindow();
	assert(w != NULL);
	w->Close();
}

}; // namespace gui