2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2002-10-16 23:50:27 +04:00
|
|
|
// $Id: gui.cc,v 1.51 2002-10-16 19:50:27 vruppert Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2002-02-01 19:46:27 +03:00
|
|
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
2001-05-09 00:18:04 +04:00
|
|
|
#include <signal.h>
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "bochs.h"
|
|
|
|
#include "gui/bitmaps/floppya.h"
|
|
|
|
#include "gui/bitmaps/floppyb.h"
|
|
|
|
#include "gui/bitmaps/mouse.h"
|
|
|
|
#include "gui/bitmaps/reset.h"
|
|
|
|
#include "gui/bitmaps/power.h"
|
|
|
|
#include "gui/bitmaps/snapshot.h"
|
2002-03-11 18:04:58 +03:00
|
|
|
#include "gui/bitmaps/copy.h"
|
|
|
|
#include "gui/bitmaps/paste.h"
|
2001-11-10 01:17:33 +03:00
|
|
|
#include "gui/bitmaps/configbutton.h"
|
2002-02-01 19:46:27 +03:00
|
|
|
#include "gui/bitmaps/cdromd.h"
|
2002-08-09 10:16:43 +04:00
|
|
|
#include "gui/bitmaps/userbutton.h"
|
2001-09-26 04:15:30 +04:00
|
|
|
#if BX_WITH_MACOS
|
2001-04-10 05:04:59 +04:00
|
|
|
# include <Disks.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bx_gui_c bx_gui;
|
|
|
|
|
|
|
|
#define BX_GUI_THIS bx_gui.
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
#define LOG_THIS BX_GUI_THIS
|
2001-04-10 05:04:59 +04:00
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
bx_gui_c::bx_gui_c(void)
|
|
|
|
{
|
2001-06-27 23:16:01 +04:00
|
|
|
put("GUI"); // Init in specific_init
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
settype(GUILOG);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
|
|
|
|
{
|
|
|
|
specific_init(&bx_gui, argc, argv, tilewidth, tileheight, BX_HEADER_BAR_Y);
|
|
|
|
|
|
|
|
// Define some bitmaps to use in the headerbar
|
|
|
|
BX_GUI_THIS floppyA_bmap_id = create_bitmap(bx_floppya_bmap,
|
|
|
|
BX_FLOPPYA_BMAP_X, BX_FLOPPYA_BMAP_Y);
|
|
|
|
BX_GUI_THIS floppyA_eject_bmap_id = create_bitmap(bx_floppya_eject_bmap,
|
|
|
|
BX_FLOPPYA_BMAP_X, BX_FLOPPYA_BMAP_Y);
|
|
|
|
BX_GUI_THIS floppyB_bmap_id = create_bitmap(bx_floppyb_bmap,
|
|
|
|
BX_FLOPPYB_BMAP_X, BX_FLOPPYB_BMAP_Y);
|
|
|
|
BX_GUI_THIS floppyB_eject_bmap_id = create_bitmap(bx_floppyb_eject_bmap,
|
|
|
|
BX_FLOPPYB_BMAP_X, BX_FLOPPYB_BMAP_Y);
|
2002-02-01 19:46:27 +03:00
|
|
|
BX_GUI_THIS cdromD_bmap_id = create_bitmap(bx_cdromd_bmap,
|
|
|
|
BX_CDROMD_BMAP_X, BX_CDROMD_BMAP_Y);
|
|
|
|
BX_GUI_THIS cdromD_eject_bmap_id = create_bitmap(bx_cdromd_eject_bmap,
|
|
|
|
BX_CDROMD_BMAP_X, BX_CDROMD_BMAP_Y);
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_GUI_THIS mouse_bmap_id = create_bitmap(bx_mouse_bmap,
|
|
|
|
BX_MOUSE_BMAP_X, BX_MOUSE_BMAP_Y);
|
|
|
|
BX_GUI_THIS nomouse_bmap_id = create_bitmap(bx_nomouse_bmap,
|
|
|
|
BX_MOUSE_BMAP_X, BX_MOUSE_BMAP_Y);
|
|
|
|
|
|
|
|
|
|
|
|
BX_GUI_THIS power_bmap_id = create_bitmap(bx_power_bmap, BX_POWER_BMAP_X, BX_POWER_BMAP_Y);
|
|
|
|
BX_GUI_THIS reset_bmap_id = create_bitmap(bx_reset_bmap, BX_RESET_BMAP_X, BX_RESET_BMAP_Y);
|
|
|
|
BX_GUI_THIS snapshot_bmap_id = create_bitmap(bx_snapshot_bmap, BX_SNAPSHOT_BMAP_X, BX_SNAPSHOT_BMAP_Y);
|
2002-03-11 18:04:58 +03:00
|
|
|
BX_GUI_THIS copy_bmap_id = create_bitmap(bx_copy_bmap, BX_COPY_BMAP_X, BX_COPY_BMAP_Y);
|
|
|
|
BX_GUI_THIS paste_bmap_id = create_bitmap(bx_paste_bmap, BX_PASTE_BMAP_X, BX_PASTE_BMAP_Y);
|
|
|
|
BX_GUI_THIS config_bmap_id = create_bitmap(bx_config_bmap, BX_CONFIG_BMAP_X, BX_CONFIG_BMAP_Y);
|
2002-08-09 10:16:43 +04:00
|
|
|
BX_GUI_THIS user_bmap_id = create_bitmap(bx_user_bmap, BX_USER_BMAP_X, BX_USER_BMAP_Y);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
// Add the initial bitmaps to the headerbar, and enable callback routine, for use
|
|
|
|
// when that bitmap is clicked on
|
|
|
|
|
|
|
|
// Floppy A:
|
|
|
|
BX_GUI_THIS floppyA_status = bx_devices.floppy->get_media_status(0);
|
|
|
|
if (BX_GUI_THIS floppyA_status)
|
|
|
|
BX_GUI_THIS floppyA_hbar_id = headerbar_bitmap(BX_GUI_THIS floppyA_bmap_id,
|
|
|
|
BX_GRAVITY_LEFT, floppyA_handler);
|
|
|
|
else
|
|
|
|
BX_GUI_THIS floppyA_hbar_id = headerbar_bitmap(BX_GUI_THIS floppyA_eject_bmap_id,
|
|
|
|
BX_GRAVITY_LEFT, floppyA_handler);
|
|
|
|
|
|
|
|
// Floppy B:
|
|
|
|
BX_GUI_THIS floppyB_status = bx_devices.floppy->get_media_status(1);
|
|
|
|
if (BX_GUI_THIS floppyB_status)
|
|
|
|
BX_GUI_THIS floppyB_hbar_id = headerbar_bitmap(BX_GUI_THIS floppyB_bmap_id,
|
|
|
|
BX_GRAVITY_LEFT, floppyB_handler);
|
|
|
|
else
|
|
|
|
BX_GUI_THIS floppyB_hbar_id = headerbar_bitmap(BX_GUI_THIS floppyB_eject_bmap_id,
|
|
|
|
BX_GRAVITY_LEFT, floppyB_handler);
|
|
|
|
|
2002-02-01 19:46:27 +03:00
|
|
|
// CDROM
|
2002-09-23 00:56:12 +04:00
|
|
|
Bit32u handle = bx_devices.hard_drive->get_first_cd_handle();
|
|
|
|
BX_GUI_THIS cdromD_status = bx_devices.hard_drive->get_cd_media_status(handle);
|
|
|
|
|
2002-02-01 19:46:27 +03:00
|
|
|
if (BX_GUI_THIS cdromD_status)
|
|
|
|
BX_GUI_THIS cdromD_hbar_id = headerbar_bitmap(BX_GUI_THIS cdromD_bmap_id,
|
|
|
|
BX_GRAVITY_LEFT, cdromD_handler);
|
|
|
|
else
|
|
|
|
BX_GUI_THIS cdromD_hbar_id = headerbar_bitmap(BX_GUI_THIS cdromD_eject_bmap_id,
|
|
|
|
BX_GRAVITY_LEFT, cdromD_handler);
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
// Mouse button
|
2001-06-20 18:01:39 +04:00
|
|
|
if (bx_options.Omouse_enabled->get ())
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_GUI_THIS mouse_hbar_id = headerbar_bitmap(BX_GUI_THIS mouse_bmap_id,
|
2001-06-23 07:18:14 +04:00
|
|
|
BX_GRAVITY_LEFT, toggle_mouse_enable);
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
|
|
|
BX_GUI_THIS mouse_hbar_id = headerbar_bitmap(BX_GUI_THIS nomouse_bmap_id,
|
2001-06-23 07:18:14 +04:00
|
|
|
BX_GRAVITY_LEFT, toggle_mouse_enable);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-03-11 18:04:58 +03:00
|
|
|
// These are the buttons on the right side. They are created in order
|
|
|
|
// of right to left.
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
// Power button
|
|
|
|
BX_GUI_THIS power_hbar_id = headerbar_bitmap(BX_GUI_THIS power_bmap_id,
|
|
|
|
BX_GRAVITY_RIGHT, power_handler);
|
|
|
|
// Reset button
|
|
|
|
BX_GUI_THIS reset_hbar_id = headerbar_bitmap(BX_GUI_THIS reset_bmap_id,
|
|
|
|
BX_GRAVITY_RIGHT, reset_handler);
|
2001-11-10 01:17:33 +03:00
|
|
|
// Configure button
|
|
|
|
BX_GUI_THIS config_hbar_id = headerbar_bitmap(BX_GUI_THIS config_bmap_id,
|
|
|
|
BX_GRAVITY_RIGHT, config_handler);
|
2002-03-11 18:04:58 +03:00
|
|
|
// Snapshot button
|
|
|
|
BX_GUI_THIS snapshot_hbar_id = headerbar_bitmap(BX_GUI_THIS snapshot_bmap_id,
|
|
|
|
BX_GRAVITY_RIGHT, snapshot_handler);
|
|
|
|
// Paste button
|
|
|
|
BX_GUI_THIS paste_hbar_id = headerbar_bitmap(BX_GUI_THIS paste_bmap_id,
|
|
|
|
BX_GRAVITY_RIGHT, paste_handler);
|
|
|
|
// Copy button
|
|
|
|
BX_GUI_THIS copy_hbar_id = headerbar_bitmap(BX_GUI_THIS copy_bmap_id,
|
|
|
|
BX_GRAVITY_RIGHT, copy_handler);
|
2002-08-09 10:16:43 +04:00
|
|
|
// User button
|
|
|
|
BX_GUI_THIS user_hbar_id = headerbar_bitmap(BX_GUI_THIS user_bmap_id,
|
|
|
|
BX_GRAVITY_RIGHT, userbutton_handler);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
show_headerbar();
|
|
|
|
}
|
|
|
|
|
2001-09-28 10:03:40 +04:00
|
|
|
void
|
2002-03-17 23:57:54 +03:00
|
|
|
bx_gui_c::update_drive_status_buttons (void) {
|
2001-09-28 10:03:40 +04:00
|
|
|
BX_GUI_THIS floppyA_status =
|
|
|
|
bx_devices.floppy->get_media_status (0)
|
2002-08-04 12:42:34 +04:00
|
|
|
&& bx_options.floppya.Ostatus->get ();
|
2001-09-28 10:03:40 +04:00
|
|
|
BX_GUI_THIS floppyB_status =
|
|
|
|
bx_devices.floppy->get_media_status (1)
|
2002-08-04 12:42:34 +04:00
|
|
|
&& bx_options.floppyb.Ostatus->get ();
|
2002-09-23 00:56:12 +04:00
|
|
|
Bit32u handle = bx_devices.hard_drive->get_first_cd_handle();
|
|
|
|
BX_GUI_THIS cdromD_status = bx_devices.hard_drive->get_cd_media_status(handle);
|
2001-04-10 05:04:59 +04:00
|
|
|
if (BX_GUI_THIS floppyA_status)
|
|
|
|
replace_bitmap(BX_GUI_THIS floppyA_hbar_id, BX_GUI_THIS floppyA_bmap_id);
|
|
|
|
else {
|
2001-09-26 04:15:30 +04:00
|
|
|
#if BX_WITH_MACOS
|
2001-04-10 05:04:59 +04:00
|
|
|
// If we are using the Mac floppy driver, eject the disk
|
2001-09-26 04:15:30 +04:00
|
|
|
// from the floppy drive. This doesn't work in MacOS X.
|
2001-06-21 18:56:43 +04:00
|
|
|
if (!strcmp(bx_options.floppya.Opath->get (), SuperDrive))
|
2001-04-10 05:04:59 +04:00
|
|
|
DiskEject(1);
|
|
|
|
#endif
|
|
|
|
replace_bitmap(BX_GUI_THIS floppyA_hbar_id, BX_GUI_THIS floppyA_eject_bmap_id);
|
|
|
|
}
|
2001-09-28 10:03:40 +04:00
|
|
|
if (BX_GUI_THIS floppyB_status)
|
|
|
|
replace_bitmap(BX_GUI_THIS floppyB_hbar_id, BX_GUI_THIS floppyB_bmap_id);
|
|
|
|
else {
|
|
|
|
#if BX_WITH_MACOS
|
|
|
|
// If we are using the Mac floppy driver, eject the disk
|
|
|
|
// from the floppy drive. This doesn't work in MacOS X.
|
|
|
|
if (!strcmp(bx_options.floppyb.Opath->get (), SuperDrive))
|
|
|
|
DiskEject(1);
|
|
|
|
#endif
|
|
|
|
replace_bitmap(BX_GUI_THIS floppyB_hbar_id, BX_GUI_THIS floppyB_eject_bmap_id);
|
|
|
|
}
|
2002-02-01 19:46:27 +03:00
|
|
|
if (BX_GUI_THIS cdromD_status)
|
|
|
|
replace_bitmap(BX_GUI_THIS cdromD_hbar_id, BX_GUI_THIS cdromD_bmap_id);
|
|
|
|
else {
|
|
|
|
replace_bitmap(BX_GUI_THIS cdromD_hbar_id, BX_GUI_THIS cdromD_eject_bmap_id);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-28 10:03:40 +04:00
|
|
|
bx_gui_c::floppyA_handler(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-04-18 04:22:20 +04:00
|
|
|
#if BX_WITH_WX
|
|
|
|
// instead of just toggling the status, call wxWindows to bring up
|
|
|
|
// a dialog asking what disk image you want to switch to.
|
|
|
|
int ret = SIM->ask_param (BXP_FLOPPYA_PATH);
|
2002-08-25 16:32:54 +04:00
|
|
|
if (ret < 0) return; // cancelled
|
2002-04-18 04:22:20 +04:00
|
|
|
// eject and then insert the disk. If the new path is invalid,
|
|
|
|
// the status will return 0.
|
|
|
|
unsigned new_status = bx_devices.floppy->set_media_status(0, 0);
|
|
|
|
printf ("eject disk, new_status is %d\n", new_status);
|
|
|
|
new_status = bx_devices.floppy->set_media_status(0, 1);
|
|
|
|
printf ("insert disk, new_status is %d\n", new_status);
|
|
|
|
fflush (stdout);
|
|
|
|
BX_GUI_THIS floppyA_status = new_status;
|
|
|
|
#else
|
2001-09-28 10:03:40 +04:00
|
|
|
BX_GUI_THIS floppyA_status = !BX_GUI_THIS floppyA_status;
|
|
|
|
bx_devices.floppy->set_media_status(0, BX_GUI_THIS floppyA_status);
|
2002-04-18 04:22:20 +04:00
|
|
|
#endif
|
2002-03-17 23:57:54 +03:00
|
|
|
BX_GUI_THIS update_drive_status_buttons ();
|
2001-09-28 10:03:40 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-09-28 10:03:40 +04:00
|
|
|
void
|
|
|
|
bx_gui_c::floppyB_handler(void)
|
|
|
|
{
|
2002-04-18 04:22:20 +04:00
|
|
|
#if BX_WITH_WX
|
|
|
|
// instead of just toggling the status, call wxWindows to bring up
|
|
|
|
// a dialog asking what disk image you want to switch to.
|
|
|
|
int ret = SIM->ask_param (BXP_FLOPPYB_PATH);
|
2002-08-25 16:32:54 +04:00
|
|
|
if (ret < 0) return; // cancelled
|
2002-04-18 04:22:20 +04:00
|
|
|
// eject and then insert the disk. If the new path is invalid,
|
|
|
|
// the status will return 0.
|
|
|
|
unsigned new_status = bx_devices.floppy->set_media_status(1, 0);
|
|
|
|
printf ("eject disk, new_status is %d\n", new_status);
|
|
|
|
new_status = bx_devices.floppy->set_media_status(1, 1);
|
|
|
|
printf ("insert disk, new_status is %d\n", new_status);
|
|
|
|
fflush (stdout);
|
|
|
|
BX_GUI_THIS floppyB_status = new_status;
|
|
|
|
#else
|
2001-09-28 10:03:40 +04:00
|
|
|
BX_GUI_THIS floppyB_status = !BX_GUI_THIS floppyB_status;
|
|
|
|
bx_devices.floppy->set_media_status(1, BX_GUI_THIS floppyB_status);
|
2002-04-18 04:22:20 +04:00
|
|
|
#endif
|
2002-03-17 23:57:54 +03:00
|
|
|
BX_GUI_THIS update_drive_status_buttons ();
|
2002-02-01 19:46:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_gui_c::cdromD_handler(void)
|
|
|
|
{
|
2002-09-23 00:56:12 +04:00
|
|
|
Bit32u handle = bx_devices.hard_drive->get_first_cd_handle();
|
2002-04-18 04:22:20 +04:00
|
|
|
#if BX_WITH_WX
|
|
|
|
// instead of just toggling the status, call wxWindows to bring up
|
|
|
|
// a dialog asking what disk image you want to switch to.
|
2002-09-23 00:56:12 +04:00
|
|
|
// BBD: for now, find the first cdrom and call ask_param on that.
|
|
|
|
// Since we could have multiple cdroms now, maybe we should be adding
|
|
|
|
// one cdrom button for each?
|
|
|
|
bx_param_c *cdrom = SIM->get_first_cdrom ();
|
|
|
|
if (cdrom == NULL)
|
|
|
|
return; // no cdrom found
|
|
|
|
int ret = SIM->ask_param (cdrom->get_id ());
|
2002-08-25 16:32:54 +04:00
|
|
|
if (ret < 0) return; // cancelled
|
2002-04-18 04:22:20 +04:00
|
|
|
// eject and then insert the disk. If the new path is invalid,
|
|
|
|
// the status will return 0.
|
2002-09-23 00:56:12 +04:00
|
|
|
unsigned status = bx_devices.hard_drive->set_cd_media_status(handle, 0);
|
2002-04-18 04:22:20 +04:00
|
|
|
printf ("eject disk, new_status is %d\n", status);
|
2002-09-23 00:56:12 +04:00
|
|
|
status = bx_devices.hard_drive->set_cd_media_status(handle, 1);
|
2002-04-18 04:22:20 +04:00
|
|
|
printf ("insert disk, new_status is %d\n", status);
|
|
|
|
fflush (stdout);
|
|
|
|
BX_GUI_THIS cdromD_status = status;
|
|
|
|
#else
|
2002-02-01 19:46:27 +03:00
|
|
|
BX_GUI_THIS cdromD_status =
|
2002-09-23 00:56:12 +04:00
|
|
|
bx_devices.hard_drive->set_cd_media_status(handle, !BX_GUI_THIS cdromD_status);
|
2002-04-18 04:22:20 +04:00
|
|
|
#endif
|
2002-03-17 23:57:54 +03:00
|
|
|
BX_GUI_THIS update_drive_status_buttons ();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_gui_c::reset_handler(void)
|
|
|
|
{
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(( "system RESET callback." ));
|
2001-05-25 18:21:46 +04:00
|
|
|
bx_pc_system.ResetSignal( PCS_SET ); /* XXX is this right? */
|
|
|
|
for (int i=0; i<BX_SMP_PROCESSORS; i++)
|
|
|
|
BX_CPU(i)->reset(BX_RESET_HARDWARE);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_gui_c::power_handler(void)
|
|
|
|
{
|
2001-06-15 22:01:52 +04:00
|
|
|
// the user pressed power button, so there's no doubt they want bochs
|
|
|
|
// to quit. Change panics to fatal for the GUI and then do a panic.
|
|
|
|
LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL);
|
|
|
|
BX_PANIC (("POWER button turned off."));
|
|
|
|
// shouldn't reach this point, but if you do, QUIT!!!
|
|
|
|
fprintf (stderr, "Bochs is exiting because you pressed the power button.\n");
|
2002-04-18 04:22:20 +04:00
|
|
|
BX_EXIT (1);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-03-11 18:04:58 +03:00
|
|
|
Bit32s
|
|
|
|
bx_gui_c::make_text_snapshot (char **snapshot, Bit32u *length)
|
2001-11-10 01:17:33 +03:00
|
|
|
{
|
2002-03-11 18:04:58 +03:00
|
|
|
Bit8u* raw_snap = NULL;
|
|
|
|
char *clean_snap;
|
2002-02-12 20:09:51 +03:00
|
|
|
unsigned line_addr, txt_addr, txHeight, txWidth;
|
2002-02-04 23:31:35 +03:00
|
|
|
|
2002-03-11 18:04:58 +03:00
|
|
|
bx_vga.get_text_snapshot(&raw_snap, &txHeight, &txWidth);
|
|
|
|
if (txHeight <= 0) return -1;
|
|
|
|
clean_snap = (char*) malloc(txHeight*(txWidth+2)+1);
|
|
|
|
txt_addr = 0;
|
|
|
|
for (unsigned i=0; i<txHeight; i++) {
|
|
|
|
line_addr = i * txWidth * 2;
|
|
|
|
for (unsigned j=0; j<(txWidth*2); j+=2) {
|
|
|
|
clean_snap[txt_addr] = raw_snap[line_addr+j];
|
2002-02-12 20:09:51 +03:00
|
|
|
txt_addr++;
|
2002-02-04 23:31:35 +03:00
|
|
|
}
|
2002-03-10 08:49:26 +03:00
|
|
|
#ifdef WIN32
|
2002-03-11 18:04:58 +03:00
|
|
|
clean_snap[txt_addr] = 13;
|
|
|
|
txt_addr++;
|
|
|
|
#endif
|
|
|
|
clean_snap[txt_addr] = 10;
|
|
|
|
txt_addr++;
|
|
|
|
}
|
|
|
|
clean_snap[txt_addr] = 0;
|
|
|
|
*snapshot = clean_snap;
|
|
|
|
*length = txt_addr;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// create a text snapshot and copy to the system clipboard. On guis that
|
|
|
|
// we haven't figured out how to support yet, dump to a file instead.
|
|
|
|
void
|
|
|
|
bx_gui_c::copy_handler(void)
|
|
|
|
{
|
|
|
|
Bit32u len;
|
|
|
|
char *text_snapshot;
|
|
|
|
if (make_text_snapshot (&text_snapshot, &len) < 0) {
|
|
|
|
BX_INFO(( "copy button failed, mode not implemented"));
|
|
|
|
return;
|
|
|
|
}
|
2002-03-16 14:30:06 +03:00
|
|
|
if (!set_clipboard_text(text_snapshot, len)) {
|
|
|
|
// platform specific code failed, use portable code instead
|
|
|
|
FILE *fp = fopen("copy.txt", "w");
|
|
|
|
fwrite(text_snapshot, 1, strlen(text_snapshot), fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
2002-03-11 18:04:58 +03:00
|
|
|
free(text_snapshot);
|
|
|
|
}
|
|
|
|
|
|
|
|
// create a text snapshot and dump it to a file
|
|
|
|
void
|
|
|
|
bx_gui_c::snapshot_handler(void)
|
|
|
|
{
|
|
|
|
char *text_snapshot;
|
|
|
|
Bit32u len;
|
|
|
|
if (make_text_snapshot (&text_snapshot, &len) < 0) {
|
2002-03-15 19:45:10 +03:00
|
|
|
BX_ERROR(( "snapshot button failed, mode not implemented"));
|
2002-03-11 18:04:58 +03:00
|
|
|
return;
|
2002-02-04 23:31:35 +03:00
|
|
|
}
|
2002-04-18 04:22:20 +04:00
|
|
|
//FIXME
|
|
|
|
char filename[BX_PATHNAME_LEN];
|
|
|
|
#if BX_WITH_WX
|
2002-09-21 23:38:47 +04:00
|
|
|
int ret = SIM->ask_filename (filename, sizeof(filename),
|
|
|
|
"Save snapshot as...", "snapshot.txt",
|
- fixed up ParamDialog to correctly handle "trees" of parameters. A
bx_list_c can now be displayed as either a wxStaticBox with the
child parameters inside, or as a wxNotebook with each child
parameter in a separate tab. (The children can also be lists of
course.) The default display is the wxStaticBox type, but if you
set the option bit bx_list_c::USE_TAB_WINDOW in the list,
ParamDialog will use the wxNotebook display instead.
- to get the param trees working, I created a new struct
AddParamContext, which is passed to AddParam(). This struct is
critical when AddParam calls itself recursively to display lists
within lists.
- use the wxNotebook display feature for the ATA0,1,2,3 controller
dialog box. Now instead of being hundreds of pixels tall, it is
reasonable height with three different tabs. This fixed bug
#619074: "wx: ATA interface editor too tall" and was the whole
reason I started messing with this at all.
plus some minor cleanups
- when I added the enum constant bx_list_c::USE_TAB_WINDOW, I also
removed the BX_ prefix from all the other enum constants that are
used in parameter options in siminterface.cc. Since these constants
are enums within a class, there is no possibility of namespace
conflicts so the prefix is not needed.
- added wxADJUST_MINSIZE to all wxChoice controls, since that tells
wxWindows to adjust its size to the length of the longest string.
- instead of calling SetSize or SetSizeHints on every textcontrol with
a hardcoded width, I am using just two wxSize specifications for
everything: either normalTextSize or longTextSize.
- edit names of a few menus and params. For example now instead of
the tab saying "Master ATA device on channel 0" it will say
"First HD/CD on channel 0".
Modified Files:
main.cc gui/control.cc gui/gui.cc gui/siminterface.cc gui/siminterface.h
gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc
2002-10-06 06:37:28 +04:00
|
|
|
bx_param_string_c::SAVE_FILE_DIALOG);
|
2002-09-21 23:38:47 +04:00
|
|
|
if (ret < 0) { // cancelled
|
|
|
|
free(text_snapshot);
|
|
|
|
return;
|
|
|
|
}
|
2002-04-18 04:22:20 +04:00
|
|
|
#else
|
|
|
|
strcpy (filename, "snapshot.txt");
|
|
|
|
#endif
|
2002-09-21 23:38:47 +04:00
|
|
|
FILE *fp = fopen(filename, "wb");
|
2002-04-18 04:22:20 +04:00
|
|
|
fwrite(text_snapshot, 1, strlen(text_snapshot), fp);
|
|
|
|
fclose(fp);
|
2002-03-16 14:30:06 +03:00
|
|
|
free(text_snapshot);
|
2001-11-10 01:17:33 +03:00
|
|
|
}
|
|
|
|
|
2002-03-11 18:04:58 +03:00
|
|
|
// Read ASCII chars from the system clipboard and paste them into bochs.
|
|
|
|
// Note that paste cannot work with the key mapping tables loaded.
|
|
|
|
void
|
|
|
|
bx_gui_c::paste_handler(void)
|
|
|
|
{
|
|
|
|
Bit32s nbytes;
|
|
|
|
Bit8u *bytes;
|
|
|
|
if (!bx_keymap.isKeymapLoaded ()) {
|
|
|
|
BX_ERROR (("keyboard_mapping disabled, so paste cannot work"));
|
|
|
|
return;
|
|
|
|
}
|
2002-03-16 14:30:06 +03:00
|
|
|
if (!get_clipboard_text(&bytes, &nbytes)) {
|
|
|
|
BX_ERROR (("paste not implemented on this platform"));
|
|
|
|
return;
|
|
|
|
}
|
2002-03-11 18:04:58 +03:00
|
|
|
BX_INFO (("pasting %d bytes", nbytes));
|
|
|
|
bx_devices.keyboard->paste_bytes (bytes, nbytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-10 01:17:33 +03:00
|
|
|
void
|
|
|
|
bx_gui_c::config_handler(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
#if BX_USE_CONFIG_INTERFACE && !BX_WITH_WX
|
|
|
|
bx_config_interface (BX_CI_RUNTIME);
|
2001-06-11 10:48:37 +04:00
|
|
|
#else
|
2002-03-11 18:04:58 +03:00
|
|
|
BX_ERROR(( "# CONFIG callback (unimplemented)." ));
|
2001-06-11 10:48:37 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-06-23 07:18:14 +04:00
|
|
|
bx_gui_c::toggle_mouse_enable(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2001-06-20 18:01:39 +04:00
|
|
|
int old = bx_options.Omouse_enabled->get ();
|
2001-08-31 20:06:32 +04:00
|
|
|
BX_DEBUG (("toggle mouse_enabled, now %d", !old));
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_options.Omouse_enabled->set (!old);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-08-09 10:16:43 +04:00
|
|
|
void
|
|
|
|
bx_gui_c::userbutton_handler(void)
|
|
|
|
{
|
|
|
|
unsigned shortcut[4];
|
2002-10-16 23:50:27 +04:00
|
|
|
unsigned p;
|
2002-08-09 10:16:43 +04:00
|
|
|
char *user_shortcut;
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
len = 0;
|
2002-08-25 16:32:54 +04:00
|
|
|
#if BX_WITH_WX
|
|
|
|
int ret = SIM->ask_param (BXP_USER_SHORTCUT);
|
|
|
|
user_shortcut = bx_options.Ouser_shortcut->getptr();
|
|
|
|
if ((ret > 0) && user_shortcut[0] && (strcmp(user_shortcut, "none"))) {
|
|
|
|
#else
|
2002-08-09 10:16:43 +04:00
|
|
|
user_shortcut = bx_options.Ouser_shortcut->getptr();
|
|
|
|
if (user_shortcut[0] && (strcmp(user_shortcut, "none"))) {
|
2002-08-25 16:32:54 +04:00
|
|
|
#endif
|
2002-10-16 23:50:27 +04:00
|
|
|
len = 0;
|
|
|
|
p = 0;
|
|
|
|
while ((p < strlen(user_shortcut)) && (len < 3)) {
|
|
|
|
if (!strncmp(user_shortcut+p, "alt", 3)) {
|
|
|
|
shortcut[len] = BX_KEY_ALT_L;
|
|
|
|
len++;
|
|
|
|
p += 3;
|
|
|
|
} else if (!strncmp(user_shortcut+p, "ctrl", 4)) {
|
|
|
|
shortcut[len] = BX_KEY_CTRL_L;
|
|
|
|
len++;
|
|
|
|
p += 4;
|
|
|
|
} else if (!strncmp(user_shortcut+p, "del", 3)) {
|
|
|
|
shortcut[len] = BX_KEY_DELETE;
|
|
|
|
len++;
|
|
|
|
p += 3;
|
|
|
|
} else if (!strncmp(user_shortcut+p, "esc", 3)) {
|
|
|
|
shortcut[len] = BX_KEY_ESC;
|
|
|
|
len++;
|
|
|
|
p += 3;
|
|
|
|
} else if (!strncmp(user_shortcut+p, "f1", 2)) {
|
|
|
|
shortcut[len] = BX_KEY_F1;
|
|
|
|
len++;
|
|
|
|
p += 2;
|
|
|
|
} else if (!strncmp(user_shortcut+p, "f4", 2)) {
|
|
|
|
shortcut[len] = BX_KEY_F4;
|
|
|
|
len++;
|
|
|
|
p += 2;
|
|
|
|
} else if (!strncmp(user_shortcut+p, "tab", 3)) {
|
|
|
|
shortcut[len] = BX_KEY_TAB;
|
|
|
|
len++;
|
|
|
|
p += 3;
|
|
|
|
} else if (!strncmp(user_shortcut+p, "win", 3)) {
|
|
|
|
shortcut[len] = BX_KEY_WIN_L;
|
|
|
|
len++;
|
|
|
|
p += 3;
|
|
|
|
} else {
|
|
|
|
BX_ERROR(("Unknown shortcut %s ignored", user_shortcut));
|
2002-08-09 10:16:43 +04:00
|
|
|
}
|
2002-10-16 23:50:27 +04:00
|
|
|
}
|
2002-08-25 16:32:54 +04:00
|
|
|
i = 0;
|
2002-08-09 10:16:43 +04:00
|
|
|
while (i < len) {
|
|
|
|
bx_devices.keyboard->gen_scancode(shortcut[i++]);
|
|
|
|
}
|
|
|
|
i--;
|
|
|
|
while (i >= 0) {
|
|
|
|
bx_devices.keyboard->gen_scancode(shortcut[i--] | BX_KEY_RELEASED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
void
|
2001-06-17 03:08:32 +04:00
|
|
|
bx_gui_c::mouse_enabled_changed (Boolean val)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2001-06-23 07:18:14 +04:00
|
|
|
// This is only called when SIM->get_init_done is 1. Note that VAL
|
|
|
|
// is the new value of mouse_enabled, which may not match the old
|
|
|
|
// value which is still in bx_options.Omouse_enabled->get ().
|
2001-08-31 20:06:32 +04:00
|
|
|
BX_DEBUG (("replacing the mouse bitmaps"));
|
2001-06-17 03:08:32 +04:00
|
|
|
if (val)
|
2001-06-10 00:01:12 +04:00
|
|
|
replace_bitmap(BX_GUI_THIS mouse_hbar_id, BX_GUI_THIS mouse_bmap_id);
|
|
|
|
else
|
|
|
|
replace_bitmap(BX_GUI_THIS mouse_hbar_id, BX_GUI_THIS nomouse_bmap_id);
|
2001-06-23 07:18:14 +04:00
|
|
|
// give the GUI a chance to respond to the event. Most guis will hide
|
|
|
|
// the native mouse cursor and do something to trap the mouse inside the
|
|
|
|
// bochs VGA display window.
|
|
|
|
mouse_enabled_changed_specific (val);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-05-09 00:18:04 +04:00
|
|
|
|
2002-09-21 23:38:47 +04:00
|
|
|
void
|
2001-05-09 00:18:04 +04:00
|
|
|
bx_gui_c::init_signal_handlers ()
|
|
|
|
{
|
|
|
|
#if BX_GUI_SIGHANDLER
|
|
|
|
Bit32u mask = get_sighandler_mask ();
|
|
|
|
for (Bit32u sig=0; sig<32; sig++)
|
|
|
|
{
|
|
|
|
if (mask & (1<<sig))
|
|
|
|
signal (sig, bx_signal_handler);
|
|
|
|
}
|
|
|
|
#endif
|
2002-09-08 11:56:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_gui_c::set_text_charmap(Bit8u *fbuffer)
|
|
|
|
{
|
|
|
|
memcpy(& BX_GUI_THIS vga_charmap, fbuffer, 0x2000);
|
2002-09-21 23:38:47 +04:00
|
|
|
for (unsigned i=0; i<256; i++) BX_GUI_THIS char_changed[i] = 1;
|
|
|
|
BX_GUI_THIS charmap_updated = 1;
|
2002-09-19 22:59:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_gui_c::set_text_charbyte(Bit16u address, Bit8u data)
|
|
|
|
{
|
|
|
|
BX_GUI_THIS vga_charmap[address] = data;
|
2002-09-21 23:38:47 +04:00
|
|
|
BX_GUI_THIS char_changed[address >> 5] = 1;
|
|
|
|
BX_GUI_THIS charmap_updated = 1;
|
2001-05-09 00:18:04 +04:00
|
|
|
}
|