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