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_select PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function selects one button, invalidating and eventing as */ |
46 |
|
|
/* necessary. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* button Button control block */ |
51 |
|
|
/* */ |
52 |
|
|
/* OUTPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* status Completion status */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLS */ |
57 |
|
|
/* */ |
58 |
|
|
/* _gx_widget_front_move Move widget to the front */ |
59 |
|
|
/* _gx_button_siblings_deselect Deselect all the siblings */ |
60 |
|
|
/* _gx_widget_event_generate Generate events for widget */ |
61 |
|
|
/* _gx_system_timer_start Allocate a free timer and */ |
62 |
|
|
/* activates it */ |
63 |
|
|
/* _gx_system_dirty_mark Mark the widget dirty */ |
64 |
|
|
/* */ |
65 |
|
|
/* CALLED BY */ |
66 |
|
|
/* */ |
67 |
|
|
/* Application Code */ |
68 |
|
|
/* */ |
69 |
|
|
/**************************************************************************/ |
70 |
|
332 |
UINT _gx_button_select(GX_BUTTON *button) |
71 |
|
|
{ |
72 |
|
332 |
GX_WIDGET *widget = (GX_WIDGET *)button; |
73 |
|
|
|
74 |
✓✓ |
332 |
if (button -> gx_widget_style & GX_STYLE_ENABLED) |
75 |
|
|
{ |
76 |
✓✓ |
331 |
if (!(button -> gx_widget_style & GX_STYLE_BUTTON_PUSHED)) |
77 |
|
|
{ |
78 |
|
|
/* Set style for pen down. */ |
79 |
|
291 |
button -> gx_widget_style |= GX_STYLE_BUTTON_PUSHED; |
80 |
|
|
|
81 |
✓✓ |
291 |
if (widget -> gx_widget_status & GX_STATUS_ACCEPTS_FOCUS) |
82 |
|
|
{ |
83 |
|
256 |
_gx_widget_front_move(widget, NULL); |
84 |
|
|
} |
85 |
|
|
|
86 |
✓✓ |
291 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_RADIO) |
87 |
|
|
{ |
88 |
|
72 |
_gx_button_siblings_deselect(button); |
89 |
|
72 |
_gx_widget_event_generate(widget, GX_EVENT_RADIO_SELECT, 0); |
90 |
|
|
} |
91 |
✓✓ |
291 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_EVENT_ON_PUSH) |
92 |
|
|
{ |
93 |
|
2 |
_gx_widget_event_generate(widget, GX_EVENT_CLICKED, 0); |
94 |
|
|
} |
95 |
|
|
else |
96 |
|
|
{ |
97 |
✓✓ |
289 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_TOGGLE) |
98 |
|
|
{ |
99 |
|
2 |
_gx_widget_event_generate(widget, GX_EVENT_TOGGLE_ON, 0); |
100 |
|
|
} |
101 |
|
|
} |
102 |
|
|
|
103 |
✓✓ |
291 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_REPEAT) |
104 |
|
|
{ |
105 |
|
22 |
_gx_system_timer_start(widget, GX_BUTTON_TIMER, GX_REPEAT_BUTTON_INITIAL_TICS, GX_REPEAT_BUTTON_REPEAT_TICS); |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
/* Mark as dirty. */ |
109 |
|
291 |
_gx_system_dirty_mark(widget); |
110 |
|
|
} |
111 |
|
|
else |
112 |
|
|
{ |
113 |
✓✓ |
40 |
if (button -> gx_widget_style & GX_STYLE_BUTTON_TOGGLE) |
114 |
|
|
{ |
115 |
|
2 |
button -> gx_widget_status |= GX_STATUS_TOGGLE_UNLOCK; |
116 |
|
|
} |
117 |
|
|
} |
118 |
|
|
} |
119 |
|
332 |
return(GX_SUCCESS); |
120 |
|
|
|
121 |
|
|
} |
122 |
|
|
|