(Part 1 wxFrame)Exploring wxwidgets using zetcode’s “A simple button” and Code::Blocks

Many moons ago, a friend of mine at lunch said that I ate like a Romulan. I guess I take my food apart before I eat it.
I guess I take the same approach learning new things.

In my previous post I went over how get this zetcode titled “A Simple button” using the IDE C::B Code::Blocks.
http://zetcode.com/tutorials/wxwidgetstutorial/firstprograms/
This produces some output that looks like this:

My previous post was more of a tutorial, this is more note pad for me for my exploration into both Code::blocks and wxwidgets.
The code I’m interested in looking at is the the file button.cpp:

#include “button.h”

Button::Button(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(270, 150))
{
wxPanel *panel = new wxPanel(this, wxID_ANY);

wxButton *button = new wxButton(panel, wxID_EXIT, wxT(“Quit”),
wxPoint(20, 20));
Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(Button::OnQuit));
button->SetFocus();
Centre();
}

void Button::OnQuit(wxCommandEvent & WXUNUSED(event))
{
Close(true);
}

Starting out I’m interested in researching the contructor for wxFrame.
Searching locally on my machine this is what I came up with.

jonas@Ubuntu4:~$
jonas@Ubuntu4:~$ locate wxframe
/usr/share/doc/wx2.6-doc/wx-manual.html/wx2.6-manual_wxframe.html
/usr/share/doc/wx2.8-doc/wx-manual.html/wx_wxframe.html
jonas@Ubuntu4:~$ locate wx/frame
/usr/include/wx-2.6/wx/frame.h
/usr/include/wx-2.8/wx/frame.h
jonas@Ubuntu4:~$

Looking inside usr/include/wx-2.8/wx/frame.h here is the constructor:

wxFrame *New(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);

(Ok…. One think that is really irritating at the moment is that I’m loosing what I guess is tabs when I switching between Visual and Html in my wordpress software…. I’m not interesting in following that thread at the moment so sorry about that.)

Anyway.. As near as I can tell, It appears that data contained in /usr/include/wx-2.8/wx/frame.h mirror’s that which is on the website:http://docs.wxwidgets.org/stable/wx_wxframe.html

Going through each parameter in the constructor

wxWindow *parent, // Makes sense to me.. Not going to pursue further
wxWindowID winid, // This has gotten me curious.  I need to research this further. I think I between these two links it sort of explains it.
http://docs.wxwidgets.org/stable/wx_wxframe.html
Refers to it as “The window identifier.”

[http://docs.wxwidgets.org/stable/wx_….html#stdevtid I have a theory in my head as to what this does, but I want to work it out in samples .

const wxString& title, // This seems to be a no brainer to me.

const wxPoint& pos = wxDefaultPosition, // This one merits a little bit of research
Nice explanation here:http://docs.wxwidgets.org/stable/wx_wxpoint.html#wxpointoperators
Simple stated:

A wxPoint is a useful data structure for graphics operations. It simply contains integer x and y members.

const wxSize& size = wxDefaultSize, In formation on that can be found here:http://docs.wxwidgets.org/stable/wx_wxsize.html#wxsize

Quoting:

A wxSize is a useful data structure for graphics operations. It simply contains integer width and height members.

To me these statements are a bit misleading, looking through the documentation there is a bunch of interesting member functions associated with these classes..

long style = wxDEFAULT_FRAME_STYLE, //Ok… This is is pretty much explained in wxframe, so this is a no-brainer to me.

const wxString& name = wxFrameNameStr); wxframe defines this as:

The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.

It sound to me than in Vb6 speak. “Name” is the “name” and “title” would be the “caption”.

Ok… That’s enough for now..
I think the next thing to really look at is:

wxPanel *panel = new wxPanel(this, wxID_ANY);

This entry was posted in OpenCascade, Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *