I’ve been line by line through zetcode tutorial titled “A Simple button” using the IDE C::B Code::Blocks.
This tutorial produces some output that looks like this:
The source looks like this:
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”),
void Button::OnQuit(wxCommandEvent & WXUNUSED(event))
This is the section for me is the mostly new and unfamiliar , but I also expect the most useful in the exploration of this tutorial..
The tutorial has that to say about that:
If we click on the button, a wxEVT_COMMAND_BUTTON_CLICKED event is generated. We connect the event to the OnQuit() method of the Button class. So when we click on the button, the OnQuit() method is called.
Ok… It’s enough to get your curiosity peeked but for me, I want to know a whole more about what the heck is going on here. When I understand this part, I think the rest will be easy.
My selection of research reading material starts here:http://wiki.wxwidgets.org/Events
This link also points to the following which looks interesting:
Ehhh. A little light reading here. 😉
Ok… For some reason I was drawn like a moth to this link… (Must have been the font)
So… two ways of hand of handling events:
- event table macro’s done at design time
- wxEvtHandler::Connect() (Which can connect/disconnect dynamically)
Ok… I get the impression that you either do one style or the other. The Connect() method appears to be what is used in this tutorial and if I’m not mistaken it is also used in wxformbuilder. So for now, I’m not going to confuse my brain, I’m just going to focus on Dynamic Event Handling.
Yea.. I’m having a some unsual quite time along with a beer at the moment. The family is out with the mother in law and the house is quite. Shame its the end of the day because I’m sort of tired at the moment and this stuff is not sinking in… But… I’m giving it a go …
I wound up having about a dozen tabs open and lost track of what is looking for….
I need to narrow the scope and focus on the tutorial here..
|Sample Code||Member function|
Ok… Now its the morning perhaps things will be more clear.
The usage of this wxID_EXIT is most curious to me.. In one of the links, I was researching I found a most satisfactory explanation… Lets see if I can stumble on it again..
I believe the section that sort explains this is titled: Window Identifiers.
I’m having a particularitly hard time with this for some reason…
This pretty much explain’s it:
Window identifiers are integers, and are used to uniquely determine window identity in the event system (though you can use it for other purposes). In fact, identifiers do not need to be unique across your entire application as long they are unique within the particular context you’re interested in, such as a frame and its children. You may use the wxID_OK identifier, for example, on any number of dialogs as long as you don’t have several within the same dialog.
From what I’ve seen so far you can have pretty icons automatically show up on buttons if you use the Standard event identifiers.
If you don’t care about the indentifier you can use xID_ANY which will generate a negative integer value so conflict the always positive user-specified identifiers.
Hmmm. The don’t really say what happens if you do have a duplication. (Todo:I need to test that latter on and see what happens..
This seems straight forward enough. We’re connecting a unique identifier for a button with some type of action. I’m interested in see the type of actions that we can connect up to… And the list is here. Todo: I want to have a simple button and see what it takes to produce mouse move events, lost focus events…. basically the array of stuff that I take for granted in VB6.
I’m not finding the documentation to my liking about this wxCommandEventHandler. I wound about surfing a little bit and I ran across this site which seems to have people who seem to know wxwidgets far better than I do.. I need to look at this further.