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