#include "mainFrame.h" #include "bars/menuBar.h" #include "bars/statusBar.h" #include "bars/toolBar.h" /* --- */ #include "api/requirement.h" /* --- */ using namespace std; using namespace gui; //-------------------------------------------------------------- /* Constructor */ MainFrame::MainFrame(dBus::Bus &bus) : wxFrame(nullptr, wxID_ANY, _("kwa.Fr"), wxDefaultPosition, wxDefaultSize) , m_bus(bus) { // Initialization SetIcon(wxICON(AAAA_ICON)); const wxSize minSize(1200, 900); SetMinSize(minSize); SetSize(minSize); // Creating controls createControls(); // Post-initialization m_menuBar->Bind(wxEVT_MENU, &MainFrame::on_menubarItemClick, this); CenterOnScreen(); } //-------------------------------------------------------------- /* Creating controls */ void MainFrame::createControls() { m_menuBar = new MenuBar(this); m_statusBar = new StatusBar(this); const auto framePanel = new wxPanel(this /*, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER*/); m_toolBar = new ToolBar(framePanel); m_pageNotebook = new wxNotebook(framePanel, wxID_ANY); // Controls positioning const auto mainSizer = new wxBoxSizer(wxVERTICAL); mainSizer->Add(m_toolBar, wxSizerFlags(0).Expand()); mainSizer->Add(m_pageNotebook, wxSizerFlags(1).Expand().Border(wxALL, 5)); framePanel->SetSizer(mainSizer); Layout(); } //-------------------------------------------------------------- /* Create a new project */ void MainFrame::createProject() { try { const auto ret = postFileOperationRequest(m_bus, api::requirement::FileOperation::Create); if (!ret) { wxMessageBox("No manager found for project creation request.\n\n" "The manager responsible for handling project creation " "did not respond to the request. Please ensure that " "the project management component is running and try again.", "Failed...", wxOK | wxICON_WARNING, this); } } catch (const std::exception &e) { wxMessageBox("An unexpected error occurred while creating a new project\n\n" + wxString(e.what()), "Critical Error", wxOK | wxICON_ERROR, this); } } //-------------------------------------------------------------- /* Open an existing project */ void MainFrame::openProject() { } //-------------------------------------------------------------- /* Save the current project */ void MainFrame::saveProject() { } //-------------------------------------------------------------- /* Save the current project as... */ void MainFrame::saveProjectAs() { } //-------------------------------------------------------------- /* Close the current project */ void MainFrame::closeProject() const { } //-------------------------------------------------------------- /* Menu bar item click event */ void MainFrame::on_menubarItemClick(wxCommandEvent &event) { switch (static_cast(event.GetId())) { using enum MenuBar::IDs; // File menu case ID_MENU_FILE_NEW: { createProject(); break; } case ID_MENU_FILE_OPEN: { openProject(); break; } case ID_MENU_FILE_SAVE: { saveProject(); break; } case ID_MENU_FILE_SAVE_AS: { saveProjectAs(); break; } case ID_MENU_FILE_CLOSE: { closeProject(); break; } case ID_MENU_FILE_QUIT: { Close(); break; } // Requirement menu case ID_MENU_REQ_CREATE: { break; } // Help menu default: { } } } //--------------------------------------------------------------