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 /**   Numeric Scroll Wheel Management (Scroll Wheel)                      */
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_scroll_wheel.h"
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _gx_numeric_scroll_wheel_create                     PORTABLE C      */
35 /*                                                           6.1.6        */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Kenneth Maxwell, Microsoft Corporation                              */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function creates a numeric scroll wheel selector widget.       */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    wheel                                 Scroll wheel control block    */
47 /*    name                                  Name of widget                */
48 /*    parent                                Parent widget control block   */
49 /*    start_val                             Start value of numeric range  */
50 /*    end_val                               End value of numeric range    */
51 /*    style                                 Style of widget               */
52 /*    Id                                    Application-defined ID of the */
53 /*                                            the widget                  */
54 /*    size                                  Widget size                   */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    status                                Completion status             */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*    _gx_text_scroll_wheel_create          Create a text scroll wheel    */
63 /*    _gx_widget_link                       Link a widget to parent       */
64 /*                                                                        */
65 /*  CALLED BY                                                             */
66 /*                                                                        */
67 /*    Application Code                                                    */
68 /*                                                                        */
69 /*  RELEASE HISTORY                                                       */
70 /*                                                                        */
71 /*    DATE              NAME                      DESCRIPTION             */
72 /*                                                                        */
73 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
74 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
75 /*                                            resulting in version 6.1    */
76 /*  04-02-2021     Kenneth Maxwell          Modified comment(s),          */
77 /*                                            replace usage of abs(),     */
78 /*                                            resulting in version 6.1.6  */
79 /*                                                                        */
80 /**************************************************************************/
_gx_numeric_scroll_wheel_create(GX_NUMERIC_SCROLL_WHEEL * wheel,GX_CONST GX_CHAR * name,GX_WIDGET * parent,INT start_val,INT end_val,ULONG style,USHORT Id,GX_CONST GX_RECTANGLE * size)81 UINT  _gx_numeric_scroll_wheel_create(GX_NUMERIC_SCROLL_WHEEL *wheel,
82                                       GX_CONST GX_CHAR *name,
83                                       GX_WIDGET *parent, INT start_val, INT end_val,
84                                       ULONG style, USHORT Id, GX_CONST GX_RECTANGLE *size)
85 {
86 
87     /* Call text scroll wheel create. */
88     _gx_text_scroll_wheel_create((GX_TEXT_SCROLL_WHEEL *)wheel, name, GX_NULL, GX_ABS(start_val - end_val) + 1, style, Id, size);
89 
90     wheel -> gx_widget_type = GX_TYPE_NUMERIC_SCROLL_WHEEL;
91     wheel -> gx_numeric_scroll_wheel_start_val = start_val;
92     wheel -> gx_numeric_scroll_wheel_end_val = end_val;
93 
94     wheel -> gx_text_scroll_wheel_text_get = (UINT (*)(GX_TEXT_SCROLL_WHEEL *, INT, GX_STRING *))_gx_numeric_scroll_wheel_text_get;
95 
96     /* Determine if a parent widget was provided.  */
97     if (parent)
98     {
99         _gx_widget_link(parent, (GX_WIDGET *)wheel);
100     }
101 
102     /* Return completion status.  */
103     return(GX_SUCCESS);
104 }
105 
106