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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
#include <precomp.h>
#include "title.h"
#include <api/wndmgr/layout.h>
#include <api/wnd/paintset.h>
#include <api/skin/widgets/text.h>
#include <api/locales/xlatstr.h>
#include <api/wnd/cwndtrack.h>
#include <api/util/varmgr.h>
#include <api/wnd/PaintCanvas.h>
#define DC_MAXIMIZE 0x9831
const wchar_t titleBarXuiObjectStr[] = L"TitleBar"; // This is the xml tag
char titleBarXuiSvcName[] = "TitleBar xui object"; // this is the name of the xuiservice
XMLParamPair Title::params[] = {
{TITLE_SETBORDER, L"BORDER"},
{TITLE_SETDBLCLKACTION, L"DBLCLICKACTION"},
{TITLE_SETMAXIMIZE, L"MAXIMIZE"},
{TITLE_SETSTREAKS, L"STREAKS"},
{TITLE_SETTITLE, L"TITLE"},
};
Title::Title()
{
getScriptObject()->vcpu_setInterface(titleGuid, (void *)static_cast<Title *>(this));
getScriptObject()->vcpu_setClassName(L"Title");
getScriptObject()->vcpu_setController(titleController);
dostreaks = 1;
doborder = 1;
m_maximize = 0;
getGuiObject()->guiobject_setMover(1);
xuihandle = newXuiHandle();
CreateXMLParameters(xuihandle);
}
void Title::CreateXMLParameters(int master_handle)
{
//TITLE_PARENT::CreateXMLParameters(master_handle);
int numParams = sizeof(params) / sizeof(params[0]);
hintNumberOfParams(xuihandle, numParams);
for (int i = 0;i < numParams;i++)
addParam(xuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
}
Title::~Title()
{}
int Title::setXuiParam(int _xuihandle, int attrid, const wchar_t *name, const wchar_t *strval)
{
if (xuihandle != _xuihandle) return TITLE_PARENT::setXuiParam(_xuihandle, attrid, name, strval);
switch (attrid)
{
case TITLE_SETTITLE:
setTitle(strval);
break;
case TITLE_SETSTREAKS:
setStreaks(WTOI(strval));
break;
case TITLE_SETBORDER:
setBorder(WTOI(strval));
break;
case TITLE_SETMAXIMIZE:
m_maximize = WTOI(strval);
break;
case TITLE_SETDBLCLKACTION:
dblClickAction = strval;
break;
default:
return 0;
}
return 1;
}
void Title::setStreaks(int s)
{
if (s == dostreaks) return ;
dostreaks = s;
invalidate();
}
void Title::setBorder(int b)
{
if (b == doborder) return ;
doborder = b;
invalidate();
}
int Title::getPreferences(int what)
{
if (what == SUGGESTED_W) return 128;
if (what == SUGGESTED_H) return 22;
return TITLE_PARENT::getPreferences(what);
}
int Title::onPaint(Canvas *canvas)
{
const wchar_t *tempname = title;
//StringW tempname(title);
PaintCanvas paintcanvas;
if (canvas == NULL)
{
if (!paintcanvas.beginPaint(this)) return 0;
canvas = &paintcanvas;
}
TITLE_PARENT::onPaint(canvas);
#ifdef WA3COMPATIBILITY
//tempname = PublicVarManager::translate(title, getGuiObject());
#else
tempname = title;
#endif
#ifdef WASABI_COMPILE_PAINTSETS
RECT pr(TITLE_PARENT::clientRect());
const wchar_t *t = NULL;
switch(wantTranslation())
{
case 0:
t = tempname;
break;
case 1:
t = _(tempname);
break;
case 2:
t = __(tempname);
break;
}
paintset_renderTitle(t, canvas, &pr, getPaintingAlpha(), dostreaks, doborder);
#endif
return 1;
}
void Title::setTitle(const wchar_t *t)
{
title = t;
title.toupper();
}
const wchar_t *Title::getTitle()
{
return title;
}
int Title::onLeftButtonDblClk(int x, int y)
{
if (m_maximize)
postDeferredCallback(DC_MAXIMIZE, 0);
else
{
#ifdef WASABI_COMPILE_WNDMGR
if (dblClickAction)
{
const wchar_t *toCheck = L"SWITCH;";
if (!WCSNICMP(dblClickAction, toCheck, 7))
{
onLeftButtonUp(x, y);
getGuiObject()->guiobject_getParentGroup()->getParentContainer()->switchToLayout(dblClickAction.getValue() + 7);
}
}
#endif
}
ifc_window *b = getParent();
if (b)
return b->onLeftButtonDblClk(x, y);
return TITLE_PARENT::onLeftButtonDblClk(x, y);
}
int Title::onDeferredCallback(intptr_t param1, intptr_t param2)
{
switch (param1)
{
#ifdef WASABI_COMPILE_WNDMGR
case DC_MAXIMIZE:
Container *c = getGuiObject()->guiobject_getParentGroup()->getParentContainer();
if (c)
{
Layout *l = c->getCurrentLayout();
if (l)
{
if (l->isMaximized()) l->restore();
else l->maximize();
}
}
return 1;
#endif
}
return TITLE_PARENT::onDeferredCallback(param1, param2);
}
TitleScriptController _titleController;
TitleScriptController *titleController = &_titleController;
// -- Functions table -------------------------------------
function_descriptor_struct TitleScriptController::exportedFunction[] = {
{L"fake", 0, (void*)Title::script_vcpu_fake },
};
const wchar_t *TitleScriptController::getClassName()
{
return L"Title";
}
const wchar_t *TitleScriptController::getAncestorClassName()
{
return L"GuiObject";
}
ScriptObject *TitleScriptController::instantiate()
{
Title *t = new Title;
ASSERT(t != NULL);
return t->getScriptObject();
}
void TitleScriptController::destroy(ScriptObject *o)
{
Title *t = static_cast<Title *>(o->vcpu_getInterface(titleGuid));
ASSERT(t != NULL);
delete t;
}
void *TitleScriptController::encapsulate(ScriptObject *o)
{
return NULL; // no encapsulation for title yet
}
void TitleScriptController::deencapsulate(void *o)
{}
int TitleScriptController::getNumFunctions()
{
return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
}
const function_descriptor_struct *TitleScriptController::getExportedFunctions()
{
return exportedFunction;
}
GUID TitleScriptController::getClassGuid()
{
return titleGuid;
}
const wchar_t *Title::vcpu_getClassName()
{
return L"Title";
}
scriptVar Title::script_vcpu_fake(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
{
SCRIPT_FUNCTION_INIT
RETURN_SCRIPT_VOID;
}
|