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 // -------------------------------------------------------------------------*/
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
||
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. */
32 if (NULL
== SetParent(componentWindow
,
34 return inState
->implIntern
->getLastError(inState
,
35 SJME_ERROR_NOT_SUB_COMPONENT
);
37 /* Make the child window visible. */
39 ShowWindow(componentWindow
, SW_SHOW
);
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
)
53 if (inState
== NULL
|| inContainer
== NULL
|| inContainerData
== NULL
||
54 removeComponent
== NULL
)
55 return SJME_ERROR_NULL_ARGUMENTS
;
58 componentWindow
= removeComponent
->common
.handle
[SJME_SUI_WIN32_H_HWND
];
60 /* Make the child window invisible. */
62 ShowWindow(componentWindow
, SW_HIDE
);
64 /* Reparent window, there should always be a parent returned. */
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
);
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
)
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. */
94 if (0 == MoveWindow(componentWindow
, x
, y
,
96 return inState
->implIntern
->getLastError(inState
,
97 SJME_ERROR_NATIVE_WIDGET_FAILURE
);
100 return inState
->implIntern
->getLastError(inState
, SJME_ERROR_NONE
);