Differences

This shows you the differences between two versions of the page.

Link to this comparison view

appunti3s:gestione_degli_eventi [2018/04/25 07:55] (current)
Line 1: Line 1:
 +compilazione
  
 +<​code>​g++ gui1.cpp `wx-config --libs` `wx-config --cxxflags` -o gui1</​code>​
 +
 +<file cpp gui1.h>
 +#include <​wx/​app.h>​
 +
 +class MiaApp : public wxApp
 +{
 +public: ​
 +   ​virtual bool OnInit();
 +};
 +
 +DECLARE_APP(MiaApp) //vedi gui1.cpp
 +
 +class MiaCornice : public wxFrame
 +{
 +public:
 +   ​MiaCornice(const wxString &title, const wxPoint &pos, const wxSize &size);
 +   /​*~MiaCornice();​*/​
 +   void Uscire(wxCommandEvent&​ event);
 +   
 +protected:
 +   ​DECLARE_EVENT_TABLE() //vedi gui1.cpp
 +
 +private:
 +   ​wxButton* b1;
 +
 +};
 +</​file>​
 +
 +<file cpp gui1.cpp>​
 +#include <​wx/​wxprec.h>​
 +#ifndef WX_PRECOMP
 +#       ​include <​wx/​wx.h>​
 +#endif
 +
 +#include "​gui1.h"​
 +
 +BEGIN_EVENT_TABLE(MiaCornice,​wxFrame) //associa ad ogni evento un metodo di getione
 + EVT_BUTTON(1001,​MiaCornice::​Uscire)
 +END_EVENT_TABLE()
 +
 +IMPLEMENT_APP(MiaApp) //crea il main e il metodo wxGetApp e fa inizializzazioni
 +
 +bool MiaApp::​OnInit()
 +{
 +   ​MiaCornice *finestra1 = new MiaCornice(_T("​titolodellafinestra!"​),​ wxDefaultPosition,​wxSize(300,​ 200));
 +   ​finestra1->​Show(true);​
 +   //​SetTopWindow(finestra1);​
 +   ​return true;
 +}
 +
 +MiaCornice::​MiaCornice(const wxString&​ title, const wxPoint&​ pos, const wxSize& size): wxFrame((wxFrame *) NULL, -1, title, pos, size)
 +{
 +   b1 = new wxButton(this,​1001,​_T("​pulsante....."​),​wxDefaultPosition,​ wxDefaultSize,​ 0);
 +}
 +
 +void MiaCornice::​Uscire(wxCommandEvent&​ event)
 +{
 +   ​Close(true);​
 +}
 +</​file>​
  • appunti3s/gestione_degli_eventi.txt
  • Last modified: 2018/04/25 07:55
  • (external edit)