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 /** Scrollbar Management (Scrollbar) */
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_utility.h"
31 #include "gx_scrollbar.h"
32 #include "gx_system.h"
33 #include "gx_window.h"
34
35
36 /**************************************************************************/
37 /* */
38 /* FUNCTION RELEASE */
39 /* */
40 /* _gx_horizontal_scrollbar_create PORTABLE C */
41 /* 6.1 */
42 /* AUTHOR */
43 /* */
44 /* Kenneth Maxwell, Microsoft Corporation */
45 /* */
46 /* DESCRIPTION */
47 /* */
48 /* This function creates a horizontal scrollbar. */
49 /* */
50 /* INPUT */
51 /* */
52 /* scrollbar scroll control block */
53 /* name name of scroll */
54 /* parent parent window */
55 /* appearance appearance of scroll bar */
56 /* style style of scroll bar */
57 /* */
58 /* OUTPUT */
59 /* */
60 /* status Completion status */
61 /* */
62 /* CALLS */
63 /* */
64 /* _gx_utility_rectangle_define Define a rectangle */
65 /* _gx_widget_create Create the underlying prompt */
66 /* _gx_system_scroll_appearance_get Get the scrollbar appearance */
67 /* _gx_button_create Button create call */
68 /* [gx_window_scroll_info_get] Retrieve window scroll info */
69 /* _gx_scroll_thumb_create Create the thrum button */
70 /* _gx_widget_link Link the widget to its parent */
71 /* _gx_widget_child_clipping_update Update the clipping area */
72 /* */
73 /* CALLED BY */
74 /* */
75 /* Application Code */
76 /* */
77 /* RELEASE HISTORY */
78 /* */
79 /* DATE NAME DESCRIPTION */
80 /* */
81 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
82 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
83 /* resulting in version 6.1 */
84 /* */
85 /**************************************************************************/
_gx_horizontal_scrollbar_create(GX_SCROLLBAR * scrollbar,GX_CONST GX_CHAR * name,GX_WINDOW * parent,GX_SCROLLBAR_APPEARANCE * appearance,ULONG style)86 UINT _gx_horizontal_scrollbar_create(GX_SCROLLBAR *scrollbar, GX_CONST GX_CHAR *name, GX_WINDOW *parent,
87 GX_SCROLLBAR_APPEARANCE *appearance, ULONG style)
88 {
89
90 GX_RECTANGLE size;
91 UINT id;
92
93 _gx_utility_rectangle_define(&size, 0, 0, 0, 0);
94
95 id = GX_ID_HORIZONTAL_SCROLL;
96
97 if (appearance)
98 {
99 scrollbar -> gx_scrollbar_appearance = *appearance;
100 }
101 else
102 {
103 _gx_system_scroll_appearance_get(GX_SCROLLBAR_HORIZONTAL, &scrollbar -> gx_scrollbar_appearance);
104 }
105
106 /* make sure style is set correctly */
107 style &= (ULONG)(~GX_SCROLLBAR_VERTICAL);
108 style |= GX_SCROLLBAR_HORIZONTAL;
109
110 /* Call the base widget create function. */
111 _gx_widget_create((GX_WIDGET *)scrollbar, name, GX_NULL, style, (USHORT)id, &size);
112
113 /* Check for completion status on the widget's create. */
114 scrollbar -> gx_widget_type = GX_TYPE_HORIZONTAL_SCROLL;
115 scrollbar -> gx_widget_normal_fill_color = GX_COLOR_ID_SCROLL_FILL;
116 scrollbar -> gx_widget_selected_fill_color = GX_COLOR_ID_SCROLL_FILL;
117
118 if (style & GX_SCROLLBAR_END_BUTTONS)
119 {
120 /* create the up/left button */
121 _gx_button_create(&scrollbar -> gx_scrollbar_upleft, NULL, (GX_WIDGET *)scrollbar,
122 GX_STYLE_ENABLED | GX_STYLE_BORDER_RAISED, GX_ID_SCROLL_UP_LEFT, &size);
123
124 _gx_widget_fill_color_set((GX_WIDGET *)&scrollbar -> gx_scrollbar_upleft,
125 scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
126 scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
127 scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color);
128
129 scrollbar -> gx_scrollbar_upleft.gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
130
131 /* create the down/right button */
132 _gx_button_create(&scrollbar -> gx_scrollbar_downright, NULL, (GX_WIDGET *)scrollbar,
133 GX_STYLE_ENABLED | GX_STYLE_BORDER_RAISED, GX_ID_SCROLL_DOWN_RIGHT, &size);
134 _gx_widget_fill_color_set((GX_WIDGET *)&scrollbar -> gx_scrollbar_downright,
135 scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
136 scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color,
137 scrollbar -> gx_scrollbar_appearance.gx_scroll_button_color);
138
139 scrollbar -> gx_scrollbar_downright.gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
140 }
141
142 /* create the thumb button */
143 _gx_scroll_thumb_create(&scrollbar -> gx_scrollbar_thumb, scrollbar, (ULONG)((scrollbar -> gx_scrollbar_appearance.gx_scroll_thumb_border_style) | GX_SCROLLBAR_HORIZONTAL) | GX_STYLE_ENABLED);
144
145 /* initialize the drawing function */
146 scrollbar -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_scrollbar_draw;
147
148 /* initialize the event handler function */
149 scrollbar -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_scrollbar_event_process;
150
151 /* scroll-bars have non-client area status and do not accept focus */
152
153 scrollbar -> gx_widget_status |= GX_STATUS_NONCLIENT;
154 scrollbar -> gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
155
156 /* Determine if a parent widget was provided. */
157 if (parent)
158 {
159 _gx_widget_link((GX_WIDGET *)parent, (GX_WIDGET *)scrollbar);
160
161 if (parent -> gx_widget_status & GX_STATUS_VISIBLE)
162 {
163 _gx_widget_child_clipping_update((GX_WIDGET *)parent);
164 }
165 }
166
167 return(GX_SUCCESS);
168 }
169
170