#include <bias_config.h>
#include <wx/wx.h>
#include <Gui/ImageCanvas.hh>
#include <Gui/StringConv.hh>
#include <Base/Image/ImageIO.hh>
using namespace BIAS;
using namespace std;
class MyApp: public wxApp
{
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnLoad(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame( wxT("ImageCanvas"), wxPoint(50,50),
wxSize(450,340) );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Load, MyFrame::OnLoad)
END_EVENT_TABLE()
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
wxMenu *menuFile = new wxMenu;
menuFile->Append( ID_About, wxT("&About...") );
menuFile->Append( ID_Load, wxT("&Load...") );
menuFile->AppendSeparator();
menuFile->Append( ID_Quit, wxT("E&xit") );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, wxT("&File"));
SetMenuBar(menuBar);
CreateStatusBar(2);
SetStatusText(wxT("ImageName"), 0);
wxBoxSizer *box=new wxBoxSizer(wxVERTICAL);
box->Add(_ic, 1, wxALL| wxGROW |wxALIGN_CENTER, 5);
box->SetSizeHints(this);
SetSizer(box);
const string fn(BIAS_TESTS_DATA "r4.jpg" );
if (res!=0){
cout<<"could not load "<<fn<<endl;
wxMessageBox(_T( "could not load image. aborting. ") );
BIASABORT;
}
SetStatusText(_T("image"), 0);
_ic->Show(im, "image" );
FitInside();
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{ Close(TRUE); }
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(wxT("This is a wxWidgets Hello world sample"),
wxT("About Hello World"), wxOK | wxICON_INFORMATION, this);
}
void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event))
{
wxFileDialog fileDialog(this, wxT("Choose a file"), wxT("."), wxT("ucim.pgm"));
if (fileDialog.ShowModal() == wxID_OK){
string fname=WxToAscii(fileDialog.GetPath());
BIASERR("errro loading "<<fname);
} else {
SetStatusText(fileDialog.GetFilename(), 0);
_ic->Show(im, WxToAscii(fileDialog.GetFilename()));
}
} else {
cerr << "canceled loadin image" << endl;
}
}