Use the gadget-sent events in the dialogs in ui
This commit is contained in:
parent
6068bf961d
commit
cdfd06bbd6
|
@ -1,5 +1,9 @@
|
|||
D1X-Rebirth Changelog
|
||||
|
||||
20120305
|
||||
--------
|
||||
include/ui.h, ui/file.c, ui/gadget.c, ui/keypress.c, ui/listbox.c, ui/menu.c, ui/message.c, ui/popup.c: Use the gadget-sent events in the dialogs in ui
|
||||
|
||||
20120303
|
||||
--------
|
||||
d1x-Info.plist, d1xgl-Info.plist, English.lproj/InfoPlist.strings, RELEASE-NOTES.txt: Increment version to 0.57.2 for Mac and RELEASE-NOTES
|
||||
|
|
|
@ -278,6 +278,8 @@ extern struct window *ui_dialog_get_window(UI_DIALOG *dlg);
|
|||
extern void ui_dialog_set_current_canvas(UI_DIALOG *dlg);
|
||||
extern void ui_close_dialog( UI_DIALOG * dlg );
|
||||
|
||||
#define GADGET_PRESSED(g) ((event->type == EVENT_UI_GADGET_PRESSED) && (ui_event_get_gadget(event) == (UI_GADGET *)g))
|
||||
|
||||
extern UI_GADGET * ui_gadget_add( UI_DIALOG * dlg, short kind, short x1, short y1, short x2, short y2 );
|
||||
extern UI_GADGET_BUTTON * ui_add_gadget_button( UI_DIALOG * dlg, short x, short y, short w, short h, char * text, int (*function_to_call)(void) );
|
||||
extern void ui_gadget_delete_all( UI_DIALOG * dlg );
|
||||
|
|
19
ui/file.c
19
ui/file.c
|
@ -128,7 +128,7 @@ static int browser_handler(UI_DIALOG *dlg, d_event *event, browser *b)
|
|||
{
|
||||
int rval = 0;
|
||||
|
||||
if ( b->button2->pressed )
|
||||
if (GADGET_PRESSED(b->button2))
|
||||
{
|
||||
PHYSFS_freeList(b->filename_list); b->filename_list = NULL;
|
||||
PHYSFS_freeList(b->directory_list); b->directory_list = NULL;
|
||||
|
@ -136,35 +136,32 @@ static int browser_handler(UI_DIALOG *dlg, d_event *event, browser *b)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if ( b->help_button->pressed )
|
||||
if (GADGET_PRESSED(b->help_button))
|
||||
{
|
||||
MessageBox( -1, -1, 1, "Sorry, no help is available!", "Ok" );
|
||||
rval = 1;
|
||||
}
|
||||
|
||||
if (b->listbox1->moved || b->new_listboxes)
|
||||
if ((event->type == EVENT_UI_LISTBOX_MOVED) || b->new_listboxes)
|
||||
{
|
||||
if (b->listbox1->current_item >= 0 )
|
||||
ui_inputbox_set_text(b->user_file, b->filename_list[b->listbox1->current_item]);
|
||||
rval = 1;
|
||||
}
|
||||
|
||||
if (b->listbox2->moved || b->new_listboxes)
|
||||
{
|
||||
|
||||
if (b->listbox2->current_item >= 0 )
|
||||
ui_inputbox_set_text(b->user_file, b->directory_list[b->listbox2->current_item]);
|
||||
|
||||
rval = 1;
|
||||
}
|
||||
b->new_listboxes = 0;
|
||||
|
||||
if (b->button1->pressed || b->user_file->pressed || (b->listbox1->selected_item > -1 ) || (b->listbox2->selected_item > -1 ))
|
||||
if (GADGET_PRESSED(b->button1) || GADGET_PRESSED(b->user_file) || (event->type == EVENT_UI_LISTBOX_SELECTED))
|
||||
{
|
||||
char *p;
|
||||
|
||||
ui_mouse_hide();
|
||||
|
||||
if (b->listbox2->selected_item > -1 )
|
||||
strcpy(b->user_file->text, b->directory_list[b->listbox2->selected_item]);
|
||||
if (ui_event_get_gadget(event) == (UI_GADGET *)listbox2)
|
||||
strcpy(b->user_file->text, b->directory_list[b->listbox2->current_item]);
|
||||
|
||||
strncpy(b->filename, b->view_dir, PATH_MAX);
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ int ui_gadget_send_event(UI_DIALOG *dlg, event_type type, UI_GADGET *gadget)
|
|||
|
||||
UI_GADGET *ui_event_get_gadget(d_event *event)
|
||||
{
|
||||
Assert(event->type == EVENT_UI_GADGET_PRESSED); // more to come?
|
||||
Assert(event->type >= EVENT_UI_GADGET_PRESSED); // Any UI event
|
||||
return ((event_gadget *) event)->gadget;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ static int key_dialog_handler(UI_DIALOG *dlg, d_event *event, UI_GADGET_BUTTON *
|
|||
rval = 1;
|
||||
}
|
||||
|
||||
if ((*DoneButton)->pressed)
|
||||
if (GADGET_PRESSED(*DoneButton))
|
||||
{
|
||||
ui_close_dialog(dlg);
|
||||
rval = 1;
|
||||
|
|
|
@ -182,8 +182,7 @@ int ui_listbox_do( UI_DIALOG *dlg, UI_GADGET_LISTBOX * listbox, d_event *event )
|
|||
listbox->old_first_item = listbox->first_item;
|
||||
|
||||
|
||||
if ((event->type == EVENT_UI_GADGET_PRESSED) &&
|
||||
(ui_event_get_gadget(event) == (UI_GADGET *)listbox->scrollbar))
|
||||
if (GADGET_PRESSED(listbox->scrollbar))
|
||||
{
|
||||
listbox->moved = 1;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ static int menu_handler(UI_DIALOG *dlg, d_event *event, menu *m)
|
|||
|
||||
for (i=0; i<m->num_buttons; i++ )
|
||||
{
|
||||
if (m->button_g[i]->pressed)
|
||||
if (GADGET_PRESSED(m->button_g[i]))
|
||||
{
|
||||
*(m->choice) = i+1;
|
||||
return 1;
|
||||
|
|
|
@ -52,7 +52,7 @@ static int messagebox_handler(UI_DIALOG *dlg, d_event *event, messagebox *m)
|
|||
|
||||
for (i=0; i<m->num_buttons; i++ )
|
||||
{
|
||||
if (m->button_g[i]->pressed)
|
||||
if (GADGET_PRESSED(m->button_g[i]))
|
||||
{
|
||||
*(m->choice) = i+1;
|
||||
return 1;
|
||||
|
|
|
@ -41,7 +41,7 @@ static int popup_handler(UI_DIALOG *dlg, d_event *event, popup *p)
|
|||
|
||||
for (i=0; i<p->num_buttons; i++ )
|
||||
{
|
||||
if (p->button_g[i]->pressed)
|
||||
if (GADGET_PRESSED(p->button_g[i]))
|
||||
{
|
||||
*(p->choice) = i+1;
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue