94
|
1 |
/*
|
|
2 |
* Copyright (c) 2000 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 "nw_fbox_inputboxi.h"
|
|
19 |
|
|
20 |
#include "nw_fbox_inputskin.h"
|
|
21 |
#include "nw_fbox_inputinteractor.h"
|
|
22 |
#include "nw_lmgr_rootbox.h"
|
|
23 |
#include "nwx_string.h"
|
|
24 |
//#include "nw_fbox_passwordbox.h"
|
|
25 |
#include "nw_hed_documentroot.h"
|
|
26 |
#include "nw_fbox_formboxutils.h"
|
|
27 |
#include "GDIDeviceContext.h"
|
|
28 |
#include "BrsrStatusCodes.h"
|
|
29 |
#include "nw_wml1x_wml1xformliaison.h"
|
|
30 |
#include "wml_elm_attr.h"
|
|
31 |
#include "nw_wml_core.h"
|
|
32 |
#include "nw_wml1x_wml1xcontenthandler.h"
|
|
33 |
|
|
34 |
/* ------------------------------------------------------------------------- *
|
|
35 |
private data
|
|
36 |
* ------------------------------------------------------------------------- */
|
|
37 |
|
|
38 |
/* ------------------------------------------------------------------------- *
|
|
39 |
private methods
|
|
40 |
* ------------------------------------------------------------------------- */
|
|
41 |
|
|
42 |
/* ------------------------------------------------------------------------- *
|
|
43 |
global data
|
|
44 |
* ------------------------------------------------------------------------- */
|
|
45 |
|
|
46 |
/* ------------------------------------------------------------------------- */
|
|
47 |
static
|
|
48 |
const
|
|
49 |
NW_LMgr_IEventListener_Class_t _NW_FBox_InputBox_IEventListener_Class = {
|
|
50 |
{ /* NW_Object_Core */
|
|
51 |
/* super */ &NW_LMgr_IEventListener_Class,
|
|
52 |
/* queryInterface */ _NW_Object_Interface_QueryInterface
|
|
53 |
},
|
|
54 |
{ /* NW_Object_Interface */
|
|
55 |
/* offset */ offsetof (NW_LMgr_ActiveBox_t, NW_LMgr_IEventListener)
|
|
56 |
},
|
|
57 |
{ /* NW_LMgr_IEventListener */
|
|
58 |
/* processEvent */ _NW_FBox_InputBox_IEventListener_ProcessEvent
|
|
59 |
}
|
|
60 |
};
|
|
61 |
|
|
62 |
/* ------------------------------------------------------------------------- */
|
|
63 |
static
|
|
64 |
const NW_Object_Class_t* const _NW_FBox_InputBox_InterfaceList[] = {
|
|
65 |
&_NW_FBox_InputBox_IEventListener_Class,
|
|
66 |
NULL
|
|
67 |
};
|
|
68 |
|
|
69 |
/* ------------------------------------------------------------------------- */
|
|
70 |
const
|
|
71 |
NW_FBox_InputBox_Class_t NW_FBox_InputBox_Class = {
|
|
72 |
{ /* NW_Object_Core */
|
|
73 |
/* super */ &NW_FBox_FormBox_Class,
|
|
74 |
/* queryInterface */ _NW_Object_Base_QueryInterface
|
|
75 |
},
|
|
76 |
{ /* NW_Object_Base */
|
|
77 |
/* interfaceList */ _NW_FBox_InputBox_InterfaceList
|
|
78 |
},
|
|
79 |
{ /* NW_Object_Dynamic */
|
|
80 |
/* instanceSize */ sizeof (NW_FBox_InputBox_t),
|
|
81 |
/* construct */ _NW_FBox_InputBox_Construct,
|
|
82 |
/* destruct */ _NW_FBox_InputBox_Destruct
|
|
83 |
},
|
|
84 |
{ /* NW_LMgr_Box */
|
|
85 |
/* split */ _NW_FBox_InputBox_Split,
|
|
86 |
/* resize */ _NW_FBox_FormBox_Resize,
|
|
87 |
/* postResize */ _NW_LMgr_Box_PostResize,
|
|
88 |
/* getMinimumContentSize */ _NW_FBox_FormBox_GetMinimumContentSize,
|
|
89 |
/* hasFixedContentSize */ _NW_LMgr_Box_HasFixedContentSize,
|
|
90 |
/* constrain */ _NW_LMgr_Box_Constrain,
|
|
91 |
/* draw */ _NW_FBox_FormBox_Draw,
|
|
92 |
/* render */ _NW_LMgr_Box_Render,
|
|
93 |
/* getBaseline */ _NW_FBox_InputBox_GetBaseline,
|
|
94 |
/* shift */ _NW_LMgr_Box_Shift,
|
|
95 |
/* clone */ _NW_LMgr_Box_Clone
|
|
96 |
},
|
|
97 |
{ /* NW_LMgr_ActiveBox */
|
|
98 |
/* unused */ NW_Object_Unused
|
|
99 |
},
|
|
100 |
{ /* NW_FBox_FormBox */
|
|
101 |
/* initSkin */ _NW_FBox_InputBox_InitSkin,
|
|
102 |
/* initInteractor */ _NW_FBox_InputBox_InitInteractor,
|
|
103 |
/* reset */ _NW_FBox_InputBox_Reset
|
|
104 |
},
|
|
105 |
{ /* NW_FBox_InputBox */
|
|
106 |
/* getHeight */ _NW_FBox_InputBox_GetHeight,
|
|
107 |
/* setHeight */ _NW_FBox_InputBox_SetHeight,
|
|
108 |
/* setDisplayText */ _NW_FBox_InputBox_SetDisplayText,
|
|
109 |
/* modifyBuffer */ _NW_FBox_InputBox_ModifyBuffer
|
|
110 |
}
|
|
111 |
};
|
|
112 |
|
|
113 |
/* ------------------------------------------------------------------------- *
|
|
114 |
virtual methods
|
|
115 |
* ------------------------------------------------------------------------- */
|
|
116 |
|
|
117 |
/* ------------------------------------------------------------------------- */
|
|
118 |
TBrowserStatusCode
|
|
119 |
_NW_FBox_InputBox_Construct (NW_Object_Dynamic_t* dynamicObject,
|
|
120 |
va_list* argp)
|
|
121 |
{
|
|
122 |
NW_FBox_InputBox_t* thisObj;
|
|
123 |
TBrowserStatusCode status;
|
|
124 |
NW_FBox_FormLiaison_t* formLiaison;
|
|
125 |
void *controlId;
|
|
126 |
NW_Text_t* buffer;
|
|
127 |
NW_Bool initialValue = NW_FALSE;
|
|
128 |
|
|
129 |
/* for convenience */
|
|
130 |
thisObj = NW_FBox_InputBoxOf (dynamicObject);
|
|
131 |
buffer = NULL;
|
|
132 |
/* invoke our superclass constructor */
|
|
133 |
status = _NW_FBox_FormBox_Construct (dynamicObject, argp);
|
|
134 |
if (status != KBrsrSuccess) {
|
|
135 |
return status;
|
|
136 |
}
|
|
137 |
thisObj->width = (NW_Uint16)va_arg (*argp, NW_Uint32);
|
|
138 |
thisObj->appServices = va_arg (*argp, NW_HED_AppServices_t*);
|
|
139 |
thisObj->title = NULL;
|
|
140 |
thisObj->validator = NULL;
|
|
141 |
thisObj->active = NW_FALSE;
|
|
142 |
thisObj->focus = NW_FALSE;
|
|
143 |
thisObj->maxChars = NW_FBox_InputBox_MaxCharacters;
|
|
144 |
thisObj->IsMaxlength = NW_FALSE;
|
|
145 |
thisObj->value = NULL;
|
|
146 |
|
|
147 |
/* Get initial value from the form liaison */
|
|
148 |
formLiaison = NW_FBox_FormBox_GetFormLiaison(thisObj);
|
|
149 |
controlId = NW_FBox_FormBox_GetFormCntrlID(thisObj);
|
|
150 |
(void) NW_FBox_FormLiaison_GetStringValue(formLiaison, controlId, &buffer, &initialValue);
|
|
151 |
thisObj->initialValueUsed = initialValue;
|
|
152 |
|
|
153 |
if (buffer){
|
|
154 |
NW_FBox_InputBox_SetDefaultVal(thisObj, buffer);
|
|
155 |
}
|
|
156 |
/* successful completion */
|
|
157 |
return KBrsrSuccess;
|
|
158 |
}
|
|
159 |
|
|
160 |
/* --------------------------------------------------------------------------*/
|
|
161 |
void
|
|
162 |
_NW_FBox_InputBox_Destruct (NW_Object_Dynamic_t* dynamicObject)
|
|
163 |
{
|
|
164 |
NW_FBox_InputBox_t* thisObj;
|
|
165 |
|
|
166 |
/* for convenience */
|
|
167 |
thisObj = NW_FBox_InputBoxOf (dynamicObject);
|
|
168 |
|
|
169 |
NW_ASSERT(NW_Object_IsInstanceOf(thisObj, &NW_FBox_InputBox_Class));
|
|
170 |
|
|
171 |
/* Destroy our Value object */
|
|
172 |
if(thisObj->value != NULL){
|
|
173 |
NW_Object_Delete(thisObj->value);
|
|
174 |
}
|
|
175 |
if (thisObj->title != NULL) {
|
|
176 |
NW_Str_Delete(thisObj->title);
|
|
177 |
}
|
|
178 |
if (thisObj->validator != NULL) {
|
|
179 |
NW_Object_Delete(thisObj->validator);
|
|
180 |
}
|
|
181 |
}
|
|
182 |
|
|
183 |
/* ------------------------------------------------------------------------- */
|
|
184 |
NW_Uint16
|
|
185 |
_NW_FBox_InputBox_GetHeight(NW_FBox_InputBox_t* box)
|
|
186 |
{
|
|
187 |
NW_ASSERT(NW_Object_IsInstanceOf(box, &NW_FBox_InputBox_Class));
|
|
188 |
NW_REQUIRED_PARAM(box);
|
|
189 |
return 1;
|
|
190 |
}
|
|
191 |
|
|
192 |
/* ------------------------------------------------------------------------- */
|
|
193 |
|
|
194 |
/* ------------------------------------------------------------------------- */
|
|
195 |
|
|
196 |
void
|
|
197 |
_NW_FBox_InputBox_SetHeight(NW_FBox_InputBox_t* box, NW_Uint16 height)
|
|
198 |
{
|
|
199 |
NW_ASSERT(NW_Object_IsInstanceOf(box, &NW_FBox_InputBox_Class));
|
|
200 |
NW_REQUIRED_PARAM(box);
|
|
201 |
NW_REQUIRED_PARAM(height);
|
|
202 |
// box->height = height;
|
|
203 |
}
|
|
204 |
|
|
205 |
/* ------------------------------------------------------------------------- */
|
|
206 |
|
|
207 |
TBrowserStatusCode
|
|
208 |
_NW_FBox_InputBox_SetDisplayText(NW_FBox_InputBox_t* thisObj,
|
|
209 |
NW_Bool bufferModificationOn)
|
|
210 |
{
|
|
211 |
NW_FBox_InputSkin_t* skin;
|
|
212 |
NW_ASSERT(NW_Object_IsInstanceOf(thisObj, &NW_FBox_InputBox_Class));
|
|
213 |
NW_REQUIRED_PARAM(thisObj);
|
|
214 |
NW_REQUIRED_PARAM(bufferModificationOn);
|
|
215 |
skin = NW_FBox_InputSkinOf(NW_FBox_FormBox_GetSkin(thisObj));
|
|
216 |
return NW_FBox_InputSkin_SetDisplayText(skin);
|
|
217 |
}
|
|
218 |
|
|
219 |
|
|
220 |
/* ------------------------------------------------------------------------- */
|
|
221 |
NW_FBox_Skin_t*
|
|
222 |
_NW_FBox_InputBox_InitSkin(NW_FBox_FormBox_t* formBox)
|
|
223 |
{
|
|
224 |
NW_ASSERT(NW_Object_IsInstanceOf(formBox, &NW_FBox_InputBox_Class));
|
|
225 |
return (NW_FBox_Skin_t *)NW_FBox_InputSkin_New(formBox);
|
|
226 |
}
|
|
227 |
|
|
228 |
/* ------------------------------------------------------------------------- */
|
|
229 |
NW_FBox_Interactor_t*
|
|
230 |
_NW_FBox_InputBox_InitInteractor(NW_FBox_FormBox_t* formBox)
|
|
231 |
{
|
|
232 |
NW_ASSERT(NW_Object_IsInstanceOf(formBox, &NW_FBox_InputBox_Class));
|
|
233 |
return (NW_FBox_Interactor_t *)NW_FBox_InputInteractor_New(formBox);
|
|
234 |
}
|
|
235 |
|
|
236 |
/* --------------------------------------------------------------------------*/
|
|
237 |
TBrowserStatusCode
|
|
238 |
_NW_FBox_InputBox_ModifyBuffer(NW_FBox_InputBox_t* inputBox,
|
|
239 |
NW_Ucs2 c,
|
|
240 |
NW_Uint32 repeated)
|
|
241 |
{
|
|
242 |
NW_REQUIRED_PARAM(inputBox);
|
|
243 |
NW_REQUIRED_PARAM(c);
|
|
244 |
NW_REQUIRED_PARAM(repeated);
|
|
245 |
return KBrsrSuccess;
|
|
246 |
}
|
|
247 |
|
|
248 |
/* ------------------------------------------------------------------------- */
|
|
249 |
TBrowserStatusCode
|
|
250 |
_NW_FBox_InputBox_Split(NW_LMgr_Box_t* box,
|
|
251 |
NW_GDI_Metric_t space,
|
|
252 |
NW_LMgr_Box_t* *splitBox,
|
|
253 |
NW_Uint8 flags)
|
|
254 |
{
|
|
255 |
NW_FBox_InputSkin_t* inputSkin;
|
|
256 |
NW_FBox_FormBox_t* formBox;
|
|
257 |
|
|
258 |
if (flags & NW_LMgr_Box_SplitFlags_Nowrap) {
|
|
259 |
*splitBox = NULL;
|
|
260 |
return KBrsrSuccess;
|
|
261 |
}
|
|
262 |
*splitBox = NULL;
|
|
263 |
formBox = NW_FBox_FormBoxOf(box);
|
|
264 |
inputSkin = NW_FBox_InputSkinOf(NW_FBox_FormBox_GetSkin(formBox));
|
|
265 |
return NW_FBox_InputSkin_Split(inputSkin, space, splitBox, flags);
|
|
266 |
}
|
|
267 |
|
|
268 |
|
|
269 |
/* ------------------------------------------------------------------------- *
|
|
270 |
final methods
|
|
271 |
* ------------------------------------------------------------------------- */
|
|
272 |
|
|
273 |
NW_Text_Length_t
|
|
274 |
NW_FBox_InputBox_GetBufferLength(NW_FBox_InputBox_t* inputBox)
|
|
275 |
{
|
|
276 |
NW_ASSERT(NW_Object_IsInstanceOf(inputBox, &NW_FBox_InputBox_Class));
|
|
277 |
if (inputBox->value == NULL){
|
|
278 |
return 0;
|
|
279 |
}
|
|
280 |
return NW_Text_GetCharCount(inputBox->value);
|
|
281 |
}
|
|
282 |
|
|
283 |
/* ------------------------------------------------------------------------- */
|
|
284 |
TBrowserStatusCode
|
|
285 |
NW_FBox_InputBox_CheckFormLiaisonVal(NW_FBox_InputBox_t* inputBox)
|
|
286 |
{
|
|
287 |
NW_Text_t* text;
|
|
288 |
NW_FBox_FormLiaison_t* formLiaison;
|
|
289 |
void* formControlId;
|
|
290 |
TBrowserStatusCode status;
|
|
291 |
|
|
292 |
/* parameter assertion block */
|
|
293 |
NW_ASSERT(NW_Object_IsInstanceOf(inputBox, &NW_FBox_InputBox_Class));
|
|
294 |
|
|
295 |
/* get the UCS2 pointer to the value and construct a new Text
|
|
296 |
object from this */
|
|
297 |
text = NW_Text_Copy(inputBox->value, NW_TRUE);
|
|
298 |
|
|
299 |
/* we pass ownership of the text object to the formLiaison */
|
|
300 |
formLiaison = NW_FBox_FormBox_GetFormLiaison (inputBox);
|
|
301 |
formControlId = NW_FBox_FormBox_GetFormCntrlID(inputBox);
|
|
302 |
|
|
303 |
status = NW_FBox_FormLiaison_ValidateStringValue (formLiaison, formControlId,
|
|
304 |
text);
|
|
305 |
|
|
306 |
NW_Object_Delete( text );
|
|
307 |
|
|
308 |
return status;
|
|
309 |
}
|
|
310 |
|
|
311 |
/* ------------------------------------------------------------------------- */
|
|
312 |
TBrowserStatusCode
|
|
313 |
NW_FBox_InputBox_SetFormLiaisonVal(NW_FBox_InputBox_t* inputBox)
|
|
314 |
{
|
|
315 |
NW_Text_t* text = NULL;
|
|
316 |
NW_FBox_FormLiaison_t* formLiaison;
|
|
317 |
void* formControlId;
|
|
318 |
TBrowserStatusCode status;
|
|
319 |
NW_Bool dummy;
|
|
320 |
|
|
321 |
// parameter assertion block
|
|
322 |
NW_ASSERT(NW_Object_IsInstanceOf(inputBox, &NW_FBox_InputBox_Class));
|
|
323 |
|
|
324 |
// get UCS2 pointer to value and construct new Text object from this
|
|
325 |
if (inputBox->value != NULL){
|
|
326 |
text = NW_Text_Copy(inputBox->value, NW_TRUE);
|
|
327 |
}else{
|
|
328 |
text = (NW_Text_t*) NW_Text_UCS2_New (NULL, 0, 0);
|
|
329 |
}
|
|
330 |
// pass ownership of text object to formLiaison
|
|
331 |
formLiaison = NW_FBox_FormBox_GetFormLiaison (inputBox);
|
|
332 |
formControlId = NW_FBox_FormBox_GetFormCntrlID(inputBox);
|
|
333 |
|
|
334 |
status = NW_FBox_FormLiaison_SetStringValue (formLiaison, formControlId,
|
|
335 |
text);
|
|
336 |
if (status == KBrsrWmlbrowserInputNonconformingToMask) {
|
|
337 |
// Expected that may not match format mask. Force to success so
|
|
338 |
// will contine.
|
|
339 |
status = KBrsrSuccess;
|
|
340 |
} else if (status == KBrsrOutOfMemory) {
|
|
341 |
return KBrsrOutOfMemory;
|
|
342 |
} else if (status != KBrsrSuccess) {
|
|
343 |
// Gracefully attempt to recover from other types of errors, at least
|
|
344 |
// trying to keep the displayed text in synch with what the user entered.
|
|
345 |
// Without this, expected possible errors such as KBrsrWmlbrowserBadContent
|
|
346 |
// for example, will cause displayed text to be out of synch.
|
|
347 |
return NW_FBox_InputBox_SetDisplayText (inputBox, NW_TRUE);
|
|
348 |
}
|
|
349 |
|
|
350 |
// get formLiaison's intrepretation of value and set that as default
|
|
351 |
status =
|
|
352 |
NW_FBox_FormLiaison_GetStringValue (formLiaison, formControlId, &text, &dummy);
|
|
353 |
if (status != KBrsrSuccess){
|
|
354 |
return status;
|
|
355 |
}
|
|
356 |
status = NW_FBox_InputBox_SetDefaultVal (inputBox, text);
|
|
357 |
NW_ASSERT (status == KBrsrSuccess);
|
|
358 |
return NW_FBox_InputBox_SetDisplayText (inputBox, NW_TRUE);
|
|
359 |
}
|
|
360 |
|
|
361 |
/* --------------------------------------------------------------------------*/
|
|
362 |
TBrowserStatusCode
|
|
363 |
NW_FBox_InputBox_SetDefaultVal(NW_FBox_InputBox_t* thisObj,
|
|
364 |
NW_Text_t* defaultVal)
|
|
365 |
{
|
|
366 |
/* parameter assertion block */
|
|
367 |
NW_ASSERT(NW_Object_IsInstanceOf(thisObj, &NW_FBox_InputBox_Class));
|
|
368 |
NW_ASSERT (defaultVal == NULL ||
|
|
369 |
NW_Object_IsInstanceOf (defaultVal, &NW_Text_Abstract_Class));
|
|
370 |
|
|
371 |
if (thisObj->value){
|
|
372 |
NW_Object_Delete(thisObj->value);
|
|
373 |
thisObj->value = NULL;
|
|
374 |
}
|
|
375 |
if (defaultVal == NULL){
|
|
376 |
return KBrsrSuccess;
|
|
377 |
}
|
|
378 |
thisObj->value = NW_Text_Copy(defaultVal, NW_TRUE);
|
|
379 |
if (thisObj->value == NULL){
|
|
380 |
return KBrsrOutOfMemory;
|
|
381 |
}
|
|
382 |
return KBrsrSuccess;
|
|
383 |
}
|
|
384 |
|
|
385 |
/* --------------------------------------------------------------------------*/
|
|
386 |
void
|
|
387 |
NW_FBox_InputBox_SetActive(NW_FBox_InputBox_t* inputBox, NW_Bool active)
|
|
388 |
{
|
|
389 |
NW_AppServices_SoftKeyAPI_t* softKeyAPI;
|
|
390 |
NW_FBox_InputSkin_t* inputSkin;
|
|
391 |
TBrowserStatusCode status;
|
|
392 |
|
|
393 |
NW_ASSERT(NW_Object_IsInstanceOf(inputBox, &NW_FBox_InputBox_Class));
|
|
394 |
|
|
395 |
inputBox->active = active;
|
|
396 |
softKeyAPI = &(inputBox->appServices->softKeyApi);
|
|
397 |
NW_ASSERT(softKeyAPI != NULL);
|
|
398 |
|
|
399 |
if (active == NW_TRUE) {
|
|
400 |
if (softKeyAPI->setLeft != NULL) {
|
|
401 |
softKeyAPI->setLeft(NW_SOFTKEY_OK);
|
|
402 |
}
|
|
403 |
if (softKeyAPI->setRight != NULL) {
|
|
404 |
softKeyAPI->setRight(NW_SOFTKEY_CLEAR);
|
|
405 |
}
|
|
406 |
inputSkin = NW_FBox_InputSkinOf(NW_FBox_FormBox_GetSkin(inputBox));
|
|
407 |
status = NW_FBox_InputSkin_SetActive (inputSkin);
|
|
408 |
if (status != KBrsrSuccess) {
|
|
409 |
NW_FBox_InputBox_SetActive (inputBox, NW_FALSE);
|
|
410 |
(void) inputBox->appServices->errorApi.notifyError (NULL, status, NULL, NULL);
|
|
411 |
}
|
|
412 |
}
|
|
413 |
else {
|
|
414 |
if (softKeyAPI->setLeft != NULL) {
|
|
415 |
softKeyAPI->setLeft(NW_SOFTKEY_OPTIONS);
|
|
416 |
}
|
|
417 |
if (softKeyAPI->setRight != NULL) {
|
|
418 |
softKeyAPI->setRight(NW_SOFTKEY_BACK);
|
|
419 |
}
|
|
420 |
}
|
|
421 |
}
|
|
422 |
|
|
423 |
/* --------------------------------------------------------------------------*/
|
|
424 |
void
|
|
425 |
NW_FBox_InputBox_SetFocus( NW_FBox_InputBox_t* inputBox, NW_Bool focus )
|
|
426 |
{
|
|
427 |
NW_FBox_InputSkin_t* inputSkin;
|
|
428 |
NW_ASSERT( NW_Object_IsInstanceOf( inputBox, &NW_FBox_InputBox_Class ) );
|
|
429 |
inputSkin = NW_FBox_InputSkinOf( NW_FBox_FormBox_GetSkin( inputBox ) );
|
|
430 |
NW_FBox_InputSkin_SetFocus( inputSkin, focus );
|
|
431 |
}
|
|
432 |
|
|
433 |
/* --------------------------------------------------------------------------*/
|
|
434 |
void
|
|
435 |
NW_FBox_InputBox_SetVKB( NW_FBox_InputBox_t* inputBox)
|
|
436 |
{
|
|
437 |
NW_FBox_InputSkin_t* inputSkin;
|
|
438 |
NW_ASSERT( NW_Object_IsInstanceOf( inputBox, &NW_FBox_InputBox_Class ) );
|
|
439 |
inputSkin = NW_FBox_InputSkinOf( NW_FBox_FormBox_GetSkin( inputBox ) );
|
|
440 |
NW_FBox_InputSkin_SetVKB( inputSkin);
|
|
441 |
}
|
|
442 |
|
|
443 |
|
|
444 |
/* --------------------------------------------------------------------------*/
|
|
445 |
TBrowserStatusCode
|
|
446 |
_NW_FBox_InputBox_Reset (NW_FBox_FormBox_t* box)
|
|
447 |
{
|
|
448 |
TBrowserStatusCode status;
|
|
449 |
NW_FBox_FormLiaison_t* formLiaison;
|
|
450 |
void* formControlId;
|
|
451 |
NW_Text_t *buffer;
|
|
452 |
NW_FBox_InputBox_t* thisObj;
|
|
453 |
NW_Bool dummy;
|
|
454 |
|
|
455 |
/* Call superclass to NULL/reset values. */
|
|
456 |
status = _NW_FBox_FormBox_Reset(box);
|
|
457 |
if ( status != KBrsrSuccess ) {
|
|
458 |
return status;
|
|
459 |
}
|
|
460 |
|
|
461 |
thisObj = NW_FBox_InputBoxOf (box);
|
|
462 |
|
|
463 |
formControlId = NW_FBox_FormBox_GetFormCntrlID(thisObj);
|
|
464 |
formLiaison = NW_FBox_FormBox_GetFormLiaison(NW_FBox_FormBoxOf(thisObj));
|
|
465 |
|
|
466 |
/* SetInitialStringValue will retrieve the the default form value... */
|
|
467 |
status = NW_FBox_FormLiaison_SetInitialStringValue(formLiaison,
|
|
468 |
formControlId,
|
|
469 |
NW_FBox_InputBox_GetMaxChars(thisObj));
|
|
470 |
if (status == KBrsrWmlbrowserInputNonconformingToMask) {
|
|
471 |
/* Expected that may not match format mask. Force to success so
|
|
472 |
will contine. */
|
|
473 |
status = KBrsrSuccess;
|
|
474 |
}
|
|
475 |
|
|
476 |
status = NW_FBox_FormLiaison_GetStringValue(formLiaison, formControlId, &buffer, &dummy);
|
|
477 |
NW_ASSERT(status == KBrsrSuccess);
|
|
478 |
if (status != KBrsrSuccess){
|
|
479 |
return status;
|
|
480 |
}
|
|
481 |
|
|
482 |
NW_FBox_InputBox_SetDefaultVal(thisObj, buffer);
|
|
483 |
status = NW_FBox_InputBox_SetDisplayText(thisObj, NW_TRUE);
|
|
484 |
if (status != KBrsrSuccess) {
|
|
485 |
return status;
|
|
486 |
}
|
|
487 |
|
|
488 |
return status;
|
|
489 |
}
|
|
490 |
|
|
491 |
/* ------------------------------------------------------------------------- */
|
|
492 |
NW_GDI_Metric_t
|
|
493 |
_NW_FBox_InputBox_GetBaseline (NW_LMgr_Box_t* box)
|
|
494 |
{
|
|
495 |
CGDIFont* font;
|
|
496 |
TGDIFontInfo fontInfo;
|
|
497 |
|
|
498 |
/* parameter assertion block */
|
|
499 |
NW_ASSERT (box != NULL);
|
|
500 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_FBox_FormBox_Class));
|
|
501 |
|
|
502 |
/* Get the font info */
|
|
503 |
font = NW_LMgr_Box_GetFont (box);
|
|
504 |
if (font != NULL)
|
|
505 |
{
|
|
506 |
NW_LMgr_FrameInfo_t padding;
|
|
507 |
NW_LMgr_FrameInfo_t borderWidth;
|
|
508 |
|
|
509 |
(void) font->GetFontInfo ( &fontInfo);
|
|
510 |
|
|
511 |
/* Get the padding and the border width */
|
|
512 |
NW_LMgr_Box_GetPadding(box, &padding, ELMgrFrameTop );
|
|
513 |
NW_LMgr_Box_GetBorderWidth(box, &borderWidth, ELMgrFrameTop );
|
|
514 |
|
|
515 |
return (NW_GDI_Metric_t)(fontInfo.baseline + borderWidth.top + padding.top);
|
|
516 |
}
|
|
517 |
|
|
518 |
/* unable to get the FontInfo we return our height */
|
|
519 |
return NW_LMgr_Box_GetFormatBounds(box).dimension.height;
|
|
520 |
}
|
|
521 |
|
|
522 |
|
|
523 |
/* --------------------------------------------------------------------------*/
|
|
524 |
TBrowserStatusCode
|
|
525 |
NW_FBox_InputBox_GetFormat(NW_FBox_InputBox_t* thisObj,
|
|
526 |
const NW_Text_t** format,
|
|
527 |
NW_FBox_Validator_Mode_t* mode,
|
|
528 |
NW_FBox_Validator_EmptyOk_t* emptyOk)
|
|
529 |
{
|
|
530 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
531 |
NW_LMgr_Property_t prop;
|
|
532 |
|
|
533 |
/* parameter assertion block */
|
|
534 |
NW_ASSERT(NW_Object_IsInstanceOf(thisObj, &NW_FBox_InputBox_Class));
|
|
535 |
NW_ASSERT( format != NULL );
|
|
536 |
NW_ASSERT( emptyOk != NULL );
|
|
537 |
NW_ASSERT( mode != NULL );
|
|
538 |
|
|
539 |
*format = NULL;
|
|
540 |
*emptyOk = NW_FBox_Validator_EmptyOk_None;
|
|
541 |
*mode = NW_FBox_Validator_Mode_None;
|
|
542 |
|
|
543 |
/* Get and set -wap-input-format property. */
|
|
544 |
status = NW_LMgr_Box_GetProperty( NW_LMgr_BoxOf(thisObj),
|
|
545 |
NW_CSS_Prop_inputFormat,
|
|
546 |
&prop );
|
|
547 |
|
|
548 |
if ( ( status == KBrsrSuccess ) &&
|
|
549 |
( prop.type == NW_CSS_ValueType_Text ) ) {
|
|
550 |
/* Found -wap-input-format property. Set it on the box. */
|
|
551 |
*format = NW_TextOf( prop.value.object );
|
|
552 |
}
|
|
553 |
|
|
554 |
/* Get and set -wap-input-required property. */
|
|
555 |
status = NW_LMgr_Box_GetProperty( NW_LMgr_BoxOf(thisObj),
|
|
556 |
NW_CSS_Prop_inputRequired,
|
|
557 |
&prop );
|
|
558 |
|
|
559 |
if ( ( status == KBrsrSuccess ) &&
|
|
560 |
( prop.type == NW_CSS_ValueType_Token ) ) {
|
|
561 |
/* Found -wap-input-required property. Set it on the box. */
|
|
562 |
if ( prop.value.token == NW_CSS_PropValue_true ) {
|
|
563 |
/* Input required is true. Note this translates to emptyOk == FALSE. */
|
|
564 |
*emptyOk = NW_FBox_Validator_EmptyOk_False;
|
|
565 |
}
|
|
566 |
else if ( prop.value.token == NW_CSS_PropValue_false ) {
|
|
567 |
/* Input required is false. Note this translates to emptyOk == TRUE. */
|
|
568 |
*emptyOk = NW_FBox_Validator_EmptyOk_True;
|
|
569 |
}
|
|
570 |
}
|
|
571 |
|
|
572 |
status = NW_LMgr_Box_GetProperty( NW_LMgr_BoxOf(thisObj), NW_CSS_Prop_istyle,
|
|
573 |
&prop );
|
|
574 |
if ( ( status == KBrsrSuccess ) &&
|
|
575 |
( prop.type == NW_CSS_ValueType_Integer ) ) {
|
|
576 |
switch (prop.value.integer)
|
|
577 |
{
|
|
578 |
case 1:
|
|
579 |
{
|
|
580 |
*mode = NW_FBox_Validator_Mode_Hiragana;
|
|
581 |
break;
|
|
582 |
}
|
|
583 |
case 2:
|
|
584 |
{
|
|
585 |
*mode = NW_FBox_Validator_Mode_Hankakukana;
|
|
586 |
break;
|
|
587 |
}
|
|
588 |
case 3:
|
|
589 |
{
|
|
590 |
*mode = NW_FBox_Validator_Mode_Alphabet;
|
|
591 |
break;
|
|
592 |
}
|
|
593 |
case 4:
|
|
594 |
{
|
|
595 |
*mode = NW_FBox_Validator_Mode_Numeric;
|
|
596 |
break;
|
|
597 |
}
|
|
598 |
default:
|
|
599 |
{
|
|
600 |
break;
|
|
601 |
}
|
|
602 |
}
|
|
603 |
}
|
|
604 |
|
|
605 |
status = NW_LMgr_Box_GetProperty( NW_LMgr_BoxOf(thisObj), NW_CSS_Prop_mode,
|
|
606 |
&prop );
|
|
607 |
if ( ( status == KBrsrSuccess ) &&
|
|
608 |
( prop.type == NW_CSS_ValueType_Token ) ) {
|
|
609 |
switch (prop.value.token)
|
|
610 |
{
|
|
611 |
case NW_CSS_PropValue_hiragana:
|
|
612 |
{
|
|
613 |
*mode = NW_FBox_Validator_Mode_Hiragana;
|
|
614 |
break;
|
|
615 |
}
|
|
616 |
case NW_CSS_PropValue_katakana:
|
|
617 |
{
|
|
618 |
*mode = NW_FBox_Validator_Mode_Katakana;
|
|
619 |
break;
|
|
620 |
}
|
|
621 |
case NW_CSS_PropValue_hankakukana:
|
|
622 |
{
|
|
623 |
*mode = NW_FBox_Validator_Mode_Hankakukana;
|
|
624 |
break;
|
|
625 |
}
|
|
626 |
case NW_CSS_PropValue_alphabet:
|
|
627 |
{
|
|
628 |
*mode = NW_FBox_Validator_Mode_Alphabet;
|
|
629 |
break;
|
|
630 |
}
|
|
631 |
case NW_CSS_PropValue_numeric:
|
|
632 |
{
|
|
633 |
*mode = NW_FBox_Validator_Mode_Numeric;
|
|
634 |
break;
|
|
635 |
}
|
|
636 |
default:
|
|
637 |
{
|
|
638 |
break;
|
|
639 |
}
|
|
640 |
}
|
|
641 |
}
|
|
642 |
return KBrsrSuccess;
|
|
643 |
}
|
|
644 |
|
|
645 |
/* ------------------------------------------------------------------------- *
|
|
646 |
implemented interface methods
|
|
647 |
* ------------------------------------------------------------------------- */
|
|
648 |
|
|
649 |
/* --------------------------------------------------------------------------*/
|
|
650 |
NW_Uint8
|
|
651 |
_NW_FBox_InputBox_IEventListener_ProcessEvent (NW_LMgr_IEventListener_t* eventListener,
|
|
652 |
NW_Evt_Event_t* event)
|
|
653 |
{
|
|
654 |
NW_FBox_InputBox_t* thisObj;
|
|
655 |
NW_FBox_Interactor_t* interactor;
|
|
656 |
NW_Uint8 eventAbsorbed;
|
|
657 |
|
|
658 |
/* parameter assertion block */
|
|
659 |
NW_ASSERT (NW_Object_IsInstanceOf (eventListener,
|
|
660 |
&NW_LMgr_IEventListener_Class));
|
|
661 |
NW_ASSERT (NW_Object_IsInstanceOf (event, &NW_Evt_Event_Class));
|
|
662 |
|
|
663 |
/* obtain the implementer */
|
|
664 |
thisObj = (NW_FBox_InputBox_t*) NW_Object_Interface_GetImplementer (eventListener);
|
|
665 |
NW_ASSERT (NW_Object_IsInstanceOf (thisObj, &NW_FBox_InputBox_Class));
|
|
666 |
|
|
667 |
thisObj = NW_FBox_InputBoxOf(thisObj);
|
|
668 |
NW_ASSERT(NW_Object_IsInstanceOf(thisObj, &NW_FBox_InputBox_Class));
|
|
669 |
|
|
670 |
interactor = NW_FBox_FormBox_GetInteractor(NW_FBox_FormBoxOf(thisObj));
|
|
671 |
|
|
672 |
eventAbsorbed =
|
|
673 |
NW_FBox_Interactor_ProcessEvent (interactor,
|
|
674 |
NW_LMgr_ActiveBoxOf (thisObj), event);
|
|
675 |
if (eventAbsorbed){
|
|
676 |
return eventAbsorbed;
|
|
677 |
}
|
|
678 |
|
|
679 |
return _NW_LMgr_ActiveBox_IEventListener_ProcessEvent (eventListener, event);
|
|
680 |
}
|
|
681 |
|
|
682 |
/* ------------------------------------------------------------------------- *
|
|
683 |
convenience methods
|
|
684 |
* ------------------------------------------------------------------------- */
|
|
685 |
|
|
686 |
/* --------------------------------------------------------------------------*/
|
|
687 |
NW_FBox_InputBox_t*
|
|
688 |
NW_FBox_InputBox_New (NW_ADT_Vector_Metric_t numProperties,
|
|
689 |
NW_LMgr_EventHandler_t* eventHandler,
|
|
690 |
void* formCntrlId,
|
|
691 |
NW_FBox_FormLiaison_t* formLiaison,
|
|
692 |
NW_Uint16 colulmns,
|
|
693 |
NW_HED_AppServices_t* appServices)
|
|
694 |
{
|
|
695 |
return (NW_FBox_InputBox_t*)
|
|
696 |
NW_Object_New (&NW_FBox_InputBox_Class, (NW_Uint32)numProperties, eventHandler,
|
|
697 |
formCntrlId, formLiaison, (NW_Uint32)colulmns, appServices);
|
|
698 |
}
|
|
699 |
|
|
700 |
|
|
701 |
|