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 /** Scroll Management (Scroll) */
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_button.h"
29 #include "gx_scrollbar.h"
30 #include "gx_utility.h"
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _gx_scroll_thumb_create PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Kenneth Maxwell, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function creates a bitmap prompt, which is a special type of */
45 /* widget. */
46 /* */
47 /* INPUT */
48 /* */
49 /* scroll_thumb Scroll thumb control block */
50 /* parent Pointer to parent scrollbar */
51 /* style Style of scroll bar */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* status Completion status */
56 /* */
57 /* CALLS */
58 /* */
59 /* _gx_button_create Create a button */
60 /* _gx_widget_status_remove Clear the widget status flag */
61 /* _gx_widget_link Link the widget to its parent */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* Application Code */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
72 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
73 /* resulting in version 6.1 */
74 /* */
75 /**************************************************************************/
_gx_scroll_thumb_create(GX_SCROLL_THUMB * scroll_thumb,GX_SCROLLBAR * parent,ULONG style)76 UINT _gx_scroll_thumb_create(GX_SCROLL_THUMB *scroll_thumb, GX_SCROLLBAR *parent,
77 ULONG style)
78 {
79 GX_RECTANGLE size;
80
81 if (parent)
82 {
83 size = parent -> gx_widget_size;
84 }
85 else
86 {
87 size.gx_rectangle_bottom = size.gx_rectangle_left = size.gx_rectangle_right = size.gx_rectangle_top = 0;
88 }
89
90 /* Clear the scroll control block. */
91 _gx_button_create((GX_BUTTON *)scroll_thumb, GX_NULL, GX_NULL, style, GX_ID_SCROLL_THUMB, &size);
92 _gx_widget_status_remove((GX_WIDGET *)scroll_thumb, GX_STATUS_ACCEPTS_FOCUS);
93
94 scroll_thumb -> gx_widget_draw_function = (VOID (*)(struct GX_WIDGET_STRUCT *))_gx_scroll_thumb_draw;
95 scroll_thumb -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_scroll_thumb_event_process;
96 scroll_thumb -> gx_widget_normal_fill_color = GX_COLOR_ID_SCROLL_BUTTON;
97 scroll_thumb -> gx_widget_selected_fill_color = GX_COLOR_ID_SCROLL_BUTTON;
98 scroll_thumb -> gx_scroll_thumb_border_color = GX_COLOR_ID_SCROLL_BUTTON;
99
100 /* Determine if a parent widget was provided. */
101 if (parent)
102 {
103 scroll_thumb -> gx_scroll_thumb_border_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_border_color;
104 scroll_thumb -> gx_widget_normal_fill_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_color;
105 scroll_thumb -> gx_widget_selected_fill_color = parent -> gx_scrollbar_appearance.gx_scroll_thumb_color;
106 scroll_thumb -> gx_scroll_thumb_pixelmap = parent -> gx_scrollbar_appearance.gx_scroll_thumb_pixelmap;
107
108 _gx_widget_link((GX_WIDGET *)parent, (GX_WIDGET *)scroll_thumb);
109 }
110 return GX_SUCCESS;
111 }
112
113