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 /**   Slider Management (Slider)                                          */
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_slider.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_pixelmap_slider_create                          PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function creates a pixelmap slider, which is a type of widget  */
44 /*    for displaying a user-adjustable value in graphical fashion.        */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    slider                                Slider control block          */
49 /*    name                                  Name of prompt                */
50 /*    parent                                Parent widget control block   */
51 /*    info                                  Pointer to a GX_SLIDER_INFO   */
52 /*    pixelmap_info                         Pointer to the pixelmap       */
53 /*                                            info block                  */
54 /*    style                                 Style of slider               */
55 /*    pixelmap_slider_id                    Application-defined ID of     */
56 /*                                            pixelmap slider             */
57 /*    size                                  Dimensions of pixelmap prompt */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    status                                Completion status             */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    _gx_widget_create                     Create the underlying widget  */
66 /*    _gx_widget_link                       Link the widget to its parent */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Application Code                                                    */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
77 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
78 /*                                            resulting in version 6.1    */
79 /*                                                                        */
80 /**************************************************************************/
81 
_gx_pixelmap_slider_create(GX_PIXELMAP_SLIDER * slider,GX_CONST GX_CHAR * name,GX_WIDGET * parent,GX_SLIDER_INFO * info,GX_PIXELMAP_SLIDER_INFO * pixelmap_info,ULONG style,USHORT pixelmap_slider_id,GX_CONST GX_RECTANGLE * size)82 UINT  _gx_pixelmap_slider_create(GX_PIXELMAP_SLIDER *slider,
83                                  GX_CONST GX_CHAR *name,
84                                  GX_WIDGET *parent,
85                                  GX_SLIDER_INFO *info,
86                                  GX_PIXELMAP_SLIDER_INFO *pixelmap_info,
87                                  ULONG style,
88                                  USHORT pixelmap_slider_id,
89                                  GX_CONST GX_RECTANGLE *size)
90 {
91 
92     /* Call the widget create function.  */
93     _gx_widget_create((GX_WIDGET *)slider, name, GX_NULL, style, pixelmap_slider_id, size);
94 
95     /* Populate the rest of slider control block - overriding as necessary.  */
96     slider -> gx_widget_type = GX_TYPE_PIXELMAP_SLIDER;
97 
98     slider -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_pixelmap_slider_draw;
99     slider -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_pixelmap_slider_event_process;
100     slider -> gx_slider_info = *info;
101     slider -> gx_pixelmap_slider_pixelmap_info = *pixelmap_info;
102 
103     slider -> gx_slider_info.gx_slider_info_needle_height = 0;
104     slider -> gx_slider_info.gx_slider_info_needle_width = 0;
105 
106     /* Determine if a parent widget was provided.  */
107     if (parent)
108     {
109         _gx_widget_link(parent, (GX_WIDGET *)slider);
110     }
111 
112     /* Return the status from prompt create.  */
113     return(GX_SUCCESS);
114 }
115 
116