summaryrefslogtreecommitdiffstats
path: root/src/check.cpp
blob: 4c8637b41a34dc749c733dfdbd8a01f691c7ae6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// check.cpp

#define STRICT
#define D3D_OVERLOADS

#include <windows.h>
#include <stdio.h>
#include <d3d.h>

#include "struct.h"
#include "D3DEngine.h"
#include "math3d.h"
#include "event.h"
#include "misc.h"
#include "iman.h"
#include "restext.h"
#include "text.h"
#include "check.h"




// Constructeur de l'objet.

CCheck::CCheck(CInstanceManager* iMan) : CControl(iMan)
{
	CControl::CControl(iMan);
}

// Destructeur de l'objet.

CCheck::~CCheck()
{
	CControl::~CControl();
}


// Cr�e un nouveau bouton.

BOOL CCheck::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
{
	char	name[100];
	char*	p;

	if ( eventMsg == EVENT_NULL )  eventMsg = GetUniqueEventMsg();

	CControl::Create(pos, dim, icon, eventMsg);

	GetResource(RES_EVENT, eventMsg, name);
	p = strchr(name, '\\');
	if ( p != 0 )  *p = 0;
	SetName(name);

	return TRUE;
}


// Gestion d'un �v�nement.

BOOL CCheck::EventProcess(const Event &event)
{
	if ( m_state & STATE_DEAD )  return TRUE;

	CControl::EventProcess(event);

	if ( event.event == EVENT_LBUTTONDOWN &&
		 (m_state & STATE_VISIBLE)        &&
		 (m_state & STATE_ENABLE)         )
	{
		if ( CControl::Detect(event.pos) )
		{
			Event newEvent = event;
			newEvent.event = m_eventMsg;
			m_event->AddEvent(newEvent);
			return FALSE;
		}
	}

	return TRUE;
}


// Dessine le bouton.

void CCheck::Draw()
{
	FPOINT		iDim, pos;
	float		zoomExt, zoomInt;
	int			icon;

	if ( (m_state & STATE_VISIBLE) == 0 )  return;

	iDim = m_dim;
	m_dim.x = m_dim.y*0.75f;  // carr�

	if ( m_state & STATE_SHADOW )
	{
		DrawShadow(m_pos, m_dim);
	}

	m_engine->SetTexture("button1.tga");
	m_engine->SetState(D3DSTATENORMAL);

	zoomExt = 1.00f;
	zoomInt = 0.95f;

	icon = 2;
	if ( m_state & STATE_DEFAULT )
	{
		DrawPart(23, 1.3f, 0.0f);

		zoomExt *= 1.15f;
		zoomInt *= 1.15f;
	}
	if ( m_state & STATE_HILIGHT )
	{
		icon = 1;
	}
	if ( m_state & STATE_PRESS )
	{
		icon = 3;
		zoomInt *= 0.9f;
	}
	if ( (m_state & STATE_ENABLE) == 0 )
	{
		icon = 7;
	}
	if ( m_state & STATE_DEAD )
	{
		icon = 17;
	}
	DrawPart(icon, zoomExt, 0.0f);  // dessine le bouton

	if ( (m_state & STATE_DEAD) == 0 )
	{
		m_engine->SetState(D3DSTATETTw);

		if ( m_state & STATE_CHECK )
		{
			icon = 16;  // vu
			DrawPart(icon, zoomInt, 0.0f);  // dessine l'ic�ne
		}
	}

	m_dim = iDim;

	if ( m_state & STATE_DEAD )  return;

	// Dessine le nom.
	pos.x = m_pos.x+m_dim.y/0.9f;
	pos.y = m_pos.y+m_dim.y*0.50f;
	pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f;
	m_engine->RetText()->DrawText(m_name, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0);
}