Java base for menu initialization; Add base for deletion of ScritchUI objects.
[SquirrelJME.git] / nanocoat / include / lib / scritchui / scritchuiImpl.h
blob157ba5434b9021b92a7a50e63c417eff8a8e446a
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 /**
11 * ScritchUI implementation interface.
13 * @since 2024/04/06
16 #ifndef SQUIRRELJME_SCRITCHUIIMPL_H
17 #define SQUIRRELJME_SCRITCHUIIMPL_H
19 #include "lib/scritchui/scritchui.h"
21 /* Anti-C++. */
22 #ifdef __cplusplus
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_SCRITCHUIIMPL_H
26 extern "C" {
27 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
28 #endif /* #ifdef __cplusplus */
30 /*--------------------------------------------------------------------------*/
32 /**
33 * Obtains the core listener for the given type.
35 * @param item The structure to access.
36 * @param specific The specific listener that is wanted.
37 * @return A pointer to the listener info.
38 * @since 2024/05/01
40 #define SJME_SCRITCHUI_LISTENER_CORE(item, specific) \
41 ((item)->listeners[SJME_SCRITCHUI_LISTENER_CORE].specific)
43 /**
44 * Obtains the user listener for the given type.
46 * @param item The structure to access.
47 * @param specific The specific listener that is wanted.
48 * @return A pointer to the listener info.
49 * @since 2024/05/01
51 #define SJME_SCRITCHUI_LISTENER_USER(item, specific) \
52 ((item)->listeners[SJME_SCRITCHUI_LISTENER_USER].specific)
54 /**
55 * Implementation specific initialization.
57 * @param inState The state being initialized.
58 * @return Any resultant error, if any.
59 * @since 2024/04/15
61 typedef sjme_errorCode (*sjme_scritchui_impl_apiInitFunc)(
62 sjme_attrInNotNull sjme_scritchui inState);
64 /**
65 * Adds the given component to the specified container.
67 * @param inState The input state.
68 * @param inContainer The container to place the component within.
69 * @param addComponent The component to add to the container.
70 * @return Any error code if applicable.
71 * @since 2024/04/20
73 typedef sjme_errorCode (*sjme_scritchui_impl_containerAddFunc)(
74 sjme_attrInNotNull sjme_scritchui inState,
75 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer,
76 sjme_attrInNotNull sjme_scritchui_uiContainer inContainerData,
77 sjme_attrInNotNull sjme_scritchui_uiComponent addComponent);
79 /**
80 * Removes the given component from the specified container.
82 * @param inState The input state.
83 * @param inContainer The container to remove the component within.
84 * @param removeComponent The component to remove from the container.
85 * @return Any error code if applicable.
86 * @since 2024/07/15
88 typedef sjme_errorCode (*sjme_scritchui_impl_containerRemoveFunc)(
89 sjme_attrInNotNull sjme_scritchui inState,
90 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer,
91 sjme_attrInNotNull sjme_scritchui_uiContainer inContainerData,
92 sjme_attrInNotNull sjme_scritchui_uiComponent removeComponent);
94 /**
95 * Creates a new native list.
97 * @param inState The input ScritchUI state.
98 * @param inList The list that was created.
99 * @return Any error code as per implementation.
100 * @since 2024/04/06
102 typedef sjme_errorCode (*sjme_scritchui_impl_listNewFunc)(
103 sjme_attrInNotNull sjme_scritchui inState,
104 sjme_attrInNotNull sjme_scritchui_uiList inList,
105 sjme_attrInValue sjme_scritchui_choiceType inChoiceType);
108 * Creates a new native panel.
110 * @param inState The input ScritchUI state.
111 * @param inPanel The panel that was created.
112 * @return Any error code as per implementation.
113 * @since 2024/04/06
115 typedef sjme_errorCode (*sjme_scritchui_impl_panelNewFunc)(
116 sjme_attrInNotNull sjme_scritchui inState,
117 sjme_attrInNotNull sjme_scritchui_uiPanel inPanel);
120 * Creates a new window.
122 * @param inState The input state.
123 * @param inWindow The window that was created.
124 * @return Any resultant error, if any.
125 * @since 2024/04/24
127 typedef sjme_errorCode (*sjme_scritchui_impl_windowNewFunc)(
128 sjme_attrInNotNull sjme_scritchui inState,
129 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow);
131 #define SJME_SCRITCHUI_QUICK_IMPL(x) \
132 SJME_TOKEN_PASTE3(sjme_scritchui_impl_, x, Func) x
134 /** Uses the same main implementation. */
135 #define SJME_SCRITCHUI_QUICK_SAME(x) \
136 SJME_TOKEN_PASTE3(sjme_scritchui_, x, Func) x
138 struct sjme_scritchui_implFunctions
140 /** Initialize implementation API instance. */
141 SJME_SCRITCHUI_QUICK_IMPL(apiInit);
143 /** Repaint component. */
144 SJME_SCRITCHUI_QUICK_SAME(componentRepaint);
146 /** Revalidate component. */
147 SJME_SCRITCHUI_QUICK_SAME(componentRevalidate);
149 /** Sets the input listener for a component. */
150 SJME_SCRITCHUI_QUICK_SAME(componentSetInputListener);
152 /** Set paint listener for component. */
153 SJME_SCRITCHUI_QUICK_SAME(componentSetPaintListener);
155 /** Set size listener for component. */
156 SJME_SCRITCHUI_QUICK_SAME(componentSetSizeListener);
158 /** Sets the listener for component visible events. */
159 SJME_SCRITCHUI_QUICK_SAME(componentSetVisibleListener);
161 /** Get size of component. */
162 SJME_SCRITCHUI_QUICK_SAME(componentSize);
164 /** Add component to container. */
165 SJME_SCRITCHUI_QUICK_IMPL(containerAdd);
167 /** Remove component from container. */
168 SJME_SCRITCHUI_QUICK_IMPL(containerRemove);
170 /** Set bounds of component in container. */
171 SJME_SCRITCHUI_QUICK_SAME(containerSetBounds);
173 /** Hardware graphics support on arbitrary buffers. */
174 SJME_SCRITCHUI_QUICK_SAME(hardwareGraphics);
176 /** Creates a new native list. */
177 SJME_SCRITCHUI_QUICK_IMPL(listNew);
179 /** Execute callback within the event loop or schedule later. */
180 SJME_SCRITCHUI_QUICK_SAME(loopExecute);
182 /** Execute call later in the loop. */
183 sjme_scritchui_loopExecuteFunc loopExecuteLater;
185 /** Execute callback within the event loop and wait until termination. */
186 sjme_scritchui_loopExecuteFunc loopExecuteWait;
188 /** Enable/disable focus on a panel. */
189 SJME_SCRITCHUI_QUICK_SAME(panelEnableFocus);
191 /** Creates a new native panel. */
192 SJME_SCRITCHUI_QUICK_IMPL(panelNew);
194 /** The available screens. */
195 SJME_SCRITCHUI_QUICK_SAME(screens);
197 /** Set minimum size of content window. */
198 SJME_SCRITCHUI_QUICK_SAME(windowContentMinimumSize);
200 /** Creates a new window. */
201 SJME_SCRITCHUI_QUICK_IMPL(windowNew);
203 /** Set close listener for a window. */
204 SJME_SCRITCHUI_QUICK_SAME(windowSetCloseListener);
206 /** Sets visibility of the window. */
207 SJME_SCRITCHUI_QUICK_SAME(windowSetVisible);
210 #undef SJME_SCRITCHUI_QUICK_IMPL
211 #undef SJME_SCRITCHUI_QUICK_SAME
214 * Returns the choice for the given component.
216 * @param inState The input state.
217 * @param inComponent The input component.
218 * @param outChoice The resultant choice.
219 * @return Any error code if applicable, such as the component is not valid.
220 * @since 2024/07/16
222 typedef sjme_errorCode (*sjme_scritchui_intern_getChoiceFunc)(
223 sjme_attrInNotNull sjme_scritchui inState,
224 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent,
225 sjme_attrInOutNotNull sjme_scritchui_uiChoice* outChoice);
228 * Returns the container for the given component.
230 * @param inState The input state.
231 * @param inComponent The input component.
232 * @param outContainer The resultant container.
233 * @return Any error code if applicable, such as the component is not valid.
234 * @since 2024/04/20
236 typedef sjme_errorCode (*sjme_scritchui_intern_getContainerFunc)(
237 sjme_attrInNotNull sjme_scritchui inState,
238 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent,
239 sjme_attrInOutNotNull sjme_scritchui_uiContainer* outContainer);
242 * Returns the container for the given component.
244 * @param inState The input state.
245 * @param inComponent The input component.
246 * @param outContainer The resultant container.
247 * @return Any error code if applicable, such as the component is not valid.
248 * @since 2024/04/20
250 typedef sjme_errorCode (*sjme_scritchui_intern_getPaintableFunc)(
251 sjme_attrInNotNull sjme_scritchui inState,
252 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent,
253 sjme_attrInOutNotNull sjme_scritchui_uiPaintable* outPaintable);
256 * Common base common initialization for before and after create.
258 * @param inState The input state.
259 * @param inCommon The input common.
260 * @param postCreate Is this after the create call?
261 * @param uiType The type of common this is.
262 * @return Any resultant error, if any.
263 * @since 2024/07/19
265 typedef sjme_errorCode (*sjme_scritchui_intern_initCommonFunc)(
266 sjme_attrInNotNull sjme_scritchui inState,
267 sjme_attrInNotNull sjme_scritchui_uiCommon inCommon,
268 sjme_attrInValue sjme_jboolean postCreate,
269 sjme_attrInRange(0, SJME_NUM_SCRITCHUI_UI_TYPES)
270 sjme_scritchui_uiType uiType);
273 * Common component initialization function for before and after create.
275 * @param inState The input state.
276 * @param inComponent The input component.
277 * @param postCreate Is this after the create call?
278 * @param uiType The type of component this is.
279 * @return Any resultant error, if any.
280 * @since 2024/04/26
282 typedef sjme_errorCode (*sjme_scritchui_intern_initComponentFunc)(
283 sjme_attrInNotNull sjme_scritchui inState,
284 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent,
285 sjme_attrInValue sjme_jboolean postCreate,
286 sjme_attrInRange(0, SJME_NUM_SCRITCHUI_UI_TYPES)
287 sjme_scritchui_uiType uiType);
290 * Maps the given screen internally.
292 * @param inState The input state.
293 * @param screenId The screen ID to map.
294 * @param outScreen The resultant screen, may be newly created or one that
295 * already exists.
296 * @param updateHandle If not @c NULL then the handle is updated to this.
297 * @return Any resultant error, if any.
298 * @since 2024/04/15
300 typedef sjme_errorCode (*sjme_scritchui_intern_mapScreenFunc)(
301 sjme_attrInNotNull sjme_scritchui inState,
302 sjme_attrInValue sjme_jint screenId,
303 sjme_attrInOutNotNull sjme_scritchui_uiScreen* outScreen,
304 sjme_attrInNullable sjme_scritchui_handle updateHandle);
307 * Updates the visibility state of a container.
309 * @param inState The input state.
310 * @param inContainer The input container.
311 * @param isVisible Is this now visible?
312 * @since 2024/06/28
314 typedef sjme_errorCode (*sjme_scritchui_intern_updateVisibleContainerFunc)(
315 sjme_attrInNotNull sjme_scritchui inState,
316 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer,
317 sjme_attrInValue sjme_jboolean isVisible);
320 * Updates the visibility state of a container.
322 * @param inState The input state.
323 * @param inComponent The input component.
324 * @param isVisible Is this now visible?
325 * @since 2024/06/28
327 typedef sjme_errorCode (*sjme_scritchui_intern_updateVisibleComponentFunc)(
328 sjme_attrInNotNull sjme_scritchui inState,
329 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent,
330 sjme_attrInValue sjme_jboolean isVisible);
333 * Updates the visibility state of a window.
335 * @param inState The input state.
336 * @param inWindow The input window.
337 * @param isVisible Is this now visible?
338 * @since 2024/06/28
340 typedef sjme_errorCode (*sjme_scritchui_intern_updateVisibleWindowFunc)(
341 sjme_attrInNotNull sjme_scritchui inState,
342 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow,
343 sjme_attrInValue sjme_jboolean isVisible);
345 struct sjme_scritchui_internFunctions
347 /** Returns the built-in font, this can handle layers. */
348 sjme_scritchui_fontBuiltinFunc fontBuiltin;
350 /** Returns the choice for the given component. */
351 sjme_scritchui_intern_getChoiceFunc getChoice;
353 /** Returns the container for the given component. */
354 sjme_scritchui_intern_getContainerFunc getContainer;
356 /** Returns the paintable for the given component. */
357 sjme_scritchui_intern_getPaintableFunc getPaintable;
359 /** Common "common" initialization. */
360 sjme_scritchui_intern_initCommonFunc initCommon;
362 /** Common component initialization. */
363 sjme_scritchui_intern_initComponentFunc initComponent;
365 /** Maps the given screen. */
366 sjme_scritchui_intern_mapScreenFunc mapScreen;
368 /** Update visibility recursively on container. */
369 sjme_scritchui_intern_updateVisibleContainerFunc updateVisibleContainer;
371 /** Update visibility on component. */
372 sjme_scritchui_intern_updateVisibleComponentFunc updateVisibleComponent;
374 /** Update visibility recursively on window. */
375 sjme_scritchui_intern_updateVisibleWindowFunc updateVisibleWindow;
378 /*--------------------------------------------------------------------------*/
380 /* Anti-C++. */
381 #ifdef __cplusplus
382 #ifdef SJME_CXX_SQUIRRELJME_SCRITCHUIIMPL_H
384 #undef SJME_CXX_SQUIRRELJME_SCRITCHUIIMPL_H
385 #undef SJME_CXX_IS_EXTERNED
386 #endif /* #ifdef SJME_CXX_SQUIRRELJME_SCRITCHUIIMPL_H */
387 #endif /* #ifdef __cplusplus */
389 #endif /* SQUIRRELJME_SCRITCHUIIMPL_H */