216
216
/* =================================================== */
217
/* ===================== GUI LIST ==================== */
217
/* ===================== WIDGET LIST ==================== */
218
218
/* =================================================== */
220
220
/**************************************************************************
221
Simple "Search and De..." no search in 'pGUI_List' == "Widget's list" and
222
return ( not Disabled and not Hiden ) widget under cursor 'pPosition'.
221
Find the next visible widget in the widget list starting with
222
pStartWidget that is drawn at position (x, y). If pStartWidget is NULL,
223
the search starts with the first entry of the main widget list.
223
224
**************************************************************************/
224
struct widget * WidgetListScaner(const struct widget *pGUI_List, int x, int y)
225
struct widget *find_next_widget_at_pos(struct widget *pStartWidget, int x, int y)
226
227
SDL_Rect area = {0, 0, 0, 0};
229
area.x = pGUI_List->dst->dest_rect.x + pGUI_List->size.x;
230
area.y = pGUI_List->dst->dest_rect.y + pGUI_List->size.y;
231
area.w = pGUI_List->size.w;
232
area.h = pGUI_List->size.h;
228
struct widget *pWidget;
230
pWidget = pStartWidget ? pStartWidget : pBeginMainWidgetList;
233
area.x = pWidget->dst->dest_rect.x + pWidget->size.x;
234
area.y = pWidget->dst->dest_rect.y + pWidget->size.y;
235
area.w = pWidget->size.w;
236
area.h = pWidget->size.h;
233
237
if (is_in_rect_area(x, y, area)
234
&& !((get_wflags(pGUI_List) & WF_HIDDEN) == WF_HIDDEN)) {
235
return (struct widget *) pGUI_List;
238
&& !((get_wflags(pWidget) & WF_HIDDEN) == WF_HIDDEN)) {
239
return (struct widget *) pWidget;
237
pGUI_List = pGUI_List->next;
241
pWidget = pWidget->next;
242
246
/**************************************************************************
243
Search in 'pGUI_List' == "Widget's list" and
244
return ( not Disabled and not Hiden ) widget with 'Key' allias.
247
Find the next enabled and visible widget in the widget list starting
248
with pStartWidget that handles the given key. If pStartWidget is NULL,
249
the search starts with the first entry of the main widget list.
245
250
NOTE: This function ignores CapsLock and NumLock Keys.
246
251
**************************************************************************/
247
struct widget *WidgetListKeyScaner(const struct widget *pGUI_List, SDL_keysym Key)
252
struct widget *find_next_widget_for_key(struct widget *pStartWidget,
249
Key.mod &= ~(KMOD_NUM | KMOD_CAPS);
251
if ((pGUI_List->key == Key.sym ||
252
(pGUI_List->key == SDLK_RETURN && Key.sym == SDLK_KP_ENTER) ||
253
(pGUI_List->key == SDLK_KP_ENTER && Key.sym == SDLK_RETURN)) &&
254
((pGUI_List->mod & Key.mod) || (pGUI_List->mod == Key.mod))) {
255
if (!((get_wstate(pGUI_List) == FC_WS_DISABLED) ||
256
((get_wflags(pGUI_List) & WF_HIDDEN) == WF_HIDDEN))) {
257
return (struct widget *) pGUI_List;
255
struct widget *pWidget;
257
pWidget = pStartWidget ? pStartWidget : pBeginMainWidgetList;
259
key.mod &= ~(KMOD_NUM | KMOD_CAPS);
261
if ((pWidget->key == key.sym ||
262
(pWidget->key == SDLK_RETURN && key.sym == SDLK_KP_ENTER) ||
263
(pWidget->key == SDLK_KP_ENTER && key.sym == SDLK_RETURN)) &&
264
((pWidget->mod & key.mod) || (pWidget->mod == key.mod))) {
265
if (!((get_wstate(pWidget) == FC_WS_DISABLED) ||
266
((get_wflags(pWidget) & WF_HIDDEN) == WF_HIDDEN))) {
267
return (struct widget *) pWidget;
260
pGUI_List = pGUI_List->next;
270
pWidget = pWidget->next;
265
275
/**************************************************************************
266
Pointer to Main Widget list is declared staric in 'gui_stuff.c'
267
This function only calls 'WidgetListScaner' in Main list
268
'pBeginMainWidgetList'
269
**************************************************************************/
270
struct widget *MainWidgetListScaner(int x, int y)
272
return WidgetListScaner(pBeginMainWidgetList, x, y);
275
/**************************************************************************
277
**************************************************************************/
278
struct widget *MainWidgetListKeyScaner(SDL_keysym Key)
280
return WidgetListKeyScaner(pBeginMainWidgetList, Key);
283
/**************************************************************************
284
276
Do default Widget action when pressed, and then call widget callback