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/gfxConst.h"
23 #include "sjme/list.h"
24 #include "sjme/native.h"
25 #include "lib/scritchinput/scritchinput.h"
26 #include "sjme/alloc.h"
30 #ifndef SJME_CXX_IS_EXTERNED
31 #define SJME_CXX_IS_EXTERNED
32 #define SJME_CXX_SQUIRRELJME_SCRITCHUI_H
34 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
35 #endif /* #ifdef __cplusplus */
37 /*--------------------------------------------------------------------------*/
40 * Represents the type that this is.
44 typedef enum sjme_scritchui_uiType
47 SJME_SCRITCHUI_TYPE_RESERVED
,
50 SJME_SCRITCHUI_TYPE_FONT
,
53 SJME_SCRITCHUI_TYPE_LIST
,
56 SJME_SCRITCHUI_TYPE_MENU
,
59 SJME_SCRITCHUI_TYPE_MENU_BAR
,
62 SJME_SCRITCHUI_TYPE_MENU_ITEM
,
65 SJME_SCRITCHUI_TYPE_PANEL
,
68 SJME_SCRITCHUI_TYPE_PENCIL
,
71 SJME_SCRITCHUI_TYPE_ROOT_STATE
,
74 SJME_SCRITCHUI_TYPE_SCREEN
,
77 SJME_SCRITCHUI_TYPE_SCROLL_PANEL
,
80 SJME_SCRITCHUI_TYPE_WINDOW
,
82 /** The number of possible types. */
83 SJME_NUM_SCRITCHUI_UI_TYPES
84 } sjme_scritchui_uiType
;
86 /** Generic cast check. */
87 #define SJME_SUI_CAST(uiType, type, v) \
88 ((type)sjme_scritchui_checkCast((type), (v)))
90 /** Check cast to menu kind. */
91 #define SJME_SUI_CAST_MENU_KIND(v) \
92 ((sjme_scritchui_uiMenuKind)sjme_scritchui_checkCast_menuKind((v)))
94 /** Check cast to menu. */
95 #define SJME_SUI_CAST_MENU(v) \
96 SJME_SUI_CAST(SJME_SCRITCHUI_TYPE_MENU, \
97 sjme_scritchui_uiMenu, (v))
99 /** Check cast to menu bar. */
100 #define SJME_SUI_CAST_MENU_BAR(v) \
101 SJME_SUI_CAST(SJME_SCRITCHUI_TYPE_MENU_BAR, \
102 sjme_scritchui_uiMenuBar, (v))
104 /** Check cast to menu item. */
105 #define SJME_SUI_CAST_MENU_ITEM(v) \
106 SJME_SUI_CAST(SJME_SCRITCHUI_TYPE_MENU_Item, \
107 sjme_scritchui_uiMenuItem, (v))
110 * An opaque native handle.
114 typedef sjme_pointer sjme_scritchui_handle
;
117 * API Flags for ScritchUI.
121 typedef enum sjme_scritchui_apiFlag
123 /** Only panels are supported for this interface. */
124 SJME_SCRITCHUI_API_FLAG_PANEL_ONLY
= 1,
125 } sjme_scritchui_apiFlag
;
128 * Which type of screen update has occurred?
132 typedef enum sjme_scritchui_screenUpdateType
135 SJME_SCRITCHUI_SCREEN_UPDATE_UNKNOWN
,
138 SJME_SCRITCHUI_SCREEN_UPDATE_NEW
,
140 /** Deleted screen. */
141 SJME_SCRITCHUI_SCREEN_UPDATE_DELETED
,
143 /** Updated screen (resolution, color, etc.) */
144 SJME_SCRITCHUI_SCREEN_UPDATE_CHANGED
,
146 /** The number of update types. */
147 SJME_SCRITCHUI_NUM_SCREEN_UPDATE
148 } sjme_scritchui_screenUpdateType
;
151 * The type of window manager that is used.
155 typedef enum sjme_scritchui_windowManagerType
157 /** One frame per screen. */
158 SJME_SCRITCHUI_WM_TYPE_ONE_FRAME_PER_SCREEN
= 0,
160 /** Standard desktop interface. */
161 SJME_SCRITCHUI_WM_TYPE_STANDARD_DESKTOP
= 1,
163 /** The number of window manager types. */
164 SJME_SCRITCHUI_NUM_WM_TYPES
165 } sjme_scritchui_windowManagerType
;
168 * Font style for pencil fonts.
172 typedef enum sjme_scritchui_pencilFontStyle
175 SJME_SCRITCHUI_PENCIL_FONT_STYLE_BOLD
= 1,
177 /** Italic (slanted) text. */
178 SJME_SCRITCHUI_PENCIL_FONT_STYLE_ITALIC
= 2,
180 /** Underlined text. */
181 SJME_SCRITCHUI_PENCIL_FONT_STYLE_UNDERLINED
= 4,
184 SJME_SCRITCHUI_PENCIL_FONT_STYLE_ALL
=
185 SJME_SCRITCHUI_PENCIL_FONT_STYLE_BOLD
|
186 SJME_SCRITCHUI_PENCIL_FONT_STYLE_ITALIC
|
187 SJME_SCRITCHUI_PENCIL_FONT_STYLE_UNDERLINED
,
188 } sjme_scritchui_pencilFontStyle
;
191 * Represents the type of choice that a choice selection may be.
195 typedef enum sjme_scritchui_choiceType
197 /** Only one element may be selected at a time. */
198 SJME_SCRITCHUI_CHOICE_TYPE_EXCLUSIVE
= 0,
201 * The item that is focused is always the only one selected, pressing an
202 * action key (like enter/space) will activate the item.
204 SJME_SCRITCHUI_CHOICE_TYPE_IMPLICIT
= 1,
206 /** Any number of items may be selected. */
207 SJME_SCRITCHUI_CHOICE_TYPE_MULTIPLE
= 2,
209 /** The number of choice types. */
210 SJME_SCRITCHUI_NUM_CHOICE_TYPES
= 3,
211 } sjme_scritchui_choiceType
;
214 * The element color type for look and feel.
218 typedef enum sjme_scritchui_lafElementColorType
220 /** Background color. */
221 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_BACKGROUND
= 0,
224 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_BORDER
= 1,
226 /** Foreground color. */
227 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_FOREGROUND
= 2,
229 /** Highlighted background color. */
230 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_HIGHLIGHTED_BACKGROUND
= 3,
232 /** Highlighted border color. */
233 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_HIGHLIGHTED_BORDER
= 4,
235 /** Highlighted foreground color. */
236 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_HIGHLIGHTED_FOREGROUND
= 5,
239 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_FOCUS_BORDER
= 6,
241 /** Panel background color. */
242 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_PANEL_BACKGROUND
= 7,
244 /** Panel foreground color. */
245 SJME_SCRITCHUI_LAF_ELEMENT_COLOR_PANEL_FOREGROUND
= 8,
247 /** The number of element colors. */
248 SJME_SCRITCHUI_NUM_LAF_ELEMENT_COLOR
= 9,
249 } sjme_scritchui_lafElementColorType
;
252 * Represents a point.
256 typedef struct sjme_scritchui_point
263 } sjme_scritchui_point
;
270 typedef struct sjme_scritchui_line
272 /** Starting point. */
273 sjme_scritchui_point s
;
276 sjme_scritchui_point e
;
277 } sjme_scritchui_line
;
280 * Represents a dimension.
284 typedef struct sjme_scritchui_dim
291 } sjme_scritchui_dim
;
294 * Represents a rectangle.
298 typedef struct sjme_scritchui_rect
300 /** The starting point of the rectangle. */
301 sjme_scritchui_point s
;
303 /** The dimension of the rect. */
304 sjme_scritchui_dim d
;
305 } sjme_scritchui_rect
;
312 typedef struct sjme_scritchui_stateBase
* sjme_scritchui
;
315 * ScritchUI API functions, implemented by a native library accordingly.
319 typedef struct sjme_scritchui_apiFunctions sjme_scritchui_apiFunctions
;
322 * ScritchUI implementation functions.
326 typedef struct sjme_scritchui_implFunctions sjme_scritchui_implFunctions
;
329 * Internal ScritchUI API functions.
333 typedef struct sjme_scritchui_internFunctions sjme_scritchui_internFunctions
;
336 * Common data structure shared by everything in ScritchUI.
340 typedef struct sjme_scritchui_uiCommonBase sjme_scritchui_uiCommonBase
;
343 * Common data pointer, which is shared by everything in ScritchUI.
347 typedef sjme_scritchui_uiCommonBase
* sjme_scritchui_uiCommon
;
350 * Represents a choice of options such as those in a list.
354 typedef struct sjme_scritchui_uiChoiceBase
* sjme_scritchui_uiChoice
;
357 * Represents a single choice item.
361 typedef struct sjme_scritchui_uiChoiceItemBase sjme_scritchui_uiChoiceItemBase
;
364 * Represents a single choice item.
368 typedef struct sjme_scritchui_uiChoiceItemBase
* sjme_scritchui_uiChoiceItem
;
371 * Component within ScritchUI.
375 typedef struct sjme_scritchui_uiComponentBase
* sjme_scritchui_uiComponent
;
378 * Represents a container which can contain other components.
382 typedef struct sjme_scritchui_uiContainerBase
* sjme_scritchui_uiContainer
;
385 * Represents a component which can have a label.
389 typedef struct sjme_scritchui_uiLabeledBase sjme_scritchui_uiLabeledBase
;
392 * Represents a component which can have a label.
396 typedef sjme_scritchui_uiLabeledBase
* sjme_scritchui_uiLabeled
;
399 * Base paintable for ScritchUI.
403 typedef struct sjme_scritchui_uiPaintableBase
* sjme_scritchui_uiPaintable
;
406 * A panel within ScritchUI.
410 typedef struct sjme_scritchui_uiPanelBase sjme_scritchui_uiPanelBase
;
413 * A panel within ScritchUI.
417 typedef sjme_scritchui_uiPanelBase
* sjme_scritchui_uiPanel
;
420 * A list within ScritchUI.
424 typedef struct sjme_scritchui_uiListBase
* sjme_scritchui_uiList
;
427 * A menu that has children.
431 typedef struct sjme_scritchui_uiMenuHasChildrenBase
432 sjme_scritchui_uiMenuHasChildrenBase
;
435 * A ScritchUI menu kind
439 typedef struct sjme_scritchui_uiMenuKindBase sjme_scritchui_uiMenuKindBase
;
442 * A ScritchUI menu kind
446 typedef sjme_scritchui_uiMenuKindBase
* sjme_scritchui_uiMenuKind
;
449 * A menu that has children.
453 typedef sjme_scritchui_uiMenuHasChildrenBase
* sjme_scritchui_uiMenuHasChildren
;
456 * A menu that has a parent.
460 typedef struct sjme_scritchui_uiMenuHasParentBase
461 sjme_scritchui_uiMenuHasParentBase
;
464 * A menu that has a parent.
468 typedef sjme_scritchui_uiMenuHasParentBase
* sjme_scritchui_uiMenuHasParent
;
471 * A menu within ScritchUI.
475 typedef struct sjme_scritchui_uiMenuBase
* sjme_scritchui_uiMenu
;
478 * A menu bar within ScritchUI.
482 typedef struct sjme_scritchui_uiMenuBarBase
* sjme_scritchui_uiMenuBar
;
485 * A menu item within ScritchUI.
489 typedef struct sjme_scritchui_uiMenuItemBase
* sjme_scritchui_uiMenuItem
;
492 * A single monitor screen on the display for ScritchUI.
496 typedef struct sjme_scritchui_uiScreenBase
* sjme_scritchui_uiScreen
;
498 /** A list of screens. */
499 SJME_LIST_DECLARE(sjme_scritchui_uiScreen
, 0);
502 * A panel which can also be scrolled.
506 typedef struct sjme_scritchui_uiScrollPanelBase
* sjme_scritchui_uiScrollPanel
;
509 * Viewport manager information for any widget that is a viewport.
513 typedef struct sjme_scritchui_uiViewBase sjme_scritchui_uiViewBase
;
516 * Viewport manager information for any widget that is a viewport.
520 typedef sjme_scritchui_uiViewBase
* sjme_scritchui_uiView
;
523 * A window within ScritchUI.
527 typedef struct sjme_scritchui_uiWindowBase
* sjme_scritchui_uiWindow
;
530 * ScritchUI Pencil state.
534 typedef struct sjme_scritchui_pencilBase
* sjme_scritchui_pencil
;
537 * Font structure for ScritchUI Pencil.
541 typedef struct sjme_scritchui_pencilFontBase
* sjme_scritchui_pencilFont
;
544 * A single link within a loaded/known font chain.
548 typedef struct sjme_scritchui_pencilFontLink sjme_scritchui_pencilFontLink
;
551 * Utility functions to help in implementations or otherwise perform some
556 typedef struct sjme_scritchui_pencilUtilFunctions
557 sjme_scritchui_pencilUtilFunctions
;
560 * Functions which are used to lock and unlock access to the backing pencil
561 * buffer, if applicable.
565 typedef struct sjme_scritchui_pencilLockFunctions
566 sjme_scritchui_pencilLockFunctions
;
568 /** Arguments to pass for setting of listeners. */
569 #define SJME_SCRITCHUI_SET_LISTENER_ARGS(what) \
570 sjme_attrInNullable SJME_TOKEN_PASTE3(sjme_scritchui_, what, \
571 ListenerFunc) inListener, \
572 sjme_attrInNullable sjme_frontEnd* copyFrontEnd
575 * Listener that is called when an item is activated.
577 * @param inState The input state.
578 * @param inComponent The item which was activated.
579 * @return Any resultant error, if any.
582 typedef sjme_errorCode (*sjme_scritchui_activateListenerFunc
)(
583 sjme_attrInNotNull sjme_scritchui inState
,
584 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
);
587 * Listener that is called when a window closes.
589 * @param inState The input state.
590 * @param inWindow The window being closed.
591 * @return Any resultant error, @c SJME_ERROR_CANCEL_WINDOW_CLOSE is handled
592 * specifically in that it will not be treated as an error however normal
593 * application exit will not happen.
596 typedef sjme_errorCode (*sjme_scritchui_closeListenerFunc
)(
597 sjme_attrInNotNull sjme_scritchui inState
,
598 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
);
601 * Listener for input events.
603 * @param inState The input state.
604 * @param inComponent The component this event is for.
605 * @param inEvent The event which occurred.
606 * @return Any resultant error, if any.
609 typedef sjme_errorCode (*sjme_scritchui_inputListenerFunc
)(
610 sjme_attrInNotNull sjme_scritchui inState
,
611 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
612 sjme_attrInNotNull
const sjme_scritchinput_event
* inEvent
);
615 * This is called when a menu item has been activated.
617 * @param inState The input state.
618 * @param inWindow The window this is activating under.
619 * @param activatedItem The menu item that was activated.
620 * @return Any resultant error, if any.
623 typedef sjme_errorCode (*sjme_scritchui_menuItemActivateListenerFunc
)(
624 sjme_attrInNotNull sjme_scritchui inState
,
625 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
626 sjme_attrInNotNull sjme_scritchui_uiMenuKind activatedItem
);
629 * Callback that is used to draw the given component.
631 * @param inState The ScritchUI state.
632 * @param inComponent The component to draw on.
633 * @param g The graphics used for drawing.
634 * @param sw Surface width.
635 * @param sh Surface height.
636 * @param special Special value for painting, may be @c 0 or any
637 * other value if it is meaningful to what is being painted.
638 * @return Any error as required.
641 typedef sjme_errorCode (*sjme_scritchui_paintListenerFunc
)(
642 sjme_attrInNotNull sjme_scritchui inState
,
643 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
644 sjme_attrInNotNull sjme_scritchui_pencil g
,
645 sjme_attrInPositive sjme_jint sw
,
646 sjme_attrInPositive sjme_jint sh
,
647 sjme_attrInValue sjme_jint special
);
650 * Listener callback for when a screen has been queried or it has been
653 * @param inState The input state.
654 * @param updateType The type of update this is for.
655 * @param inScreen The screen that has been updated.
656 * @return Any error code if applicable.
659 typedef sjme_errorCode (*sjme_scritchui_screenListenerFunc
)(
660 sjme_attrInNotNull sjme_scritchui inState
,
661 sjme_attrInValue sjme_scritchui_screenUpdateType updateType
,
662 sjme_attrInNotNull sjme_scritchui_uiScreen inScreen
);
665 * Listener that is called when the size of a component changes.
667 * @param inState The input state.
668 * @param inComponent The component that was resized.
669 * @param newWidth The new component width.
670 * @param newHeight The new component height.
671 * @return On any error if applicable.
674 typedef sjme_errorCode (*sjme_scritchui_sizeListenerFunc
)(
675 sjme_attrInNotNull sjme_scritchui inState
,
676 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
677 sjme_attrInPositiveNonZero sjme_jint newWidth
,
678 sjme_attrInPositiveNonZero sjme_jint newHeight
);
681 * Listener for views so that a sub-component can suggest a size that it
684 * @param inState The ScritchUI state.
685 * @param inView The view this is in.
686 * @param subComponent The component that is suggesting a size.
687 * @param subDim The size of the sub-component.
688 * @return Any resultant error, if any.
691 typedef sjme_errorCode (*sjme_scritchui_sizeSuggestListenerFunc
)(
692 sjme_attrInNotNull sjme_scritchui inState
,
693 sjme_attrInNotNull sjme_scritchui_uiComponent inView
,
694 sjme_attrInNotNull sjme_scritchui_uiComponent subComponent
,
695 sjme_attrInNotNull
const sjme_scritchui_dim
* subDim
);
698 * Listener that is called before and after the state within a component
699 * has changed, when @c isAfterUpdate is @c SJME_JNI_FALSE then the component
700 * is about to be updated.
702 * @param inState The input state.
703 * @param inComponent The component where this event occurred.
704 * @param isAfterUpdate Is this after the update has occurred?
705 * @return Any resultant error, if any.
708 typedef sjme_errorCode (*sjme_scritchui_valueUpdateListenerFunc
)(
709 sjme_attrInNotNull sjme_scritchui inState
,
710 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
711 sjme_attrInValue sjme_jboolean isAfterUpdate
);
714 * Listener for view rectangle changes.
716 * @param inState The input state.
717 * @param inComponent The component that triggered this.
718 * @param inViewRect The new view rectangle.
719 * @return Any resultant error, if any.
722 typedef sjme_errorCode (*sjme_scritchui_viewListenerFunc
)(
723 sjme_attrInNotNull sjme_scritchui inState
,
724 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
725 sjme_attrInNotNull
const sjme_scritchui_rect
* inViewRect
);
728 * Listener for changes in if a component becomes visible or not.
730 * @param inState The input state.
731 * @param inComponent The component which has its visibility changed.
732 * @param fromVisible The previous visible state.
733 * @param toVisible The current visible state.
734 * @return Any resultant error, if any.
737 typedef sjme_errorCode (*sjme_scritchui_visibleListenerFunc
)(
738 sjme_attrInNotNull sjme_scritchui inState
,
739 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
740 sjme_attrInValue sjme_jboolean fromVisible
,
741 sjme_attrInValue sjme_jboolean toVisible
);
743 /** Void listener function. */
744 typedef sjme_errorCode (*sjme_scritchui_voidListenerFunc
)(void);
747 * Obtains the flags which describe the interface.
749 * @param inState The input ScritchUI state.
750 * @param outFlags The output flags for this interface.
751 * @return Any error code if applicable.
754 typedef sjme_errorCode (*sjme_scritchui_apiFlagsFunc
)(
755 sjme_attrInNotNull sjme_scritchui inState
,
756 sjme_attrOutNotNull sjme_jint outFlags
);
759 * Initializes the native UI interface needed by ScritchUI.
761 * @param inPool The allocation pool to use.
762 * @param outState The resultant state.
763 * @param inImplFunc The implementation functions to use.
764 * @param loopExecute Optional callback for loop execution, may be @c NULL ,
765 * the passed argument is always the state.
766 * @param initFrontEnd Optional initial front end data.
767 * @return Any error code if applicable.
770 typedef sjme_errorCode (*sjme_scritchui_apiInitFunc
)(
771 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
772 sjme_attrInOutNotNull sjme_scritchui
* outState
,
773 sjme_attrInNotNull
const sjme_scritchui_implFunctions
* inImplFunc
,
774 sjme_attrInNullable sjme_thread_mainFunc loopExecute
,
775 sjme_attrInNullable sjme_frontEnd
* initFrontEnd
);
778 * Gets the first selected index of a choice or otherwise @c -1 .
780 * @param inState The input state.
781 * @param inComponent The choice to read from.
782 * @param outIndex The resultant index.
783 * @return Any resultant error, if any.
786 typedef sjme_errorCode (*sjme_scritchui_choiceGetSelectedIndexFunc
)(
787 sjme_attrInNotNull sjme_scritchui inState
,
788 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
789 sjme_attrOutNotNull sjme_jint
* outIndex
);
792 * Gets the specified item template.
794 * @param inState The input state.
795 * @param inComponent The choice to read from.
796 * @param atIndex The index to obtain the template of.
797 * @param inItemTemplate A copy of the item template.
798 * @return Any resultant error, if any.
801 typedef sjme_errorCode (*sjme_scritchui_choiceItemGetFunc
)(
802 sjme_attrInNotNull sjme_scritchui inState
,
803 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
804 sjme_attrInPositive sjme_jint atIndex
,
805 sjme_attrOutNotNull sjme_scritchui_uiChoiceItem outItemTemplate
);
808 * Inserts a blank item at the given index.
810 * @param inState The input state.
811 * @param inComponent The choice to modify.
812 * @param inOutIndex The input index to insert at, then resultant index
813 * where it was added.
814 * @return Any resultant error, if any.
817 typedef sjme_errorCode (*sjme_scritchui_choiceItemInsertFunc
)(
818 sjme_attrInNotNull sjme_scritchui inState
,
819 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
820 sjme_attrInOutNotNull sjme_jint
* inOutIndex
);
823 * Removes the specified item at the given index.
825 * @param inState The input state.
826 * @param inComponent The choice to modify.
827 * @param atIndex The index to remove.
828 * @return Any resultant error, if any.
831 typedef sjme_errorCode (*sjme_scritchui_choiceItemRemoveFunc
)(
832 sjme_attrInNotNull sjme_scritchui inState
,
833 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
834 sjme_attrInPositive sjme_jint atIndex
);
837 * Removes all items from the given choice.
839 * @param inState The input state.
840 * @param inComponent The choice to modify.
841 * @return Any resultant error, if any.
844 typedef sjme_errorCode (*sjme_scritchui_choiceItemRemoveAllFunc
)(
845 sjme_attrInNotNull sjme_scritchui inState
,
846 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
);
850 * Sets whether the specified choice item is enabled.
852 * @param inState The input state.
853 * @param inComponent The choice to modify.
854 * @param atIndex The index to modify.
855 * @param isEnabled If the item should be enabled.
856 * @return Any resultant error, if any.
859 typedef sjme_errorCode (*sjme_scritchui_choiceItemSetEnabledFunc
)(
860 sjme_attrInNotNull sjme_scritchui inState
,
861 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
862 sjme_attrInPositive sjme_jint atIndex
,
863 sjme_attrInNotNull sjme_jboolean isEnabled
);
866 * Sets the image of the specified choice item.
868 * @param inState The input state.
869 * @param inComponent The choice to modify.
870 * @param atIndex The index to modify.
871 * @param inRgb The RGB data, may be @c NULL to clear the image.
872 * @param inRgbOff The offset in the RGB data.
873 * @param inRgbDataLen The data length of the RGB data.
874 * @param inRgbScanLen The scanline length of the RGB data.
875 * @param width The width of the image.
876 * @param height The height of the image.
877 * @return Any resultant error, if any.
880 typedef sjme_errorCode (*sjme_scritchui_choiceItemSetImageFunc
)(
881 sjme_attrInNotNull sjme_scritchui inState
,
882 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
883 sjme_attrInPositive sjme_jint atIndex
,
884 sjme_attrInNullable sjme_jint
* inRgb
,
885 sjme_attrInPositive sjme_jint inRgbOff
,
886 sjme_attrInPositiveNonZero sjme_jint inRgbDataLen
,
887 sjme_attrInPositiveNonZero sjme_jint inRgbScanLen
,
888 sjme_attrInPositiveNonZero sjme_jint width
,
889 sjme_attrInPositiveNonZero sjme_jint height
);
892 * Sets whether the specified choice item is selected.
894 * @param inState The input state.
895 * @param inComponent The choice to modify.
896 * @param atIndex The index to modify.
897 * @param isSelected If the item should be selected.
898 * @return Any resultant error, if any.
901 typedef sjme_errorCode (*sjme_scritchui_choiceItemSetSelectedFunc
)(
902 sjme_attrInNotNull sjme_scritchui inState
,
903 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
904 sjme_attrInPositive sjme_jint atIndex
,
905 sjme_attrInNotNull sjme_jboolean isSelected
);
908 * Sets the string of the specified choice item.
910 * @param inState The input state.
911 * @param inComponent The choice to modify.
912 * @param atIndex The index to modify.
913 * @param inString The string to set, @c NULL will clear it.
914 * @return Any resultant error, if any.
917 typedef sjme_errorCode (*sjme_scritchui_choiceItemSetStringFunc
)(
918 sjme_attrInNotNull sjme_scritchui inState
,
919 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
920 sjme_attrInPositive sjme_jint atIndex
,
921 sjme_attrInNullable sjme_lpcstr inString
);
924 * Returns the length of the choice list.
926 * @param inState The input state.
927 * @param inComponent The choice to get the length of.
928 * @param outLength The resultant length.
929 * @return Any resultant error, if any.
932 typedef sjme_errorCode (*sjme_scritchui_choiceLengthFunc
)(
933 sjme_attrInNotNull sjme_scritchui inState
,
934 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
935 sjme_attrOutNotNull sjme_jint
* outLength
);
938 * Grabs the focus onto this item.
940 * @param inState The input state.
941 * @param inComponent The input component.
942 * @return Any resultant error, if any.
945 typedef sjme_errorCode (*sjme_scritchui_componentFocusGrabFunc
)(
946 sjme_attrInNotNull sjme_scritchui inState
,
947 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
);
950 * Checks whether the given component has focus.
952 * @param inState The input state.
953 * @param inComponent The input component.
954 * @param outHasFocus The result of whether the component has focus.
955 * @return Any resultant error, if any.
958 typedef sjme_errorCode (*sjme_scritchui_componentFocusHasFunc
)(
959 sjme_attrInNotNull sjme_scritchui inState
,
960 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
961 sjme_attrOutNotNull sjme_jboolean
* outHasFocus
);
964 * Gets the parent of this component.
966 * @param inState The ScritchUI state.
967 * @param inComponent The component to get the parent of.
968 * @param outParent The resultant parent that contains this, or @c NULL if
969 * there is no parent.
970 * @return Any resultant error, if any.
973 typedef sjme_errorCode (*sjme_scritchui_componentGetParentFunc
)(
974 sjme_attrInNotNull sjme_scritchui inState
,
975 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
976 sjme_attrOutNotNull sjme_scritchui_uiComponent
* outParent
);
979 * Returns the position of the given component.
981 * @param inState The input state.
982 * @param inComponent The component to get the position of.
983 * @param outX The output X coordinate.
984 * @param outY The output Y coordinate.
985 * @return Any resultant error, if any.
988 typedef sjme_errorCode (*sjme_scritchui_componentPositionFunc
)(
989 sjme_attrInNotNull sjme_scritchui inState
,
990 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
991 sjme_attrOutNullable sjme_jint
* outX
,
992 sjme_attrOutNullable sjme_jint
* outY
);
995 * Repaints the given component.
997 * @param inState The input state.
998 * @param inComponent The input component.
999 * @param x The X position.
1000 * @param y The Y position.
1001 * @param width The width.
1002 * @param height The height.
1003 * @return Any error code if applicable.
1006 typedef sjme_errorCode (*sjme_scritchui_componentRepaintFunc
)(
1007 sjme_attrInNotNull sjme_scritchui inState
,
1008 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1009 sjme_attrInPositive sjme_jint x
,
1010 sjme_attrInPositive sjme_jint y
,
1011 sjme_attrInPositiveNonZero sjme_jint width
,
1012 sjme_attrInPositiveNonZero sjme_jint height
);
1015 * Revalidates the given component.
1017 * @param inState The input state.
1018 * @param inComponent The component to be revalidated.
1019 * @return On any error if applicable.
1022 typedef sjme_errorCode (*sjme_scritchui_componentRevalidateFunc
)(
1023 sjme_attrInNotNull sjme_scritchui inState
,
1024 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
);
1027 * Sets the activation listener for the given choice.
1029 * @param inState The input state.
1030 * @param inComponent The choice to update.
1031 * @param inListener The listener to set.
1032 * @param copyFrontEnd Any front end data to copy.
1033 * @return Any resultant error, if any.
1036 typedef sjme_errorCode (*sjme_scritchui_componentSetActivateListenerFunc
)(
1037 sjme_attrInNotNull sjme_scritchui inState
,
1038 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1039 SJME_SCRITCHUI_SET_LISTENER_ARGS(activate
));
1042 * Sets the input listener for the given component.
1044 * @param inState The input state.
1045 * @param inComponent The component to set the listener for.
1046 * @param inListener The listener for events, may be @c NULL to clear
1047 * the existing listener.
1048 * @param copyFrontEnd The front end data to copy, may be @c NULL .
1049 * @return Any resultant error, if any.
1052 typedef sjme_errorCode (*sjme_scritchui_componentSetInputListenerFunc
)(
1053 sjme_attrInNotNull sjme_scritchui inState
,
1054 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1055 SJME_SCRITCHUI_SET_LISTENER_ARGS(input
));
1058 * Sets the paint listener for the given component.
1060 * @param inState The input state.
1061 * @param inComponent The component to set the listener for.
1062 * @param inListener The listener for paint events, may be @c NULL to clear
1063 * the existing listener.
1064 * @param copyFrontEnd The front end data to copy, may be @c NULL .
1065 * @return Any error code if applicable.
1068 typedef sjme_errorCode (*sjme_scritchui_componentSetPaintListenerFunc
)(
1069 sjme_attrInNotNull sjme_scritchui inState
,
1070 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1071 SJME_SCRITCHUI_SET_LISTENER_ARGS(paint
));
1074 * Sets the listener for size events.
1076 * @param inState The input state.
1077 * @param inComponent The component to set the listener for.
1078 * @param inListener The listener to set to or to clear.
1079 * @param copyFrontEnd Any front end data to be copied.
1080 * @return Any resultant error, if any.
1083 typedef sjme_errorCode (*sjme_scritchui_componentSetSizeListenerFunc
)(
1084 sjme_attrInNotNull sjme_scritchui inState
,
1085 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1086 SJME_SCRITCHUI_SET_LISTENER_ARGS(size
));
1089 * Sets the update listener for the given choice.
1091 * @param inState The input state.
1092 * @param inComponent The choice to update.
1093 * @param inListener The listener to set.
1094 * @param copyFrontEnd Any front end data to copy.
1095 * @return Any resultant error, if any.
1098 typedef sjme_errorCode (*sjme_scritchui_componentSetValueUpdateListenerFunc
)(
1099 sjme_attrInNotNull sjme_scritchui inState
,
1100 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1101 SJME_SCRITCHUI_SET_LISTENER_ARGS(valueUpdate
));
1104 * Sets the listener to call when the visibility of a component changes.
1106 * @param inState The input state.
1107 * @param inComponent The component to set for.
1108 * @param inListener The listener to use.
1109 * @param copyFrontEnd The front end data to use.
1110 * @return Any resultant error, if any.
1113 typedef sjme_errorCode (*sjme_scritchui_componentSetVisibleListenerFunc
)(
1114 sjme_attrInNotNull sjme_scritchui inState
,
1115 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1116 SJME_SCRITCHUI_SET_LISTENER_ARGS(visible
));
1119 * Returns the size of the given component.
1121 * @param inState The input state.
1122 * @param inComponent The component to get the size of.
1123 * @param outWidth The output width.
1124 * @param outHeight The output height.
1125 * @return Any resultant error, if any.
1128 typedef sjme_errorCode (*sjme_scritchui_componentSizeFunc
)(
1129 sjme_attrInNotNull sjme_scritchui inState
,
1130 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1131 sjme_attrOutNullable sjme_jint
* outWidth
,
1132 sjme_attrOutNullable sjme_jint
* outHeight
);
1135 * Adds the given component to the specified container.
1137 * @param inState The input state.
1138 * @param inContainer The container to place the component within.
1139 * @param addComponent The component to add to the container.
1140 * @return Any error code if applicable.
1143 typedef sjme_errorCode (*sjme_scritchui_containerAddFunc
)(
1144 sjme_attrInNotNull sjme_scritchui inState
,
1145 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer
,
1146 sjme_attrInNotNull sjme_scritchui_uiComponent addComponent
);
1149 * Removes the given component from the specified container.
1151 * @param inState The input state.
1152 * @param inContainer The container to remove the component from.
1153 * @param removeComponent The component to remove from the container.
1154 * @return Any error code if applicable.
1157 typedef sjme_errorCode (*sjme_scritchui_containerRemoveFunc
)(
1158 sjme_attrInNotNull sjme_scritchui inState
,
1159 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer
,
1160 sjme_attrInNotNull sjme_scritchui_uiComponent removeComponent
);
1163 * Removes all components from the container.
1165 * @param inState The input state.
1166 * @param inContainer The container to remove everything from.
1167 * @return Any error code if applicable.
1170 typedef sjme_errorCode (*sjme_scritchui_containerRemoveAllFunc
)(
1171 sjme_attrInNotNull sjme_scritchui inState
,
1172 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer
);
1175 * Sets the bounds of a component within the container.
1177 * @param inState The input state.
1178 * @param inContainer The container to set the component within.
1179 * @param inComponent The component to be placed and resized.
1180 * @param x The X position.
1181 * @param y The Y position.
1182 * @param width The width.
1183 * @param height The height.
1184 * @return Any error code if applicable.
1187 typedef sjme_errorCode (*sjme_scritchui_containerSetBoundsFunc
)(
1188 sjme_attrInNotNull sjme_scritchui inState
,
1189 sjme_attrInNotNull sjme_scritchui_uiComponent inContainer
,
1190 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1191 sjme_attrInPositive sjme_jint x
,
1192 sjme_attrInPositive sjme_jint y
,
1193 sjme_attrInPositiveNonZero sjme_jint width
,
1194 sjme_attrInPositiveNonZero sjme_jint height
);
1197 * Returns the default built-in font.
1199 * @param inState The input state.
1200 * @param outFont The resultant font.
1201 * @return Any resultant error, if any.
1204 typedef sjme_errorCode (*sjme_scritchui_fontBuiltinFunc
)(
1205 sjme_attrInNotNull sjme_scritchui inState
,
1206 sjme_attrOutNotNull sjme_scritchui_pencilFont
* outFont
);
1209 * Derives a new font from an existing font.
1211 * @param inState The input state.
1212 * @param inFont The input font to derive.
1213 * @param inStyle The style to switch to.
1214 * @param inPixelSize The pixel size to use.
1215 * @param outDerived The resultant derived font.
1216 * @return Any resultant error, if any.
1219 typedef sjme_errorCode (*sjme_scritchui_fontDeriveFunc
)(
1220 sjme_attrInNotNull sjme_scritchui inState
,
1221 sjme_attrInNotNull sjme_scritchui_pencilFont inFont
,
1222 sjme_attrInValue sjme_scritchui_pencilFontStyle inStyle
,
1223 sjme_attrInPositiveNonZero sjme_jint inPixelSize
,
1224 sjme_attrOutNotNull sjme_scritchui_pencilFont
* outDerived
);
1227 * Creates a hardware reference bracket to the native hardware graphics.
1229 * @param inState The UI state.
1230 * @param outPencil The resultant pencil.
1231 * @param outWeakPencil The weak reference to the pencil.
1232 * @param pf The @c sjme_gfx_pixelFormat used for the draw.
1233 * @param bw The buffer width, this is the scanline width of the buffer.
1234 * @param bh The buffer height.
1235 * @param inLockFuncs The locking functions to use for buffer access.
1236 * @param inLockFrontEndCopy Front end copy data for locks.
1237 * @param sx Starting surface X coordinate.
1238 * @param sy Starting surface Y coordinate.
1239 * @param sw Surface width.
1240 * @param sh Surface height.
1241 * @param pencilFrontEndCopy Front end data that goes into the pencil.
1242 * @return An error if the requested graphics are not valid.
1245 typedef sjme_errorCode (*sjme_scritchui_hardwareGraphicsFunc
)(
1246 sjme_attrInNotNull sjme_scritchui inState
,
1247 sjme_attrOutNotNull sjme_scritchui_pencil
* outPencil
,
1248 sjme_attrOutNullable sjme_alloc_weak
* outWeakPencil
,
1249 sjme_attrInValue sjme_gfx_pixelFormat pf
,
1250 sjme_attrInPositiveNonZero sjme_jint bw
,
1251 sjme_attrInPositiveNonZero sjme_jint bh
,
1252 sjme_attrInNullable
const sjme_scritchui_pencilLockFunctions
* inLockFuncs
,
1253 sjme_attrInNullable
const sjme_frontEnd
* inLockFrontEndCopy
,
1254 sjme_attrInValue sjme_jint sx
,
1255 sjme_attrInValue sjme_jint sy
,
1256 sjme_attrInPositiveNonZero sjme_jint sw
,
1257 sjme_attrInPositiveNonZero sjme_jint sh
,
1258 sjme_attrInNullable
const sjme_frontEnd
* pencilFrontEndCopy
);
1261 * Sets the label of the specified component.
1263 * @param inState The input state.
1264 * @param inCommon The item to set the label for.
1265 * @param inString The label to set.
1266 * @return Any resultant error, if any.
1269 typedef sjme_errorCode (*sjme_scritchui_labelSetStringFunc
)(
1270 sjme_attrInNotNull sjme_scritchui inState
,
1271 sjme_attrInNotNull sjme_scritchui_uiCommon inCommon
,
1272 sjme_attrInNullable sjme_lpcstr inString
);
1275 * Returns the color for the given element based on the current look and feel.
1277 * @param inState The current state.
1278 * @param inContext Optional context that can be targetted at a widget to get
1279 * its color themeing.
1280 * @param outRGB The resultant RGB color.
1281 * @param elementColor The color to request.
1282 * @return On any resultant error, if any.
1285 typedef sjme_errorCode (*sjme_scritchui_lafElementColorFunc
)(
1286 sjme_attrInNotNull sjme_scritchui inState
,
1287 sjme_attrInNullable sjme_scritchui_uiComponent inContext
,
1288 sjme_attrOutNotNull sjme_jint
* outRGB
,
1289 sjme_attrInValue sjme_scritchui_lafElementColorType elementColor
);
1292 * Creates a new list.
1294 * @param inState The input state.
1295 * @param outPanel The resultant list.
1296 * @param inChoiceType The type of choice this is.
1297 * @return Any error code if applicable.
1300 typedef sjme_errorCode (*sjme_scritchui_listNewFunc
)(
1301 sjme_attrInNotNull sjme_scritchui inState
,
1302 sjme_attrInOutNotNull sjme_scritchui_uiList
* outList
,
1303 sjme_attrInValue sjme_scritchui_choiceType inChoiceType
);
1306 * Execute the given callback within the event loop of the GUI.
1308 * @param inState The input state.
1309 * @param callback The callback to execute.
1310 * @param anything A value that can be passed to the listener.
1311 * @return Any error code if applicable.
1314 typedef sjme_errorCode (*sjme_scritchui_loopExecuteFunc
)(
1315 sjme_attrInNotNull sjme_scritchui inState
,
1316 sjme_attrInNotNull sjme_thread_mainFunc callback
,
1317 sjme_attrInNullable sjme_thread_parameter anything
);
1320 * Determines whether the current thread is in the event loop or not.
1322 * @param inState The input state.
1323 * @param outInThread The result of whether this is in the event loop.
1324 * @return Any error code if applicable.
1327 typedef sjme_errorCode (*sjme_scritchui_loopIsInThreadFunc
)(
1328 sjme_attrInNotNull sjme_scritchui inState
,
1329 sjme_attrInOutNotNull sjme_jboolean
* outInThread
);
1332 * Iterates a single run of the event loop.
1334 * @param inState The input ScritchUI state.
1335 * @param blocking If the iteration should block for something to happen.
1336 * @param outHasTerminated Has the GUI interface terminated?
1337 * @return Any error code if applicable.
1340 typedef sjme_errorCode (*sjme_scritchui_loopIterateFunc
)(
1341 sjme_attrInNotNull sjme_scritchui inState
,
1342 sjme_attrInValue sjme_jboolean blocking
,
1343 sjme_attrOutNullable sjme_jboolean
* outHasTerminated
);
1346 * Creates a new menu bar.
1348 * @param inState The input state.
1349 * @param outMenuBar The resultant menu bar.
1350 * @return Any error code if applicable.
1353 typedef sjme_errorCode (*sjme_scritchui_menuBarNewFunc
)(
1354 sjme_attrInNotNull sjme_scritchui inState
,
1355 sjme_attrInOutNotNull sjme_scritchui_uiMenuBar
* outMenuBar
);
1358 * Inserts the given menu item into the menu at the specified index.
1360 * @param inState The ScritchUI state.
1361 * @param intoMenu The menu to insert into.
1362 * @param atIndex The index to insert at.
1363 * @param childItem The child menu item to add.
1364 * @return Any resultant error, if any.
1367 typedef sjme_errorCode (*sjme_scritchui_menuInsertFunc
)(
1368 sjme_attrInNotNull sjme_scritchui inState
,
1369 sjme_attrInNotNull sjme_scritchui_uiMenuKind intoMenu
,
1370 sjme_attrInPositive sjme_jint atIndex
,
1371 sjme_attrInNotNull sjme_scritchui_uiMenuKind childItem
);
1374 * Creates a new menu item.
1376 * @param inState The input state.
1377 * @param outMenuItem The resultant menu item.
1378 * @return Any error code if applicable.
1381 typedef sjme_errorCode (*sjme_scritchui_menuItemNewFunc
)(
1382 sjme_attrInNotNull sjme_scritchui inState
,
1383 sjme_attrInOutNotNull sjme_scritchui_uiMenuItem
* outMenuItem
);
1386 * Creates a new menu.
1388 * @param inState The input state.
1389 * @param outMenu The resultant menu.
1390 * @return Any error code if applicable.
1393 typedef sjme_errorCode (*sjme_scritchui_menuNewFunc
)(
1394 sjme_attrInNotNull sjme_scritchui inState
,
1395 sjme_attrInOutNotNull sjme_scritchui_uiMenu
* outMenu
);
1398 * Removes the item at the specified index from this menu.
1400 * @param inState The ScritchUI state.
1401 * @param fromMenu The menu to remove from.
1402 * @param atIndex The index to remove.
1403 * @return Any resultant error, if any.
1406 typedef sjme_errorCode (*sjme_scritchui_menuRemoveFunc
)(
1407 sjme_attrInNotNull sjme_scritchui inState
,
1408 sjme_attrInNotNull sjme_scritchui_uiMenuKind fromMenu
,
1409 sjme_attrInPositive sjme_jint atIndex
);
1412 * Removes all items from the given menu.
1414 * @param inState The ScritchUI state.
1415 * @param fromMenu The menu to remove from.
1416 * @return Any resultant error, if any.
1419 typedef sjme_errorCode (*sjme_scritchui_menuRemoveAllFunc
)(
1420 sjme_attrInNotNull sjme_scritchui inState
,
1421 sjme_attrInNotNull sjme_scritchui_uiMenuKind fromMenu
);
1424 * Deletes the given object.
1426 * @param inState The input state.
1427 * @param inOutObject The object to delete.
1428 * @return Any resultant error, if any.
1431 typedef sjme_errorCode (*sjme_scritchui_objectDeleteFunc
)(
1432 sjme_attrInNotNull sjme_scritchui inState
,
1433 sjme_attrInOutNotNull sjme_scritchui_uiCommon
* inOutObject
);
1436 * Enables or disables focus on a panel.
1438 * @param inState The input state.
1439 * @param inPanel The input panel.
1440 * @param enableFocus Should focus be enabled?
1441 * @return Any error code if applicable.
1444 typedef sjme_errorCode (*sjme_scritchui_panelEnableFocusFunc
)(
1445 sjme_attrInNotNull sjme_scritchui inState
,
1446 sjme_attrInNotNull sjme_scritchui_uiPanel inPanel
,
1447 sjme_attrInValue sjme_jboolean enableFocus
,
1448 sjme_attrInValue sjme_jboolean defaultFocus
);
1451 * Creates a new panel.
1453 * @param inState The input state.
1454 * @param outPanel The resultant panel.
1455 * @return Any error code if applicable.
1458 typedef sjme_errorCode (*sjme_scritchui_panelNewFunc
)(
1459 sjme_attrInNotNull sjme_scritchui inState
,
1460 sjme_attrInOutNotNull sjme_scritchui_uiPanel
* outPanel
);
1463 * Sets the screen listener callback for screen changes.
1465 * @param inState The input state.
1466 * @param callback The callback for screen information and changes.
1467 * @return Any error code if applicable.
1470 typedef sjme_errorCode (*sjme_scritchui_screenSetListenerFunc
)(
1471 sjme_attrInNotNull sjme_scritchui inState
,
1472 SJME_SCRITCHUI_SET_LISTENER_ARGS(screen
));
1475 * Obtains and queries the screens which are attached to the system displays.
1477 * @param inState The input state.
1478 * @param outScreens The resultant screens.
1479 * @param inOutNumScreens The number of screens for input and output.
1480 * @return Any error code if applicable.
1483 typedef sjme_errorCode (*sjme_scritchui_screensFunc
)(
1484 sjme_attrInNotNull sjme_scritchui inState
,
1485 sjme_attrOutNotNull sjme_scritchui_uiScreen
* outScreens
,
1486 sjme_attrInOutNotNull sjme_jint
* inOutNumScreens
);
1489 * Creates a new scroll panel which contains other components within a viewport
1492 * @param inState The ScritchUI state.
1493 * @param outScrollPanel The newly created scroll panel.
1494 * @return Any resultant error, if any.
1497 typedef sjme_errorCode (*sjme_scritchui_scrollPanelNewFunc
)(
1498 sjme_attrInNotNull sjme_scritchui inState
,
1499 sjme_attrOutNotNull sjme_scritchui_uiScrollPanel
* outScrollPanel
);
1502 * Gets the current view rectangle of a viewport.
1504 * @param inState The ScritchUI state.
1505 * @param inComponent The viewport.
1506 * @param outViewRect The current view rectangle.
1507 * @return Any resultant error, if any.
1510 typedef sjme_errorCode (*sjme_scritchui_viewGetViewFunc
)(
1511 sjme_attrInNotNull sjme_scritchui inState
,
1512 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1513 sjme_attrOutNotNull sjme_scritchui_rect
* outViewRect
);
1516 * Sets the area that the scroll panel provides a viewport area, this area
1517 * may be larger than the viewport and widgets may be placed inside.
1519 * @param inState The ScritchUI state.
1520 * @param inComponent The viewport.
1521 * @param inViewArea The view area to set.
1522 * @return Any resultant error, if any.
1525 typedef sjme_errorCode (*sjme_scritchui_viewSetAreaFunc
)(
1526 sjme_attrInNotNull sjme_scritchui inState
,
1527 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1528 sjme_attrInNotNull
const sjme_scritchui_dim
* inViewArea
);
1531 * Sets the view rectangle of a viewport.
1533 * @param inState The ScritchUI state.
1534 * @param inComponent The viewport.
1535 * @param inViewPos The new view position to set.
1536 * @return Any resultant error, if any.
1539 typedef sjme_errorCode (*sjme_scritchui_viewSetViewFunc
)(
1540 sjme_attrInNotNull sjme_scritchui inState
,
1541 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1542 sjme_attrInNotNull
const sjme_scritchui_point
* inViewPos
);
1545 * Sets the listener which is called for a viewport when a contained component
1546 * has a suggestion as to how large it should be to contain it.
1548 * @param inState The ScritchUI state.
1549 * @param inComponent The viewport.
1550 * @param inListener The listener to set.
1551 * @param copyFrontEnd Any front-end data needed for the listener.
1552 * @return Any resultant error, if any.
1555 typedef sjme_errorCode (*sjme_scritchui_viewSetSizeSuggestListenerFunc
)(
1556 sjme_attrInNotNull sjme_scritchui inState
,
1557 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1558 SJME_SCRITCHUI_SET_LISTENER_ARGS(sizeSuggest
));
1561 * Sets the listener which is called whenever the viewport changes such as it
1564 * @param inState The ScritchUI state.
1565 * @param inComponent The viewport.
1566 * @param inListener The listener to set.
1567 * @param copyFrontEnd Any front-end data needed for the listener.
1568 * @return Any resultant error, if any.
1571 typedef sjme_errorCode (*sjme_scritchui_viewSetViewListenerFunc
)(
1572 sjme_attrInNotNull sjme_scritchui inState
,
1573 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1574 SJME_SCRITCHUI_SET_LISTENER_ARGS(view
));
1577 * Void listener set.
1579 * @param inState The ScritchUI state.
1580 * @param inComponent The component.
1581 * @param inListener The listener to set.
1582 * @param copyFrontEnd Any front-end data needed for the listener.
1583 * @return Any resultant error, if any.
1586 typedef sjme_errorCode (*sjme_scritchui_voidSetVoidListenerFunc
)(
1587 sjme_attrInNotNull sjme_scritchui inState
,
1588 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
1589 SJME_SCRITCHUI_SET_LISTENER_ARGS(void));
1592 * Sets the minimum content size for windows.
1594 * @param inState The input state.
1595 * @param inWindow The window to set the minimum content size for.
1596 * @param width The width to set.
1597 * @param height The height to set.
1598 * @return Any error code if applicable, such as if the width and/or height
1599 * are zero or negative.
1602 typedef sjme_errorCode (*sjme_scritchui_windowContentMinimumSizeFunc
)(
1603 sjme_attrInNotNull sjme_scritchui inState
,
1604 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1605 sjme_attrInPositiveNonZero sjme_jint width
,
1606 sjme_attrInPositiveNonZero sjme_jint height
);
1609 * Creates a new window.
1611 * @param inState The input state.
1612 * @param outWindow The resultant newly created window.
1613 * @return Any error code if applicable.
1616 typedef sjme_errorCode (*sjme_scritchui_windowNewFunc
)(
1617 sjme_attrInNotNull sjme_scritchui inState
,
1618 sjme_attrInOutNotNull sjme_scritchui_uiWindow
* outWindow
);
1621 * Sets the close listener for a window.
1623 * @param inState The input state.
1624 * @param inWindow The window to set for.
1625 * @param inListener The listener to use.
1626 * @param copyFrontEnd The front end data to use.
1627 * @return Any resultant error, if any.
1630 typedef sjme_errorCode (*sjme_scritchui_windowSetCloseListenerFunc
)(
1631 sjme_attrInNotNull sjme_scritchui inState
,
1632 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1633 SJME_SCRITCHUI_SET_LISTENER_ARGS(close
));
1636 * Sets the menu bar for a window.
1638 * @param inState The input state.
1639 * @param inWindow The window to set the menu bar of.
1640 * @param inMenuBar The menu bar to set, if @c NULL then it is removed.
1641 * @return Any resultant error, if any.
1644 typedef sjme_errorCode (*sjme_scritchui_windowSetMenuBarFunc
)(
1645 sjme_attrInNotNull sjme_scritchui inState
,
1646 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1647 sjme_attrInNullable sjme_scritchui_uiMenuBar inMenuBar
);
1650 * Sets the menu item activation listener for a window.
1652 * @param inState The input state.
1653 * @param inWindow The window to set for.
1654 * @param inListener The listener to use.
1655 * @param copyFrontEnd The front end data to use.
1656 * @return Any resultant error, if any.
1659 typedef sjme_errorCode (*sjme_scritchui_windowSetMenuItemActivateListenerFunc
)(
1660 sjme_attrInNotNull sjme_scritchui inState
,
1661 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1662 SJME_SCRITCHUI_SET_LISTENER_ARGS(menuItemActivate
));
1665 * Sets the visibility of a window.
1667 * @param inState The input state.
1668 * @param inWindow The input window.
1669 * @param isVisible Should the window be visible?
1670 * @return Any error code if applicable.
1673 typedef sjme_errorCode (*sjme_scritchui_windowSetVisibleFunc
)(
1674 sjme_attrInNotNull sjme_scritchui inState
,
1675 sjme_attrInNotNull sjme_scritchui_uiWindow inWindow
,
1676 sjme_attrInValue sjme_jboolean isVisible
);
1678 /** Quicker API declaration in struct. */
1679 #define SJME_SCRITCHUI_QUICK_API(x) \
1680 SJME_TOKEN_PASTE3(sjme_scritchui_, x, Func) x
1682 struct sjme_scritchui_apiFunctions
1685 SJME_SCRITCHUI_QUICK_API(apiFlags
);
1687 /** Get the first selected index of a choice. */
1688 SJME_SCRITCHUI_QUICK_API(choiceGetSelectedIndex
);
1690 /** Gets the item information. */
1691 SJME_SCRITCHUI_QUICK_API(choiceItemGet
);
1693 /** Inserts an item into the given choice. */
1694 SJME_SCRITCHUI_QUICK_API(choiceItemInsert
);
1696 /** Removes an item from the given choice. */
1697 SJME_SCRITCHUI_QUICK_API(choiceItemRemove
);
1699 /** Removes all items from the given choice. */
1700 SJME_SCRITCHUI_QUICK_API(choiceItemRemoveAll
);
1702 /** Sets whether the given choice item is enabled. */
1703 SJME_SCRITCHUI_QUICK_API(choiceItemSetEnabled
);
1705 /** Sets the image of the given choice item. */
1706 SJME_SCRITCHUI_QUICK_API(choiceItemSetImage
);
1708 /** Sets whether the given choice item is selected. */
1709 SJME_SCRITCHUI_QUICK_API(choiceItemSetSelected
);
1711 /** Sets the string of the given choice item. */
1712 SJME_SCRITCHUI_QUICK_API(choiceItemSetString
);
1714 /** Gets the choice length. */
1715 SJME_SCRITCHUI_QUICK_API(choiceLength
);
1717 /** Grabs the focus for this component. */
1718 SJME_SCRITCHUI_QUICK_API(componentFocusGrab
);
1720 /** Checks if this component has focus. */
1721 SJME_SCRITCHUI_QUICK_API(componentFocusHas
);
1723 /** Gets the parent component of this one. */
1724 SJME_SCRITCHUI_QUICK_API(componentGetParent
);
1726 /** Get size of component. */
1727 SJME_SCRITCHUI_QUICK_API(componentPosition
);
1729 /** Repaints the given component. */
1730 SJME_SCRITCHUI_QUICK_API(componentRepaint
);
1732 /** Revalidates the given component. */
1733 SJME_SCRITCHUI_QUICK_API(componentRevalidate
);
1735 /** Set listener for when a component is activated. */
1736 SJME_SCRITCHUI_QUICK_API(componentSetActivateListener
);
1738 /** Sets the input listener for a component. */
1739 SJME_SCRITCHUI_QUICK_API(componentSetInputListener
);
1741 /** Sets the paint listener for a component. */
1742 SJME_SCRITCHUI_QUICK_API(componentSetPaintListener
);
1744 /** Sets the listener for component size events. */
1745 SJME_SCRITCHUI_QUICK_API(componentSetSizeListener
);
1747 /** Set listener for when a component value has updated. */
1748 SJME_SCRITCHUI_QUICK_API(componentSetValueUpdateListener
);
1750 /** Sets the listener for component visible events. */
1751 SJME_SCRITCHUI_QUICK_API(componentSetVisibleListener
);
1753 /** Get size of component. */
1754 SJME_SCRITCHUI_QUICK_API(componentSize
);
1756 /** Adds component to container. */
1757 SJME_SCRITCHUI_QUICK_API(containerAdd
);
1759 /** Remove component from container. */
1760 SJME_SCRITCHUI_QUICK_API(containerRemove
);
1762 /** Remove all components from a container. */
1763 SJME_SCRITCHUI_QUICK_API(containerRemoveAll
);
1765 /** Set bounds of component in a container. */
1766 SJME_SCRITCHUI_QUICK_API(containerSetBounds
);
1768 /** Returns the default built-in font. */
1769 SJME_SCRITCHUI_QUICK_API(fontBuiltin
);
1771 /** Derive a similar font. */
1772 SJME_SCRITCHUI_QUICK_API(fontDerive
);
1774 /** Hardware graphics support on arbitrary buffers. */
1775 SJME_SCRITCHUI_QUICK_API(hardwareGraphics
);
1777 /** Sets the close listener for a window. */
1778 SJME_SCRITCHUI_QUICK_API(labelSetString
);
1780 /** Returns the element color for the look and feel. */
1781 SJME_SCRITCHUI_QUICK_API(lafElementColor
);
1783 /** Creates a new list. */
1784 SJME_SCRITCHUI_QUICK_API(listNew
);
1786 /** Execute callback within the event loop. */
1787 SJME_SCRITCHUI_QUICK_API(loopExecute
);
1789 /** Execute callback later in the event loop. */
1790 sjme_scritchui_loopExecuteFunc loopExecuteLater
;
1792 /** Execute callback within the event loop and wait until termination. */
1793 sjme_scritchui_loopExecuteFunc loopExecuteWait
;
1795 /** Is the current thread in the loop? */
1796 SJME_SCRITCHUI_QUICK_API(loopIsInThread
);
1798 /** Iterates a single run of the event loop. */
1799 SJME_SCRITCHUI_QUICK_API(loopIterate
);
1801 /** Creates a new menu bar. */
1802 SJME_SCRITCHUI_QUICK_API(menuBarNew
);
1804 /** Insert the given menu item into a menu. */
1805 SJME_SCRITCHUI_QUICK_API(menuInsert
);
1807 /** Creates a new menu item. */
1808 SJME_SCRITCHUI_QUICK_API(menuItemNew
);
1810 /** Creates a new menu. */
1811 SJME_SCRITCHUI_QUICK_API(menuNew
);
1813 /** Removes an item from the menu. */
1814 SJME_SCRITCHUI_QUICK_API(menuRemove
);
1816 /** Removes all items from the menu. */
1817 SJME_SCRITCHUI_QUICK_API(menuRemoveAll
);
1819 /** Deletes an object. */
1820 SJME_SCRITCHUI_QUICK_API(objectDelete
);
1822 /** Enable focus on a panel. */
1823 SJME_SCRITCHUI_QUICK_API(panelEnableFocus
);
1825 /** Creates a new panel. */
1826 SJME_SCRITCHUI_QUICK_API(panelNew
);
1828 /** Register listener. */
1829 SJME_SCRITCHUI_QUICK_API(screenSetListener
);
1831 /** Screens available. */
1832 SJME_SCRITCHUI_QUICK_API(screens
);
1834 /** Create a new scroll panel. */
1835 SJME_SCRITCHUI_QUICK_API(scrollPanelNew
);
1837 /** Get the current view rect of a viewport. */
1838 SJME_SCRITCHUI_QUICK_API(viewGetView
);
1840 /** Set the area of the viewport's bounds, the entire scrollable area. */
1841 SJME_SCRITCHUI_QUICK_API(viewSetArea
);
1843 /** Sets the view rect of a viewport. */
1844 SJME_SCRITCHUI_QUICK_API(viewSetView
);
1846 /** Sets the size suggestion for this view. */
1847 SJME_SCRITCHUI_QUICK_API(viewSetSizeSuggestListener
);
1849 /** Sets the listener for tracking scrolling and viewport changes. */
1850 SJME_SCRITCHUI_QUICK_API(viewSetViewListener
);
1852 /** Sets minimum size of the window contents. */
1853 SJME_SCRITCHUI_QUICK_API(windowContentMinimumSize
);
1855 /** Creates a new window. */
1856 SJME_SCRITCHUI_QUICK_API(windowNew
);
1858 /** Sets the close listener for a window. */
1859 SJME_SCRITCHUI_QUICK_API(windowSetCloseListener
);
1861 /** Sets the menu bar for a window. */
1862 SJME_SCRITCHUI_QUICK_API(windowSetMenuBar
);
1864 /** Sets the activation listener for menu items in a window. */
1865 SJME_SCRITCHUI_QUICK_API(windowSetMenuItemActivateListener
);
1867 /** Sets visibility of window. */
1868 SJME_SCRITCHUI_QUICK_API(windowSetVisible
);
1871 #undef SJME_SCRITCHUI_QUICK_API
1874 * Opaque internal implementation functions.
1878 typedef struct sjme_scritchui_implInternFunctions
1879 sjme_scritchui_implInternFunctions
;
1881 /** The number of common handles. */
1882 #define SJME_SCRITCHUI_NUM_COMMON_HANDLES 4
1884 /** The number of common values. */
1885 #define SJME_SCRITCHUI_NUM_COMMON_VALUES SJME_SCRITCHUI_NUM_COMMON_HANDLES
1887 struct sjme_scritchui_uiCommonBase
1889 /** The type of what this is. */
1890 sjme_scritchui_uiType type
;
1892 /** The state which owns this. */
1893 sjme_scritchui state
;
1896 * Front-end data for this, note that ScritchUI implementations must not
1897 * use this for information as this is only to be used by front-ends.
1899 sjme_frontEnd frontEnd
;
1901 /** Opaque native handles for this, as needed. */
1902 sjme_scritchui_handle handle
[SJME_SCRITCHUI_NUM_COMMON_HANDLES
];
1904 /** Other value storage, as needed. */
1905 sjme_jint intVals
[SJME_SCRITCHUI_NUM_COMMON_VALUES
];
1909 * Window manager details to use.
1913 typedef struct sjme_scritchui_wmInfo
1915 /** Default title. */
1916 sjme_lpcstr defaultTitle
;
1918 /** X Window System Class. */
1919 sjme_lpcstr xwsClass
;
1920 } sjme_scritchui_wmInfo
;
1923 * Windowing system specific bugs.
1927 typedef struct sjme_scritchui_bugs
1929 /** Do not set content size when the window is made visible. */
1930 sjme_jboolean noContentSizeWhenVisible
;
1931 } sjme_scritchui_bugs
;
1933 struct sjme_scritchui_stateBase
1936 sjme_scritchui_uiCommonBase common
;
1938 /** Window manager information. */
1939 const sjme_scritchui_wmInfo
* wmInfo
;
1941 /** API functions to use. */
1942 const sjme_scritchui_apiFunctions
* api
;
1944 /** In thread API functions. */
1945 const sjme_scritchui_apiFunctions
* apiInThread
;
1947 /** Internal implementation functions to use. */
1948 const sjme_scritchui_internFunctions
* intern
;
1950 /** Implementation functions to use. */
1951 const sjme_scritchui_implFunctions
* impl
;
1953 /** Internal implementation functions, which are opaque. */
1954 const sjme_scritchui_implInternFunctions
* implIntern
;
1956 /** The allocation pool to use for allocations. */
1957 sjme_alloc_pool
* pool
;
1959 /** The event loop thread, if applicable. */
1960 sjme_thread loopThread
;
1962 /** Loop thread initializer if one was passed. */
1963 sjme_thread_mainFunc loopThreadInit
;
1965 /** Indicator that the main loop is ready for execution. */
1966 sjme_atomic_sjme_jint loopThreadReady
;
1968 /** The available screens. */
1969 sjme_list_sjme_scritchui_uiScreen
* screens
;
1971 /** The window manager type used. */
1972 sjme_scritchui_windowManagerType wmType
;
1974 /** The internal built-in font. */
1975 sjme_scritchui_pencilFont builtinFont
;
1977 /** The fonts which are loaded and known to the state. */
1978 sjme_scritchui_pencilFontLink
* fontChain
;
1980 /** Function to obtain the current nanotime, for input events. */
1981 sjme_nal_nanoTimeFunc nanoTime
;
1983 /** Is this a panel only interface? */
1984 sjme_jboolean isPanelOnly
;
1986 /** Wrapped ScritchUI state, if this is a wrapper. */
1987 sjme_scritchui wrappedState
;
1989 /** Reference to owning state. */
1990 sjme_atomic_sjme_pointer topState
;
1992 /** The next ID for opaque menu items. */
1993 sjme_jint nextMenuItemId
;
1995 /** Windowing system specific bugs. */
1996 sjme_scritchui_bugs bugs
;
1999 /* If dynamic libraries are not supported, we cannot do this. */
2000 #if !defined(SJME_CONFIG_SCRITCHUI_NO_DYLIB)
2003 * Initializes the API through the dynamic library.
2005 * @param inPool The pool to allocate within.
2006 * @param loopExecute Optional callback for loop execution, may be @c NULL ,
2007 * the passed argument is always the state.
2008 * @param initFrontEnd Optional initial front end data.
2009 * @param outState The resultant newly created ScritchUI state.
2010 * @return Any error code that may occur.
2013 typedef sjme_errorCode (*sjme_scritchui_dylibApiFunc
)(
2014 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
2015 sjme_attrInNullable sjme_thread_mainFunc loopExecute
,
2016 sjme_attrInNullable sjme_frontEnd
* initFrontEnd
,
2017 sjme_attrInOutNotNull sjme_scritchui
* outState
);
2019 /** The base name for the ScritchUI dynamic library. */
2020 #define SJME_SCRITCHUI_DYLIB_NAME_BASE \
2021 "squirreljme-scritchui-"
2023 /** The name of the dynamic library for ScritchUI. */
2024 #define SJME_SCRITCHUI_DYLIB_NAME(x) \
2025 SJME_SCRITCHUI_DYLIB_NAME_BASE SJME_TOKEN_STRING_PP(x)
2027 /** The path name for the dynamic library for ScritchUI. */
2028 #define SJME_SCRITCHUI_DYLIB_PATHNAME(x) \
2029 SJME_CONFIG_DYLIB_PATHNAME(SJME_SCRITCHUI_DYLIB_NAME(x))
2031 /** The symbol to use with @c sjme_scritchui_dylibApiFunc . */
2032 #define SJME_SCRITCHUI_DYLIB_SYMBOL(x) \
2033 SJME_TOKEN_PASTE(sjme_scritchui_dylibApi, x)
2038 * Check cast of a given type.
2040 * @param inType The input type.
2041 * @param inPtr The input pointer.
2042 * @return Always @c inPtr .
2045 sjme_pointer
sjme_scritchui_checkCast(sjme_scritchui_uiType inType
,
2046 sjme_pointer inPtr
);
2049 * Check cast of a given type against a menu kind.
2051 * @param inPtr The input pointer.
2052 * @return Always @c inPtr .
2055 sjme_pointer
sjme_scritchui_checkCast_menuKind(sjme_pointer inPtr
);
2057 /*--------------------------------------------------------------------------*/
2061 #ifdef SJME_CXX_SQUIRRELJME_SCRITCHUI_H
2063 #undef SJME_CXX_SQUIRRELJME_SCRITCHUI_H
2064 #undef SJME_CXX_IS_EXTERNED
2065 #endif /* #ifdef SJME_CXX_SQUIRRELJME_SCRITCHUI_H */
2066 #endif /* #ifdef __cplusplus */
2068 #endif /* SQUIRRELJME_SCRITCHUI_H */