From bcee944b898e25d0124c020b2c371728e1a1fce8 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Thu, 7 Aug 2025 12:36:02 -0400 Subject: [PATCH 01/11] fixup! more wx/MFC conversion helpers --- GShr/CyberBoard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GShr/CyberBoard.h b/GShr/CyberBoard.h index 5bbf03d..dd99e21 100644 --- a/GShr/CyberBoard.h +++ b/GShr/CyberBoard.h @@ -346,7 +346,7 @@ struct std::formatter : private std::formatter FormatContext::iterator format(const wxRect& r, FormatContext& ctx) const { - std::format_to(ctx.out(), "[("); + std::format_to(ctx.out(), "(("); BASE::format(r.GetLeft(), ctx); std::format_to(ctx.out(), ","); BASE::format(r.GetTop(), ctx); From 41b1b4a659d21c0fc6360d361d3c005311b406d2 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sun, 3 Aug 2025 19:15:45 -0400 Subject: [PATCH 02/11] Revert "CyberBoard.h: disable not-currently-used MFC adapters" This reverts commit 3b416859c149c2d3f5a66609b2d308487b45bf8c. --- GShr/CyberBoard.h | 6 ------ GShr/LibMfc.cpp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/GShr/CyberBoard.h b/GShr/CyberBoard.h index dd99e21..83bcf53 100644 --- a/GShr/CyberBoard.h +++ b/GShr/CyberBoard.h @@ -1969,19 +1969,16 @@ namespace CB // emulate CWnd::SendMessageToDescendants() void SendEventToDescendants(wxWindow& wnd, wxEvent& event, bool deep = true); -#if 0 const CWnd* ToCWnd(const wxWindow& w); inline CWnd* ToCWnd(wxWindow& w) { return const_cast(ToCWnd(std::as_const(w))); } // MFC if possible, wx otherwise const std::type_info& GetPublicTypeid(const wxWindow& w); -#endif } // helpers for providing wx/docview namespace CB { -#if 0 // satisfy wxDocChildFrameAny<> requirements template class PseudoFrame : public BASE @@ -2029,7 +2026,6 @@ namespace CB private: RefPtr window; }; -#endif /* wxView must be separate from wxWindow (see https://groups.google.com/g/wx-dev/c/xMK4zYT3FFQ/m/kR9JmczbBAAJ) */ @@ -2333,7 +2329,6 @@ namespace CB void InflateAndNormalize(wxRect& rect, int dx, int dy); } -#if 0 // use these to translate and relay MFC messages to a wx target namespace CB { @@ -2415,7 +2410,6 @@ namespace CB } }; } -#endif namespace CB { diff --git a/GShr/LibMfc.cpp b/GShr/LibMfc.cpp index 5686afc..c102ec6 100644 --- a/GShr/LibMfc.cpp +++ b/GShr/LibMfc.cpp @@ -882,7 +882,6 @@ void CB::SendEventToDescendants(wxWindow& wnd, wxEvent& event, bool deep /*= tru } } -#if 0 const CWnd* CB::ToCWnd(const wxWindow& w) { const wxNativeContainerWindow* ncw = dynamic_cast(&w); @@ -902,7 +901,6 @@ const std::type_info& CB::GetPublicTypeid(const wxWindow& w) const CWnd* mfcWnd = ToCWnd(w); return mfcWnd ? typeid(*mfcWnd) : typeid(w); } -#endif void CB::wxView::OnDraw(wxDC * dc) { @@ -1291,7 +1289,6 @@ void CB::InflateAndNormalize(wxRect& rect, int dx, int dy) rect.Inflate(dx, dy); } -#if 0 namespace CB { int ToWxID(int id) @@ -1511,7 +1508,6 @@ BOOL CB::RelayOnCmdMsg(wxEvtHandler& dest, return false; } } -#endif namespace CB { @@ -1541,7 +1537,6 @@ namespace CB } } -#if 0 bool CB::RelayProcessEvent(CCmdTarget& dest, wxEvent& event) { @@ -1605,7 +1600,6 @@ bool CB::RelayProcessEvent(CCmdTarget& dest, return false; } -#endif int CB::GetMouseButtons(const wxMouseState& event) { From 6362c67058569f853f70362af91e41c50c2965a7 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Fri, 1 Aug 2025 22:00:22 -0400 Subject: [PATCH 03/11] DlgState: convert MFC to wx --- GP/CBPlay.fbp | 459 ++++++++++++++++++++++++++++++++++++++++++++++++ GP/CBPlay.xrc | 84 +++++++++ GP/DlgState.cpp | 45 +++-- GP/DlgState.h | 22 +-- GP/GamDoc4.cpp | 2 +- 5 files changed, 582 insertions(+), 30 deletions(-) diff --git a/GP/CBPlay.fbp b/GP/CBPlay.fbp index 28f2522..af132ea 100644 --- a/GP/CBPlay.fbp +++ b/GP/CBPlay.fbp @@ -11291,6 +11291,465 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + CSelectStateDialog + + + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + Select Game State + + 0 + + + + + + bSizer67 + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + bSizer68 + wxHORIZONTAL + none + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + The move file's game state (positions, etc..) doesn't match the current game's state. Choose one of the following corrective measures: + 0 + + 0 + + + 0 + + 1 + m_staticDesc + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + + 0 + + + bSizer69 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 1 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + OK + + 0 + + 0 + + + 0 + + 1 + wxID_OK + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Cancel + + 0 + + 0 + + + 0 + + 1 + wxID_CANCEL + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Use the state information in the move file as the starting point. + + 0 + + + 0 + + 1 + m_radioMove + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Use the current game state as the starting point. + + 0 + + + 0 + + 1 + m_radioBtn2 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Choose Cancel if you don't know what's going on. + 0 + + 0 + + + 0 + + 1 + m_staticText49 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 0 wxAUI_MGR_DEFAULT diff --git a/GP/CBPlay.xrc b/GP/CBPlay.xrc index 0664ab8..517e226 100644 --- a/GP/CBPlay.xrc +++ b/GP/CBPlay.xrc @@ -2163,6 +2163,90 @@ + + + Select Game State + 1 + + wxVERTICAL + + wxEXPAND + 5 + + + wxHORIZONTAL + + wxALL + 5 + + + + -1 + + + + + 5 + + + wxVERTICAL + + wxALL + 5 + + + + 1 + 0 + 0 + + + + + wxALL + 5 + + + + 0 + 0 + 0 + + + + + + + + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + 0 + + + + wxALL + 5 + + + + 0 + + + + wxALL + 5 + + + + -1 + + + + Send Message diff --git a/GP/DlgState.cpp b/GP/DlgState.cpp index 541cf4a..c4e270f 100644 --- a/GP/DlgState.cpp +++ b/GP/DlgState.cpp @@ -1,6 +1,6 @@ // DlgState.cpp : implementation file // -// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved. +// Copyright (c) 1994-2025 By Dale L. Larson & William Su, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -34,30 +34,38 @@ static char THIS_FILE[] = __FILE__; ///////////////////////////////////////////////////////////////////////////// // CSelectStateDialog dialog -CSelectStateDialog::CSelectStateDialog(CWnd* pParent /*=NULL*/) - : CDialog(CSelectStateDialog::IDD, pParent) +CSelectStateDialog::CSelectStateDialog(wxWindow* pParent /*= &CB::GetMainWndWx()*/) : + CB_XRC_BEGIN_CTRLS_DEFN(pParent, CSelectStateDialog) + CB_XRC_CTRL_VAL(m_radioMove, m_nState) + CB_XRC_END_CTRLS_DEFN() { - //{{AFX_DATA_INIT(CSelectStateDialog) - m_nState = -1; - //}}AFX_DATA_INIT -} + // match the desc + OK button width to rest of dlg's width + wxStaticText& desc = CheckedDeref(XRCCTRL(*this, "m_staticDesc", wxStaticText)); + desc.Hide(); + // find size w/o desc + wxSize dlgMinSize = GetSizer()->GetMinSize(); + wxButton& ok = CheckedDeref(XRCCTRL(*this, "wxID_OK", wxButton)); + wxSizer& okSizer = CheckedDeref(ok.GetContainingSizer()); + desc.Show(); + desc.InvalidateBestSize(); + desc.Wrap(dlgMinSize.x - okSizer.GetMinSize().x); -void CSelectStateDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSelectStateDialog) - DDX_Radio(pDX, IDC_D_STATE_MOVEFILE, m_nState); - //}}AFX_DATA_MAP + SetMinSize(wxDefaultSize); + Layout(); + Fit(); + Centre(); + + m_nState = -1; } -BEGIN_MESSAGE_MAP(CSelectStateDialog, CDialog) - //{{AFX_MSG_MAP(CSelectStateDialog) - // NOTE: the ClassWizard will add message map macros here +wxBEGIN_EVENT_TABLE(CSelectStateDialog, wxDialog) +#if 0 ON_WM_HELPINFO() ON_WM_CONTEXTMENU() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() +#endif +wxEND_EVENT_TABLE() +#if 0 ///////////////////////////////////////////////////////////////////////////// // Html Help control ID Map @@ -77,4 +85,5 @@ void CSelectStateDialog::OnContextMenu(CWnd* pWnd, CPoint point) { GetApp()->DoHelpWhatIsHelp(pWnd, adwHelpMap); } +#endif diff --git a/GP/DlgState.h b/GP/DlgState.h index b93b554..b8a7915 100644 --- a/GP/DlgState.h +++ b/GP/DlgState.h @@ -1,6 +1,6 @@ // DlgState.h : header file // -// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved. +// Copyright (c) 1994-2025 By Dale L. Larson & William Su, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -25,27 +25,27 @@ ///////////////////////////////////////////////////////////////////////////// // CSelectStateDialog dialog -class CSelectStateDialog : public CDialog +class CSelectStateDialog : public wxDialog { // Construction public: - CSelectStateDialog(CWnd* pParent = NULL); // standard constructor + CSelectStateDialog(wxWindow* parent = &CB::GetMainWndWx()); // standard constructor // Dialog Data - //{{AFX_DATA(CSelectStateDialog) - enum { IDD = IDD_CHOOSESTATE }; int m_nState; - //}}AFX_DATA +private: + CB_XRC_BEGIN_CTRLS_DECL() + RefPtr m_radioMove; + CB_XRC_END_CTRLS_DECL() +public: // Implementation protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Generated message map functions - //{{AFX_MSG(CSelectStateDialog) - // NOTE: the ClassWizard will add member functions here +#if 0 afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() +#endif + wxDECLARE_EVENT_TABLE(); }; diff --git a/GP/GamDoc4.cpp b/GP/GamDoc4.cpp index 157363c..cb8a0a1 100644 --- a/GP/GamDoc4.cpp +++ b/GP/GamDoc4.cpp @@ -128,7 +128,7 @@ void CGamDoc::LoadAndActivateMoveFile(const CB::string& pszPathName) // File's positions don't match current games' positions. CSelectStateDialog dlg; dlg.m_nState = 0; // Select first button (file state) - if (dlg.DoModal() != IDOK) + if (dlg.ShowModal() != wxID_OK) AfxThrowUserException(); if (dlg.m_nState == 0) { From e3ae28d9d423a687d470f787c795625b9fe749c7 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sat, 2 Aug 2025 00:15:13 -0400 Subject: [PATCH 04/11] DlgTrunc: replace MFC with wx --- GP/CBPlay.fbp | 397 ++++++++++++++++++++++++++++++++++++++++++++++++ GP/CBPlay.xrc | 75 +++++++++ GP/DlgTrunc.cpp | 44 +++--- GP/DlgTrunc.h | 26 ++-- GP/GamDoc2.cpp | 2 +- 5 files changed, 509 insertions(+), 35 deletions(-) diff --git a/GP/CBPlay.fbp b/GP/CBPlay.fbp index af132ea..dc331d8 100644 --- a/GP/CBPlay.fbp +++ b/GP/CBPlay.fbp @@ -13280,5 +13280,402 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + CTruncatePlaybackDlg + + + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + Truncate Playback? + + 0 + + + + + + bSizer70 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizer71 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + You are not at the end of the move playback. You have the option of discarding all moves that occur after this point. The preceding moves will be stored in the Game History database. Truncating moves is useful in order to recover from a hopelessly flawed set of moves. You resume play at the state of the game where the playback was truncated. + 0 + + 0 + + + 0 + + 1 + m_staticDesc + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + NO! Do NOT...I repeat DO NOT truncate the playback. + + 0 + + + 0 + + 1 + m_radioTruncateSel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Yes. Truncate the playback and retain that state of the game. + + 0 + + + 0 + + 1 + m_radioBtn3 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + 5 + + 0 + + + bSizer72 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 1 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + OK + + 0 + + 0 + + + 0 + + 1 + wxID_OK + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Cancel + + 0 + + 0 + + + 0 + + 1 + wxID_CANCEL + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + diff --git a/GP/CBPlay.xrc b/GP/CBPlay.xrc index 517e226..d6515ec 100644 --- a/GP/CBPlay.xrc +++ b/GP/CBPlay.xrc @@ -2536,4 +2536,79 @@ + + + Truncate Playback? + 1 + + wxHORIZONTAL + + wxEXPAND + 5 + + + wxVERTICAL + + wxALL + 5 + + + + -1 + + + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + 0 + + + + wxALL + 5 + + + + 0 + + + + + + + 5 + + + wxVERTICAL + + wxALL + 5 + + + + 1 + 0 + 0 + + + + + wxALL + 5 + + + + 0 + 0 + 0 + + + + + + + diff --git a/GP/DlgTrunc.cpp b/GP/DlgTrunc.cpp index 4ce85df..f241cb9 100644 --- a/GP/DlgTrunc.cpp +++ b/GP/DlgTrunc.cpp @@ -1,6 +1,6 @@ // DlgTrunc.cpp : implementation file // -// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved. +// Copyright (c) 1994-2025 By Dale L. Larson & William Su, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -35,30 +35,37 @@ static char THIS_FILE[] = __FILE__; ///////////////////////////////////////////////////////////////////////////// // CTruncatePlaybackDlg dialog -CTruncatePlaybackDlg::CTruncatePlaybackDlg(CWnd* pParent /*=NULL*/) - : CDialog(CTruncatePlaybackDlg::IDD, pParent) +CTruncatePlaybackDlg::CTruncatePlaybackDlg(wxWindow* pParent /*= &CB::GetMainWndWx()*/) : + CB_XRC_BEGIN_CTRLS_DEFN(pParent, CTruncatePlaybackDlg) + CB_XRC_CTRL_VAL(m_radioTruncateSel, m_nTruncateSel) + CB_XRC_END_CTRLS_DEFN() { - //{{AFX_DATA_INIT(CTruncatePlaybackDlg) - m_nTruncateSel = 0; - //}}AFX_DATA_INIT -} + // match the desc + OK button width to rest of sizer + wxStaticText& desc = CheckedDeref(XRCCTRL(*this, "m_staticDesc", wxStaticText)); + desc.Hide(); + // find size w/o desc + wxSizer& sizer = CheckedDeref(desc.GetContainingSizer()); + wxSize minSize = sizer.GetMinSize(); + desc.Show(); + desc.InvalidateBestSize(); + desc.Wrap(minSize.x); -void CTruncatePlaybackDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CTruncatePlaybackDlg) - DDX_Radio(pDX, IDC_D_TRUNC_DONT, m_nTruncateSel); - //}}AFX_DATA_MAP + SetMinSize(wxDefaultSize); + Layout(); + Fit(); + Centre(); + + m_nTruncateSel = 0; } -BEGIN_MESSAGE_MAP(CTruncatePlaybackDlg, CDialog) - //{{AFX_MSG_MAP(CTruncatePlaybackDlg) - // NOTE: the ClassWizard will add message map macros here +wxBEGIN_EVENT_TABLE(CTruncatePlaybackDlg, wxDialog) +#if 0 ON_WM_HELPINFO() ON_WM_CONTEXTMENU() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() +#endif +wxEND_EVENT_TABLE() +#if 0 ///////////////////////////////////////////////////////////////////////////// // Html Help control ID Map @@ -78,6 +85,7 @@ void CTruncatePlaybackDlg::OnContextMenu(CWnd* pWnd, CPoint point) { GetApp()->DoHelpWhatIsHelp(pWnd, adwHelpMap); } +#endif ///////////////////////////////////////////////////////////////////////////// // CTruncatePlaybackDlg message handlers diff --git a/GP/DlgTrunc.h b/GP/DlgTrunc.h index 239277f..81b98af 100644 --- a/GP/DlgTrunc.h +++ b/GP/DlgTrunc.h @@ -1,6 +1,6 @@ // DlgTrunc.h : header file // -// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved. +// Copyright (c) 1994-2025 By Dale L. Larson & William Su, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -32,36 +32,30 @@ ///////////////////////////////////////////////////////////////////////////// // CTruncatePlaybackDlg dialog -class CTruncatePlaybackDlg : public CDialog +class CTruncatePlaybackDlg : public wxDialog { // Construction public: - CTruncatePlaybackDlg(CWnd* pParent = NULL); // standard constructor + CTruncatePlaybackDlg(wxWindow* pParent = &CB::GetMainWndWx()); // standard constructor // Dialog Data - //{{AFX_DATA(CTruncatePlaybackDlg) - enum { IDD = IDD_TRUNCATE_PLAYBACK }; int m_nTruncateSel; - //}}AFX_DATA +private: + CB_XRC_BEGIN_CTRLS_DECL() + RefPtr m_radioTruncateSel; + CB_XRC_END_CTRLS_DECL() // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CTruncatePlaybackDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL // Implementation protected: - // Generated message map functions - //{{AFX_MSG(CTruncatePlaybackDlg) - // NOTE: the ClassWizard will add member functions here +#if 0 afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() +#endif + wxDECLARE_EVENT_TABLE(); }; #endif diff --git a/GP/GamDoc2.cpp b/GP/GamDoc2.cpp index 382879b..20d93ca 100644 --- a/GP/GamDoc2.cpp +++ b/GP/GamDoc2.cpp @@ -539,7 +539,7 @@ void CGamDoc::DoAcceptPlayback() // (exposed for project window access) if (m_nCurMove != Invalid_v) { CTruncatePlaybackDlg dlg; - if (dlg.DoModal() != IDOK) + if (dlg.ShowModal() != wxID_OK) return; bTruncateRemainingMoves = dlg.m_nTruncateSel == 1; } From 139c6a641cfc48496c0c6327da3cb47c6b02e05f Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sat, 2 Aug 2025 02:01:28 -0400 Subject: [PATCH 05/11] DlgYnew: replace MFC with wx --- GP/CBPlay.fbp | 394 +++++++++++++++++++++++++++++++++++++++++++++++++ GP/CBPlay.xrc | 75 ++++++++++ GP/DlgYnew.cpp | 49 +++--- GP/DlgYnew.h | 27 ++-- GP/GamDoc.cpp | 7 +- 5 files changed, 499 insertions(+), 53 deletions(-) diff --git a/GP/CBPlay.fbp b/GP/CBPlay.fbp index dc331d8..df16aca 100644 --- a/GP/CBPlay.fbp +++ b/GP/CBPlay.fbp @@ -13280,6 +13280,400 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + CTrayNewDialog + + + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + Create Tray + + 0 + + + + + + bSizer73 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizer74 + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Enter name of new Playing Piece Tray: + 0 + + 0 + + + 0 + + 1 + m_staticText51 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_editName + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + See the Tray Properties dialog to set Tray options. + 0 + + 0 + + + 0 + + 1 + m_staticText52 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 5 + + 0 + + + bSizer75 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 1 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + OK + + 0 + + 0 + + + 0 + + 1 + wxID_OK + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Cancel + + 0 + + 0 + + + 0 + + 1 + wxID_CANCEL + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 0 wxAUI_MGR_DEFAULT diff --git a/GP/CBPlay.xrc b/GP/CBPlay.xrc index d6515ec..eb20105 100644 --- a/GP/CBPlay.xrc +++ b/GP/CBPlay.xrc @@ -2536,6 +2536,81 @@ + + + Create Tray + 1 + + wxHORIZONTAL + + wxEXPAND + 5 + + + wxVERTICAL + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + -1 + + + + wxALL|wxEXPAND + 5 + + + + 0 + + + + wxALL + 5 + + + + -1 + + + + + + + 5 + + + wxVERTICAL + + wxALL + 5 + + + + 1 + 0 + 0 + + + + + wxALL + 5 + + + + 0 + 0 + 0 + + + + + + + Truncate Playback? diff --git a/GP/DlgYnew.cpp b/GP/DlgYnew.cpp index 587ed0e..6e78b43 100644 --- a/GP/DlgYnew.cpp +++ b/GP/DlgYnew.cpp @@ -1,6 +1,6 @@ // DlgYnew.cpp : implementation file // -// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved. +// Copyright (c) 1994-2025 By Dale L. Larson & William Su, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -36,48 +36,33 @@ static char THIS_FILE[] = __FILE__; // CTrayNewDialog dialog -CTrayNewDialog::CTrayNewDialog(CWnd* pParent /*=NULL*/) - : CDialog(CTrayNewDialog::IDD, pParent) +CTrayNewDialog::CTrayNewDialog(CTrayManager& yMgr, wxWindow* pParent /*= &CB::GetMainWndWx()*/) : + CB_XRC_BEGIN_CTRLS_DEFN(pParent, CTrayNewDialog) + CB_XRC_CTRL_VAL(m_editName, m_strName, wxFILTER_EMPTY, 32) + CB_XRC_END_CTRLS_DEFN(), + m_pYMgr(yMgr) { - //{{AFX_DATA_INIT(CTrayNewDialog) m_strName = ""; - //}}AFX_DATA_INIT } -void CTrayNewDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CTrayNewDialog) - DDX_Control(pDX, IDC_D_YNEW_NAME, m_editName); - DDX_Text(pDX, IDC_D_YNEW_NAME, m_strName); - DDV_MaxChars(pDX, m_strName, 32); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CTrayNewDialog, CDialog) - //{{AFX_MSG_MAP(CTrayNewDialog) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - ///////////////////////////////////////////////////////////////////////////// // CTrayNewDialog message handlers -void CTrayNewDialog::OnOK() +bool CTrayNewDialog::TransferDataFromWindow() { - m_strName = CB::string::GetWindowText(m_editName); - if (m_strName.empty()) + if (!wxDialog::TransferDataFromWindow()) { - AfxMessageBox(IDS_ERR_TRAYNAME, MB_OK | MB_ICONINFORMATION); - m_editName.SetFocus(); - return; + return false; } - size_t nSel = m_pYMgr->FindTrayByName(m_strName); + + size_t nSel = m_pYMgr.FindTrayByName(m_strName); if (nSel != Invalid_v) { - AfxMessageBox(IDS_ERR_TRAYNAMEUSED, MB_OK | MB_ICONINFORMATION); - m_editName.SetFocus(); - return; + wxMessageBox(CB::string::LoadString(IDS_ERR_TRAYNAMEUSED), + CB::GetAppName(), + wxOK | wxICON_INFORMATION); + m_editName->SetFocus(); + return false; } - CDialog::OnOK(); + return true; } diff --git a/GP/DlgYnew.h b/GP/DlgYnew.h index 1482af3..7ddfcc9 100644 --- a/GP/DlgYnew.h +++ b/GP/DlgYnew.h @@ -1,6 +1,6 @@ // DlgYnew.h : header file // -// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved. +// Copyright (c) 1994-2025 By Dale L. Larson & William Su, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -29,29 +29,22 @@ class CTrayManager; ///////////////////////////////////////////////////////////////////////////// // CTrayNewDialog dialog -class CTrayNewDialog : public CDialog +class CTrayNewDialog : public wxDialog { // Construction public: - CTrayNewDialog(CWnd* pParent = NULL); // standard constructor + CTrayNewDialog(CTrayManager& yMgr, wxWindow* pParent = &CB::GetMainWndWx()); // standard constructor -// Dialog Data - //{{AFX_DATA(CTrayNewDialog) - enum { IDD = IDD_TRAYNEW }; - CEdit m_editName; - CB::string m_strName; - //}}AFX_DATA + wxString m_strName; +private: + CB_XRC_BEGIN_CTRLS_DECL() + RefPtr m_editName; + CB_XRC_END_CTRLS_DECL() - CTrayManager* m_pYMgr; + const CTrayManager& m_pYMgr; // Implementation protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - // Generated message map functions - //{{AFX_MSG(CTrayNewDialog) - virtual void OnOK(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + bool TransferDataFromWindow() override; }; diff --git a/GP/GamDoc.cpp b/GP/GamDoc.cpp index b6fd74d..626b187 100644 --- a/GP/GamDoc.cpp +++ b/GP/GamDoc.cpp @@ -1571,11 +1571,10 @@ void CGamDoc::OnUpdateFileDiscardRecordedMoves(CCmdUI* pCmdUI) void CGamDoc::OnEditCreateTray() { ASSERT(IsScenario()); - CTrayNewDialog dlg; - dlg.m_pYMgr = &GetTrayManager(); - if (dlg.DoModal() == IDOK) + CTrayNewDialog dlg(GetTrayManager()); + if (dlg.ShowModal() == wxID_OK) { - dlg.m_pYMgr->CreateTraySet(dlg.m_strName); + GetTrayManager().CreateTraySet(dlg.m_strName); CGamDocHint hint; hint.GetArgs().m_pTray = NULL; From 91b6e0b7a82c629ebda7a85ee7ba63dba82bdb3e Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sat, 2 Aug 2025 14:57:34 -0400 Subject: [PATCH 06/11] DlgYprop: improve const- and null-correctness --- GP/DlgYprop.cpp | 15 ++++++++------- GP/DlgYprop.h | 16 ++++++++++++---- GP/VwPrjgs1.cpp | 6 ++---- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/GP/DlgYprop.cpp b/GP/DlgYprop.cpp index c9e74d9..11ff832 100644 --- a/GP/DlgYprop.cpp +++ b/GP/DlgYprop.cpp @@ -36,8 +36,12 @@ static char THIS_FILE[] = __FILE__; ///////////////////////////////////////////////////////////////////////////// // CTrayPropDialog dialog -CTrayPropDialog::CTrayPropDialog(CWnd* pParent /*=NULL*/) - : CDialog(CTrayPropDialog::IDD, pParent) +CTrayPropDialog::CTrayPropDialog(const CTrayManager& yMgr, + const CPlayerManager* playerMgr, + CWnd* pParent /*=NULL*/) + : CDialog(CTrayPropDialog::IDD, pParent), + m_pYMgr(yMgr), + m_pPlayerMgr(playerMgr) { //{{AFX_DATA_INIT(CTrayPropDialog) m_strName = ""; @@ -48,8 +52,6 @@ CTrayPropDialog::CTrayPropDialog(CWnd* pParent /*=NULL*/) m_nYSel = Invalid_v; m_nOwnerSel = INVALID_PLAYER; m_bNonOwnerAccess = FALSE; - m_pPlayerMgr = NULL; - m_pYMgr = NULL; m_bEnforceVizForOwnerToo = FALSE; } @@ -136,7 +138,7 @@ void CTrayPropDialog::OnOK() m_editName.SetFocus(); return; } - size_t nSel = m_pYMgr->FindTrayByName(m_strName); + size_t nSel = m_pYMgr.FindTrayByName(m_strName); if (nSel != Invalid_v && nSel != m_nYSel) { AfxMessageBox(IDS_ERR_TRAYNAMEUSED, MB_OK | MB_ICONINFORMATION); @@ -161,10 +163,9 @@ void CTrayPropDialog::OnOK() BOOL CTrayPropDialog::OnInitDialog() { CDialog::OnInitDialog(); - ASSERT(m_pYMgr); ASSERT(m_nYSel != Invalid_v); - m_editName.SetWindowText(m_pYMgr->GetTraySet(m_nYSel).GetName()); + m_editName.SetWindowText(m_pYMgr.GetTraySet(m_nYSel).GetName()); if (m_pPlayerMgr == NULL) { m_comboOwners.EnableWindow(FALSE); diff --git a/GP/DlgYprop.h b/GP/DlgYprop.h index ff2fc9c..b24fc96 100644 --- a/GP/DlgYprop.h +++ b/GP/DlgYprop.h @@ -1,6 +1,6 @@ // DlgYprop.h : header file // -// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved. +// Copyright (c) 1994-2025 By Dale L. Larson & William Su, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -34,18 +34,24 @@ class CTrayPropDialog : public CDialog { // Construction public: - CTrayPropDialog(CWnd* pParent = NULL); // standard constructor + CTrayPropDialog(const CTrayManager& yMgr, + const CPlayerManager* playerMgr, + CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CTrayPropDialog) +private: enum { IDD = IDD_TRAYPRP }; CButton m_chkVizOwnerToo; CButton m_chkAllowAccess; CStatic m_staticOwnerLabel; CComboBox m_comboOwners; CEdit m_editName; +public: CB::string m_strName; +private: int m_nVizOpts; +public: BOOL m_bRandomSel; BOOL m_bRandomSide; //}}AFX_DATA @@ -55,9 +61,11 @@ class CTrayPropDialog : public CDialog BOOL m_bNonOwnerAccess; BOOL m_bEnforceVizForOwnerToo; - CTrayManager* m_pYMgr; - CPlayerManager* m_pPlayerMgr; +private: + const CTrayManager& m_pYMgr; + const CPlayerManager* const m_pPlayerMgr; +public: void SetTrayViz(TrayViz eTrayViz) { m_nVizOpts = (int)eTrayViz; } TrayViz GetTrayViz() { return (TrayViz)m_nVizOpts; } diff --git a/GP/VwPrjgs1.cpp b/GP/VwPrjgs1.cpp index d6b7292..dd70c0d 100644 --- a/GP/VwPrjgs1.cpp +++ b/GP/VwPrjgs1.cpp @@ -152,10 +152,8 @@ void CGsnProjView::DoTrayProperty() size_t nGrp = m_listProj.GetItemSourceCode(nSel); - CTrayPropDialog dlg; + CTrayPropDialog dlg(pDoc->GetTrayManager(), pDoc->GetPlayerManager()); dlg.m_nYSel = nGrp; - dlg.m_pYMgr = &pDoc->GetTrayManager(); - dlg.m_pPlayerMgr = pDoc->GetPlayerManager(); CTraySet& pYGrp = pDoc->GetTrayManager().GetTraySet(nGrp); dlg.m_bRandomSel = pYGrp.IsRandomPiecePull(); @@ -172,7 +170,7 @@ void CGsnProjView::DoTrayProperty() pYGrp.SetRandPiecePull(dlg.m_bRandomSel); pYGrp.SetRandSidePull(dlg.m_bRandomSide); pYGrp.SetTrayContentVisibility(dlg.GetTrayViz()); - if (dlg.m_pPlayerMgr != NULL) + if (pDoc->GetPlayerManager() != NULL) { pYGrp.SetOwnerMask(CPlayerManager::GetMaskFromPlayerNum(dlg.m_nOwnerSel)); pYGrp.PropagateOwnerMaskToAllPieces(pDoc); From f7cd2b01355e508703e885292b7b923756d49717 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sat, 2 Aug 2025 23:18:43 -0400 Subject: [PATCH 07/11] DlgYprop: replace MFC with wx --- GP/CBPlay.fbp | 1004 +++++++++++++++++++++++++++++++++++++++++++++++ GP/CBPlay.xrc | 174 ++++++++ GP/DlgYprop.cpp | 131 +++---- GP/DlgYprop.h | 52 ++- GP/VwPrjgs1.cpp | 2 +- 5 files changed, 1266 insertions(+), 97 deletions(-) diff --git a/GP/CBPlay.fbp b/GP/CBPlay.fbp index df16aca..8becc26 100644 --- a/GP/CBPlay.fbp +++ b/GP/CBPlay.fbp @@ -13674,6 +13674,1010 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + CTrayPropDialog + + + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + Tray Properties + + 0 + + + + + + bSizer76 + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + bSizer77 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizer78 + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Name for Playing Piece Tray: + 0 + + 0 + + + 0 + + 1 + m_staticText53 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_editName + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Tray's owner: + 0 + + 0 + + + 0 + + 1 + m_staticOwnerLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_comboOwners + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Allow non-owners to access this owned tray. + + 0 + + + 0 + + 1 + m_chkAllowAccess + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Drag delivers random pieces for selections + + 0 + + + 0 + + 1 + m_checkRandomSel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Drag delivers random sides for selections + + 0 + + + 0 + + 1 + m_checkRandomSide + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + + 0 + + + bSizer79 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 1 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + OK + + 0 + + 0 + + + 0 + + 1 + wxID_OK + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Cancel + + 0 + + 0 + + + 0 + + 1 + wxID_CANCEL + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + wxID_ANY + Tray content visibility + + sbSizer5 + wxVERTICAL + 1 + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Visibility rule also applies to the tray's owner. + + 0 + + + 0 + + 1 + m_chkVizOwnerToo + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + All sides of pieces are fully visible + + 0 + + + 0 + + 1 + m_radioVizOpts + 1 + + + protected + 1 + + Resizable + 1 + + wxRB_GROUP + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Only the top side of pieces are visible + + 0 + + + 0 + + 1 + m_radioBtn6 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Each piece image is hidden. (shows "HIDDEN") + + 0 + + + 0 + + 1 + m_radioBtn7 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + All piece items hidden. (shows the text "ALL HIDDEN") + + 0 + + + 0 + + 1 + m_radioBtn8 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + 0 wxAUI_MGR_DEFAULT diff --git a/GP/CBPlay.xrc b/GP/CBPlay.xrc index eb20105..4b02c94 100644 --- a/GP/CBPlay.xrc +++ b/GP/CBPlay.xrc @@ -2611,6 +2611,180 @@ + + + Tray Properties + 1 + + wxVERTICAL + + wxEXPAND + 5 + + + wxHORIZONTAL + + wxEXPAND + 5 + + + wxVERTICAL + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + -1 + + + + wxALL|wxEXPAND + 5 + + + + 0 + + + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + -1 + + + + wxALL|wxEXPAND + 5 + + + 0 + + + + + wxALL + 5 + + + + 0 + + + + wxALL + 5 + + + + 0 + + + + wxALL + 5 + + + + 0 + + + + + + + 5 + + + wxVERTICAL + + wxALL + 5 + + + + 1 + 0 + 0 + + + + + wxALL + 5 + + + + 0 + 0 + 0 + + + + + + + + + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 5 + + + wxVERTICAL + + + wxALL + 5 + + + + 0 + + + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + + 0 + + + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + 0 + + + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + 0 + + + + wxTOP|wxRIGHT|wxLEFT + 5 + + + + 0 + + + + + + Truncate Playback? diff --git a/GP/DlgYprop.cpp b/GP/DlgYprop.cpp index 11ff832..a0ea46d 100644 --- a/GP/DlgYprop.cpp +++ b/GP/DlgYprop.cpp @@ -38,48 +38,39 @@ static char THIS_FILE[] = __FILE__; CTrayPropDialog::CTrayPropDialog(const CTrayManager& yMgr, const CPlayerManager* playerMgr, - CWnd* pParent /*=NULL*/) - : CDialog(CTrayPropDialog::IDD, pParent), + wxWindow* pParent /*= &CB::GetMainWndWx()*/) : + CB_XRC_BEGIN_CTRLS_DEFN(pParent, CTrayPropDialog) + CB_XRC_CTRL(m_chkVizOwnerToo) + CB_XRC_CTRL(m_chkAllowAccess) + CB_XRC_CTRL(m_staticOwnerLabel) + CB_XRC_CTRL(m_comboOwners) + CB_XRC_CTRL_VAL(m_editName, m_strName, wxFILTER_EMPTY, 32) + CB_XRC_CTRL_VAL(m_radioVizOpts, m_nVizOpts) + CB_XRC_CTRL_VAL(m_checkRandomSel, m_bRandomSel) + CB_XRC_CTRL_VAL(m_checkRandomSide, m_bRandomSide) + CB_XRC_END_CTRLS_DEFN(), m_pYMgr(yMgr), m_pPlayerMgr(playerMgr) { - //{{AFX_DATA_INIT(CTrayPropDialog) m_strName = ""; m_nVizOpts = -1; m_bRandomSel = FALSE; m_bRandomSide = false; - //}}AFX_DATA_INIT m_nYSel = Invalid_v; m_nOwnerSel = INVALID_PLAYER; m_bNonOwnerAccess = FALSE; m_bEnforceVizForOwnerToo = FALSE; } -void CTrayPropDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CTrayPropDialog) - DDX_Control(pDX, IDC_D_YPRP_OWNER_TOO, m_chkVizOwnerToo); - DDX_Control(pDX, IDC_D_YPRP_NONOWNER_ACCESS, m_chkAllowAccess); - DDX_Control(pDX, IDC_D_YPRP_OWNER_LABEL, m_staticOwnerLabel); - DDX_Control(pDX, IDC_D_YPRP_OWNER_LIST, m_comboOwners); - DDX_Control(pDX, IDC_D_YPRP_NAME, m_editName); - DDX_Text(pDX, IDC_D_YPRP_NAME, m_strName); - DDV_MaxChars(pDX, m_strName, 32); - DDX_Radio(pDX, IDC_D_YPRP_VIZFULL, m_nVizOpts); - DDX_Check(pDX, IDC_D_YPRP_RANDSEL, m_bRandomSel); - DDX_Check(pDX, IDC_D_YPRP_RANDSIDE, m_bRandomSide); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CTrayPropDialog, CDialog) - //{{AFX_MSG_MAP(CTrayPropDialog) - ON_CBN_SELCHANGE(IDC_D_YPRP_OWNER_LIST, OnSelChangeOwnerList) +wxBEGIN_EVENT_TABLE(CTrayPropDialog, wxDialog) + EVT_CHOICE(XRCID("m_comboOwners"), OnSelChangeOwnerList) +#if 0 ON_WM_HELPINFO() ON_WM_CONTEXTMENU() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() +#endif +wxEND_EVENT_TABLE() +#if 0 ///////////////////////////////////////////////////////////////////////////// // Html Help control ID Map @@ -108,48 +99,49 @@ void CTrayPropDialog::OnContextMenu(CWnd* pWnd, CPoint point) { GetApp()->DoHelpWhatIsHelp(pWnd, adwHelpMap); } +#endif ///////////////////////////////////////////////////////////////////////////// // CTrayPropDialog message handlers -void CTrayPropDialog::OnSelChangeOwnerList() +void CTrayPropDialog::OnSelChangeOwnerList(wxCommandEvent& /*event*/) { - if (m_comboOwners.GetCurSel() <= 0) + if (m_comboOwners->GetSelection() <= 0) { - m_chkAllowAccess.SetCheck(0); - m_chkVizOwnerToo.SetCheck(0); - m_chkAllowAccess.EnableWindow(FALSE); - m_chkVizOwnerToo.EnableWindow(FALSE); + m_chkAllowAccess->SetValue(false); + m_chkVizOwnerToo->SetValue(false); + m_chkAllowAccess->Enable(FALSE); + m_chkVizOwnerToo->Enable(FALSE); } else { - m_chkAllowAccess.EnableWindow(TRUE); - m_chkVizOwnerToo.EnableWindow(TRUE); + m_chkAllowAccess->Enable(TRUE); + m_chkVizOwnerToo->Enable(TRUE); } } -void CTrayPropDialog::OnOK() +bool CTrayPropDialog::TransferDataFromWindow() { - m_strName = CB::string::GetWindowText(m_editName); - if (m_strName.empty()) + if (!wxDialog::TransferDataFromWindow()) { - AfxMessageBox(IDS_ERR_TRAYNAME, MB_OK | MB_ICONINFORMATION); - m_editName.SetFocus(); - return; + return false; } + size_t nSel = m_pYMgr.FindTrayByName(m_strName); if (nSel != Invalid_v && nSel != m_nYSel) { - AfxMessageBox(IDS_ERR_TRAYNAMEUSED, MB_OK | MB_ICONINFORMATION); - m_editName.SetFocus(); - return; + wxMessageBox(CB::string::LoadString(IDS_ERR_TRAYNAMEUSED), + CB::GetAppName(), + wxOK | wxICON_INFORMATION); + m_editName->SetFocus(); + return false; } if (m_pPlayerMgr != NULL) { - m_nOwnerSel = PlayerId(m_comboOwners.GetCurSel() - 1); - m_bNonOwnerAccess = m_chkAllowAccess.GetCheck() != 0; - m_bEnforceVizForOwnerToo = m_chkVizOwnerToo.GetCheck() != 0; + m_nOwnerSel = PlayerId(m_comboOwners->GetSelection() - 1); + m_bNonOwnerAccess = m_chkAllowAccess->GetValue(); + m_bEnforceVizForOwnerToo = m_chkVizOwnerToo->GetValue(); if (m_nOwnerSel == INVALID_PLAYER) { m_bNonOwnerAccess = FALSE; @@ -157,46 +149,49 @@ void CTrayPropDialog::OnOK() } } - CDialog::OnOK(); + return true; } -BOOL CTrayPropDialog::OnInitDialog() +bool CTrayPropDialog::TransferDataToWindow() { - CDialog::OnInitDialog(); - ASSERT(m_nYSel != Invalid_v); + if (!wxDialog::TransferDataToWindow()) + { + return false; + } + wxASSERT(m_nYSel != Invalid_v); - m_editName.SetWindowText(m_pYMgr.GetTraySet(m_nYSel).GetName()); + m_editName->SetValue(m_pYMgr.GetTraySet(m_nYSel).GetName()); if (m_pPlayerMgr == NULL) { - m_comboOwners.EnableWindow(FALSE); - m_staticOwnerLabel.EnableWindow(FALSE); - m_chkAllowAccess.SetCheck(0); - m_chkAllowAccess.EnableWindow(FALSE); + m_comboOwners->Enable(FALSE); + m_staticOwnerLabel->Enable(FALSE); + m_chkAllowAccess->SetValue(false); + m_chkAllowAccess->Enable(FALSE); } else { CB::string str = CB::string::LoadString(IDS_LBL_NO_OWNER); - m_comboOwners.AddString(str); + m_comboOwners->Append(str); for (const Player& player : *m_pPlayerMgr) { - m_comboOwners.AddString(player.m_strName); + m_comboOwners->Append(player.m_strName); } - m_comboOwners.SetCurSel(static_cast(m_nOwnerSel) + 1); - if (m_comboOwners.GetCurSel() <= 0) + m_comboOwners->SetSelection(static_cast(m_nOwnerSel) + 1); + if (m_comboOwners->GetSelection() <= 0) { - m_chkAllowAccess.SetCheck(0); - m_chkAllowAccess.EnableWindow(FALSE); - m_chkVizOwnerToo.SetCheck(0); - m_chkVizOwnerToo.EnableWindow(FALSE); + m_chkAllowAccess->SetValue(false); + m_chkAllowAccess->Enable(FALSE); + m_chkVizOwnerToo->SetValue(false); + m_chkVizOwnerToo->Enable(FALSE); } else { - m_chkAllowAccess.EnableWindow(TRUE); - m_chkVizOwnerToo.EnableWindow(TRUE); - m_chkAllowAccess.SetCheck(m_bNonOwnerAccess ? 1 : 0); - m_chkVizOwnerToo.SetCheck(m_bEnforceVizForOwnerToo ? 1 : 0); + m_chkAllowAccess->Enable(TRUE); + m_chkVizOwnerToo->Enable(TRUE); + m_chkAllowAccess->SetValue(m_bNonOwnerAccess); + m_chkVizOwnerToo->SetValue(m_bEnforceVizForOwnerToo); } } - return TRUE; // return TRUE unless you set the focus to a control + return TRUE; } diff --git a/GP/DlgYprop.h b/GP/DlgYprop.h index b24fc96..189e91d 100644 --- a/GP/DlgYprop.h +++ b/GP/DlgYprop.h @@ -30,38 +30,37 @@ class CPlayerManager; ///////////////////////////////////////////////////////////////////////////// // CTrayPropDialog dialog -class CTrayPropDialog : public CDialog +class CTrayPropDialog : public wxDialog { // Construction public: CTrayPropDialog(const CTrayManager& yMgr, const CPlayerManager* playerMgr, - CWnd* pParent = NULL); // standard constructor + wxWindow* parent = &CB::GetMainWndWx()); // standard constructor -// Dialog Data - //{{AFX_DATA(CTrayPropDialog) -private: - enum { IDD = IDD_TRAYPRP }; - CButton m_chkVizOwnerToo; - CButton m_chkAllowAccess; - CStatic m_staticOwnerLabel; - CComboBox m_comboOwners; - CEdit m_editName; -public: - CB::string m_strName; + wxString m_strName; private: int m_nVizOpts; public: - BOOL m_bRandomSel; - BOOL m_bRandomSide; - //}}AFX_DATA + bool m_bRandomSel; + bool m_bRandomSide; size_t m_nYSel; PlayerId m_nOwnerSel; // -1 = no owner, 0 = first player, .... - BOOL m_bNonOwnerAccess; - BOOL m_bEnforceVizForOwnerToo; - + bool m_bNonOwnerAccess; + bool m_bEnforceVizForOwnerToo; private: + CB_XRC_BEGIN_CTRLS_DECL() + RefPtr m_chkVizOwnerToo; + RefPtr m_chkAllowAccess; + RefPtr m_staticOwnerLabel; + RefPtr m_comboOwners; + RefPtr m_editName; + RefPtr m_radioVizOpts; + RefPtr m_checkRandomSel; + RefPtr m_checkRandomSide; + CB_XRC_END_CTRLS_DECL() + const CTrayManager& m_pYMgr; const CPlayerManager* const m_pPlayerMgr; @@ -71,15 +70,12 @@ class CTrayPropDialog : public CDialog // Implementation protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - // Generated message map functions - //{{AFX_MSG(CTrayPropDialog) - virtual void OnOK(); - virtual BOOL OnInitDialog(); - afx_msg void OnSelChangeOwnerList(); + bool TransferDataFromWindow() override; + bool TransferDataToWindow() override; + void OnSelChangeOwnerList(wxCommandEvent& event); +#if 0 afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() +#endif + wxDECLARE_EVENT_TABLE(); }; diff --git a/GP/VwPrjgs1.cpp b/GP/VwPrjgs1.cpp index dd70c0d..d3f4b89 100644 --- a/GP/VwPrjgs1.cpp +++ b/GP/VwPrjgs1.cpp @@ -163,7 +163,7 @@ void CGsnProjView::DoTrayProperty() dlg.m_bNonOwnerAccess = pYGrp.IsNonOwnerAccessAllowed(); dlg.m_bEnforceVizForOwnerToo = pYGrp.IsEnforcingVisibilityForOwnerToo(); - if (dlg.DoModal() == IDOK) + if (dlg.ShowModal() == wxID_OK) { pYGrp.SetName(dlg.m_strName); From 75c1bc540e414210e35cf432f1f727f81459b50c Mon Sep 17 00:00:00 2001 From: Bill Su Date: Wed, 6 Aug 2025 00:31:54 -0400 Subject: [PATCH 08/11] Gp: wx Event versions of MFC messages WM_SHOWPLAYINGBOARD and WM_WINSTATE_RESTORE --- GP/Gp.cpp | 3 +++ GP/Gp.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/GP/Gp.cpp b/GP/Gp.cpp index faf8cf5..dd7c36c 100644 --- a/GP/Gp.cpp +++ b/GP/Gp.cpp @@ -48,6 +48,9 @@ static char THIS_FILE[] = __FILE__; #define new DEBUG_NEW #endif +wxDEFINE_EVENT(WM_SHOWPLAYINGBOARD_WX, ShowPlayingBoardEvent); +wxDEFINE_EVENT(WM_WINSTATE_RESTORE_WX, WinStateRestoreEvent); + ///////////////////////////////////////////////////////////////////////////// // Registry keys... diff --git a/GP/Gp.h b/GP/Gp.h index fb659be..7f07452 100644 --- a/GP/Gp.h +++ b/GP/Gp.h @@ -48,8 +48,49 @@ #define WM_ROTATEPIECE_DELTA (WM_USER + 210) // WPARAM = (int)relative rotation delta #define WM_CENTERBOARDONPOINT (WM_USER + 211) // WPARAM = POINT* in board coords + #define WM_SHOWPLAYINGBOARD (WM_USER + 212) // WPARAM = size_t Playing Board Index +class ShowPlayingBoardEvent : public wxEvent +{ +public: + ShowPlayingBoardEvent(size_t playBrdIndex); + + size_t GetPlayingBoardIndex() const { return playBrdIndex; } + + wxEvent* Clone() const override { return new ShowPlayingBoardEvent(*this); } + +private: + const size_t playBrdIndex; +}; +wxDECLARE_EVENT(WM_SHOWPLAYINGBOARD_WX, ShowPlayingBoardEvent); +inline ShowPlayingBoardEvent::ShowPlayingBoardEvent(size_t pbi) : + wxEvent(wxID_ANY, WM_SHOWPLAYINGBOARD_WX), + playBrdIndex(pbi) +{ +} +typedef void (wxEvtHandler::* ShowPlayingBoardEventFunction)(ShowPlayingBoardEvent&); +#define ShowPlayingBoardEventHandler(func) wxEVENT_HANDLER_CAST(ShowPlayingBoardEventFunction, func) +#define EVT_SHOWPLAYINGBOARD(func) \ + wx__DECLARE_EVT0(WM_SHOWPLAYINGBOARD_WX, ShowPlayingBoardEventHandler(func)) + #define WM_WINSTATE_RESTORE (WM_USER + 213) // No Args. Posted to project window +class WinStateRestoreEvent : public wxEvent +{ +public: + WinStateRestoreEvent(); + + wxEvent* Clone() const override { return new WinStateRestoreEvent(*this); } +}; +wxDECLARE_EVENT(WM_WINSTATE_RESTORE_WX, WinStateRestoreEvent); +inline WinStateRestoreEvent::WinStateRestoreEvent() : + wxEvent(wxID_ANY, WM_WINSTATE_RESTORE_WX) +{ +} +typedef void (wxEvtHandler::* WinStateRestoreEventFunction)(WinStateRestoreEvent&); +#define WinStateRestoreEventHandler(func) wxEVENT_HANDLER_CAST(WinStateRestoreEventFunction, func) +#define EVT_WINSTATE_RESTORE(func) \ + wx__DECLARE_EVT0(WM_WINSTATE_RESTORE_WX, WinStateRestoreEventHandler(func)) + #define WM_SELECT_BOARD_OBJLIST (WM_USER + 214) // WPARAM = CPlayBoard*, LPARAM = const std::vector>* #define WM_MESSAGEBOX (WM_USER + 215) // WPARAM = Opts. LPARAM = Msg ID or Ptr From e9751e243949b37c7e915c5a9ec09e156c368505 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sun, 3 Aug 2025 17:09:44 -0400 Subject: [PATCH 09/11] VwPrjgsn: improve null-correctness --- GP/VwPrjgs1.cpp | 80 ++++++++++++++++++++++++------------------------- GP/VwPrjgsn.cpp | 31 ++++++++++--------- GP/VwPrjgsn.h | 2 +- 3 files changed, 56 insertions(+), 57 deletions(-) diff --git a/GP/VwPrjgs1.cpp b/GP/VwPrjgs1.cpp index d3f4b89..de8de22 100644 --- a/GP/VwPrjgs1.cpp +++ b/GP/VwPrjgs1.cpp @@ -53,19 +53,19 @@ static char THIS_FILE[] = __FILE__; void CGsnProjView::DoGsnProperty() { - GetDocument()->DoScenarioProperties(); + GetDocument().DoScenarioProperties(); } void CGsnProjView::DoUpdateGsnInfo() { - CGamDoc* pDoc = GetDocument(); + CGamDoc& pDoc = GetDocument(); CB::string str; - if (!pDoc->m_strScnTitle.empty()) - str += "TITLE: " + pDoc->m_strScnTitle + "\r\n\r\n"; - if (!pDoc->m_strScnAuthor.empty()) - str += "AUTHOR: " + pDoc->m_strScnAuthor + "\r\n\r\n"; - if (!pDoc->m_strScnDescr.empty()) - str += "DESCRIPTION:\r\n\r\n" + pDoc->m_strScnDescr; + if (!pDoc.m_strScnTitle.empty()) + str += "TITLE: " + pDoc.m_strScnTitle + "\r\n\r\n"; + if (!pDoc.m_strScnAuthor.empty()) + str += "AUTHOR: " + pDoc.m_strScnAuthor + "\r\n\r\n"; + if (!pDoc.m_strScnDescr.empty()) + str += "DESCRIPTION:\r\n\r\n" + pDoc.m_strScnDescr; m_editInfo.SetWindowText(str); } @@ -74,29 +74,29 @@ void CGsnProjView::DoUpdateGsnInfo() void CGsnProjView::DoBoardSelection() { - GetDocument()->DoSelectBoards(); + GetDocument().DoSelectBoards(); } void CGsnProjView::DoBoardProperty() { - CGamDoc* pDoc = GetDocument(); + CGamDoc& pDoc = GetDocument(); int nSel = m_listProj.GetCurSel(); ASSERT(nSel >= 0); ASSERT(m_listProj.GetItemGroupCode(nSel) == grpBrd); size_t nBrd = m_listProj.GetItemSourceCode(nSel); - pDoc->DoBoardProperties(nBrd); + pDoc.DoBoardProperties(nBrd); } void CGsnProjView::DoBoardView() { - CGamDoc* pDoc = GetDocument(); + CGamDoc& pDoc = GetDocument(); int nSel = m_listProj.GetCurSel(); ASSERT(nSel >= 0); ASSERT(m_listProj.GetItemGroupCode(nSel) == grpBrd); size_t nBrd = m_listProj.GetItemSourceCode(nSel); - CPlayBoard& pPBoard = pDoc->GetPBoardManager().GetPBoard(nBrd); - CView* pView = pDoc->FindPBoardView(pPBoard); + CPlayBoard& pPBoard = pDoc.GetPBoardManager().GetPBoard(nBrd); + CView* pView = pDoc.FindPBoardView(pPBoard); if (pView != NULL) { // This board already has an editor. Activate that view. @@ -107,22 +107,22 @@ void CGsnProjView::DoBoardView() else { CB::string strTitle = m_listProj.GetItemText(nSel); - pDoc->CreateNewFrame(GetApp()->m_pBrdViewTmpl, strTitle, &pPBoard); + pDoc.CreateNewFrame(GetApp()->m_pBrdViewTmpl, strTitle, &pPBoard); } } void CGsnProjView::DoBoardRemove() { - CGamDoc* pDoc = GetDocument(); + CGamDoc& pDoc = GetDocument(); int nSel = m_listProj.GetCurSel(); ASSERT(nSel >= 0); ASSERT(m_listProj.GetItemGroupCode(nSel) == grpBrd); size_t nBrd = m_listProj.GetItemSourceCode(nSel); - pDoc->GetPBoardManager().DeletePBoard(nBrd); - pDoc->SetModifiedFlag(TRUE); - pDoc->UpdateAllViews(NULL, HINT_BOARDCHANGE); + pDoc.GetPBoardManager().DeletePBoard(nBrd); + pDoc.SetModifiedFlag(TRUE); + pDoc.UpdateAllViews(NULL, HINT_BOARDCHANGE); } void CGsnProjView::DoUpdateBoardHelpInfo() @@ -140,22 +140,22 @@ void CGsnProjView::DoUpdateBoardInfo() void CGsnProjView::DoTrayCreate() { - GetDocument()->DoCreateTray(); + GetDocument().DoCreateTray(); } void CGsnProjView::DoTrayProperty() { - CGamDoc* pDoc = GetDocument(); + CGamDoc& pDoc = GetDocument(); int nSel = m_listProj.GetCurSel(); ASSERT(nSel >= 0); ASSERT(m_listProj.GetItemGroupCode(nSel) == grpTray); size_t nGrp = m_listProj.GetItemSourceCode(nSel); - CTrayPropDialog dlg(pDoc->GetTrayManager(), pDoc->GetPlayerManager()); + CTrayPropDialog dlg(pDoc.GetTrayManager(), pDoc.GetPlayerManager()); dlg.m_nYSel = nGrp; - CTraySet& pYGrp = pDoc->GetTrayManager().GetTraySet(nGrp); + CTraySet& pYGrp = pDoc.GetTrayManager().GetTraySet(nGrp); dlg.m_bRandomSel = pYGrp.IsRandomPiecePull(); dlg.m_bRandomSide = pYGrp.IsRandomSidePull(); dlg.SetTrayViz(pYGrp.GetTrayContentVisibility()); @@ -170,50 +170,50 @@ void CGsnProjView::DoTrayProperty() pYGrp.SetRandPiecePull(dlg.m_bRandomSel); pYGrp.SetRandSidePull(dlg.m_bRandomSide); pYGrp.SetTrayContentVisibility(dlg.GetTrayViz()); - if (pDoc->GetPlayerManager() != NULL) + if (pDoc.GetPlayerManager() != NULL) { pYGrp.SetOwnerMask(CPlayerManager::GetMaskFromPlayerNum(dlg.m_nOwnerSel)); - pYGrp.PropagateOwnerMaskToAllPieces(pDoc); + pYGrp.PropagateOwnerMaskToAllPieces(&pDoc); pYGrp.SetNonOwnerAccess(dlg.m_bNonOwnerAccess); pYGrp.SetEnforceVisibilityForOwnerToo(dlg.m_bEnforceVizForOwnerToo); } CGamDocHint hint; hint.GetArgs().m_pTray = NULL; - pDoc->UpdateAllViews(NULL, HINT_TRAYCHANGE, &hint); - pDoc->SetModifiedFlag(); + pDoc.UpdateAllViews(NULL, HINT_TRAYCHANGE, &hint); + pDoc.SetModifiedFlag(); } } void CGsnProjView::DoTrayEdit() { - CGamDoc* pDoc = GetDocument(); + CGamDoc& pDoc = GetDocument(); int nSel = m_listProj.GetCurSel(); wxASSERT(nSel >= 0); wxASSERT(m_listProj.GetItemGroupCode(nSel) == grpTray); size_t nGrp = m_listProj.GetItemSourceCode(nSel); - CTrayManager& pYMgr = pDoc->GetTrayManager(); + CTrayManager& pYMgr = pDoc.GetTrayManager(); - CSetPiecesDialog dlg(*pDoc); + CSetPiecesDialog dlg(pDoc); dlg.m_nYSel = value_preserving_cast(nGrp); m_listTrays->SetItemMap(NULL); // Clear this since repaint may fail... - pDoc->CloseTrayPalettes(); // ...Ditto that for tray palettes + pDoc.CloseTrayPalettes(); // ...Ditto that for tray palettes dlg.ShowModal(); // Notify all visible trays CGamDocHint hint; hint.GetArgs().m_pTray = NULL; - pDoc->UpdateAllViews(NULL, HINT_TRAYCHANGE, &hint); - pDoc->SetModifiedFlag(); + pDoc.UpdateAllViews(NULL, HINT_TRAYCHANGE, &hint); + pDoc.SetModifiedFlag(); } void CGsnProjView::DoTrayDelete() { - CGamDoc* pDoc = GetDocument(); - CTrayManager& pYMgr = pDoc->GetTrayManager(); - CPieceTable& pPTbl = pDoc->GetPieceTable(); + CGamDoc& pDoc = GetDocument(); + CTrayManager& pYMgr = pDoc.GetTrayManager(); + CPieceTable& pPTbl = pDoc.GetPieceTable(); int nSel = m_listProj.GetCurSel(); ASSERT(nSel >= 0); @@ -232,8 +232,8 @@ void CGsnProjView::DoTrayDelete() pYMgr.DeleteTraySet(nGrp); CGamDocHint hint; hint.GetArgs().m_pTray = NULL; - pDoc->UpdateAllViews(NULL, HINT_TRAYCHANGE, &hint); - pDoc->SetModifiedFlag(); + pDoc.UpdateAllViews(NULL, HINT_TRAYCHANGE, &hint); + pDoc.SetModifiedFlag(); } void CGsnProjView::DoUpdateTrayHelpInfo() @@ -243,14 +243,14 @@ void CGsnProjView::DoUpdateTrayHelpInfo() void CGsnProjView::DoUpdateTrayList() { - CGamDoc* pDoc = GetDocument(); + CGamDoc& pDoc = GetDocument(); int nSel = m_listProj.GetCurSel(); ASSERT(nSel >= 0); ASSERT(m_listProj.GetItemGroupCode(nSel) == grpTray); size_t nGrp = m_listProj.GetItemSourceCode(nSel); - CTraySet& pYGrp = pDoc->GetTrayManager().GetTraySet(nGrp); + CTraySet& pYGrp = pDoc.GetTrayManager().GetTraySet(nGrp); const std::vector& pLstMap = pYGrp.GetPieceIDTable(); m_listTrays->SetItemMap(&pLstMap); } diff --git a/GP/VwPrjgsn.cpp b/GP/VwPrjgsn.cpp index 70430f7..c07c5cf 100644 --- a/GP/VwPrjgsn.cpp +++ b/GP/VwPrjgsn.cpp @@ -156,7 +156,7 @@ int CGsnProjView::OnCreate(LPCREATESTRUCT lpCreateStruct) rctList.left = rctList.right + BTN_GROUP_XGAP; rctList.right = rctClient.right - XBORDER; - m_listTrays = MakeOwner(CheckedDeref(GetDocument())); + m_listTrays = MakeOwner(GetDocument()); if (!CreateListbox(IDC_V_GSN_TRAYLIST, *m_listTrays, WS_HSCROLL | LBS_HASSTRINGS, rctList)) return -1; m_listTrays->SetTrayContentVisibility(trayVizAllSides); @@ -170,13 +170,13 @@ int CGsnProjView::OnCreate(LPCREATESTRUCT lpCreateStruct) void CGsnProjView::OnInitialUpdate() { - GetDocument()->DoInitialUpdate(); // Since UpdateAllViews isn't virtual + GetDocument().DoInitialUpdate(); // Since UpdateAllViews isn't virtual CView::OnInitialUpdate(); - CGamDoc* pDoc = GetDocument(); - CPBoardManager& pPBMgr = pDoc->GetPBoardManager(); + CGamDoc& pDoc = GetDocument(); + CPBoardManager& pPBMgr = pDoc.GetPBoardManager(); // Only honor the open-on-load flags if the save window state // is disabled. - if (!pDoc->m_bSaveWindowPositions) + if (!pDoc.m_bSaveWindowPositions) { for (size_t i = size_t(0); i < pPBMgr.GetNumPBoards(); i++) { @@ -205,7 +205,7 @@ void CGsnProjView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) void CGsnProjView::OnDraw(CDC* pDC) { - CDocument* pDoc = GetDocument(); + CDocument& pDoc = GetDocument(); // TODO: add draw code here } @@ -401,8 +401,7 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) { bDisplayIDs = GetApp()->GetProfileInt("Settings"_cbstring, "DisplayIDs"_cbstring, 0); } - CGamDoc* pDoc = GetDocument(); - ASSERT(pDoc); + CGamDoc& pDoc = GetDocument(); m_listProj.SetRedraw(FALSE); @@ -420,7 +419,7 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) str = CB::string::LoadString(IDS_PHEAD_GSN_BOARDS); m_listProj.AddItem(grpBrdHdr, str); - CPBoardManager& pPBMgr = pDoc->GetPBoardManager(); + CPBoardManager& pPBMgr = pDoc.GetPBoardManager(); for (size_t i = size_t(0); i < pPBMgr.GetNumPBoards(); i++) { CPlayBoard& pPBoard = pPBMgr.GetPBoard(i); @@ -433,7 +432,7 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) } if (pPBoard.IsOwned()) { - CB::string strOwner = pDoc->GetPlayerManager()->GetPlayerUsingMask( + CB::string strOwner = pDoc.GetPlayerManager()->GetPlayerUsingMask( pPBoard.GetOwnerMask()).m_strName; CB::string strOwnedBy = CB::string::Format(IDS_TIP_OWNED_BY_PROJ, strOwner); str += strOwnedBy; @@ -445,7 +444,7 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) str = CB::string::LoadString(IDS_PHEAD_GSN_TRAYS); m_listProj.AddItem(grpTrayHdr, str); - CTrayManager& pYMgr = pDoc->GetTrayManager(); + CTrayManager& pYMgr = pDoc.GetTrayManager(); for (size_t i = size_t(0); i < pYMgr.GetNumTraySets(); i++) { CTraySet& pYSet = pYMgr.GetTraySet(i); @@ -457,7 +456,7 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) } if (pYSet.IsOwned()) { - CB::string strOwner = pDoc->GetPlayerManager()->GetPlayerUsingMask( + CB::string strOwner = pDoc.GetPlayerManager()->GetPlayerUsingMask( pYSet.GetOwnerMask()).m_strName; CB::string strOwnedBy = CB::string::Format(IDS_TIP_OWNED_BY_PROJ, strOwner); str += strOwnedBy; @@ -744,10 +743,10 @@ void CGsnProjView::OnUpdateProjItemView(CCmdUI* pCmdUI) LRESULT CGsnProjView::OnMessageShowPlayingBoard(WPARAM wParam, LPARAM) { - CGamDoc* pDoc = GetDocument(); - CPlayBoard& pPBoard = pDoc->GetPBoardManager().GetPBoard(value_preserving_cast(wParam)); + CGamDoc& pDoc = GetDocument(); + CPlayBoard& pPBoard = pDoc.GetPBoardManager().GetPBoard(value_preserving_cast(wParam)); ASSERT(pPBoard.m_bOpenBoardOnLoad); - pDoc->CreateNewFrame(GetApp()->m_pBrdViewTmpl, + pDoc.CreateNewFrame(GetApp()->m_pBrdViewTmpl, pPBoard.GetBoard()->GetName(), &pPBoard); return (LRESULT)0; } @@ -759,6 +758,6 @@ LRESULT CGsnProjView::OnMessageShowPlayingBoard(WPARAM wParam, LPARAM) LRESULT CGsnProjView::OnMessageRestoreWinState(WPARAM, LPARAM) { - GetDocument()->RestoreWindowState(); + GetDocument().RestoreWindowState(); return (LRESULT)0; } diff --git a/GP/VwPrjgsn.h b/GP/VwPrjgsn.h index 44f7ff5..50287d5 100644 --- a/GP/VwPrjgsn.h +++ b/GP/VwPrjgsn.h @@ -67,7 +67,7 @@ class CGsnProjView : public CView, private CB::Impl::CGsnProjViewBase // Attributes public: - CGamDoc* GetDocument() { return CB::ToCGamDoc(m_pDocument); } + CGamDoc& GetDocument() { return CheckedDeref(CB::ToCGamDoc(m_pDocument)); } // Various controls... CProjListBox m_listProj; // Main project box From 4ae7301c15d852c1ea897b35c28486a952c39a1e Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sun, 3 Aug 2025 16:02:48 -0400 Subject: [PATCH 10/11] VwPrjgsn: create an extra window to simplify wx conversion MFC manages doc/frame/view objects, so split CGsnProjView into a parent window that MFC can manage and a child window that has the main implementation. That way we can convert the main implementation to wx while still letting MFC's doc/frame/view code work. --- GP/FrmProj.cpp | 3 ++- GP/Gp.cpp | 2 +- GP/VwPrjgsn.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++- GP/VwPrjgsn.h | 23 ++++++++++++++++++++--- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/GP/FrmProj.cpp b/GP/FrmProj.cpp index b85a8e6..7d3142e 100644 --- a/GP/FrmProj.cpp +++ b/GP/FrmProj.cpp @@ -89,7 +89,8 @@ void CProjFrame::OnSysCommand(UINT nID, LPARAM lParam) CView *pView = GetActiveView(); if (pView) { - if (pView->IsKindOf(RUNTIME_CLASS(CGsnProjView)) || + wxASSERT(!pView->IsKindOf(RUNTIME_CLASS(CGsnProjView))); + if (pView->IsKindOf(RUNTIME_CLASS(CGsnProjViewContainer)) || pView->IsKindOf(RUNTIME_CLASS(CGamProjView))) { CB::ToCGamDoc(GetActiveDocument())->OnFileClose(); diff --git a/GP/Gp.cpp b/GP/Gp.cpp index dd7c36c..eab940e 100644 --- a/GP/Gp.cpp +++ b/GP/Gp.cpp @@ -258,7 +258,7 @@ BOOL CGpApp::InitInstance() IDR_GSCNTYPE, RUNTIME_CLASS(CGamDoc), RUNTIME_CLASS(CProjFrame), - RUNTIME_CLASS(CGsnProjView)); + RUNTIME_CLASS(CGsnProjViewContainer)); AddDocTemplate(m_pScnDocTemplate); m_pBrdViewTmpl = new CMultiDocTemplate( diff --git a/GP/VwPrjgsn.cpp b/GP/VwPrjgsn.cpp index c07c5cf..fc1d269 100644 --- a/GP/VwPrjgsn.cpp +++ b/GP/VwPrjgsn.cpp @@ -38,7 +38,8 @@ static char THIS_FILE[] = __FILE__; #endif -IMPLEMENT_DYNCREATE(CGsnProjView, CView) +IMPLEMENT_DYNAMIC(CGsnProjView, CView) +IMPLEMENT_DYNCREATE(CGsnProjViewContainer, CView) #ifdef _DEBUG #define new DEBUG_NEW @@ -108,6 +109,11 @@ BEGIN_MESSAGE_MAP(CGsnProjView, CView) ON_MESSAGE(WM_WINSTATE_RESTORE, OnMessageRestoreWinState) END_MESSAGE_MAP() +BEGIN_MESSAGE_MAP(CGsnProjViewContainer, CView) + ON_WM_CREATE() + ON_WM_SIZE() +END_MESSAGE_MAP() + ///////////////////////////////////////////////////////////////////////////// // CGsnProjView @@ -761,3 +767,41 @@ LRESULT CGsnProjView::OnMessageRestoreWinState(WPARAM, LPARAM) GetDocument().RestoreWindowState(); return (LRESULT)0; } + +void CGsnProjViewContainer::OnDraw(CDC* pDC) +{ + // do nothing because child covers entire client rect +} + +CGsnProjViewContainer::CGsnProjViewContainer() : + child(new CGsnProjView) +{ +} + +int CGsnProjViewContainer::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CView::OnCreate(lpCreateStruct) == -1) + { + return -1; + } + + DWORD dwStyle = AFX_WS_DEFAULT_VIEW & ~WS_BORDER; + // Create with the right size (wrong position) + CRect rect; + GetClientRect(rect); + CCreateContext context; + context.m_pCurrentDoc = GetDocument(); + if (!child->Create(NULL, NULL, dwStyle, + rect, this, 0, &context)) + { + return -1; + } + + return 0; +} + +void CGsnProjViewContainer::OnSize(UINT nType, int cx, int cy) +{ + child->MoveWindow(0, 0, cx, cy); + return CView::OnSize(nType, cx, cy); +} diff --git a/GP/VwPrjgsn.h b/GP/VwPrjgsn.h index 50287d5..1ade350 100644 --- a/GP/VwPrjgsn.h +++ b/GP/VwPrjgsn.h @@ -61,9 +61,9 @@ namespace CB { namespace Impl class CGsnProjView : public CView, private CB::Impl::CGsnProjViewBase { - DECLARE_DYNCREATE(CGsnProjView) -protected: - CGsnProjView(); // protected constructor used by dynamic creation + DECLARE_DYNAMIC(CGsnProjView) +public: + CGsnProjView(); // Attributes public: @@ -158,6 +158,23 @@ class CGsnProjView : public CView, private CB::Impl::CGsnProjViewBase DECLARE_MESSAGE_MAP() }; +class CGsnProjViewContainer : public CView +{ +public: + void OnDraw(CDC* pDC) override; + +private: + CGsnProjViewContainer(); // used by dynamic creation + DECLARE_DYNCREATE(CGsnProjViewContainer) + + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + DECLARE_MESSAGE_MAP() + + // owned by MFC + RefPtr child; +}; + ///////////////////////////////////////////////////////////////////////////// #endif From 1eaa30d9523a43fb210e618b7e80702bb5232131 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sat, 9 Aug 2025 23:49:10 -0400 Subject: [PATCH 11/11] VwPrjgsn: replace MFC with wx --- GP/CBPlay.fbp | 716 ++++++++++++++++++++++++++++++++++++++++++++++++ GP/CBPlay.xrc | 170 ++++++++++++ GP/FrmProj.cpp | 1 - GP/VwPrjgs1.cpp | 68 ++--- GP/VwPrjgsn.cpp | 369 +++++++++++++------------ GP/VwPrjgsn.h | 117 +++++--- GShr/LibMfc.cpp | 26 +- 7 files changed, 1217 insertions(+), 250 deletions(-) diff --git a/GP/CBPlay.fbp b/GP/CBPlay.fbp index 8becc26..9a5a2cd 100644 --- a/GP/CBPlay.fbp +++ b/GP/CBPlay.fbp @@ -4316,6 +4316,534 @@ + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 0 + 1 + impl_virtual + + + 0 + wxID_ANY + + + CGsnProjView + + -1,-1 + ; ; forward_declare + + 0 + + + wxTAB_TRAVERSAL + + + bSizer80 + wxHORIZONTAL + none + + 5 + wxEXPAND + 0 + + + bSizer81 + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_listProj + 1 + + + protected + 1 + + Resizable + 1 + + + CProjListBoxGsn; forward_declare + 0 + + + + + + + + 5 + wxEXPAND + 0 + + + bSizer83 + wxHORIZONTAL + none + + 5 + wxTOP|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + MyButton + + 0 + + 0 + + + 0 + + 1 + m_btnPrjA + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + MyButton + + 0 + + 0 + + + 0 + + 1 + m_btnPrjB + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + MyButton + + 0 + + 0 + + + 0 + + 1 + m_btnPrjC + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_VERTICAL + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer82 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_listTrays + 1 + + + protected + 1 + + Resizable + 1 + + + CTrayListBoxWx; forward_declare + 0 + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 1 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_editInfo + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE|wxTE_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + 0 wxAUI_MGR_DEFAULT @@ -15075,5 +15603,193 @@ + + + + 1 + 0 + 1 + + + 0 + wxID_ANY + MyMenuBar + + + IDR_MENU_PLAYER_POPUPS + + + + ; ; forward_declare + + + + + + 0=PV_MOVEMODE + MENU_PV_MOVEMODE + protected + + + 1=PV_PLAYMODE + MENU_PV_PLAYMODE + protected + + + 2=PV_SCNMODE + MENU_PV_SCNMODE + protected + + + 3=PJ_GSN_DEFAULT + MENU_PJ_GSN_DEFAULT + protected + + + 0 + 1 + Create a new tray which are used to hold playing pieces + wxID_ANY + wxITEM_NORMAL + Create Playing Piece Tray... + ID_EDIT_CREATETRAY + none + + + + + + 0 + 1 + Create geomorphic board. Create Geomorphic Board + wxID_ANY + wxITEM_NORMAL + Create Geomorphic Board... + ID_EDIT_CREATE_GEOMORPHIC + none + + + + + m_separator1 + none + + + + 0 + 1 + Select the game boards that are used in this scenario + wxID_ANY + wxITEM_NORMAL + Select Game Boards... + ID_EDIT_SELECTBOARDS + none + + + + + + 0 + 1 + Select the game pieces that are used in this scenario + wxID_ANY + wxITEM_NORMAL + Select Game Pieces... + ID_EDIT_SELECTGAMEPIECES + none + + + + + m_separator2 + none + + + + 0 + 1 + View selected item. + wxID_ANY + wxITEM_NORMAL + View + ID_PPROJITEM_VIEW + none + + + + + m_separator3 + none + + + + 0 + 1 + Edit selected item. + wxID_ANY + wxITEM_NORMAL + Edit... + ID_PPROJITEM_EDIT + none + + + + + + 0 + 1 + Delete or Remove selected item. + wxID_ANY + wxITEM_NORMAL + Delete + ID_PPROJITEM_DELETE + none + + + + + m_separator4 + none + + + + 0 + 1 + Examine item properties. + wxID_ANY + wxITEM_NORMAL + Properties... + ID_PPROJITEM_PROPERTIES + none + + + + + + 4=PJ_GAM_DEFAULT + MENU_PJ_GAM_DEFAULT + protected + + + 5=PV_PIECE_TRAY + MENU_PV_PIECE_TRAY + protected + + + 6=MV_RICHEDIT + MENU_MV_RICHEDIT + protected + + + 7=ACT_TURNOVER + MENU_ACT_TURNOVER + protected + + + 8=PV_SELCT_BOX + MENU_PV_SELCT_BOX + protected + + diff --git a/GP/CBPlay.xrc b/GP/CBPlay.xrc index 4b02c94..40590c7 100644 --- a/GP/CBPlay.xrc +++ b/GP/CBPlay.xrc @@ -815,6 +815,103 @@ + + + + wxHORIZONTAL + + wxEXPAND + 5 + + + wxVERTICAL + + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 5 + + + + + wxEXPAND + 5 + + + wxHORIZONTAL + + wxTOP|wxBOTTOM|wxLEFT + 5 + + + + 0 + 0 + 0 + + + + + wxTOP|wxBOTTOM + 5 + + + + 0 + 0 + 0 + + + + + wxTOP|wxBOTTOM|wxRIGHT + 5 + + + + 0 + 0 + 0 + + + + + + + + + wxEXPAND + 5 + + + + + + + wxEXPAND + 5 + + + wxVERTICAL + + wxALL|wxEXPAND + 5 + + + + + wxALL|wxEXPAND + 5 + + + + 1 + + 0 + + + + + + Import Piece Groups @@ -2860,4 +2957,77 @@ + + + + + + + + + + + + + + + + Create a new tray which are used to hold playing pieces + + + + + Create geomorphic board.\nCreate Geomorphic Board + + + + + + Select the game boards that are used in this scenario + + + + + Select the game pieces that are used in this scenario + + + + + + View selected item. + + + + + + Edit selected item. + + + + + Delete or Remove selected item. + + + + + + Examine item properties. + + + + + + + + + + + + + + + + + + diff --git a/GP/FrmProj.cpp b/GP/FrmProj.cpp index 7d3142e..e10eda9 100644 --- a/GP/FrmProj.cpp +++ b/GP/FrmProj.cpp @@ -89,7 +89,6 @@ void CProjFrame::OnSysCommand(UINT nID, LPARAM lParam) CView *pView = GetActiveView(); if (pView) { - wxASSERT(!pView->IsKindOf(RUNTIME_CLASS(CGsnProjView))); if (pView->IsKindOf(RUNTIME_CLASS(CGsnProjViewContainer)) || pView->IsKindOf(RUNTIME_CLASS(CGamProjView))) { diff --git a/GP/VwPrjgs1.cpp b/GP/VwPrjgs1.cpp index de8de22..5edadb3 100644 --- a/GP/VwPrjgs1.cpp +++ b/GP/VwPrjgs1.cpp @@ -66,7 +66,7 @@ void CGsnProjView::DoUpdateGsnInfo() str += "AUTHOR: " + pDoc.m_strScnAuthor + "\r\n\r\n"; if (!pDoc.m_strScnDescr.empty()) str += "DESCRIPTION:\r\n\r\n" + pDoc.m_strScnDescr; - m_editInfo.SetWindowText(str); + m_editInfo->SetValue(str); } ///////////////////////////////////////////////////////////////////////////// @@ -80,20 +80,20 @@ void CGsnProjView::DoBoardSelection() void CGsnProjView::DoBoardProperty() { CGamDoc& pDoc = GetDocument(); - int nSel = m_listProj.GetCurSel(); - ASSERT(nSel >= 0); - ASSERT(m_listProj.GetItemGroupCode(nSel) == grpBrd); - size_t nBrd = m_listProj.GetItemSourceCode(nSel); + int nSel = m_listProj->GetSelection(); + wxASSERT(nSel != wxNOT_FOUND); + wxASSERT(m_listProj->GetItemGroupCode(value_preserving_cast(nSel)) == grpBrd); + size_t nBrd = m_listProj->GetItemSourceCode(value_preserving_cast(nSel)); pDoc.DoBoardProperties(nBrd); } void CGsnProjView::DoBoardView() { CGamDoc& pDoc = GetDocument(); - int nSel = m_listProj.GetCurSel(); - ASSERT(nSel >= 0); - ASSERT(m_listProj.GetItemGroupCode(nSel) == grpBrd); - size_t nBrd = m_listProj.GetItemSourceCode(nSel); + int nSel = m_listProj->GetSelection(); + wxASSERT(nSel != wxNOT_FOUND); + wxASSERT(m_listProj->GetItemGroupCode(value_preserving_cast(nSel)) == grpBrd); + size_t nBrd = m_listProj->GetItemSourceCode(value_preserving_cast(nSel)); CPlayBoard& pPBoard = pDoc.GetPBoardManager().GetPBoard(nBrd); CView* pView = pDoc.FindPBoardView(pPBoard); @@ -101,12 +101,12 @@ void CGsnProjView::DoBoardView() { // This board already has an editor. Activate that view. CFrameWnd* pFrm = pView->GetParentFrame(); - ASSERT(pFrm); + wxASSERT(pFrm); pFrm->ActivateFrame(); } else { - CB::string strTitle = m_listProj.GetItemText(nSel); + CB::string strTitle = m_listProj->GetItemText(value_preserving_cast(nSel)); pDoc.CreateNewFrame(GetApp()->m_pBrdViewTmpl, strTitle, &pPBoard); } } @@ -115,10 +115,10 @@ void CGsnProjView::DoBoardRemove() { CGamDoc& pDoc = GetDocument(); - int nSel = m_listProj.GetCurSel(); - ASSERT(nSel >= 0); - ASSERT(m_listProj.GetItemGroupCode(nSel) == grpBrd); - size_t nBrd = m_listProj.GetItemSourceCode(nSel); + int nSel = m_listProj->GetSelection(); + wxASSERT(nSel != wxNOT_FOUND); + wxASSERT(m_listProj->GetItemGroupCode(value_preserving_cast(nSel)) == grpBrd); + size_t nBrd = m_listProj->GetItemSourceCode(value_preserving_cast(nSel)); pDoc.GetPBoardManager().DeletePBoard(nBrd); pDoc.SetModifiedFlag(TRUE); @@ -127,12 +127,12 @@ void CGsnProjView::DoBoardRemove() void CGsnProjView::DoUpdateBoardHelpInfo() { - m_editInfo.SetWindowText(""_cbstring); + m_editInfo->Clear(); } void CGsnProjView::DoUpdateBoardInfo() { - m_editInfo.SetWindowText(""_cbstring); + m_editInfo->Clear(); } ///////////////////////////////////////////////////////////////////////////// @@ -146,10 +146,10 @@ void CGsnProjView::DoTrayCreate() void CGsnProjView::DoTrayProperty() { CGamDoc& pDoc = GetDocument(); - int nSel = m_listProj.GetCurSel(); - ASSERT(nSel >= 0); - ASSERT(m_listProj.GetItemGroupCode(nSel) == grpTray); - size_t nGrp = m_listProj.GetItemSourceCode(nSel); + int nSel = m_listProj->GetSelection(); + wxASSERT(nSel != wxNOT_FOUND); + wxASSERT(m_listProj->GetItemGroupCode(value_preserving_cast(nSel)) == grpTray); + size_t nGrp = m_listProj->GetItemSourceCode(value_preserving_cast(nSel)); CTrayPropDialog dlg(pDoc.GetTrayManager(), pDoc.GetPlayerManager()); @@ -188,10 +188,10 @@ void CGsnProjView::DoTrayProperty() void CGsnProjView::DoTrayEdit() { CGamDoc& pDoc = GetDocument(); - int nSel = m_listProj.GetCurSel(); - wxASSERT(nSel >= 0); - wxASSERT(m_listProj.GetItemGroupCode(nSel) == grpTray); - size_t nGrp = m_listProj.GetItemSourceCode(nSel); + int nSel = m_listProj->GetSelection(); + wxASSERT(nSel != wxNOT_FOUND); + wxASSERT(m_listProj->GetItemGroupCode(value_preserving_cast(nSel)) == grpTray); + size_t nGrp = m_listProj->GetItemSourceCode(value_preserving_cast(nSel)); CTrayManager& pYMgr = pDoc.GetTrayManager(); CSetPiecesDialog dlg(pDoc); @@ -215,10 +215,10 @@ void CGsnProjView::DoTrayDelete() CTrayManager& pYMgr = pDoc.GetTrayManager(); CPieceTable& pPTbl = pDoc.GetPieceTable(); - int nSel = m_listProj.GetCurSel(); - ASSERT(nSel >= 0); - ASSERT(m_listProj.GetItemGroupCode(nSel) == grpTray); - size_t nGrp = m_listProj.GetItemSourceCode(nSel); + int nSel = m_listProj->GetSelection(); + wxASSERT(nSel != wxNOT_FOUND); + wxASSERT(m_listProj->GetItemGroupCode(value_preserving_cast(nSel)) == grpTray); + size_t nGrp = m_listProj->GetItemSourceCode(value_preserving_cast(nSel)); if (!pYMgr.GetTraySet(nGrp).IsEmpty()) { @@ -238,17 +238,17 @@ void CGsnProjView::DoTrayDelete() void CGsnProjView::DoUpdateTrayHelpInfo() { - m_editInfo.SetWindowText(""_cbstring); + m_editInfo->Clear(); } void CGsnProjView::DoUpdateTrayList() { CGamDoc& pDoc = GetDocument(); - int nSel = m_listProj.GetCurSel(); - ASSERT(nSel >= 0); - ASSERT(m_listProj.GetItemGroupCode(nSel) == grpTray); - size_t nGrp = m_listProj.GetItemSourceCode(nSel); + int nSel = m_listProj->GetSelection(); + wxASSERT(nSel != wxNOT_FOUND); + wxASSERT(m_listProj->GetItemGroupCode(value_preserving_cast(nSel)) == grpTray); + size_t nGrp = m_listProj->GetItemSourceCode(value_preserving_cast(nSel)); CTraySet& pYGrp = pDoc.GetTrayManager().GetTraySet(nGrp); const std::vector& pLstMap = pYGrp.GetPieceIDTable(); diff --git a/GP/VwPrjgsn.cpp b/GP/VwPrjgsn.cpp index fc1d269..6e8f279 100644 --- a/GP/VwPrjgsn.cpp +++ b/GP/VwPrjgsn.cpp @@ -38,13 +38,14 @@ static char THIS_FILE[] = __FILE__; #endif -IMPLEMENT_DYNAMIC(CGsnProjView, CView) +wxIMPLEMENT_DYNAMIC_CLASS(CProjListBoxGsn, CProjListBoxBaseWx) IMPLEMENT_DYNCREATE(CGsnProjViewContainer, CView) #ifdef _DEBUG #define new DEBUG_NEW #endif +#if 0 ///////////////////////////////////////////////////////////////////////////// const int XBORDER = 5; @@ -57,6 +58,7 @@ const int BTN_PROJ_WD = 14 * 4; const int BTN_PROJ_HT = 12; const int PROJ_LIST_WIDTH = 250; +#endif ///////////////////////////////////////////////////////////////////////////// // Button content tables - selected based on current type of item selected @@ -83,50 +85,65 @@ static UINT * btnGroupTbl[nNumGroups + 1] = ///////////////////////////////////////////////////////////////////////////// -BEGIN_MESSAGE_MAP(CGsnProjView, CView) - //{{AFX_MSG_MAP(CGsnProjView) +wxBEGIN_EVENT_TABLE(CGsnProjView, wxPanel) +#if 0 ON_WM_SIZE() ON_WM_CREATE() - ON_LBN_SELCHANGE(IDC_V_GSN_PROJLIST, OnSelChangeProjList) - ON_LBN_DBLCLK(IDC_V_GSN_PROJLIST, OnDblClkProjList) - ON_BN_CLICKED(IDC_V_GSN_BTN_PRJA, OnClickedProjBtnA) - ON_BN_CLICKED(IDC_V_GSN_BTN_PRJB, OnClickedProjBtnB) - ON_BN_CLICKED(IDC_V_GSN_BTN_PRJC, OnClickedProjBtnC) +#endif + EVT_LISTBOX(XRCID("m_listProj"), OnSelChangeProjList) + EVT_LISTBOX_DCLICK(XRCID("m_listProj"), OnDblClkProjList) + EVT_BUTTON(XRCID("m_btnPrjA"), OnClickedProjBtnA) + EVT_BUTTON(XRCID("m_btnPrjB"), OnClickedProjBtnB) + EVT_BUTTON(XRCID("m_btnPrjC"), OnClickedProjBtnC) +#if 0 ON_WM_ERASEBKGND() - ON_COMMAND(ID_EDIT_BRDPROP, OnEditBoardProperties) - ON_UPDATE_COMMAND_UI(ID_EDIT_BRDPROP, OnUpdateEditBoardProperties) - ON_WM_CONTEXTMENU() - ON_COMMAND(ID_PPROJITEM_EDIT, OnProjItemEdit) - ON_UPDATE_COMMAND_UI(ID_PPROJITEM_EDIT, OnUpdateProjItemEdit) - ON_COMMAND(ID_PPROJITEM_DELETE, OnProjItemDelete) - ON_UPDATE_COMMAND_UI(ID_PPROJITEM_DELETE, OnUpdateProjItemDelete) - ON_COMMAND(ID_PPROJITEM_PROPERTIES, OnProjItemProperties) - ON_UPDATE_COMMAND_UI(ID_PPROJITEM_PROPERTIES, OnUpdateProjItemProperties) - ON_COMMAND(ID_PPROJITEM_VIEW, OnProjItemView) - ON_UPDATE_COMMAND_UI(ID_PPROJITEM_VIEW, OnUpdateProjItemView) - //}}AFX_MSG_MAP - ON_MESSAGE(WM_SHOWPLAYINGBOARD, OnMessageShowPlayingBoard) - ON_MESSAGE(WM_WINSTATE_RESTORE, OnMessageRestoreWinState) -END_MESSAGE_MAP() +#endif + EVT_MENU(XRCID("ID_EDIT_BRDPROP"), OnEditBoardProperties) + EVT_UPDATE_UI(XRCID("ID_EDIT_BRDPROP"), OnUpdateEditBoardProperties) + EVT_CONTEXT_MENU(OnContextMenu) + EVT_MENU(XRCID("ID_PPROJITEM_EDIT"), OnProjItemEdit) + EVT_UPDATE_UI(XRCID("ID_PPROJITEM_EDIT"), OnUpdateProjItemEdit) + EVT_MENU(XRCID("ID_PPROJITEM_DELETE"), OnProjItemDelete) + EVT_UPDATE_UI(XRCID("ID_PPROJITEM_DELETE"), OnUpdateProjItemDelete) + EVT_MENU(XRCID("ID_PPROJITEM_PROPERTIES"), OnProjItemProperties) + EVT_UPDATE_UI(XRCID("ID_PPROJITEM_PROPERTIES"), OnUpdateProjItemProperties) + EVT_MENU(XRCID("ID_PPROJITEM_VIEW"), OnProjItemView) + EVT_UPDATE_UI(XRCID("ID_PPROJITEM_VIEW"), OnUpdateProjItemView) + EVT_SHOWPLAYINGBOARD(OnMessageShowPlayingBoard) + EVT_WINSTATE_RESTORE(OnMessageRestoreWinState) +wxEND_EVENT_TABLE() BEGIN_MESSAGE_MAP(CGsnProjViewContainer, CView) ON_WM_CREATE() - ON_WM_SIZE() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGsnProjView -CGsnProjView::CGsnProjView() +CGsnProjView::CGsnProjView(CGsnProjViewContainer& p) : + CB_XRC_BEGIN_CTRLS_DEFN(static_cast(p), CGsnProjView) + CB_XRC_CTRL(m_listProj) + CB_XRC_CTRL(m_editInfo) + CB_XRC_CTRL(m_listTrays) + CB_XRC_CTRL(m_btnPrjA) + CB_XRC_CTRL(m_btnPrjB) + CB_XRC_CTRL(m_btnPrjC) + CB_XRC_END_CTRLS_DEFN(), + parent(&p), + document(dynamic_cast(parent->GetDocument())) { m_nLastSel = -1; m_nLastGrp = -1; + + m_listTrays->Init(GetDocument()); + m_listTrays->SetTrayContentVisibility(trayVizAllSides); } CGsnProjView::~CGsnProjView() { } +#if 0 int CGsnProjView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) @@ -171,13 +188,13 @@ int CGsnProjView::OnCreate(LPCREATESTRUCT lpCreateStruct) return 0; } +#endif ///////////////////////////////////////////////////////////////////////////// void CGsnProjView::OnInitialUpdate() { GetDocument().DoInitialUpdate(); // Since UpdateAllViews isn't virtual - CView::OnInitialUpdate(); CGamDoc& pDoc = GetDocument(); CPBoardManager& pPBMgr = pDoc.GetPBoardManager(); // Only honor the open-on-load flags if the save window state @@ -191,12 +208,16 @@ void CGsnProjView::OnInitialUpdate() { // Defer opening the view until our view init // in done. - PostMessage(WM_SHOWPLAYINGBOARD, value_preserving_cast(i)); + ShowPlayingBoardEvent event(i); + AddPendingEvent(event); } } } else - PostMessage(WM_WINSTATE_RESTORE); + { + WinStateRestoreEvent event; + AddPendingEvent(event); + } } void CGsnProjView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) @@ -215,6 +236,7 @@ void CGsnProjView::OnDraw(CDC* pDC) // TODO: add draw code here } +#if 0 BOOL CGsnProjView::OnEraseBkgnd(CDC* pDC) { CBrush brFill(GetSysColor(COLOR_BTNFACE)); @@ -350,6 +372,7 @@ BOOL CGsnProjView::CreateEditbox(UINT nCtrlID, CEdit& ebox, CRect& rct) ebox.SetFont(CFont::FromHandle(g_res.h8ss)); return bOk; } +#endif ///////////////////////////////////////////////////////////////////////////// // Updates buttons for specified group @@ -358,21 +381,21 @@ void CGsnProjView::UpdateButtons(int nGrp) { nGrp++; // -1 means no selection so bump to zero UINT* pTbl = btnGroupTbl[nGrp]; - SetButtonState(m_btnPrjA, pTbl[0]); - SetButtonState(m_btnPrjB, pTbl[1]); - SetButtonState(m_btnPrjC, pTbl[2]); + SetButtonState(*m_btnPrjA, pTbl[0]); + SetButtonState(*m_btnPrjB, pTbl[1]); + SetButtonState(*m_btnPrjC, pTbl[2]); } -void CGsnProjView::SetButtonState(CButton& btn, UINT nStringID) +void CGsnProjView::SetButtonState(wxButton& btn, UINT nStringID) { if (nStringID == 0) - btn.SetWindowText(""_cbstring); + btn.SetLabel(""_cbstring); else { CB::string str = CB::string::LoadString(nStringID); - btn.SetWindowText(str); + btn.SetLabel(str); } - btn.EnableWindow(nStringID != 0); + btn.Enable(nStringID != 0); } ///////////////////////////////////////////////////////////////////////////// @@ -380,22 +403,20 @@ void CGsnProjView::SetButtonState(CButton& btn, UINT nStringID) void CGsnProjView::UpdateItemControls(int nGrp) { - HDWP hDwp = BeginDeferWindowPos(4); - #define EzDefer(h, c, flg) \ - DeferWindowPos(h, (c).m_hWnd, NULL, 0, 0, 0, 0, \ - SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | flg) + wxWindowUpdateLocker freezer(this); + ChildrenRepositioningGuard crg(this); + m_listTrays->Hide(); + m_editInfo->Hide(); if (nGrp == grpTray) // Trays { - hDwp = EzDefer(hDwp, *m_listTrays, SWP_SHOWWINDOW); - hDwp = EzDefer(hDwp, m_editInfo, SWP_HIDEWINDOW); + m_listTrays->Show(); } else // Board, headings and no selection { - hDwp = EzDefer(hDwp, m_editInfo, SWP_SHOWWINDOW); - hDwp = EzDefer(hDwp, *m_listTrays, SWP_HIDEWINDOW); + m_editInfo->Show(); } - EndDeferWindowPos(hDwp); + Layout(); } ///////////////////////////////////////////////////////////////////////////// @@ -409,21 +430,22 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) } CGamDoc& pDoc = GetDocument(); - m_listProj.SetRedraw(FALSE); - // Preserve the current selection - int nTopIdx = m_listProj.GetTopIndex(); - int nCurSel = m_listProj.GetCurSel(); + size_t nTopIdx = m_listProj->GetVisibleRowsBegin(); + int nCurSel = m_listProj->GetSelection(); + + { + wxWindowUpdateLocker freezer(&*m_listProj); - m_listProj.ResetContent(); + m_listProj->Clear(); // Document type.... CB::string str = CB::string::LoadString(IDS_PHEAD_GSN_DOCTYPE); - m_listProj.AddItem(grpDoc, str); + m_listProj->AddItem(grpDoc, str); // Boards.... str = CB::string::LoadString(IDS_PHEAD_GSN_BOARDS); - m_listProj.AddItem(grpBrdHdr, str); + m_listProj->AddItem(grpBrdHdr, str); CPBoardManager& pPBMgr = pDoc.GetPBoardManager(); for (size_t i = size_t(0); i < pPBMgr.GetNumPBoards(); i++) @@ -443,12 +465,12 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) CB::string strOwnedBy = CB::string::Format(IDS_TIP_OWNED_BY_PROJ, strOwner); str += strOwnedBy; } - m_listProj.AddItem(grpBrd, str, i); + m_listProj->AddItem(grpBrd, str, i); } // Trays.... str = CB::string::LoadString(IDS_PHEAD_GSN_TRAYS); - m_listProj.AddItem(grpTrayHdr, str); + m_listProj->AddItem(grpTrayHdr, str); CTrayManager& pYMgr = pDoc.GetTrayManager(); for (size_t i = size_t(0); i < pYMgr.GetNumTraySets(); i++) @@ -467,22 +489,22 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) CB::string strOwnedBy = CB::string::Format(IDS_TIP_OWNED_BY_PROJ, strOwner); str += strOwnedBy; } - m_listProj.AddItem(grpTray, str, i); + m_listProj->AddItem(grpTray, str, i); } // OK...Show the updates - m_listProj.SetRedraw(TRUE); - m_listProj.Invalidate(); + } + m_listProj->Refresh(); - m_listProj.SetTopIndex(nTopIdx); - if (nCurSel >= 0) + m_listProj->ScrollToRow(nTopIdx); + if (nCurSel != wxNOT_FOUND) { - if (nCurSel >= m_listProj.GetCount()) - nCurSel = m_listProj.GetCount() - 1; - m_listProj.SetCurSel(nCurSel); + if (nCurSel >= m_listProj->GetItemCount()) + nCurSel = value_preserving_cast(m_listProj->GetItemCount() - size_t(1)); + m_listProj->SetSelection(nCurSel); } else - m_listProj.SetCurSel(0); + m_listProj->SetSelection(0); if (bUpdateItem) { @@ -495,14 +517,14 @@ void CGsnProjView::DoUpdateProjectList(BOOL bUpdateItem /* = TRUE */) ///////////////////////////////////////////////////////////////////////////// // List box notifications -void CGsnProjView::OnSelChangeProjList() +void CGsnProjView::OnSelChangeProjList(wxCommandEvent& /*event*/) { - int nSel = m_listProj.GetCurSel(); + int nSel = m_listProj->GetSelection(); if (m_nLastSel == nSel) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpDoc) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpDoc: DoUpdateGsnInfo(); break; @@ -519,13 +541,13 @@ void CGsnProjView::OnSelChangeProjList() } } -void CGsnProjView::OnDblClkProjList() +void CGsnProjView::OnDblClkProjList(wxCommandEvent& event) { - int nSel = m_listProj.GetCurSel(); - if (nSel < 0) + int nSel = m_listProj->GetSelection(); + if (nSel == wxNOT_FOUND) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpDoc) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpDoc: DoGsnProperty(); break; @@ -539,12 +561,12 @@ void CGsnProjView::OnDblClkProjList() ///////////////////////////////////////////////////////////////////////////// // Button notifications -void CGsnProjView::OnClickedProjBtnA() +void CGsnProjView::OnClickedProjBtnA(wxCommandEvent& event) { - int nSel = m_listProj.GetCurSel(); - if (nSel < 0) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + int nSel = m_listProj->GetSelection(); + if (nSel == wxNOT_FOUND) return; + decltype(grpDoc) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpDoc: DoGsnProperty(); break; @@ -555,12 +577,12 @@ void CGsnProjView::OnClickedProjBtnA() } } -void CGsnProjView::OnClickedProjBtnB() +void CGsnProjView::OnClickedProjBtnB(wxCommandEvent& event) { - int nSel = m_listProj.GetCurSel(); - if (nSel < 0) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + int nSel = m_listProj->GetSelection(); + if (nSel == wxNOT_FOUND) return; + decltype(grpDoc) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpBrd: DoBoardProperty(); break; @@ -568,12 +590,12 @@ void CGsnProjView::OnClickedProjBtnB() } } -void CGsnProjView::OnClickedProjBtnC() +void CGsnProjView::OnClickedProjBtnC(wxCommandEvent& event) { - int nSel = m_listProj.GetCurSel(); - if (nSel < 0) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + int nSel = m_listProj->GetSelection(); + if (nSel == wxNOT_FOUND) return; + decltype(grpDoc) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpBrd: DoBoardRemove(); break; @@ -581,80 +603,79 @@ void CGsnProjView::OnClickedProjBtnC() } } -void CGsnProjView::OnEditBoardProperties() +void CGsnProjView::OnEditBoardProperties(wxCommandEvent& event) { DoBoardProperty(); } -void CGsnProjView::OnUpdateEditBoardProperties(CCmdUI* pCmdUI) +void CGsnProjView::OnUpdateEditBoardProperties(wxUpdateUIEvent& pCmdUI) { - int nSel = m_listProj.GetCurSel(); - pCmdUI->Enable(nSel >= 0 && - m_listProj.GetItemGroupCode(nSel) == grpBrd); + int nSel = m_listProj->GetSelection(); + pCmdUI.Enable(nSel != wxNOT_FOUND && + m_listProj->GetItemGroupCode(value_preserving_cast(nSel)) == grpBrd); } -void CGsnProjView::OnContextMenu(CWnd* pWnd, CPoint point) +void CGsnProjView::OnContextMenu(wxContextMenuEvent& event) { - // Make sure window is active. - GetParentFrame()->ActivateFrame(); - UINT nID = (UINT)-1; + const char* nID = nullptr; - if (pWnd->GetDlgCtrlID() == IDC_V_GSN_PROJLIST) - nID = MENU_PJ_GSN_DEFAULT; + if (event.GetEventObject() == &*m_listProj) + nID = "3=PJ_GSN_DEFAULT"; - if ((int)nID < 0) + if (!nID) return; - CMenu bar; - if (bar.LoadMenuW(IDR_MENU_PLAYER_POPUPS)) + std::unique_ptr bar(wxXmlResource::Get()->LoadMenuBar("IDR_MENU_PLAYER_POPUPS")); + if (bar) { - CMenu& popup = *bar.GetSubMenu(nID); - ASSERT(popup.m_hMenu != NULL); + int index = bar->FindMenu(nID); + wxASSERT(index != wxNOT_FOUND); + std::unique_ptr popup(bar->Remove(value_preserving_cast(index))); // Make sure we clean up even if exception is tossed. - TRY + try { - popup.TrackPopupMenu(TPM_RIGHTBUTTON, point.x, point.y, - AfxGetMainWnd()); // Route commands through main window - // Make sure command is dispatched BEFORE we clear m_bInRightMouse. - GetApp()->DispatchMessages(); + PopupMenu(&*popup); + } + catch (...) + { + wxASSERT(!"exception"); } - END_TRY } } -void CGsnProjView::OnProjItemEdit() +void CGsnProjView::OnProjItemEdit(wxCommandEvent& event) { - int nSel = m_listProj.GetCurSel(); - if (nSel < 0) + int nSel = m_listProj->GetSelection(); + if (nSel == wxNOT_FOUND) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpTray) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); if (nGrp == grpTray) DoTrayEdit(); } -void CGsnProjView::OnUpdateProjItemEdit(CCmdUI* pCmdUI) +void CGsnProjView::OnUpdateProjItemEdit(wxUpdateUIEvent& pCmdUI) { BOOL bEnable = FALSE; - int nSel = m_listProj.GetCurSel(); - if (nSel >= 0) + int nSel = m_listProj->GetSelection(); + if (nSel != wxNOT_FOUND) { - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpTray) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); if (nGrp == grpTray) bEnable = TRUE; } - pCmdUI->Enable(bEnable); + pCmdUI.Enable(bEnable); } -void CGsnProjView::OnProjItemDelete() +void CGsnProjView::OnProjItemDelete(wxCommandEvent& event) { - int nSel = m_listProj.GetCurSel(); - if (nSel < 0) + int nSel = m_listProj->GetSelection(); + if (nSel == wxNOT_FOUND) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpBrd) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpBrd: DoBoardRemove(); break; @@ -662,14 +683,14 @@ void CGsnProjView::OnProjItemDelete() } } -void CGsnProjView::OnUpdateProjItemDelete(CCmdUI* pCmdUI) +void CGsnProjView::OnUpdateProjItemDelete(wxUpdateUIEvent& pCmdUI) { BOOL bEnable = FALSE; - int nSel = m_listProj.GetCurSel(); - if (nSel >= 0) + int nSel = m_listProj->GetSelection(); + if (nSel != wxNOT_FOUND) { - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpBrd) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpBrd: @@ -679,16 +700,16 @@ void CGsnProjView::OnUpdateProjItemDelete(CCmdUI* pCmdUI) default: ; } } - pCmdUI->Enable(bEnable); + pCmdUI.Enable(bEnable); } -void CGsnProjView::OnProjItemProperties() +void CGsnProjView::OnProjItemProperties(wxCommandEvent& event) { - int nSel = m_listProj.GetCurSel(); - if (nSel < 0) + int nSel = m_listProj->GetSelection(); + if (nSel == wxNOT_FOUND) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpDoc) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpDoc: DoGsnProperty(); break; @@ -697,14 +718,14 @@ void CGsnProjView::OnProjItemProperties() } } -void CGsnProjView::OnUpdateProjItemProperties(CCmdUI* pCmdUI) +void CGsnProjView::OnUpdateProjItemProperties(wxUpdateUIEvent& pCmdUI) { BOOL bEnable = FALSE; - int nSel = m_listProj.GetCurSel(); - if (nSel >= 0) + int nSel = m_listProj->GetSelection(); + if (nSel != wxNOT_FOUND) { - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpDoc) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); switch (nGrp) { case grpDoc: @@ -715,31 +736,31 @@ void CGsnProjView::OnUpdateProjItemProperties(CCmdUI* pCmdUI) default: ; } } - pCmdUI->Enable(bEnable); + pCmdUI.Enable(bEnable); } -void CGsnProjView::OnProjItemView() +void CGsnProjView::OnProjItemView(wxCommandEvent& event) { - int nSel = m_listProj.GetCurSel(); - if (nSel < 0) return; - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + int nSel = m_listProj->GetSelection(); + if (nSel == wxNOT_FOUND) return; + decltype(grpBrd) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); if (nGrp == grpBrd) DoBoardView(); } -void CGsnProjView::OnUpdateProjItemView(CCmdUI* pCmdUI) +void CGsnProjView::OnUpdateProjItemView(wxUpdateUIEvent& pCmdUI) { BOOL bEnable = FALSE; - int nSel = m_listProj.GetCurSel(); - if (nSel >= 0) + int nSel = m_listProj->GetSelection(); + if (nSel != wxNOT_FOUND) { - int nGrp = m_listProj.GetItemGroupCode(nSel); - ASSERT(nGrp >= 0); + decltype(grpBrd) nGrp = m_listProj->GetItemGroupCode(value_preserving_cast(nSel)); + wxASSERT(nGrp >= 0); if (nGrp == grpBrd) bEnable = TRUE; } - pCmdUI->Enable(bEnable); + pCmdUI.Enable(bEnable); } /////////////////////////////////////////////////////////////////////// @@ -747,14 +768,13 @@ void CGsnProjView::OnUpdateProjItemView(CCmdUI* pCmdUI) // message is posted during view initial update if the playing // board m_bOpenBoardOnLoad option is set. (wParam = the board index) -LRESULT CGsnProjView::OnMessageShowPlayingBoard(WPARAM wParam, LPARAM) +void CGsnProjView::OnMessageShowPlayingBoard(ShowPlayingBoardEvent& event) { CGamDoc& pDoc = GetDocument(); - CPlayBoard& pPBoard = pDoc.GetPBoardManager().GetPBoard(value_preserving_cast(wParam)); - ASSERT(pPBoard.m_bOpenBoardOnLoad); + CPlayBoard& pPBoard = pDoc.GetPBoardManager().GetPBoard(event.GetPlayingBoardIndex()); + wxASSERT(pPBoard.m_bOpenBoardOnLoad); pDoc.CreateNewFrame(GetApp()->m_pBrdViewTmpl, pPBoard.GetBoard()->GetName(), &pPBoard); - return (LRESULT)0; } /////////////////////////////////////////////////////////////////////// @@ -762,10 +782,9 @@ LRESULT CGsnProjView::OnMessageShowPlayingBoard(WPARAM wParam, LPARAM) // message is posted during view initial update if the state of // the windows should be restored. -LRESULT CGsnProjView::OnMessageRestoreWinState(WPARAM, LPARAM) +void CGsnProjView::OnMessageRestoreWinState(WinStateRestoreEvent& event) { GetDocument().RestoreWindowState(); - return (LRESULT)0; } void CGsnProjViewContainer::OnDraw(CDC* pDC) @@ -773,8 +792,22 @@ void CGsnProjViewContainer::OnDraw(CDC* pDC) // do nothing because child covers entire client rect } +void CGsnProjViewContainer::OnInitialUpdate() +{ + child->OnInitialUpdate(); + + BASE::OnInitialUpdate(); +} + +void CGsnProjViewContainer::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) +{ + child->OnUpdate(pSender, lHint, pHint); + + BASE::OnUpdate(pSender, lHint, pHint); +} + CGsnProjViewContainer::CGsnProjViewContainer() : - child(new CGsnProjView) + CB::wxNativeContainerWindowMixin(static_cast(*this)) { } @@ -785,23 +818,7 @@ int CGsnProjViewContainer::OnCreate(LPCREATESTRUCT lpCreateStruct) return -1; } - DWORD dwStyle = AFX_WS_DEFAULT_VIEW & ~WS_BORDER; - // Create with the right size (wrong position) - CRect rect; - GetClientRect(rect); - CCreateContext context; - context.m_pCurrentDoc = GetDocument(); - if (!child->Create(NULL, NULL, dwStyle, - rect, this, 0, &context)) - { - return -1; - } + child = new CGsnProjView(*this); return 0; } - -void CGsnProjViewContainer::OnSize(UINT nType, int cx, int cy) -{ - child->MoveWindow(0, 0, cx, cy); - return CView::OnSize(nType, cx, cy); -} diff --git a/GP/VwPrjgsn.h b/GP/VwPrjgsn.h index 1ade350..943d653 100644 --- a/GP/VwPrjgsn.h +++ b/GP/VwPrjgsn.h @@ -1,6 +1,6 @@ // VwPrjgsn.h : header file // -// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved. +// Copyright (c) 1994-2025 By Dale L. Larson & William Su, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -59,25 +59,33 @@ namespace CB { namespace Impl }; }} -class CGsnProjView : public CView, private CB::Impl::CGsnProjViewBase +class CGsnProjViewContainer; + +class CProjListBoxGsn : public CProjListBoxWx +{ + wxDECLARE_DYNAMIC_CLASS(CProjListBoxGsn); +}; + +class CGsnProjView : public CB::ProcessEventOverride, private CB::Impl::CGsnProjViewBase { - DECLARE_DYNAMIC(CGsnProjView) public: - CGsnProjView(); + CGsnProjView(CGsnProjViewContainer& p); // Attributes -public: - CGamDoc& GetDocument() { return CheckedDeref(CB::ToCGamDoc(m_pDocument)); } +private: + CGamDoc& GetDocument() { return *document; } // Various controls... - CProjListBox m_listProj; // Main project box + CB_XRC_BEGIN_CTRLS_DECL() + RefPtr m_listProj; // Main project box - CEdit m_editInfo; // Used for various project info/help - OwnerOrNullPtr m_listTrays; // For viewing tray contents + RefPtr m_editInfo; // Used for various project info/help + RefPtr m_listTrays; // For viewing tray contents - CButton m_btnPrjA; // Project button group - CButton m_btnPrjB; - CButton m_btnPrjC; + RefPtr m_btnPrjA; // Project button group + RefPtr m_btnPrjB; + RefPtr m_btnPrjC; + CB_XRC_END_CTRLS_DECL() // Operations public: @@ -89,11 +97,13 @@ class CGsnProjView : public CView, private CB::Impl::CGsnProjViewBase // Implementation protected: +#if 0 int CreateButton(UINT nCtrlID, CButton& btn, CPoint llpos, CSize relsize); BOOL CreateListbox(UINT nCtrlID, CListBox& lbox, DWORD dwStyle, CRect& rct); BOOL CreateEditbox(UINT nCtrlID, CEdit& ebox, CRect& rct); +#endif - void SetButtonState(CButton& btn, UINT nStringID); + void SetButtonState(wxButton& btn, UINT nStringID); void UpdateButtons(int nGrp = -1); void UpdateItemControls(int nGrp = -1); @@ -132,49 +142,82 @@ class CGsnProjView : public CView, private CB::Impl::CGsnProjViewBase // Generated message map functions protected: //{{AFX_MSG(CGsnProjView) +#if 0 afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSelChangeProjList(); - afx_msg void OnDblClkProjList(); - afx_msg void OnClickedProjBtnA(); - afx_msg void OnClickedProjBtnB(); - afx_msg void OnClickedProjBtnC(); +#endif + void OnSelChangeProjList(wxCommandEvent& event); + void OnSelChangeProjList() + { + wxCommandEvent dummy; + OnSelChangeProjList(dummy); + } + void OnDblClkProjList(wxCommandEvent& event); + void OnClickedProjBtnA(wxCommandEvent& event); + void OnClickedProjBtnB(wxCommandEvent& event); + void OnClickedProjBtnC(wxCommandEvent& event); +#if 0 afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnEditBoardProperties(); - afx_msg void OnUpdateEditBoardProperties(CCmdUI* pCmdUI); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnProjItemEdit(); - afx_msg void OnUpdateProjItemEdit(CCmdUI* pCmdUI); - afx_msg void OnProjItemDelete(); - afx_msg void OnUpdateProjItemDelete(CCmdUI* pCmdUI); - afx_msg void OnProjItemProperties(); - afx_msg void OnUpdateProjItemProperties(CCmdUI* pCmdUI); - afx_msg void OnProjItemView(); - afx_msg void OnUpdateProjItemView(CCmdUI* pCmdUI); - //}}AFX_MSG - afx_msg LRESULT OnMessageShowPlayingBoard(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnMessageRestoreWinState(WPARAM, LPARAM); +#endif + void OnEditBoardProperties(wxCommandEvent& event); + void OnUpdateEditBoardProperties(wxUpdateUIEvent& pCmdUI); + void OnContextMenu(wxContextMenuEvent& event); + void OnProjItemEdit(wxCommandEvent& event); + void OnUpdateProjItemEdit(wxUpdateUIEvent& pCmdUI); + void OnProjItemDelete(wxCommandEvent& event); + void OnUpdateProjItemDelete(wxUpdateUIEvent& pCmdUI); + void OnProjItemProperties(wxCommandEvent& event); + void OnUpdateProjItemProperties(wxUpdateUIEvent& pCmdUI); + void OnProjItemView(wxCommandEvent& event); + void OnUpdateProjItemView(wxUpdateUIEvent& pCmdUI); + void OnMessageShowPlayingBoard(ShowPlayingBoardEvent& event); + void OnMessageRestoreWinState(WinStateRestoreEvent& event); + + wxDECLARE_EVENT_TABLE(); - DECLARE_MESSAGE_MAP() +private: + // IGetCmdTarget + CCmdTarget& Get() override; + + RefPtr parent; + RefPtr document; + + friend class CGsnProjViewContainer; }; -class CGsnProjViewContainer : public CView +class CGsnProjViewContainer : public CB::OnCmdMsgOverride, + public CB::wxNativeContainerWindowMixin { public: void OnDraw(CDC* pDC) override; + void OnInitialUpdate() override; + void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) override; + private: CGsnProjViewContainer(); // used by dynamic creation DECLARE_DYNCREATE(CGsnProjViewContainer) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSize(UINT nType, int cx, int cy); DECLARE_MESSAGE_MAP() - // owned by MFC - RefPtr child; + // IGetEvtHandler + wxEvtHandler& Get() override + { + return CheckedDeref(CheckedDeref(child).GetEventHandler()); + } + + // owned by wx + CB::propagate_const child = nullptr; + + typedef CB::OnCmdMsgOverride BASE; }; +inline CCmdTarget& CGsnProjView::Get() +{ + return *parent; +} + ///////////////////////////////////////////////////////////////////////////// #endif diff --git a/GShr/LibMfc.cpp b/GShr/LibMfc.cpp index c102ec6..55975a4 100644 --- a/GShr/LibMfc.cpp +++ b/GShr/LibMfc.cpp @@ -1305,9 +1305,23 @@ namespace CB return wxID_UNDO; default: #if defined(GPLAY) - // TODO: - return wxID_NONE; + switch (id) + { + case ID_EDIT_BRDPROP: + return XRCID("ID_EDIT_BRDPROP"); + case ID_PPROJITEM_DELETE: + return XRCID("ID_PPROJITEM_DELETE"); + case ID_PPROJITEM_EDIT: + return XRCID("ID_PPROJITEM_EDIT"); + case ID_PPROJITEM_PROPERTIES: + return XRCID("ID_PPROJITEM_PROPERTIES"); + case ID_PPROJITEM_VIEW: + return XRCID("ID_PPROJITEM_VIEW"); + default: + return wxID_NONE; + } #else + wxASSERT(!"dead code"); switch (id) { case ID_BUGFIX_DUMPBADTILES: @@ -1523,6 +1537,14 @@ namespace CB { XRCID("ID_TOOLS_ROT180"), ID_TOOLS_ROT180 }, { XRCID("ID_TOOLS_ROT270"), ID_TOOLS_ROT270 }, #else + { XRCID("ID_EDIT_CREATE_GEOMORPHIC"), ID_EDIT_CREATE_GEOMORPHIC }, + { XRCID("ID_EDIT_CREATETRAY"), ID_EDIT_CREATETRAY }, + { XRCID("ID_EDIT_SELECTBOARDS"), ID_EDIT_SELECTBOARDS }, + { XRCID("ID_EDIT_SELECTGAMEPIECES"), ID_EDIT_SELECTGAMEPIECES }, + { XRCID("ID_PPROJITEM_DELETE"), ID_PPROJITEM_DELETE }, + { XRCID("ID_PPROJITEM_EDIT"), ID_PPROJITEM_EDIT }, + { XRCID("ID_PPROJITEM_PROPERTIES"), ID_PPROJITEM_PROPERTIES }, + { XRCID("ID_PPROJITEM_VIEW"), ID_PPROJITEM_VIEW }, #endif }; auto it = ids.find(wxId);