Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move DialogBase method bodies into a separate .cpp file
- Loading branch information
Matthew Mott
committed
Feb 25, 2020
1 parent
ce08c7f
commit a6c3540
Showing
3 changed files
with
67 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "DialogBase.h" | ||
|
||
namespace wxutil | ||
{ | ||
|
||
void DialogBase::_onDelete(wxCloseEvent& ev) | ||
{ | ||
if (_onDeleteEvent()) | ||
{ | ||
ev.Veto(); | ||
} | ||
else | ||
{ | ||
EndModal(wxID_CANCEL); | ||
} | ||
} | ||
|
||
DialogBase::DialogBase(const std::string& title, wxWindow* parent) | ||
: wxDialog(parent ? parent : GlobalMainFrame().getWxTopLevelWindow(), | ||
wxID_ANY, title, wxDefaultPosition, wxDefaultSize, | ||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) | ||
{ | ||
Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(DialogBase::_onDelete), | ||
nullptr, this); | ||
} | ||
|
||
void DialogBase::FitToScreen(float xProp, float yProp) | ||
{ | ||
int curDisplayIdx = 0; | ||
|
||
if (GlobalMainFrame().getWxTopLevelWindow() != NULL) | ||
{ | ||
curDisplayIdx = wxDisplay::GetFromWindow(GlobalMainFrame().getWxTopLevelWindow()); | ||
} | ||
|
||
wxDisplay curDisplay(curDisplayIdx); | ||
|
||
wxRect rect = curDisplay.GetGeometry(); | ||
int newWidth = static_cast<int>(rect.GetWidth() * xProp); | ||
int newHeight = static_cast<int>(rect.GetHeight() * yProp); | ||
|
||
SetSize(newWidth, newHeight); | ||
CenterOnScreen(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters