Trouble with wxStatusBar

Lothar Behrens lothar.behrens at lollisoft.de
Sun Jan 28 11:27:21 PST 2007


Hi,

using a dynamic int array to set widths of my statusbar doesn't work 
properly when not in debug mode.
Is there anything wrong with using a dynamic int array ?

I have the following client code:

// Initial

frame->addStatusBar();

// The parameter gets internally mapped to an index.
// It inclements the stb_areas variable used for the
// number of fields in the status bar.

frame->addStatusBarTextArea("Info");

Thanks, Lothar

Here is the code snipped for the frame:

class lb_wxFrame {
	wxStatusBar* status_bar;
	int stb_areas;
	int* widths;
	lb_wxFrame() {
		stb_areas = 1;
		status_bar = NULL;
		widths = NULL;
	}

	void addStatusBarTextArea(char* name);
	void addStatusBar();

// ...
};

void lb_wxFrame::addStatusBar() {
	if (status_bar == NULL) {
		wxStatusBar* statusBar = new wxStatusBar(this, wxID_ANY, 
wxST_SIZEGRIP);
		SetStatusBar(statusBar);
		widths = new int[stb_areas];
		widths[0] = -1;
		stb_areas = 1;

		statusBar->SetStatusWidths(stb_areas, widths);
		statusBar->SetStatusText(wxT("Ready"), 0);
		status_bar = statusBar;
	} else {
		status_bar->SetFieldsCount(stb_areas, widths);
		status_bar->SetStatusText(wxT("Ready"), 0);
	}
}

void lb_wxFrame::addStatusBarTextArea(char* name) {
	stb_areas++;
	int* new_widths = new int [stb_areas];

	for (int i = 1; i < stb_areas; i++) {
		new_widths[i-1] = widths[i-1];
	}
	new_widths[stb_areas-1] = -1;
	delete[] widths;
	widths = new_widths;

	addStatusBar();
}







More information about the wx-users mailing list