1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** GUIX Component                                                        */
16 /**                                                                       */
17 /**   Sprite Management (Sprite)                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_widget.h"
28 #include "gx_sprite.h"
29 
30 
31 /* Bring in externs for caller checking code.  */
32 GX_CALLER_CHECKING_EXTERNS
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _gxe_sprite_create                                  PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Kenneth Maxwell, Microsoft Corporation                              */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function checks for error in the sprite create call.           */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    sprite                                Pointer to sprite widget      */
51 /*                                            control block               */
52 /*    name                                  Logical name of sprite        */
53 /*    parent                                Pointer to parent widget      */
54 /*                                            of sprite                   */
55 /*    frame_list                            The frame_list to be assigned */
56 /*    frame_count                           Number of frames in the frame */
57 /*    style                                 Sprite stuyle                 */
58 /*    sprite_id                             Application-defined ID of     */
59 /*                                             the sprite                 */
60 /*    size                                  Size of the sprite            */
61 /*                                                                        */
62 /*  OUTPUT                                                                */
63 /*                                                                        */
64 /*    status                                Completion status             */
65 /*                                                                        */
66 /*  CALLS                                                                 */
67 /*                                                                        */
68 /*    _gx_sprite_create                     Actual sprite create call     */
69 /*    _gx_widget_link                       Link the sprite to its parent */
70 /*                                                                        */
71 /*  CALLED BY                                                             */
72 /*                                                                        */
73 /*    Application Code                                                    */
74 /*                                                                        */
75 /*  RELEASE HISTORY                                                       */
76 /*                                                                        */
77 /*    DATE              NAME                      DESCRIPTION             */
78 /*                                                                        */
79 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
80 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
81 /*                                            resulting in version 6.1    */
82 /*                                                                        */
83 /**************************************************************************/
_gxe_sprite_create(GX_SPRITE * sprite,GX_CONST GX_CHAR * name,GX_WIDGET * parent,GX_SPRITE_FRAME * frame_list,USHORT frame_count,ULONG style,USHORT sprite_id,GX_CONST GX_RECTANGLE * size,UINT sprite_control_block_size)84 UINT  _gxe_sprite_create(GX_SPRITE *sprite, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
85                          GX_SPRITE_FRAME *frame_list, USHORT frame_count,
86                          ULONG style, USHORT sprite_id, GX_CONST GX_RECTANGLE *size, UINT sprite_control_block_size)
87 {
88 
89 UINT status;
90 
91     /* Check for appropriate caller.  */
92     GX_INIT_AND_THREADS_CALLER_CHECKING
93 
94     /* Check for invalid input pointers.  */
95     if ((sprite == GX_NULL) || (size == GX_NULL))
96     {
97         return(GX_PTR_ERROR);
98     }
99 
100     /* Check for invalid widget control block size.  */
101     if (sprite_control_block_size != sizeof(GX_SPRITE))
102     {
103         return(GX_INVALID_SIZE);
104     }
105 
106     /* Check for widget already created.  */
107     if (sprite -> gx_widget_type != 0)
108     {
109         return(GX_ALREADY_CREATED);
110     }
111 
112     /* Check for invalid parent widget. */
113     if (parent && (parent->gx_widget_type == 0))
114     {
115         return(GX_INVALID_WIDGET);
116     }
117 
118     /* Call the actual sprite create function.  */
119     status = _gx_sprite_create(sprite, name, parent, frame_list, frame_count, style, sprite_id, size);
120 
121     /* Return completion status.  */
122     return status;
123 }
124 
125