1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
12 #include "lib/scritchui/scritchuiTypes.h"
13 #include "lib/scritchui/core/core.h"
14 #include "sjme/alloc.h"
15 #include "lib/scritchui/core/coreGeneric.h"
17 static sjme_errorCode
sjme_scritchui_core_listNewWrap(
18 sjme_attrInNotNull sjme_scritchui inState
,
19 sjme_attrInNotNull sjme_scritchui_uiList inList
,
20 sjme_attrInNotNull
const sjme_scritchui_impl_initParamList
* init
)
22 if (inState
== NULL
|| inList
== NULL
|| init
== NULL
)
23 return SJME_ERROR_NULL_ARGUMENTS
;
26 inList
->choice
.type
= init
->type
;
29 return inState
->impl
->listNew(inState
, inList
, init
);
32 sjme_errorCode
sjme_scritchui_core_listNew(
33 sjme_attrInNotNull sjme_scritchui inState
,
34 sjme_attrInOutNotNull sjme_scritchui_uiList
* outList
,
35 sjme_attrInValue sjme_scritchui_choiceType inChoiceType
)
37 sjme_scritchui_impl_initParamList init
;
39 if (inState
== NULL
|| outList
== NULL
)
40 return SJME_ERROR_NULL_ARGUMENTS
;
42 if (inChoiceType
< 0 || inChoiceType
>= SJME_SCRITCHUI_NUM_CHOICE_TYPES
)
43 return SJME_ERROR_INVALID_ARGUMENT
;
45 if (inState
->impl
->listNew
== NULL
)
46 return sjme_error_notImplemented(0);
48 /* Setup initialization data. */
49 memset(&init
, 0, sizeof(init
));
50 init
.type
= inChoiceType
;
52 /* Use generic function. */
53 return sjme_scritchui_coreGeneric_componentNew(inState
,
54 (sjme_scritchui_uiComponent
*)outList
,
56 SJME_SCRITCHUI_TYPE_LIST
,
57 (sjme_scritchui_coreGeneric_componentNewImplFunc
)
58 sjme_scritchui_core_listNewWrap
,