- obsolete harddisk and cdrom dialogs removed

- wx.cc must not include wxdialog.h
This commit is contained in:
Volker Ruppert 2003-08-23 17:53:27 +00:00
parent be5bd5dca4
commit b78c910e8f
4 changed files with 5 additions and 543 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wx.cc,v 1.64 2003-07-13 16:31:35 vruppert Exp $
// $Id: wx.cc,v 1.65 2003-08-23 17:53:27 vruppert Exp $
/////////////////////////////////////////////////////////////////
//
// wxWindows VGA display for Bochs. wx.cc implements a custom
@ -54,7 +54,6 @@
#include "osdep.h"
#include "font/vga.bitmap.h"
#include "wxdialog.h"
// shared elements between wxmain.cc and this file
#include "wxmain.h"

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxdialog.cc,v 1.55 2003-08-23 15:28:06 vruppert Exp $
// $Id: wxdialog.cc,v 1.56 2003-08-23 17:53:27 vruppert Exp $
/////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
@ -380,401 +380,6 @@ void FloppyConfigDialog::ShowHelp ()
wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR );
}
//////////////////////////////////////////////////////////////////////
// HDConfigDialog implementation
//////////////////////////////////////////////////////////////////////
// Structure:
// vertSizer:
// enable checkbox
// hsizer[0]:
// "Disk image:"
// disk image text control
// browse button
// hsizer[1]:
// "Geometry: cylinders"
// geom[0] = cyl control
// "heads"
// geom[1] = heads control
// " sectors/track "
// geom[2] = spt control
// hsizer[2]:
// megs = "Size in MB: NUMBER"
// compute geometry button
// buttonSizer:
// help
// cancel
// ok
// all events go to OnEvent method
BEGIN_EVENT_TABLE(HDConfigDialog, wxDialog)
EVT_BUTTON(-1, HDConfigDialog::OnEvent)
EVT_CHECKBOX(-1, HDConfigDialog::OnEvent)
EVT_TEXT(-1, HDConfigDialog::OnEvent)
END_EVENT_TABLE()
HDConfigDialog::HDConfigDialog(
wxWindow* parent,
wxWindowID id)
: wxDialog (parent, id, "", wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
static char *geomNames[] = HD_CONFIG_GEOM_NAMES;
vertSizer = new wxBoxSizer (wxVERTICAL);
enable = new wxCheckBox (this, ID_Enable, MSG_ENABLED);
enable->SetValue (TRUE);
hsizer[0] = new wxBoxSizer (wxHORIZONTAL);
hsizer[1] = new wxBoxSizer (wxHORIZONTAL);
hsizer[2] = new wxBoxSizer (wxHORIZONTAL);
buttonSizer = new wxBoxSizer (wxHORIZONTAL);
// add top level components to vertSizer
vertSizer->Add (enable, 0, wxTOP|wxLEFT, 10);
vertSizer->Add (hsizer[0], 0, wxTOP|wxLEFT, 10);
vertSizer->Add (hsizer[1], 0, wxTOP|wxLEFT, 10);
vertSizer->Add (hsizer[2], 0, wxTOP|wxLEFT, 10);
vertSizer->Add (buttonSizer, 0, wxALIGN_RIGHT|wxTOP, 10);
// contents of hsizer[0]
wxStaticText *text;
text = new wxStaticText (this, -1, HD_CONFIG_DISKIMG);
hsizer[0]->Add (text);
filename = new wxTextCtrl (this, ID_FilenameText, "", wxDefaultPosition, longTextSize);
hsizer[0]->Add (filename, 1);
wxButton *btn = new wxButton (this, ID_Browse, BTNLABEL_BROWSE);
hsizer[0]->Add (btn);
// contents of hsizer[1]
for (int i=0; i<3; i++) {
text = new wxStaticText (this, -1, geomNames[i]);
hsizer[1]->Add (text);
geom[i] = new wxSpinCtrl (this, ID_Cylinders+i);
hsizer[1]->Add (geom[i]);
}
// contents of hsizer[2]
megs = new wxStaticText (this, ID_Megs, ""); // size in megs
hsizer[2]->Add (megs);
computeGeom = new wxButton (this, ID_ComputeGeometry, HD_CONFIG_COMPUTE_TEXT);
hsizer[2]->Add (computeGeom, 0, wxLEFT, 20);
// contents of buttonSizer
btn = new wxButton (this, wxID_HELP, BTNLABEL_HELP);
buttonSizer->Add (btn, 0, wxALL, 5);
// use wxID_CANCEL because pressing ESC produces this same code
btn = new wxButton (this, wxID_CANCEL, BTNLABEL_CANCEL);
buttonSizer->Add (btn, 0, wxALL, 5);
btn = new wxButton (this, ID_Create, BTNLABEL_CREATE_IMG);
buttonSizer->Add (btn, 0, wxALL, 5);
btn = new wxButton (this, wxID_OK, BTNLABEL_OK);
buttonSizer->Add (btn, 0, wxALL, 5);
// lay it out!
SetAutoLayout(TRUE);
SetSizer(vertSizer);
vertSizer->Fit (this);
wxSize size = vertSizer->GetMinSize ();
wxLogMessage ("minsize is %d,%d", size.GetWidth(), size.GetHeight ());
int margin = 5;
SetSizeHints (size.GetWidth () + margin, size.GetHeight () + margin);
Center ();
}
void HDConfigDialog::SetDriveName (wxString name) {
wxString text;
text.Printf (HD_CONFIG_TITLE, name.c_str ());
SetTitle (text);
}
void HDConfigDialog::SetGeom (int n, int value) {
wxLogMessage ("setting geom[%d] to %d", n, value);
geom[n]->SetValue (value);
wxLogMessage ("now geom[%d] has value %d", n, geom[n]->GetValue ());
UpdateMegs ();
}
void HDConfigDialog::SetGeomRange (int n, int min, int max)
{
wxLogDebug ("Setting range of geom[%d] to min=%d, max=%d", n, min, max);
geom[n]->SetRange (min, SPINCTRL_FIX_MAX(max));
wxLogDebug ("now min=%d, max=%d", geom[n]->GetMin (), geom[n]->GetMax ());
}
float
HDConfigDialog::UpdateMegs () {
float meg = 512.0
* geom[0]->GetValue ()
* geom[1]->GetValue ()
* geom[2]->GetValue ()
/ (1024.0*1024.0);
wxString text;
text.Printf (HD_CONFIG_MEGS, meg);
ChangeStaticText (hsizer[2], megs, text);
Layout ();
return meg;
}
void HDConfigDialog::Init()
{
}
void HDConfigDialog::EnableChanged ()
{
bool en = enable->GetValue ();
filename->Enable (en);
for (int i=0; i<3; i++) geom[i]->Enable (en);
computeGeom->Enable (en);
}
void HDConfigDialog::OnEvent(wxCommandEvent& event)
{
int id = event.GetId ();
wxLogMessage ("you pressed button id=%d", id);
switch (id) {
case ID_Cylinders:
case ID_Heads:
case ID_SPT:
UpdateMegs ();
break;
case ID_ComputeGeometry:
EnterSize ();
break;
case ID_Create:
{
int cyl = geom[0]->GetValue ();
int heads = geom[1]->GetValue ();
int spt = geom[2]->GetValue ();
int sectors = cyl*heads*spt;
char name[1024];
strncpy (name, filename->GetValue ().c_str (), sizeof(name));
if (CreateImage (1, sectors, name)) {
wxString msg;
msg.Printf ("Created a %d megabyte disk image called '%s'.",
sectors*512, name);
wxMessageBox(msg, "Image Created", wxOK | wxICON_INFORMATION);
}
}
break;
case ID_Enable:
EnableChanged ();
break;
case wxID_OK:
// probably should validate before allowing ok
EndModal (wxID_OK);
break;
case ID_Browse:
BrowseTextCtrl (filename);
break;
case wxID_CANCEL:
EndModal (wxID_CANCEL);
break;
case wxID_HELP:
ShowHelp();
break;
default:
event.Skip ();
}
}
void HDConfigDialog::EnterSize ()
{
int initval = (int) (0.5 + UpdateMegs ());
int target_megs = wxGetNumberFromUser (HD_CONFIG_COMPUTE_INSTR, HD_CONFIG_COMPUTE_PROMPT, HD_CONFIG_COMPUTE_CAPTION, initval, 0, 32255);
if (target_megs<0) return;
// this calculate copied from misc/bximage.c
int cyl, heads=16, spt=63;
cyl = (int) (target_megs*1024.0*1024.0/16.0/63.0/512.0);
wxASSERT (cyl < 65536);
geom[0]->SetValue (cyl);
geom[1]->SetValue (heads);
geom[2]->SetValue (spt);
UpdateMegs ();
}
void HDConfigDialog::ShowHelp ()
{
wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR );
}
//////////////////////////////////////////////////////////////////////
// CdromConfigDialog implementation
//////////////////////////////////////////////////////////////////////
// Structure:
// vertSizer:
// box labeled "Device":
// enable = enable checkbox
// box labeled "Media":
// "Where should the emulated CD-ROM find its data?"
// ejected radio button (added by constructor)
// use physical radio buttons (added by calls to AddRadio)
// fileSizer:
// use disk image radio button
// filename = text control
// browse button
// buttonSizer:
// help
// cancel
// ok
// all events go to OnEvent method
BEGIN_EVENT_TABLE(CdromConfigDialog, wxDialog)
EVT_BUTTON(-1, CdromConfigDialog::OnEvent)
EVT_CHECKBOX(-1, CdromConfigDialog::OnEvent)
EVT_TEXT(-1, CdromConfigDialog::OnEvent)
END_EVENT_TABLE()
CdromConfigDialog::CdromConfigDialog(
wxWindow* parent,
wxWindowID id)
: wxDialog (parent, id, "", wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
n_rbtns = 0;
// top level objects
wxStaticBox *dBox = new wxStaticBox (this, -1, "Device");
dBoxSizer = new wxStaticBoxSizer (dBox, wxVERTICAL);
wxStaticBox *mBox = new wxStaticBox (this, -1, "Media");
mBoxSizer = new wxStaticBoxSizer (mBox, wxVERTICAL);
buttonSizer = new wxBoxSizer (wxHORIZONTAL);
// add top level objects to vertSizer
vertSizer = new wxBoxSizer (wxVERTICAL);
vertSizer->Add (dBoxSizer, 0, wxALL|wxGROW, 10);
vertSizer->Add (mBoxSizer, 0, wxALL|wxGROW, 10);
vertSizer->Add (buttonSizer, 0, wxALIGN_RIGHT|wxTOP, 10);
// device box contents
enable = new wxCheckBox (this, ID_Enable, MSG_ENABLED);
enable->SetValue (TRUE);
dBoxSizer->Add (enable, 0, wxALL, 5);
// media box contents
//prompt = new wxStaticText (this, -1, CDROM_CONFIG_PROMPT);
//mBoxSizer->Add (prompt, 0, wxTOP|wxLEFT|wxGROW, 10);
AddRadio ("Ejected", "none"); // that's always an option!
// ... wait for more calls to AddRadio before Init()
// create fileSizer & contents, but don't add yet
fileSizer = new wxBoxSizer (wxHORIZONTAL);
diskImageRadioBtn = new wxRadioButton (this, -1, CDROM_CONFIG_DISKIMG);
fileSizer->Add (diskImageRadioBtn, 0);
filename = new wxTextCtrl (this, ID_FilenameText, "", wxDefaultPosition, longTextSize);
fileSizer->Add (filename, 1, wxLEFT, 5);
wxButton *btn = new wxButton (this, ID_Browse, BTNLABEL_BROWSE);
fileSizer->Add (btn, 0, wxALL, 5);
// create buttonSizer & contents but don't add yet
btn = new wxButton (this, wxID_HELP, BTNLABEL_HELP);
buttonSizer->Add (btn, 0, wxALL, 5);
// use wxID_CANCEL because pressing ESC produces this same code
btn = new wxButton (this, wxID_CANCEL, BTNLABEL_CANCEL);
buttonSizer->Add (btn, 0, wxALL, 5);
btn = new wxButton (this, wxID_OK, BTNLABEL_OK);
buttonSizer->Add (btn, 0, wxALL, 5);
}
void CdromConfigDialog::Init()
{
// add top level components to vertSizer
mBoxSizer->Add (fileSizer, 0, wxLEFT, 20);
// lay it out!
SetAutoLayout(TRUE);
SetSizer(vertSizer);
vertSizer->Fit (this);
wxSize size = vertSizer->GetMinSize ();
wxLogMessage ("minsize is %d,%d", size.GetWidth(), size.GetHeight ());
int margin = 5;
SetSizeHints (size.GetWidth () + margin, size.GetHeight () + margin);
Center ();
}
void CdromConfigDialog::SetDriveName (wxString name) {
wxString text;
text.Printf (CDROM_CONFIG_TITLE, name.c_str ());
SetTitle (text);
}
// called from outside the object
void CdromConfigDialog::EnableChanged ()
{
bool en = enable->GetValue ();
//prompt->Enable (en);
filename->Enable (en);
for (int i=0; i<n_rbtns; i++)
rbtn[i]->Enable (en);
diskImageRadioBtn->Enable (en);
}
void CdromConfigDialog::SetFilename (wxString f) {
for (int i=0; i<n_rbtns; i++) {
if (!strcmp (f.c_str (), equivalentFilename[i])) {
rbtn[i]->SetValue (TRUE);
return;
}
}
filename->SetValue (wxString (f));
}
wxString
CdromConfigDialog::GetFilename ()
{
if (enable->GetValue ()) {
// check radio buttons
for (int i=0; i<n_rbtns; i++) {
if (rbtn[i]->GetValue ())
return equivalentFilename[i];
}
// if it wasn't any of the other radio buttons, it certainly should
// be the last one. That's what radio buttons do!
wxASSERT (diskImageRadioBtn->GetValue ());
}
return filename->GetValue();
}
void
CdromConfigDialog::AddRadio (const wxString& description, const wxString& filename)
{
if (n_rbtns >= CDROM_MAX_RBTNS) {
wxLogError ("AddRadio failed: increase CDROM_MAX_RBTNS in wxdialog.h");
return;
}
rbtn[n_rbtns] = new wxRadioButton (this, -1, description);
equivalentFilename[n_rbtns] = filename;
mBoxSizer->Add (rbtn[n_rbtns], 0, wxLEFT, 20);
n_rbtns++;
}
void CdromConfigDialog::OnEvent(wxCommandEvent& event)
{
int id = event.GetId ();
wxLogMessage ("you pressed button id=%d", id);
switch (id) {
case ID_FilenameText:
// when you type into the filename field, ensure that the radio
// button associated with that field is chosen.
diskImageRadioBtn->SetValue (enable->GetValue ());
break;
case ID_Enable:
EnableChanged (); // enable/disable fields that depend on this
break;
case wxID_OK:
// probably should validate before allowing ok
EndModal (wxID_OK);
break;
case ID_Browse:
BrowseTextCtrl (filename);
break;
case wxID_CANCEL:
EndModal (wxID_CANCEL);
break;
case wxID_HELP:
ShowHelp();
break;
default:
event.Skip ();
}
}
void CdromConfigDialog::ShowHelp ()
{
wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR );
}
//////////////////////////////////////////////////////////////////////
// NetConfigDialog implementation
//////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////
// $Id: wxdialog.h,v 1.47 2003-01-04 11:47:00 vruppert Exp $
// $Id: wxdialog.h,v 1.48 2003-08-23 17:53:27 vruppert Exp $
////////////////////////////////////////////////////////////////////
//
// wxWindows dialogs for Bochs
@ -208,143 +208,6 @@ public:
DECLARE_EVENT_TABLE()
};
////////////////////////////////////////////////////////////////////
// HDConfigDialog is a modal dialog box that asks the user
// what physical device or disk image should be used for emulation.
//
// +-----Configure Hard Disk-------------------------------------------+
// | |
// | [ ] Enable |
// | |
// | Disk image: [______________________________] [Browse] |
// | Geometry: cylinders [____] heads [____] sectors/track [____] |
// | Size in Megabytes: 38.2 [Enter size/Compute Geometry] |
// | |
// | [ Help ] [ Cancel ] [ Create image ] [ Ok ] |
// +-------------------------------------------------------------------+
//
// To use this dialog:
// After constructor, use SetFilename(), SetGeomRange(), SetGeom() to fill in
// the fields. Note that SetGeomRange() should be called before SetGeom()
// or else the text field may not accept the SetGeom() value because of its
// default min/max setting. Call ShowModal to display. Return value is 0=ok
// or -1=cancel. Use GetFilename() and GetGeom() to retrieve values.
//////////////////////////////////////////////////////////////////////
class HDConfigDialog: public wxDialog
{
public:
#define HD_CONFIG_TITLE "Configure %s"
#define HD_CONFIG_DISKIMG "Disk image: "
private:
void Init (); // called automatically by ShowModal()
void ShowHelp ();
wxBoxSizer *vertSizer, *hsizer[3], *buttonSizer;
wxCheckBox *enable;
wxTextCtrl *filename;
wxSpinCtrl *geom[3];
wxStaticText *megs;
wxButton *computeGeom;
enum geomfields_t { CYL, HEADS, SPT };
#define HD_CONFIG_GEOM_NAMES \
{ "Geometry: cylinders", " heads ", " sectors/track " }
#define HD_CONFIG_MEGS "Size in Megabytes: %.1f"
#define HD_CONFIG_COMPUTE_TEXT "<-- Enter Size/Compute Geometry"
#define HD_CONFIG_COMPUTE_INSTR "Enter size of the hard disk image in megabytes. Between 1 and 32255 please!"
#define HD_CONFIG_COMPUTE_PROMPT "Size in megs: "
#define HD_CONFIG_COMPUTE_CAPTION "Choose Disk Size"
public:
HDConfigDialog(wxWindow* parent, wxWindowID id);
void OnEvent (wxCommandEvent& event);
int ShowModal() { Init(); return wxDialog::ShowModal(); }
void SetFilename (wxString f) { filename->SetValue (f); }
wxString GetFilename () { return filename->GetValue(); }
void SetDriveName (wxString n);
void SetGeom (int n, int value);
int GetGeom (int n) { return geom[n]->GetValue (); }
void SetGeomRange (int n, int min, int max);
float UpdateMegs ();
void EnableChanged ();
void SetEnable (bool val) { enable->SetValue (val); EnableChanged (); }
bool GetEnable () { return enable->GetValue (); }
void EnterSize ();
DECLARE_EVENT_TABLE()
};
////////////////////////////////////////////////////////////////////
// CdromConfigDialog is a modal dialog box that asks the user
// what physical device or disk image should be used for cdrom
// emulation.
//
// +-----Configure CDROM-------------------------------------------+
// | |
// | +-- Device -----------------------------------------------+ |
// | | | |
// | | [ ] Enable Emulated CD-ROM | |
// | | | |
// | +---------------------------------------------------------+ |
// | |
// | +-- Media: Where does the data come from? ----------------+ |
// | | | |
// | | Bochs can use a physical CD-ROM drive as the data | |
// | | source, or use an image file. | |
// | | | |
// | | [X] Ejected | |
// | | [ ] Physical CD-ROM drive /dev/cdrom | |
// | | [ ] Disk image: [_________________________] [Browse] | |
// | | | |
// | +---------------------------------------------------------+ |
// | |
// | [ Help ] [ Cancel ] [ Ok ] |
// +---------------------------------------------------------------+
//
// To use this dialog:
// After constructor, use SetEnabled(), SetFilename() to fill in the
// disk image filename, AddRadio() to add radio buttons (the disk
// image file radio button will be added automatically). Then call
// ShowModal() to display it. Return value is wxID_OK or wxID_CANCEL.
// After ShowModal() returns, use GetFilename() and
// GetEnabled().
class CdromConfigDialog: public wxDialog
{
public:
#define CDROM_CONFIG_TITLE "Configure %s"
#define CDROM_CONFIG_DISKIMG "Use disk image: "
// prompt disabled because I can't figure out what text would make
// the most sense here. If one of the answers is "Ejected" then what
// is the question?
//#define CDROM_CONFIG_PROMPT "Where should the emulated CD-ROM find its data?"
private:
void Init (); // called automatically by ShowModal()
void ShowHelp ();
wxBoxSizer *vertSizer, *fileSizer, *buttonSizer;
wxStaticBoxSizer *dBoxSizer, *mBoxSizer;
//wxStaticText *prompt;
wxCheckBox *enable;
wxTextCtrl *filename;
wxRadioButton *diskImageRadioBtn;
#define CDROM_MAX_RBTNS 2
wxRadioButton *rbtn[CDROM_MAX_RBTNS];
wxString equivalentFilename[CDROM_MAX_RBTNS];
int n_rbtns;
public:
CdromConfigDialog(wxWindow* parent, wxWindowID id);
void OnEvent (wxCommandEvent& event);
int ShowModal() { Init(); return wxDialog::ShowModal(); }
void SetFilename (wxString f);
wxString GetFilename ();
void SetDriveName (wxString f);
void EnableChanged ();
void SetEnable (bool val) { enable->SetValue (val); EnableChanged (); }
bool GetEnable () { return enable->GetValue (); }
void AddRadio (const wxString& descr, const wxString& path);
// rbtn[0] will always be the "ejected" button
void SetEjected (bool val) { if (val) rbtn[0]->SetValue (TRUE); }
bool GetEjected () { return rbtn[0]->GetValue (); }
DECLARE_EVENT_TABLE()
};
////////////////////////////////////////////////////////////////////////////
// ConfigNetworkDialog allows the user to change the settings for
// the emulated NE2000 network card.

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxmain.h,v 1.41 2003-08-22 16:52:38 cbothamy Exp $
// $Id: wxmain.h,v 1.42 2003-08-23 17:53:27 vruppert Exp $
/////////////////////////////////////////////////////////////////
// This file defines variables and classes that the wxWindows .cc files
// share. It should be included only by wx.cc and wxmain.cc.
@ -86,13 +86,8 @@ enum
ID_Browse,
ID_Browse2,
ID_Create,
// dialog box: HDConfigDialog
// dialog box: NetConfigDialog
ID_Enable,
ID_Cylinders,
ID_Heads,
ID_SPT,
ID_Megs,
ID_ComputeGeometry,
// dialog box: LogOptions
ID_Advanced,
// dialog box: CpuRegistersDialog