wxAuiNotebook events Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Kerry
Experienced Solver
Experienced Solver
Posts: 58
Joined: Fri Mar 07, 2008 5:44 pm

wxAuiNotebook events

Post by Kerry » Sat Apr 05, 2008 1:23 pm

Hello,

I have a class derived from wxAuiNotebook, and I'm trying to create an event table. The AUI events seem to have poor (missing) documentation, and I'm having difficulty figuring out how to use the events that are defined in auibook.cpp. I need to be able to delete some objects that reside in a notebook page when the user closes the page, so I think I'm interested in wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE. I've tried this:

Code: Select all

class MAIN_NOTEBOOK : public wxAuiNotebook
{
public:
	MAIN_NOTEBOOK(wxWindow* parent, wxWindowID id, const wxPoint& pos,
		const wxSize& size, long style);
	~MAIN_NOTEBOOK();

	virtual void NotebookPageClose_Event(wxAuiNotebookEvent &event);

	bool Create(void);

	enum
	{
		ID_Page_Close
	};

private:
	wxVTKRenderWindowInteractor *VTKPage;

protected:
	DECLARE_EVENT_TABLE();
};
with this:

Code: Select all

BEGIN_EVENT_TABLE(MAIN_NOTEBOOK, wxAuiNotebook)
	wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE(ID_Page_Close, MAIN_NOTEBOOK::NotebookPageClose_Event)// Line # 42
END_EVENT_TABLE();// Line # 43

void MAIN_NOTEBOOK::NotebookPageClose_Event(wxAuiNotebookEvent &event)
{
	// More to come
	event.Skip();
}
but it won't compile. I get these errors:
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(42) : error C2064: term does not evaluate to a function taking 2 arguments
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C2466: cannot allocate an array of constant size 0
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C2440: 'initializing' : cannot convert from 'int' to 'const wxEventTableEntry'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C2146: syntax error : missing '}' before identifier 'wxEventTableEntry'
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C2146: syntax error : missing ';' before identifier 'wxEventTableEntry'
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C2078: too many initializers
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C2143: syntax error : missing ';' before '}'
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C2143: syntax error : missing ';' before '}'
1>c:\documents and settings\kerry\my documents\visual studio 2005\projects\cardesigner\cardesigner\src\gui\main_notebook_class.cpp(43) : error C2059: syntax error : '}'

So it looks like it doesn't like the event macro. Searching for aui notebook events has turned up a couple others, and substituting them in for wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE hasn't helped anything. I couldn't find anything else in auibook.cpp either. What am I missing here? Can anyone tell me the correct way to catch a tab close event?

Thanks,

Kerry

edit: I should have mentioned I'm using wxWidgets 2.8.7

ArKay
Knows some wx things
Knows some wx things
Posts: 41
Joined: Wed Mar 26, 2008 1:38 pm
Location: Germany

Post by ArKay » Sat Apr 05, 2008 3:15 pm

Try using EVT_AUINOTEBOOK_PAGE_CLOSE() instead of wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE().

Post Reply