diff --git a/include/ui/MainFrame.hpp b/include/ui/MainFrame.hpp index a9cb86b..b7ce182 100644 --- a/include/ui/MainFrame.hpp +++ b/include/ui/MainFrame.hpp @@ -17,7 +17,8 @@ namespace kdeck ID_Logout = wxID_HIGHEST + 2, ID_Exchange_Announcements = wxID_HIGHEST + 3, ID_Exchange_Schedule = wxID_HIGHEST + 4, - ID_Exchange_Status = wxID_HIGHEST + 5 + ID_Exchange_Status = wxID_HIGHEST + 5, + ID_View_ShowClosedPositions = wxID_HIGHEST + 6, }; class MainFrame : public wxFrame @@ -34,6 +35,7 @@ namespace kdeck wxMenuItem *mnuLogin; wxMenuItem *mnuLogout; + wxMenuItem *mnuShowClosedPositions; PortfolioPanel* pnlPortfolio; diff --git a/include/ui/PortfolioPanel.hpp b/include/ui/PortfolioPanel.hpp index c6cfc4a..18f3fb6 100644 --- a/include/ui/PortfolioPanel.hpp +++ b/include/ui/PortfolioPanel.hpp @@ -7,13 +7,14 @@ namespace kdeck { class Api; class BalancePanel; + class Config; class PortfolioPanel : public wxScrolledWindow { public: PortfolioPanel(wxWindow* parent, wxWindowID winid = wxID_ANY); - void UpdateStuff(Api* api); + void UpdateStuff(const Config* config, Api* api); private: BalancePanel* pnlBalance; diff --git a/src/ui/MainFrame.cpp b/src/ui/MainFrame.cpp index 40d1de0..993db75 100644 --- a/src/ui/MainFrame.cpp +++ b/src/ui/MainFrame.cpp @@ -55,6 +55,14 @@ namespace kdeck /////////////////////////////////////////////////////////////////////////// + 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); @@ -63,6 +71,7 @@ namespace kdeck wxMenuBar *menuBar = new wxMenuBar; menuBar->Append(menuFile, "&File"); menuBar->Append(menuExchange, "&Exchange"); + menuBar->Append(menuView, "&View"); menuBar->Append(menuHelp, "&Help"); SetMenuBar(menuBar); @@ -87,10 +96,13 @@ namespace kdeck void MainFrame::UpdateStuff() { - pnlPortfolio->UpdateStuff(&api); + pnlPortfolio->UpdateStuff(&config, &api); mnuLogin->Enable(!api.IsLoggedIn()); mnuLogout->Enable(api.IsLoggedIn()); + + mnuShowClosedPositions->Enable(api.IsLoggedIn()); + mnuShowClosedPositions->Check(config.GetShowClosedPositions()); } // helpers //////////////////////////////////////////////////////////////////// @@ -239,6 +251,12 @@ namespace kdeck case ID_Exchange_Status: DoShowExchangeStatus(); + break; + case ID_View_ShowClosedPositions: + config.SetShowClosedPositions(mnuShowClosedPositions->IsChecked()); + + UpdateStuff(); + break; case wxID_ABOUT: wxMessageBox(wxString::Format("%s v%s", kProjectName, kProjectVersion), wxString::Format("About %s", kProjectName), wxOK | wxICON_INFORMATION); diff --git a/src/ui/PortfolioPanel.cpp b/src/ui/PortfolioPanel.cpp index 6fa1922..aa6e42b 100644 --- a/src/ui/PortfolioPanel.cpp +++ b/src/ui/PortfolioPanel.cpp @@ -1,6 +1,7 @@ #include #include "api/Api.hpp" +#include "config/Config.hpp" #include "ui/BalancePanel.hpp" #include "ui/PortfolioPanel.hpp" #include "ui/EventPositionPanel.hpp" @@ -38,7 +39,7 @@ namespace kdeck SetScrollRate(10, 10); } - void PortfolioPanel::UpdateStuff(Api* api) + void PortfolioPanel::UpdateStuff(const Config* config, Api* api) { pnlBalance->UpdateStuff(api); @@ -56,10 +57,20 @@ namespace kdeck for (auto event : api->GetEventPositions()) { + if (0 == *event->event_exposure && !config->GetShowClosedPositions()) + { + continue; + } + boxSizer->Add(new EventPositionPanel(pnlPositions, wxID_ANY, event), flags); for (auto market : api->GetMarketPositions(*event->event_ticker)) { + if (0 == *market->market_exposure && !config->GetShowClosedPositions()) + { + continue; + } + boxSizer->Add(new MarketPositionPanel(pnlPositions, wxID_ANY, market), flags); } }