INSUBRIA TODOLIST
CLASSI
class MainFrame : public wxFrame
{
public:
MainFrame(const wxString& title);
void Add(wxCommandEvent & event);
void Del(wxCommandEvent & event);
void Mark(wxCommandEvent & event);
void UnMark(wxCommandEvent & event);
};
void MainFrame::Add(wxCommandEvent & event)
{
string testo_della_box = testo->GetValue().ToStdString();
if (testo_della_box != "")
{
aggiungi( testo_della_box );
leggiFile();
testo -> SetValue("");
}
else
{
wxMessageDialog *dial = new wxMessageDialog(NULL,
wxT("EMPTY FIELD"), wxT("WARNING"), wxOK);
dial -> ShowModal();
}
log_write(1);
}
void MainFrame::Del(wxCommandEvent & event)
{
//controllo se sono selezionate più celle
wxGridCellCoordsArray get_cell_selected = grid->GetSelectedCells();
string testo_della_cella = "";
if (get_cell_selected.GetCount() != 0) {
testo_della_cella = grid->GetCellValue(grid->GetSelectedCells()[0]).ToStdString();
}
string testo_della_box = testo->GetValue().ToStdString();
if (testo_della_cella != "")
{
testo_della_box = testo_della_cella;
}
if (testo_della_box != "")
{
elimina( cerca( testo_della_box ) );
leggiFile();
testo -> SetValue("");
}
else
{
wxMessageDialog *dial = new wxMessageDialog(NULL,
wxT("EMPTY FIELD OR NOT SELECTED CELL"), wxT("WARNING"), wxOK);
dial -> ShowModal();
}
log_write(2);
}
void MainFrame::Mark(wxCommandEvent & event)
{
//controllo se sono selezionate più celle
wxGridCellCoordsArray get_cell_selected = grid->GetSelectedCells();
string testo_della_cella = "";
if (get_cell_selected.GetCount() != 0) {
testo_della_cella = grid->GetCellValue(grid->GetSelectedCells()[0]).ToStdString();
}
int num = -1;
for (int i=0; i<len(); i++)
{
if(grid -> GetCellValue(i, 0).ToStdString() == testo -> GetValue().ToStdString() || grid -> GetCellValue(i, 0).ToStdString() == testo_della_cella)
{
num = i;
elemento_da_markare = num;
getMarked(num+1, 1);
break;
}
}
if ( num == -1 )
{
wxMessageDialog *dial = new wxMessageDialog(NULL,
wxT("NO MATCHING WORD OR NOT SELECTED CELL"), wxT("ERROR"), wxICON_ERROR);
dial -> ShowModal();
}
grid -> SetCellBackgroundColour(num, 0, wxColor(70, 189, 92));
grid -> SetCellTextColour(num, 0, wxColor(0, 0, 0));
testo -> SetValue("");
log_write(3);
}
void MainFrame::UnMark(wxCommandEvent & event)
{
//controllo se sono selezionate più celle
wxGridCellCoordsArray get_cell_selected = grid->GetSelectedCells();
string testo_della_cella = "";
if (get_cell_selected.GetCount() != 0) {
testo_della_cella = grid->GetCellValue(grid->GetSelectedCells()[0]).ToStdString();
}
int num = -1;
for (int i=0; i<len(); i++)
{
if(grid -> GetCellValue(i, 0).ToStdString() == testo -> GetValue().ToStdString() || grid -> GetCellValue(i, 0).ToStdString() == testo_della_cella)
{
num = i;
elemento_da_markare = num;
getMarked(num+1, 0);
break;
}
}
if ( num == -1 )
{
wxMessageDialog *dial = new wxMessageDialog(NULL,
wxT("NO MATCHING WORD OR NOT SELECTED CELL"), wxT("ERROR"), wxICON_ERROR);
dial -> ShowModal();
}
if (num % 2 == 0)
{
grid -> SetCellBackgroundColour(num, 0, wxColor(69, 69, 69));
grid -> SetCellTextColour(num, 0, wxColor(217, 217, 217));
}
else if (num % 2 != 0)
{
grid -> SetCellBackgroundColour(num, 0, wxColor(97, 97, 97));
grid -> SetCellTextColour(num, 0, wxColor(217, 217, 217));
}
elemento_da_markare = -1;
testo -> SetValue("");
log_write(4);
}