Code: Select all
#include "GUI.h"
#include<iostream>
#include <fstream>
#include <sstream>
#include <string>
GUI::GUI(int h, int w,const wxString& title)
: wxFrame(NULL, -1, title, wxPoint(-1, -1), wxSize(900,660))
{
panel = new wxPanel(this, -1);
vboxMap = new wxBoxSizer(wxVERTICAL);
vboxMapAndInformation = new wxBoxSizer(wxVERTICAL);
vboxControlsAndResults = new wxBoxSizer(wxVERTICAL);
mapInfoAndControlsResultsHbox = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *vboxControls = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *hboxForEnviro = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *hboxForFileName = new wxBoxSizer(wxHORIZONTAL);
height = h; // height is rows
width = w; // width is columns
start = 0;
goal = 0;
createMap();
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
wxStaticText *choosingComplexityIndexLabel = new wxStaticText(panel,choosingComplexityIndexLabelId, "complexity index (CI) ");
complexityIndexStrings.Add(wxT("---"));
complexityIndexStrings.Add(wxT("Low"));
complexityIndexStrings.Add(wxT("Medium"));
complexityIndexStrings.Add(wxT("High"));
complexityIndexList = new wxChoice(panel,complexityIndexListId,wxDefaultPosition,wxDefaultSize,complexityIndexStrings);
complexityIndexList->Connect(complexityIndexListId,wxEVT_COMMAND_CHOICE_SELECTED,wxCommandEventHandler(GUI::OnChoice),NULL,this);
complexityIndexList->SetSelection(0); // default selected ---
wxStaticText *enterFileNameLabel = new wxStaticText(panel,enteringFileNameLabelId, "Enter file name: ");
fileNameInputTextCtrl = new wxTextCtrl(panel,fileNameInputTextCtrlId,"",wxDefaultPosition, wxSize(100,25));
wxButton *readFileNameButton = new wxButton(panel,readFileNameButtonId, wxT("Read File"));
readFileNameButton->Connect(readFileNameButtonId, wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(GUI::OnButtonClicked),NULL,this);
wxButton *resetButton = new wxButton(panel,resetButtonId, wxT("Reset"));
resetButton->Connect(resetButtonId, wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(GUI::OnButtonClicked),NULL,this);
wxBoxSizer *vboxMapInfo = new wxBoxSizer(wxVERTICAL);
wxStaticText *mapInfoRedLabel = new wxStaticText(panel,100," ");
mapInfoRedLabel->SetBackgroundColour(*wxRED);
wxStaticText *mapInfoStartLabel = new wxStaticText(panel,100," Start");
wxBoxSizer *hboxStartLegend = new wxBoxSizer(wxHORIZONTAL);
hboxStartLegend->Add(mapInfoRedLabel);
hboxStartLegend->Add(mapInfoStartLabel);
wxStaticText *mapInfoGreenLabel = new wxStaticText(panel,100," ");
mapInfoGreenLabel->SetBackgroundColour(*wxGREEN);
wxStaticText *mapInfoGoalLabel = new wxStaticText(panel,100," Goal");
wxBoxSizer *hboxGoalLegend = new wxBoxSizer(wxHORIZONTAL);
hboxGoalLegend->Add(mapInfoGreenLabel);
hboxGoalLegend->Add(mapInfoGoalLabel);
wxStaticText *mapInfoCyanLabel = new wxStaticText(panel,100," ");
mapInfoCyanLabel->SetBackgroundColour(*wxCYAN);
wxStaticText *mapInfoPathLabel = new wxStaticText(panel,100," Path ");
wxBoxSizer *hboxAlgorithmsLegend = new wxBoxSizer(wxHORIZONTAL);
hboxAlgorithmsLegend->Add(mapInfoCyanLabel);
hboxAlgorithmsLegend->Add(mapInfoPathLabel);
vboxMapInfo->Add(hboxStartLegend);
vboxMapInfo->Add(hboxGoalLegend);
vboxMapInfo->Add(hboxAlgorithmsLegend);
showSimulatorParameters();
//Sizer for Environemnt size label and list
hboxForEnviro->Add(choosingComplexityIndexLabel,0,wxALIGN_CENTER);
hboxForEnviro->Add(complexityIndexList);
hboxForFileName->Add(enterFileNameLabel);
hboxForFileName->Add(fileNameInputTextCtrl);
vboxControls->Add(hboxForEnviro);
vboxControls->Add(hboxForFileName);
vboxControls->Add(readFileNameButton);
vboxControls->Add(resetButton);
vboxControlsAndResults->Add(vboxControls);
vboxControlsAndResults->Add(vboxMapInfo);
vboxMapAndInformation->Add(vboxMap,1,wxALL,10);//10 is the space around box
//vboxMapAndInformation->Add(vboxMapInfo,1,wxALL,10);//10 is the space around box
mapInfoAndControlsResultsHbox->Add(vboxMapAndInformation);
mapInfoAndControlsResultsHbox->Add(vboxControlsAndResults,0,wxALL,10);//10 is the space around box
panel->SetBackgroundColour("#40E0D0");
panel->SetSizer(mapInfoAndControlsResultsHbox);
Centre();
}
void GUI::createMap()
{
gridTable = new wxGrid(panel,-1,wxPoint( 0, 0 ), wxSize( 660, 660 ));
gridTable->SetRowMinimalAcceptableHeight(1);
gridTable->SetColMinimalAcceptableWidth(1);
gridTable->SetDefaultRowSize(16);
gridTable->SetDefaultColSize(16);
gridTable->SetRowLabelSize(0);
gridTable->SetColLabelSize(0);
gridTable->CreateGrid(height, width );
//gridTable->AutoSize();
// re-put the new gridTable to the sizer hierarchy
vboxMap->Add(gridTable,0,wxRESERVE_SPACE_EVEN_IF_HIDDEN);
}
void GUI::showSimulatorParameters()
{
}
GUI::~GUI()
{
}
// handles clicking buttons
void GUI::OnButtonClicked(wxCommandEvent& event)
{
}
void GUI::OnChoice(wxCommandEvent& event)
{
}