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 |
|
|
/** Button Management (Button) */ |
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_system.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_button_deselect PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This service deselects the specified button. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* button Pointer to button control */ |
49 |
|
|
/* block */ |
50 |
|
|
/* generate_event If GX_TRUE, the button will */ |
51 |
|
|
/* generate an event depending */ |
52 |
|
|
/* on the button style. */ |
53 |
|
|
/* If GX_FALSE, the button will */ |
54 |
|
|
/* not generate any higher */ |
55 |
|
|
/* level event. */ |
56 |
|
|
/* */ |
57 |
|
|
/* OUTPUT */ |
58 |
|
|
/* */ |
59 |
|
|
/* status Completion status */ |
60 |
|
|
/* */ |
61 |
|
|
/* CALLS */ |
62 |
|
|
/* */ |
63 |
|
|
/* _gx_system_timer_stop Stop an active GUIX timer */ |
64 |
|
|
/* _gx_widget_event_generate Generate event to notify */ |
65 |
|
|
/* parent widget */ |
66 |
|
|
/* _gx_system_dirty_mark Sets the dirty flag */ |
67 |
|
|
/* */ |
68 |
|
|
/* CALLED BY */ |
69 |
|
|
/* */ |
70 |
|
|
/* Application Code */ |
71 |
|
|
/* */ |
72 |
|
|
/* RELEASE HISTORY */ |
73 |
|
|
/* */ |
74 |
|
|
/* DATE NAME DESCRIPTION */ |
75 |
|
|
/* */ |
76 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
77 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
78 |
|
|
/* resulting in version 6.1 */ |
79 |
|
|
/* */ |
80 |
|
|
/**************************************************************************/ |
81 |
|
285 |
UINT _gx_button_deselect(GX_BUTTON *button, GX_BOOL generate_event) |
82 |
|
|
{ |
83 |
|
285 |
GX_WIDGET *widget = (GX_WIDGET *)button; |
84 |
|
|
|
85 |
✓✓ |
285 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_PUSHED) |
86 |
|
|
{ |
87 |
✓✓ |
284 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_TOGGLE) |
88 |
|
|
{ |
89 |
✓✓ |
4 |
if (!(button -> gx_widget_status & GX_STATUS_TOGGLE_UNLOCK)) |
90 |
|
|
{ |
91 |
|
2 |
return GX_SUCCESS; |
92 |
|
|
} |
93 |
|
2 |
button -> gx_widget_status &= ~GX_STATUS_TOGGLE_UNLOCK; |
94 |
|
|
} |
95 |
|
|
|
96 |
✓✓ |
282 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_REPEAT) |
97 |
|
|
{ |
98 |
|
21 |
_gx_system_timer_stop(widget, GX_BUTTON_TIMER); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
/* Remove style for pen down. */ |
102 |
|
282 |
button -> gx_widget_style &= ~GX_STYLE_BUTTON_PUSHED; |
103 |
|
|
|
104 |
✓✓ |
282 |
if (generate_event) |
105 |
|
|
{ |
106 |
✓✓ |
178 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_RADIO) |
107 |
|
|
{ |
108 |
|
65 |
_gx_widget_event_generate(widget, GX_EVENT_RADIO_DESELECT, 0); |
109 |
|
|
} |
110 |
|
|
else |
111 |
|
|
{ |
112 |
✓✓ |
113 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_TOGGLE) |
113 |
|
|
{ |
114 |
|
1 |
_gx_widget_event_generate(widget, GX_EVENT_TOGGLE_OFF, 0); |
115 |
|
|
} |
116 |
|
|
else |
117 |
|
|
{ |
118 |
✓✓ |
112 |
if (!(button -> gx_widget_style & GX_STYLE_BUTTON_EVENT_ON_PUSH)) |
119 |
|
|
{ |
120 |
|
111 |
_gx_widget_event_generate(widget, GX_EVENT_CLICKED, 0); |
121 |
|
|
} |
122 |
|
|
} |
123 |
|
|
} |
124 |
|
|
} |
125 |
|
|
} |
126 |
|
|
|
127 |
✓✓ |
283 |
if (button -> gx_widget_status & GX_STATUS_VISIBLE) |
128 |
|
|
{ |
129 |
|
|
/* Mark as dirty. */ |
130 |
|
252 |
_gx_system_dirty_mark(widget); |
131 |
|
|
} |
132 |
|
|
|
133 |
|
283 |
return(GX_SUCCESS); |
134 |
|
|
} |
135 |
|
|
|