1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
10 |
|
|
**************************************************************************/ |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/** */ |
16 |
|
|
/** GUIX Component */ |
17 |
|
|
/** */ |
18 |
|
|
/** Slider Management (Slider) */ |
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_slider.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_slider_create PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This service creates a slider. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* slider Slider control block */ |
49 |
|
|
/* name Name of prompt */ |
50 |
|
|
/* parent Parent widget control block */ |
51 |
|
|
/* tick_count Number of slider ticks */ |
52 |
|
|
/* slider_info Pointer to slider info */ |
53 |
|
|
/* style Style of slider */ |
54 |
|
|
/* slider_id Application-defined ID of */ |
55 |
|
|
/* slider */ |
56 |
|
|
/* size Dimensions of slider */ |
57 |
|
|
/* */ |
58 |
|
|
/* OUTPUT */ |
59 |
|
|
/* */ |
60 |
|
|
/* status Completion status */ |
61 |
|
|
/* */ |
62 |
|
|
/* CALLS */ |
63 |
|
|
/* */ |
64 |
|
|
/* memset Set control block to zero */ |
65 |
|
|
/* _gx_widget_create Create the underlying widget */ |
66 |
|
|
/* _gx_widget_width_get Retrieve the width of the */ |
67 |
|
|
/* widget */ |
68 |
|
|
/* _gx_widget_height_get Retrieve the height of the */ |
69 |
|
|
/* widget */ |
70 |
|
|
/* _gx_widget_link Link the widget to its parent */ |
71 |
|
|
/* */ |
72 |
|
|
/* CALLED BY */ |
73 |
|
|
/* */ |
74 |
|
|
/* Application Code */ |
75 |
|
|
/* */ |
76 |
|
|
/**************************************************************************/ |
77 |
|
3696 |
UINT _gx_slider_create(GX_SLIDER *slider, GX_CONST GX_CHAR *name, |
78 |
|
|
GX_WIDGET *parent, INT tick_count, |
79 |
|
|
GX_SLIDER_INFO *slider_info, ULONG style, |
80 |
|
|
USHORT slider_id, GX_CONST GX_RECTANGLE *size) |
81 |
|
|
{ |
82 |
|
|
|
83 |
|
|
/* Call the widget create function. */ |
84 |
|
3696 |
_gx_widget_create((GX_WIDGET *)slider, name, GX_NULL, style, slider_id, size); |
85 |
|
|
|
86 |
|
|
/* Populate the rest of slider control block - overriding as necessary. */ |
87 |
|
3696 |
slider -> gx_widget_type = GX_TYPE_SLIDER; |
88 |
|
|
|
89 |
|
3696 |
slider -> gx_slider_info = *slider_info; |
90 |
✓✓ |
3696 |
if (slider -> gx_slider_info.gx_slider_info_needle_width <= 0) |
91 |
|
|
{ |
92 |
✓✓ |
8 |
if (style & GX_STYLE_SLIDER_VERTICAL) |
93 |
|
|
{ |
94 |
|
1 |
_gx_widget_width_get((GX_WIDGET *)slider, &slider -> gx_slider_info.gx_slider_info_needle_width); |
95 |
|
1 |
slider -> gx_slider_info.gx_slider_info_needle_width /= 2; |
96 |
|
|
} |
97 |
|
|
else |
98 |
|
|
{ |
99 |
|
7 |
slider -> gx_slider_info.gx_slider_info_needle_width = GX_SLIDER_NEEDLE_WIDTH; |
100 |
|
|
} |
101 |
|
|
} |
102 |
✓✓ |
3696 |
if (slider -> gx_slider_info.gx_slider_info_needle_height <= 0) |
103 |
|
|
{ |
104 |
✓✓ |
2 |
if (style & GX_STYLE_SLIDER_VERTICAL) |
105 |
|
|
{ |
106 |
|
1 |
slider -> gx_slider_info.gx_slider_info_needle_height = GX_SLIDER_NEEDLE_WIDTH; |
107 |
|
|
} |
108 |
|
|
else |
109 |
|
|
{ |
110 |
|
1 |
_gx_widget_height_get((GX_WIDGET *)slider, &slider -> gx_slider_info.gx_slider_info_needle_height); |
111 |
|
1 |
slider -> gx_slider_info.gx_slider_info_needle_height /= 2; |
112 |
|
|
} |
113 |
|
|
} |
114 |
|
3696 |
slider -> gx_widget_normal_fill_color = GX_COLOR_ID_BUTTON_UPPER; |
115 |
|
3696 |
slider -> gx_widget_selected_fill_color = GX_COLOR_ID_BUTTON_UPPER; |
116 |
|
3696 |
slider -> gx_slider_tick_color = GX_COLOR_ID_SLIDER_TICK; |
117 |
|
3696 |
slider -> gx_slider_tick_count = tick_count; |
118 |
|
3696 |
slider -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_slider_draw; |
119 |
|
3696 |
slider -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_slider_event_process; |
120 |
|
|
|
121 |
|
|
/* Determine if a parent widget was provided. */ |
122 |
✓✓ |
3696 |
if (parent) |
123 |
|
|
{ |
124 |
|
3694 |
_gx_widget_link(parent, (GX_WIDGET *)slider); |
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
/* Return the status from widget create. */ |
128 |
|
3696 |
return(GX_SUCCESS); |
129 |
|
|
} |
130 |
|
|
|