author | KUDr |
Sat, 03 Mar 2007 11:20:46 +0000 | |
branch | cpp_gui |
changeset 6279 | c75b2c7222ff |
parent 6278 | c09f5e53af9b |
child 6282 | c5b92f2d924f |
permissions | -rw-r--r-- |
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" |
6258
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
19 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
20 |
|
6273 | 21 |
namespace gui { |
22 |
||
6279
c75b2c7222ff
(svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents:
6278
diff
changeset
|
23 |
/*virtual*/ void CaptionBar::CreateWidgets() |
c75b2c7222ff
(svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents:
6278
diff
changeset
|
24 |
{ |
c75b2c7222ff
(svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents:
6278
diff
changeset
|
25 |
|
c75b2c7222ff
(svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents:
6278
diff
changeset
|
26 |
} |
c75b2c7222ff
(svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents:
6278
diff
changeset
|
27 |
|
6273 | 28 |
/*virtual*/ void CaptionBar::DrawBackground(EvtPaint &ev) |
29 |
{ |
|
30 |
BaseWindow *w = GetWindow(); |
|
31 |
assert(w != NULL); |
|
32 |
||
33 |
byte caption_color = w->caption_color; |
|
34 |
assert(Height() == 14); // XXX - to ensure the same sizes are used everywhere! |
|
35 |
DrawFrameRect(Left(), Top(), Right(), Bottom(), m_color, FR_BORDERONLY); |
|
36 |
DrawFrameRect(Left() + 1, Top() + 1, Right() - 1, Bottom() - 1, m_color, (caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY); |
|
37 |
if (caption_color != 0xFF) { |
|
38 |
GfxFillRect(Left() + 2, Top() + 2, Right() - 2, Bottom() - 2, _colour_gradient[_player_colors[caption_color]][4]); |
|
39 |
} |
|
40 |
} |
|
41 |
||
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
42 |
/*virtual*/ void CaptionBar::OnCreate(EvtCreate &ev) |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
43 |
{ |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
44 |
SetAnchors(PIN_LEFT | PIN_TOP | PIN_RIGHT); |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
45 |
} |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
46 |
|
6273 | 47 |
/*virtual*/ void CaptionBar::OnPaint(EvtPaint &ev) |
48 |
{ |
|
49 |
DrawBackground(ev); |
|
50 |
DrawStringCenteredTruncated(Left() + 2, Right() - 2, Top() + 2, m_text, m_text_color); |
|
51 |
ev.SetHandled(); |
|
52 |
} |
|
53 |
||
6275
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
54 |
/*virtual*/ void CaptionBar::OnLeftClick(EvtClick &ev) |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
55 |
{ |
6276
e5f0198ec570
(svn r8984) [cpp_gui] -Cleanup: some forgotten commented code removed
KUDr
parents:
6275
diff
changeset
|
56 |
m_moving_offset = ev.m_pt; |
6275
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
57 |
ev.SetHandled(); |
6277
732cf765e2d7
(svn r8985) [cpp_gui] -Cleanup: copy/paste error (CaptionBar::OnCaptureMoving method name)
KUDr
parents:
6276
diff
changeset
|
58 |
m_ticket_moving = CaptureEventsT(this, &CaptionBar::OnCaptureMoving); |
6275
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
59 |
Invalidate(); |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
60 |
} |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
61 |
|
6277
732cf765e2d7
(svn r8985) [cpp_gui] -Cleanup: copy/paste error (CaptionBar::OnCaptureMoving method name)
KUDr
parents:
6276
diff
changeset
|
62 |
void CaptionBar::OnCaptureMoving(EvtMouseOver &e) |
6275
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
63 |
{ |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
64 |
if (!_left_button_down) { |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
65 |
m_ticket_moving.Release(); |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
66 |
|
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
67 |
EvtClick ev(Point(0, 0)); |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
68 |
ev.m_widget = this; |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
69 |
CallHandlers(ev); |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
70 |
return; |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
71 |
} |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
72 |
GetWindow()->SetTopLeft(e.m_pt - m_moving_offset); |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
73 |
e.SetHandled(); |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
74 |
Invalidate(); |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
75 |
} |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
76 |
|
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
77 |
|
6273 | 78 |
}; // namespace gui |