- new gui variable 'user_dialog' indicates the presence of a gui dialog box for
editing the userbutton shortcut before sending it - simple userbutton shortcut dialog for the X11 gui implemented - small fixes in the X11 "ask" dialog code
This commit is contained in:
parent
915c2d9eea
commit
feb97a65a0
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: gui.cc,v 1.84 2005-10-20 17:34:22 sshwarts Exp $
|
// $Id: gui.cc,v 1.85 2005-10-21 18:00:17 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||||
@ -116,6 +116,7 @@ bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
|
|||||||
BX_GUI_THIS host_xres = 640;
|
BX_GUI_THIS host_xres = 640;
|
||||||
BX_GUI_THIS host_yres = 480;
|
BX_GUI_THIS host_yres = 480;
|
||||||
BX_GUI_THIS host_bpp = 8;
|
BX_GUI_THIS host_bpp = 8;
|
||||||
|
BX_GUI_THIS user_dialog = 0;
|
||||||
|
|
||||||
specific_init(argc, argv, tilewidth, tileheight, BX_HEADER_BAR_Y);
|
specific_init(argc, argv, tilewidth, tileheight, BX_HEADER_BAR_Y);
|
||||||
|
|
||||||
@ -550,13 +551,7 @@ bx_gui_c::userbutton_handler(void)
|
|||||||
char *ptr;
|
char *ptr;
|
||||||
int i, len = 0, ret = 1;
|
int i, len = 0, ret = 1;
|
||||||
|
|
||||||
#ifdef WIN32
|
if (BX_GUI_THIS user_dialog) {
|
||||||
if (strcmp(bx_options.Osel_displaylib->get_choice(bx_options.Osel_displaylib->get()),
|
|
||||||
"rfb")) {
|
|
||||||
#else
|
|
||||||
if (!strcmp(bx_options.Osel_config->get_choice(bx_options.Osel_config->get()),
|
|
||||||
"wx")) {
|
|
||||||
#endif
|
|
||||||
ret = SIM->ask_param (BXP_USER_SHORTCUT);
|
ret = SIM->ask_param (BXP_USER_SHORTCUT);
|
||||||
}
|
}
|
||||||
strcpy(user_shortcut, bx_options.Ouser_shortcut->getptr());
|
strcpy(user_shortcut, bx_options.Ouser_shortcut->getptr());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: gui.h,v 1.47 2005-10-13 16:22:21 sshwarts Exp $
|
// $Id: gui.h,v 1.48 2005-10-21 18:00:17 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||||
@ -165,7 +165,8 @@ protected:
|
|||||||
Bit16u host_pitch;
|
Bit16u host_pitch;
|
||||||
Bit8u host_bpp;
|
Bit8u host_bpp;
|
||||||
Bit8u *framebuffer;
|
Bit8u *framebuffer;
|
||||||
};
|
bx_bool user_dialog;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Add this macro in the class declaration of each GUI, to define all the
|
// Add this macro in the class declaration of each GUI, to define all the
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: sdl.cc,v 1.59 2005-07-30 18:57:02 vruppert Exp $
|
// $Id: sdl.cc,v 1.60 2005-10-21 18:00:17 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||||
@ -297,6 +297,9 @@ void bx_sdl_gui_c::specific_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_gfx_api = 1;
|
new_gfx_api = 1;
|
||||||
|
#ifdef WIN32
|
||||||
|
user_dialog = 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdl_set_status_text(int element, const char *text, bx_bool active)
|
void sdl_set_status_text(int element, const char *text, bx_bool active)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: win32.cc,v 1.96 2005-10-02 17:37:56 vruppert Exp $
|
// $Id: win32.cc,v 1.97 2005-10-21 18:00:17 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||||
@ -678,8 +678,9 @@ void bx_win32_gui_c::specific_init(int argc, char **argv, unsigned
|
|||||||
// load keymap tables
|
// load keymap tables
|
||||||
if(bx_options.keyboard.OuseMapping->get()) {
|
if(bx_options.keyboard.OuseMapping->get()) {
|
||||||
bx_keymap.loadKeymap(NULL); // I have no function to convert X windows symbols
|
bx_keymap.loadKeymap(NULL); // I have no function to convert X windows symbols
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user_dialog = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize_main_window()
|
void resize_main_window()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// $Id: wx.cc,v 1.74 2004-11-06 17:03:43 vruppert Exp $
|
// $Id: wx.cc,v 1.75 2005-10-21 18:00:17 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// wxWidgets VGA display for Bochs. wx.cc implements a custom
|
// wxWidgets VGA display for Bochs. wx.cc implements a custom
|
||||||
@ -914,6 +914,7 @@ bx_wx_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned t
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
new_gfx_api = 1;
|
new_gfx_api = 1;
|
||||||
|
user_dialog = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ::HANDLE_EVENTS()
|
// ::HANDLE_EVENTS()
|
||||||
|
188
bochs/gui/x.cc
188
bochs/gui/x.cc
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: x.cc,v 1.92 2005-10-16 13:11:38 vruppert Exp $
|
// $Id: x.cc,v 1.93 2005-10-21 18:00:17 vruppert Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||||
@ -640,6 +640,7 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_gfx_api = 1;
|
new_gfx_api = 1;
|
||||||
|
user_dialog = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1973,7 +1974,7 @@ int x11_ask_dialog(BxEvent *event)
|
|||||||
KeySym key;
|
KeySym key;
|
||||||
int done, i, level;
|
int done, i, level;
|
||||||
int retcode = -1;
|
int retcode = -1;
|
||||||
int button = 0, oldbutton = -1;
|
int valid = 0, control = 0, oldctrl = -1;
|
||||||
unsigned long black_pixel, white_pixel;
|
unsigned long black_pixel, white_pixel;
|
||||||
char name[16], text[10], device[16], message[512];
|
char name[16], text[10], device[16], message[512];
|
||||||
|
|
||||||
@ -2024,62 +2025,213 @@ int x11_ask_dialog(BxEvent *event)
|
|||||||
gc, 105, 60, 65, 20, "Alwayscont");
|
gc, 105, 60, 65, 20, "Alwayscont");
|
||||||
x11_create_button(xevent.xexpose.display, dialog,
|
x11_create_button(xevent.xexpose.display, dialog,
|
||||||
gc, 190, 60, 65, 20, "Quit");
|
gc, 190, 60, 65, 20, "Quit");
|
||||||
oldbutton = button - 1;
|
oldctrl = control - 1;
|
||||||
if (oldbutton < 0) oldbutton = 1;
|
if (oldctrl < 0) oldctrl = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
if (xevent.xbutton.button == Button1) {
|
if (xevent.xbutton.button == Button1) {
|
||||||
if ((xevent.xbutton.y > 60) && (xevent.xbutton.y < 80)) {
|
if ((xevent.xbutton.y > 60) && (xevent.xbutton.y < 80)) {
|
||||||
if ((xevent.xbutton.x > 20) && (xevent.xbutton.x < 85)) {
|
if ((xevent.xbutton.x > 20) && (xevent.xbutton.x < 85)) {
|
||||||
button = 0;
|
control = 0;
|
||||||
|
valid = 1;
|
||||||
} else if ((xevent.xbutton.x > 105) && (xevent.xbutton.x < 170)) {
|
} else if ((xevent.xbutton.x > 105) && (xevent.xbutton.x < 170)) {
|
||||||
button = 1;
|
control = 1;
|
||||||
|
valid = 1;
|
||||||
} else if ((xevent.xbutton.x > 190) && (xevent.xbutton.x < 255)) {
|
} else if ((xevent.xbutton.x > 190) && (xevent.xbutton.x < 255)) {
|
||||||
button = 2;
|
control = 2;
|
||||||
|
valid = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
if (xevent.xbutton.button == Button1) {
|
if ((xevent.xbutton.button == Button1) && (valid == 1)) {
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
i = XLookupString((XKeyEvent *)&xevent, text, 10, &key, 0);
|
i = XLookupString((XKeyEvent *)&xevent, text, 10, &key, 0);
|
||||||
if (key == XK_Tab) {
|
if (key == XK_Tab) {
|
||||||
button++;
|
control++;
|
||||||
if (button == 3) button = 0;
|
if (control == 3) control = 0;
|
||||||
|
} else if (key == XK_Escape) {
|
||||||
|
control = 2;
|
||||||
|
done = 1;
|
||||||
} else if ((key == XK_space) || (key == XK_Return)) {
|
} else if ((key == XK_space) || (key == XK_Return)) {
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (button != oldbutton) {
|
if (control != oldctrl) {
|
||||||
XDrawRectangle(xevent.xexpose.display, dialog,
|
XDrawRectangle(bx_x_display, dialog, gc_inv, button_x[oldctrl], 58, 69, 24);
|
||||||
gc_inv, button_x[oldbutton], 58, 69, 24);
|
XDrawRectangle(bx_x_display, dialog, gc, button_x[control], 58, 69, 24);
|
||||||
XDrawRectangle(xevent.xexpose.display, dialog,
|
oldctrl = control;
|
||||||
gc, button_x[button], 58, 69, 24);
|
|
||||||
oldbutton = button;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
retcode = ask_code[button];
|
retcode = ask_code[control];
|
||||||
XFreeGC(bx_x_display, gc);
|
XFreeGC(bx_x_display, gc);
|
||||||
XDestroyWindow(bx_x_display, dialog);
|
XDestroyWindow(bx_x_display, dialog);
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int x11_string_dialog(bx_param_string_c *param)
|
||||||
|
{
|
||||||
|
Window dialog;
|
||||||
|
XSizeHints hint;
|
||||||
|
XEvent xevent;
|
||||||
|
GC gc, gc_inv;
|
||||||
|
KeySym key;
|
||||||
|
int valid = 0, control = 0, oldctrl = -1;
|
||||||
|
int done, i;
|
||||||
|
unsigned long black_pixel, white_pixel;
|
||||||
|
char editstr[80], name[80], text[10], value[80];
|
||||||
|
|
||||||
|
strcpy(name, param->get_name());
|
||||||
|
strcpy(value, param->getptr());
|
||||||
|
hint.flags = PPosition | PSize | PMinSize | PMaxSize;
|
||||||
|
hint.x = 100;
|
||||||
|
hint.y = 100;
|
||||||
|
hint.width = hint.min_width = hint.max_width = 250;
|
||||||
|
hint.height = hint.min_height = hint.max_height = 90;
|
||||||
|
black_pixel = BlackPixel(bx_x_display, bx_x_screen_num);
|
||||||
|
white_pixel = WhitePixel(bx_x_display, bx_x_screen_num);
|
||||||
|
dialog = XCreateSimpleWindow(bx_x_display, RootWindow(bx_x_display,bx_x_screen_num),
|
||||||
|
hint.x, hint.y, hint.width, hint.height, 4, black_pixel, white_pixel);
|
||||||
|
XSetStandardProperties(bx_x_display, dialog, name, name, None, NULL, 0, &hint);
|
||||||
|
|
||||||
|
gc = XCreateGC(bx_x_display, dialog, 0, 0);
|
||||||
|
gc_inv = XCreateGC(bx_x_display, dialog, 0, 0);
|
||||||
|
XSetState(bx_x_display, gc_inv, white_pixel, black_pixel, GXcopy, AllPlanes);
|
||||||
|
XSetBackground(bx_x_display,gc,WhitePixel(bx_x_display, bx_x_screen_num));
|
||||||
|
XSetForeground(bx_x_display,gc,BlackPixel(bx_x_display, bx_x_screen_num));
|
||||||
|
|
||||||
|
XSelectInput(bx_x_display, dialog, ButtonPressMask
|
||||||
|
| ButtonReleaseMask
|
||||||
|
| KeyPressMask
|
||||||
|
| KeyReleaseMask
|
||||||
|
| ExposureMask
|
||||||
|
| PointerMotionMask
|
||||||
|
| EnterWindowMask
|
||||||
|
| LeaveWindowMask);
|
||||||
|
XMapWindow(bx_x_display, dialog);
|
||||||
|
XFlush(bx_x_display);
|
||||||
|
done = 0;
|
||||||
|
while (!done) {
|
||||||
|
XNextEvent(bx_x_display, &xevent);
|
||||||
|
switch (xevent.type) {
|
||||||
|
case Expose:
|
||||||
|
if (xevent.xexpose.count == 0) {
|
||||||
|
sprintf(editstr, "%s%s", value, "_ ");
|
||||||
|
XDrawRectangle(xevent.xexpose.display, dialog, gc, 45, 20, 160, 20);
|
||||||
|
XDrawImageString(xevent.xexpose.display, dialog, gc, 49, 34, editstr, strlen(editstr));
|
||||||
|
x11_create_button(xevent.xexpose.display, dialog,
|
||||||
|
gc, 55, 60, 65, 20, "OK");
|
||||||
|
x11_create_button(xevent.xexpose.display, dialog,
|
||||||
|
gc, 130, 60, 65, 20, "Cancel");
|
||||||
|
oldctrl = control - 1;
|
||||||
|
if (oldctrl < 0) oldctrl = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ButtonPress:
|
||||||
|
if (xevent.xbutton.button == Button1) {
|
||||||
|
if ((xevent.xbutton.y > 60) && (xevent.xbutton.y < 80)) {
|
||||||
|
if ((xevent.xbutton.x > 55) && (xevent.xbutton.x < 120)) {
|
||||||
|
control = 1;
|
||||||
|
valid = 1;
|
||||||
|
} else if ((xevent.xbutton.x > 130) && (xevent.xbutton.x < 195)) {
|
||||||
|
control = 2;
|
||||||
|
valid = 1;
|
||||||
|
}
|
||||||
|
} else if ((xevent.xbutton.y > 20) && (xevent.xbutton.y < 40)) {
|
||||||
|
if ((xevent.xbutton.x > 45) && (xevent.xbutton.x < 205)) {
|
||||||
|
control = 0;
|
||||||
|
valid = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ButtonRelease:
|
||||||
|
if ((xevent.xbutton.button == Button1) && (valid == 1)) {
|
||||||
|
if (control > 0) {
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case KeyPress:
|
||||||
|
i = XLookupString((XKeyEvent *)&xevent, text, 10, &key, 0);
|
||||||
|
if (key == XK_Tab) {
|
||||||
|
control++;
|
||||||
|
if (control == 3) control = 0;
|
||||||
|
} else if (key == XK_Escape) {
|
||||||
|
control = 2;
|
||||||
|
done = 1;
|
||||||
|
} else if (control > 0) {
|
||||||
|
if ((key == XK_space) || (key == XK_Return)) {
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (key == XK_Return) {
|
||||||
|
control = 1;
|
||||||
|
done = 1;
|
||||||
|
} else if (key == XK_BackSpace) {
|
||||||
|
if (strlen(value) > 0) {
|
||||||
|
value[strlen(value)-1] = 0;
|
||||||
|
oldctrl = -1;
|
||||||
|
}
|
||||||
|
} else if ((i == 1) && (strlen(value) < 40)) {
|
||||||
|
strcat(value, text);
|
||||||
|
oldctrl = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (control != oldctrl) {
|
||||||
|
if (oldctrl > 0) {
|
||||||
|
XDrawRectangle(bx_x_display, dialog, gc_inv, oldctrl==1?53:128, 58, 69, 24);
|
||||||
|
} else if (oldctrl == 0) {
|
||||||
|
sprintf(editstr, "%s%s", value, " ");
|
||||||
|
XDrawImageString(bx_x_display, dialog, gc, 49, 34, editstr, strlen(editstr));
|
||||||
|
}
|
||||||
|
if (control > 0) {
|
||||||
|
XDrawRectangle(bx_x_display, dialog, gc, control==1?53:128, 58, 69, 24);
|
||||||
|
} else {
|
||||||
|
sprintf(editstr, "%s%s", value, "_ ");
|
||||||
|
XDrawImageString(bx_x_display, dialog, gc, 49, 34, editstr, strlen(editstr));
|
||||||
|
}
|
||||||
|
oldctrl = control;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (control == 1) param->set(value);
|
||||||
|
if (control == 2) control = -1;
|
||||||
|
XFreeGC(bx_x_display, gc);
|
||||||
|
XDestroyWindow(bx_x_display, dialog);
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
|
||||||
BxEvent *
|
BxEvent *
|
||||||
x11_notify_callback (void *unused, BxEvent *event)
|
x11_notify_callback (void *unused, BxEvent *event)
|
||||||
{
|
{
|
||||||
|
int opts;
|
||||||
|
bx_param_c *param;
|
||||||
|
bx_param_string_c *sparam;
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case BX_SYNC_EVT_LOG_ASK:
|
case BX_SYNC_EVT_LOG_ASK:
|
||||||
event->retcode = x11_ask_dialog(event);
|
event->retcode = x11_ask_dialog(event);
|
||||||
return event;
|
return event;
|
||||||
|
case BX_SYNC_EVT_ASK_PARAM:
|
||||||
|
param = event->u.param.param;
|
||||||
|
if (param->get_type() == BXT_PARAM_STRING) {
|
||||||
|
sparam = (bx_param_string_c *)param;
|
||||||
|
opts = sparam->get_options()->get();
|
||||||
|
if ((opts & sparam->IS_FILENAME) == 0) {
|
||||||
|
event->retcode = x11_string_dialog(sparam);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
}
|
||||||
case BX_SYNC_EVT_TICK: // called periodically by siminterface.
|
case BX_SYNC_EVT_TICK: // called periodically by siminterface.
|
||||||
case BX_SYNC_EVT_ASK_PARAM: // called if simulator needs to know value of a param.
|
|
||||||
case BX_ASYNC_EVT_REFRESH: // called when some bx_param_c parameters have changed.
|
case BX_ASYNC_EVT_REFRESH: // called when some bx_param_c parameters have changed.
|
||||||
// fall into default case
|
// fall into default case
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user