Visualisation et affichage d'un graphe sous wxWidgets. Le code source de ce programme se trouve dans "samples/wxdisplay". Il n'est utilisable que dans le cas où Cogitant a été compilé avec les fonctions de dessin et d'interfacage avec wxWidgets.
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/scrolwin.h>
#include <wx/menu.h>
#include <wx/msgdlg.h>
#include <wx/intl.h>
class MyFrame: public wxFrame
{
private:
public:
~MyFrame();
void OnAbout(wxCommandEvent& event);
void OnQuit(wxCommandEvent & event);
DECLARE_EVENT_TABLE()
};
class MyApp: public wxApp
{
private:
public:
MyApp();
~MyApp();
bool OnInit();
int OnExit();
DECLARE_EVENT_TABLE()
};
DECLARE_APP(MyApp)
IMPLEMENT_APP(MyApp)
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
END_EVENT_TABLE()
:wxFrame((wxFrame *)NULL, -1,
cs2ws(
"wxCoGITaNT"), wxPoint(20,20), wxSize(470,360), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
{
wxMenu *file_menu = new wxMenu();
file_menu->Append( wxID_ABOUT,
cs2ws(
"&About..."));
file_menu->Append( wxID_EXIT,
cs2ws(
"&Close"));
wxMenuBar *menu_bar = new wxMenuBar();
menu_bar->Append(file_menu,
cs2ws(
"&Cogitant"));
SetMenuBar(menu_bar);
m_panel = dh->
newPanel(m_drawing,
this, -1, wxPoint(0,0), wxSize(100,100));
m_editor = dh->
newEditor(1, m_panel, file, ig);
}
MyFrame::~MyFrame()
{
delete m_drawing;
}
void MyFrame::OnQuit(wxCommandEvent &)
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent &)
{
wxMessageBox(
cs2ws(
"Graph display with wxWidgets"),
cs2ws(
"wxCoGITaNT"), wxICON_INFORMATION | wxOK );
}
BEGIN_EVENT_TABLE(MyApp, wxApp)
END_EVENT_TABLE()
MyApp::MyApp()
{
m_dh->addFormats(*m_env);
m_env->readSupport("../bcgct/bucolic/bucolic.bcs");
}
MyApp::~MyApp()
{
delete m_dh;
delete m_env;
}
bool MyApp::OnInit()
{
SetAppName(
cs2ws(
"wxCoGITaNT"));
MyFrame *frame = new MyFrame(m_dh, m_env, "../bcgct/bucolic/fact_editor.bcg");
frame->Show(TRUE);
return TRUE;
}
int MyApp::OnExit()
{
return 0;
}