Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion GM/FrmMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ static const wxClassInfo *tblBrd[] = {
CMainFrame::CMainFrame() :
wxDocParentFrameAny<wxAuiMDIParentFrame>(wxDocManager::GetDocumentManager(),
nullptr, wxID_ANY,
wxTheApp->GetAppDisplayName())
wxTheApp->GetAppDisplayName()),
CB::FreezeUntilIdleMixin(static_cast<wxWindow&>(*this))
{
auiManager.SetManagedWindow(this);
SetIcon(wxIcon(std::format("#{}", IDR_MAINFRAME)));
Expand Down Expand Up @@ -653,6 +654,8 @@ void CMainFrame::OnIdle()
auiMgrScheduleUpdate = false;
auiManager.Update();
}

CB::FreezeUntilIdleMixin::OnIdle();
}

namespace {
Expand Down
3 changes: 2 additions & 1 deletion GM/FrmMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
#include "frmdocktile.h"
#endif

class CMainFrame : public wxDocParentFrameAny<CB::wxAuiMDIParentFrame>
class CMainFrame : public wxDocParentFrameAny<CB::wxAuiMDIParentFrame>,
public CB::FreezeUntilIdleMixin
{
public:
CMainFrame();
Expand Down
20 changes: 20 additions & 0 deletions GShr/CyberBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,9 @@ namespace CB
public:
virtual wxWindow& GetWindow() = 0;

void OnActivateView(bool activate,
::wxView *activeView,
::wxView *deactiveView) override;
void OnDraw(wxDC* dc) override;

protected:
Expand Down Expand Up @@ -2070,6 +2073,23 @@ namespace CB
{
wxWindow* pGetMainWndWx();
inline wxWindow& GetMainWndWx() { return CheckedDeref(pGetMainWndWx()); }

/* call wxWindow::Freeze() to block repaint until after idle
processing shows/hides palettes */
class FreezeUntilIdleMixin
{
public:
FreezeUntilIdleMixin(wxWindow& inw);
// avoid compiler preferring copy ctor to above ctor
FreezeUntilIdleMixin(const FreezeUntilIdleMixin&) = delete;
void FreezeUntilIdle();
protected:
void OnIdle();
private:
wxWindow& w;
bool scheduleThaw = false;
};

string GetAppName();
}

Expand Down
39 changes: 39 additions & 0 deletions GShr/LibMfc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,22 @@ const std::type_info& CB::GetPublicTypeid(const wxWindow& w)
return mfcWnd ? typeid(*mfcWnd) : typeid(w);
}

void CB::wxView::OnActivateView(bool activate,
::wxView *activeView,
::wxView *deactiveView)
{
if (activate)
{
wxWindow& mainWnd = GetMainWndWx();
CB::FreezeUntilIdleMixin* freezer = dynamic_cast<CB::FreezeUntilIdleMixin*>(&mainWnd);
if (freezer)
{
freezer->FreezeUntilIdle();
}
}
::wxView::OnActivateView(activate, activeView, deactiveView);
}

void CB::wxView::OnDraw(wxDC * dc)
{
CPP20_TRACE("{}({})\n", __func__, *this);
Expand Down Expand Up @@ -1012,6 +1028,29 @@ void CB::wxView::FileHistoryRemoveMenu()
docMgr.FileHistoryRemoveMenu(&menuFile);
}

CB::FreezeUntilIdleMixin::FreezeUntilIdleMixin(wxWindow& inw) :
w(inw)
{
}

void CB::FreezeUntilIdleMixin::FreezeUntilIdle()
{
if (!scheduleThaw)
{
w.Freeze();
scheduleThaw = true;
}
}

void CB::FreezeUntilIdleMixin::OnIdle()
{
if (scheduleThaw)
{
w.Thaw();
scheduleThaw = false;
}
}

CB::ToolTip::~ToolTip()
{
Enable(false);
Expand Down
Loading