From f674e09d80bc17202f8cb74808bf159705544490 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 15:36:12 -0700 Subject: [PATCH 01/26] Initial wxFormBuilder project with only MainFrame implemented. --- src/wxfb/App.fbp | 553 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 553 insertions(+) create mode 100644 src/wxfb/App.fbp diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp new file mode 100644 index 0000000..9cc6eb2 --- /dev/null +++ b/src/wxfb/App.fbp @@ -0,0 +1,553 @@ + + + + + C++ + ; + 0 + connect + none + "kdeck" "wxfb" + + 0 + 1 + res + UTF-8 + App + 6000 + 1 + 1 + UI + App + . + 0 + source_name + 1 + 0 + source_name + + 1 + 1 + 1 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + MainFrame + + 800,600 + wxDEFAULT_FRAME_STYLE + ; ; forward_declare + kdeck + + 1 + + + wxTAB_TRAVERSAL + 1 + + + vszrRoot + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 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 + pnlRoot + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + vszrContent + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + hszrPortfolioInfo + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 0 + protected + 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 + Balance + 0 + + 0 + + + 0 + + 1 + lblBalance + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + 0 + + 1 + txtBalance + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + + "Ticker" "Position" "Exposure" "Realized P/L" "Total Traded" "Resting Orders" + wxALIGN_CENTER + 6 + + + 1 + 0 + Dock + 0 + Left + 0 + 0 + 1 + 0 + 1 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + + 1 + gridPositions + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTER + + + wxALIGN_CENTER + + 0 + 1 + + ; ; forward_declare + 0 + + + + + + + + + + + + + + 1 + 0 + 1 + + + 0 + wxID_ANY + + + mnuBar + protected + + + + ; ; forward_declare + + + + + + &File + mnuFile + protected + + + 0 + 1 + Login + ID_Login + wxITEM_NORMAL + Login... + mnuLogin + none + + + OnMenuItemSelected + + + + 0 + 0 + Logout + ID_Logout + wxITEM_NORMAL + Logout... + mnuLogout + none + + + OnMenuItemSelected + + + mnuSeparatorExit + none + + + + 0 + 1 + + wxID_EXIT + wxITEM_NORMAL + + mnuExit + none + + + + + + &Exchange + mnuExchange + protected + + + 0 + 1 + Announcements + ID_Exchange_Announcements + wxITEM_NORMAL + Announcements + mnuItemExchangeAnnouncements + none + + + OnMenuItemSelected + + + + 0 + 1 + Schedule + ID_Exchange_Schedule + wxITEM_NORMAL + Schedule + mnuItemExchangeSchedule + none + + + OnMenuItemSelected + + + + 0 + 1 + Status + ID_Exchange_Status + wxITEM_NORMAL + Status + mnuItemExchangeStatus + none + + + OnMenuItemSelected + + + + &View + mnuView + protected + + + 0 + 1 + Show Closed Positions + ID_View_ShowClosedPositions + wxITEM_CHECK + Show Closed Positions + mnuShowClosedPositions + none + + + OnMenuItemSelected + + + + &Help + mnuHelp + protected + + + 0 + 1 + + wxID_ABOUT + wxITEM_NORMAL + + mnuAbout + none + + + + + + + + + 1 + 0 + 1 + + 2 + + 0 + wxID_ANY + + + statusBar + protected + + + wxSTB_SIZEGRIP + ; ; forward_declare + + + + + + + + From bb30266da90cedf88fb7c117ffbab9f2865ed401 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 15:37:41 -0700 Subject: [PATCH 02/26] Add initial wxFormBuilder-generated files. --- src/wxfb/App.cpp | 160 +++++++++++++++++++++++++++++++++++++++++++++++ src/wxfb/App.h | 81 ++++++++++++++++++++++++ 2 files changed, 241 insertions(+) create mode 100644 src/wxfb/App.cpp create mode 100644 src/wxfb/App.h diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp new file mode 100644 index 0000000..5e035c9 --- /dev/null +++ b/src/wxfb/App.cpp @@ -0,0 +1,160 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 4.2.1-33-g6494dcef) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "App.h" + +/////////////////////////////////////////////////////////////////////////// +using namespace kdeck::wxfb; + +MainFrame::MainFrame() +{ +} + +MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) +{ + this->Create( parent, id, title, pos, size, style ); +} + +bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) +{ + if ( !wxFrame::Create( parent, id, title, pos, size, style ) ) + { + return false; + } + + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* vszrRoot; + vszrRoot = new wxBoxSizer( wxVERTICAL ); + + pnlRoot = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* vszrContent; + vszrContent = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* hszrPortfolioInfo; + hszrPortfolioInfo = new wxBoxSizer( wxHORIZONTAL ); + + + hszrPortfolioInfo->Add( 0, 0, 1, wxEXPAND, 5 ); + + lblBalance = new wxStaticText( pnlRoot, wxID_ANY, _("Balance"), wxDefaultPosition, wxDefaultSize, 0 ); + lblBalance->Wrap( -1 ); + hszrPortfolioInfo->Add( lblBalance, 0, wxALL, 5 ); + + txtBalance = new wxTextCtrl( pnlRoot, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + hszrPortfolioInfo->Add( txtBalance, 0, wxALL, 5 ); + + + vszrContent->Add( hszrPortfolioInfo, 0, wxEXPAND, 5 ); + + gridPositions = new wxGrid( pnlRoot, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + gridPositions->CreateGrid( 0, 6 ); + gridPositions->EnableEditing( true ); + gridPositions->EnableGridLines( true ); + gridPositions->EnableDragGridSize( false ); + gridPositions->SetMargins( 0, 0 ); + + // Columns + gridPositions->EnableDragColMove( false ); + gridPositions->EnableDragColSize( true ); + gridPositions->SetColLabelValue( 0, _("Ticker") ); + gridPositions->SetColLabelValue( 1, _("Position") ); + gridPositions->SetColLabelValue( 2, _("Exposure") ); + gridPositions->SetColLabelValue( 3, _("Realized P/L") ); + gridPositions->SetColLabelValue( 4, _("Total Traded") ); + gridPositions->SetColLabelValue( 5, _("Resting Orders") ); + gridPositions->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Rows + gridPositions->EnableDragRowSize( true ); + gridPositions->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Label Appearance + + // Cell Defaults + gridPositions->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + vszrContent->Add( gridPositions, 1, wxALL|wxEXPAND, 5 ); + + + pnlRoot->SetSizer( vszrContent ); + pnlRoot->Layout(); + vszrContent->Fit( pnlRoot ); + vszrRoot->Add( pnlRoot, 1, wxEXPAND | wxALL, 5 ); + + + this->SetSizer( vszrRoot ); + this->Layout(); + mnuBar = new wxMenuBar( 0 ); + mnuFile = new wxMenu(); + wxMenuItem* mnuLogin; + mnuLogin = new wxMenuItem( mnuFile, ID_Login, wxString( _("Login...") ) , _("Login"), wxITEM_NORMAL ); + mnuFile->Append( mnuLogin ); + + wxMenuItem* mnuLogout; + mnuLogout = new wxMenuItem( mnuFile, ID_Logout, wxString( _("Logout...") ) , _("Logout"), wxITEM_NORMAL ); + mnuFile->Append( mnuLogout ); + mnuLogout->Enable( false ); + + mnuFile->AppendSeparator(); + + wxMenuItem* mnuExit; + mnuExit = new wxMenuItem( mnuFile, wxID_EXIT, wxString( wxEmptyString ) , wxEmptyString, wxITEM_NORMAL ); + mnuFile->Append( mnuExit ); + + mnuBar->Append( mnuFile, _("&File") ); + + mnuExchange = new wxMenu(); + wxMenuItem* mnuItemExchangeAnnouncements; + mnuItemExchangeAnnouncements = new wxMenuItem( mnuExchange, ID_Exchange_Announcements, wxString( _("Announcements") ) , _("Announcements"), wxITEM_NORMAL ); + mnuExchange->Append( mnuItemExchangeAnnouncements ); + + wxMenuItem* mnuItemExchangeSchedule; + mnuItemExchangeSchedule = new wxMenuItem( mnuExchange, ID_Exchange_Schedule, wxString( _("Schedule") ) , _("Schedule"), wxITEM_NORMAL ); + mnuExchange->Append( mnuItemExchangeSchedule ); + + wxMenuItem* mnuItemExchangeStatus; + mnuItemExchangeStatus = new wxMenuItem( mnuExchange, ID_Exchange_Status, wxString( _("Status") ) , _("Status"), wxITEM_NORMAL ); + mnuExchange->Append( mnuItemExchangeStatus ); + + mnuBar->Append( mnuExchange, _("&Exchange") ); + + mnuView = new wxMenu(); + wxMenuItem* mnuShowClosedPositions; + mnuShowClosedPositions = new wxMenuItem( mnuView, ID_View_ShowClosedPositions, wxString( _("Show Closed Positions") ) , _("Show Closed Positions"), wxITEM_CHECK ); + mnuView->Append( mnuShowClosedPositions ); + + mnuBar->Append( mnuView, _("&View") ); + + mnuHelp = new wxMenu(); + wxMenuItem* mnuAbout; + mnuAbout = new wxMenuItem( mnuHelp, wxID_ABOUT, wxString( wxEmptyString ) , wxEmptyString, wxITEM_NORMAL ); + mnuHelp->Append( mnuAbout ); + + mnuBar->Append( mnuHelp, _("&Help") ); + + this->SetMenuBar( mnuBar ); + + statusBar = this->CreateStatusBar( 2, wxSTB_SIZEGRIP, wxID_ANY ); + + this->Centre( wxBOTH ); + + // Connect Events + mnuFile->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuLogin->GetId()); + mnuFile->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuLogout->GetId()); + mnuExchange->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuItemExchangeAnnouncements->GetId()); + mnuExchange->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuItemExchangeSchedule->GetId()); + mnuExchange->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuItemExchangeStatus->GetId()); + mnuView->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuShowClosedPositions->GetId()); + + return true; +} + +MainFrame::~MainFrame() +{ +} diff --git a/src/wxfb/App.h b/src/wxfb/App.h new file mode 100644 index 0000000..aa89e4c --- /dev/null +++ b/src/wxfb/App.h @@ -0,0 +1,81 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 4.2.1-33-g6494dcef) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +namespace kdeck +{ + namespace wxfb + { + /////////////////////////////////////////////////////////////////////////////// + /// Class MainFrame + /////////////////////////////////////////////////////////////////////////////// + class MainFrame : public wxFrame + { + private: + + protected: + enum + { + ID_Login = 6000, + ID_Logout, + ID_Exchange_Announcements, + ID_Exchange_Schedule, + ID_Exchange_Status, + ID_View_ShowClosedPositions, + }; + + wxPanel* pnlRoot; + wxStaticText* lblBalance; + wxTextCtrl* txtBalance; + wxGrid* gridPositions; + wxMenuBar* mnuBar; + wxMenu* mnuFile; + wxMenu* mnuExchange; + wxMenu* mnuView; + wxMenu* mnuHelp; + wxStatusBar* statusBar; + + // Virtual event handlers, override them in your derived class + virtual void OnMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } + + + public: + + MainFrame(); + MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("kdeck"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 800,600 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + bool Create( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("kdeck"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 800,600 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + + ~MainFrame(); + + }; + + } // namespace wxfb +} // namespace kdeck + From 031093521fdebeaeecd6a6a1bee74fa78ac17e19 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 15:52:36 -0700 Subject: [PATCH 03/26] Add wxFormBuilder files to CMake project. --- src/CMakeLists.txt | 1 + src/ui/CMakeLists.txt | 1 + src/wxfb/CMakeLists.txt | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/wxfb/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a80808d..e02418a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,3 +23,4 @@ target_link_libraries(${PROJECT_NAME} add_subdirectory(api) add_subdirectory(config) add_subdirectory(ui) +add_subdirectory(wxfb) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index c991110..8960c1a 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -25,6 +25,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC api config + wxfb PRIVATE OpenGL::EGL wx::core diff --git a/src/wxfb/CMakeLists.txt b/src/wxfb/CMakeLists.txt new file mode 100644 index 0000000..d40e964 --- /dev/null +++ b/src/wxfb/CMakeLists.txt @@ -0,0 +1,22 @@ +project(wxfb) + +add_library(${PROJECT_NAME} STATIC + App.cpp +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + $ + $ + $ +) + +target_link_libraries(${PROJECT_NAME} + PUBLIC + ui + PRIVATE + OpenGL::EGL + wx::core + wx::base + wx::gl +) From c9269c278f75768a12a8f09f67b573bae21641b4 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:12:37 -0700 Subject: [PATCH 04/26] Clean up base MainFrame config. --- src/wxfb/App.cpp | 10 ++++++---- src/wxfb/App.fbp | 14 +++++++++----- src/wxfb/App.h | 5 +++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index 5e035c9..14ffb97 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -92,11 +92,9 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, this->Layout(); mnuBar = new wxMenuBar( 0 ); mnuFile = new wxMenu(); - wxMenuItem* mnuLogin; mnuLogin = new wxMenuItem( mnuFile, ID_Login, wxString( _("Login...") ) , _("Login"), wxITEM_NORMAL ); mnuFile->Append( mnuLogin ); - wxMenuItem* mnuLogout; mnuLogout = new wxMenuItem( mnuFile, ID_Logout, wxString( _("Logout...") ) , _("Logout"), wxITEM_NORMAL ); mnuFile->Append( mnuLogout ); mnuLogout->Enable( false ); @@ -125,9 +123,9 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, mnuBar->Append( mnuExchange, _("&Exchange") ); mnuView = new wxMenu(); - wxMenuItem* mnuShowClosedPositions; mnuShowClosedPositions = new wxMenuItem( mnuView, ID_View_ShowClosedPositions, wxString( _("Show Closed Positions") ) , _("Show Closed Positions"), wxITEM_CHECK ); mnuView->Append( mnuShowClosedPositions ); + mnuShowClosedPositions->Enable( false ); mnuBar->Append( mnuView, _("&View") ); @@ -140,17 +138,21 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, this->SetMenuBar( mnuBar ); - statusBar = this->CreateStatusBar( 2, wxSTB_SIZEGRIP, wxID_ANY ); + statusBar = this->CreateStatusBar( 3, wxSTB_SIZEGRIP, wxID_ANY ); this->Centre( wxBOTH ); // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainFrame::OnClose ) ); + this->Connect( wxEVT_SHOW, wxShowEventHandler( MainFrame::OnShow ) ); mnuFile->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuLogin->GetId()); mnuFile->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuLogout->GetId()); + mnuFile->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuExit->GetId()); mnuExchange->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuItemExchangeAnnouncements->GetId()); mnuExchange->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuItemExchangeSchedule->GetId()); mnuExchange->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuItemExchangeStatus->GetId()); mnuView->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuShowClosedPositions->GetId()); + mnuHelp->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnMenuItemSelected ), this, mnuAbout->GetId()); return true; } diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 9cc6eb2..093c121 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -60,6 +60,8 @@ wxTAB_TRAVERSAL 1 + OnClose + OnShow vszrRoot @@ -402,7 +404,7 @@ wxITEM_NORMAL Login... mnuLogin - none + protected OnMenuItemSelected @@ -416,7 +418,7 @@ wxITEM_NORMAL Logout... mnuLogout - none + protected OnMenuItemSelected @@ -437,6 +439,7 @@ none + OnMenuItemSelected @@ -493,13 +496,13 @@ 0 - 1 + 0 Show Closed Positions ID_View_ShowClosedPositions wxITEM_CHECK Show Closed Positions mnuShowClosedPositions - none + protected OnMenuItemSelected @@ -521,6 +524,7 @@ none + OnMenuItemSelected @@ -531,7 +535,7 @@ 0 1 - 2 + 3 0 wxID_ANY diff --git a/src/wxfb/App.h b/src/wxfb/App.h index aa89e4c..c1c0f07 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -57,12 +57,17 @@ namespace kdeck wxGrid* gridPositions; wxMenuBar* mnuBar; wxMenu* mnuFile; + wxMenuItem* mnuLogin; + wxMenuItem* mnuLogout; wxMenu* mnuExchange; wxMenu* mnuView; + wxMenuItem* mnuShowClosedPositions; wxMenu* mnuHelp; wxStatusBar* statusBar; // Virtual event handlers, override them in your derived class + virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } + virtual void OnShow( wxShowEvent& event ) { event.Skip(); } virtual void OnMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } From 84c86adc528daaf328011e9bf0cd1db70646f8c8 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:41:22 -0700 Subject: [PATCH 05/26] Remove positions grid in favor of old PortfolioPanel as a custom control. --- src/wxfb/App.cpp | 31 ++----------------------------- src/wxfb/App.fbp | 40 +++++++--------------------------------- src/wxfb/App.h | 4 ++-- 3 files changed, 11 insertions(+), 64 deletions(-) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index 14ffb97..dcd4ce0 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -51,35 +51,8 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, vszrContent->Add( hszrPortfolioInfo, 0, wxEXPAND, 5 ); - gridPositions = new wxGrid( pnlRoot, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - - // Grid - gridPositions->CreateGrid( 0, 6 ); - gridPositions->EnableEditing( true ); - gridPositions->EnableGridLines( true ); - gridPositions->EnableDragGridSize( false ); - gridPositions->SetMargins( 0, 0 ); - - // Columns - gridPositions->EnableDragColMove( false ); - gridPositions->EnableDragColSize( true ); - gridPositions->SetColLabelValue( 0, _("Ticker") ); - gridPositions->SetColLabelValue( 1, _("Position") ); - gridPositions->SetColLabelValue( 2, _("Exposure") ); - gridPositions->SetColLabelValue( 3, _("Realized P/L") ); - gridPositions->SetColLabelValue( 4, _("Total Traded") ); - gridPositions->SetColLabelValue( 5, _("Resting Orders") ); - gridPositions->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); - - // Rows - gridPositions->EnableDragRowSize( true ); - gridPositions->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); - - // Label Appearance - - // Cell Defaults - gridPositions->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - vszrContent->Add( gridPositions, 1, wxALL|wxEXPAND, 5 ); + pnlPortfolio = new PortfolioPanel(this); + vszrContent->Add( pnlPortfolio, 1, wxALL|wxEXPAND, 5 ); pnlRoot->SetSizer( vszrContent ); diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 093c121..be13397 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -280,7 +280,7 @@ 5 wxALL|wxEXPAND 1 - + 1 1 1 @@ -289,51 +289,30 @@ 0 0 - 0 - 0 1 - - - wxALIGN_LEFT - - wxALIGN_TOP 0 + 1 - wxALIGN_CENTER - - "Ticker" "Position" "Exposure" "Realized P/L" "Total Traded" "Resting Orders" - wxALIGN_CENTER - 6 - + pnlPortfolio = new PortfolioPanel(this); 1 + PortfolioPanel* pnlPortfolio; 0 Dock 0 Left 0 - 0 - 1 - 0 - 1 - 1 1 1 - - 1 0 0 wxID_ANY - - - - 0 - 0 + #include "ui/PortfolioPanel.hpp" 0 @@ -341,7 +320,7 @@ 0 1 - gridPositions + pnlPortfolio 1 @@ -349,12 +328,7 @@ 1 Resizable - wxALIGN_CENTER - - - wxALIGN_CENTER - - 0 + 1 ; ; forward_declare diff --git a/src/wxfb/App.h b/src/wxfb/App.h index c1c0f07..14c7cfd 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include "ui/PortfolioPanel.hpp" #include #include #include @@ -54,7 +54,7 @@ namespace kdeck wxPanel* pnlRoot; wxStaticText* lblBalance; wxTextCtrl* txtBalance; - wxGrid* gridPositions; + PortfolioPanel* pnlPortfolio; wxMenuBar* mnuBar; wxMenu* mnuFile; wxMenuItem* mnuLogin; From 0b81d54124c8f60161b8babb1e3bfa88b0e966c8 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:43:13 -0700 Subject: [PATCH 06/26] Derive MainFrame class from new base MainFrame class. Removes some duplicate code and works around any issues discovered. --- include/ui/MainFrame.hpp | 26 ++++----------- src/ui/MainFrame.cpp | 71 +++++----------------------------------- 2 files changed, 16 insertions(+), 81 deletions(-) diff --git a/include/ui/MainFrame.hpp b/include/ui/MainFrame.hpp index b7ce182..36e8885 100644 --- a/include/ui/MainFrame.hpp +++ b/include/ui/MainFrame.hpp @@ -3,6 +3,8 @@ #include +#include "App.h" // wxfb + #include "app_config.hpp" #include "api/Api.hpp" #include "config/Config.hpp" @@ -11,17 +13,7 @@ namespace kdeck { class PortfolioPanel; - enum - { - ID_Login = wxID_HIGHEST + 1, - ID_Logout = wxID_HIGHEST + 2, - ID_Exchange_Announcements = wxID_HIGHEST + 3, - ID_Exchange_Schedule = wxID_HIGHEST + 4, - ID_Exchange_Status = wxID_HIGHEST + 5, - ID_View_ShowClosedPositions = wxID_HIGHEST + 6, - }; - - class MainFrame : public wxFrame + class MainFrame : public wxfb::MainFrame { public: MainFrame(wxWindow* parent = nullptr, wxWindowID winid = wxID_ANY, const wxString &title = std::string{kProjectName}); @@ -33,11 +25,7 @@ namespace kdeck Config config; Api api; - wxMenuItem *mnuLogin; - wxMenuItem *mnuLogout; - wxMenuItem *mnuShowClosedPositions; - - PortfolioPanel* pnlPortfolio; + bool isLoginDialogShownOnce = false; // init void Setup(); @@ -54,9 +42,9 @@ namespace kdeck // event handlers void OnLoginOrLogout(wxCommandEvent& event); void OnApiError(wxCommandEvent& event); - void OnIdleRunOnce(wxIdleEvent& event); - void OnMenuItemSelected(wxCommandEvent& event); - void OnClose(wxCloseEvent& event); + void OnShow(wxShowEvent &event) override; + void OnMenuItemSelected(wxCommandEvent& event) override; + void OnClose(wxCloseEvent& event) override; }; } diff --git a/src/ui/MainFrame.cpp b/src/ui/MainFrame.cpp index 22c7b12..f2d6f9a 100644 --- a/src/ui/MainFrame.cpp +++ b/src/ui/MainFrame.cpp @@ -3,6 +3,8 @@ #include #include +#include "App.h" // wxfb + #include "api/Api.hpp" #include "config/Config.hpp" #include "ui/ExchangeAnnouncementsDialog.hpp" @@ -19,7 +21,7 @@ namespace kdeck /////////////////////////////////////////////////////////////////////////////// MainFrame::MainFrame(wxWindow* parent, wxWindowID winid, const wxString &title) - : wxFrame(parent, winid, title) + : wxfb::MainFrame(parent, winid, title) , config{} , api{config.GetKalshiApiUrl(), config.GetSslTrustStoreDir()} { @@ -31,68 +33,11 @@ namespace kdeck void MainFrame::Setup() { - // NOTE: It appears to be important that we add the status bar (and possibly - // the menu bar) before we add a panel/sizer. It seems to change the - // dimensions of the panel/frame and messes with sizer logic. - - wxMenu *menuFile = new wxMenu; - - mnuLogin = menuFile->Append(ID_Login, "Login...", "Login"); - mnuLogout = menuFile->Append(ID_Logout, "Logout...", "Logout"); - - mnuLogout->Enable(false); - - menuFile->AppendSeparator(); - menuFile->Append(wxID_EXIT); - - /////////////////////////////////////////////////////////////////////////// - - wxMenu *menuExchange = new wxMenu; - - menuExchange->Append(ID_Exchange_Announcements, "Announcements", "Announcements"); - menuExchange->Append(ID_Exchange_Schedule, "Schedule", "Schedule"); - menuExchange->Append(ID_Exchange_Status, "Status", "Status"); - - /////////////////////////////////////////////////////////////////////////// - - wxMenu *menuView = new wxMenu; - - mnuShowClosedPositions = menuView->AppendCheckItem(ID_View_ShowClosedPositions, "Show Closed Positions", "Show Closed Positions"); - - mnuShowClosedPositions->Enable(false); - - /////////////////////////////////////////////////////////////////////////// - - wxMenu *menuHelp = new wxMenu; - menuHelp->Append(wxID_ABOUT); - - /////////////////////////////////////////////////////////////////////////// - - wxMenuBar *menuBar = new wxMenuBar; - menuBar->Append(menuFile, "&File"); - menuBar->Append(menuExchange, "&Exchange"); - menuBar->Append(menuView, "&View"); - menuBar->Append(menuHelp, "&Help"); - - SetMenuBar(menuBar); - - /////////////////////////////////////////////////////////////////////////// - - CreateStatusBar(3); ShowStatus(wxString::Format("Welcome to %s!", kProjectName)); - /////////////////////////////////////////////////////////////////////////// - - pnlPortfolio = new PortfolioPanel(this); - - SetMinSize(wxSize{400, 400}); - Bind(EVT_LOGIN, &MainFrame::OnLoginOrLogout, this); Bind(EVT_LOGOUT, &MainFrame::OnLoginOrLogout, this); Bind(EVT_API_ERROR, &MainFrame::OnApiError, this); - Bind(wxEVT_IDLE, &MainFrame::OnIdleRunOnce, this); - Bind(wxEVT_MENU, &MainFrame::OnMenuItemSelected, this); - Bind(wxEVT_CLOSE_WINDOW, &MainFrame::OnClose, this); } void MainFrame::UpdateStuff() @@ -221,12 +166,14 @@ namespace kdeck ShowStatus(event.GetString()); } - void MainFrame::OnIdleRunOnce(wxIdleEvent &event) + void MainFrame::OnShow(wxShowEvent &event) { - // unbind this event handler so it only runs once - Unbind(wxEVT_IDLE, &MainFrame::OnIdleRunOnce, this); + if (!isLoginDialogShownOnce) + { + isLoginDialogShownOnce = true; - DoLogin(); + DoLogin(); + } } void MainFrame::OnMenuItemSelected(wxCommandEvent &event) From d67ffeb616e6216c10d501c3745106900e298d40 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:43:47 -0700 Subject: [PATCH 07/26] Add wxFormBuilder-generated code to VS Code Intellisense. --- .vscode/c_cpp_properties.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 7ee154f..7a124c7 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,6 +4,7 @@ "name": "Linux", "includePath": [ "${workspaceFolder}/include/**", + "${workspaceFolder}/src/wxfb/**", "${workspaceFolder}/build/vcpkg_installed/x64-linux/include/**", "/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2", "/usr/include/wx-3.2" From 4d5d81f2e3f8ba088d5e7483942235dfb3de18b2 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:58:47 -0700 Subject: [PATCH 08/26] Fix runtime issue with control hierarchy. --- src/wxfb/App.cpp | 2 +- src/wxfb/App.fbp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index dcd4ce0..6b9ccd5 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -51,7 +51,7 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, vszrContent->Add( hszrPortfolioInfo, 0, wxEXPAND, 5 ); - pnlPortfolio = new PortfolioPanel(this); + pnlPortfolio = new PortfolioPanel(pnlRoot); vszrContent->Add( pnlPortfolio, 1, wxALL|wxEXPAND, 5 ); diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index be13397..1ee2052 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -296,7 +296,7 @@ 0 1 - pnlPortfolio = new PortfolioPanel(this); + pnlPortfolio = new PortfolioPanel(pnlRoot); 1 PortfolioPanel* pnlPortfolio; From 521a4bf5ff6f9b868870ef4ffeef5cb2a817c69f Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 18:00:11 -0700 Subject: [PATCH 09/26] Remove broken balance field (for now) because the custom PortfolioPanel control is working. --- src/wxfb/App.cpp | 15 ----- src/wxfb/App.fbp | 148 ----------------------------------------------- src/wxfb/App.h | 8 +-- 3 files changed, 2 insertions(+), 169 deletions(-) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index 6b9ccd5..ef6521a 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -35,21 +35,6 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, wxBoxSizer* vszrContent; vszrContent = new wxBoxSizer( wxVERTICAL ); - wxBoxSizer* hszrPortfolioInfo; - hszrPortfolioInfo = new wxBoxSizer( wxHORIZONTAL ); - - - hszrPortfolioInfo->Add( 0, 0, 1, wxEXPAND, 5 ); - - lblBalance = new wxStaticText( pnlRoot, wxID_ANY, _("Balance"), wxDefaultPosition, wxDefaultSize, 0 ); - lblBalance->Wrap( -1 ); - hszrPortfolioInfo->Add( lblBalance, 0, wxALL, 5 ); - - txtBalance = new wxTextCtrl( pnlRoot, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - hszrPortfolioInfo->Add( txtBalance, 0, wxALL, 5 ); - - - vszrContent->Add( hszrPortfolioInfo, 0, wxEXPAND, 5 ); pnlPortfolio = new PortfolioPanel(pnlRoot); vszrContent->Add( pnlPortfolio, 1, wxALL|wxEXPAND, 5 ); diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 1ee2052..add96c4 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -128,154 +128,6 @@ vszrContent wxVERTICAL none - - 5 - wxEXPAND - 0 - - - hszrPortfolioInfo - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - 0 - protected - 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 - Balance - 0 - - 0 - - - 0 - - 1 - lblBalance - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 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 - - 0 - - 0 - - 0 - - 1 - txtBalance - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 wxALL|wxEXPAND diff --git a/src/wxfb/App.h b/src/wxfb/App.h index 14c7cfd..6dfbabc 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -10,15 +10,13 @@ #include #include #include -#include -#include +#include "ui/PortfolioPanel.hpp" #include #include #include #include -#include +#include #include -#include "ui/PortfolioPanel.hpp" #include #include #include @@ -52,8 +50,6 @@ namespace kdeck }; wxPanel* pnlRoot; - wxStaticText* lblBalance; - wxTextCtrl* txtBalance; PortfolioPanel* pnlPortfolio; wxMenuBar* mnuBar; wxMenu* mnuFile; From 77ba03144a4bf228eb760cacf7449d9d9e074484 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 19:21:22 -0700 Subject: [PATCH 10/26] Don't hardcode main frame title. --- src/wxfb/App.fbp | 2 +- src/wxfb/App.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index add96c4..a8d9886 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -53,7 +53,7 @@ 800,600 wxDEFAULT_FRAME_STYLE ; ; forward_declare - kdeck + 1 diff --git a/src/wxfb/App.h b/src/wxfb/App.h index 6dfbabc..6675b37 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -70,8 +70,8 @@ namespace kdeck public: MainFrame(); - MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("kdeck"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 800,600 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); - bool Create( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("kdeck"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 800,600 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 800,600 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + bool Create( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 800,600 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); ~MainFrame(); From 780a0e62cb9c9d9dd24cbde25c12a3264dae2822 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 19:44:03 -0700 Subject: [PATCH 11/26] Add base LoginDialog to wxFormBuilder project. --- include/ui/LoginDialog.hpp | 14 +- src/ui/LoginDialog.cpp | 37 +-- src/wxfb/App.cpp | 67 +++++- src/wxfb/App.fbp | 450 +++++++++++++++++++++++++++++++++++++ src/wxfb/App.h | 26 +++ 5 files changed, 551 insertions(+), 43 deletions(-) diff --git a/include/ui/LoginDialog.hpp b/include/ui/LoginDialog.hpp index f765ee3..f6bb717 100644 --- a/include/ui/LoginDialog.hpp +++ b/include/ui/LoginDialog.hpp @@ -3,14 +3,16 @@ #include +#include "App.h" // wxfb + namespace kdeck { class Config; - class LoginDialog : public wxDialog + class LoginDialog : public wxfb::LoginDialog { public: - LoginDialog(wxWindow* parent, wxWindowID winid = wxID_ANY, const wxString &title = "Login"); + LoginDialog(wxWindow* parent, wxWindowID winid = wxID_ANY); void UpdateStuff(const Config* config); @@ -18,14 +20,6 @@ namespace kdeck std::string GetPassword() const; bool GetRememberMe() const; - - private: - wxTextCtrl* txtEmail; - wxTextCtrl* txtPassword; - wxCheckBox* chkRememberMe; - - // init - void Setup(); }; } diff --git a/src/ui/LoginDialog.cpp b/src/ui/LoginDialog.cpp index a16a55e..d549130 100644 --- a/src/ui/LoginDialog.cpp +++ b/src/ui/LoginDialog.cpp @@ -1,5 +1,7 @@ #include +#include "App.h" // wxfb + #include "config/Config.hpp" #include "ui/LoginDialog.hpp" #include "ui/event.hpp" @@ -9,44 +11,15 @@ namespace kdeck // constructor //////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// - LoginDialog::LoginDialog(wxWindow* parent, wxWindowID winid, const wxString &title) - : wxDialog(parent, winid, title) + LoginDialog::LoginDialog(wxWindow* parent, wxWindowID winid) + : wxfb::LoginDialog(parent, winid) { - Setup(); + } // init /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// - void LoginDialog::Setup() - { - txtEmail = new wxTextCtrl(this, wxID_ANY); - txtEmail->SetHint("Email"); - txtEmail->SetFocus(); - - txtPassword = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD); - txtPassword->SetHint("Password"); - - chkRememberMe = new wxCheckBox(this, wxID_ANY, "Remember me"); - chkRememberMe->SetValue(false); - - wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL); - - wxSizerFlags flagsInput = wxSizerFlags().Border(wxALL, 10).Expand(); - - boxSizer->Add(txtEmail, flagsInput); - boxSizer->Add(txtPassword, flagsInput); - boxSizer->Add(chkRememberMe, flagsInput); - - wxSizer* szrButton = CreateButtonSizer(wxOK | wxCANCEL); - if (szrButton) - { - boxSizer->Add(szrButton, wxSizerFlags().Center()); - } - - SetSizerAndFit(boxSizer); - } - void LoginDialog::UpdateStuff(const Config* config) { if (config->GetEmail().empty()) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index ef6521a..849c4d2 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -35,7 +35,6 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, wxBoxSizer* vszrContent; vszrContent = new wxBoxSizer( wxVERTICAL ); - pnlPortfolio = new PortfolioPanel(pnlRoot); vszrContent->Add( pnlPortfolio, 1, wxALL|wxEXPAND, 5 ); @@ -118,3 +117,69 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, MainFrame::~MainFrame() { } + +LoginDialog::LoginDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* vszrRoot; + vszrRoot = new wxBoxSizer( wxVERTICAL ); + + pnlRoot = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* vszrContent; + vszrContent = new wxBoxSizer( wxVERTICAL ); + + wxGridSizer* gridInputs; + gridInputs = new wxGridSizer( 0, 2, 0, 0 ); + + wxStaticText* lblEmail; + lblEmail = new wxStaticText( pnlRoot, wxID_ANY, _("Email"), wxDefaultPosition, wxDefaultSize, 0 ); + lblEmail->Wrap( -1 ); + gridInputs->Add( lblEmail, 0, wxALIGN_RIGHT|wxALL, 5 ); + + txtEmail = new wxTextCtrl( pnlRoot, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + gridInputs->Add( txtEmail, 0, wxALL|wxEXPAND, 5 ); + + wxStaticText* lblPassword; + lblPassword = new wxStaticText( pnlRoot, wxID_ANY, _("Password"), wxDefaultPosition, wxDefaultSize, 0 ); + lblPassword->Wrap( -1 ); + gridInputs->Add( lblPassword, 0, wxALIGN_RIGHT|wxALL, 5 ); + + txtPassword = new wxTextCtrl( pnlRoot, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); + gridInputs->Add( txtPassword, 0, wxALL|wxEXPAND, 5 ); + + + vszrContent->Add( gridInputs, 1, wxEXPAND, 5 ); + + chkRememberMe = new wxCheckBox( pnlRoot, wxID_ANY, _("Remember me"), wxDefaultPosition, wxDefaultSize, 0 ); + vszrContent->Add( chkRememberMe, 0, wxALL, 5 ); + + wxStdDialogButtonSizer* szrStandardButtons; + wxButton* szrStandardButtonsOK; + wxButton* szrStandardButtonsCancel; + szrStandardButtons = new wxStdDialogButtonSizer(); + szrStandardButtonsOK = new wxButton( pnlRoot, wxID_OK ); + szrStandardButtons->AddButton( szrStandardButtonsOK ); + szrStandardButtonsCancel = new wxButton( pnlRoot, wxID_CANCEL ); + szrStandardButtons->AddButton( szrStandardButtonsCancel ); + szrStandardButtons->Realize(); + + vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); + + + pnlRoot->SetSizer( vszrContent ); + pnlRoot->Layout(); + vszrContent->Fit( pnlRoot ); + vszrRoot->Add( pnlRoot, 1, wxEXPAND | wxALL, 5 ); + + + this->SetSizer( vszrRoot ); + this->Layout(); + vszrRoot->Fit( this ); + + this->Centre( wxBOTH ); +} + +LoginDialog::~LoginDialog() +{ +} diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index a8d9886..89dea30 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -379,5 +379,455 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + LoginDialog + + + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + Login + + 0 + + + + + + vszrRoot + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 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 + pnlRoot + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + vszrContent + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + 2 + 0 + + gridInputs + none + 0 + 0 + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Email + 0 + + 0 + + + 0 + + 1 + lblEmail + 1 + + + none + 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 + txtEmail + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Password + 0 + + 0 + + + 0 + + 1 + lblPassword + 1 + + + none + 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 + txtPassword + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_PASSWORD + ; ; 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 + Remember me + + 0 + + + 0 + + 1 + chkRememberMe + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + szrStandardButtons + none + + + + + + + diff --git a/src/wxfb/App.h b/src/wxfb/App.h index 6675b37..37927b5 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -24,6 +24,11 @@ #include #include #include +#include +#include +#include +#include +#include /////////////////////////////////////////////////////////////////////////// @@ -77,6 +82,27 @@ namespace kdeck }; + /////////////////////////////////////////////////////////////////////////////// + /// Class LoginDialog + /////////////////////////////////////////////////////////////////////////////// + class LoginDialog : public wxDialog + { + private: + + protected: + wxPanel* pnlRoot; + wxTextCtrl* txtEmail; + wxTextCtrl* txtPassword; + wxCheckBox* chkRememberMe; + + public: + + LoginDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Login"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); + + ~LoginDialog(); + + }; + } // namespace wxfb } // namespace kdeck From 68287c8e5613909f49b2f1dde9dfa4631ff7b40b Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 21:22:52 -0700 Subject: [PATCH 12/26] Remove superfluous panel from LoginDialog. --- src/wxfb/App.cpp | 28 +- src/wxfb/App.fbp | 660 +++++++++++++++++++++-------------------------- src/wxfb/App.h | 1 - 3 files changed, 307 insertions(+), 382 deletions(-) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index 849c4d2..c1432f4 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -122,10 +122,6 @@ LoginDialog::LoginDialog( wxWindow* parent, wxWindowID id, const wxString& title { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - wxBoxSizer* vszrRoot; - vszrRoot = new wxBoxSizer( wxVERTICAL ); - - pnlRoot = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* vszrContent; vszrContent = new wxBoxSizer( wxVERTICAL ); @@ -133,49 +129,43 @@ LoginDialog::LoginDialog( wxWindow* parent, wxWindowID id, const wxString& title gridInputs = new wxGridSizer( 0, 2, 0, 0 ); wxStaticText* lblEmail; - lblEmail = new wxStaticText( pnlRoot, wxID_ANY, _("Email"), wxDefaultPosition, wxDefaultSize, 0 ); + lblEmail = new wxStaticText( this, wxID_ANY, _("Email"), wxDefaultPosition, wxDefaultSize, 0 ); lblEmail->Wrap( -1 ); gridInputs->Add( lblEmail, 0, wxALIGN_RIGHT|wxALL, 5 ); - txtEmail = new wxTextCtrl( pnlRoot, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + txtEmail = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); gridInputs->Add( txtEmail, 0, wxALL|wxEXPAND, 5 ); wxStaticText* lblPassword; - lblPassword = new wxStaticText( pnlRoot, wxID_ANY, _("Password"), wxDefaultPosition, wxDefaultSize, 0 ); + lblPassword = new wxStaticText( this, wxID_ANY, _("Password"), wxDefaultPosition, wxDefaultSize, 0 ); lblPassword->Wrap( -1 ); gridInputs->Add( lblPassword, 0, wxALIGN_RIGHT|wxALL, 5 ); - txtPassword = new wxTextCtrl( pnlRoot, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); + txtPassword = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); gridInputs->Add( txtPassword, 0, wxALL|wxEXPAND, 5 ); vszrContent->Add( gridInputs, 1, wxEXPAND, 5 ); - chkRememberMe = new wxCheckBox( pnlRoot, wxID_ANY, _("Remember me"), wxDefaultPosition, wxDefaultSize, 0 ); + chkRememberMe = new wxCheckBox( this, wxID_ANY, _("Remember me"), wxDefaultPosition, wxDefaultSize, 0 ); vszrContent->Add( chkRememberMe, 0, wxALL, 5 ); wxStdDialogButtonSizer* szrStandardButtons; wxButton* szrStandardButtonsOK; wxButton* szrStandardButtonsCancel; szrStandardButtons = new wxStdDialogButtonSizer(); - szrStandardButtonsOK = new wxButton( pnlRoot, wxID_OK ); + szrStandardButtonsOK = new wxButton( this, wxID_OK ); szrStandardButtons->AddButton( szrStandardButtonsOK ); - szrStandardButtonsCancel = new wxButton( pnlRoot, wxID_CANCEL ); + szrStandardButtonsCancel = new wxButton( this, wxID_CANCEL ); szrStandardButtons->AddButton( szrStandardButtonsCancel ); szrStandardButtons->Realize(); vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); - pnlRoot->SetSizer( vszrContent ); - pnlRoot->Layout(); - vszrContent->Fit( pnlRoot ); - vszrRoot->Add( pnlRoot, 1, wxEXPAND | wxALL, 5 ); - - - this->SetSizer( vszrRoot ); + this->SetSizer( vszrContent ); this->Layout(); - vszrRoot->Fit( this ); + vszrContent->Fit( this ); this->Centre( wxBOTH ); } diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 89dea30..62898a1 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -409,14 +409,282 @@ - vszrRoot + vszrContent wxVERTICAL none 5 - wxEXPAND | wxALL + wxEXPAND 1 - + + 2 + 0 + + gridInputs + none + 0 + 0 + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Email + 0 + + 0 + + + 0 + + 1 + lblEmail + 1 + + + none + 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 + txtEmail + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Password + 0 + + 0 + + + 0 + + 1 + lblPassword + 1 + + + none + 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 + txtPassword + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_PASSWORD + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + 5 + wxALL + 0 + 1 1 1 @@ -430,6 +698,7 @@ 1 0 + 0 1 1 @@ -445,6 +714,7 @@ 0 0 wxID_ANY + Remember me 0 @@ -452,7 +722,7 @@ 0 1 - pnlRoot + chkRememberMe 1 @@ -462,369 +732,35 @@ Resizable 1 + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - wxTAB_TRAVERSAL - - - vszrContent - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - 2 - 0 - - gridInputs - none - 0 - 0 - - 5 - wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Email - 0 - - 0 - - - 0 - - 1 - lblEmail - 1 - - - none - 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 - txtEmail - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Password - 0 - - 0 - - - 0 - - 1 - lblPassword - 1 - - - none - 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 - txtPassword - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_PASSWORD - ; ; 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 - Remember me - - 0 - - - 0 - - 1 - chkRememberMe - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - szrStandardButtons - none - - - + + + + + 5 + wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + szrStandardButtons + none diff --git a/src/wxfb/App.h b/src/wxfb/App.h index 37927b5..fbfb4f8 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -90,7 +90,6 @@ namespace kdeck private: protected: - wxPanel* pnlRoot; wxTextCtrl* txtEmail; wxTextCtrl* txtPassword; wxCheckBox* chkRememberMe; From bf42798bbf2f8e84cfcab18bafceac66b51a0d9c Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sat, 10 Aug 2024 22:00:10 -0700 Subject: [PATCH 13/26] Add ExchangeAnnouncementsDialog to wxFormBuilder project. --- include/ui/ExchangeAnnouncementsDialog.hpp | 12 +- src/ui/ExchangeAnnouncementsDialog.cpp | 59 +++------ src/wxfb/App.cpp | 40 +++++++ src/wxfb/App.fbp | 133 +++++++++++++++++++++ src/wxfb/App.h | 19 +++ 5 files changed, 212 insertions(+), 51 deletions(-) diff --git a/include/ui/ExchangeAnnouncementsDialog.hpp b/include/ui/ExchangeAnnouncementsDialog.hpp index f4ad6f6..77fe5da 100644 --- a/include/ui/ExchangeAnnouncementsDialog.hpp +++ b/include/ui/ExchangeAnnouncementsDialog.hpp @@ -3,22 +3,18 @@ #include +#include "App.h" // wxfb + namespace kdeck { class Api; - class ExchangeAnnouncementsDialog : public wxDialog + class ExchangeAnnouncementsDialog : public wxfb::ExchangeAnnouncementsDialog { public: - ExchangeAnnouncementsDialog(wxWindow* parent, wxWindowID winid = wxID_ANY, const wxString &title = "Exchange Announcements"); + ExchangeAnnouncementsDialog(wxWindow* parent, wxWindowID winid = wxID_ANY); void UpdateStuff(Api* api); - - private: - wxBoxSizer* boxSizer; - - // init - void Setup(); }; } diff --git a/src/ui/ExchangeAnnouncementsDialog.cpp b/src/ui/ExchangeAnnouncementsDialog.cpp index 0e74f6e..7e31b3d 100644 --- a/src/ui/ExchangeAnnouncementsDialog.cpp +++ b/src/ui/ExchangeAnnouncementsDialog.cpp @@ -1,5 +1,7 @@ #include +#include "App.h" // wxfb + #include "api/Api.hpp" #include "ui/ExchangeAnnouncementsDialog.hpp" #include "ui/event.hpp" @@ -11,65 +13,36 @@ namespace kdeck // constructor //////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// - ExchangeAnnouncementsDialog::ExchangeAnnouncementsDialog(wxWindow* parent, wxWindowID winid, const wxString &title) - : wxDialog(parent, winid, title) + ExchangeAnnouncementsDialog::ExchangeAnnouncementsDialog(wxWindow* parent, wxWindowID winid) + : wxfb::ExchangeAnnouncementsDialog(parent, winid) { - Setup(); + } // init /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// - void ExchangeAnnouncementsDialog::Setup() - { - boxSizer = new wxBoxSizer(wxVERTICAL); - - wxBoxSizer* szr = new wxBoxSizer(wxVERTICAL); - - szr->Add(boxSizer, wxSizerFlags().Border(wxALL, 10).Expand()); - - wxSizer* szrButton = CreateButtonSizer(wxOK); - if (szrButton) - { - szr->Add(szrButton, wxSizerFlags().Center()); - } - - SetSizerAndFit(szr); - //TODO? messages have arbitrary length, so we should probably set a max size; - // wxWidgets complains if max size is less than the sizer's minimum size - // (look in git log for how I reconciled these previously) - //SetMaxSize(wxSize{800, 0}); - } - void ExchangeAnnouncementsDialog::UpdateStuff(Api* api) { - boxSizer->Clear(); + fgszrAnnouncements->Clear(); try { std::shared_ptr announcements = api->GetExchangeAnnouncements(); - if (announcements->announcements->empty()) - { - boxSizer->Add(new wxStaticText(this, wxID_ANY, "No announcements."), wxSizerFlags().Center()); - } - else - { - wxSizerFlags flags = wxSizerFlags().Border(wxUP | wxDOWN, 10).Expand(); - - for (auto announcement : *announcements->announcements) - { - wxBoxSizer* szr = new wxBoxSizer(wxHORIZONTAL); + bool hasAnnouncements = !announcements->announcements->empty(); - wxSizerFlags flagsLbl = wxSizerFlags().Border(wxLEFT, 10).CenterVertical(); + fgszrAnnouncements->Show(hasAnnouncements); + lblNoAnnouncements->Show(!hasAnnouncements); - szr->Add(new wxStaticText(this, wxID_ANY, announcement->delivery_time->c_str()), flagsLbl); - szr->Add(new wxStaticText(this, wxID_ANY, announcement->status->c_str()), flagsLbl); - szr->Add(new wxStaticText(this, wxID_ANY, announcement->type->c_str()), flagsLbl); - szr->Add(new wxStaticText(this, wxID_ANY, announcement->message->c_str()), flagsLbl); + for (auto announcement : *announcements->announcements) + { + wxSizerFlags flagsLbl = wxSizerFlags().Border(wxLEFT, 10).CenterVertical(); - boxSizer->Add(szr, flags); - } + fgszrAnnouncements->Add(new wxStaticText(this, wxID_ANY, announcement->delivery_time->c_str()), flagsLbl); + fgszrAnnouncements->Add(new wxStaticText(this, wxID_ANY, announcement->status->c_str()), flagsLbl); + fgszrAnnouncements->Add(new wxStaticText(this, wxID_ANY, announcement->type->c_str()), flagsLbl); + fgszrAnnouncements->Add(new wxStaticText(this, wxID_ANY, announcement->message->c_str()), flagsLbl); } } catch (const std::exception &e) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index c1432f4..2de4891 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -173,3 +173,43 @@ LoginDialog::LoginDialog( wxWindow* parent, wxWindowID id, const wxString& title LoginDialog::~LoginDialog() { } + +ExchangeAnnouncementsDialog::ExchangeAnnouncementsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* vszrContent; + vszrContent = new wxBoxSizer( wxVERTICAL ); + + fgszrAnnouncements = new wxFlexGridSizer( 1, 4, 0, 0 ); + fgszrAnnouncements->AddGrowableCol( 3 ); + fgszrAnnouncements->SetFlexibleDirection( wxBOTH ); + fgszrAnnouncements->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + + vszrContent->Add( fgszrAnnouncements, 1, wxEXPAND, 5 ); + + lblNoAnnouncements = new wxStaticText( this, wxID_ANY, _("There are no announcements."), wxDefaultPosition, wxDefaultSize, 0 ); + lblNoAnnouncements->Wrap( -1 ); + vszrContent->Add( lblNoAnnouncements, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + + wxStdDialogButtonSizer* szrStandardButtons; + wxButton* szrStandardButtonsOK; + szrStandardButtons = new wxStdDialogButtonSizer(); + szrStandardButtonsOK = new wxButton( this, wxID_OK ); + szrStandardButtons->AddButton( szrStandardButtonsOK ); + szrStandardButtons->Realize(); + + vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); + + + this->SetSizer( vszrContent ); + this->Layout(); + vszrContent->Fit( this ); + + this->Centre( wxBOTH ); +} + +ExchangeAnnouncementsDialog::~ExchangeAnnouncementsDialog() +{ +} diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 62898a1..157cf25 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -765,5 +765,138 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + ExchangeAnnouncementsDialog + + + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + Exchange Announcements + + 0 + + + + + + vszrContent + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + 4 + wxBOTH + 3 + + 0 + + fgszrAnnouncements + wxFLEX_GROWMODE_SPECIFIED + protected + 1 + 0 + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + There are no announcements. + 0 + + 0 + + + 0 + + 1 + lblNoAnnouncements + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 0 + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + + szrStandardButtons + none + + + + diff --git a/src/wxfb/App.h b/src/wxfb/App.h index fbfb4f8..492045b 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -102,6 +102,25 @@ namespace kdeck }; + /////////////////////////////////////////////////////////////////////////////// + /// Class ExchangeAnnouncementsDialog + /////////////////////////////////////////////////////////////////////////////// + class ExchangeAnnouncementsDialog : public wxDialog + { + private: + + protected: + wxFlexGridSizer* fgszrAnnouncements; + wxStaticText* lblNoAnnouncements; + + public: + + ExchangeAnnouncementsDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Exchange Announcements"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); + + ~ExchangeAnnouncementsDialog(); + + }; + } // namespace wxfb } // namespace kdeck From f6906804c7a56e382e1497203af23d28c1cb80f1 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 06:26:04 -0700 Subject: [PATCH 14/26] Add ExchangeStatusDialog to wxFormBuilder project. --- include/ui/ExchangeStatusDialog.hpp | 11 +- src/ui/ExchangeStatusDialog.cpp | 41 +--- src/wxfb/App.cpp | 52 +++++ src/wxfb/App.fbp | 315 ++++++++++++++++++++++++++++ src/wxfb/App.h | 19 ++ 5 files changed, 390 insertions(+), 48 deletions(-) diff --git a/include/ui/ExchangeStatusDialog.hpp b/include/ui/ExchangeStatusDialog.hpp index 01c6ed3..81ddbe8 100644 --- a/include/ui/ExchangeStatusDialog.hpp +++ b/include/ui/ExchangeStatusDialog.hpp @@ -3,23 +3,18 @@ #include +#include "App.h" // wxfb + namespace kdeck { class Api; - class ExchangeStatusDialog : public wxDialog + class ExchangeStatusDialog : public wxfb::ExchangeStatusDialog { public: ExchangeStatusDialog(wxWindow* parent, wxWindowID winid = wxID_ANY, const wxString &title = "Exchange Status"); void UpdateStuff(Api* api); - - private: - wxStaticText* lblExchangeStatus; - wxStaticText* lblTradingStatus; - - // init - void Setup(); }; } diff --git a/src/ui/ExchangeStatusDialog.cpp b/src/ui/ExchangeStatusDialog.cpp index ad4773a..91861c2 100644 --- a/src/ui/ExchangeStatusDialog.cpp +++ b/src/ui/ExchangeStatusDialog.cpp @@ -12,48 +12,9 @@ namespace kdeck /////////////////////////////////////////////////////////////////////////////// ExchangeStatusDialog::ExchangeStatusDialog(wxWindow* parent, wxWindowID winid, const wxString &title) - : wxDialog(parent, winid, title) + : wxfb::ExchangeStatusDialog(parent, winid, title) { - Setup(); - } - - // init /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - - void ExchangeStatusDialog::Setup() - { - wxStaticText* lblExchange = new wxStaticText(this, wxID_ANY, "Exchange:"); - lblExchangeStatus = new wxStaticText(this, wxID_ANY, ""); - - wxStaticText* lblTrading = new wxStaticText(this, wxID_ANY, "Trading:"); - lblTradingStatus = new wxStaticText(this, wxID_ANY, ""); - - /////////////////////////////////////////////////////////////////////////// - - wxGridSizer* gridSizer = new wxGridSizer(2, 2, wxSize{10, 10}); - - wxSizerFlags flagsLblLeft = wxSizerFlags().CenterVertical().Left(); - wxSizerFlags flagsLblRight = wxSizerFlags().CenterVertical().Right(); - - gridSizer->Add(lblExchange, flagsLblRight); - gridSizer->Add(lblExchangeStatus, flagsLblLeft); - - gridSizer->Add(lblTrading, flagsLblRight); - gridSizer->Add(lblTradingStatus, flagsLblLeft); - - /////////////////////////////////////////////////////////////////////////// - - wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL); - - boxSizer->Add(gridSizer, wxSizerFlags().Border(wxALL, 10).Expand()); - - wxSizer* szrButton = CreateButtonSizer(wxOK); - if (szrButton) - { - boxSizer->Add(szrButton, wxSizerFlags().Center()); - } - SetSizerAndFit(boxSizer); } void ExchangeStatusDialog::UpdateStuff(Api* api) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index 2de4891..349d9a9 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -213,3 +213,55 @@ ExchangeAnnouncementsDialog::ExchangeAnnouncementsDialog( wxWindow* parent, wxWi ExchangeAnnouncementsDialog::~ExchangeAnnouncementsDialog() { } + +ExchangeStatusDialog::ExchangeStatusDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* vszrContent; + vszrContent = new wxBoxSizer( wxVERTICAL ); + + wxGridSizer* gszrStatus; + gszrStatus = new wxGridSizer( 0, 2, 0, 0 ); + + wxStaticText* lblExchange; + lblExchange = new wxStaticText( this, wxID_ANY, _("Exchange"), wxDefaultPosition, wxDefaultSize, 0 ); + lblExchange->Wrap( -1 ); + gszrStatus->Add( lblExchange, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblExchangeStatus = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblExchangeStatus->Wrap( -1 ); + gszrStatus->Add( lblExchangeStatus, 0, wxALL, 5 ); + + wxStaticText* lblTrading; + lblTrading = new wxStaticText( this, wxID_ANY, _("Trading"), wxDefaultPosition, wxDefaultSize, 0 ); + lblTrading->Wrap( -1 ); + gszrStatus->Add( lblTrading, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblTradingStatus = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblTradingStatus->Wrap( -1 ); + gszrStatus->Add( lblTradingStatus, 0, wxALL, 5 ); + + + vszrContent->Add( gszrStatus, 1, wxEXPAND, 5 ); + + wxStdDialogButtonSizer* szrStandardButtons; + wxButton* szrStandardButtonsOK; + szrStandardButtons = new wxStdDialogButtonSizer(); + szrStandardButtonsOK = new wxButton( this, wxID_OK ); + szrStandardButtons->AddButton( szrStandardButtonsOK ); + szrStandardButtons->Realize(); + + vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); + + + this->SetSizer( vszrContent ); + this->Layout(); + vszrContent->Fit( this ); + + this->Centre( wxBOTH ); +} + +ExchangeStatusDialog::~ExchangeStatusDialog() +{ +} diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 157cf25..08e14d0 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -898,5 +898,320 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + ExchangeStatusDialog + + + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + Exchange Status + + 0 + + + + + + vszrContent + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + 2 + 0 + + gszrStatus + none + 0 + 0 + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Exchange + 0 + + 0 + + + 0 + + 1 + lblExchange + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + + 0 + + 1 + lblExchangeStatus + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Trading + 0 + + 0 + + + 0 + + 1 + lblTrading + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + + 0 + + 1 + lblTradingStatus + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 5 + wxEXPAND + 0 + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + + szrStandardButtons + none + + + + diff --git a/src/wxfb/App.h b/src/wxfb/App.h index 492045b..035c150 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -121,6 +121,25 @@ namespace kdeck }; + /////////////////////////////////////////////////////////////////////////////// + /// Class ExchangeStatusDialog + /////////////////////////////////////////////////////////////////////////////// + class ExchangeStatusDialog : public wxDialog + { + private: + + protected: + wxStaticText* lblExchangeStatus; + wxStaticText* lblTradingStatus; + + public: + + ExchangeStatusDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Exchange Status"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); + + ~ExchangeStatusDialog(); + + }; + } // namespace wxfb } // namespace kdeck From 293c56a184fb9555470db7125d7f19755037725e Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 09:02:23 -0700 Subject: [PATCH 15/26] Add ExchangeScheduleDialog to wxFormBuilderProject. --- include/ui/ExchangeScheduleDialog.hpp | 20 +- src/ui/ExchangeScheduleDialog.cpp | 114 +-- src/wxfb/App.cpp | 125 +++ src/wxfb/App.fbp | 1211 +++++++++++++++++++++++++ src/wxfb/App.h | 28 + 5 files changed, 1384 insertions(+), 114 deletions(-) diff --git a/include/ui/ExchangeScheduleDialog.hpp b/include/ui/ExchangeScheduleDialog.hpp index 2a86ab1..617537e 100644 --- a/include/ui/ExchangeScheduleDialog.hpp +++ b/include/ui/ExchangeScheduleDialog.hpp @@ -3,30 +3,18 @@ #include +#include "App.h" // wxfb + namespace kdeck { class Api; - class ExchangeScheduleDialog : public wxDialog + class ExchangeScheduleDialog : public wxfb::ExchangeScheduleDialog { public: - ExchangeScheduleDialog(wxWindow* parent, wxWindowID winid = wxID_ANY, const wxString &title = "Exchange Schedule"); + ExchangeScheduleDialog(wxWindow* parent, wxWindowID winid = wxID_ANY); void UpdateStuff(Api* api); - - private: - wxStaticText* lblSundaySchedule; - wxStaticText* lblMondaySchedule; - wxStaticText* lblTuesdaySchedule; - wxStaticText* lblWednesdaySchedule; - wxStaticText* lblThursdaySchedule; - wxStaticText* lblFridaySchedule; - wxStaticText* lblSaturdaySchedule; - - wxBoxSizer* boxSizer; - - // init - void Setup(); }; } diff --git a/src/ui/ExchangeScheduleDialog.cpp b/src/ui/ExchangeScheduleDialog.cpp index 5de7349..eeb7972 100644 --- a/src/ui/ExchangeScheduleDialog.cpp +++ b/src/ui/ExchangeScheduleDialog.cpp @@ -1,6 +1,8 @@ #include #include +#include "App.h" // wxfb + #include "api/Api.hpp" #include "ui/ExchangeScheduleDialog.hpp" #include "ui/event.hpp" @@ -12,89 +14,15 @@ namespace kdeck // constructor //////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// - ExchangeScheduleDialog::ExchangeScheduleDialog(wxWindow* parent, wxWindowID winid, const wxString &title) - : wxDialog(parent, winid, title) - { - Setup(); - } - - // init /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - - void ExchangeScheduleDialog::Setup() + ExchangeScheduleDialog::ExchangeScheduleDialog(wxWindow* parent, wxWindowID winid) + : wxfb::ExchangeScheduleDialog(parent, winid) { - wxStaticText* lblSunday = new wxStaticText(this, wxID_ANY, "Sunday:"); - lblSundaySchedule = new wxStaticText(this, wxID_ANY, ""); - - wxStaticText* lblMonday = new wxStaticText(this, wxID_ANY, "Monday:"); - lblMondaySchedule = new wxStaticText(this, wxID_ANY, ""); - - wxStaticText* lblTuesday = new wxStaticText(this, wxID_ANY, "Tuesday:"); - lblTuesdaySchedule = new wxStaticText(this, wxID_ANY, ""); - - wxStaticText* lblWednesday = new wxStaticText(this, wxID_ANY, "Wednesday:"); - lblWednesdaySchedule = new wxStaticText(this, wxID_ANY, ""); - - wxStaticText* lblThursday = new wxStaticText(this, wxID_ANY, "Thursday:"); - lblThursdaySchedule = new wxStaticText(this, wxID_ANY, ""); - - wxStaticText* lblFriday = new wxStaticText(this, wxID_ANY, "Friday:"); - lblFridaySchedule = new wxStaticText(this, wxID_ANY, ""); - - wxStaticText* lblSaturday = new wxStaticText(this, wxID_ANY, "Saturday:"); - lblSaturdaySchedule = new wxStaticText(this, wxID_ANY, ""); - - /////////////////////////////////////////////////////////////////////////// - - wxGridSizer* gridSizer = new wxGridSizer(7, 2, wxSize{10, 10}); - - wxSizerFlags flagsLblLeft = wxSizerFlags().CenterVertical().Left(); - wxSizerFlags flagsLblRight = wxSizerFlags().CenterVertical().Right(); - - gridSizer->Add(lblSunday, flagsLblRight); - gridSizer->Add(lblSundaySchedule, flagsLblLeft); - - gridSizer->Add(lblMonday, flagsLblRight); - gridSizer->Add(lblMondaySchedule, flagsLblLeft); - - gridSizer->Add(lblTuesday, flagsLblRight); - gridSizer->Add(lblTuesdaySchedule, flagsLblLeft); - - gridSizer->Add(lblWednesday, flagsLblRight); - gridSizer->Add(lblWednesdaySchedule, flagsLblLeft); - gridSizer->Add(lblThursday, flagsLblRight); - gridSizer->Add(lblThursdaySchedule, flagsLblLeft); - - gridSizer->Add(lblFriday, flagsLblRight); - gridSizer->Add(lblFridaySchedule, flagsLblLeft); - - gridSizer->Add(lblSaturday, flagsLblRight); - gridSizer->Add(lblSaturdaySchedule, flagsLblLeft); - - /////////////////////////////////////////////////////////////////////////// - - boxSizer = new wxBoxSizer(wxVERTICAL); - - wxBoxSizer* szr = new wxBoxSizer(wxVERTICAL); - - wxSizerFlags flags = wxSizerFlags().Border(wxALL, 10).Expand(); - - szr->Add(gridSizer, flags); - szr->Add(boxSizer, flags); - - wxSizer* szrButton = CreateButtonSizer(wxOK); - if (szrButton) - { - szr->Add(szrButton, wxSizerFlags().Center()); - } - - SetSizerAndFit(szr); } void ExchangeScheduleDialog::UpdateStuff(Api* api) { - boxSizer->Clear(); + gszrMaintenanceSchedule->Clear(); try { @@ -108,30 +36,20 @@ namespace kdeck lblFridaySchedule->SetLabel(wxString::Format(L"%s—%s ET", schedule->schedule->standard_hours->friday->open_time->c_str(), schedule->schedule->standard_hours->friday->close_time->c_str())); lblSaturdaySchedule->SetLabel(wxString::Format(L"%s—%s ET", schedule->schedule->standard_hours->saturday->open_time->c_str(), schedule->schedule->standard_hours->saturday->close_time->c_str())); - if (schedule->schedule->maintenance_windows->empty()) - { - boxSizer->Add(new wxStaticText(this, wxID_ANY, "No scheduled maintenance closures."), wxSizerFlags().Center()); - } - else - { - boxSizer->Add(new wxStaticText(this, wxID_ANY, "Scheduled maintenance closures:"), wxSizerFlags().Center()); - - wxGridSizer* gridSizer = new wxGridSizer(0, 2, wxSize{10, 10}); + bool hasMaintenanceScheduled = !schedule->schedule->maintenance_windows->empty(); - wxSizerFlags flagsLblCenter = wxSizerFlags().CenterVertical().Center(); - wxSizerFlags flagsLblLeft = wxSizerFlags().CenterVertical().Left(); + lblScheduledMaintenance->Show(hasMaintenanceScheduled); + gszrMaintenanceScheduleColumns->Show(hasMaintenanceScheduled); + gszrMaintenanceSchedule->Show(hasMaintenanceScheduled); - gridSizer->Add(new wxStaticText(this, wxID_ANY, "Start"), flagsLblCenter); - gridSizer->Add(new wxStaticText(this, wxID_ANY, "End"), flagsLblCenter); - - for (auto maint : *schedule->schedule->maintenance_windows) - { - gridSizer->Add(new wxStaticText(this, wxID_ANY, maint->start_datetime->c_str()), flagsLblLeft); - gridSizer->Add(new wxStaticText(this, wxID_ANY, maint->end_datetime->c_str()), flagsLblLeft); - } - - boxSizer->Add(gridSizer); + wxSizerFlags flagsLblLeft = wxSizerFlags().CenterVertical().Left(); + for (auto maint : *schedule->schedule->maintenance_windows) + { + gszrMaintenanceSchedule->Add(new wxStaticText(this, wxID_ANY, maint->start_datetime->c_str()), flagsLblLeft); + gszrMaintenanceSchedule->Add(new wxStaticText(this, wxID_ANY, maint->end_datetime->c_str()), flagsLblLeft); } + + lblNoScheduledMaintenance->Show(!hasMaintenanceScheduled); } catch (const std::exception &e) { diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index 349d9a9..e1a14bb 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -214,6 +214,131 @@ ExchangeAnnouncementsDialog::~ExchangeAnnouncementsDialog() { } +ExchangeScheduleDialog::ExchangeScheduleDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* vszrContent; + vszrContent = new wxBoxSizer( wxVERTICAL ); + + wxGridSizer* gszrSchedule; + gszrSchedule = new wxGridSizer( 0, 2, 0, 0 ); + + wxStaticText* lblSunday; + lblSunday = new wxStaticText( this, wxID_ANY, _("Sunday"), wxDefaultPosition, wxDefaultSize, 0 ); + lblSunday->Wrap( -1 ); + gszrSchedule->Add( lblSunday, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblSundaySchedule = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblSundaySchedule->Wrap( -1 ); + gszrSchedule->Add( lblSundaySchedule, 0, wxALIGN_LEFT|wxALL, 5 ); + + wxStaticText* lblMonday; + lblMonday = new wxStaticText( this, wxID_ANY, _("Monday"), wxDefaultPosition, wxDefaultSize, 0 ); + lblMonday->Wrap( -1 ); + gszrSchedule->Add( lblMonday, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblMondaySchedule = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblMondaySchedule->Wrap( -1 ); + gszrSchedule->Add( lblMondaySchedule, 0, wxALL, 5 ); + + wxStaticText* lblTuesday; + lblTuesday = new wxStaticText( this, wxID_ANY, _("Tuesday"), wxDefaultPosition, wxDefaultSize, 0 ); + lblTuesday->Wrap( -1 ); + gszrSchedule->Add( lblTuesday, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblTuesdaySchedule = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblTuesdaySchedule->Wrap( -1 ); + gszrSchedule->Add( lblTuesdaySchedule, 0, wxALL, 5 ); + + wxStaticText* lblWednesday; + lblWednesday = new wxStaticText( this, wxID_ANY, _("Wednesday"), wxDefaultPosition, wxDefaultSize, 0 ); + lblWednesday->Wrap( -1 ); + gszrSchedule->Add( lblWednesday, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblWednesdaySchedule = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblWednesdaySchedule->Wrap( -1 ); + gszrSchedule->Add( lblWednesdaySchedule, 0, wxALL, 5 ); + + wxStaticText* lblThursday; + lblThursday = new wxStaticText( this, wxID_ANY, _("Thursday"), wxDefaultPosition, wxDefaultSize, 0 ); + lblThursday->Wrap( -1 ); + gszrSchedule->Add( lblThursday, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblThursdaySchedule = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblThursdaySchedule->Wrap( -1 ); + gszrSchedule->Add( lblThursdaySchedule, 0, wxALL, 5 ); + + wxStaticText* lblFriday; + lblFriday = new wxStaticText( this, wxID_ANY, _("Friday"), wxDefaultPosition, wxDefaultSize, 0 ); + lblFriday->Wrap( -1 ); + gszrSchedule->Add( lblFriday, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblFridaySchedule = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblFridaySchedule->Wrap( -1 ); + gszrSchedule->Add( lblFridaySchedule, 0, wxALL, 5 ); + + wxStaticText* lblSaturday; + lblSaturday = new wxStaticText( this, wxID_ANY, _("Saturday"), wxDefaultPosition, wxDefaultSize, 0 ); + lblSaturday->Wrap( -1 ); + gszrSchedule->Add( lblSaturday, 0, wxALIGN_RIGHT|wxALL, 5 ); + + lblSaturdaySchedule = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + lblSaturdaySchedule->Wrap( -1 ); + gszrSchedule->Add( lblSaturdaySchedule, 0, wxALL, 5 ); + + + vszrContent->Add( gszrSchedule, 1, wxEXPAND, 5 ); + + lblScheduledMaintenance = new wxStaticText( this, wxID_ANY, _("Scheduled Maintenance Closures"), wxDefaultPosition, wxDefaultSize, 0 ); + lblScheduledMaintenance->Wrap( -1 ); + vszrContent->Add( lblScheduledMaintenance, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + + gszrMaintenanceScheduleColumns = new wxGridSizer( 0, 2, 0, 0 ); + + wxStaticText* lblStart; + lblStart = new wxStaticText( this, wxID_ANY, _("Start"), wxDefaultPosition, wxDefaultSize, 0 ); + lblStart->Wrap( -1 ); + gszrMaintenanceScheduleColumns->Add( lblStart, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + + wxStaticText* m_staticText118; + m_staticText118 = new wxStaticText( this, wxID_ANY, _("End"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText118->Wrap( -1 ); + gszrMaintenanceScheduleColumns->Add( m_staticText118, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxLEFT, 5 ); + + + vszrContent->Add( gszrMaintenanceScheduleColumns, 0, wxEXPAND, 5 ); + + gszrMaintenanceSchedule = new wxGridSizer( 0, 2, 0, 0 ); + + + vszrContent->Add( gszrMaintenanceSchedule, 1, wxEXPAND, 5 ); + + lblNoScheduledMaintenance = new wxStaticText( this, wxID_ANY, _("There are no scheduled maintenance closures."), wxDefaultPosition, wxDefaultSize, 0 ); + lblNoScheduledMaintenance->Wrap( -1 ); + vszrContent->Add( lblNoScheduledMaintenance, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + + wxStdDialogButtonSizer* szrStandardButtons; + wxButton* szrStandardButtonsOK; + szrStandardButtons = new wxStdDialogButtonSizer(); + szrStandardButtonsOK = new wxButton( this, wxID_OK ); + szrStandardButtons->AddButton( szrStandardButtonsOK ); + szrStandardButtons->Realize(); + + vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); + + + this->SetSizer( vszrContent ); + this->Layout(); + vszrContent->Fit( this ); + + this->Centre( wxBOTH ); +} + +ExchangeScheduleDialog::~ExchangeScheduleDialog() +{ +} + ExchangeStatusDialog::ExchangeStatusDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 08e14d0..093bbea 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -898,6 +898,1217 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + ExchangeScheduleDialog + + + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + Exchange Schedule + + 0 + + + + + + vszrContent + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + 2 + 0 + + gszrSchedule + none + 0 + 0 + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Sunday + 0 + + 0 + + + 0 + + 1 + lblSunday + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_LEFT|wxALL + 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 + lblSundaySchedule + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Monday + 0 + + 0 + + + 0 + + 1 + lblMonday + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + + 0 + + 1 + lblMondaySchedule + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Tuesday + 0 + + 0 + + + 0 + + 1 + lblTuesday + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + + 0 + + 1 + lblTuesdaySchedule + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Wednesday + 0 + + 0 + + + 0 + + 1 + lblWednesday + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + + 0 + + 1 + lblWednesdaySchedule + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Thursday + 0 + + 0 + + + 0 + + 1 + lblThursday + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + + 0 + + 1 + lblThursdaySchedule + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Friday + 0 + + 0 + + + 0 + + 1 + lblFriday + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + + 0 + + 1 + lblFridaySchedule + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Saturday + 0 + + 0 + + + 0 + + 1 + lblSaturday + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 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 + + 0 + + 0 + + + 0 + + 1 + lblSaturdaySchedule + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Scheduled Maintenance Closures + 0 + + 0 + + + 0 + + 1 + lblScheduledMaintenance + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 0 + + 2 + 0 + + gszrMaintenanceScheduleColumns + protected + 0 + 0 + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Start + 0 + + 0 + + + 0 + + 1 + lblStart + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + End + 0 + + 0 + + + 0 + + 1 + m_staticText118 + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 5 + wxEXPAND + 1 + + 2 + 0 + + gszrMaintenanceSchedule + protected + 0 + 0 + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + There are no scheduled maintenance closures. + 0 + + 0 + + + 0 + + 1 + lblNoScheduledMaintenance + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 0 + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + + szrStandardButtons + none + + + + 0 wxAUI_MGR_DEFAULT diff --git a/src/wxfb/App.h b/src/wxfb/App.h index 035c150..9c1c2dd 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -121,6 +121,34 @@ namespace kdeck }; + /////////////////////////////////////////////////////////////////////////////// + /// Class ExchangeScheduleDialog + /////////////////////////////////////////////////////////////////////////////// + class ExchangeScheduleDialog : public wxDialog + { + private: + + protected: + wxStaticText* lblSundaySchedule; + wxStaticText* lblMondaySchedule; + wxStaticText* lblTuesdaySchedule; + wxStaticText* lblWednesdaySchedule; + wxStaticText* lblThursdaySchedule; + wxStaticText* lblFridaySchedule; + wxStaticText* lblSaturdaySchedule; + wxStaticText* lblScheduledMaintenance; + wxGridSizer* gszrMaintenanceScheduleColumns; + wxGridSizer* gszrMaintenanceSchedule; + wxStaticText* lblNoScheduledMaintenance; + + public: + + ExchangeScheduleDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Exchange Schedule"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); + + ~ExchangeScheduleDialog(); + + }; + /////////////////////////////////////////////////////////////////////////////// /// Class ExchangeStatusDialog /////////////////////////////////////////////////////////////////////////////// From c0029351a97f00ce1cca3caa1a3888eb192bd57f Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 09:02:39 -0700 Subject: [PATCH 16/26] Remove hard-coded title for ExchangeStatusDialog. --- include/ui/ExchangeStatusDialog.hpp | 2 +- src/ui/ExchangeStatusDialog.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ui/ExchangeStatusDialog.hpp b/include/ui/ExchangeStatusDialog.hpp index 81ddbe8..bb0c769 100644 --- a/include/ui/ExchangeStatusDialog.hpp +++ b/include/ui/ExchangeStatusDialog.hpp @@ -12,7 +12,7 @@ namespace kdeck class ExchangeStatusDialog : public wxfb::ExchangeStatusDialog { public: - ExchangeStatusDialog(wxWindow* parent, wxWindowID winid = wxID_ANY, const wxString &title = "Exchange Status"); + ExchangeStatusDialog(wxWindow* parent, wxWindowID winid = wxID_ANY); void UpdateStuff(Api* api); }; diff --git a/src/ui/ExchangeStatusDialog.cpp b/src/ui/ExchangeStatusDialog.cpp index 91861c2..dff7ac9 100644 --- a/src/ui/ExchangeStatusDialog.cpp +++ b/src/ui/ExchangeStatusDialog.cpp @@ -11,8 +11,8 @@ namespace kdeck // constructor //////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// - ExchangeStatusDialog::ExchangeStatusDialog(wxWindow* parent, wxWindowID winid, const wxString &title) - : wxfb::ExchangeStatusDialog(parent, winid, title) + ExchangeStatusDialog::ExchangeStatusDialog(wxWindow* parent, wxWindowID winid) + : wxfb::ExchangeStatusDialog(parent, winid) { } From 0c45a63d65bfb288c679d5c490ace757121c9cbd Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 09:02:48 -0700 Subject: [PATCH 17/26] Cleanup. --- src/ui/ExchangeAnnouncementsDialog.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ui/ExchangeAnnouncementsDialog.cpp b/src/ui/ExchangeAnnouncementsDialog.cpp index 7e31b3d..f4e4616 100644 --- a/src/ui/ExchangeAnnouncementsDialog.cpp +++ b/src/ui/ExchangeAnnouncementsDialog.cpp @@ -19,9 +19,6 @@ namespace kdeck } - // init /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - void ExchangeAnnouncementsDialog::UpdateStuff(Api* api) { fgszrAnnouncements->Clear(); @@ -33,17 +30,17 @@ namespace kdeck bool hasAnnouncements = !announcements->announcements->empty(); fgszrAnnouncements->Show(hasAnnouncements); - lblNoAnnouncements->Show(!hasAnnouncements); + wxSizerFlags flagsLbl = wxSizerFlags().Border(wxLEFT, 10).CenterVertical(); for (auto announcement : *announcements->announcements) { - wxSizerFlags flagsLbl = wxSizerFlags().Border(wxLEFT, 10).CenterVertical(); - fgszrAnnouncements->Add(new wxStaticText(this, wxID_ANY, announcement->delivery_time->c_str()), flagsLbl); fgszrAnnouncements->Add(new wxStaticText(this, wxID_ANY, announcement->status->c_str()), flagsLbl); fgszrAnnouncements->Add(new wxStaticText(this, wxID_ANY, announcement->type->c_str()), flagsLbl); fgszrAnnouncements->Add(new wxStaticText(this, wxID_ANY, announcement->message->c_str()), flagsLbl); } + + lblNoAnnouncements->Show(!hasAnnouncements); } catch (const std::exception &e) { From ce1c14a9327dd79695c4e8bd364b87ad114fef9d Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 09:03:13 -0700 Subject: [PATCH 18/26] Cleanup. --- src/wxfb/App.cpp | 14 +++++++------- src/wxfb/App.fbp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index e1a14bb..e7a0e1c 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -125,27 +125,27 @@ LoginDialog::LoginDialog( wxWindow* parent, wxWindowID id, const wxString& title wxBoxSizer* vszrContent; vszrContent = new wxBoxSizer( wxVERTICAL ); - wxGridSizer* gridInputs; - gridInputs = new wxGridSizer( 0, 2, 0, 0 ); + wxGridSizer* gszrInputs; + gszrInputs = new wxGridSizer( 0, 2, 0, 0 ); wxStaticText* lblEmail; lblEmail = new wxStaticText( this, wxID_ANY, _("Email"), wxDefaultPosition, wxDefaultSize, 0 ); lblEmail->Wrap( -1 ); - gridInputs->Add( lblEmail, 0, wxALIGN_RIGHT|wxALL, 5 ); + gszrInputs->Add( lblEmail, 0, wxALIGN_RIGHT|wxALL, 5 ); txtEmail = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - gridInputs->Add( txtEmail, 0, wxALL|wxEXPAND, 5 ); + gszrInputs->Add( txtEmail, 0, wxALL|wxEXPAND, 5 ); wxStaticText* lblPassword; lblPassword = new wxStaticText( this, wxID_ANY, _("Password"), wxDefaultPosition, wxDefaultSize, 0 ); lblPassword->Wrap( -1 ); - gridInputs->Add( lblPassword, 0, wxALIGN_RIGHT|wxALL, 5 ); + gszrInputs->Add( lblPassword, 0, wxALIGN_RIGHT|wxALL, 5 ); txtPassword = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); - gridInputs->Add( txtPassword, 0, wxALL|wxEXPAND, 5 ); + gszrInputs->Add( txtPassword, 0, wxALL|wxEXPAND, 5 ); - vszrContent->Add( gridInputs, 1, wxEXPAND, 5 ); + vszrContent->Add( gszrInputs, 1, wxEXPAND, 5 ); chkRememberMe = new wxCheckBox( this, wxID_ANY, _("Remember me"), wxDefaultPosition, wxDefaultSize, 0 ); vszrContent->Add( chkRememberMe, 0, wxALL, 5 ); diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 093bbea..ab3834f 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -420,7 +420,7 @@ 2 0 - gridInputs + gszrInputs none 0 0 From 453f07e8f322a9f3aaee8d9fed4665c95eae9aee Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 09:08:46 -0700 Subject: [PATCH 19/26] Center align standard buttons. --- src/wxfb/App.cpp | 8 ++++---- src/wxfb/App.fbp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index e7a0e1c..b4ecf20 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -160,7 +160,7 @@ LoginDialog::LoginDialog( wxWindow* parent, wxWindowID id, const wxString& title szrStandardButtons->AddButton( szrStandardButtonsCancel ); szrStandardButtons->Realize(); - vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); + vszrContent->Add( szrStandardButtons, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); this->SetSizer( vszrContent ); @@ -200,7 +200,7 @@ ExchangeAnnouncementsDialog::ExchangeAnnouncementsDialog( wxWindow* parent, wxWi szrStandardButtons->AddButton( szrStandardButtonsOK ); szrStandardButtons->Realize(); - vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); + vszrContent->Add( szrStandardButtons, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); this->SetSizer( vszrContent ); @@ -325,7 +325,7 @@ ExchangeScheduleDialog::ExchangeScheduleDialog( wxWindow* parent, wxWindowID id, szrStandardButtons->AddButton( szrStandardButtonsOK ); szrStandardButtons->Realize(); - vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); + vszrContent->Add( szrStandardButtons, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); this->SetSizer( vszrContent ); @@ -377,7 +377,7 @@ ExchangeStatusDialog::ExchangeStatusDialog( wxWindow* parent, wxWindowID id, con szrStandardButtons->AddButton( szrStandardButtonsOK ); szrStandardButtons->Realize(); - vszrContent->Add( szrStandardButtons, 0, wxEXPAND, 5 ); + vszrContent->Add( szrStandardButtons, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); this->SetSizer( vszrContent ); diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index ab3834f..119f8c5 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -747,7 +747,7 @@ 5 - wxEXPAND + wxALIGN_CENTER_HORIZONTAL 0 0 @@ -880,7 +880,7 @@ 5 - wxEXPAND + wxALIGN_CENTER_HORIZONTAL 0 0 @@ -2091,7 +2091,7 @@ 5 - wxEXPAND + wxALIGN_CENTER_HORIZONTAL 0 0 @@ -2406,7 +2406,7 @@ 5 - wxEXPAND + wxALIGN_CENTER_HORIZONTAL 0 0 From d6c120b26d58fe2120717529e565c18f148dd3e1 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 09:46:35 -0700 Subject: [PATCH 20/26] Add note in README about wxFormBuilder. --- README.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5f39538..e1a4aea 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ vcpkg is designed to statically compile programs and makes it difficult to rely However, a number of build tools are required to be present on the system. A `Dockerfile` documents which packages must be installed to acquire the necessary tools on a Debian-based system. You may install these directly or use the Docker-based build. +### Design Tools + +This project makes use of [wxFormBuilder](https://github.com/wxFormBuilder/wxFormBuilder) for rapid UI iteration. The project file and generated classes can be found under `src/wxfb`. + ## Build Steps > [!NOTE] @@ -99,16 +103,6 @@ For subsequent builds, vcpkg will make use of the binary cache under `$(pwd)/bui > [!WARNING] > This is the default vcpkg binary cache directory for this project. If your host system is Debian 12 (Bookworm), it should be safe to bind-mount this directory and share installed dependencies with the container. Users on other systems wishing to build with and without Docker may want to bind-mount to a different host directory (although builds targeting different system triplets can coexist). -## Design Tools - -This project is **not yet** making use of wxWidgets' XRC support. In the future, one of the following design tools will be recommended for work on the kdeck project: - -* codeblocks -* codelite -* wxglade - -**Suggestions are welcome.** - ## Kalshi API Kalshi provides a [REST API](https://trading-api.readme.io/reference/getting-started) for getting portfolio information and making trades, among other things. kdeck uses the [Oat++](https://oatpp.io/) library to make API requests[^1]. From 56317eb48b0fba79e02be800f1dc169ede76a219 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 11:51:16 -0700 Subject: [PATCH 21/26] Cleanup. --- include/ui/MainFrame.hpp | 2 -- src/ui/MainFrame.cpp | 1 - 2 files changed, 3 deletions(-) diff --git a/include/ui/MainFrame.hpp b/include/ui/MainFrame.hpp index 36e8885..3eb5f70 100644 --- a/include/ui/MainFrame.hpp +++ b/include/ui/MainFrame.hpp @@ -11,8 +11,6 @@ namespace kdeck { - class PortfolioPanel; - class MainFrame : public wxfb::MainFrame { public: diff --git a/src/ui/MainFrame.cpp b/src/ui/MainFrame.cpp index f2d6f9a..de0d196 100644 --- a/src/ui/MainFrame.cpp +++ b/src/ui/MainFrame.cpp @@ -12,7 +12,6 @@ #include "ui/ExchangeStatusDialog.hpp" #include "ui/MainFrame.hpp" #include "ui/LoginDialog.hpp" -#include "ui/PortfolioPanel.hpp" #include "ui/event.hpp" namespace kdeck From e550cd80b6a7b9a558eb2379d32b02496c1fc957 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:27:12 -0700 Subject: [PATCH 22/26] Add new wxFormBuilder project for custom control. This is required due to interdependencies that were breaking includes in the generated files. --- src/wxfb/CMakeLists.txt | 1 + src/wxfb/PortfolioPanel.cpp | 38 +++++++ src/wxfb/PortfolioPanel.fbp | 195 ++++++++++++++++++++++++++++++++++++ src/wxfb/PortfolioPanel.h | 51 ++++++++++ 4 files changed, 285 insertions(+) create mode 100644 src/wxfb/PortfolioPanel.cpp create mode 100644 src/wxfb/PortfolioPanel.fbp create mode 100644 src/wxfb/PortfolioPanel.h diff --git a/src/wxfb/CMakeLists.txt b/src/wxfb/CMakeLists.txt index d40e964..7b37e29 100644 --- a/src/wxfb/CMakeLists.txt +++ b/src/wxfb/CMakeLists.txt @@ -2,6 +2,7 @@ project(wxfb) add_library(${PROJECT_NAME} STATIC App.cpp + PortfolioPanel.cpp ) target_include_directories(${PROJECT_NAME} diff --git a/src/wxfb/PortfolioPanel.cpp b/src/wxfb/PortfolioPanel.cpp new file mode 100644 index 0000000..b2fc0b1 --- /dev/null +++ b/src/wxfb/PortfolioPanel.cpp @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 4.2.1-33-g6494dcef) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "PortfolioPanel.h" + +/////////////////////////////////////////////////////////////////////////// +using namespace kdeck::wxfb; + +PortfolioPanel::PortfolioPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + wxBoxSizer* vszrContent; + vszrContent = new wxBoxSizer( wxVERTICAL ); + + pnlBalance = new BalancePanel(this); + vszrContent->Add( pnlBalance, 0, wxALL, 5 ); + + pnlPositions = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + pnlPositions->SetScrollRate( 5, 5 ); + vszrPositions = new wxBoxSizer( wxVERTICAL ); + + + pnlPositions->SetSizer( vszrPositions ); + pnlPositions->Layout(); + vszrPositions->Fit( pnlPositions ); + vszrContent->Add( pnlPositions, 1, wxEXPAND | wxALL, 5 ); + + + this->SetSizer( vszrContent ); + this->Layout(); +} + +PortfolioPanel::~PortfolioPanel() +{ +} diff --git a/src/wxfb/PortfolioPanel.fbp b/src/wxfb/PortfolioPanel.fbp new file mode 100644 index 0000000..b4157ff --- /dev/null +++ b/src/wxfb/PortfolioPanel.fbp @@ -0,0 +1,195 @@ + + + + + C++ + ; + 0 + connect + none + "kdeck" "wxfb" + + 0 + 1 + res + UTF-8 + PortfolioPanel + 6000 + 1 + 1 + UI + PortfolioPanel + . + 0 + source_name + 1 + 0 + source_name + + 1 + 1 + 1 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 0 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PortfolioPanel + + 500,300 + ; ; forward_declare + + 0 + + + wxTAB_TRAVERSAL + + + vszrContent + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + BalancePanel + 1 + pnlBalance = new BalancePanel(this); + + 1 + BalancePanel* pnlBalance; + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + #include "ui/BalancePanel.hpp" + + 0 + + + 0 + + 1 + pnlBalance + 1 + + + protected + 1 + + Resizable + + 1 + + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND | wxALL + 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 + pnlPositions + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + ; ; forward_declare + 0 + + + + wxHSCROLL|wxVSCROLL + + + vszrPositions + wxVERTICAL + protected + + + + + + + diff --git a/src/wxfb/PortfolioPanel.h b/src/wxfb/PortfolioPanel.h new file mode 100644 index 0000000..2aedf48 --- /dev/null +++ b/src/wxfb/PortfolioPanel.h @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 4.2.1-33-g6494dcef) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include "ui/BalancePanel.hpp" +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +namespace kdeck +{ + namespace wxfb + { + /////////////////////////////////////////////////////////////////////////////// + /// Class PortfolioPanel + /////////////////////////////////////////////////////////////////////////////// + class PortfolioPanel : public wxPanel + { + private: + + protected: + BalancePanel* pnlBalance; + wxScrolledWindow* pnlPositions; + wxBoxSizer* vszrPositions; + + public: + + PortfolioPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + + ~PortfolioPanel(); + + }; + + } // namespace wxfb +} // namespace kdeck + From 6dda7702fd717d17fab85bfec129dfe39d889f96 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:29:22 -0700 Subject: [PATCH 23/26] Base PortfolioPanel on new wxFormBuilder-generated type. To prevent confusion, namespaces are explicitly added in some places. --- include/ui/PortfolioPanel.hpp | 11 +++-------- src/ui/PortfolioPanel.cpp | 33 +++++++-------------------------- src/wxfb/App.cpp | 2 +- src/wxfb/App.fbp | 4 ++-- src/wxfb/App.h | 2 +- 5 files changed, 14 insertions(+), 38 deletions(-) diff --git a/include/ui/PortfolioPanel.hpp b/include/ui/PortfolioPanel.hpp index 18f3fb6..ec9c7dc 100644 --- a/include/ui/PortfolioPanel.hpp +++ b/include/ui/PortfolioPanel.hpp @@ -3,25 +3,20 @@ #include +#include "PortfolioPanel.h" // wxfb + namespace kdeck { class Api; class BalancePanel; class Config; - class PortfolioPanel : public wxScrolledWindow + class PortfolioPanel : public wxfb::PortfolioPanel { public: PortfolioPanel(wxWindow* parent, wxWindowID winid = wxID_ANY); void UpdateStuff(const Config* config, Api* api); - - private: - BalancePanel* pnlBalance; - wxPanel* pnlPositions; - - // init - void Setup(); }; } diff --git a/src/ui/PortfolioPanel.cpp b/src/ui/PortfolioPanel.cpp index aa6e42b..7efc538 100644 --- a/src/ui/PortfolioPanel.cpp +++ b/src/ui/PortfolioPanel.cpp @@ -1,5 +1,7 @@ #include +#include "PortfolioPanel.h" // wxfb + #include "api/Api.hpp" #include "config/Config.hpp" #include "ui/BalancePanel.hpp" @@ -14,31 +16,14 @@ namespace kdeck /////////////////////////////////////////////////////////////////////////////// PortfolioPanel::PortfolioPanel(wxWindow* parent, wxWindowID winid) - : wxScrolledWindow(parent, winid) + : wxfb::PortfolioPanel(parent, winid) { - Setup(); + } // init /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// - void PortfolioPanel::Setup() - { - pnlBalance = new BalancePanel(this); - - pnlPositions = new wxPanel(this); - - wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL); - - wxSizerFlags flags = wxSizerFlags().Border(wxALL, 10).Expand(); - - boxSizer->Add(pnlBalance, flags); - boxSizer->Add(pnlPositions, flags); - - SetSizerAndFit(boxSizer); - SetScrollRate(10, 10); - } - void PortfolioPanel::UpdateStuff(const Config* config, Api* api) { pnlBalance->UpdateStuff(api); @@ -51,10 +36,7 @@ namespace kdeck { api->GetPositions(); - wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL); - wxSizerFlags flags = wxSizerFlags().Border(wxUP | wxDOWN, 10).Expand(); - for (auto event : api->GetEventPositions()) { if (0 == *event->event_exposure && !config->GetShowClosedPositions()) @@ -62,7 +44,7 @@ namespace kdeck continue; } - boxSizer->Add(new EventPositionPanel(pnlPositions, wxID_ANY, event), flags); + vszrPositions->Add(new EventPositionPanel(pnlPositions, wxID_ANY, event), flags); for (auto market : api->GetMarketPositions(*event->event_ticker)) { @@ -71,11 +53,10 @@ namespace kdeck continue; } - boxSizer->Add(new MarketPositionPanel(pnlPositions, wxID_ANY, market), flags); + vszrPositions->Add(new MarketPositionPanel(pnlPositions, wxID_ANY, market), flags); } } - - pnlPositions->SetSizerAndFit(boxSizer); + pnlPositions->Layout(); } catch (const std::exception &e) { diff --git a/src/wxfb/App.cpp b/src/wxfb/App.cpp index b4ecf20..b5e7810 100644 --- a/src/wxfb/App.cpp +++ b/src/wxfb/App.cpp @@ -35,7 +35,7 @@ bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& title, wxBoxSizer* vszrContent; vszrContent = new wxBoxSizer( wxVERTICAL ); - pnlPortfolio = new PortfolioPanel(pnlRoot); + pnlPortfolio = new kdeck::PortfolioPanel(pnlRoot); vszrContent->Add( pnlPortfolio, 1, wxALL|wxEXPAND, 5 ); diff --git a/src/wxfb/App.fbp b/src/wxfb/App.fbp index 119f8c5..62d506c 100644 --- a/src/wxfb/App.fbp +++ b/src/wxfb/App.fbp @@ -148,10 +148,10 @@ 0 1 - pnlPortfolio = new PortfolioPanel(pnlRoot); + pnlPortfolio = new kdeck::PortfolioPanel(pnlRoot); 1 - PortfolioPanel* pnlPortfolio; + kdeck::PortfolioPanel* pnlPortfolio; 0 Dock 0 diff --git a/src/wxfb/App.h b/src/wxfb/App.h index 9c1c2dd..c4de319 100644 --- a/src/wxfb/App.h +++ b/src/wxfb/App.h @@ -55,7 +55,7 @@ namespace kdeck }; wxPanel* pnlRoot; - PortfolioPanel* pnlPortfolio; + kdeck::PortfolioPanel* pnlPortfolio; wxMenuBar* mnuBar; wxMenu* mnuFile; wxMenuItem* mnuLogin; From 1145656b2ca36e63700fa9912e2a8f98f576d595 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:50:15 -0700 Subject: [PATCH 24/26] Merge BalancePanel component into PortfolioPanel. --- include/ui/BalancePanel.hpp | 26 ----- include/ui/PortfolioPanel.hpp | 1 - src/ui/BalancePanel.cpp | 59 ---------- src/ui/CMakeLists.txt | 1 - src/ui/PortfolioPanel.cpp | 12 ++- src/wxfb/PortfolioPanel.cpp | 18 +++- src/wxfb/PortfolioPanel.fbp | 197 ++++++++++++++++++++++++---------- src/wxfb/PortfolioPanel.h | 7 +- 8 files changed, 168 insertions(+), 153 deletions(-) delete mode 100644 include/ui/BalancePanel.hpp delete mode 100644 src/ui/BalancePanel.cpp diff --git a/include/ui/BalancePanel.hpp b/include/ui/BalancePanel.hpp deleted file mode 100644 index f9e1b04..0000000 --- a/include/ui/BalancePanel.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef BALANCEPANEL_HPP -#define BALANCEPANEL_HPP - -#include - -namespace kdeck -{ - class Api; - class StaticCurrency; - - class BalancePanel : public wxPanel - { - public: - BalancePanel(wxWindow* parent, wxWindowID winid = wxID_ANY, double balance = 0.0); - - void UpdateStuff(Api* api); - - private: - StaticCurrency* lblBalanceAmount; - - // init - void Setup(); - }; -} - -#endif diff --git a/include/ui/PortfolioPanel.hpp b/include/ui/PortfolioPanel.hpp index ec9c7dc..ff2d79c 100644 --- a/include/ui/PortfolioPanel.hpp +++ b/include/ui/PortfolioPanel.hpp @@ -8,7 +8,6 @@ namespace kdeck { class Api; - class BalancePanel; class Config; class PortfolioPanel : public wxfb::PortfolioPanel diff --git a/src/ui/BalancePanel.cpp b/src/ui/BalancePanel.cpp deleted file mode 100644 index be57f75..0000000 --- a/src/ui/BalancePanel.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include - -#include "api/Api.hpp" -#include "ui/BalancePanel.hpp" -#include "ui/StaticCurrency.hpp" -#include "ui/event.hpp" - -namespace kdeck -{ - // constructor //////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - - BalancePanel::BalancePanel(wxWindow* parent, wxWindowID winid, double balance) - : wxPanel(parent, winid) - { - Setup(); - } - - // init /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - - void BalancePanel::Setup() - { - wxStaticText* lblBalance = new wxStaticText(this, wxID_ANY, "Balance:"); - lblBalanceAmount = new StaticCurrency(this); - - wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL); - - wxSizerFlags flagsLbl = wxSizerFlags().Border(wxLEFT, 10).CenterVertical(); - - boxSizer->AddStretchSpacer(); - boxSizer->Add(lblBalance, flagsLbl); - boxSizer->Add(lblBalanceAmount, flagsLbl); - - SetSizerAndFit(boxSizer); - } - - void BalancePanel::UpdateStuff(Api* api) - { - if (api->IsLoggedIn()) - { - try - { - lblBalanceAmount->SetAmount(api->GetBalance()); - } - catch (const std::exception &e) - { - wxCommandEvent* evt = new wxCommandEvent(EVT_API_ERROR); - evt->SetEventObject(this); - evt->SetString("Balance update failed!"); - QueueEvent(evt); - } - } - else - { - lblBalanceAmount->SetAmount(0); - } - } -} diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 8960c1a..7b65e77 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -2,7 +2,6 @@ project(ui) add_library(${PROJECT_NAME} STATIC App.cpp - BalancePanel.cpp EventPositionPanel.cpp ExchangeAnnouncementsDialog.cpp ExchangeScheduleDialog.cpp diff --git a/src/ui/PortfolioPanel.cpp b/src/ui/PortfolioPanel.cpp index 7efc538..4a5b1b0 100644 --- a/src/ui/PortfolioPanel.cpp +++ b/src/ui/PortfolioPanel.cpp @@ -4,7 +4,6 @@ #include "api/Api.hpp" #include "config/Config.hpp" -#include "ui/BalancePanel.hpp" #include "ui/PortfolioPanel.hpp" #include "ui/EventPositionPanel.hpp" #include "ui/MarketPositionPanel.hpp" @@ -26,14 +25,14 @@ namespace kdeck void PortfolioPanel::UpdateStuff(const Config* config, Api* api) { - pnlBalance->UpdateStuff(api); - pnlPositions->DestroyChildren(); if (api->IsLoggedIn()) { try { + lblBalanceAmount->SetAmount(api->GetBalance()); + api->GetPositions(); wxSizerFlags flags = wxSizerFlags().Border(wxUP | wxDOWN, 10).Expand(); @@ -56,7 +55,6 @@ namespace kdeck vszrPositions->Add(new MarketPositionPanel(pnlPositions, wxID_ANY, market), flags); } } - pnlPositions->Layout(); } catch (const std::exception &e) { @@ -66,5 +64,11 @@ namespace kdeck QueueEvent(evt); } } + else + { + lblBalanceAmount->SetAmount(0); + } + + Layout(); } } diff --git a/src/wxfb/PortfolioPanel.cpp b/src/wxfb/PortfolioPanel.cpp index b2fc0b1..bfe61b6 100644 --- a/src/wxfb/PortfolioPanel.cpp +++ b/src/wxfb/PortfolioPanel.cpp @@ -15,8 +15,22 @@ PortfolioPanel::PortfolioPanel( wxWindow* parent, wxWindowID id, const wxPoint& wxBoxSizer* vszrContent; vszrContent = new wxBoxSizer( wxVERTICAL ); - pnlBalance = new BalancePanel(this); - vszrContent->Add( pnlBalance, 0, wxALL, 5 ); + wxBoxSizer* hszrPortfolioInfo; + hszrPortfolioInfo = new wxBoxSizer( wxHORIZONTAL ); + + + hszrPortfolioInfo->Add( 0, 0, 1, wxEXPAND, 5 ); + + wxStaticText* lblBalance; + lblBalance = new wxStaticText( this, wxID_ANY, _("Balance"), wxDefaultPosition, wxDefaultSize, 0 ); + lblBalance->Wrap( -1 ); + hszrPortfolioInfo->Add( lblBalance, 0, wxALL, 5 ); + + lblBalanceAmount = new StaticCurrency(this); + hszrPortfolioInfo->Add( lblBalanceAmount, 0, wxALL, 5 ); + + + vszrContent->Add( hszrPortfolioInfo, 0, wxEXPAND, 5 ); pnlPositions = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); pnlPositions->SetScrollRate( 5, 5 ); diff --git a/src/wxfb/PortfolioPanel.fbp b/src/wxfb/PortfolioPanel.fbp index b4157ff..1eec4d3 100644 --- a/src/wxfb/PortfolioPanel.fbp +++ b/src/wxfb/PortfolioPanel.fbp @@ -62,65 +62,148 @@ none 5 - wxALL + wxEXPAND 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - BalancePanel - 1 - pnlBalance = new BalancePanel(this); - - 1 - BalancePanel* pnlBalance; - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - #include "ui/BalancePanel.hpp" - - 0 - - - 0 + - 1 - pnlBalance - 1 - - - protected - 1 - - Resizable - - 1 - - ; ; forward_declare - 0 - - - - + hszrPortfolioInfo + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 0 + none + 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 + Balance + 0 + + 0 + + + 0 + + 1 + lblBalance + 1 + + + none + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + + 1 + lblBalanceAmount = new StaticCurrency(this); + + 1 + StaticCurrency* lblBalanceAmount; + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + #include "ui/StaticCurrency.hpp" + + 0 + + + 0 + + 1 + lblBalanceAmount + 1 + + + protected + 1 + + Resizable + + 1 + + ; ; forward_declare + 0 + + + + + + diff --git a/src/wxfb/PortfolioPanel.h b/src/wxfb/PortfolioPanel.h index 2aedf48..5083c6b 100644 --- a/src/wxfb/PortfolioPanel.h +++ b/src/wxfb/PortfolioPanel.h @@ -10,12 +10,13 @@ #include #include #include -#include "ui/BalancePanel.hpp" +#include +#include #include #include #include #include -#include +#include "ui/StaticCurrency.hpp" #include #include #include @@ -34,7 +35,7 @@ namespace kdeck private: protected: - BalancePanel* pnlBalance; + StaticCurrency* lblBalanceAmount; wxScrolledWindow* pnlPositions; wxBoxSizer* vszrPositions; From a29305b7d3f3386f184fa83c3232a2b4a95a3e42 Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 13:30:21 -0700 Subject: [PATCH 25/26] Merge EventPositionPanel and MarketPositionPanel components into PortfolioPanel. --- include/ui/EventPositionPanel.hpp | 25 ------------- include/ui/MarketPositionPanel.hpp | 25 ------------- src/ui/CMakeLists.txt | 2 - src/ui/EventPositionPanel.cpp | 49 ------------------------ src/ui/MarketPositionPanel.cpp | 60 ------------------------------ src/ui/PortfolioPanel.cpp | 43 ++++++++++++++++++--- src/wxfb/PortfolioPanel.cpp | 9 +++-- src/wxfb/PortfolioPanel.fbp | 13 +++++-- src/wxfb/PortfolioPanel.h | 2 +- 9 files changed, 55 insertions(+), 173 deletions(-) delete mode 100644 include/ui/EventPositionPanel.hpp delete mode 100644 include/ui/MarketPositionPanel.hpp delete mode 100644 src/ui/EventPositionPanel.cpp delete mode 100644 src/ui/MarketPositionPanel.cpp diff --git a/include/ui/EventPositionPanel.hpp b/include/ui/EventPositionPanel.hpp deleted file mode 100644 index 66c37ba..0000000 --- a/include/ui/EventPositionPanel.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef EVENTTPOSITIONPANEL_HPP -#define EVENTTPOSITIONPANEL_HPP - -#include - -#include - -namespace kdeck -{ - class EventPosition; - - class EventPositionPanel : public wxPanel - { - public: - EventPositionPanel(wxWindow* parent, wxWindowID winid, std::shared_ptr event); - - private: - std::shared_ptr event; - - // init - void Setup(); - }; -} - -#endif diff --git a/include/ui/MarketPositionPanel.hpp b/include/ui/MarketPositionPanel.hpp deleted file mode 100644 index 9bfd27e..0000000 --- a/include/ui/MarketPositionPanel.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MARKETPOSITIONPANEL_HPP -#define MARKETPOSITIONPANEL_HPP - -#include - -#include - -namespace kdeck -{ - class MarketPosition; - - class MarketPositionPanel : public wxPanel - { - public: - MarketPositionPanel(wxWindow* parent, wxWindowID winid, std::shared_ptr market); - - private: - std::shared_ptr market; - - // init - void Setup(); - }; -} - -#endif diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 7b65e77..642dc83 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -2,13 +2,11 @@ project(ui) add_library(${PROJECT_NAME} STATIC App.cpp - EventPositionPanel.cpp ExchangeAnnouncementsDialog.cpp ExchangeScheduleDialog.cpp ExchangeStatusDialog.cpp LoginDialog.cpp MainFrame.cpp - MarketPositionPanel.cpp PortfolioPanel.cpp StaticCurrency.cpp event.cpp diff --git a/src/ui/EventPositionPanel.cpp b/src/ui/EventPositionPanel.cpp deleted file mode 100644 index 7df4731..0000000 --- a/src/ui/EventPositionPanel.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include - -#include - -#include - -#include "api/types.hpp" -#include "ui/EventPositionPanel.hpp" -#include "ui/StaticCurrency.hpp" - -namespace kdeck -{ - // constructor //////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - - EventPositionPanel::EventPositionPanel(wxWindow* parent, wxWindowID winid, std::shared_ptr event) - : wxPanel(parent, winid) - , event{event} - { - Setup(); - } - - // init /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - - void EventPositionPanel::Setup() - { - wxStaticText* lblTicker = new wxStaticText(this, wxID_ANY, *event->event_ticker); - wxStaticText* lblBlank = new wxStaticText(this, wxID_ANY, ""); - StaticCurrency* lblExposure = new StaticCurrency(this, wxID_ANY, *event->event_exposure); - StaticCurrency* lblRealizedPnL = new StaticCurrency(this, wxID_ANY, *event->realized_pnl); - StaticCurrency* lblTotalTraded = new StaticCurrency(this, wxID_ANY, *event->total_cost); - wxStaticText* lblRestingOrders = new wxStaticText(this, wxID_ANY, std::to_string(*event->resting_order_count)); - - wxGridSizer* gridSizer = new wxGridSizer(6, wxSize{10, 0}); - - wxSizerFlags flagsLblLeft = wxSizerFlags().CenterVertical().Left(); - wxSizerFlags flagsLblRight = wxSizerFlags().CenterVertical().Right(); - - gridSizer->Add(lblTicker, flagsLblLeft); - gridSizer->Add(lblBlank, flagsLblRight); - gridSizer->Add(lblExposure, flagsLblRight); - gridSizer->Add(lblRealizedPnL, flagsLblRight); - gridSizer->Add(lblTotalTraded, flagsLblRight); - gridSizer->Add(lblRestingOrders, flagsLblRight); - - SetSizerAndFit(gridSizer); - } -} diff --git a/src/ui/MarketPositionPanel.cpp b/src/ui/MarketPositionPanel.cpp deleted file mode 100644 index 98684cd..0000000 --- a/src/ui/MarketPositionPanel.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include - -#include - -#include -#include - -#include "api/types.hpp" -#include "ui/MarketPositionPanel.hpp" -#include "ui/StaticCurrency.hpp" - -namespace kdeck -{ - // constructor //////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - - MarketPositionPanel::MarketPositionPanel(wxWindow* parent, wxWindowID winid, std::shared_ptr market) - : wxPanel(parent, winid) - , market{market} - { - Setup(); - } - - // init /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// - - void MarketPositionPanel::Setup() - { - wxStaticText* lblTicker = new wxStaticText(this, wxID_ANY, *market->ticker); - - wxStaticText* lblPosition; - if (market->position > 0) - { - lblPosition = new wxStaticText(this, wxID_ANY, wxString::Format("Yes %d", std::abs(*market->position))); - } - else - { - lblPosition = new wxStaticText(this, wxID_ANY, wxString::Format("No %d", std::abs(*market->position))); - } - - StaticCurrency* lblExposure = new StaticCurrency(this, wxID_ANY, *market->market_exposure); - StaticCurrency* lblRealizedPnL = new StaticCurrency(this, wxID_ANY, *market->realized_pnl); - StaticCurrency* lblTotalTraded = new StaticCurrency(this, wxID_ANY, *market->total_traded); - wxStaticText* lblRestingOrders = new wxStaticText(this, wxID_ANY, std::to_string(*market->resting_orders_count)); - - wxGridSizer* gridSizer = new wxGridSizer(6, wxSize{10, 0}); - - wxSizerFlags flagsLblLeft = wxSizerFlags().CenterVertical().Left(); - wxSizerFlags flagsLblRight = wxSizerFlags().CenterVertical().Right(); - - gridSizer->Add(lblTicker, flagsLblLeft); - gridSizer->Add(lblPosition, flagsLblRight); - gridSizer->Add(lblExposure, flagsLblRight); - gridSizer->Add(lblRealizedPnL, flagsLblRight); - gridSizer->Add(lblTotalTraded, flagsLblRight); - gridSizer->Add(lblRestingOrders, flagsLblRight); - - SetSizerAndFit(gridSizer); - } -} diff --git a/src/ui/PortfolioPanel.cpp b/src/ui/PortfolioPanel.cpp index 4a5b1b0..c6c6c7c 100644 --- a/src/ui/PortfolioPanel.cpp +++ b/src/ui/PortfolioPanel.cpp @@ -5,8 +5,6 @@ #include "api/Api.hpp" #include "config/Config.hpp" #include "ui/PortfolioPanel.hpp" -#include "ui/EventPositionPanel.hpp" -#include "ui/MarketPositionPanel.hpp" #include "ui/event.hpp" namespace kdeck @@ -35,7 +33,8 @@ namespace kdeck api->GetPositions(); - wxSizerFlags flags = wxSizerFlags().Border(wxUP | wxDOWN, 10).Expand(); + wxSizerFlags flagsLblLeft = wxSizerFlags().CenterVertical().Left(); + wxSizerFlags flagsLblRight = wxSizerFlags().CenterVertical().Right(); for (auto event : api->GetEventPositions()) { if (0 == *event->event_exposure && !config->GetShowClosedPositions()) @@ -43,7 +42,19 @@ namespace kdeck continue; } - vszrPositions->Add(new EventPositionPanel(pnlPositions, wxID_ANY, event), flags); + wxStaticText* lblTicker = new wxStaticText(pnlPositions, wxID_ANY, *event->event_ticker); + wxStaticText* lblBlank = new wxStaticText(pnlPositions, wxID_ANY, ""); + StaticCurrency* lblExposure = new StaticCurrency(pnlPositions, wxID_ANY, *event->event_exposure); + StaticCurrency* lblRealizedPnL = new StaticCurrency(pnlPositions, wxID_ANY, *event->realized_pnl); + StaticCurrency* lblTotalTraded = new StaticCurrency(pnlPositions, wxID_ANY, *event->total_cost); + wxStaticText* lblRestingOrders = new wxStaticText(pnlPositions, wxID_ANY, std::to_string(*event->resting_order_count)); + + fgszrPositions->Add(lblTicker, flagsLblLeft); + fgszrPositions->Add(lblBlank, flagsLblRight); + fgszrPositions->Add(lblExposure, flagsLblRight); + fgszrPositions->Add(lblRealizedPnL, flagsLblRight); + fgszrPositions->Add(lblTotalTraded, flagsLblRight); + fgszrPositions->Add(lblRestingOrders, flagsLblRight); for (auto market : api->GetMarketPositions(*event->event_ticker)) { @@ -52,7 +63,29 @@ namespace kdeck continue; } - vszrPositions->Add(new MarketPositionPanel(pnlPositions, wxID_ANY, market), flags); + wxStaticText* lblTicker = new wxStaticText(pnlPositions, wxID_ANY, *market->ticker); + + wxStaticText* lblPosition; + if (market->position > 0) + { + lblPosition = new wxStaticText(pnlPositions, wxID_ANY, wxString::Format("Yes %d", std::abs(*market->position))); + } + else + { + lblPosition = new wxStaticText(pnlPositions, wxID_ANY, wxString::Format("No %d", std::abs(*market->position))); + } + + StaticCurrency* lblExposure = new StaticCurrency(pnlPositions, wxID_ANY, *market->market_exposure); + StaticCurrency* lblRealizedPnL = new StaticCurrency(pnlPositions, wxID_ANY, *market->realized_pnl); + StaticCurrency* lblTotalTraded = new StaticCurrency(pnlPositions, wxID_ANY, *market->total_traded); + wxStaticText* lblRestingOrders = new wxStaticText(pnlPositions, wxID_ANY, std::to_string(*market->resting_orders_count)); + + fgszrPositions->Add(lblTicker, flagsLblLeft); + fgszrPositions->Add(lblPosition, flagsLblRight); + fgszrPositions->Add(lblExposure, flagsLblRight); + fgszrPositions->Add(lblRealizedPnL, flagsLblRight); + fgszrPositions->Add(lblTotalTraded, flagsLblRight); + fgszrPositions->Add(lblRestingOrders, flagsLblRight); } } } diff --git a/src/wxfb/PortfolioPanel.cpp b/src/wxfb/PortfolioPanel.cpp index bfe61b6..84bc1ed 100644 --- a/src/wxfb/PortfolioPanel.cpp +++ b/src/wxfb/PortfolioPanel.cpp @@ -34,12 +34,15 @@ PortfolioPanel::PortfolioPanel( wxWindow* parent, wxWindowID id, const wxPoint& pnlPositions = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); pnlPositions->SetScrollRate( 5, 5 ); - vszrPositions = new wxBoxSizer( wxVERTICAL ); + fgszrPositions = new wxFlexGridSizer( 0, 6, 10, 10 ); + fgszrPositions->AddGrowableCol( 0 ); + fgszrPositions->SetFlexibleDirection( wxBOTH ); + fgszrPositions->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - pnlPositions->SetSizer( vszrPositions ); + pnlPositions->SetSizer( fgszrPositions ); pnlPositions->Layout(); - vszrPositions->Fit( pnlPositions ); + fgszrPositions->Fit( pnlPositions ); vszrContent->Add( pnlPositions, 1, wxEXPAND | wxALL, 5 ); diff --git a/src/wxfb/PortfolioPanel.fbp b/src/wxfb/PortfolioPanel.fbp index 1eec4d3..77d7d04 100644 --- a/src/wxfb/PortfolioPanel.fbp +++ b/src/wxfb/PortfolioPanel.fbp @@ -264,11 +264,18 @@ wxHSCROLL|wxVSCROLL - + + 6 + wxBOTH + 0 + + 10 - vszrPositions - wxVERTICAL + fgszrPositions + wxFLEX_GROWMODE_SPECIFIED protected + 0 + 10 diff --git a/src/wxfb/PortfolioPanel.h b/src/wxfb/PortfolioPanel.h index 5083c6b..24dac96 100644 --- a/src/wxfb/PortfolioPanel.h +++ b/src/wxfb/PortfolioPanel.h @@ -37,7 +37,7 @@ namespace kdeck protected: StaticCurrency* lblBalanceAmount; wxScrolledWindow* pnlPositions; - wxBoxSizer* vszrPositions; + wxFlexGridSizer* fgszrPositions; public: From 311dc1365e57cb9e18bc012362ea3b905036dabe Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Sun, 11 Aug 2024 13:30:30 -0700 Subject: [PATCH 26/26] Cleanup. --- src/wxfb/PortfolioPanel.fbp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wxfb/PortfolioPanel.fbp b/src/wxfb/PortfolioPanel.fbp index 77d7d04..1bb06dd 100644 --- a/src/wxfb/PortfolioPanel.fbp +++ b/src/wxfb/PortfolioPanel.fbp @@ -1,7 +1,7 @@ - + C++ ; 0