Added modeless message box support for the wxWidgets port.
This commit is contained in:
parent
5bb77620c3
commit
75d076b990
@ -2,7 +2,7 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002-2021 The Bochs Project
|
// Copyright (C) 2002-2023 The Bochs Project
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
@ -1492,6 +1492,71 @@ int LogOptionsDialog::GetAction(int evtype)
|
|||||||
return *ptrToChoice;
|
return *ptrToChoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// ModelessDialog implementation
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// all events go to OnEvent method
|
||||||
|
BEGIN_EVENT_TABLE(ModelessDialog, wxDialog)
|
||||||
|
EVT_BUTTON(-1, ModelessDialog::OnEvent)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
ModelessDialog::ModelessDialog(
|
||||||
|
wxWindow* parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& title,
|
||||||
|
const wxString& msg)
|
||||||
|
: wxDialog(parent, id, title, wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxDEFAULT_DIALOG_STYLE)
|
||||||
|
{
|
||||||
|
mainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
msgSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
buttonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
mainSizer->Add(msgSizer, 0, wxALIGN_CENTER);
|
||||||
|
mainSizer->Add(buttonSizer, 0, wxALIGN_CENTER);
|
||||||
|
// msgSizer contents
|
||||||
|
message = new wxStaticText(this, -1, msg);
|
||||||
|
wxFont font = message->GetFont();
|
||||||
|
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||||
|
font.SetPointSize(2 + font.GetPointSize());
|
||||||
|
message->SetFont(font);
|
||||||
|
msgSizer->Add(message, 0, wxGROW|wxALIGN_LEFT|wxLEFT, 30);
|
||||||
|
// buttonSizer contents
|
||||||
|
wxButton *btn = new wxButton(this, wxID_OK, BTNLABEL_CLOSE);
|
||||||
|
buttonSizer->Add(btn, 0, wxALL, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelessDialog::Init()
|
||||||
|
{
|
||||||
|
SetSizer(mainSizer);
|
||||||
|
mainSizer->Fit(this);
|
||||||
|
wxSize size = mainSizer->GetMinSize();
|
||||||
|
int margin = 5;
|
||||||
|
SetSizeHints(size.GetWidth() + margin, size.GetHeight() + margin);
|
||||||
|
Center();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModelessDialog::Show(bool val)
|
||||||
|
{
|
||||||
|
if (val) {
|
||||||
|
Init();
|
||||||
|
wxDialog::Raise();
|
||||||
|
}
|
||||||
|
return wxDialog::Show(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelessDialog::OnEvent(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
int id = event.GetId();
|
||||||
|
switch (id) {
|
||||||
|
case wxID_OK:
|
||||||
|
Show(false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// utility
|
// utility
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2002-2021 The Bochs Project
|
// Copyright (C) 2002-2023 The Bochs Project
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
@ -369,6 +369,25 @@ public:
|
|||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// ModelessDialog
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
class ModelessDialog: public wxDialog
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxBoxSizer *mainSizer, *msgSizer, *buttonSizer;
|
||||||
|
wxStaticText *message;
|
||||||
|
public:
|
||||||
|
ModelessDialog(wxWindow* parent, wxWindowID id,
|
||||||
|
const wxString& title,
|
||||||
|
const wxString& msg);
|
||||||
|
~ModelessDialog() {}
|
||||||
|
void Init();
|
||||||
|
bool Show(bool val);
|
||||||
|
void OnEvent(wxCommandEvent& event);
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Everything else in here is a comment!
|
Everything else in here is a comment!
|
||||||
|
@ -1085,6 +1085,7 @@ void MyFrame::OnSim2CIEvent(wxCommandEvent& event)
|
|||||||
{
|
{
|
||||||
IFDBG_EVENT(wxLogDebug(wxT("received a bochs event in the GUI thread")));
|
IFDBG_EVENT(wxLogDebug(wxT("received a bochs event in the GUI thread")));
|
||||||
BxEvent *be = (BxEvent *) event.GetEventObject();
|
BxEvent *be = (BxEvent *) event.GetEventObject();
|
||||||
|
ModelessDialog *ModelessMsgBox;
|
||||||
IFDBG_EVENT(wxLogDebug(wxT("event type = %d"), (int)be->type));
|
IFDBG_EVENT(wxLogDebug(wxT("event type = %d"), (int)be->type));
|
||||||
// all cases should return. sync event handlers MUST send back a
|
// all cases should return. sync event handlers MUST send back a
|
||||||
// response. async event handlers MUST delete the event.
|
// response. async event handlers MUST delete the event.
|
||||||
@ -1111,10 +1112,16 @@ void MyFrame::OnSim2CIEvent(wxCommandEvent& event)
|
|||||||
sim_thread->SendSyncResponse(be);
|
sim_thread->SendSyncResponse(be);
|
||||||
break;
|
break;
|
||||||
case BX_SYNC_EVT_ML_MSG_BOX:
|
case BX_SYNC_EVT_ML_MSG_BOX:
|
||||||
// TODO
|
ModelessMsgBox = new ModelessDialog(this, -1,
|
||||||
|
wxString(be->u.logmsg.prefix, wxConvUTF8),
|
||||||
|
wxString(be->u.logmsg.msg, wxConvUTF8));
|
||||||
|
ModelessMsgBox->Show(true);
|
||||||
|
be->param0 = (void*)ModelessMsgBox;
|
||||||
|
sim_thread->SendSyncResponse(be);
|
||||||
break;
|
break;
|
||||||
case BX_SYNC_EVT_ML_MSG_BOX_KILL:
|
case BX_SYNC_EVT_ML_MSG_BOX_KILL:
|
||||||
// TODO
|
delete (ModelessDialog*)be->param0;
|
||||||
|
sim_thread->SendSyncResponse(be);
|
||||||
break;
|
break;
|
||||||
case BX_ASYNC_EVT_QUIT_SIM:
|
case BX_ASYNC_EVT_QUIT_SIM:
|
||||||
wxMessageBox(wxT("Bochs simulation has stopped."), wxT("Bochs Stopped"),
|
wxMessageBox(wxT("Bochs simulation has stopped."), wxT("Bochs Stopped"),
|
||||||
|
Loading…
Reference in New Issue
Block a user