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 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _gx_sprite_create PORTABLE C */ |
36 |
|
|
/* 6.1 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* This function creates a sprite, which is a special type of */ |
44 |
|
|
/* widget. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* sprite Pointer to sprite widget */ |
49 |
|
|
/* control block */ |
50 |
|
|
/* name Logical name of sprite */ |
51 |
|
|
/* parent Pointer to parent widget */ |
52 |
|
|
/* of sprite */ |
53 |
|
|
/* frame_list The frame_list to be assigned */ |
54 |
|
|
/* frame_count Number of frames in the frame */ |
55 |
|
|
/* style Sprite stuyle */ |
56 |
|
|
/* button_id Application-defined ID of */ |
57 |
|
|
/* the sprite */ |
58 |
|
|
/* size Size of the sprite */ |
59 |
|
|
/* */ |
60 |
|
|
/* OUTPUT */ |
61 |
|
|
/* */ |
62 |
|
|
/* status Completion status */ |
63 |
|
|
/* */ |
64 |
|
|
/* CALLS */ |
65 |
|
|
/* */ |
66 |
|
|
/* _gx_widget_create Create the underlying widget */ |
67 |
|
|
/* _gx_widget_link Link the sprite to its parent */ |
68 |
|
|
/* */ |
69 |
|
|
/* CALLED BY */ |
70 |
|
|
/* */ |
71 |
|
|
/* Application Code */ |
72 |
|
|
/* */ |
73 |
|
|
/* RELEASE HISTORY */ |
74 |
|
|
/* */ |
75 |
|
|
/* DATE NAME DESCRIPTION */ |
76 |
|
|
/* */ |
77 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
78 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
79 |
|
|
/* resulting in version 6.1 */ |
80 |
|
|
/* */ |
81 |
|
|
/**************************************************************************/ |
82 |
|
477 |
UINT _gx_sprite_create(GX_SPRITE *sprite, GX_CONST GX_CHAR *name, GX_WIDGET *parent, |
83 |
|
|
GX_SPRITE_FRAME *frame_list, USHORT frame_count, |
84 |
|
|
ULONG style, USHORT sprite_id, GX_CONST GX_RECTANGLE *size) |
85 |
|
|
{ |
86 |
|
|
|
87 |
|
|
/* Call the widget create function. */ |
88 |
|
477 |
_gx_widget_create((GX_WIDGET *)sprite, name, GX_NULL, style, sprite_id, size); |
89 |
|
|
|
90 |
|
|
/* Populate the rest of prompt control block - overriding as necessary. */ |
91 |
|
477 |
sprite -> gx_widget_type = GX_TYPE_SPRITE; |
92 |
|
477 |
sprite -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_sprite_draw; |
93 |
|
477 |
sprite -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_sprite_event_process; |
94 |
|
477 |
sprite -> gx_sprite_current_frame = 0; |
95 |
|
477 |
sprite -> gx_sprite_run_state = GX_SPRITE_IDLE; |
96 |
|
477 |
sprite -> gx_sprite_frame_list = frame_list; |
97 |
|
477 |
sprite -> gx_sprite_frame_count = frame_count; |
98 |
|
|
|
99 |
|
|
/* Determine if a parent widget was provided. */ |
100 |
✓✓ |
477 |
if (parent) |
101 |
|
|
{ |
102 |
|
476 |
_gx_widget_link(parent, (GX_WIDGET *)sprite); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
/* Return the status from prompt create. */ |
106 |
|
477 |
return(GX_SUCCESS); |
107 |
|
|
} |
108 |
|
|
|