1. can I inhrite from wxPanel a MyPanel that is an abstract class?
2. in MyPanel i have a virtual func PaintEvent() for EVT_PAINT, and in MyPnael's child MyChildPanel, I override PaintEvent()...both in MyPanel and MyChildPanel,i declare BEGIN_EVENT_TABLE, EVT_PAINT, is it OK?
Will the MyChildPanel object implement PaintEvent() twice if I called MyPanel::PaintEvent() in MyChildPanel::PaintEvent()?
If this method is wrong... what is the normal way to make a event func virtual ?
3. in MyChildPanel's PaintEvent(), is calling event.Skip() equals to calling MyPanel::PaintEvent()?
4. the efficient is important in my application, so if nothing more is done in MyChildPanel, which one is more effciant? and does the use of virtual func affect the efficient? (1)only call MyPanel::PaintEvent() in MyChildPanel::PaintEvent(); (2)not override MyPanel::PaintEvent() and so no EVT_PAINT in MyChildPanel, just use the MyPanel::PaintEvent() for MyChildPanel; (3)not use virtual event func, just use EVT_PAINT in MyChildPanel and no EVT_PAINT in MyPanel;
virtual event func ? Topic is solved
Re: virtual event func ?
You want MyPanel to be an abstract class? Yes, by adding a pure virtual method.1. can I inhrite from wxPanel a MyPanel that is an abstract class?
I would have an event table only in the base class, e.g. pointing to a non-virtual method like OnPaint(wxPaintEvent &event). From there i'd call the a virtual method like DoPaint(wxPaintEvent &event) which you can override in the inherited classes.2. in MyPanel i have a virtual func PaintEvent() for EVT_PAINT, and in MyPnael's child MyChildPanel, I override PaintEvent()...both in MyPanel and MyChildPanel,i declare BEGIN_EVENT_TABLE, EVT_PAINT, is it OK?
No. event.Skip() only sets a flag in the event structure which is checked by the wxWidgets event handling code. But this code knows nothing about your virtual methods. You'd have to call the method in the base class yourself.3. in MyChildPanel's PaintEvent(), is calling event.Skip() equals to calling MyPanel::PaintEvent()?
As all this is happens only once per redraw, i'm pretty sure it's not relevant for overall performance.4. the efficient is important in my application, so if nothing more is done in MyChildPanel, which one is more effciant?
Use the source, Luke!
Re: virtual event func ?
is the wxPanel not abstract, but its child abstrct and child's child not abstract OK?You want MyPanel to be an abstract class? Yes, by adding a pure virtual method.
2. & 3. so I should call the virtual func and then event.Skip() in the abstract class and then overrider the virtual func in its child, right?
and I saw the comment, but still not sure what exactly it does ?
but in some situation, virtual func is not fast as not virtual ones..As all this is happens only once per redraw, i'm pretty sure it's not relevant for overall performance.
Re: virtual event func ?
Like already said, event.Skip() is only relevant inside the wxWidgets event hierarchy. It doesn't know about your virtual methods.2. & 3. so I should call the virtual func and then event.Skip() in the abstract class and then overrider the virtual func in its child, right?
Yes, it's a few clock cycles slower. But it's totally irrelevant from a performance point of view here.but in some situation, virtual func is not fast as not virtual ones..
Use the source, Luke!