Indentations break the feed.
[SquirrelJME.git] / nanocoat / lib / scritchui / scritchPanel.c
blob3116f13642c95c0a67af869433ece141d2813028
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
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 // -------------------------------------------------------------------------*/
10 #include "lib/scritchui/scritchuiTypes.h"
11 #include "lib/scritchui/core/core.h"
12 #include "sjme/alloc.h"
13 #include "lib/scritchui/core/coreGeneric.h"
15 sjme_errorCode sjme_scritchui_core_panelEnableFocus(
16 sjme_attrInNotNull sjme_scritchui inState,
17 sjme_attrInNotNull sjme_scritchui_uiPanel inPanel,
18 sjme_attrInValue sjme_jboolean enableFocus,
19 sjme_attrInValue sjme_jboolean defaultFocus)
21 sjme_errorCode error;
23 if (inState == NULL || inPanel == NULL)
24 return SJME_ERROR_NULL_ARGUMENTS;
26 if (inState->impl->panelEnableFocus == NULL)
27 return sjme_error_notImplemented(0);
29 /* Forward to native handler. */
30 if (sjme_error_is(error = inState->impl->panelEnableFocus(inState,
31 inPanel, enableFocus, enableFocus && defaultFocus)))
32 return sjme_error_default(error);
34 /* Set new state. */
35 inPanel->enableFocus = enableFocus;
36 inPanel->defaultFocus = defaultFocus;
38 /* If we are removing focus, make sure we are unbound from the window, */
39 /* otherwise we bind to the focus if we are the default. */
40 if (sjme_error_is(error = inState->intern->bindFocus(inState,
41 SJME_SUI_CAST_COMPONENT(inPanel),
42 SJME_SUI_CAST_COMPONENT(inPanel),
43 (enableFocus ? defaultFocus : SJME_JNI_FALSE))))
44 return sjme_error_default(error);
46 /* Success! */
47 return SJME_ERROR_NONE;
50 sjme_errorCode sjme_scritchui_core_panelNew(
51 sjme_attrInNotNull sjme_scritchui inState,
52 sjme_attrInOutNotNull sjme_scritchui_uiPanel* outPanel)
54 if (inState == NULL || outPanel == NULL)
55 return SJME_ERROR_NULL_ARGUMENTS;
57 /* Use generic function. */
58 return sjme_scritchui_coreGeneric_componentNew(inState,
59 (sjme_scritchui_uiComponent*)outPanel,
60 sizeof(**outPanel),
61 SJME_SCRITCHUI_TYPE_PANEL,
62 (sjme_scritchui_coreGeneric_componentNewImplFunc)
63 inState->impl->panelNew,
64 NULL);