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 |
|
|
/** Slider Management (Slider) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_system.h" |
28 |
|
|
#include "gx_widget.h" |
29 |
|
|
#include "gx_button.h" |
30 |
|
|
#include "gx_slider.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _gx_pixelmap_slider_event_process PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function processes events for the specified slider widget. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* slider Slider's widget control block */ |
50 |
|
|
/* event_ptr Incoming event to process */ |
51 |
|
|
/* */ |
52 |
|
|
/* OUTPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* status Completion status */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLS */ |
57 |
|
|
/* */ |
58 |
|
|
/* _gx_slider_value_calcualte Compute the slider value */ |
59 |
|
|
/* _gx_widget_event_process Default widget event process */ |
60 |
|
|
/* _gx_pixelmap_slider_pixelmap_update Update the pixelmap in slider */ |
61 |
|
|
/* widget */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLED BY */ |
64 |
|
|
/* */ |
65 |
|
|
/* Application Code */ |
66 |
|
|
/* GUIX Internal 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 |
|
|
/**************************************************************************/ |
77 |
|
4866 |
UINT _gx_pixelmap_slider_event_process(GX_PIXELMAP_SLIDER *slider, GX_EVENT *event_ptr) |
78 |
|
|
{ |
79 |
|
|
UINT status; |
80 |
|
|
INT pos; |
81 |
|
|
|
82 |
|
|
/* Default status to success. */ |
83 |
|
4866 |
status = GX_SUCCESS; |
84 |
|
|
|
85 |
|
|
/* Process relative to the type of event. */ |
86 |
✓✓✓✓ ✓ |
4866 |
switch (event_ptr -> gx_event_type) |
87 |
|
|
{ |
88 |
|
1218 |
case GX_EVENT_PEN_DOWN: |
89 |
|
|
|
90 |
|
|
/* Set style for pen down. */ |
91 |
|
1218 |
slider -> gx_widget_style |= GX_STYLE_BUTTON_PUSHED; |
92 |
|
|
|
93 |
✓✓ |
1218 |
if (slider -> gx_widget_style & GX_STYLE_SLIDER_VERTICAL) |
94 |
|
|
{ |
95 |
|
874 |
pos = event_ptr -> gx_event_payload.gx_event_pointdata.gx_point_y; |
96 |
|
|
} |
97 |
|
|
else |
98 |
|
|
{ |
99 |
|
344 |
pos = event_ptr -> gx_event_payload.gx_event_pointdata.gx_point_x; |
100 |
|
|
} |
101 |
|
|
|
102 |
|
1218 |
_gx_slider_value_calculate((GX_SLIDER *)slider, &slider -> gx_slider_info, pos); |
103 |
|
1218 |
break; |
104 |
|
|
|
105 |
|
35 |
case GX_EVENT_PEN_UP: |
106 |
|
|
|
107 |
|
|
/* Set style for pen down. */ |
108 |
|
35 |
slider -> gx_widget_style &= ~GX_STYLE_BUTTON_PUSHED; |
109 |
|
35 |
break; |
110 |
|
|
|
111 |
|
1145 |
case GX_EVENT_PEN_DRAG: |
112 |
|
|
/* move my needle */ |
113 |
✓✓ |
1145 |
if (slider -> gx_widget_style & GX_STYLE_BUTTON_PUSHED) |
114 |
|
|
{ |
115 |
✓✓ |
1144 |
if (slider -> gx_widget_style & GX_STYLE_SLIDER_VERTICAL) |
116 |
|
|
{ |
117 |
|
864 |
pos = event_ptr -> gx_event_payload.gx_event_pointdata.gx_point_y; |
118 |
|
|
} |
119 |
|
|
else |
120 |
|
|
{ |
121 |
|
280 |
pos = event_ptr -> gx_event_payload.gx_event_pointdata.gx_point_x; |
122 |
|
|
} |
123 |
|
|
|
124 |
|
1144 |
_gx_slider_value_calculate((GX_SLIDER *)slider, &slider -> gx_slider_info, pos); |
125 |
|
|
} |
126 |
|
1145 |
break; |
127 |
|
|
|
128 |
|
401 |
case GX_EVENT_SHOW: |
129 |
|
401 |
status = _gx_widget_event_process((GX_WIDGET *)slider, event_ptr); |
130 |
|
401 |
_gx_pixelmap_slider_pixelmap_update(slider); |
131 |
|
401 |
break; |
132 |
|
|
|
133 |
|
2067 |
default: |
134 |
|
|
|
135 |
|
|
/* Call the widget default processing. */ |
136 |
|
2067 |
status = _gx_widget_event_process((GX_WIDGET *)slider, event_ptr); |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
/* Return completion status. */ |
140 |
|
4866 |
return(status); |
141 |
|
|
} |
142 |
|
|
|