|
94
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2000-2004 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
#include <e32def.h> // First to avoid NULL redefine warning (no #ifndef NULL).
|
|
|
19 |
#include "nw_fbox_epoc32selectskini.h"
|
|
|
20 |
#include "nw_image_cannedimages.h"
|
|
|
21 |
#include "nw_fbox_selectboxi.h"
|
|
|
22 |
#include "nw_lmgr_rootbox.h"
|
|
|
23 |
#include "nwx_string.h"
|
|
|
24 |
#include "nw_fbox_epoc32formimages.h"
|
|
|
25 |
#include "nw_gdi_types.h"
|
|
|
26 |
#include "GDIDeviceContext.h"
|
|
|
27 |
#include "nw_adt_resizablevector.h"
|
|
|
28 |
#include "nw_fbox_formboxutils.h"
|
|
|
29 |
#include "KimonoLocalizationStrings.h"
|
|
|
30 |
#include "nwx_logger.h"
|
|
|
31 |
#include "nw_lmgr_statictablecellbox.h"
|
|
|
32 |
#include "nw_browser_browserimages.h"
|
|
|
33 |
#include "BrsrStatusCodes.h"
|
|
|
34 |
|
|
|
35 |
/* ------------------------------------------------------------------------- *
|
|
|
36 |
private data typed
|
|
|
37 |
* ------------------------------------------------------------------------- */
|
|
|
38 |
|
|
|
39 |
static const NW_Ucs2 _NW_FBox_Epoc32SelectSkin_Separator[] = {',',' ','\0'};
|
|
|
40 |
#define NW_FBox_Epoc32SelectSkin_Separator_len ((sizeof(_NW_FBox_Epoc32SelectSkin_Separator)\
|
|
|
41 |
/sizeof(NW_Ucs2))-1)
|
|
|
42 |
|
|
|
43 |
/* ------------------------------------------------------------------------- *
|
|
|
44 |
static data
|
|
|
45 |
* ------------------------------------------------------------------------- */
|
|
|
46 |
|
|
|
47 |
/* ------------------------------------------------------------------------- *
|
|
|
48 |
private methods
|
|
|
49 |
* ------------------------------------------------------------------------- */
|
|
|
50 |
|
|
|
51 |
NW_Ucs2*
|
|
|
52 |
NW_FBox_Epoc32SelectSkin_GetNewUcs2Str(NW_FBox_Epoc32SelectSkin_t* skin,
|
|
|
53 |
NW_Text_t* text)
|
|
|
54 |
{
|
|
|
55 |
NW_REQUIRED_PARAM(skin);
|
|
|
56 |
|
|
|
57 |
return
|
|
|
58 |
NW_Text_GetUCS2Buffer (text, NW_Text_Flags_Aligned | NW_Text_Flags_Copy,
|
|
|
59 |
NULL, NULL);
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
/* ------------------------------------------------------------------------- */
|
|
|
63 |
static
|
|
|
64 |
TBrowserStatusCode
|
|
|
65 |
NW_FBox_Epoc32SelectSkin_GetArrowSize(NW_FBox_SelectBox_t* selectBox,
|
|
|
66 |
NW_GDI_Dimension3D_t* imageSize)
|
|
|
67 |
{
|
|
|
68 |
const NW_Image_AbstractImage_t* image;
|
|
|
69 |
NW_LMgr_RootBox_t* rootBox;
|
|
|
70 |
|
|
|
71 |
NW_ASSERT(imageSize!=NULL);
|
|
|
72 |
NW_ASSERT(selectBox!=NULL);
|
|
|
73 |
|
|
|
74 |
/* get the root box */
|
|
|
75 |
rootBox = NW_LMgr_Box_GetRootBox(NW_LMgr_BoxOf(selectBox));
|
|
|
76 |
NW_ASSERT(rootBox);
|
|
|
77 |
|
|
|
78 |
/* get the image from the canned images dictionary */
|
|
|
79 |
NW_ASSERT(rootBox->cannedImages!=NULL);
|
|
|
80 |
image = NW_Image_CannedImages_GetImage( rootBox->cannedImages,
|
|
|
81 |
NW_Image_SelectArrow );
|
|
|
82 |
NW_ASSERT(image);
|
|
|
83 |
return NW_Image_AbstractImage_GetSize (image, imageSize);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
/* ------------------------------------------------------------------------- */
|
|
|
87 |
static
|
|
|
88 |
TBrowserStatusCode
|
|
|
89 |
NW_FBox_Epoc32SelectSkin_GetTextExtent(NW_FBox_Epoc32SelectSkin_t* selectSkin,
|
|
|
90 |
NW_FBox_SelectBox_t* selectBox,
|
|
|
91 |
CGDIDeviceContext* deviceContext,
|
|
|
92 |
NW_GDI_Dimension2D_t* extent,
|
|
|
93 |
NW_Text_t* text)
|
|
|
94 |
{
|
|
|
95 |
NW_REQUIRED_PARAM(selectSkin);
|
|
|
96 |
|
|
|
97 |
CGDIFont *font;
|
|
|
98 |
TBrowserStatusCode status;
|
|
|
99 |
TGDIFontInfo fontInfo;
|
|
|
100 |
|
|
|
101 |
extent->width = 0;
|
|
|
102 |
extent->height = 0;
|
|
|
103 |
|
|
|
104 |
/* Set the font to match the parent. */
|
|
|
105 |
font = NW_LMgr_Box_GetFont (NW_LMgr_BoxOf(selectBox));
|
|
|
106 |
NW_ASSERT(font != NULL);
|
|
|
107 |
/* Get info */
|
|
|
108 |
font->GetFontInfo ( &fontInfo);
|
|
|
109 |
|
|
|
110 |
if (text == NULL)
|
|
|
111 |
{
|
|
|
112 |
return KBrsrSuccess;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
status = deviceContext->GetTextExtent (text,
|
|
|
116 |
font,
|
|
|
117 |
0,
|
|
|
118 |
NW_GDI_FlowDirection_LeftRight,
|
|
|
119 |
extent);
|
|
|
120 |
|
|
|
121 |
extent->height = fontInfo.height;
|
|
|
122 |
|
|
|
123 |
return status;
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
/* ------------------------------------------------------------------------- */
|
|
|
127 |
static
|
|
|
128 |
NW_Int32
|
|
|
129 |
NW_FBox_Epoc32SelectSkin_GetMaxTextWidth(NW_FBox_Epoc32SelectSkin_t* selectSkin,
|
|
|
130 |
NW_FBox_SelectBox_t* selectBox)
|
|
|
131 |
{
|
|
|
132 |
NW_REQUIRED_PARAM(selectSkin);
|
|
|
133 |
|
|
|
134 |
CGDIFont *font;
|
|
|
135 |
CGDIDeviceContext* deviceContext;
|
|
|
136 |
TGDIFontInfo fontInfo;
|
|
|
137 |
NW_Int32 maxWidth = 0;
|
|
|
138 |
NW_Text_t* text = NULL;
|
|
|
139 |
NW_ADT_Vector_Metric_t index;
|
|
|
140 |
NW_GDI_Dimension2D_t extent;
|
|
|
141 |
NW_FBox_OptionBox_t* optionBox = NULL;
|
|
|
142 |
|
|
|
143 |
/* we're going to need the deviceContext to do text extent calculations */
|
|
|
144 |
deviceContext = NW_LMgr_RootBox_GetDeviceContext (NW_LMgr_Box_GetRootBox(selectBox));
|
|
|
145 |
NW_ASSERT (deviceContext != NULL);
|
|
|
146 |
|
|
|
147 |
/* Set the font to match the parent. */
|
|
|
148 |
font = NW_LMgr_Box_GetFont(NW_LMgr_BoxOf(selectBox));
|
|
|
149 |
NW_ASSERT(font != NULL);
|
|
|
150 |
font->GetFontInfo( &fontInfo);
|
|
|
151 |
|
|
|
152 |
NW_Int32 numItems = NW_ADT_Vector_GetSize(NW_ADT_VectorOf(selectBox->children));
|
|
|
153 |
|
|
|
154 |
for(index = 0; index < numItems; index++)
|
|
|
155 |
{
|
|
|
156 |
optionBox = *(NW_FBox_OptionBox_t**)NW_ADT_Vector_ElementAt(selectBox->children, index);
|
|
|
157 |
|
|
|
158 |
if (!NW_Object_IsInstanceOf(optionBox, &NW_FBox_OptionBox_Class))
|
|
|
159 |
continue;
|
|
|
160 |
|
|
|
161 |
text = NW_FBox_OptionBox_GetText(optionBox);
|
|
|
162 |
if (text == NULL)
|
|
|
163 |
continue;
|
|
|
164 |
|
|
|
165 |
extent.width = 0;
|
|
|
166 |
extent.height = 0;
|
|
|
167 |
deviceContext->GetTextExtent (text, font, 0, NW_GDI_FlowDirection_LeftRight, &extent);
|
|
|
168 |
if (maxWidth < extent.width)
|
|
|
169 |
{
|
|
|
170 |
maxWidth = extent.width;
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
return maxWidth;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
/* ------------------------------------------------------------------------- */
|
|
|
178 |
static
|
|
|
179 |
TBrowserStatusCode
|
|
|
180 |
NW_FBox_Epoc32SelectSkin_SetDisplayText(NW_FBox_Epoc32SelectSkin_t* thisObj)
|
|
|
181 |
{
|
|
|
182 |
CGDIDeviceContext* deviceContext = NULL;
|
|
|
183 |
NW_FBox_SelectBox_t* selectBox = NULL;
|
|
|
184 |
NW_GDI_Dimension2D_t extent;
|
|
|
185 |
NW_GDI_Dimension2D_t charExtent;
|
|
|
186 |
NW_GDI_Dimension3D_t imageSize;
|
|
|
187 |
NW_Uint16 displayWidth = 0;
|
|
|
188 |
NW_GDI_Rectangle_t innerRect;
|
|
|
189 |
NW_Text_Length_t valueLength = 0;
|
|
|
190 |
NW_Text_Length_t displayLength = 0;
|
|
|
191 |
CGDIFont *font = NULL;
|
|
|
192 |
NW_Ucs2* displayStorage = NULL;
|
|
|
193 |
NW_Ucs2* valueStorage = NULL;
|
|
|
194 |
|
|
|
195 |
NW_TRY(status)
|
|
|
196 |
{
|
|
|
197 |
selectBox = NW_FBox_SelectSkin_GetSelectBox(thisObj);
|
|
|
198 |
NW_ASSERT (selectBox);
|
|
|
199 |
|
|
|
200 |
/* we're going to need the deviceContext to do text extent calculations */
|
|
|
201 |
deviceContext = NW_LMgr_RootBox_GetDeviceContext (NW_LMgr_Box_GetRootBox(selectBox));
|
|
|
202 |
NW_ASSERT (deviceContext != NULL);
|
|
|
203 |
|
|
|
204 |
/* Set the font to match the parent. TODO: this may not be the best policy */
|
|
|
205 |
font = NW_LMgr_Box_GetFont (NW_LMgr_BoxOf(selectBox));
|
|
|
206 |
NW_ASSERT(font != NULL);
|
|
|
207 |
|
|
|
208 |
/* extract the image from our canned images */
|
|
|
209 |
status = NW_FBox_Epoc32SelectSkin_GetArrowSize(selectBox, &imageSize);
|
|
|
210 |
NW_THROW_ON_ERROR (status);
|
|
|
211 |
|
|
|
212 |
status = NW_FBox_SelectSkin_GetMCharExtent(NW_FBox_SelectSkinOf(thisObj), &charExtent);
|
|
|
213 |
NW_THROW_ON_ERROR (status);
|
|
|
214 |
|
|
|
215 |
if (thisObj->value == NULL)
|
|
|
216 |
{
|
|
|
217 |
/* nothing to display */
|
|
|
218 |
NW_THROW_SUCCESS(status);
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
/* Find out how much space is required to display the value */
|
|
|
222 |
status = NW_FBox_Epoc32SelectSkin_GetTextExtent(thisObj, selectBox,
|
|
|
223 |
deviceContext, &extent, NW_TextOf(thisObj->value));
|
|
|
224 |
NW_THROW_ON_ERROR (status);
|
|
|
225 |
|
|
|
226 |
displayWidth = (NW_Uint16)(extent.width + imageSize.width);
|
|
|
227 |
NW_LMgr_Box_GetInnerRectangle(NW_LMgr_BoxOf(selectBox), &innerRect);
|
|
|
228 |
|
|
|
229 |
valueStorage =
|
|
|
230 |
NW_Text_GetUCS2Buffer(NW_TextOf(thisObj->value), 0, &valueLength, NULL);
|
|
|
231 |
|
|
|
232 |
/* The text fits within the space */
|
|
|
233 |
if (displayWidth <= innerRect.dimension.width)
|
|
|
234 |
{
|
|
|
235 |
/* Make a copy of the value */
|
|
|
236 |
if (valueStorage)
|
|
|
237 |
{
|
|
|
238 |
displayStorage = NW_Str_Newcpy(valueStorage);
|
|
|
239 |
NW_THROW_OOM_ON_NULL(displayStorage, status);
|
|
|
240 |
}
|
|
|
241 |
|
|
|
242 |
if (thisObj->displayText)
|
|
|
243 |
{
|
|
|
244 |
status = NW_Text_SetStorage(NW_TextOf(thisObj->displayText), displayStorage,
|
|
|
245 |
valueLength, NW_Text_Flags_TakeOwnership);
|
|
|
246 |
NW_THROW_ON_ERROR (status);
|
|
|
247 |
}
|
|
|
248 |
else
|
|
|
249 |
{
|
|
|
250 |
thisObj->displayText = NW_Text_UCS2_New(displayStorage, valueLength, NW_Text_Flags_TakeOwnership);
|
|
|
251 |
NW_THROW_OOM_ON_NULL(thisObj->displayText, status);
|
|
|
252 |
}
|
|
|
253 |
NW_THROW_SUCCESS(status);
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
/* The text does not fit the select box. We have to truncate it */
|
|
|
257 |
status = NW_FBox_FormBoxUtils_GetDisplayLength(deviceContext,
|
|
|
258 |
(NW_Text_t*)thisObj->value,
|
|
|
259 |
font,
|
|
|
260 |
valueLength,
|
|
|
261 |
(NW_Uint16)(innerRect.dimension.width - imageSize.width),
|
|
|
262 |
&displayLength, NW_FALSE);
|
|
|
263 |
|
|
|
264 |
NW_THROW_ON_ERROR (status);
|
|
|
265 |
displayStorage = NW_Str_New(displayLength + NW_FBox_FormBoxUtils_Truncate_len);
|
|
|
266 |
NW_THROW_OOM_ON_NULL(displayStorage, status);
|
|
|
267 |
|
|
|
268 |
NW_Mem_memcpy(displayStorage, (valueStorage), displayLength*sizeof(NW_Ucs2));
|
|
|
269 |
NW_Mem_memcpy(displayStorage + displayLength, NW_FBox_FormBoxUtils_Truncate,
|
|
|
270 |
NW_FBox_FormBoxUtils_Truncate_len*sizeof(NW_Ucs2));
|
|
|
271 |
displayLength += NW_FBox_FormBoxUtils_Truncate_len;
|
|
|
272 |
|
|
|
273 |
if (thisObj->displayText == NULL)
|
|
|
274 |
{
|
|
|
275 |
thisObj->displayText = NW_Text_UCS2_New(displayStorage, displayLength, NW_Text_Flags_TakeOwnership);
|
|
|
276 |
if (thisObj->displayText == NULL)
|
|
|
277 |
{
|
|
|
278 |
NW_Mem_Free(displayStorage);
|
|
|
279 |
status = KBrsrOutOfMemory;
|
|
|
280 |
}
|
|
|
281 |
}
|
|
|
282 |
else
|
|
|
283 |
{
|
|
|
284 |
status = NW_Text_SetStorage(NW_TextOf(thisObj->displayText), displayStorage,
|
|
|
285 |
displayLength, NW_TRUE);
|
|
|
286 |
}
|
|
|
287 |
}
|
|
|
288 |
NW_CATCH (status)
|
|
|
289 |
{
|
|
|
290 |
}
|
|
|
291 |
NW_FINALLY
|
|
|
292 |
{
|
|
|
293 |
return status;
|
|
|
294 |
}
|
|
|
295 |
NW_END_TRY
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
/* ------------------------------------------------------------------------- */
|
|
|
299 |
static
|
|
|
300 |
NW_Bool
|
|
|
301 |
NW_FBox_Epoc32SelectSkin_OptionStateChanged(NW_FBox_Epoc32SelectSkin_t *skin,
|
|
|
302 |
NW_Ucs2* data,
|
|
|
303 |
NW_FBox_OptionBox_t* optionBox)
|
|
|
304 |
{
|
|
|
305 |
NW_Ucs2* textStr;
|
|
|
306 |
NW_Uint8 freeNeeded;
|
|
|
307 |
NW_Text_Length_t length;
|
|
|
308 |
NW_Text_Length_t dataLength;
|
|
|
309 |
NW_Text_t* text;
|
|
|
310 |
NW_Bool changed;
|
|
|
311 |
|
|
|
312 |
NW_REQUIRED_PARAM(skin);
|
|
|
313 |
|
|
|
314 |
dataLength = (NW_Text_Length_t)NW_Str_Strlen(data);
|
|
|
315 |
|
|
|
316 |
changed = NW_FALSE;
|
|
|
317 |
text = NW_FBox_OptionBox_GetText(optionBox);
|
|
|
318 |
textStr = (NW_Ucs2*) NW_Text_GetUCS2Buffer (text, 0, &length, &freeNeeded);
|
|
|
319 |
|
|
|
320 |
if (length == dataLength)
|
|
|
321 |
{
|
|
|
322 |
if (!NW_Mem_memcmp (data, textStr, length * sizeof (NW_Ucs2))) {
|
|
|
323 |
NW_FBox_OptionBox_ChangeState(optionBox);
|
|
|
324 |
changed = NW_TRUE;
|
|
|
325 |
}
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
if (freeNeeded){
|
|
|
329 |
NW_Mem_Free(textStr);
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
return changed;
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
/* ------------------------------------------------------------------------- */
|
|
|
336 |
static
|
|
|
337 |
NW_Bool
|
|
|
338 |
NW_FBox_Epoc32SelectSkin_OptGrpStateChanged(NW_FBox_Epoc32SelectSkin_t *skin,
|
|
|
339 |
NW_Ucs2* data,
|
|
|
340 |
NW_FBox_OptGrpBox_t* optGrpBox)
|
|
|
341 |
{
|
|
|
342 |
NW_ADT_Vector_Metric_t numItems;
|
|
|
343 |
NW_ADT_Vector_Metric_t index;
|
|
|
344 |
|
|
|
345 |
numItems = NW_ADT_Vector_GetSize(NW_ADT_VectorOf(optGrpBox->children));
|
|
|
346 |
|
|
|
347 |
for(index = 0; index < numItems; index++)
|
|
|
348 |
{
|
|
|
349 |
NW_FBox_FormBox_t* formBox;
|
|
|
350 |
|
|
|
351 |
formBox = *(NW_FBox_FormBox_t**)
|
|
|
352 |
NW_ADT_Vector_ElementAt(optGrpBox->children, index);
|
|
|
353 |
|
|
|
354 |
if (NW_Object_IsInstanceOf(formBox, &NW_FBox_OptionBox_Class))
|
|
|
355 |
{
|
|
|
356 |
if (NW_FBox_Epoc32SelectSkin_OptionStateChanged(skin, data, NW_FBox_OptionBoxOf(formBox)))
|
|
|
357 |
return NW_TRUE;
|
|
|
358 |
}
|
|
|
359 |
else if (NW_Object_IsInstanceOf(formBox, &NW_FBox_OptGrpBox_Class))
|
|
|
360 |
{
|
|
|
361 |
/* recurse here */
|
|
|
362 |
if (NW_FBox_Epoc32SelectSkin_OptGrpStateChanged(skin, data, NW_FBox_OptGrpBoxOf(formBox)))
|
|
|
363 |
return NW_TRUE;
|
|
|
364 |
}
|
|
|
365 |
else{
|
|
|
366 |
NW_ASSERT(0);
|
|
|
367 |
}
|
|
|
368 |
}
|
|
|
369 |
return NW_FALSE;
|
|
|
370 |
}
|
|
|
371 |
|
|
|
372 |
/* ------------------------------------------------------------------------- */
|
|
|
373 |
/* ------------------------------------------------------------------------- */
|
|
|
374 |
static
|
|
|
375 |
NW_Bool
|
|
|
376 |
NW_FBox_Epoc32SelectSkin_ChangeState(NW_FBox_Epoc32SelectSkin_t *skin,
|
|
|
377 |
NW_Ucs2* data)
|
|
|
378 |
{
|
|
|
379 |
NW_ADT_Vector_Metric_t numItems;
|
|
|
380 |
NW_ADT_Vector_Metric_t index;
|
|
|
381 |
NW_FBox_SelectBox_t* selectBox;
|
|
|
382 |
|
|
|
383 |
selectBox = (NW_FBox_SelectBox_t*)NW_FBox_Skin_GetFormBox(NW_FBox_SkinOf(skin));
|
|
|
384 |
numItems = NW_ADT_Vector_GetSize(NW_ADT_VectorOf(selectBox->children));
|
|
|
385 |
|
|
|
386 |
for(index = 0; index < numItems; index++)
|
|
|
387 |
{
|
|
|
388 |
NW_FBox_FormBox_t* formBox;
|
|
|
389 |
|
|
|
390 |
formBox = *(NW_FBox_FormBox_t**)
|
|
|
391 |
NW_ADT_Vector_ElementAt(selectBox->children, index);
|
|
|
392 |
|
|
|
393 |
if (NW_Object_IsInstanceOf(formBox, &NW_FBox_OptionBox_Class))
|
|
|
394 |
{
|
|
|
395 |
if (NW_FBox_Epoc32SelectSkin_OptionStateChanged(skin, data, NW_FBox_OptionBoxOf(formBox)))
|
|
|
396 |
return NW_TRUE;
|
|
|
397 |
}
|
|
|
398 |
else if (NW_Object_IsInstanceOf(formBox, &NW_FBox_OptGrpBox_Class))
|
|
|
399 |
{
|
|
|
400 |
if (NW_FBox_Epoc32SelectSkin_OptGrpStateChanged(skin, data, NW_FBox_OptGrpBoxOf(formBox)))
|
|
|
401 |
return NW_TRUE;
|
|
|
402 |
}
|
|
|
403 |
else{
|
|
|
404 |
NW_ASSERT(0);
|
|
|
405 |
}
|
|
|
406 |
}
|
|
|
407 |
return NW_FALSE;
|
|
|
408 |
}
|
|
|
409 |
|
|
|
410 |
|
|
|
411 |
/* ------------------------------------------------------------------------- */
|
|
|
412 |
static
|
|
|
413 |
TBrowserStatusCode
|
|
|
414 |
NW_FBox_Epoc32SelectSkin_GetOptionValue(NW_FBox_OptionBox_t* optionBox,
|
|
|
415 |
NW_Ucs2** val,
|
|
|
416 |
NW_Bool* updated)
|
|
|
417 |
{
|
|
|
418 |
NW_Ucs2* textStr = NULL;
|
|
|
419 |
NW_Uint8 freeNeeded = NW_FALSE;
|
|
|
420 |
NW_Text_Length_t length;
|
|
|
421 |
NW_Text_t* text;
|
|
|
422 |
NW_Bool state;
|
|
|
423 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
|
424 |
|
|
|
425 |
if (updated == NULL)
|
|
|
426 |
{
|
|
|
427 |
return KBrsrFailure;
|
|
|
428 |
}
|
|
|
429 |
|
|
|
430 |
state = NW_FBox_CheckBox_GetState(NW_FBox_CheckBoxOf(optionBox));
|
|
|
431 |
if (state == NW_FALSE)
|
|
|
432 |
{
|
|
|
433 |
*updated = NW_FALSE;
|
|
|
434 |
goto cleanup;
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
text = NW_FBox_OptionBox_GetText(optionBox);
|
|
|
438 |
textStr =
|
|
|
439 |
NW_Text_GetUCS2Buffer (text, NW_Text_Flags_Aligned, &length, &freeNeeded);
|
|
|
440 |
|
|
|
441 |
if (textStr == NULL)
|
|
|
442 |
{
|
|
|
443 |
*updated = NW_FALSE;
|
|
|
444 |
status = KBrsrOutOfMemory;
|
|
|
445 |
goto cleanup;
|
|
|
446 |
}
|
|
|
447 |
|
|
|
448 |
if (*val)
|
|
|
449 |
{
|
|
|
450 |
NW_Ucs2* str;
|
|
|
451 |
NW_Uint16 newLength;
|
|
|
452 |
|
|
|
453 |
newLength = (NW_Uint16)
|
|
|
454 |
(NW_Str_Strlen (*val) + NW_FBox_Epoc32SelectSkin_Separator_len + length);
|
|
|
455 |
str = NW_Str_New(newLength);
|
|
|
456 |
|
|
|
457 |
if (str == NULL)
|
|
|
458 |
{
|
|
|
459 |
*updated = NW_FALSE;
|
|
|
460 |
status = KBrsrOutOfMemory;
|
|
|
461 |
goto cleanup;
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
NW_Mem_memset(str, 0, newLength);
|
|
|
465 |
NW_Str_Strcpy(str, *val);
|
|
|
466 |
NW_Str_Strcat(str, _NW_FBox_Epoc32SelectSkin_Separator);
|
|
|
467 |
NW_Str_Strcat(str, textStr);
|
|
|
468 |
NW_Str_Delete(*val);
|
|
|
469 |
*val = str;
|
|
|
470 |
}
|
|
|
471 |
else{
|
|
|
472 |
*val = NW_Str_Newcpy(textStr);
|
|
|
473 |
|
|
|
474 |
if (*val == NULL)
|
|
|
475 |
{
|
|
|
476 |
*updated = NW_FALSE;
|
|
|
477 |
status = KBrsrOutOfMemory;
|
|
|
478 |
goto cleanup;
|
|
|
479 |
}
|
|
|
480 |
}
|
|
|
481 |
|
|
|
482 |
*updated = NW_TRUE;
|
|
|
483 |
|
|
|
484 |
cleanup:
|
|
|
485 |
if (freeNeeded){
|
|
|
486 |
NW_Mem_Free(textStr);
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
return status;
|
|
|
490 |
}
|
|
|
491 |
|
|
|
492 |
|
|
|
493 |
/* ------------------------------------------------------------------------- */
|
|
|
494 |
static
|
|
|
495 |
TBrowserStatusCode
|
|
|
496 |
NW_FBox_Epoc32SelectSkin_GetChildrenValue(NW_FBox_Epoc32SelectSkin_t *skin,
|
|
|
497 |
NW_FBox_FormBox_t* parentFormBox,
|
|
|
498 |
NW_ADT_Vector_Metric_t numParentItems,
|
|
|
499 |
NW_Bool multiple,
|
|
|
500 |
NW_Ucs2** newStr,
|
|
|
501 |
NW_Bool* updated)
|
|
|
502 |
{
|
|
|
503 |
NW_ADT_Vector_Metric_t index;
|
|
|
504 |
NW_FBox_OptionBox_t* optionBox;
|
|
|
505 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
|
506 |
*updated = NW_FALSE;
|
|
|
507 |
|
|
|
508 |
for(index = 0; index < numParentItems; index++)
|
|
|
509 |
{
|
|
|
510 |
NW_FBox_FormBox_t* childFormBox;
|
|
|
511 |
|
|
|
512 |
childFormBox = NULL;
|
|
|
513 |
|
|
|
514 |
/* get the next child of the parent */
|
|
|
515 |
if (NW_Object_IsInstanceOf(parentFormBox, &NW_FBox_SelectBox_Class))
|
|
|
516 |
{
|
|
|
517 |
childFormBox = *(NW_FBox_FormBox_t**)
|
|
|
518 |
NW_ADT_Vector_ElementAt(NW_FBox_SelectBoxOf(parentFormBox)->children, index);
|
|
|
519 |
}
|
|
|
520 |
else if (NW_Object_IsInstanceOf(parentFormBox, &NW_FBox_OptGrpBox_Class))
|
|
|
521 |
{
|
|
|
522 |
childFormBox = *(NW_FBox_FormBox_t**)
|
|
|
523 |
NW_ADT_Vector_ElementAt(NW_FBox_OptGrpBoxOf(parentFormBox)->children, index);
|
|
|
524 |
}
|
|
|
525 |
else
|
|
|
526 |
{
|
|
|
527 |
/* bad content - only <select> and <optgroup> are allowed as parent */
|
|
|
528 |
NW_ASSERT((NW_Object_IsInstanceOf(parentFormBox, &NW_FBox_SelectBox_Class))
|
|
|
529 |
|| (NW_Object_IsInstanceOf(parentFormBox, &NW_FBox_OptGrpBox_Class)));
|
|
|
530 |
|
|
|
531 |
}
|
|
|
532 |
|
|
|
533 |
/* handle the child */
|
|
|
534 |
if (childFormBox == NULL)
|
|
|
535 |
{
|
|
|
536 |
NW_LOG0(NW_LOG_LEVEL1, "!!! NW_FBox_Epoc32SelectSkin_GetChildrenValue: BadContent: childFormBox==NULL");
|
|
|
537 |
status = KBrsrXhtmlBadContent;
|
|
|
538 |
break;
|
|
|
539 |
}
|
|
|
540 |
else if (NW_Object_IsInstanceOf(childFormBox, &NW_FBox_OptionBox_Class))
|
|
|
541 |
{
|
|
|
542 |
optionBox = NW_FBox_OptionBoxOf(childFormBox);
|
|
|
543 |
|
|
|
544 |
status = NW_FBox_Epoc32SelectSkin_GetOptionValue(NW_FBox_OptionBoxOf(optionBox),
|
|
|
545 |
newStr,
|
|
|
546 |
updated);
|
|
|
547 |
if (status != KBrsrSuccess)
|
|
|
548 |
break;
|
|
|
549 |
|
|
|
550 |
if (*updated && !multiple)
|
|
|
551 |
break;
|
|
|
552 |
}
|
|
|
553 |
else if (NW_Object_IsInstanceOf(childFormBox, &NW_FBox_OptGrpBox_Class))
|
|
|
554 |
{
|
|
|
555 |
NW_FBox_OptGrpBox_t* optGrpBox;
|
|
|
556 |
NW_ADT_Vector_Metric_t numOptGrpItems;
|
|
|
557 |
|
|
|
558 |
optGrpBox = NW_FBox_OptGrpBoxOf(childFormBox);
|
|
|
559 |
numOptGrpItems = NW_FBox_OptGrpBox_GetNumOptions(optGrpBox);
|
|
|
560 |
|
|
|
561 |
/* recurse here */
|
|
|
562 |
status = NW_FBox_Epoc32SelectSkin_GetChildrenValue(skin,
|
|
|
563 |
childFormBox,
|
|
|
564 |
numOptGrpItems,
|
|
|
565 |
multiple,
|
|
|
566 |
newStr,
|
|
|
567 |
updated);
|
|
|
568 |
if (status != KBrsrSuccess)
|
|
|
569 |
break;
|
|
|
570 |
|
|
|
571 |
if (*updated && !multiple)
|
|
|
572 |
break;
|
|
|
573 |
}
|
|
|
574 |
else
|
|
|
575 |
{
|
|
|
576 |
/* bad content - only <optgroup> and <option> are allowed as children */
|
|
|
577 |
NW_ASSERT((NW_Object_IsInstanceOf(childFormBox, &NW_FBox_OptionBox_Class))
|
|
|
578 |
|| (NW_Object_IsInstanceOf(childFormBox, &NW_FBox_OptGrpBox_Class)));
|
|
|
579 |
|
|
|
580 |
NW_LOG0(NW_LOG_LEVEL1, "!!! NW_FBox_Epoc32SelectSkin_GetChildrenValue: BadContent: instance type error");
|
|
|
581 |
status = KBrsrXhtmlBadContent;
|
|
|
582 |
break;
|
|
|
583 |
}
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
return status;
|
|
|
587 |
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
/* ------------------------------------------------------------------------- */
|
|
|
591 |
static
|
|
|
592 |
TBrowserStatusCode
|
|
|
593 |
NW_FBox_Epoc32SelectSkin_UpdateValue(NW_FBox_Epoc32SelectSkin_t *skin)
|
|
|
594 |
{
|
|
|
595 |
NW_FBox_SelectBox_t* selectBox;
|
|
|
596 |
NW_ADT_Vector_Metric_t numItems;
|
|
|
597 |
NW_Bool multiple;
|
|
|
598 |
NW_Ucs2* newStr;
|
|
|
599 |
NW_Bool updated;
|
|
|
600 |
TBrowserStatusCode status;
|
|
|
601 |
|
|
|
602 |
selectBox = (NW_FBox_SelectBox_t*)NW_FBox_Skin_GetFormBox(NW_FBox_SkinOf(skin));
|
|
|
603 |
numItems = NW_ADT_Vector_GetSize(NW_ADT_VectorOf(selectBox->children));
|
|
|
604 |
multiple = NW_FBox_SelectBox_IsMultiple(selectBox);
|
|
|
605 |
newStr = NULL;
|
|
|
606 |
|
|
|
607 |
status = NW_FBox_Epoc32SelectSkin_GetChildrenValue(skin,
|
|
|
608 |
NW_FBox_FormBoxOf(selectBox),
|
|
|
609 |
numItems,
|
|
|
610 |
multiple,
|
|
|
611 |
&newStr,
|
|
|
612 |
&updated);
|
|
|
613 |
|
|
|
614 |
if (status != KBrsrSuccess) {
|
|
|
615 |
goto cleanup;
|
|
|
616 |
}
|
|
|
617 |
|
|
|
618 |
if (newStr == NULL){
|
|
|
619 |
return NW_Text_SetStorage (skin->value, NULL, 0, 0);
|
|
|
620 |
}
|
|
|
621 |
else{
|
|
|
622 |
status = NW_Text_SetStorage(NW_TextOf(skin->value),
|
|
|
623 |
newStr,
|
|
|
624 |
0,
|
|
|
625 |
NW_Text_Flags_TakeOwnership);
|
|
|
626 |
}
|
|
|
627 |
|
|
|
628 |
cleanup:
|
|
|
629 |
return status;
|
|
|
630 |
|
|
|
631 |
}
|
|
|
632 |
|
|
|
633 |
/* ------------------------------------------------------------------------- */
|
|
|
634 |
static
|
|
|
635 |
TBrowserStatusCode
|
|
|
636 |
NW_FBox_Epoc32SelectSkin_ClearOptionsList( NW_FBox_Epoc32SelectSkin_t* thisObj )
|
|
|
637 |
{
|
|
|
638 |
NW_ASSERT (thisObj != NULL);
|
|
|
639 |
|
|
|
640 |
if (thisObj->optionsList != NULL)
|
|
|
641 |
{
|
|
|
642 |
NW_Int32 index;
|
|
|
643 |
NW_Dlg_SelectItemData_t* entry;
|
|
|
644 |
NW_Uint32 optionsListSize;
|
|
|
645 |
|
|
|
646 |
optionsListSize = NW_ADT_Vector_GetSize (NW_ADT_VectorOf (thisObj->optionsList)) ;
|
|
|
647 |
index = 0;
|
|
|
648 |
for (index = optionsListSize - 1; index >= 0; index--)
|
|
|
649 |
{
|
|
|
650 |
entry = (NW_Dlg_SelectItemData_t*)
|
|
|
651 |
NW_ADT_Vector_ElementAt (NW_ADT_VectorOf (thisObj->optionsList),
|
|
|
652 |
(NW_ADT_Vector_Metric_t) index) ;
|
|
|
653 |
NW_Mem_Free (entry->text);
|
|
|
654 |
NW_ADT_DynamicVector_RemoveAt(thisObj->optionsList,
|
|
|
655 |
(NW_ADT_Vector_Metric_t)index);
|
|
|
656 |
}
|
|
|
657 |
}
|
|
|
658 |
|
|
|
659 |
return KBrsrSuccess;
|
|
|
660 |
}
|
|
|
661 |
|
|
|
662 |
/* ------------------------------------------------------------------------- */
|
|
|
663 |
static
|
|
|
664 |
TBrowserStatusCode
|
|
|
665 |
NW_FBox_Epoc32SelectSkin_SelectPromptResp (NW_Dlg_SelectData_t *data,
|
|
|
666 |
void* callbackCtx,
|
|
|
667 |
NW_Bool selectionChanged)
|
|
|
668 |
{
|
|
|
669 |
NW_FBox_Epoc32SelectSkin_t* skin;
|
|
|
670 |
NW_FBox_SelectBox_t* selectBox;
|
|
|
671 |
NW_FBox_FormLiaison_t* formLiason;
|
|
|
672 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
|
673 |
TUint32 ii;
|
|
|
674 |
TUint32 count;
|
|
|
675 |
NW_Dlg_SelectItemData_t* selectItemData;
|
|
|
676 |
TBool updateDisplay = NW_TRUE;
|
|
|
677 |
|
|
|
678 |
skin = (NW_FBox_Epoc32SelectSkin_t*)callbackCtx;
|
|
|
679 |
selectBox = (NW_FBox_SelectBox_t*)NW_FBox_Skin_GetFormBox(NW_FBox_SkinOf(skin));
|
|
|
680 |
formLiason = NW_FBox_FormBox_GetFormLiaison(selectBox);
|
|
|
681 |
|
|
|
682 |
|
|
|
683 |
count = NW_ADT_Vector_GetSize(data->options);
|
|
|
684 |
|
|
|
685 |
/* first set all options without onpick property */
|
|
|
686 |
for ( ii = 0; ii < count; ++ii )
|
|
|
687 |
{
|
|
|
688 |
selectItemData = (NW_Dlg_SelectItemData_t*)NW_ADT_Vector_ElementAt( data->options, (NW_ADT_Vector_Metric_t)ii );
|
|
|
689 |
|
|
|
690 |
if ( !selectItemData->isOptGroup && !selectItemData->hasOnPick )
|
|
|
691 |
{
|
|
|
692 |
NW_FBox_OptionBox_t* optionBox = (NW_FBox_OptionBox_t*)selectItemData->context;
|
|
|
693 |
|
|
|
694 |
if ( selectItemData->isSelected != (NW_FBox_CheckBox_GetState(NW_FBox_CheckBoxOf(optionBox)) ))
|
|
|
695 |
{
|
|
|
696 |
NW_FBox_OptionBox_ChangeState( optionBox );
|
|
|
697 |
updateDisplay = NW_TRUE;
|
|
|
698 |
}
|
|
|
699 |
}
|
|
|
700 |
}
|
|
|
701 |
|
|
|
702 |
/* now set options with onpick property */
|
|
|
703 |
for ( ii = 0; ii < count; ++ii )
|
|
|
704 |
{
|
|
|
705 |
selectItemData = (NW_Dlg_SelectItemData_t*)NW_ADT_Vector_ElementAt( data->options, (NW_ADT_Vector_Metric_t)ii );
|
|
|
706 |
|
|
|
707 |
if ( !selectItemData->isOptGroup && selectItemData->hasOnPick )
|
|
|
708 |
{
|
|
|
709 |
NW_FBox_OptionBox_t* optionBox = (NW_FBox_OptionBox_t*)selectItemData->context;
|
|
|
710 |
|
|
|
711 |
if ( !data->isCanceled
|
|
|
712 |
&& (( !selectBox->multiple && selectItemData->isSelected)
|
|
|
713 |
|| (selectBox->multiple && selectItemData->isSelected != NW_FBox_CheckBox_GetState(NW_FBox_CheckBoxOf(optionBox))) ) )
|
|
|
714 |
{
|
|
|
715 |
updateDisplay = NW_TRUE;
|
|
|
716 |
if (selectItemData->isLocalNavOnpick)
|
|
|
717 |
{
|
|
|
718 |
updateDisplay = NW_FALSE;
|
|
|
719 |
}
|
|
|
720 |
// CAUTION: this eventually calls NW_UI_CreateCard which may remove 'skin' if onpick to intradeck card exists in content
|
|
|
721 |
NW_FBox_OptionBox_ChangeState( optionBox );
|
|
|
722 |
break;
|
|
|
723 |
}
|
|
|
724 |
}
|
|
|
725 |
}
|
|
|
726 |
|
|
|
727 |
/* if OnPick has been activated there's no skin anymore */
|
|
|
728 |
if (updateDisplay == NW_TRUE)
|
|
|
729 |
{
|
|
|
730 |
NW_FBox_Epoc32SelectSkin_ClearOptionsList(skin);
|
|
|
731 |
status = NW_FBox_Epoc32SelectSkin_UpdateValue(skin);
|
|
|
732 |
if (status == KBrsrSuccess)
|
|
|
733 |
{
|
|
|
734 |
status = NW_FBox_Epoc32SelectSkin_SetDisplayText(skin);
|
|
|
735 |
}
|
|
|
736 |
if (status == KBrsrSuccess)
|
|
|
737 |
{
|
|
|
738 |
status = NW_LMgr_Box_Refresh(NW_LMgr_BoxOf(selectBox));
|
|
|
739 |
}
|
|
|
740 |
// if the selection changed then notify ecma of the change event
|
|
|
741 |
if(selectionChanged)
|
|
|
742 |
{
|
|
|
743 |
(void) NW_FBox_FormLiaison_DelegateEcmaEvent (formLiason,
|
|
|
744 |
NW_FBox_FormBox_GetFormCntrlID(selectBox),
|
|
|
745 |
NW_Ecma_Evt_OnChange);
|
|
|
746 |
}
|
|
|
747 |
}
|
|
|
748 |
|
|
|
749 |
return status;
|
|
|
750 |
}
|
|
|
751 |
|
|
|
752 |
/* ------------------------------------------------------------------------- */
|
|
|
753 |
static
|
|
|
754 |
TBrowserStatusCode
|
|
|
755 |
NW_FBox_Epoc32SelectSkin_DrawText(NW_FBox_Epoc32SelectSkin_t* thisObj,
|
|
|
756 |
CGDIDeviceContext* deviceContext,
|
|
|
757 |
NW_Bool hasFocus,
|
|
|
758 |
NW_GDI_FlowDirection_t* dir)
|
|
|
759 |
{
|
|
|
760 |
NW_GDI_Point2D_t start;
|
|
|
761 |
NW_FBox_SelectBox_t* selectBox;
|
|
|
762 |
CGDIFont* font;
|
|
|
763 |
NW_GDI_Rectangle_t innerRect;
|
|
|
764 |
NW_LMgr_PropertyValue_t textDir;
|
|
|
765 |
NW_GDI_Color_t fgColor;
|
|
|
766 |
NW_LMgr_Property_t color;
|
|
|
767 |
NW_GDI_Dimension2D_t extent;
|
|
|
768 |
|
|
|
769 |
NW_REQUIRED_PARAM(hasFocus);
|
|
|
770 |
selectBox = NW_FBox_SelectSkin_GetSelectBox(thisObj);
|
|
|
771 |
NW_ASSERT(selectBox);
|
|
|
772 |
|
|
|
773 |
NW_TRY(status)
|
|
|
774 |
{
|
|
|
775 |
/* Get the box font */
|
|
|
776 |
font = NW_LMgr_Box_GetFont (NW_LMgr_BoxOf(selectBox));
|
|
|
777 |
NW_ASSERT(font != NULL);
|
|
|
778 |
|
|
|
779 |
/* Get the old foreground color */
|
|
|
780 |
fgColor = deviceContext->ForegroundColor ();
|
|
|
781 |
|
|
|
782 |
// Get and set the box fg color, not inherited from parent (same as IE not following CSS spec)
|
|
|
783 |
status = NW_LMgr_Box_GetRawProperty(NW_LMgr_BoxOf(selectBox), NW_CSS_Prop_color, &color);
|
|
|
784 |
if (status == KBrsrSuccess)
|
|
|
785 |
{
|
|
|
786 |
deviceContext->SetForegroundColor ( (NW_GDI_Color_t)color.value.integer);
|
|
|
787 |
}
|
|
|
788 |
else
|
|
|
789 |
{
|
|
|
790 |
deviceContext->SetForegroundColor ( (NW_GDI_Color_t)0);
|
|
|
791 |
}
|
|
|
792 |
|
|
|
793 |
/* Get the start coordinates */
|
|
|
794 |
NW_LMgr_Box_GetInnerRectangle(NW_LMgr_BoxOf(selectBox), &innerRect);
|
|
|
795 |
start = innerRect.point;
|
|
|
796 |
|
|
|
797 |
if (thisObj->displayText == NULL)
|
|
|
798 |
{
|
|
|
799 |
status = NW_FBox_SelectSkin_RefreshText(NW_FBox_SelectSkinOf(thisObj));
|
|
|
800 |
NW_THROW_ON_ERROR(status);
|
|
|
801 |
}
|
|
|
802 |
|
|
|
803 |
/* Get the text direction attribute */
|
|
|
804 |
textDir.token = NW_CSS_PropValue_ltr;
|
|
|
805 |
NW_LMgr_Box_GetPropertyValue(NW_LMgr_BoxOf(selectBox), NW_CSS_Prop_textDirection, NW_CSS_ValueType_Token, &textDir);
|
|
|
806 |
|
|
|
807 |
if (thisObj->displayText != NULL)
|
|
|
808 |
{
|
|
|
809 |
/* If RTL, change drawing coordinates */
|
|
|
810 |
*dir = (textDir.token == NW_CSS_PropValue_ltr) ? NW_GDI_FlowDirection_LeftRight : NW_GDI_FlowDirection_RightLeft;
|
|
|
811 |
|
|
|
812 |
status = deviceContext->GetTextExtent( NW_Text_AbstractOf(thisObj->displayText),
|
|
|
813 |
font,
|
|
|
814 |
0,
|
|
|
815 |
*dir,
|
|
|
816 |
&extent);
|
|
|
817 |
NW_THROW_ON_ERROR(status);
|
|
|
818 |
if (*dir == NW_GDI_FlowDirection_RightLeft)
|
|
|
819 |
{
|
|
|
820 |
start.x = innerRect.point.x + innerRect.dimension.width - extent.width;
|
|
|
821 |
}
|
|
|
822 |
status = deviceContext->DrawText( &start,
|
|
|
823 |
NW_TextOf(thisObj->displayText),
|
|
|
824 |
font,
|
|
|
825 |
0,
|
|
|
826 |
NW_GDI_TextDecoration_None,
|
|
|
827 |
*dir,
|
|
|
828 |
extent.width);
|
|
|
829 |
}
|
|
|
830 |
}
|
|
|
831 |
NW_CATCH(status)
|
|
|
832 |
{
|
|
|
833 |
}
|
|
|
834 |
NW_FINALLY
|
|
|
835 |
{
|
|
|
836 |
deviceContext->SetForegroundColor ( fgColor);
|
|
|
837 |
return KBrsrSuccess;
|
|
|
838 |
}
|
|
|
839 |
NW_END_TRY
|
|
|
840 |
}
|
|
|
841 |
|
|
|
842 |
/* ------------------------------------------------------------------------- */
|
|
|
843 |
static
|
|
|
844 |
TBrowserStatusCode
|
|
|
845 |
NW_FBox_Epoc32SelectSkin_FillOptionsList( NW_FBox_Epoc32SelectSkin_t* thisObj,
|
|
|
846 |
NW_FBox_FormBox_t* formBox,
|
|
|
847 |
NW_Uint32 level)
|
|
|
848 |
{
|
|
|
849 |
_LIT(KPrefix, " ");// 4 spaces to match look of browser engine select dialog
|
|
|
850 |
NW_Dlg_SelectItemData_t entry;
|
|
|
851 |
TBrowserStatusCode status;
|
|
|
852 |
NW_Uint32 ii;
|
|
|
853 |
NW_Uint32 count;
|
|
|
854 |
NW_Text_t* text;
|
|
|
855 |
|
|
|
856 |
NW_ASSERT(thisObj!=NULL);
|
|
|
857 |
NW_ASSERT(formBox!=NULL);
|
|
|
858 |
|
|
|
859 |
status = KBrsrSuccess;
|
|
|
860 |
|
|
|
861 |
if (NW_Object_IsInstanceOf(formBox, &NW_FBox_OptionBox_Class))
|
|
|
862 |
{
|
|
|
863 |
/* just option - add to the list */
|
|
|
864 |
NW_FBox_OptionBox_t* optionBox;
|
|
|
865 |
|
|
|
866 |
optionBox = NW_FBox_OptionBoxOf(formBox);
|
|
|
867 |
|
|
|
868 |
text = NW_FBox_OptionBox_GetText(optionBox);
|
|
|
869 |
|
|
|
870 |
entry.hasOnPick = NW_FBox_OptionBox_HasOnPick(optionBox);
|
|
|
871 |
entry.isLocalNavOnpick = NW_FBox_OptionBox_IsLocalNavOnPick(optionBox);
|
|
|
872 |
entry.isOptGroup = NW_FALSE;
|
|
|
873 |
entry.isSelected = NW_FBox_CheckBox_GetState(NW_FBox_CheckBoxOf(optionBox));
|
|
|
874 |
|
|
|
875 |
// child of option group elements must be indented (level 0 = <select>)
|
|
|
876 |
if (level > 1)
|
|
|
877 |
{
|
|
|
878 |
HBufC* newText(NULL);
|
|
|
879 |
TRAPD(err, newText = HBufC::NewL(text->characterCount + KPrefix().Length() + 1));// add 1 for zero terminate
|
|
|
880 |
if (err == KErrNone)
|
|
|
881 |
{
|
|
|
882 |
newText->Des().Copy(KPrefix);
|
|
|
883 |
newText->Des().Append((NW_Ucs2*)text->storage, text->characterCount);
|
|
|
884 |
NW_Text_t* nt = NW_Text_New (HTTP_iso_10646_ucs_2, (void*)(newText->Des().PtrZ()),
|
|
|
885 |
newText->Length(), NW_TRUE);
|
|
|
886 |
|
|
|
887 |
entry.text = NW_FBox_Epoc32SelectSkin_GetNewUcs2Str(thisObj, nt);
|
|
|
888 |
NW_Mem_Free(nt);
|
|
|
889 |
}
|
|
|
890 |
else
|
|
|
891 |
{
|
|
|
892 |
entry.text = NW_FBox_Epoc32SelectSkin_GetNewUcs2Str(thisObj, text);
|
|
|
893 |
}
|
|
|
894 |
}
|
|
|
895 |
else
|
|
|
896 |
{
|
|
|
897 |
entry.text = NW_FBox_Epoc32SelectSkin_GetNewUcs2Str(thisObj, text);
|
|
|
898 |
}
|
|
|
899 |
|
|
|
900 |
entry.context = optionBox;
|
|
|
901 |
|
|
|
902 |
NW_ADT_DynamicVector_InsertAt (thisObj->optionsList, &entry, NW_ADT_Vector_AtEnd);
|
|
|
903 |
}
|
|
|
904 |
else if (NW_Object_IsInstanceOf(formBox, &NW_FBox_OptGrpBox_Class))
|
|
|
905 |
{
|
|
|
906 |
/* optgroup - add to the list if not nested and process children */
|
|
|
907 |
NW_FBox_OptGrpBox_t* optGrpBox;
|
|
|
908 |
|
|
|
909 |
optGrpBox = NW_FBox_OptGrpBoxOf(formBox);
|
|
|
910 |
|
|
|
911 |
text = NW_FBox_OptGrpBox_GetText(optGrpBox);
|
|
|
912 |
|
|
|
913 |
if (text)
|
|
|
914 |
{
|
|
|
915 |
/* add optgroup only if it has a title */
|
|
|
916 |
entry.text = NW_FBox_Epoc32SelectSkin_GetNewUcs2Str(thisObj, text);
|
|
|
917 |
entry.isLocalNavOnpick = NW_FALSE;
|
|
|
918 |
entry.hasOnPick = NW_FALSE;
|
|
|
919 |
entry.isOptGroup = NW_TRUE;
|
|
|
920 |
entry.isSelected = NW_FALSE;
|
|
|
921 |
entry.context = optGrpBox;
|
|
|
922 |
|
|
|
923 |
NW_ADT_DynamicVector_InsertAt (thisObj->optionsList, &entry, NW_ADT_Vector_AtEnd);
|
|
|
924 |
}
|
|
|
925 |
|
|
|
926 |
|
|
|
927 |
/* process children recursively */
|
|
|
928 |
if (optGrpBox->children)
|
|
|
929 |
count = NW_ADT_Vector_GetSize(optGrpBox->children);
|
|
|
930 |
else count = 0;
|
|
|
931 |
for ( ii = 0; ii < count; ii++ )
|
|
|
932 |
{
|
|
|
933 |
NW_FBox_FormBox_t* child =
|
|
|
934 |
*(NW_FBox_FormBox_t**)NW_ADT_Vector_ElementAt(optGrpBox->children,
|
|
|
935 |
(NW_ADT_Vector_Metric_t)ii);
|
|
|
936 |
status = NW_FBox_Epoc32SelectSkin_FillOptionsList(thisObj,
|
|
|
937 |
child, level + 1);
|
|
|
938 |
}
|
|
|
939 |
|
|
|
940 |
}
|
|
|
941 |
else if (NW_Object_IsInstanceOf(formBox, &NW_FBox_SelectBox_Class))
|
|
|
942 |
{
|
|
|
943 |
/* select - just process children recursively */
|
|
|
944 |
NW_FBox_SelectBox_t* selectBox;
|
|
|
945 |
|
|
|
946 |
selectBox = NW_FBox_SelectBoxOf(formBox);
|
|
|
947 |
count = NW_ADT_Vector_GetSize(selectBox->children);
|
|
|
948 |
for ( ii = 0; ii < count; ii++ )
|
|
|
949 |
{
|
|
|
950 |
NW_FBox_FormBox_t* child =
|
|
|
951 |
*(NW_FBox_FormBox_t**)NW_ADT_Vector_ElementAt(selectBox->children,
|
|
|
952 |
(NW_ADT_Vector_Metric_t)ii);
|
|
|
953 |
status = NW_FBox_Epoc32SelectSkin_FillOptionsList(thisObj,
|
|
|
954 |
child, level + 1);
|
|
|
955 |
}
|
|
|
956 |
}
|
|
|
957 |
else
|
|
|
958 |
{
|
|
|
959 |
/* unexpected box type */
|
|
|
960 |
NW_ASSERT((NW_Object_IsInstanceOf(formBox, &NW_FBox_OptionBox_Class))
|
|
|
961 |
|| (NW_Object_IsInstanceOf(formBox, &NW_FBox_OptGrpBox_Class)));
|
|
|
962 |
|
|
|
963 |
status = KBrsrFailure;
|
|
|
964 |
}
|
|
|
965 |
|
|
|
966 |
return status;
|
|
|
967 |
}
|
|
|
968 |
|
|
|
969 |
/* ------------------------------------------------------------------------- *
|
|
|
970 |
class definition
|
|
|
971 |
* ------------------------------------------------------------------------- */
|
|
|
972 |
|
|
|
973 |
/* ------------------------------------------------------------------------- */
|
|
|
974 |
const
|
|
|
975 |
NW_FBox_Epoc32SelectSkin_Class_t NW_FBox_Epoc32SelectSkin_Class = {
|
|
|
976 |
{ /* NW_Object_Core */
|
|
|
977 |
/* super */ &NW_FBox_SelectSkin_Class,
|
|
|
978 |
/* queryInterface */ _NW_Object_Base_QueryInterface
|
|
|
979 |
},
|
|
|
980 |
{ /* NW_Object_Base */
|
|
|
981 |
/* interfaceList */ NULL
|
|
|
982 |
},
|
|
|
983 |
{ /* NW_Object_Dynamic */
|
|
|
984 |
/* instanceSize */ sizeof (NW_FBox_Epoc32SelectSkin_t),
|
|
|
985 |
/* construct */ _NW_FBox_Epoc32SelectSkin_Construct,
|
|
|
986 |
/* destruct */ _NW_FBox_Epoc32SelectSkin_Destruct
|
|
|
987 |
},
|
|
|
988 |
{ /* NW_FBox_Skin */
|
|
|
989 |
/* NW_FBox_Skin_Draw_t */ _NW_FBox_Epoc32SelectSkin_Draw,
|
|
|
990 |
/* NW_FBox_Skin_GetSize_t */ _NW_FBox_Epoc32SelectSkin_GetSize
|
|
|
991 |
},
|
|
|
992 |
{ /* NW_FBox_SelectSkin */
|
|
|
993 |
/* setActive */ _NW_FBox_Epoc32SelectSkin_SetActive,
|
|
|
994 |
/* addOption */ _NW_FBox_Epoc32SelectSkin_AddOption,
|
|
|
995 |
/* addOptGrp */ _NW_FBox_Epoc32SelectSkin_AddOptGrp,
|
|
|
996 |
/* detailsDialog */ _NW_FBox_Epoc32SelectSkin_DetailsDialog,
|
|
|
997 |
/* refeshText */ _NW_FBox_Epoc32SelectSkin_RefreshText,
|
|
|
998 |
/* split */ _NW_FBox_Epoc32SelectSkin_Split
|
|
|
999 |
},
|
|
|
1000 |
{ /* NW_FBox_Epoc32SelectSkin */
|
|
|
1001 |
/* getBaseline */ _NW_FBox_Epoc32SelectSkin_GetBaseline
|
|
|
1002 |
}
|
|
|
1003 |
};
|
|
|
1004 |
|
|
|
1005 |
/* ------------------------------------------------------------------------- *
|
|
|
1006 |
virtual methods
|
|
|
1007 |
* ------------------------------------------------------------------------- */
|
|
|
1008 |
|
|
|
1009 |
/* ------------------------------------------------------------------------- */
|
|
|
1010 |
TBrowserStatusCode
|
|
|
1011 |
_NW_FBox_Epoc32SelectSkin_Construct (NW_Object_Dynamic_t* dynamicObject,
|
|
|
1012 |
va_list* argp)
|
|
|
1013 |
{
|
|
|
1014 |
NW_FBox_Epoc32SelectSkin_t* thisObj;
|
|
|
1015 |
TBrowserStatusCode status;
|
|
|
1016 |
|
|
|
1017 |
/* for convenience */
|
|
|
1018 |
thisObj = NW_FBox_Epoc32SelectSkinOf (dynamicObject);
|
|
|
1019 |
|
|
|
1020 |
/* invoke our superclass constructor */
|
|
|
1021 |
status = _NW_FBox_SelectSkin_Construct (dynamicObject, argp);
|
|
|
1022 |
if (status != KBrsrSuccess) {
|
|
|
1023 |
return status;
|
|
|
1024 |
}
|
|
|
1025 |
|
|
|
1026 |
/* Set initial value to empty string. */
|
|
|
1027 |
thisObj->value = NW_Text_UCS2_New (NULL, 0, 0);
|
|
|
1028 |
|
|
|
1029 |
thisObj->displayText = NULL;
|
|
|
1030 |
|
|
|
1031 |
thisObj->optionsList = (NW_ADT_DynamicVector_t*)
|
|
|
1032 |
NW_ADT_ResizableVector_New(sizeof(NW_Dlg_SelectItemData_t), 3, 3);
|
|
|
1033 |
|
|
|
1034 |
/* successful completion */
|
|
|
1035 |
return KBrsrSuccess;
|
|
|
1036 |
}
|
|
|
1037 |
|
|
|
1038 |
/* ------------------------------------------------------------------------- */
|
|
|
1039 |
void
|
|
|
1040 |
_NW_FBox_Epoc32SelectSkin_Destruct(NW_Object_Dynamic_t* dynamicObject)
|
|
|
1041 |
{
|
|
|
1042 |
NW_FBox_Epoc32SelectSkin_t* thisObj;
|
|
|
1043 |
|
|
|
1044 |
/* for convenience */
|
|
|
1045 |
thisObj = NW_FBox_Epoc32SelectSkinOf (dynamicObject);
|
|
|
1046 |
|
|
|
1047 |
if (thisObj->displayText){
|
|
|
1048 |
NW_Object_Delete(thisObj->displayText);
|
|
|
1049 |
}
|
|
|
1050 |
if (thisObj->value){
|
|
|
1051 |
NW_Object_Delete(thisObj->value);
|
|
|
1052 |
}
|
|
|
1053 |
if (thisObj->optionsList){
|
|
|
1054 |
NW_FBox_Epoc32SelectSkin_ClearOptionsList(thisObj);
|
|
|
1055 |
NW_Object_Delete(thisObj->optionsList);
|
|
|
1056 |
}
|
|
|
1057 |
}
|
|
|
1058 |
|
|
|
1059 |
// -------------------------------------------------------------------------
|
|
|
1060 |
TBrowserStatusCode
|
|
|
1061 |
_NW_FBox_Epoc32SelectSkin_Draw(NW_FBox_Skin_t* skin,
|
|
|
1062 |
NW_LMgr_Box_t* box,
|
|
|
1063 |
CGDIDeviceContext* deviceContext,
|
|
|
1064 |
NW_Uint8 hasFocus)
|
|
|
1065 |
{
|
|
|
1066 |
NW_FBox_SelectBox_t* selectBox;
|
|
|
1067 |
NW_FBox_Epoc32SelectSkin_t* thisObj;
|
|
|
1068 |
NW_GDI_Rectangle_t innerRectangle;
|
|
|
1069 |
NW_GDI_Point2D_t imagePoint;
|
|
|
1070 |
NW_GDI_Dimension3D_t imageSize;
|
|
|
1071 |
NW_LMgr_RootBox_t* rootBox;
|
|
|
1072 |
NW_Image_AbstractImage_t* image;
|
|
|
1073 |
NW_GDI_FlowDirection_t dir;
|
|
|
1074 |
|
|
|
1075 |
// for convenience
|
|
|
1076 |
selectBox = NW_FBox_SelectBoxOf (box);
|
|
|
1077 |
thisObj = NW_FBox_Epoc32SelectSkinOf(skin);
|
|
|
1078 |
|
|
|
1079 |
NW_TRY(status)
|
|
|
1080 |
{
|
|
|
1081 |
// standard paint mode
|
|
|
1082 |
deviceContext->SetPaintMode ( NW_GDI_PaintMode_Copy);
|
|
|
1083 |
|
|
|
1084 |
// let the base class draw draw the box
|
|
|
1085 |
status =_NW_LMgr_Box_Draw(box, deviceContext, hasFocus);
|
|
|
1086 |
NW_THROW_ON_ERROR (status);
|
|
|
1087 |
|
|
|
1088 |
// get the root box
|
|
|
1089 |
rootBox = NW_LMgr_Box_GetRootBox(NW_LMgr_BoxOf(selectBox));
|
|
|
1090 |
NW_THROW_ON_NULL (rootBox, status, KBrsrFailure);
|
|
|
1091 |
|
|
|
1092 |
// get the image from the canned images dictionary
|
|
|
1093 |
image = CONST_CAST (NW_Image_AbstractImage_t*, NW_Image_CannedImages_GetImage(rootBox->cannedImages, NW_Image_SelectArrow));
|
|
|
1094 |
NW_THROW_ON_NULL (image, status, KBrsrFailure);
|
|
|
1095 |
|
|
|
1096 |
// get the image size
|
|
|
1097 |
status = NW_Image_AbstractImage_GetSize(image, &imageSize);
|
|
|
1098 |
NW_THROW_ON_ERROR (status);
|
|
|
1099 |
|
|
|
1100 |
// draw text first
|
|
|
1101 |
status = NW_FBox_Epoc32SelectSkin_DrawText(thisObj, deviceContext, hasFocus, &dir);
|
|
|
1102 |
NW_THROW_ON_ERROR (status);
|
|
|
1103 |
|
|
|
1104 |
// get the inner rectangle
|
|
|
1105 |
status = NW_LMgr_Box_GetInnerRectangle(box, &innerRectangle);
|
|
|
1106 |
NW_THROW_ON_ERROR (status);
|
|
|
1107 |
|
|
|
1108 |
// position the select image on the correct side of the box depending on direction (RTL)
|
|
|
1109 |
if(dir == NW_GDI_FlowDirection_RightLeft)
|
|
|
1110 |
{
|
|
|
1111 |
imagePoint.x = innerRectangle.point.x;
|
|
|
1112 |
}
|
|
|
1113 |
else
|
|
|
1114 |
{
|
|
|
1115 |
imagePoint.x =
|
|
|
1116 |
(NW_GDI_Metric_t)(innerRectangle.point.x + innerRectangle.dimension.width - imageSize.width);
|
|
|
1117 |
}
|
|
|
1118 |
|
|
|
1119 |
// position the image so that it is centered in the box
|
|
|
1120 |
if (innerRectangle.dimension.height > imageSize.height)
|
|
|
1121 |
{
|
|
|
1122 |
imagePoint.y =
|
|
|
1123 |
(NW_GDI_Metric_t)(innerRectangle.point.y + ((innerRectangle.dimension.height - imageSize.height) / 2));
|
|
|
1124 |
}
|
|
|
1125 |
else
|
|
|
1126 |
{
|
|
|
1127 |
imagePoint.y = (NW_GDI_Metric_t)(innerRectangle.point.y);
|
|
|
1128 |
}
|
|
|
1129 |
|
|
|
1130 |
status = NW_Image_AbstractImage_Draw (image, deviceContext, &imagePoint);
|
|
|
1131 |
NW_THROW_ON_ERROR(status);
|
|
|
1132 |
}
|
|
|
1133 |
NW_CATCH (status)
|
|
|
1134 |
{
|
|
|
1135 |
}
|
|
|
1136 |
NW_FINALLY
|
|
|
1137 |
{
|
|
|
1138 |
return status;
|
|
|
1139 |
}
|
|
|
1140 |
NW_END_TRY
|
|
|
1141 |
}
|
|
|
1142 |
|
|
|
1143 |
// -------------------------------------------------------------------------
|
|
|
1144 |
NW_GDI_Metric_t
|
|
|
1145 |
_NW_FBox_Epoc32SelectSkin_GetBaseline(NW_FBox_Epoc32SelectSkin_t* aThisObj,
|
|
|
1146 |
NW_LMgr_Box_t* aLmgrBox)
|
|
|
1147 |
{
|
|
|
1148 |
CGDIFont* font;
|
|
|
1149 |
TBrowserStatusCode status;
|
|
|
1150 |
NW_GDI_Metric_t baseline;
|
|
|
1151 |
|
|
|
1152 |
NW_REQUIRED_PARAM(aThisObj);
|
|
|
1153 |
|
|
|
1154 |
// parameter assertion block
|
|
|
1155 |
NW_ASSERT (aLmgrBox != NULL);
|
|
|
1156 |
NW_ASSERT (NW_Object_IsInstanceOf (aLmgrBox, &NW_FBox_FormBox_Class));
|
|
|
1157 |
|
|
|
1158 |
// set the font to match the parent
|
|
|
1159 |
font = NW_LMgr_Box_GetFont (aLmgrBox);
|
|
|
1160 |
if (font)
|
|
|
1161 |
{
|
|
|
1162 |
TGDIFontInfo fontInfo;
|
|
|
1163 |
NW_LMgr_FrameInfo_t padding;
|
|
|
1164 |
NW_LMgr_FrameInfo_t borderWidth;
|
|
|
1165 |
NW_GDI_Dimension3D_t imageSize;
|
|
|
1166 |
|
|
|
1167 |
status = font->GetFontInfo ( &fontInfo);
|
|
|
1168 |
NW_ASSERT (status == KBrsrSuccess);
|
|
|
1169 |
|
|
|
1170 |
// Get padding and border width
|
|
|
1171 |
NW_LMgr_Box_GetPadding(aLmgrBox, &padding, ELMgrFrameTop );
|
|
|
1172 |
NW_LMgr_Box_GetBorderWidth(aLmgrBox, &borderWidth, ELMgrFrameTop );
|
|
|
1173 |
|
|
|
1174 |
status = NW_FBox_Epoc32SelectSkin_GetArrowSize(NW_FBox_SelectBoxOf(aLmgrBox), &imageSize);
|
|
|
1175 |
|
|
|
1176 |
if (status == KBrsrSuccess)
|
|
|
1177 |
{
|
|
|
1178 |
// Use the bigger of font baseline or image height and then adjust for border and padding
|
|
|
1179 |
baseline = (NW_GDI_Metric_t)
|
|
|
1180 |
((fontInfo.baseline < imageSize.height) ? imageSize.height : fontInfo.baseline) + borderWidth.top + padding.top;
|
|
|
1181 |
}
|
|
|
1182 |
else
|
|
|
1183 |
{
|
|
|
1184 |
baseline = fontInfo.baseline + borderWidth.top + padding.top;
|
|
|
1185 |
}
|
|
|
1186 |
}
|
|
|
1187 |
else
|
|
|
1188 |
{
|
|
|
1189 |
baseline = NW_LMgr_Box_GetFormatBounds(aLmgrBox).dimension.height;
|
|
|
1190 |
}
|
|
|
1191 |
|
|
|
1192 |
return baseline;
|
|
|
1193 |
}
|
|
|
1194 |
|
|
|
1195 |
// -------------------------------------------------------------------------
|
|
|
1196 |
TBrowserStatusCode
|
|
|
1197 |
_NW_FBox_Epoc32SelectSkin_GetSize(NW_FBox_Skin_t* skin,
|
|
|
1198 |
NW_LMgr_Box_t* box,
|
|
|
1199 |
NW_GDI_Dimension3D_t* size)
|
|
|
1200 |
{
|
|
|
1201 |
NW_FBox_Epoc32SelectSkin_t* thisObj;
|
|
|
1202 |
NW_GDI_Dimension2D_t extent;
|
|
|
1203 |
CGDIDeviceContext* deviceContext;
|
|
|
1204 |
const NW_GDI_Rectangle_t* rectangle;
|
|
|
1205 |
NW_GDI_Dimension3D_t imageSize;
|
|
|
1206 |
NW_LMgr_FrameInfo_t padding;
|
|
|
1207 |
NW_LMgr_FrameInfo_t borderWidth;
|
|
|
1208 |
|
|
|
1209 |
NW_TRY(status)
|
|
|
1210 |
{
|
|
|
1211 |
// parameter assertion block
|
|
|
1212 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_FBox_SelectBox_Class));
|
|
|
1213 |
|
|
|
1214 |
// for convenience
|
|
|
1215 |
thisObj = NW_FBox_Epoc32SelectSkinOf(skin);
|
|
|
1216 |
|
|
|
1217 |
size->width = 0;
|
|
|
1218 |
size->height = 0;
|
|
|
1219 |
|
|
|
1220 |
// get the device context
|
|
|
1221 |
deviceContext = NW_LMgr_RootBox_GetDeviceContext (NW_LMgr_Box_GetRootBox(box));
|
|
|
1222 |
NW_ASSERT (deviceContext != NULL);
|
|
|
1223 |
|
|
|
1224 |
// get the display bounds
|
|
|
1225 |
rectangle = deviceContext->DisplayBounds();
|
|
|
1226 |
|
|
|
1227 |
// get the max character extents
|
|
|
1228 |
status = NW_FBox_SelectSkin_GetMCharExtent(NW_FBox_SelectSkinOf(skin), &extent);
|
|
|
1229 |
NW_THROW_ON_ERROR (status);
|
|
|
1230 |
|
|
|
1231 |
// get the image size
|
|
|
1232 |
status = NW_FBox_Epoc32SelectSkin_GetArrowSize(NW_FBox_SelectBoxOf(box), &imageSize);
|
|
|
1233 |
|
|
|
1234 |
// get the padding and border width
|
|
|
1235 |
NW_LMgr_Box_GetPadding(box, &padding, ELMgrFrameLeft|ELMgrFrameRight );
|
|
|
1236 |
NW_LMgr_Box_GetBorderWidth(box, &borderWidth, ELMgrFrameLeft|ELMgrFrameRight );
|
|
|
1237 |
|
|
|
1238 |
size->height = (NW_GDI_Metric_t)(extent.height);
|
|
|
1239 |
|
|
|
1240 |
// height must not be smaller than the icon height
|
|
|
1241 |
if (size->height < imageSize.height)
|
|
|
1242 |
{
|
|
|
1243 |
size->height = imageSize.height;
|
|
|
1244 |
}
|
|
|
1245 |
|
|
|
1246 |
//Determine if this box sits in a table cell. Different rules apply based on this.
|
|
|
1247 |
NW_LMgr_Box_t* parent = (NW_LMgr_Box_t*) NW_LMgr_Box_GetParent(box);
|
|
|
1248 |
if (NW_Object_IsClass(parent, &NW_LMgr_StaticTableCellBox_Class))
|
|
|
1249 |
{
|
|
|
1250 |
// Calculate the minimum width. This is used for forms inside tables.
|
|
|
1251 |
// In this case the input selection fields should not span the entire screen width.
|
|
|
1252 |
size->width = imageSize.width + NW_FBox_Epoc32SelectSkin_GetMaxTextWidth(thisObj, NW_FBox_SelectBoxOf(box));
|
|
|
1253 |
}
|
|
|
1254 |
else
|
|
|
1255 |
{
|
|
|
1256 |
// Calculate the full width. This is used for forms not inside tables.
|
|
|
1257 |
// In this case the input selection fields should span the entire screen width.
|
|
|
1258 |
size->width = rectangle->dimension.width - padding.left - padding.right - borderWidth.left - borderWidth.right;
|
|
|
1259 |
}
|
|
|
1260 |
|
|
|
1261 |
// Update the value of the select box
|
|
|
1262 |
status = NW_FBox_Epoc32SelectSkin_UpdateValue(thisObj);
|
|
|
1263 |
}
|
|
|
1264 |
NW_CATCH (status)
|
|
|
1265 |
{
|
|
|
1266 |
}
|
|
|
1267 |
NW_FINALLY
|
|
|
1268 |
{
|
|
|
1269 |
return status;
|
|
|
1270 |
}
|
|
|
1271 |
NW_END_TRY
|
|
|
1272 |
}
|
|
|
1273 |
|
|
|
1274 |
// -------------------------------------------------------------------------
|
|
|
1275 |
TBrowserStatusCode
|
|
|
1276 |
_NW_FBox_Epoc32SelectSkin_SetActive(NW_FBox_SelectSkin_t* skin)
|
|
|
1277 |
{
|
|
|
1278 |
NW_FBox_SelectBox_t* selectBox;
|
|
|
1279 |
NW_FBox_FormBox_t* formBox;
|
|
|
1280 |
NW_FBox_Epoc32SelectSkin_t* epoc32Skin;
|
|
|
1281 |
NW_Dlg_SelectData_t* data;
|
|
|
1282 |
NW_Ucs2* textStr;
|
|
|
1283 |
NW_Uint8 freeNeeded;
|
|
|
1284 |
NW_Text_Length_t length;
|
|
|
1285 |
NW_Ucs2* newStr;
|
|
|
1286 |
NW_Text_t* text;
|
|
|
1287 |
|
|
|
1288 |
formBox = NW_FBox_Skin_GetFormBox(NW_FBox_SkinOf(skin));
|
|
|
1289 |
selectBox = NW_FBox_SelectBoxOf(formBox);
|
|
|
1290 |
epoc32Skin = NW_FBox_Epoc32SelectSkinOf(skin);
|
|
|
1291 |
|
|
|
1292 |
/* Use the title attribute for the select dialog title. */
|
|
|
1293 |
text = selectBox->title;
|
|
|
1294 |
if (text == NULL)
|
|
|
1295 |
{
|
|
|
1296 |
newStr = selectBox->appServices->getLocalizedStringAPI.getLocalizedString( EKmLocSelectLabel );
|
|
|
1297 |
if (!newStr)
|
|
|
1298 |
{
|
|
|
1299 |
newStr = NW_Str_NewcpyConst("Select");
|
|
|
1300 |
if (!newStr)
|
|
|
1301 |
{
|
|
|
1302 |
return KBrsrOutOfMemory;
|
|
|
1303 |
}
|
|
|
1304 |
}
|
|
|
1305 |
}
|
|
|
1306 |
else
|
|
|
1307 |
{
|
|
|
1308 |
textStr = NW_Text_GetUCS2Buffer (text, NW_Text_Flags_Aligned, &length, &freeNeeded);
|
|
|
1309 |
|
|
|
1310 |
if (freeNeeded)
|
|
|
1311 |
{
|
|
|
1312 |
newStr = textStr;
|
|
|
1313 |
}
|
|
|
1314 |
else
|
|
|
1315 |
{
|
|
|
1316 |
newStr = NW_Str_Newcpy(textStr);
|
|
|
1317 |
if (!newStr)
|
|
|
1318 |
{
|
|
|
1319 |
return KBrsrOutOfMemory;
|
|
|
1320 |
}
|
|
|
1321 |
}
|
|
|
1322 |
}
|
|
|
1323 |
|
|
|
1324 |
NW_FBox_Epoc32SelectSkin_FillOptionsList(epoc32Skin, formBox, 0);
|
|
|
1325 |
|
|
|
1326 |
data = (NW_Dlg_SelectData_t*)NW_Mem_Malloc(sizeof(NW_Dlg_SelectData_t));
|
|
|
1327 |
|
|
|
1328 |
if (!data)
|
|
|
1329 |
{
|
|
|
1330 |
return KBrsrOutOfMemory;
|
|
|
1331 |
}
|
|
|
1332 |
|
|
|
1333 |
data->title = newStr;
|
|
|
1334 |
data->multiple = selectBox->multiple;
|
|
|
1335 |
data->options = NW_ADT_VectorOf(epoc32Skin->optionsList);
|
|
|
1336 |
|
|
|
1337 |
selectBox->appServices->genDlgApi.DialogSelectOption( data,
|
|
|
1338 |
epoc32Skin,
|
|
|
1339 |
NW_FBox_Epoc32SelectSkin_SelectPromptResp);
|
|
|
1340 |
|
|
|
1341 |
NW_Mem_Free(data->title);
|
|
|
1342 |
NW_Mem_Free(data);
|
|
|
1343 |
|
|
|
1344 |
return KBrsrSuccess;
|
|
|
1345 |
}
|
|
|
1346 |
|
|
|
1347 |
/* ------------------------------------------------------------------------- */
|
|
|
1348 |
TBrowserStatusCode
|
|
|
1349 |
_NW_FBox_Epoc32SelectSkin_Split(NW_FBox_SelectSkin_t* skin,
|
|
|
1350 |
NW_GDI_Metric_t space,
|
|
|
1351 |
NW_LMgr_Box_t* *splitBox,
|
|
|
1352 |
NW_Uint8 flags)
|
|
|
1353 |
{
|
|
|
1354 |
NW_LMgr_PropertyValue_t sizeVal;
|
|
|
1355 |
TBrowserStatusCode status;
|
|
|
1356 |
NW_LMgr_Box_t* box;
|
|
|
1357 |
NW_FBox_FormBox_t* formBox;
|
|
|
1358 |
|
|
|
1359 |
formBox = NW_FBox_Skin_GetFormBox(NW_FBox_SkinOf(skin));
|
|
|
1360 |
box = NW_LMgr_BoxOf(formBox);
|
|
|
1361 |
|
|
|
1362 |
*splitBox = NULL;
|
|
|
1363 |
/* If box does not fit in the space and the box is not
|
|
|
1364 |
on the new line the input box needs to be pushed on the new line */
|
|
|
1365 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetFormatBounds( box );
|
|
|
1366 |
if ((boxBounds.dimension.width > space) && !(flags & NW_LMgr_Box_SplitFlags_AtNewLine))
|
|
|
1367 |
{
|
|
|
1368 |
return KBrsrLmgrNoSplit;
|
|
|
1369 |
}
|
|
|
1370 |
|
|
|
1371 |
if(boxBounds.dimension.width <= space)
|
|
|
1372 |
{
|
|
|
1373 |
return KBrsrSuccess;
|
|
|
1374 |
}
|
|
|
1375 |
|
|
|
1376 |
/* we are more than space */
|
|
|
1377 |
|
|
|
1378 |
/* if width was specified we do not want to change it */
|
|
|
1379 |
status = NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_width, NW_CSS_ValueType_Px, &sizeVal);
|
|
|
1380 |
if (status == KBrsrSuccess)
|
|
|
1381 |
{
|
|
|
1382 |
return status;
|
|
|
1383 |
}
|
|
|
1384 |
boxBounds.dimension.width = space;
|
|
|
1385 |
NW_LMgr_Box_SetFormatBounds( box, boxBounds );
|
|
|
1386 |
|
|
|
1387 |
return KBrsrSuccess;
|
|
|
1388 |
}
|
|
|
1389 |
|
|
|
1390 |
/* ------------------------------------------------------------------------- */
|
|
|
1391 |
TBrowserStatusCode
|
|
|
1392 |
_NW_FBox_Epoc32SelectSkin_AddOption(NW_FBox_SelectSkin_t* selectSkin,
|
|
|
1393 |
NW_FBox_OptionBox_t* optionBox,
|
|
|
1394 |
NW_LMgr_Box_t** styleBox)
|
|
|
1395 |
{
|
|
|
1396 |
NW_REQUIRED_PARAM(selectSkin);
|
|
|
1397 |
NW_REQUIRED_PARAM(optionBox);
|
|
|
1398 |
NW_REQUIRED_PARAM(styleBox);
|
|
|
1399 |
return KBrsrSuccess;
|
|
|
1400 |
}
|
|
|
1401 |
|
|
|
1402 |
/* ------------------------------------------------------------------------- */
|
|
|
1403 |
TBrowserStatusCode
|
|
|
1404 |
_NW_FBox_Epoc32SelectSkin_AddOptGrp(NW_FBox_SelectSkin_t* selectSkin,
|
|
|
1405 |
NW_FBox_OptGrpBox_t* optGrpBox)
|
|
|
1406 |
{
|
|
|
1407 |
NW_REQUIRED_PARAM(selectSkin);
|
|
|
1408 |
NW_REQUIRED_PARAM(optGrpBox);
|
|
|
1409 |
return KBrsrSuccess;
|
|
|
1410 |
|
|
|
1411 |
}
|
|
|
1412 |
|
|
|
1413 |
/* ------------------------------------------------------------------------- */
|
|
|
1414 |
TBrowserStatusCode
|
|
|
1415 |
_NW_FBox_Epoc32SelectSkin_DetailsDialog(NW_FBox_SelectSkin_t* skin)
|
|
|
1416 |
{
|
|
|
1417 |
NW_REQUIRED_PARAM(skin);
|
|
|
1418 |
return KBrsrSuccess;
|
|
|
1419 |
}
|
|
|
1420 |
|
|
|
1421 |
/* ------------------------------------------------------------------------- */
|
|
|
1422 |
TBrowserStatusCode
|
|
|
1423 |
_NW_FBox_Epoc32SelectSkin_RefreshText(NW_FBox_SelectSkin_t* selectSkin)
|
|
|
1424 |
{
|
|
|
1425 |
TBrowserStatusCode status;
|
|
|
1426 |
NW_FBox_Epoc32SelectSkin_t* skin = NW_FBox_Epoc32SelectSkinOf(selectSkin);
|
|
|
1427 |
status = NW_FBox_Epoc32SelectSkin_UpdateValue(skin);
|
|
|
1428 |
NW_ASSERT(status == KBrsrSuccess);
|
|
|
1429 |
if (status != KBrsrSuccess){
|
|
|
1430 |
return status;
|
|
|
1431 |
}
|
|
|
1432 |
return NW_FBox_Epoc32SelectSkin_SetDisplayText(skin);
|
|
|
1433 |
}
|
|
|
1434 |
|
|
|
1435 |
/* ------------------------------------------------------------------------- *
|
|
|
1436 |
public methods
|
|
|
1437 |
* ------------------------------------------------------------------------- */
|
|
|
1438 |
|
|
|
1439 |
TBrowserStatusCode
|
|
|
1440 |
NW_FBox_Epoc32SelectSkin_GetValue(NW_FBox_Epoc32SelectSkin_t *skin, NW_Ucs2** newStr)
|
|
|
1441 |
{
|
|
|
1442 |
NW_FBox_SelectBox_t* selectBox;
|
|
|
1443 |
NW_ADT_Vector_Metric_t numItems;
|
|
|
1444 |
NW_Bool multiple;
|
|
|
1445 |
NW_Bool updated;
|
|
|
1446 |
TBrowserStatusCode status;
|
|
|
1447 |
|
|
|
1448 |
NW_ASSERT(newStr != NULL);
|
|
|
1449 |
if (newStr == NULL) {
|
|
|
1450 |
return KBrsrBadInputParam;
|
|
|
1451 |
}
|
|
|
1452 |
|
|
|
1453 |
selectBox = (NW_FBox_SelectBox_t*)NW_FBox_Skin_GetFormBox(NW_FBox_SkinOf(skin));
|
|
|
1454 |
numItems = NW_ADT_Vector_GetSize(NW_ADT_VectorOf(selectBox->children));
|
|
|
1455 |
multiple = NW_FBox_SelectBox_IsMultiple(selectBox);
|
|
|
1456 |
|
|
|
1457 |
status = NW_FBox_Epoc32SelectSkin_GetChildrenValue(skin,
|
|
|
1458 |
NW_FBox_FormBoxOf(selectBox),
|
|
|
1459 |
numItems,
|
|
|
1460 |
multiple,
|
|
|
1461 |
newStr,
|
|
|
1462 |
&updated);
|
|
|
1463 |
return status;
|
|
|
1464 |
}
|
|
|
1465 |
|
|
|
1466 |
TBrowserStatusCode
|
|
|
1467 |
NW_FBox_Epoc32SelectSkin_UpdateSelection(NW_FBox_Epoc32SelectSkin_t* skin,
|
|
|
1468 |
NW_Ucs2* selectedText,
|
|
|
1469 |
NW_Bool* selectUpdated)
|
|
|
1470 |
{
|
|
|
1471 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
|
1472 |
|
|
|
1473 |
NW_FBox_SelectSkin_Reserve(NW_FBox_SelectSkinOf(skin));
|
|
|
1474 |
*selectUpdated = NW_FBox_Epoc32SelectSkin_ChangeState(skin, selectedText);
|
|
|
1475 |
if (NW_FBox_SelectSkinOf(skin)->hasFormBox == NW_TRUE)
|
|
|
1476 |
{
|
|
|
1477 |
status = NW_FBox_Epoc32SelectSkin_UpdateValue(skin);
|
|
|
1478 |
if (status == KBrsrSuccess)
|
|
|
1479 |
{
|
|
|
1480 |
status = NW_FBox_Epoc32SelectSkin_SetDisplayText(skin);
|
|
|
1481 |
}
|
|
|
1482 |
}
|
|
|
1483 |
NW_FBox_SelectSkin_Release(NW_FBox_SelectSkinOf(skin));
|
|
|
1484 |
return status;
|
|
|
1485 |
}
|
|
|
1486 |
|
|
|
1487 |
|
|
|
1488 |
/* ------------------------------------------------------------------------- *
|
|
|
1489 |
convenience methods
|
|
|
1490 |
* ------------------------------------------------------------------------- */
|
|
|
1491 |
NW_FBox_SelectSkin_t*
|
|
|
1492 |
NW_FBox_SelectSkin_New (NW_FBox_FormBox_t* formBox)
|
|
|
1493 |
{
|
|
|
1494 |
return (NW_FBox_SelectSkin_t*)
|
|
|
1495 |
NW_Object_New (&NW_FBox_Epoc32SelectSkin_Class, formBox);
|
|
|
1496 |
}
|