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
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