src/widget/widget_button.cpp
author KUDr
Tue, 27 Feb 2007 22:47:59 +0000
branchcpp_gui
changeset 6264 9fc3b5467396
parent 6258 a2f86b8fd99b
child 6271 0ad100a98853
permissions -rw-r--r--
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
-Add: new gui events (C++)
-Add: dynamic event handlers introduced (see Widget::AddReflectHandlerT)
-Add: test window using the new features (intro_gui.cpp)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     1
/* $Id$ */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     2
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     3
#include "../stdafx.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     4
#include <stdarg.h>
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     5
#include "../openttd.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     6
#include "../debug.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     7
#include "../functions.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     8
#include "../map.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     9
#include "../player.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    10
#include "../window.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    11
#include "../gfx.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    12
#include "../viewport.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    13
#include "../console.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    14
#include "../variables.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    15
#include "../table/sprites.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    16
#include "../genworld.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    17
#include "../helpers.hpp"
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    18
#include "window_events.hpp"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    19
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    20
namespace gui {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    21
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    22
/*virtual*/ void Button::DrawBackground(EvtPaint &ev)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    23
{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    24
	DrawFrameRect(m_color, m_pushed ? FR_LOWERED : FR_NONE);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    25
}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    26
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    27
/*virtual*/ void Button::OnLeftClick(EvtClick &ev)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    28
{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    29
	m_pushed = !m_pushed;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    30
	CallHandlers(ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    31
	ev.SetHandled();
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    32
	Invalidate();
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    33
}
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    34
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    35
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6258
diff changeset
    36
}; // namespace gui