Re: Howto manage objects in DrawingArea?
- From: Michael Hasselmann <michael taschenorakel de>
- To: buergi <pat_buergi124 gmx de>
- Cc: gtkmm-list gnome org
- Subject: Re: Howto manage objects in DrawingArea?
- Date: Wed, 01 Jul 2009 16:32:26 +0200
Hi,
first of all I am not quite sure why you would want to split up a single
responsibility (draw something in MyDrawingAreaWidget) over several
classes. Perhaps it's some sort of requirement.
But if your shape classes are not derived from a DrawingArea then they
probably shouldn't draw themselves because, well, drawing the shapes is
the responsibility of your MyDrawingAreaWidget. I would have my shape
objects provide all the necessary information/computation instead and
query them when I draw the shapes in MyDrawingAreaWidget.
regards,
Michael
Am Mittwoch, den 01.07.2009, 15:44 +0200 schrieb buergi:
> Hello,
> yet another noob question:
> i need to draw objects like Bezier curves or text onto a DrawingArea.
> I derived a own class from DrawingArea and made classes for every object
> i want to draw (e.g. BezierCurve). All these objects have a draw() method.
> But to draw the object this method of course needs to have a pointer to
> the DrawingArea. Not only to get the GDK::Window to draw on but also to
> get some properties like the offset and zoom, so the object knows at
> which position it should draw.
>
> My question is how to manage this nicely?
> Until now i passed every object a pointer to my DrawingArea class, but
> this is very ugly i think.
> Especially since i have an inclusion cycle because the DrawingArea
> header needs to include the objects headers which again need to include
> the DrawingArea.
> How can i manage this access better? e.g. how to the gtk widgets do it,
> what happens when i add a widget to a container. How does it know where
> it should draw itself on?
>
> thanks a lot in advance
>
> buergi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]