1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
void Agenda::Rimuovi(wxCommandEvent& event){
rmvEA1=new DialREA(NULL,wxID_ANY,wxT("Vuoi rimuovere l'elemento?"),wxDefaultPosition,wxDefaultSize );
int count=1;
for(list<CalendarItem*>::iterator i=lista1.begin();i!=lista1.end();i++){
if((calendario->GetDate()).IsEqualTo((*i)->getDate())){
rmvEA1->SetStdBtn((*i)->getTitle(),count);
(rmvEA1->StdBtn)->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Agenda::Rimv), NULL, this);
(*i)->setCount(count);
count++;
}
}
rmvEA1->SetLayout();
rmvEA1->Show(true);
// stessa cosa da fare per il modifica
}
void Agenda::OKRmv(wxCommandEvent& event){
for(list<CalendarItem*>::iterator i=lista1.begin();i!=lista1.end();i++){
if((calendario->GetDate()).IsEqualTo((*i)->getDate())&&(*i)->getTitle()==rmvEA1->GetStdBtn((*i)->getCount())){
lista1.erase(i);
}
}
/////getATT(calendario->GetDate())->removeObserver();
update(); /// Observer modifiyng
rmvDial1->Close(true);
}
void Agenda::Rimv(wxCommandEvent& event){
rmvDial1->Show(true);
rmvEA1->Close(true);
}
rmvDial is a Dial that ask you if you really want to do this action..
void Agenda::OKRmv(wxCommandEvent& event){
for(list<CalendarItem*>::iterator i=lista1.begin();i!=lista1.end();i++){
if((calendario->GetDate()).IsEqualTo((*i)->getDate())&&(*i)->getTitle()==rmvEA1->GetStdBtn((*i)->getCount())){
lista1.erase(i);
}
}
update(); /// Observer modifiyng
rmvDial1->Close(true);
}
#include "DialRmvEA.h"
MyButton::MyButton(wxDialog* parent,int id,wxString& title):wxButton( parent, id, title,wxDefaultPosition,wxDefaultSize,0){
}
MyButton::~MyButton(){
}
int MyButton::getID(){
return ID;
}
void MyButton::setID(int i){
ID=i;
}
DialREA::DialREA( 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 );
bSizer2 = new wxBoxSizer( wxVERTICAL );
Testo = new wxStaticText( this, wxID_ANY, wxT("Scegli il titolo di evento o attivita che vuoi rimuovere:"), wxDefaultPosition, wxDefaultSize, 0 );
Testo->Wrap( -1 );
bSizer2->Add( Testo, 0, wxALL, 5 );
StdCanc = new wxButton( this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
//this->SetSizer( bSizer2 );
//this->Layout();
//this->Centre(wxBOTH);
StdCanc->Connect(wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(DialREA::Esci),NULL,this);
}
void DialREA::Esci(wxCommandEvent& event){
this->Close(true);
}
void DialREA::SetStdBtn(wxString Label,int count){
StdBtn=new MyButton(this, wxID_ANY, Label);
StdBtn->setID(count);
bSizer2->Add(StdBtn,0,wxALL,5);
}
void DialREA::SetLayout(){
bSizer2->Add( StdCanc, 0, wxALL, 5 );
this->SetSizer( bSizer2 );
this->Layout();
this->Centre(wxBOTH);
bSizer2->Fit( this );
}
wxString DialREA::GetStdBtn(int count){
if (StdBtn->getID()==count){
return StdBtn->GetLabel();
}
exit(0);
}
here it is the file.h
#ifndef DIALRMVEA_H_
#define DIALRMVEA_H_
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/gdicmn.h>
#include <wx/string.h>
#include <wx/dialog.h>
#include <wx/font.h>
#include <wx/stattext.h>
#include <wx/colour.h>
#include <wx/settings.h>
class MyButton : public wxButton
{
protected:
int ID;
public:
void setID(int i);
int getID();
MyButton(wxDialog *parent,int id,wxString& title);
virtual ~MyButton();
};
class DialREA : public wxDialog {
protected:
wxButton* StdCanc;
wxStaticText* Testo;
wxBoxSizer* bSizer2;
public:
MyButton* StdBtn;
void SetLayout();
void SetTesto(wxString T);
void Esci(wxCommandEvent& event);
void SetStdBtn(wxString Label,int count);
wxString GetStdBtn(int count);
DialREA(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(200,180), long style = wxDEFAULT_DIALOG_STYLE|wxDIALOG_EX_METAL|wxSTAY_ON_TOP);
virtual ~DialREA();
};
| |