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_scrollPanelNew(
15 sjme_attrInNotNull sjme_scritchui inState
,
16 sjme_attrInNotNull sjme_scritchui_uiScrollPanel inScrollPanel
,
17 sjme_attrInNullable sjme_pointer ignored
)
20 WNDCLASSEX windowClass
;
23 if (inState
== NULL
|| inScrollPanel
== NULL
)
24 return SJME_ERROR_NULL_ARGUMENTS
;
26 /* Register window class for this window. */
27 memset(&windowClass
, 0, sizeof(windowClass
));
28 windowClass
.cbSize
= sizeof(windowClass
);
29 windowClass
.style
= CS_VREDRAW
| CS_HREDRAW
| CS_OWNDC
;
30 windowClass
.hInstance
= GetModuleHandle(NULL
);
31 windowClass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
32 windowClass
.lpszClassName
= inScrollPanel
->component
.strId
;
33 windowClass
.lpfnWndProc
= inState
->implIntern
->windowProcWin32
;
35 classAtom
= RegisterClassEx(&windowClass
);
37 return inState
->implIntern
->getLastError(inState
,
38 SJME_ERROR_NATIVE_WIDGET_FAILURE
);
40 /* Create window, child windows must always have a parent. */
42 window
= CreateWindowEx(WS_EX_TRANSPARENT
| WS_EX_RIGHTSCROLLBAR
|
44 inScrollPanel
->component
.strId
,
46 WS_CHILD
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
|
47 WS_HSCROLL
| WS_VSCROLL
,
48 CW_USEDEFAULT
, CW_USEDEFAULT
,
49 CW_USEDEFAULT
, CW_USEDEFAULT
,
50 inState
->common
.handle
[SJME_SUI_WIN32_H_VOID
],
52 GetModuleHandle(NULL
),
55 return inState
->implIntern
->getLastError(inState
,
56 SJME_ERROR_NATIVE_WIDGET_CREATE_FAILED
);
59 inScrollPanel
->component
.common
.handle
[SJME_SUI_WIN32_H_HWND
] = window
;
60 inScrollPanel
->component
.common
.handle
[SJME_SUI_WIN32_H_HWNDATOM
] =
61 (sjme_scritchui_handle
)classAtom
;
63 /* Link back to this panel. */
65 SetWindowLongPtr(window
, GWLP_USERDATA
,
66 (LONG_PTR
)inScrollPanel
);
69 return inState
->implIntern
->getLastError(inState
, SJME_ERROR_NONE
);