MatOCAD Logo

Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

TBasePanel.cpp

Go to the documentation of this file.
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 //Gestisco il moving del mouse sul widget
00037 void TBasePanel::PannelloBaseOnMotion(wxMouseEvent& event)
00038 {
00039   if(((TBasePanel*)gestionepannello->Selezione)==this)
00040    //Imposto il campo nella status-bar
00041     ((wxFrame*)GetParent()->GetParent()->GetParent())->GetStatusBar()->SetStatusText(descrizione,2);
00042 
00043     event.Skip();
00044 }
00045 
00046  //Procedura che si occupa di eliminare i bordi ad un widget che ha appena perso la selezione
00047  void TBasePanel::EliminaClick(wxCommandEvent& event)
00048 {
00049         // insert your code here
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:     //Se l'utente preme del
00067     { Elimina();
00068       break;
00069     }
00070   }
00071   if((event.GetKeyCode()==WXK_LEFT) || (event.GetKeyCode()==WXK_DOWN) || (event.GetKeyCode()==WXK_RIGHT) || (event.GetKeyCode()==WXK_UP))  //Se viene premuta una freccia passo il comando a pnlfoglio
00072     {
00073 
00074       event.ResumePropagation(1);// Eseguo l'evento ON_KEY_DOWN di pnlfoglio
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    //Ridisegno i bordi dei pannelli in relazione alla selezione con il click sinistro del mouse
00098 
00099   if((gestionepannello->Selezione!=this))//&&(pannello!=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    //Ridisegno i bordi dei pannelli in relazione alla selezione con il click sinistro del mouse
00112  if((gestionepannello->Selezione!=0)&&(gestionepannello->Selezione!=this))
00113     {
00114       RimuoviSelezione();
00115     }
00116 
00117     ImpostaBordi();
00118     //Memorizzo in Selezione il puntatore al nuovo widget selezionato
00119       SetFocusIgnoringChildren();
00120 }
00121 
00122 
00123 
00124 
00125 //Gestisco il click down del mouse
00126  void TBasePanel::PannelloBaseOnLD(wxMouseEvent& event)
00127    {
00128      ImpostaSelezione();
00129      event.Skip();
00130    }
00131 
00132 
00133 //Procedura che distrugge l'oggetto selezionato togliendolo anche dalla lista dei widget
00134 
00135 void TBasePanel::Elimina()
00136 {
00137    //Rimuove dalla lista dei widget
00138      gestionepannello->objects->RimuoviNodo(gestionepannello->objects->TrovaPosizione(gestionepannello->Selezione->GetId()));
00139   //Distruggo l'oggetto
00140      ((TBasePanel*)(gestionepannello->Selezione))->~TBasePanel();
00141 
00142   //Imposto il  puntatore a 0 per identificare l'assenza di un oggetto selezionato
00143  }
00144 
00145 //Gestisco il click right down del mouse
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 

 

SourceForge Logo