1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   Scroll Management (Scroll)                                          */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 #include "gx_button.h"
30 #include "gx_scrollbar.h"
31 #include "gx_utility.h"
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _gx_scroll_thumb_create                             PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function creates a bitmap prompt, which is a special type of   */
46 /*    widget.                                                             */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    scroll_thumb                          Scroll thumb control block    */
51 /*    parent                                Pointer to parent scrollbar   */
52 /*    style                                 Style of scroll bar           */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    status                                Completion status             */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _gx_button_create                     Create a button               */
61 /*    _gx_widget_status_remove              Clear the widget status flag  */
62 /*    _gx_widget_link                       Link the widget to its parent */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    Application Code                                                    */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
73 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_gx_scroll_thumb_create(GX_SCROLL_THUMB * scroll_thumb,GX_SCROLLBAR * parent,ULONG style)77 UINT  _gx_scroll_thumb_create(GX_SCROLL_THUMB *scroll_thumb, GX_SCROLLBAR *parent,
78                               ULONG style)
79 {
80 GX_RECTANGLE size;
81 
82     if (parent)
83     {
84         size = parent -> gx_widget_size;
85     }
86     else
87     {
88         size.gx_rectangle_bottom = size.gx_rectangle_left = size.gx_rectangle_right = size.gx_rectangle_top = 0;
89     }
90 
91     /* Clear the scroll control block.  */
92     _gx_button_create((GX_BUTTON *)scroll_thumb, GX_NULL, GX_NULL, style, GX_ID_SCROLL_THUMB, &size);
93     _gx_widget_status_remove((GX_WIDGET *)scroll_thumb, GX_STATUS_ACCEPTS_FOCUS);
94 
95     scroll_thumb -> gx_widget_draw_function = (VOID (*)(struct GX_WIDGET_STRUCT *))_gx_scroll_thumb_draw;
96     scroll_thumb -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_scroll_thumb_event_process;
97     scroll_thumb -> gx_widget_normal_fill_color = GX_COLOR_ID_SCROLL_BUTTON;
98     scroll_thumb -> gx_widget_selected_fill_color = GX_COLOR_ID_SCROLL_BUTTON;
99     scroll_thumb -> gx_scroll_thumb_border_color = GX_COLOR_ID_SCROLL_BUTTON;
100 
101     /* Determine if a parent widget was provided.  */
102     if (parent)
103     {
104         scroll_thumb -> gx_scroll_thumb_border_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_border_color;
105         scroll_thumb -> gx_widget_normal_fill_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_color;
106         scroll_thumb -> gx_widget_selected_fill_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_color;
107         scroll_thumb -> gx_scroll_thumb_pixelmap = parent -> gx_scrollbar_appearance.gx_scroll_thumb_pixelmap;
108 
109         _gx_widget_link((GX_WIDGET *)parent, (GX_WIDGET *)scroll_thumb);
110     }
111     return GX_SUCCESS;
112 }
113 
114