Working through zetcodes’s wxwidgets tutorial:Widgets II,wxListbox

I’ve made it to the next section, Widgets II of the zetcode tutorial.   I’m running out of vacation time, and I probably s/b painting but, this stuff brings me pleasure..
Anyway….. bunch of things on my mind…. none of which are suitable for a public blog…

To the tutorial..
wxListbox has two states… blah blah… single or multiple selection state…

The two main events are click and double click for wxListbox

So I guess it’s time to give this a roll.
This is a nice example with a bunch of interesting stuff going on..
Along with the list box, an insert, rename, delete and clear buttons…

Lets see if something jumps out at me with the source…
Well, for a while we were ignoring the boxsizers… now they’re back.
One thing that caught my eye was wxGetTextFromUser.
I poke around that section of the documentation…. There are all sorts of goodies in there..
Either the examples are getting easier or I’m starting to get the hang of this stuff… The only thing that really stumped me at the moment was:

void MyPanel::OnRename(wxCommandEvent& event)
{
wxString text;
wxString renamed;

int sel = m_lb->GetSelection();
if (sel != -1) {
text.Printf(m_lb->GetString(sel));
renamed = wxGetTextFromUser(wxT(“Rename item”),
wxT(“Rename dialog”), text);
}

if (!renamed.IsEmpty()) {
m_lb->Delete(sel);
m_lb->Insert(renamed, sel);
}
}

I need to refill my coffee cup, sit back and ponder that one for a moment or two..
Ok….
I changed the code and it seems to work ok.

I’m starting to get interested in good practise.. I found this link on programming style and I submitted a question to the wxforum regarding the .printf thing

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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