When creating threads allow an Id to be returned as well; For Win32 threading, use...
[SquirrelJME.git] / nanocoat / lib / scritchui / win32 / win32Container.c
blob39b8fc487bf844cd9aefdc36787843c499a8abc6
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/win32/win32.h"
12 #include "lib/scritchui/win32/win32Intern.h"
14 sjme_errorCode sjme_scritchui_win32_containerAdd(
15 sjme_attrInNotNull sjme_scritchui inState,
16 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer,
17 sjme_attrInNotNull sjme_scritchui_uiContainer inContainerData,
18 sjme_attrInNotNull sjme_scritchui_uiComponent addComponent)
20 HWND containerWindow, componentWindow;
22 if (inState == NULL || inContainer == NULL || inContainerData == NULL ||
23 addComponent == NULL)
24 return SJME_ERROR_NULL_ARGUMENTS;
26 /* Recover windows. */
27 containerWindow = inContainer->common.handle[SJME_SUI_WIN32_H_HWND];
28 componentWindow = addComponent->common.handle[SJME_SUI_WIN32_H_HWND];
30 /* Reparent window, there should always be a parent returned. */
31 SetLastError(0);
32 if (NULL == SetParent(componentWindow,
33 containerWindow))
34 return inState->implIntern->getLastError(inState,
35 SJME_ERROR_NOT_SUB_COMPONENT);
37 /* Make the child window visible. */
38 SetLastError(0);
39 ShowWindow(componentWindow, SW_SHOW);
41 /* Success? */
42 return inState->implIntern->getLastError(inState, SJME_ERROR_NONE);
45 sjme_errorCode sjme_scritchui_win32_containerRemove(
46 sjme_attrInNotNull sjme_scritchui inState,
47 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer,
48 sjme_attrInNotNull sjme_scritchui_uiContainer inContainerData,
49 sjme_attrInNotNull sjme_scritchui_uiComponent removeComponent)
51 HWND componentWindow;
53 if (inState == NULL || inContainer == NULL || inContainerData == NULL ||
54 removeComponent == NULL)
55 return SJME_ERROR_NULL_ARGUMENTS;
57 /* Recover window. */
58 componentWindow = removeComponent->common.handle[SJME_SUI_WIN32_H_HWND];
60 /* Make the child window invisible. */
61 SetLastError(0);
62 ShowWindow(componentWindow, SW_HIDE);
64 /* Reparent window, there should always be a parent returned. */
65 SetLastError(0);
66 if (NULL == SetParent(componentWindow,
67 inState->common.handle[SJME_SUI_WIN32_H_VOID]))
68 return inState->implIntern->getLastError(inState,
69 SJME_ERROR_NOT_SUB_COMPONENT);
71 /* Success? */
72 return inState->implIntern->getLastError(inState, SJME_ERROR_NONE);
75 sjme_errorCode sjme_scritchui_win32_containerSetBounds(
76 sjme_attrInNotNull sjme_scritchui inState,
77 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer,
78 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent,
79 sjme_attrInPositive sjme_jint x,
80 sjme_attrInPositive sjme_jint y,
81 sjme_attrInPositiveNonZero sjme_jint width,
82 sjme_attrInPositiveNonZero sjme_jint height)
84 HWND componentWindow;
86 if (inState == NULL || inContainer == NULL || inComponent == NULL)
87 return SJME_ERROR_NULL_ARGUMENTS;
89 /* Get the component to modify. */
90 componentWindow = inComponent->common.handle[SJME_SUI_WIN32_H_HWND];
92 /* We can just do a normal window move. */
93 SetLastError(0);
94 if (0 == MoveWindow(componentWindow, x, y,
95 width, height, TRUE))
96 return inState->implIntern->getLastError(inState,
97 SJME_ERROR_NATIVE_WIDGET_FAILURE);
99 /* Success? */
100 return inState->implIntern->getLastError(inState, SJME_ERROR_NONE);