00001 #include "../../include/BasePanel/TBasePanel.h"
00002 BEGIN_EVENT_TABLE(TBasePanel,wxResizeableControl)
00003 EVT_RIGHT_DOWN(TBasePanel::PannelloBaseOnRD)
00004 EVT_LEFT_DOWN(TBasePanel::PannelloBaseOnLD)
00005 EVT_MOTION(TBasePanel::PannelloBaseOnMotion)
00006 EVT_MENU(wxID_DELETE,TBasePanel::EliminaClick)
00007 EVT_KEY_DOWN(TBasePanel::OnKeyDown)
00008 END_EVENT_TABLE()
00009
00010 TBasePanel::TBasePanel(wxWindow* parent, wxWindowID id , const wxPoint& pos , const wxSize& size , long style , const wxString& name,int codiceoggetto ): wxResizeableControl(parent,
00011 id,
00012 pos,
00013 size,
00014 style,
00015 name)
00016 {
00017 PopLista = new wxMenu(_("") );
00018 PopLista->Append(wxID_DELETE,_("Elimina"),_("Elimina l'elemento corrente"), wxITEM_NORMAL);
00019 gestionepannello=0;
00020 codice=codiceoggetto;
00021
00022 descrizione.Append(name);
00023 wxFocusEvent evt(wxEVT_SET_FOCUS, GetId());
00024 GetEventHandler()->AddPendingEvent(evt);
00025 this->SetBackgroundColour(*wxWHITE);
00026
00027 }
00028
00029 TBasePanel::~TBasePanel()
00030 {
00031 *(gestionepannello->IdentSelezione)=0;
00032 gestionepannello->Selezione=0;
00033 }
00034
00035
00036
00037 void TBasePanel::PannelloBaseOnMotion(wxMouseEvent& event)
00038 {
00039 if(((TBasePanel*)gestionepannello->Selezione)==this)
00040
00041 ((wxFrame*)GetParent()->GetParent()->GetParent())->GetStatusBar()->SetStatusText(descrizione,2);
00042
00043 event.Skip();
00044 }
00045
00046
00047 void TBasePanel::EliminaClick(wxCommandEvent& event)
00048 {
00049
00050 Elimina();
00051
00052 }
00053 void TBasePanel::ImpostaUtilita(gestione* gpannello)
00054 {
00055 gestionepannello=gpannello;
00056
00057 }
00058
00059
00060
00061 void TBasePanel::OnKeyDown(wxKeyEvent & event)
00062 {
00063
00064 switch(event.GetKeyCode())
00065 {
00066 case 127:
00067 { Elimina();
00068 break;
00069 }
00070 }
00071 if((event.GetKeyCode()==WXK_LEFT) || (event.GetKeyCode()==WXK_DOWN) || (event.GetKeyCode()==WXK_RIGHT) || (event.GetKeyCode()==WXK_UP))
00072 {
00073
00074 event.ResumePropagation(1);
00075
00076 ((wxPanel*)GetParent())->SetFocusIgnoringChildren();
00077
00078 }
00079 event.Skip();
00080 }
00081
00082
00083
00084 void TBasePanel::RimuoviSelezione()
00085 {
00086 if(*(gestionepannello->IdentSelezione)!=0)
00087 {
00088 gestionepannello->Selezione->Show(0);
00089 gestionepannello->Selezione->SetWindowStyle(wxNO_3D|wxNO_BORDER);
00090 gestionepannello->Selezione->Show(1);
00091 gestionepannello->Selezione=0;
00092 *(gestionepannello->IdentSelezione)=0;
00093 }
00094 }
00095 void TBasePanel::ImpostaBordi()
00096 {
00097
00098
00099 if((gestionepannello->Selezione!=this))
00100 {
00101 Show(0);
00102 SetWindowStyle(wxNO_3D|wxSIMPLE_BORDER);
00103 Show(1);
00104 }
00105 *(gestionepannello->IdentSelezione)=codice;
00106 (gestionepannello->Selezione)=this;
00107
00108 }
00109 void TBasePanel::ImpostaSelezione()
00110 {
00111
00112 if((gestionepannello->Selezione!=0)&&(gestionepannello->Selezione!=this))
00113 {
00114 RimuoviSelezione();
00115 }
00116
00117 ImpostaBordi();
00118
00119 SetFocusIgnoringChildren();
00120 }
00121
00122
00123
00124
00125
00126 void TBasePanel::PannelloBaseOnLD(wxMouseEvent& event)
00127 {
00128 ImpostaSelezione();
00129 event.Skip();
00130 }
00131
00132
00133
00134
00135 void TBasePanel::Elimina()
00136 {
00137
00138 gestionepannello->objects->RimuoviNodo(gestionepannello->objects->TrovaPosizione(gestionepannello->Selezione->GetId()));
00139
00140 ((TBasePanel*)(gestionepannello->Selezione))->~TBasePanel();
00141
00142
00143 }
00144
00145
00146 void TBasePanel::PannelloBaseOnRD(wxMouseEvent& event)
00147 {
00148 ImpostaSelezione();
00149 PopupMenu(PopLista);
00150 event.Skip();
00151 }
00152
00153 wxMenu* TBasePanel::GetPopUp()
00154 { return PopLista;
00155 }
00156
00157 void TBasePanel::SetTreeItemId(wxTreeItemId Id)
00158 {
00159 TreeId=Id;
00160 }
00161
00162 wxTreeItemId TBasePanel::GetTreeItemId()
00163 {
00164 return TreeId;
00165 }
00166
00167