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 // -------------------------------------------------------------------------*/
11 * ScritchUI Library Header.
16 #ifndef SQUIRRELJME_SCRITCHUI_H
17 #define SQUIRRELJME_SCRITCHUI_H
19 #include "sjme/config.h"
20 #include "sjme/multithread.h"
21 #include "sjme/tokenUtils.h"
22 #include "sjme/gfxConst.h"
23 #include "sjme/stdTypes.h"
24 #include "sjme/list.h"
25 #include "sjme/native.h"
26 #include "lib/scritchinput/scritchinput.h"
27 #include "sjme/alloc.h"
28 #include "sjme/dylib.h"
32 #ifndef SJME_CXX_IS_EXTERNED
33 #define SJME_CXX_IS_EXTERNED
34 #define SJME_CXX_SQUIRRELJME_SCRITCHUI_H
36 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
37 #endif /* #ifdef __cplusplus */
39 /*--------------------------------------------------------------------------*/
42 * Represents the type that this is.
46 typedef enum sjme_scritchui_uiType
49 SJME_SCRITCHUI_TYPE_RESERVED
,
52 SJME_SCRITCHUI_TYPE_FONT
,
55 SJME_SCRITCHUI_TYPE_LIST
,
58 SJME_SCRITCHUI_TYPE_MENU
,
61 SJME_SCRITCHUI_TYPE_MENU_BAR
,
64 SJME_SCRITCHUI_TYPE_MENU_ITEM
,
67 SJME_SCRITCHUI_TYPE_PANEL
,
70 SJME_SCRITCHUI_TYPE_PENCIL
,
73 SJME_SCRITCHUI_TYPE_ROOT_STATE
,
76 SJME_SCRITCHUI_TYPE_SCREEN
,
79 SJME_SCRITCHUI_TYPE_SCROLL_PANEL
,
82 SJME_SCRITCHUI_TYPE_WINDOW
,
84 /** The number of possible types. */
85 SJME_NUM_SCRITCHUI_UI_TYPES
86 } sjme_scritchui_uiType
;
88 /** Generic cast check. */
89 #define SJME_SUI_CAST(uiType, type, v) \
90 ((type)sjme_scritchui_checkCast((type), (v)))
93 #define SJME_SUI_CAST_COMMON(v) \
94 ((sjme_scritchui_uiCommon)(v))
96 /** Check cast to menu kind. */
97 #define SJME_SUI_CAST_MENU_KIND(v) \
98 ((sjme_scritchui_uiMenuKind)sjme_scritchui_checkCast_menuKind((v)))
100 /** Check cast to component kind. */
101 #define SJME_SUI_CAST_COMPONENT(v) \
102 ((sjme_scritchui_uiComponent)sjme_scritchui_checkCast_component((v)))
104 /** Check cast to panel. */
105 #define SJME_SUI_CAST_PANEL(v) \
106 SJME_SUI_CAST(SJME_SCRITCHUI_TYPE_PANEL, \
107 sjme_scritchui_uiPanel, (v))
109 /** Check cast to menu. */
110 #define SJME_SUI_CAST_MENU(v) \
111 SJME_SUI_CAST(SJME_SCRITCHUI_TYPE_MENU, \
112 sjme_scritchui_uiMenu, (v))
114 /** Check cast to menu bar. */
115 #define SJME_SUI_CAST_MENU_BAR(v) \
116 SJME_SUI_CAST(SJME_SCRITCHUI_TYPE_MENU_BAR, \
117 sjme_scritchui_uiMenuBar, (v))
119 /** Check cast to menu item. */
120 #define SJME_SUI_CAST_MENU_ITEM(v) \
121 SJME_SUI_CAST(SJME_SCRITCHUI_TYPE_MENU_Item, \
122 sjme_scritchui_uiMenuItem, (v))
125 * An opaque native handle.
129 typedef sjme_pointer sjme_scritchui_handle
;
132 * API Flags for ScritchUI.
136 typedef enum sjme_scritchui_apiFlag
138 /** Only panels are supported for this interface. */
139 SJME_SCRITCHUI_API_FLAG_PANEL_ONLY
= 1,
140 } sjme_scritchui_apiFlag
;
143 * Which type of screen update has occurred?
147 typedef enum sjme_scritchui_screenUpdateType
150 SJME_SCRITCHUI_SCREEN_UPDATE_UNKNOWN
,
153 SJME_SCRITCHUI_SCREEN_UPDATE_NEW
,
155 /** Deleted screen. */
156 SJME_SCRITCHUI_SCREEN_UPDATE_DELETED
,
158 /** Updated screen (resolution, color, etc.) */
159 SJME_SCRITCHUI_SCREEN_UPDATE_CHANGED
,
161 /** The number of update types. */
162 SJME_SCRITCHUI_NUM_SCREEN_UPDATE
163 } sjme_scritchui_screenUpdateType
;
166 * The type of window manager that is used.
170 typedef enum sjme_scritchui_windowManagerType
172 /** One frame per screen. */
173 SJME_SCRITCHUI_WM_TYPE_ONE_FRAME_PER_SCREEN
= 0,
175 /** Standard desktop interface. */
176 SJME_SCRITCHUI_WM_TYPE_STANDARD_DESKTOP
= 1,
178 /** The number of window manager types. */
179 SJME_SCRITCHUI_NUM_WM_TYPES
180 } sjme_scritchui_windowManagerType
;
183 * Font style for pencil fonts.
187 typedef enum sjme_scritchui_pencilFontStyle
190 SJME_SCRITCHUI_PENCIL_FONT_STYLE_BOLD
= 1,
192 /** Italic (slanted) text. */
193 SJME_SCRITCHUI_PENCIL_FONT_STYLE_ITALIC
= 2,
195 /** Underlined text. */
196 SJME_SCRITCHUI_PENCIL_FONT_STYLE_UNDERLINED
= 4,
199 SJME_SCRITCHUI_PENCIL_FONT_STYLE_ALL
=
200 SJME_SCRITCHUI_PENCIL_FONT_STYLE_BOLD
|
201 SJME_SCRITCHUI_PENCIL_FONT_STYLE_ITALIC
|
202 SJME_SCRITCHUI_PENCIL_FONT_STYLE_UNDERLINED
,
203 } sjme_scritchui_pencilFontStyle
;
206 * Represents the type of choice that a choice selection may be.
210 typedef enum sjme_scritchui_choiceType
212 /** Only one element may be selected at a time. */
213 SJME_SCRITCHUI_CHOICE_TYPE_EXCLUSIVE
= 0,
216 * The item that is focused is always the only one selected, pressing an
217 * action key (like enter/space) will activate the item.
219 SJME_SCRITCHUI_CHOICE_TYPE_IMPLICIT
= 1,
221 /** Any number of items may be selected. */
222 SJME_SCRITCHUI_CHOICE_TYPE_MULTIPLE
= 2,
224 /** The number of choice types. */
225 SJME_SCRITCHUI_NUM_CHOICE_TYPES
= 3,
226 } sjme_scritchui_choiceType
;
229 * The element color type for look and feel.
233 typedef enum sjme_scritchui_lafElementColorType
235 /** Background color. */
236 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_BACKGROUND
= 0,
239 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_BORDER
= 1,
241 /** Foreground color. */
242 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_FOREGROUND
= 2,
244 /** Highlighted background color. */
245 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_HIGHLIGHTED_BACKGROUND
= 3,
247 /** Highlighted border color. */
248 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_HIGHLIGHTED_BORDER
= 4,
250 /** Highlighted foreground color. */
251 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_HIGHLIGHTED_FOREGROUND
= 5,
254 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_FOCUS_BORDER
= 6,
256 /** Panel background color. */
257 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_PANEL_BACKGROUND
= 7,
259 /** Panel foreground color. */
260 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_PANEL_FOREGROUND
= 8,
262 /** Top accent color. */
263 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_ACCENT_TOP
= 9,
265 /** Bottom accent color. */
266 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_ACCENT_BOTTOM
= 10,
268 /** The number of element colors. */
269 SJME_SCRITCHUI_NUM_LAF_ELEMENT_COLOR
= 11,
270 } sjme_scritchui_lafElementColorType
;
273 * Represents a point.
277 typedef struct sjme_scritchui_point
284 } sjme_scritchui_point
;
291 typedef struct sjme_scritchui_line
293 /** Starting point. */
294 sjme_scritchui_point s
;
297 sjme_scritchui_point e
;
298 } sjme_scritchui_line
;
301 * Represents a dimension.
305 typedef struct sjme_scritchui_dim
312 } sjme_scritchui_dim
;
315 * Represents a rectangle.
319 typedef struct sjme_scritchui_rect
321 /** The starting point of the rectangle. */
322 sjme_scritchui_point s
;
324 /** The dimension of the rect. */
325 sjme_scritchui_dim d
;
326 } sjme_scritchui_rect
;
333 typedef struct sjme_scritchui_stateBase
* sjme_scritchui
;
336 * ScritchUI API functions, implemented by a native library accordingly.
340 typedef struct sjme_scritchui_apiFunctions sjme_scritchui_apiFunctions
;
343 * ScritchUI implementation functions.
347 typedef struct sjme_scritchui_implFunctions sjme_scritchui_implFunctions
;
350 * Internal ScritchUI API functions.
354 typedef struct sjme_scritchui_internFunctions sjme_scritchui_internFunctions
;
357 * Common data structure shared by everything in ScritchUI.
361 typedef struct sjme_scritchui_uiCommonBase sjme_scritchui_uiCommonBase
;
364 * Common data pointer, which is shared by everything in ScritchUI.
368 typedef sjme_scritchui_uiCommonBase
* sjme_scritchui_uiCommon
;
371 * Represents a choice of options such as those in a list.
375 typedef struct sjme_scritchui_uiChoiceBase
* sjme_scritchui_uiChoice
;
378 * Represents a single choice item.
382 typedef struct sjme_scritchui_uiChoiceItemBase sjme_scritchui_uiChoiceItemBase
;
385 * Represents a single choice item.
389 typedef struct sjme_scritchui_uiChoiceItemBase
* sjme_scritchui_uiChoiceItem
;
392 * Component within ScritchUI.
396 typedef struct sjme_scritchui_uiComponentBase
* sjme_scritchui_uiComponent
;
399 * Represents a container which can contain other components.
403 typedef struct sjme_scritchui_uiContainerBase
* sjme_scritchui_uiContainer
;
406 * Represents a component which can have a label.
410 typedef struct sjme_scritchui_uiLabeledBase sjme_scritchui_uiLabeledBase
;
413 * Represents a component which can have a label.
417 typedef sjme_scritchui_uiLabeledBase
* sjme_scritchui_uiLabeled
;
420 * Base paintable for ScritchUI.
424 typedef struct sjme_scritchui_uiPaintableBase
* sjme_scritchui_uiPaintable
;
427 * A panel within ScritchUI.
431 typedef struct sjme_scritchui_uiPanelBase sjme_scritchui_uiPanelBase
;
434 * A panel within ScritchUI.
438 typedef sjme_scritchui_uiPanelBase
* sjme_scritchui_uiPanel
;
441 * A list within ScritchUI.
445 typedef struct sjme_scritchui_uiListBase
* sjme_scritchui_uiList
;
448 * A menu that has children.
452 typedef struct sjme_scritchui_uiMenuHasChildrenBase
453 sjme_scritchui_uiMenuHasChildrenBase
;
456 * A ScritchUI menu kind
460 typedef struct sjme_scritchui_uiMenuKindBase sjme_scritchui_uiMenuKindBase
;
463 * A ScritchUI menu kind
467 typedef sjme_scritchui_uiMenuKindBase
* sjme_scritchui_uiMenuKind
;
470 * A menu that has children.
474 typedef sjme_scritchui_uiMenuHasChildrenBase
* sjme_scritchui_uiMenuHasChildren
;
477 * A menu that has a parent.
481 typedef struct sjme_scritchui_uiMenuHasParentBase
482 sjme_scritchui_uiMenuHasParentBase
;
485 * A menu that has a parent.
489 typedef sjme_scritchui_uiMenuHasParentBase
* sjme_scritchui_uiMenuHasParent
;
492 * A menu within ScritchUI.
496 typedef struct sjme_scritchui_uiMenuBase
* sjme_scritchui_uiMenu
;
499 * A menu bar within ScritchUI.
503 typedef struct sjme_scritchui_uiMenuBarBase
* sjme_scritchui_uiMenuBar
;
506 * A menu item within ScritchUI.
510 typedef struct sjme_scritchui_uiMenuItemBase
* sjme_scritchui_uiMenuItem
;
513 * A single monitor screen on the display for ScritchUI.
517 typedef struct sjme_scritchui_uiScreenBase
* sjme_scritchui_uiScreen
;
519 /** A list of screens. */
520 SJME_LIST_DECLARE(sjme_scritchui_uiScreen
, 0);
523 * A panel which can also be scrolled.
527 typedef struct sjme_scritchui_uiScrollPanelBase
* sjme_scritchui_uiScrollPanel
;
530 * Viewport manager information for any widget that is a viewport.
534 typedef struct sjme_scritchui_uiViewBase sjme_scritchui_uiViewBase
;
537 * Viewport manager information for any widget that is a viewport.
541 typedef sjme_scritchui_uiViewBase
* sjme_scritchui_uiView
;
544 * A window within ScritchUI.
548 typedef struct sjme_scritchui_uiWindowBase
* sjme_scritchui_uiWindow
;
551 * ScritchUI Pencil state.
555 typedef struct sjme_scritchui_pencilBase
* sjme_scritchui_pencil
;
558 * Font structure for ScritchUI Pencil.
562 typedef struct sjme_scritchui_pencilFontBase
* sjme_scritchui_pencilFont
;
565 * A single link within a loaded/known font chain.
569 typedef struct sjme_scritchui_pencilFontLink sjme_scritchui_pencilFontLink
;
572 * Utility functions to help in implementations or otherwise perform some
577 typedef struct sjme_scritchui_pencilUtilFunctions
578 sjme_scritchui_pencilUtilFunctions
;
581 * Functions which are used to lock and unlock access to the backing pencil
582 * buffer, if applicable.
586 typedef struct sjme_scritchui_pencilLockFunctions
587 sjme_scritchui_pencilLockFunctions
;
589 /** Arguments to pass for setting of listeners. */
590 #define SJME_SCRITCHUI_SET_LISTENER_ARGS(what) \
591 sjme_attrInNullable SJME_TOKEN_PASTE3(sjme_scritchui_, what, \
592 ListenerFunc) inListener, \
593 sjme_attrInNullable sjme_frontEnd* copyFrontEnd
596 * Listener that is called when an item is activated.
598 * @param inState The input state.
599 * @param inComponent The item which was activated.
600 * @return Any resultant error, if any.
603 typedef sjme_errorCode (*sjme_scritchui_activateListenerFunc
)(
604 sjme_attrInNotNull sjme_scritchui inState
,
605 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
);
608 * Listener that is called when a window closes.
610 * @param inState The input state.
611 * @param inWindow The window being closed.
612 * @return Any resultant error, @c SJME_ERROR_CANCEL_WINDOW_CLOSE is handled
613 * specifically in that it will not be treated as an error however normal
614 * application exit will not happen.
617 typedef sjme_errorCode (*sjme_scritchui_closeListenerFunc
)(
618 sjme_attrInNotNull sjme_scritchui inState
,
619 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
);
622 * Listener for input events.
624 * @param inState The input state.
625 * @param inComponent The component this event is for.
626 * @param inEvent The event which occurred.
627 * @return Any resultant error, if any.
630 typedef sjme_errorCode (*sjme_scritchui_inputListenerFunc
)(
631 sjme_attrInNotNull sjme_scritchui inState
,
632 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
633 sjme_attrInNotNull
const sjme_scritchinput_event
* inEvent
);
636 * This is called when a menu item has been activated.
638 * @param inState The input state.
639 * @param inWindow The window this is activating under.
640 * @param activatedItem The menu item that was activated.
641 * @return Any resultant error, if any.
644 typedef sjme_errorCode (*sjme_scritchui_menuItemActivateListenerFunc
)(
645 sjme_attrInNotNull sjme_scritchui inState
,
646 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
647 sjme_attrInNotNull sjme_scritchui_uiMenuKind activatedItem
);
650 * Callback that is used to draw the given component.
652 * @param inState The ScritchUI state.
653 * @param inComponent The component to draw on.
654 * @param g The graphics used for drawing.
655 * @param sw Surface width.
656 * @param sh Surface height.
657 * @param special Special value for painting, may be @c 0 or any
658 * other value if it is meaningful to what is being painted.
659 * @return Any error as required.
662 typedef sjme_errorCode (*sjme_scritchui_paintListenerFunc
)(
663 sjme_attrInNotNull sjme_scritchui inState
,
664 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
665 sjme_attrInNotNull sjme_scritchui_pencil g
,
666 sjme_attrInPositive sjme_jint sw
,
667 sjme_attrInPositive sjme_jint sh
,
668 sjme_attrInValue sjme_jint special
);
671 * Listener callback for when a screen has been queried or it has been
674 * @param inState The input state.
675 * @param updateType The type of update this is for.
676 * @param inScreen The screen that has been updated.
677 * @return Any error code if applicable.
680 typedef sjme_errorCode (*sjme_scritchui_screenListenerFunc
)(
681 sjme_attrInNotNull sjme_scritchui inState
,
682 sjme_attrInValue sjme_scritchui_screenUpdateType updateType
,
683 sjme_attrInNotNull sjme_scritchui_uiScreen inScreen
);
686 * Listener that is called when the size of a component changes.
688 * @param inState The input state.
689 * @param inComponent The component that was resized.
690 * @param newWidth The new component width.
691 * @param newHeight The new component height.
692 * @return On any error if applicable.
695 typedef sjme_errorCode (*sjme_scritchui_sizeListenerFunc
)(
696 sjme_attrInNotNull sjme_scritchui inState
,
697 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
698 sjme_attrInPositiveNonZero sjme_jint newWidth
,
699 sjme_attrInPositiveNonZero sjme_jint newHeight
);
702 * Listener for views so that a sub-component can suggest a size that it
705 * @param inState The ScritchUI state.
706 * @param inView The view this is in.
707 * @param subComponent The component that is suggesting a size.
708 * @param subDim The size of the sub-component.
709 * @return Any resultant error, if any.
712 typedef sjme_errorCode (*sjme_scritchui_sizeSuggestListenerFunc
)(
713 sjme_attrInNotNull sjme_scritchui inState
,
714 sjme_attrInNotNull sjme_scritchui_uiComponent inView
,
715 sjme_attrInNotNull sjme_scritchui_uiComponent subComponent
,
716 sjme_attrInNotNull
const sjme_scritchui_dim
* subDim
);
719 * Listener that is called before and after the state within a component
720 * has changed, when @c isAfterUpdate is @c SJME_JNI_FALSE then the component
721 * is about to be updated.
723 * @param inState The input state.
724 * @param inComponent The component where this event occurred.
725 * @param isAfterUpdate Is this after the update has occurred?
726 * @return Any resultant error, if any.
729 typedef sjme_errorCode (*sjme_scritchui_valueUpdateListenerFunc
)(
730 sjme_attrInNotNull sjme_scritchui inState
,
731 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
732 sjme_attrInValue sjme_jboolean isAfterUpdate
);
735 * Listener for view rectangle changes.
737 * @param inState The input state.
738 * @param inComponent The component that triggered this.
739 * @param inViewRect The new view rectangle.
740 * @return Any resultant error, if any.
743 typedef sjme_errorCode (*sjme_scritchui_viewListenerFunc
)(
744 sjme_attrInNotNull sjme_scritchui inState
,
745 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
746 sjme_attrInNotNull
const sjme_scritchui_rect
* inViewRect
);
749 * Listener for changes in if a component becomes visible or not.
751 * @param inState The input state.
752 * @param inComponent The component which has its visibility changed.
753 * @param fromVisible The previous visible state.
754 * @param toVisible The current visible state.
755 * @return Any resultant error, if any.
758 typedef sjme_errorCode (*sjme_scritchui_visibleListenerFunc
)(
759 sjme_attrInNotNull sjme_scritchui inState
,
760 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
761 sjme_attrInValue sjme_jboolean fromVisible
,
762 sjme_attrInValue sjme_jboolean toVisible
);
764 /** Void listener function. */
765 typedef sjme_errorCode (*sjme_scritchui_voidListenerFunc
)(void);
768 * Obtains the flags which describe the interface.
770 * @param inState The input ScritchUI state.
771 * @param outFlags The output flags for this interface.
772 * @return Any error code if applicable.
775 typedef sjme_errorCode (*sjme_scritchui_apiFlagsFunc
)(
776 sjme_attrInNotNull sjme_scritchui inState
,
777 sjme_attrOutNotNull sjme_jint outFlags
);
780 * Initializes the native UI interface needed by ScritchUI.
782 * @param inPool The allocation pool to use.
783 * @param outState The resultant state.
784 * @param inImplFunc The implementation functions to use.
785 * @param loopExecute Optional callback for loop execution, may be @c NULL ,
786 * the passed argument is always the state.
787 * @param initFrontEnd Optional initial front end data.
788 * @return Any error code if applicable.
791 typedef sjme_errorCode (*sjme_scritchui_apiInitFunc
)(
792 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
793 sjme_attrInOutNotNull sjme_scritchui
* outState
,
794 sjme_attrInNotNull
const sjme_scritchui_implFunctions
* inImplFunc
,
795 sjme_attrInNullable sjme_thread_mainFunc loopExecute
,
796 sjme_attrInNullable sjme_frontEnd
* initFrontEnd
);
799 * Gets the first selected index of a choice or otherwise @c -1 .
801 * @param inState The input state.
802 * @param inComponent The choice to read from.
803 * @param outIndex The resultant index.
804 * @return Any resultant error, if any.
807 typedef sjme_errorCode (*sjme_scritchui_choiceGetSelectedIndexFunc
)(
808 sjme_attrInNotNull sjme_scritchui inState
,
809 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
810 sjme_attrOutNotNull sjme_jint
* outIndex
);
813 * Gets the specified item template.
815 * @param inState The input state.
816 * @param inComponent The choice to read from.
817 * @param atIndex The index to obtain the template of.
818 * @param inItemTemplate A copy of the item template.
819 * @return Any resultant error, if any.
822 typedef sjme_errorCode (*sjme_scritchui_choiceItemGetFunc
)(
823 sjme_attrInNotNull sjme_scritchui inState
,
824 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
825 sjme_attrInPositive sjme_jint atIndex
,
826 sjme_attrOutNotNull sjme_scritchui_uiChoiceItem outItemTemplate
);
829 * Inserts a blank item at the given index.
831 * @param inState The input state.
832 * @param inComponent The choice to modify.
833 * @param inOutIndex The input index to insert at, then resultant index
834 * where it was added.
835 * @return Any resultant error, if any.
838 typedef sjme_errorCode (*sjme_scritchui_choiceItemInsertFunc
)(
839 sjme_attrInNotNull sjme_scritchui inState
,
840 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
841 sjme_attrInOutNotNull sjme_jint
* inOutIndex
);
844 * Removes the specified item at the given index.
846 * @param inState The input state.
847 * @param inComponent The choice to modify.
848 * @param atIndex The index to remove.
849 * @return Any resultant error, if any.
852 typedef sjme_errorCode (*sjme_scritchui_choiceItemRemoveFunc
)(
853 sjme_attrInNotNull sjme_scritchui inState
,
854 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
855 sjme_attrInPositive sjme_jint atIndex
);
858 * Removes all items from the given choice.
860 * @param inState The input state.
861 * @param inComponent The choice to modify.
862 * @return Any resultant error, if any.
865 typedef sjme_errorCode (*sjme_scritchui_choiceItemRemoveAllFunc
)(
866 sjme_attrInNotNull sjme_scritchui inState
,
867 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
);
871 * Sets whether the specified choice item is enabled.
873 * @param inState The input state.
874 * @param inComponent The choice to modify.
875 * @param atIndex The index to modify.
876 * @param isEnabled If the item should be enabled.
877 * @return Any resultant error, if any.
880 typedef sjme_errorCode (*sjme_scritchui_choiceItemSetEnabledFunc
)(
881 sjme_attrInNotNull sjme_scritchui inState
,
882 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
883 sjme_attrInPositive sjme_jint atIndex
,
884 sjme_attrInNotNull sjme_jboolean isEnabled
);
887 * Sets the image of the specified choice item.
889 * @param inState The input state.
890 * @param inComponent The choice to modify.
891 * @param atIndex The index to modify.
892 * @param inRgb The RGB data, may be @c NULL to clear the image.
893 * @param inRgbOff The offset in the RGB data.
894 * @param inRgbDataLen The data length of the RGB data.
895 * @param inRgbScanLen The scanline length of the RGB data.
896 * @param width The width of the image.
897 * @param height The height of the image.
898 * @return Any resultant error, if any.
901 typedef sjme_errorCode (*sjme_scritchui_choiceItemSetImageFunc
)(
902 sjme_attrInNotNull sjme_scritchui inState
,
903 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
904 sjme_attrInPositive sjme_jint atIndex
,
905 sjme_attrInNullable sjme_jint
* inRgb
,
906 sjme_attrInPositive sjme_jint inRgbOff
,
907 sjme_attrInPositiveNonZero sjme_jint inRgbDataLen
,
908 sjme_attrInPositiveNonZero sjme_jint inRgbScanLen
,
909 sjme_attrInPositiveNonZero sjme_jint width
,
910 sjme_attrInPositiveNonZero sjme_jint height
);
913 * Sets whether the specified choice item is selected.
915 * @param inState The input state.
916 * @param inComponent The choice to modify.
917 * @param atIndex The index to modify.
918 * @param isSelected If the item should be selected.
919 * @return Any resultant error, if any.
922 typedef sjme_errorCode (*sjme_scritchui_choiceItemSetSelectedFunc
)(
923 sjme_attrInNotNull sjme_scritchui inState
,
924 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
925 sjme_attrInPositive sjme_jint atIndex
,
926 sjme_attrInNotNull sjme_jboolean isSelected
);
929 * Sets the string of the specified choice item.
931 * @param inState The input state.
932 * @param inComponent The choice to modify.
933 * @param atIndex The index to modify.
934 * @param inString The string to set, @c NULL will clear it.
935 * @return Any resultant error, if any.
938 typedef sjme_errorCode (*sjme_scritchui_choiceItemSetStringFunc
)(
939 sjme_attrInNotNull sjme_scritchui inState
,
940 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
941 sjme_attrInPositive sjme_jint atIndex
,
942 sjme_attrInNullable sjme_lpcstr inString
);
945 * Returns the length of the choice list.
947 * @param inState The input state.
948 * @param inComponent The choice to get the length of.
949 * @param outLength The resultant length.
950 * @return Any resultant error, if any.
953 typedef sjme_errorCode (*sjme_scritchui_choiceLengthFunc
)(
954 sjme_attrInNotNull sjme_scritchui inState
,
955 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
956 sjme_attrOutNotNull sjme_jint
* outLength
);
959 * Grabs the focus onto this item.
961 * @param inState The input state.
962 * @param inComponent The input component.
963 * @return Any resultant error, if any.
966 typedef sjme_errorCode (*sjme_scritchui_componentFocusGrabFunc
)(
967 sjme_attrInNotNull sjme_scritchui inState
,
968 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
);
971 * Checks whether the given component has focus.
973 * @param inState The input state.
974 * @param inComponent The input component.
975 * @param outHasFocus The result of whether the component has focus.
976 * @return Any resultant error, if any.
979 typedef sjme_errorCode (*sjme_scritchui_componentFocusHasFunc
)(
980 sjme_attrInNotNull sjme_scritchui inState
,
981 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
982 sjme_attrOutNotNull sjme_jboolean
* outHasFocus
);
985 * Gets the parent of this component.
987 * @param inState The ScritchUI state.
988 * @param inComponent The component to get the parent of.
989 * @param outParent The resultant parent that contains this, or @c NULL if
990 * there is no parent.
991 * @return Any resultant error, if any.
994 typedef sjme_errorCode (*sjme_scritchui_componentGetParentFunc
)(
995 sjme_attrInNotNull sjme_scritchui inState
,
996 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
997 sjme_attrOutNotNull sjme_scritchui_uiComponent
* outParent
);
1000 * Returns the position of the given component.
1002 * @param inState The input state.
1003 * @param inComponent The component to get the position of.
1004 * @param outX The output X coordinate.
1005 * @param outY The output Y coordinate.
1006 * @return Any resultant error, if any.
1009 typedef sjme_errorCode (*sjme_scritchui_componentPositionFunc
)(
1010 sjme_attrInNotNull sjme_scritchui inState
,
1011 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1012 sjme_attrOutNullable sjme_jint
* outX
,
1013 sjme_attrOutNullable sjme_jint
* outY
);
1016 * Repaints the given component.
1018 * @param inState The input state.
1019 * @param inComponent The input component.
1020 * @param x The X position.
1021 * @param y The Y position.
1022 * @param width The width.
1023 * @param height The height.
1024 * @return Any error code if applicable.
1027 typedef sjme_errorCode (*sjme_scritchui_componentRepaintFunc
)(
1028 sjme_attrInNotNull sjme_scritchui inState
,
1029 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1030 sjme_attrInPositive sjme_jint x
,
1031 sjme_attrInPositive sjme_jint y
,
1032 sjme_attrInPositiveNonZero sjme_jint width
,
1033 sjme_attrInPositiveNonZero sjme_jint height
);
1036 * Revalidates the given component.
1038 * @param inState The input state.
1039 * @param inComponent The component to be revalidated.
1040 * @return On any error if applicable.
1043 typedef sjme_errorCode (*sjme_scritchui_componentRevalidateFunc
)(
1044 sjme_attrInNotNull sjme_scritchui inState
,
1045 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
);
1048 * Sets the activation listener for the given choice.
1050 * @param inState The input state.
1051 * @param inComponent The choice to update.
1052 * @param inListener The listener to set.
1053 * @param copyFrontEnd Any front end data to copy.
1054 * @return Any resultant error, if any.
1057 typedef sjme_errorCode (*sjme_scritchui_componentSetActivateListenerFunc
)(
1058 sjme_attrInNotNull sjme_scritchui inState
,
1059 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1060 SJME_SCRITCHUI_SET_LISTENER_ARGS(activate
));
1063 * Sets the input listener for the given component.
1065 * @param inState The input state.
1066 * @param inComponent The component to set the listener for.
1067 * @param inListener The listener for events, may be @c NULL to clear
1068 * the existing listener.
1069 * @param copyFrontEnd The front end data to copy, may be @c NULL .
1070 * @return Any resultant error, if any.
1073 typedef sjme_errorCode (*sjme_scritchui_componentSetInputListenerFunc
)(
1074 sjme_attrInNotNull sjme_scritchui inState
,
1075 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1076 SJME_SCRITCHUI_SET_LISTENER_ARGS(input
));
1079 * Sets the paint listener for the given component.
1081 * @param inState The input state.
1082 * @param inComponent The component to set the listener for.
1083 * @param inListener The listener for paint events, may be @c NULL to clear
1084 * the existing listener.
1085 * @param copyFrontEnd The front end data to copy, may be @c NULL .
1086 * @return Any error code if applicable.
1089 typedef sjme_errorCode (*sjme_scritchui_componentSetPaintListenerFunc
)(
1090 sjme_attrInNotNull sjme_scritchui inState
,
1091 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1092 SJME_SCRITCHUI_SET_LISTENER_ARGS(paint
));
1095 * Sets the listener for size events.
1097 * @param inState The input state.
1098 * @param inComponent The component to set the listener for.
1099 * @param inListener The listener to set to or to clear.
1100 * @param copyFrontEnd Any front end data to be copied.
1101 * @return Any resultant error, if any.
1104 typedef sjme_errorCode (*sjme_scritchui_componentSetSizeListenerFunc
)(
1105 sjme_attrInNotNull sjme_scritchui inState
,
1106 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1107 SJME_SCRITCHUI_SET_LISTENER_ARGS(size
));
1110 * Sets the update listener for the given choice.
1112 * @param inState The input state.
1113 * @param inComponent The choice to update.
1114 * @param inListener The listener to set.
1115 * @param copyFrontEnd Any front end data to copy.
1116 * @return Any resultant error, if any.
1119 typedef sjme_errorCode (*sjme_scritchui_componentSetValueUpdateListenerFunc
)(
1120 sjme_attrInNotNull sjme_scritchui inState
,
1121 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1122 SJME_SCRITCHUI_SET_LISTENER_ARGS(valueUpdate
));
1125 * Sets the listener to call when the visibility of a component changes.
1127 * @param inState The input state.
1128 * @param inComponent The component to set for.
1129 * @param inListener The listener to use.
1130 * @param copyFrontEnd The front end data to use.
1131 * @return Any resultant error, if any.
1134 typedef sjme_errorCode (*sjme_scritchui_componentSetVisibleListenerFunc
)(
1135 sjme_attrInNotNull sjme_scritchui inState
,
1136 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1137 SJME_SCRITCHUI_SET_LISTENER_ARGS(visible
));
1140 * Returns the size of the given component.
1142 * @param inState The input state.
1143 * @param inComponent The component to get the size of.
1144 * @param outWidth The output width.
1145 * @param outHeight The output height.
1146 * @return Any resultant error, if any.
1149 typedef sjme_errorCode (*sjme_scritchui_componentSizeFunc
)(
1150 sjme_attrInNotNull sjme_scritchui inState
,
1151 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1152 sjme_attrOutNullable sjme_jint
* outWidth
,
1153 sjme_attrOutNullable sjme_jint
* outHeight
);
1156 * Adds the given component to the specified container.
1158 * @param inState The input state.
1159 * @param inContainer The container to place the component within.
1160 * @param addComponent The component to add to the container.
1161 * @return Any error code if applicable.
1164 typedef sjme_errorCode (*sjme_scritchui_containerAddFunc
)(
1165 sjme_attrInNotNull sjme_scritchui inState
,
1166 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer
,
1167 sjme_attrInNotNull sjme_scritchui_uiComponent addComponent
);
1170 * Removes the given component from the specified container.
1172 * @param inState The input state.
1173 * @param inContainer The container to remove the component from.
1174 * @param removeComponent The component to remove from the container.
1175 * @return Any error code if applicable.
1178 typedef sjme_errorCode (*sjme_scritchui_containerRemoveFunc
)(
1179 sjme_attrInNotNull sjme_scritchui inState
,
1180 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer
,
1181 sjme_attrInNotNull sjme_scritchui_uiComponent removeComponent
);
1184 * Removes all components from the container.
1186 * @param inState The input state.
1187 * @param inContainer The container to remove everything from.
1188 * @return Any error code if applicable.
1191 typedef sjme_errorCode (*sjme_scritchui_containerRemoveAllFunc
)(
1192 sjme_attrInNotNull sjme_scritchui inState
,
1193 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer
);
1196 * Sets the bounds of a component within the container.
1198 * @param inState The input state.
1199 * @param inContainer The container to set the component within.
1200 * @param inComponent The component to be placed and resized.
1201 * @param x The X position.
1202 * @param y The Y position.
1203 * @param width The width.
1204 * @param height The height.
1205 * @return Any error code if applicable.
1208 typedef sjme_errorCode (*sjme_scritchui_containerSetBoundsFunc
)(
1209 sjme_attrInNotNull sjme_scritchui inState
,
1210 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer
,
1211 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1212 sjme_attrInPositive sjme_jint x
,
1213 sjme_attrInPositive sjme_jint y
,
1214 sjme_attrInPositiveNonZero sjme_jint width
,
1215 sjme_attrInPositiveNonZero sjme_jint height
);
1218 * Returns the default built-in font.
1220 * @param inState The input state.
1221 * @param outFont The resultant font.
1222 * @return Any resultant error, if any.
1225 typedef sjme_errorCode (*sjme_scritchui_fontBuiltinFunc
)(
1226 sjme_attrInNotNull sjme_scritchui inState
,
1227 sjme_attrOutNotNull sjme_scritchui_pencilFont
* outFont
);
1230 * Derives a new font from an existing font.
1232 * @param inState The input state.
1233 * @param inFont The input font to derive.
1234 * @param inStyle The style to switch to.
1235 * @param inPixelSize The pixel size to use.
1236 * @param outDerived The resultant derived font.
1237 * @return Any resultant error, if any.
1240 typedef sjme_errorCode (*sjme_scritchui_fontDeriveFunc
)(
1241 sjme_attrInNotNull sjme_scritchui inState
,
1242 sjme_attrInNotNull sjme_scritchui_pencilFont inFont
,
1243 sjme_attrInValue sjme_scritchui_pencilFontStyle inStyle
,
1244 sjme_attrInPositiveNonZero sjme_jint inPixelSize
,
1245 sjme_attrOutNotNull sjme_scritchui_pencilFont
* outDerived
);
1248 * Creates a hardware reference bracket to the native hardware graphics.
1250 * @param inState The UI state.
1251 * @param outPencil The resultant pencil.
1252 * @param outWeakPencil The weak reference to the pencil.
1253 * @param pf The @c sjme_gfx_pixelFormat used for the draw.
1254 * @param bw The buffer width, this is the scanline width of the buffer.
1255 * @param bh The buffer height.
1256 * @param inLockFuncs The locking functions to use for buffer access.
1257 * @param inLockFrontEndCopy Front end copy data for locks.
1258 * @param sx Starting surface X coordinate.
1259 * @param sy Starting surface Y coordinate.
1260 * @param sw Surface width.
1261 * @param sh Surface height.
1262 * @param pencilFrontEndCopy Front end data that goes into the pencil.
1263 * @return An error if the requested graphics are not valid.
1266 typedef sjme_errorCode (*sjme_scritchui_hardwareGraphicsFunc
)(
1267 sjme_attrInNotNull sjme_scritchui inState
,
1268 sjme_attrOutNotNull sjme_scritchui_pencil
* outPencil
,
1269 sjme_attrOutNullable sjme_alloc_weak
* outWeakPencil
,
1270 sjme_attrInValue sjme_gfx_pixelFormat pf
,
1271 sjme_attrInPositiveNonZero sjme_jint bw
,
1272 sjme_attrInPositiveNonZero sjme_jint bh
,
1273 sjme_attrInNullable
const sjme_scritchui_pencilLockFunctions
* inLockFuncs
,
1274 sjme_attrInNullable
const sjme_frontEnd
* inLockFrontEndCopy
,
1275 sjme_attrInValue sjme_jint sx
,
1276 sjme_attrInValue sjme_jint sy
,
1277 sjme_attrInPositiveNonZero sjme_jint sw
,
1278 sjme_attrInPositiveNonZero sjme_jint sh
,
1279 sjme_attrInNullable
const sjme_frontEnd
* pencilFrontEndCopy
);
1282 * Sets the label of the specified component.
1284 * @param inState The input state.
1285 * @param inCommon The item to set the label for.
1286 * @param inString The label to set.
1287 * @return Any resultant error, if any.
1290 typedef sjme_errorCode (*sjme_scritchui_labelSetStringFunc
)(
1291 sjme_attrInNotNull sjme_scritchui inState
,
1292 sjme_attrInNotNull sjme_scritchui_uiCommon inCommon
,
1293 sjme_attrInNullable sjme_lpcstr inString
);
1296 * Returns the color for the given element based on the current look and feel.
1298 * @param inState The current state.
1299 * @param inContext Optional context that can be targetted at a widget to get
1300 * its color themeing.
1301 * @param outRGB The resultant RGB color.
1302 * @param elementColor The color to request.
1303 * @return On any resultant error, if any.
1306 typedef sjme_errorCode (*sjme_scritchui_lafElementColorFunc
)(
1307 sjme_attrInNotNull sjme_scritchui inState
,
1308 sjme_attrInNullable sjme_scritchui_uiComponent inContext
,
1309 sjme_attrOutNotNull sjme_jint
* outRGB
,
1310 sjme_attrInValue sjme_scritchui_lafElementColorType elementColor
);
1313 * Creates a new list.
1315 * @param inState The input state.
1316 * @param outPanel The resultant list.
1317 * @param inChoiceType The type of choice this is.
1318 * @return Any error code if applicable.
1321 typedef sjme_errorCode (*sjme_scritchui_listNewFunc
)(
1322 sjme_attrInNotNull sjme_scritchui inState
,
1323 sjme_attrInOutNotNull sjme_scritchui_uiList
* outList
,
1324 sjme_attrInValue sjme_scritchui_choiceType inChoiceType
);
1327 * Execute the given callback within the event loop of the GUI.
1329 * @param inState The input state.
1330 * @param callback The callback to execute.
1331 * @param anything A value that can be passed to the listener.
1332 * @return Any error code if applicable.
1335 typedef sjme_errorCode (*sjme_scritchui_loopExecuteFunc
)(
1336 sjme_attrInNotNull sjme_scritchui inState
,
1337 sjme_attrInNotNull sjme_thread_mainFunc callback
,
1338 sjme_attrInNullable sjme_thread_parameter anything
);
1341 * Determines whether the current thread is in the event loop or not.
1343 * @param inState The input state.
1344 * @param outInThread The result of whether this is in the event loop.
1345 * @return Any error code if applicable.
1348 typedef sjme_errorCode (*sjme_scritchui_loopIsInThreadFunc
)(
1349 sjme_attrInNotNull sjme_scritchui inState
,
1350 sjme_attrInOutNotNull sjme_jboolean
* outInThread
);
1353 * Iterates a single run of the event loop.
1355 * @param inState The input ScritchUI state.
1356 * @param blocking If the iteration should block for something to happen.
1357 * @param outHasTerminated Has the GUI interface terminated?
1358 * @return Any error code if applicable.
1361 typedef sjme_errorCode (*sjme_scritchui_loopIterateFunc
)(
1362 sjme_attrInNotNull sjme_scritchui inState
,
1363 sjme_attrInValue sjme_jboolean blocking
,
1364 sjme_attrOutNullable sjme_jboolean
* outHasTerminated
);
1367 * Creates a new menu bar.
1369 * @param inState The input state.
1370 * @param outMenuBar The resultant menu bar.
1371 * @return Any error code if applicable.
1374 typedef sjme_errorCode (*sjme_scritchui_menuBarNewFunc
)(
1375 sjme_attrInNotNull sjme_scritchui inState
,
1376 sjme_attrInOutNotNull sjme_scritchui_uiMenuBar
* outMenuBar
);
1379 * Inserts the given menu item into the menu at the specified index.
1381 * @param inState The ScritchUI state.
1382 * @param intoMenu The menu to insert into.
1383 * @param atIndex The index to insert at.
1384 * @param childItem The child menu item to add.
1385 * @return Any resultant error, if any.
1388 typedef sjme_errorCode (*sjme_scritchui_menuInsertFunc
)(
1389 sjme_attrInNotNull sjme_scritchui inState
,
1390 sjme_attrInNotNull sjme_scritchui_uiMenuKind intoMenu
,
1391 sjme_attrInPositive sjme_jint atIndex
,
1392 sjme_attrInNotNull sjme_scritchui_uiMenuKind childItem
);
1395 * Creates a new menu item.
1397 * @param inState The input state.
1398 * @param outMenuItem The resultant menu item.
1399 * @return Any error code if applicable.
1402 typedef sjme_errorCode (*sjme_scritchui_menuItemNewFunc
)(
1403 sjme_attrInNotNull sjme_scritchui inState
,
1404 sjme_attrInOutNotNull sjme_scritchui_uiMenuItem
* outMenuItem
);
1407 * Creates a new menu.
1409 * @param inState The input state.
1410 * @param outMenu The resultant menu.
1411 * @return Any error code if applicable.
1414 typedef sjme_errorCode (*sjme_scritchui_menuNewFunc
)(
1415 sjme_attrInNotNull sjme_scritchui inState
,
1416 sjme_attrInOutNotNull sjme_scritchui_uiMenu
* outMenu
);
1419 * Removes the item at the specified index from this menu.
1421 * @param inState The ScritchUI state.
1422 * @param fromMenu The menu to remove from.
1423 * @param atIndex The index to remove.
1424 * @return Any resultant error, if any.
1427 typedef sjme_errorCode (*sjme_scritchui_menuRemoveFunc
)(
1428 sjme_attrInNotNull sjme_scritchui inState
,
1429 sjme_attrInNotNull sjme_scritchui_uiMenuKind fromMenu
,
1430 sjme_attrInPositive sjme_jint atIndex
);
1433 * Removes all items from the given menu.
1435 * @param inState The ScritchUI state.
1436 * @param fromMenu The menu to remove from.
1437 * @return Any resultant error, if any.
1440 typedef sjme_errorCode (*sjme_scritchui_menuRemoveAllFunc
)(
1441 sjme_attrInNotNull sjme_scritchui inState
,
1442 sjme_attrInNotNull sjme_scritchui_uiMenuKind fromMenu
);
1445 * Deletes the given object.
1447 * @param inState The input state.
1448 * @param inOutObject The object to delete.
1449 * @return Any resultant error, if any.
1452 typedef sjme_errorCode (*sjme_scritchui_objectDeleteFunc
)(
1453 sjme_attrInNotNull sjme_scritchui inState
,
1454 sjme_attrInOutNotNull sjme_scritchui_uiCommon
* inOutObject
);
1457 * Enables or disables focus on a panel.
1459 * @param inState The input state.
1460 * @param inPanel The input panel.
1461 * @param enableFocus Should focus be enabled?
1462 * @return Any error code if applicable.
1465 typedef sjme_errorCode (*sjme_scritchui_panelEnableFocusFunc
)(
1466 sjme_attrInNotNull sjme_scritchui inState
,
1467 sjme_attrInNotNull sjme_scritchui_uiPanel inPanel
,
1468 sjme_attrInValue sjme_jboolean enableFocus
,
1469 sjme_attrInValue sjme_jboolean defaultFocus
);
1472 * Creates a new panel.
1474 * @param inState The input state.
1475 * @param outPanel The resultant panel.
1476 * @return Any error code if applicable.
1479 typedef sjme_errorCode (*sjme_scritchui_panelNewFunc
)(
1480 sjme_attrInNotNull sjme_scritchui inState
,
1481 sjme_attrInOutNotNull sjme_scritchui_uiPanel
* outPanel
);
1484 * Sets the screen listener callback for screen changes.
1486 * @param inState The input state.
1487 * @param callback The callback for screen information and changes.
1488 * @return Any error code if applicable.
1491 typedef sjme_errorCode (*sjme_scritchui_screenSetListenerFunc
)(
1492 sjme_attrInNotNull sjme_scritchui inState
,
1493 SJME_SCRITCHUI_SET_LISTENER_ARGS(screen
));
1496 * Obtains and queries the screens which are attached to the system displays.
1498 * @param inState The input state.
1499 * @param outScreens The resultant screens.
1500 * @param inOutNumScreens The number of screens for input and output.
1501 * @return Any error code if applicable.
1504 typedef sjme_errorCode (*sjme_scritchui_screensFunc
)(
1505 sjme_attrInNotNull sjme_scritchui inState
,
1506 sjme_attrOutNotNull sjme_scritchui_uiScreen
* outScreens
,
1507 sjme_attrInOutNotNull sjme_jint
* inOutNumScreens
);
1510 * Creates a new scroll panel which contains other components within a viewport
1513 * @param inState The ScritchUI state.
1514 * @param outScrollPanel The newly created scroll panel.
1515 * @return Any resultant error, if any.
1518 typedef sjme_errorCode (*sjme_scritchui_scrollPanelNewFunc
)(
1519 sjme_attrInNotNull sjme_scritchui inState
,
1520 sjme_attrOutNotNull sjme_scritchui_uiScrollPanel
* outScrollPanel
);
1523 * Gets the current view rectangle of a viewport.
1525 * @param inState The ScritchUI state.
1526 * @param inComponent The viewport.
1527 * @param outViewRect The current view rectangle.
1528 * @return Any resultant error, if any.
1531 typedef sjme_errorCode (*sjme_scritchui_viewGetViewFunc
)(
1532 sjme_attrInNotNull sjme_scritchui inState
,
1533 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1534 sjme_attrOutNotNull sjme_scritchui_rect
* outViewRect
);
1537 * Sets the area that the scroll panel provides a viewport area, this area
1538 * may be larger than the viewport and widgets may be placed inside.
1540 * @param inState The ScritchUI state.
1541 * @param inComponent The viewport.
1542 * @param inViewArea The view area to set.
1543 * @return Any resultant error, if any.
1546 typedef sjme_errorCode (*sjme_scritchui_viewSetAreaFunc
)(
1547 sjme_attrInNotNull sjme_scritchui inState
,
1548 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1549 sjme_attrInNotNull
const sjme_scritchui_dim
* inViewArea
);
1552 * Sets the view rectangle of a viewport.
1554 * @param inState The ScritchUI state.
1555 * @param inComponent The viewport.
1556 * @param inViewPos The new view position to set.
1557 * @return Any resultant error, if any.
1560 typedef sjme_errorCode (*sjme_scritchui_viewSetViewFunc
)(
1561 sjme_attrInNotNull sjme_scritchui inState
,
1562 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1563 sjme_attrInNotNull
const sjme_scritchui_point
* inViewPos
);
1566 * Sets the listener which is called for a viewport when a contained component
1567 * has a suggestion as to how large it should be to contain it.
1569 * @param inState The ScritchUI state.
1570 * @param inComponent The viewport.
1571 * @param inListener The listener to set.
1572 * @param copyFrontEnd Any front-end data needed for the listener.
1573 * @return Any resultant error, if any.
1576 typedef sjme_errorCode (*sjme_scritchui_viewSetSizeSuggestListenerFunc
)(
1577 sjme_attrInNotNull sjme_scritchui inState
,
1578 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1579 SJME_SCRITCHUI_SET_LISTENER_ARGS(sizeSuggest
));
1582 * Sets the listener which is called whenever the viewport changes such as it
1585 * @param inState The ScritchUI state.
1586 * @param inComponent The viewport.
1587 * @param inListener The listener to set.
1588 * @param copyFrontEnd Any front-end data needed for the listener.
1589 * @return Any resultant error, if any.
1592 typedef sjme_errorCode (*sjme_scritchui_viewSetViewListenerFunc
)(
1593 sjme_attrInNotNull sjme_scritchui inState
,
1594 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1595 SJME_SCRITCHUI_SET_LISTENER_ARGS(view
));
1598 * Void listener set.
1600 * @param inState The ScritchUI state.
1601 * @param inComponent The component.
1602 * @param inListener The listener to set.
1603 * @param copyFrontEnd Any front-end data needed for the listener.
1604 * @return Any resultant error, if any.
1607 typedef sjme_errorCode (*sjme_scritchui_voidSetVoidListenerFunc
)(
1608 sjme_attrInNotNull sjme_scritchui inState
,
1609 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1610 SJME_SCRITCHUI_SET_LISTENER_ARGS(void));
1613 * Sets the minimum content size for windows.
1615 * @param inState The input state.
1616 * @param inWindow The window to set the minimum content size for.
1617 * @param width The width to set.
1618 * @param height The height to set.
1619 * @return Any error code if applicable, such as if the width and/or height
1620 * are zero or negative.
1623 typedef sjme_errorCode (*sjme_scritchui_windowContentMinimumSizeFunc
)(
1624 sjme_attrInNotNull sjme_scritchui inState
,
1625 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1626 sjme_attrInPositiveNonZero sjme_jint width
,
1627 sjme_attrInPositiveNonZero sjme_jint height
);
1630 * Creates a new window.
1632 * @param inState The input state.
1633 * @param outWindow The resultant newly created window.
1634 * @return Any error code if applicable.
1637 typedef sjme_errorCode (*sjme_scritchui_windowNewFunc
)(
1638 sjme_attrInNotNull sjme_scritchui inState
,
1639 sjme_attrInOutNotNull sjme_scritchui_uiWindow
* outWindow
);
1642 * Sets the close listener for a window.
1644 * @param inState The input state.
1645 * @param inWindow The window to set for.
1646 * @param inListener The listener to use.
1647 * @param copyFrontEnd The front end data to use.
1648 * @return Any resultant error, if any.
1651 typedef sjme_errorCode (*sjme_scritchui_windowSetCloseListenerFunc
)(
1652 sjme_attrInNotNull sjme_scritchui inState
,
1653 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1654 SJME_SCRITCHUI_SET_LISTENER_ARGS(close
));
1657 * Sets the menu bar for a window.
1659 * @param inState The input state.
1660 * @param inWindow The window to set the menu bar of.
1661 * @param inMenuBar The menu bar to set, if @c NULL then it is removed.
1662 * @return Any resultant error, if any.
1665 typedef sjme_errorCode (*sjme_scritchui_windowSetMenuBarFunc
)(
1666 sjme_attrInNotNull sjme_scritchui inState
,
1667 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1668 sjme_attrInNullable sjme_scritchui_uiMenuBar inMenuBar
);
1671 * Sets the menu item activation listener for a window.
1673 * @param inState The input state.
1674 * @param inWindow The window to set for.
1675 * @param inListener The listener to use.
1676 * @param copyFrontEnd The front end data to use.
1677 * @return Any resultant error, if any.
1680 typedef sjme_errorCode (*sjme_scritchui_windowSetMenuItemActivateListenerFunc
)(
1681 sjme_attrInNotNull sjme_scritchui inState
,
1682 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1683 SJME_SCRITCHUI_SET_LISTENER_ARGS(menuItemActivate
));
1686 * Sets the visibility of a window.
1688 * @param inState The input state.
1689 * @param inWindow The input window.
1690 * @param isVisible Should the window be visible?
1691 * @return Any error code if applicable.
1694 typedef sjme_errorCode (*sjme_scritchui_windowSetVisibleFunc
)(
1695 sjme_attrInNotNull sjme_scritchui inState
,
1696 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1697 sjme_attrInValue sjme_jboolean isVisible
);
1699 /** Quicker API declaration in struct. */
1700 #define SJME_SCRITCHUI_QUICK_API(x) \
1701 SJME_TOKEN_PASTE3(sjme_scritchui_, x, Func) x
1703 struct sjme_scritchui_apiFunctions
1706 SJME_SCRITCHUI_QUICK_API(apiFlags
);
1708 /** Get the first selected index of a choice. */
1709 SJME_SCRITCHUI_QUICK_API(choiceGetSelectedIndex
);
1711 /** Gets the item information. */
1712 SJME_SCRITCHUI_QUICK_API(choiceItemGet
);
1714 /** Inserts an item into the given choice. */
1715 SJME_SCRITCHUI_QUICK_API(choiceItemInsert
);
1717 /** Removes an item from the given choice. */
1718 SJME_SCRITCHUI_QUICK_API(choiceItemRemove
);
1720 /** Removes all items from the given choice. */
1721 SJME_SCRITCHUI_QUICK_API(choiceItemRemoveAll
);
1723 /** Sets whether the given choice item is enabled. */
1724 SJME_SCRITCHUI_QUICK_API(choiceItemSetEnabled
);
1726 /** Sets the image of the given choice item. */
1727 SJME_SCRITCHUI_QUICK_API(choiceItemSetImage
);
1729 /** Sets whether the given choice item is selected. */
1730 SJME_SCRITCHUI_QUICK_API(choiceItemSetSelected
);
1732 /** Sets the string of the given choice item. */
1733 SJME_SCRITCHUI_QUICK_API(choiceItemSetString
);
1735 /** Gets the choice length. */
1736 SJME_SCRITCHUI_QUICK_API(choiceLength
);
1738 /** Grabs the focus for this component. */
1739 SJME_SCRITCHUI_QUICK_API(componentFocusGrab
);
1741 /** Checks if this component has focus. */
1742 SJME_SCRITCHUI_QUICK_API(componentFocusHas
);
1744 /** Gets the parent component of this one. */
1745 SJME_SCRITCHUI_QUICK_API(componentGetParent
);
1747 /** Get size of component. */
1748 SJME_SCRITCHUI_QUICK_API(componentPosition
);
1750 /** Repaints the given component. */
1751 SJME_SCRITCHUI_QUICK_API(componentRepaint
);
1753 /** Revalidates the given component. */
1754 SJME_SCRITCHUI_QUICK_API(componentRevalidate
);
1756 /** Set listener for when a component is activated. */
1757 SJME_SCRITCHUI_QUICK_API(componentSetActivateListener
);
1759 /** Sets the input listener for a component. */
1760 SJME_SCRITCHUI_QUICK_API(componentSetInputListener
);
1762 /** Sets the paint listener for a component. */
1763 SJME_SCRITCHUI_QUICK_API(componentSetPaintListener
);
1765 /** Sets the listener for component size events. */
1766 SJME_SCRITCHUI_QUICK_API(componentSetSizeListener
);
1768 /** Set listener for when a component value has updated. */
1769 SJME_SCRITCHUI_QUICK_API(componentSetValueUpdateListener
);
1771 /** Sets the listener for component visible events. */
1772 SJME_SCRITCHUI_QUICK_API(componentSetVisibleListener
);
1774 /** Get size of component. */
1775 SJME_SCRITCHUI_QUICK_API(componentSize
);
1777 /** Adds component to container. */
1778 SJME_SCRITCHUI_QUICK_API(containerAdd
);
1780 /** Remove component from container. */
1781 SJME_SCRITCHUI_QUICK_API(containerRemove
);
1783 /** Remove all components from a container. */
1784 SJME_SCRITCHUI_QUICK_API(containerRemoveAll
);
1786 /** Set bounds of component in a container. */
1787 SJME_SCRITCHUI_QUICK_API(containerSetBounds
);
1789 /** Returns the default built-in font. */
1790 SJME_SCRITCHUI_QUICK_API(fontBuiltin
);
1792 /** Derive a similar font. */
1793 SJME_SCRITCHUI_QUICK_API(fontDerive
);
1795 /** Hardware graphics support on arbitrary buffers. */
1796 SJME_SCRITCHUI_QUICK_API(hardwareGraphics
);
1798 /** Sets the close listener for a window. */
1799 SJME_SCRITCHUI_QUICK_API(labelSetString
);
1801 /** Returns the element color for the look and feel. */
1802 SJME_SCRITCHUI_QUICK_API(lafElementColor
);
1804 /** Creates a new list. */
1805 SJME_SCRITCHUI_QUICK_API(listNew
);
1807 /** Execute callback within the event loop. */
1808 SJME_SCRITCHUI_QUICK_API(loopExecute
);
1810 /** Execute callback later in the event loop. */
1811 sjme_scritchui_loopExecuteFunc loopExecuteLater
;
1813 /** Execute callback within the event loop and wait until termination. */
1814 sjme_scritchui_loopExecuteFunc loopExecuteWait
;
1816 /** Is the current thread in the loop? */
1817 SJME_SCRITCHUI_QUICK_API(loopIsInThread
);
1819 /** Iterates a single run of the event loop. */
1820 SJME_SCRITCHUI_QUICK_API(loopIterate
);
1822 /** Creates a new menu bar. */
1823 SJME_SCRITCHUI_QUICK_API(menuBarNew
);
1825 /** Insert the given menu item into a menu. */
1826 SJME_SCRITCHUI_QUICK_API(menuInsert
);
1828 /** Creates a new menu item. */
1829 SJME_SCRITCHUI_QUICK_API(menuItemNew
);
1831 /** Creates a new menu. */
1832 SJME_SCRITCHUI_QUICK_API(menuNew
);
1834 /** Removes an item from the menu. */
1835 SJME_SCRITCHUI_QUICK_API(menuRemove
);
1837 /** Removes all items from the menu. */
1838 SJME_SCRITCHUI_QUICK_API(menuRemoveAll
);
1840 /** Deletes an object. */
1841 SJME_SCRITCHUI_QUICK_API(objectDelete
);
1843 /** Enable focus on a panel. */
1844 SJME_SCRITCHUI_QUICK_API(panelEnableFocus
);
1846 /** Creates a new panel. */
1847 SJME_SCRITCHUI_QUICK_API(panelNew
);
1849 /** Register listener. */
1850 SJME_SCRITCHUI_QUICK_API(screenSetListener
);
1852 /** Screens available. */
1853 SJME_SCRITCHUI_QUICK_API(screens
);
1855 /** Create a new scroll panel. */
1856 SJME_SCRITCHUI_QUICK_API(scrollPanelNew
);
1858 /** Get the current view rect of a viewport. */
1859 SJME_SCRITCHUI_QUICK_API(viewGetView
);
1861 /** Set the area of the viewport's bounds, the entire scrollable area. */
1862 SJME_SCRITCHUI_QUICK_API(viewSetArea
);
1864 /** Sets the view rect of a viewport. */
1865 SJME_SCRITCHUI_QUICK_API(viewSetView
);
1867 /** Sets the size suggestion for this view. */
1868 SJME_SCRITCHUI_QUICK_API(viewSetSizeSuggestListener
);
1870 /** Sets the listener for tracking scrolling and viewport changes. */
1871 SJME_SCRITCHUI_QUICK_API(viewSetViewListener
);
1873 /** Sets minimum size of the window contents. */
1874 SJME_SCRITCHUI_QUICK_API(windowContentMinimumSize
);
1876 /** Creates a new window. */
1877 SJME_SCRITCHUI_QUICK_API(windowNew
);
1879 /** Sets the close listener for a window. */
1880 SJME_SCRITCHUI_QUICK_API(windowSetCloseListener
);
1882 /** Sets the menu bar for a window. */
1883 SJME_SCRITCHUI_QUICK_API(windowSetMenuBar
);
1885 /** Sets the activation listener for menu items in a window. */
1886 SJME_SCRITCHUI_QUICK_API(windowSetMenuItemActivateListener
);
1888 /** Sets visibility of window. */
1889 SJME_SCRITCHUI_QUICK_API(windowSetVisible
);
1892 #undef SJME_SCRITCHUI_QUICK_API
1895 * Opaque internal implementation functions.
1899 typedef struct sjme_scritchui_implInternFunctions
1900 sjme_scritchui_implInternFunctions
;
1902 /** The number of common handles. */
1903 #define SJME_SCRITCHUI_NUM_COMMON_HANDLES 4
1905 /** The number of common values. */
1906 #define SJME_SCRITCHUI_NUM_COMMON_VALUES SJME_SCRITCHUI_NUM_COMMON_HANDLES
1908 struct sjme_scritchui_uiCommonBase
1910 /** The type of what this is. */
1911 sjme_scritchui_uiType type
;
1913 /** The state which owns this. */
1914 sjme_scritchui state
;
1917 * Front-end data for this, note that ScritchUI implementations must not
1918 * use this for information as this is only to be used by front-ends.
1920 sjme_frontEnd frontEnd
;
1922 /** Opaque native handles for this, as needed. */
1923 sjme_scritchui_handle handle
[SJME_SCRITCHUI_NUM_COMMON_HANDLES
];
1925 /** Other value storage, as needed. */
1926 sjme_jint intVals
[SJME_SCRITCHUI_NUM_COMMON_VALUES
];
1930 * Window manager details to use.
1934 typedef struct sjme_scritchui_wmInfo
1936 /** Default title. */
1937 sjme_lpcstr defaultTitle
;
1939 /** X Window System Class. */
1940 sjme_lpcstr xwsClass
;
1941 } sjme_scritchui_wmInfo
;
1944 * Windowing system specific bugs.
1948 typedef struct sjme_scritchui_bugs
1950 /** Do not set content size when the window is made visible. */
1951 sjme_jboolean noContentSizeWhenVisible
;
1952 } sjme_scritchui_bugs
;
1954 struct sjme_scritchui_stateBase
1957 sjme_scritchui_uiCommonBase common
;
1959 /** Window manager information. */
1960 const sjme_scritchui_wmInfo
* wmInfo
;
1962 /** API functions to use. */
1963 const sjme_scritchui_apiFunctions
* api
;
1965 /** In thread API functions. */
1966 const sjme_scritchui_apiFunctions
* apiInThread
;
1968 /** Internal implementation functions to use. */
1969 const sjme_scritchui_internFunctions
* intern
;
1971 /** Implementation functions to use. */
1972 const sjme_scritchui_implFunctions
* impl
;
1974 /** Internal implementation functions, which are opaque. */
1975 const sjme_scritchui_implInternFunctions
* implIntern
;
1977 /** The allocation pool to use for allocations. */
1978 sjme_alloc_pool
* pool
;
1980 /** The event loop thread, if applicable. */
1981 sjme_thread loopThread
;
1983 /** The current loop thread ID, if applicable. */
1984 sjme_intPointer loopThreadId
;
1986 /** Loop thread initializer if one was passed. */
1987 sjme_thread_mainFunc loopThreadInit
;
1989 /** Indicator that the main loop is ready for execution. */
1990 sjme_atomic_sjme_jint loopThreadReady
;
1992 /** The available screens. */
1993 sjme_list_sjme_scritchui_uiScreen
* screens
;
1995 /** The window manager type used. */
1996 sjme_scritchui_windowManagerType wmType
;
1998 /** The internal built-in font. */
1999 sjme_scritchui_pencilFont builtinFont
;
2001 /** The fonts which are loaded and known to the state. */
2002 sjme_scritchui_pencilFontLink
* fontChain
;
2004 /** Function to obtain the current nanotime, for input events. */
2005 sjme_nal_nanoTimeFunc nanoTime
;
2007 /** Is this a panel only interface? */
2008 sjme_jboolean isPanelOnly
;
2010 /** Wrapped ScritchUI state, if this is a wrapper. */
2011 sjme_scritchui wrappedState
;
2013 /** Reference to owning state. */
2014 sjme_atomic_sjme_pointer topState
;
2016 /** The next ID for opaque menu items. */
2017 sjme_jint nextMenuItemId
;
2019 /** Windowing system specific bugs. */
2020 sjme_scritchui_bugs bugs
;
2023 /* If dynamic libraries are not supported, we cannot do this. */
2024 #if !defined(SJME_CONFIG_SCRITCHUI_NO_DYLIB)
2027 * Initializes the API through the dynamic library.
2029 * @param inPool The pool to allocate within.
2030 * @param loopExecute Optional callback for loop execution, may be @c NULL ,
2031 * the passed argument is always the state.
2032 * @param initFrontEnd Optional initial front end data.
2033 * @param outState The resultant newly created ScritchUI state.
2034 * @return Any error code that may occur.
2037 typedef sjme_errorCode (*sjme_scritchui_dylibApiFunc
)(
2038 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
2039 sjme_attrInNullable sjme_thread_mainFunc loopExecute
,
2040 sjme_attrInNullable sjme_frontEnd
* initFrontEnd
,
2041 sjme_attrInOutNotNull sjme_scritchui
* outState
);
2043 /** The base name for the ScritchUI dynamic library. */
2044 #define SJME_SCRITCHUI_DYLIB_NAME_BASE \
2045 "squirreljme-scritchui-"
2047 /** The name of the dynamic library for ScritchUI. */
2048 #define SJME_SCRITCHUI_DYLIB_NAME(x) \
2049 SJME_SCRITCHUI_DYLIB_NAME_BASE SJME_TOKEN_STRING_PP(x)
2051 /** The path name for the dynamic library for ScritchUI. */
2052 #define SJME_SCRITCHUI_DYLIB_PATHNAME(x) \
2053 SJME_CONFIG_DYLIB_PATHNAME(SJME_SCRITCHUI_DYLIB_NAME(x))
2055 /** The symbol to use with @c sjme_scritchui_dylibApiFunc . */
2056 #define SJME_SCRITCHUI_DYLIB_SYMBOL(x) \
2057 SJME_TOKEN_PASTE(sjme_scritchui_dylibApi, x)
2062 * Check cast of a given type.
2064 * @param inType The input type.
2065 * @param inPtr The input pointer.
2066 * @return Always @c inPtr .
2069 sjme_pointer
sjme_scritchui_checkCast(sjme_scritchui_uiType inType
,
2070 sjme_pointer inPtr
);
2073 * Check cast of a given type against a component.
2075 * @param inPtr The input pointer.
2076 * @return Always @c inPtr .
2079 sjme_pointer
sjme_scritchui_checkCast_component(sjme_pointer inPtr
);
2082 * Check cast of a given type against a menu kind.
2084 * @param inPtr The input pointer.
2085 * @return Always @c inPtr .
2088 sjme_pointer
sjme_scritchui_checkCast_menuKind(sjme_pointer inPtr
);
2090 /*--------------------------------------------------------------------------*/
2094 #ifdef SJME_CXX_SQUIRRELJME_SCRITCHUI_H
2096 #undef SJME_CXX_SQUIRRELJME_SCRITCHUI_H
2097 #undef SJME_CXX_IS_EXTERNED
2098 #endif /* #ifdef SJME_CXX_SQUIRRELJME_SCRITCHUI_H */
2099 #endif /* #ifdef __cplusplus */
2101 #endif /* SQUIRRELJME_SCRITCHUI_H */