- bugfixes so messageboxes show in windows and linux
This commit is contained in:
parent
4b4136d922
commit
a842909e7d
|
@ -52,7 +52,9 @@ MainWindow::MainWindow()
|
||||||
, resource(0)
|
, resource(0)
|
||||||
, startLocation(1)
|
, startLocation(1)
|
||||||
, enabledGroup(ctHeight)
|
, enabledGroup(ctHeight)
|
||||||
, fileModified(false) {
|
, fileModified(false)
|
||||||
|
, menuBar(NULL)
|
||||||
|
, panel(NULL) {
|
||||||
|
|
||||||
this->panel = new wxPanel(this, wxID_ANY);
|
this->panel = new wxPanel(this, wxID_ANY);
|
||||||
|
|
||||||
|
@ -315,10 +317,18 @@ void MainWindow::init(string fname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onClose(wxCloseEvent &event) {
|
void MainWindow::onClose(wxCloseEvent &event) {
|
||||||
|
if(timer != NULL) timer->Stop();
|
||||||
|
if(timer != NULL) delete timer;
|
||||||
|
timer = NULL;
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
|
if(timer != NULL) timer->Stop();
|
||||||
|
if(timer != NULL) delete timer;
|
||||||
|
timer = NULL;
|
||||||
|
|
||||||
delete program;
|
delete program;
|
||||||
delete glCanvas;
|
delete glCanvas;
|
||||||
}
|
}
|
||||||
|
@ -407,6 +417,9 @@ void MainWindow::onMouseMove(wxMouseEvent &event, int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onPaint(wxPaintEvent &event) {
|
void MainWindow::onPaint(wxPaintEvent &event) {
|
||||||
|
if(panel) panel->Update();
|
||||||
|
if(menuBar) menuBar->Update();
|
||||||
|
|
||||||
program->renderMap(glCanvas->GetClientSize().x, glCanvas->GetClientSize().y);
|
program->renderMap(glCanvas->GetClientSize().x, glCanvas->GetClientSize().y);
|
||||||
glCanvas->SwapBuffers();
|
glCanvas->SwapBuffers();
|
||||||
}
|
}
|
||||||
|
@ -485,8 +498,9 @@ void MainWindow::onMenuEditReset(wxCommandEvent &event) {
|
||||||
strToInt(simpleDialog.getValue("Height")),
|
strToInt(simpleDialog.getValue("Height")),
|
||||||
strToInt(simpleDialog.getValue("Altitude")),
|
strToInt(simpleDialog.getValue("Altitude")),
|
||||||
strToInt(simpleDialog.getValue("Surface")));
|
strToInt(simpleDialog.getValue("Surface")));
|
||||||
} catch (const exception &e) {
|
}
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
catch (const exception &e) {
|
||||||
|
MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
currentFile = "";
|
currentFile = "";
|
||||||
fileName = "New (unsaved) map";
|
fileName = "New (unsaved) map";
|
||||||
|
@ -499,8 +513,9 @@ void MainWindow::onMenuEditResetPlayers(wxCommandEvent &event) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
program->resetFactions(strToInt(simpleDialog.getValue("Factions")));
|
program->resetFactions(strToInt(simpleDialog.getValue("Factions")));
|
||||||
} catch (const exception &e) {
|
}
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
catch (const exception &e) {
|
||||||
|
MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
setDirty();
|
setDirty();
|
||||||
setExtension();
|
setExtension();
|
||||||
|
@ -520,8 +535,9 @@ void MainWindow::onMenuEditResize(wxCommandEvent &event) {
|
||||||
strToInt(simpleDialog.getValue("Width")),
|
strToInt(simpleDialog.getValue("Width")),
|
||||||
strToInt(simpleDialog.getValue("Altitude")),
|
strToInt(simpleDialog.getValue("Altitude")),
|
||||||
strToInt(simpleDialog.getValue("Surface")));
|
strToInt(simpleDialog.getValue("Surface")));
|
||||||
} catch (const exception &e) {
|
}
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
catch (const exception &e) {
|
||||||
|
MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
|
@ -556,8 +572,9 @@ void MainWindow::onMenuEditSwitchSurfaces(wxCommandEvent &event) {
|
||||||
program->switchMapSurfaces(
|
program->switchMapSurfaces(
|
||||||
strToInt(simpleDialog.getValue("Surface1")),
|
strToInt(simpleDialog.getValue("Surface1")),
|
||||||
strToInt(simpleDialog.getValue("Surface2")));
|
strToInt(simpleDialog.getValue("Surface2")));
|
||||||
} catch (const exception &e) {
|
}
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
catch (const exception &e) {
|
||||||
|
MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
|
@ -590,8 +607,9 @@ void MainWindow::onMenuEditAdvanced(wxCommandEvent &event) {
|
||||||
program->setMapAdvanced(
|
program->setMapAdvanced(
|
||||||
strToInt(simpleDialog.getValue("Height Factor")),
|
strToInt(simpleDialog.getValue("Height Factor")),
|
||||||
strToInt(simpleDialog.getValue("Water Level")));
|
strToInt(simpleDialog.getValue("Water Level")));
|
||||||
} catch (const exception &e) {
|
}
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
catch (const exception &e) {
|
||||||
|
MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
|
@ -601,15 +619,15 @@ void MainWindow::onMenuMiscResetZoomAndPos(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuMiscAbout(wxCommandEvent &event) {
|
void MainWindow::onMenuMiscAbout(wxCommandEvent &event) {
|
||||||
wxMessageDialog(
|
MsgDialog(
|
||||||
NULL,
|
this,
|
||||||
wxT("Glest Map Editor - Copyright 2004 The Glest Team\n(with improvements by others, 2010)."),
|
wxT("Glest Map Editor - Copyright 2004 The Glest Team\n(with improvements by others, 2010)."),
|
||||||
wxT("About")).ShowModal();
|
wxT("About")).ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuMiscHelp(wxCommandEvent &event) {
|
void MainWindow::onMenuMiscHelp(wxCommandEvent &event) {
|
||||||
wxMessageDialog(
|
MsgDialog(
|
||||||
NULL,
|
this,
|
||||||
wxT("Left mouse click: draw\nRight mouse drag: move\nCenter mouse drag: zoom"),
|
wxT("Left mouse click: draw\nRight mouse drag: move\nCenter mouse drag: zoom"),
|
||||||
wxT("Help")).ShowModal();
|
wxT("Help")).ShowModal();
|
||||||
}
|
}
|
||||||
|
@ -961,6 +979,7 @@ void SimpleDialog::show() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ===============================================
|
// ===============================================
|
||||||
// class App
|
// class App
|
||||||
// ===============================================
|
// ===============================================
|
||||||
|
@ -988,9 +1007,11 @@ bool App::OnInit() {
|
||||||
|
|
||||||
int App::MainLoop() {
|
int App::MainLoop() {
|
||||||
try {
|
try {
|
||||||
|
//throw runtime_error("test");
|
||||||
return wxApp::MainLoop();
|
return wxApp::MainLoop();
|
||||||
} catch (const exception &e) {
|
}
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
catch (const exception &e) {
|
||||||
|
MsgDialog(NULL, ToUnicode(e.what()), wxT("Exception")).ShowModal();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -999,6 +1020,47 @@ int App::OnExit() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MsgDialog::MsgDialog(wxWindow *parent,
|
||||||
|
const wxString& message,
|
||||||
|
const wxString& caption,
|
||||||
|
long style,
|
||||||
|
const wxPoint& pos) {
|
||||||
|
|
||||||
|
m_sizerText = NULL;
|
||||||
|
// TODO: should we use main frame as parent by default here?
|
||||||
|
if ( !wxDialog::Create(parent, wxID_ANY, caption,
|
||||||
|
pos, wxDefaultSize,
|
||||||
|
style) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_sizerText = new wxBoxSizer(wxVERTICAL);
|
||||||
|
wxStaticText *label = new wxStaticText(this, wxID_ANY, message);
|
||||||
|
wxFont font(*wxNORMAL_FONT);
|
||||||
|
font.SetPointSize(font.GetPointSize());
|
||||||
|
font.SetWeight(wxFONTWEIGHT_NORMAL);
|
||||||
|
label->SetFont(font);
|
||||||
|
|
||||||
|
m_sizerText->Add(label, wxSizerFlags().Centre().Border());
|
||||||
|
|
||||||
|
wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
sizerIconAndText->Add(m_sizerText, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
|
||||||
|
sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border());
|
||||||
|
|
||||||
|
wxSizer *sizerBtns = CreateButtonSizer(wxOK);
|
||||||
|
if ( sizerBtns )
|
||||||
|
{
|
||||||
|
sizerTop->Add(sizerBtns, wxSizerFlags().Expand().Border());
|
||||||
|
}
|
||||||
|
|
||||||
|
SetSizerAndFit(sizerTop);
|
||||||
|
CentreOnScreen();
|
||||||
|
}
|
||||||
|
MsgDialog::~MsgDialog() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}// end namespace
|
}// end namespace
|
||||||
|
|
||||||
IMPLEMENT_APP(MapEditor::App)
|
IMPLEMENT_APP(MapEditor::App)
|
||||||
|
|
|
@ -262,6 +262,25 @@ public:
|
||||||
void show();
|
void show();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class SimpleDialog
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
class MsgDialog: public wxDialog {
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
wxSizer *m_sizerText;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MsgDialog(wxWindow *parent,
|
||||||
|
const wxString& message,
|
||||||
|
const wxString& caption,
|
||||||
|
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCENTRE,
|
||||||
|
const wxPoint& pos = wxDefaultPosition);
|
||||||
|
virtual ~MsgDialog();
|
||||||
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class App
|
// class App
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
Loading…
Reference in New Issue
Block a user