Sorry I mean it is code blocks but I am using wxSmith for the visual designer. I hope this is not too much but I broke it all down here. In the first image of the project I dragged the control out on the panel already.
- My Initial Files.
in ImagePanelApp.cpp the code after adding wxImagePanel control is.
Code: Select all
/***************************************************************
* Name: ImagePanelApp.cpp
* Purpose: Code for Application Class
* Author: ()
* Created: 2012-09-04
* Copyright: ()
* License:
**************************************************************/
#include "wx_pch.h"
#include "ImagePanelApp.h"
//(*AppHeaders
#include "ImagePanelMain.h"
#include <wx/image.h>
//*)
IMPLEMENT_APP(ImagePanelApp);
bool ImagePanelApp::OnInit()
{
//(*AppInitialize
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
ImagePanelFrame* Frame = new ImagePanelFrame(0);
Frame->Show();
SetTopWindow(Frame);
}
//*)
return wxsOK;
}
In ImagePanelMain.cpp the code after adding wxImagePanel control is.
Code: Select all
/***************************************************************
* Name: ImagePanelMain.cpp
* Purpose: Code for Application Frame
* Author: ()
* Created: 2012-09-04
* Copyright: ()
* License:
**************************************************************/
#include "wx_pch.h"
#include "ImagePanelMain.h"
#include <wx/msgdlg.h>
//(*InternalHeaders(ImagePanelFrame)
#include <wx/intl.h>
#include <wx/string.h>
//*)
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(ImagePanelFrame)
const long ImagePanelFrame::ID_IMAGEPANEL1 = wxNewId();
const long ImagePanelFrame::ID_PANEL1 = wxNewId();
const long ImagePanelFrame::idMenuQuit = wxNewId();
const long ImagePanelFrame::idMenuAbout = wxNewId();
const long ImagePanelFrame::ID_STATUSBAR1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(ImagePanelFrame,wxFrame)
//(*EventTable(ImagePanelFrame)
//*)
END_EVENT_TABLE()
ImagePanelFrame::ImagePanelFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(ImagePanelFrame)
wxMenuItem* MenuItem2;
wxMenuItem* MenuItem1;
wxMenu* Menu1;
wxMenuBar* MenuBar1;
wxMenu* Menu2;
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
Panel1 = new wxPanel(this, ID_PANEL1, wxPoint(176,88), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
ImagePanel1 = new wxImagePanel(Panel1, ID_IMAGEPANEL1, wxPoint(112,32), wxSize(168,128), wxRAISED_BORDER|wxTAB_TRAVERSAL, _T("ID_IMAGEPANEL1"));
ImagePanel1->SetStretch(false);
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
ImagePanel1->Connect(wxEVT_PAINT,(wxObjectEventFunction)&ImagePanelFrame::OnImagePanel1Paint,0,this);
Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&ImagePanelFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&ImagePanelFrame::OnAbout);
//*)
}
ImagePanelFrame::~ImagePanelFrame()
{
//(*Destroy(ImagePanelFrame)
//*)
}
void ImagePanelFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void ImagePanelFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}
void ImagePanelFrame::OnImagePanel1Paint(wxPaintEvent& event)
{
}
In Headers the file ImagePanelApp.h after adding the control the code is
Code: Select all
/***************************************************************
* Name: ImagePanelApp.h
* Purpose: Defines Application Class
* Author: ()
* Created: 2012-09-04
* Copyright: ()
* License:
**************************************************************/
#ifndef IMAGEPANELAPP_H
#define IMAGEPANELAPP_H
#include <wx/app.h>
class ImagePanelApp : public wxApp
{
public:
virtual bool OnInit();
};
#endif // IMAGEPANELAPP_H
In Headers the file ImagePanelMain.h after adding the control is
Code: Select all
/***************************************************************
* Name: ImagePanelMain.h
* Purpose: Defines Application Frame
* Author: ()
* Created: 2012-09-04
* Copyright: ()
* License:
**************************************************************/
#ifndef IMAGEPANELMAIN_H
#define IMAGEPANELMAIN_H
//(*Headers(ImagePanelFrame)
#include <wx/menu.h>
#include "wx/wxImagePanel.h"
#include <wx/panel.h>
#include <wx/frame.h>
#include <wx/statusbr.h>
//*)
class ImagePanelFrame: public wxFrame
{
public:
ImagePanelFrame(wxWindow* parent,wxWindowID id = -1);
virtual ~ImagePanelFrame();
private:
//(*Handlers(ImagePanelFrame)
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnImagePanel1Paint(wxPaintEvent& event);
//*)
//(*Identifiers(ImagePanelFrame)
static const long ID_IMAGEPANEL1;
static const long ID_PANEL1;
static const long idMenuQuit;
static const long idMenuAbout;
static const long ID_STATUSBAR1;
//*)
//(*Declarations(ImagePanelFrame)
wxImagePanel* ImagePanel1;
wxPanel* Panel1;
wxStatusBar* StatusBar1;
//*)
DECLARE_EVENT_TABLE()
};
#endif // IMAGEPANELMAIN_H
I will show what is in the file that is made if I make an extra header file and name it wxImagePanel like in the image below.
- File Added if choose header.
If I add the header file not a class and I name the file wxImagePanel.h and in that file the code generated is.
Code: Select all
#ifndef WXIMAGEPANEL_H_INCLUDED
#define WXIMAGEPANEL_H_INCLUDED
#endif // WXIMAGEPANEL_H_INCLUDED
If I do not make a header but make a class instead I get the 2 files in the image below and the code for each file
- 2 Files Added if I choose to make a class instead of a header.
one is in sources in directory src named wxImagePanel.cpp and the code in it is
Code: Select all
#include "wxImagePanel.h"
wxImagePanel::wxImagePanel()
{
//ctor
}
wxImagePanel::~wxImagePanel()
{
//dtor
}
The other file generated if I make a class is in the directory Headers include and it is called wxImagePanel.h and the code is
Code: Select all
#ifndef WXIMAGEPANEL_H
#define WXIMAGEPANEL_H
class wxImagePanel
{
public:
wxImagePanel();
virtual ~wxImagePanel();
protected:
private:
};
#endif // WXIMAGEPANEL_H
So thats it should I be just making a header file or a class that makes the 2 files? Or can I just make it work without adding a header file or a class at all?