Design question

H

Helmut Giese

Hello out there,
as part of a 'designer like' program I have a class
class SuperPanel : Panel {
}
with functions like addWidget, rmWidget, cloneWidget, serialize and
deserialize, support for drag and drop, etc.

All fine and well, but I missed out on one thing: I need the same for
a GroupBox - conceptually something like
class SuperGroupBox : GroupBox {
}
with exactly the same set of functions.

Now I certainly don't want to duplicate all the code, but I haven't
been able to find a satisfactory solution:
- I don't see a common base class
- I don't see a sensible way to build an inheritance chain
- I thought of creating a class which would not _be_ a Control but
rather _contain_ a Control like
class Container {
Panel panel;
// Create either a Panel or a GroupBox
Container(bool isPanel) {
if (isPanel)
panel = new Panel();
else
panel = new GroupBox();
}
}
but this would break lots of code where I am using an instance of my
class directly as a Control, e.g when doing something like
Control self;
...
(self as SuperPanel)...

So it looks like I painted myself into a corner - does anybody know a
way out?
Any idea will be massively appreciated.
Best regards
Helmut Giese
 
H

Helmut Giese

For some reason (maybe because of the same subject line?) my posting
showed up as a follow-up in this thread.
I'll re-post with a different subject.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top