Re: Placing widget on top of DrawingArea



On Sat, 22 Feb 2003, Havoc Pennington wrote:
> On Sat, Feb 22, 2003 at 09:34:44PM -0600, Lars Clausen wrote:
>> 
>> In Dia, we have the diagram displayed in a GtkDrawingArea widget.
>> Currently, we do text editing in the diagram by rendering our own cursor
>> and handling all events on our own.  That's not a very practical
>> approach for several reasons.
>> 
>> Instead, I'd like to place an appropriate text editing widget
>> (GtkTextView
>> + GtkTextBuffer) on top of the text in the diagram, and get all the
>> standard editing for free.  But GtkDrawingArea is not a container widget --
>> is there any reasonable way I can place the GtkTextView on top of the
>> GtkDrawingArea?  It'll be removed as soon as the editing is done, e.g. when
>> anything else is done to the diagram.
> 
> A DrawingArea really is just a widget that doesn't offer any
> functionality; so it's pretty trivial to create a GtkContainer
> subclass that could contain the TextView and also let you draw on
> it. Or GtkFixed with its GdkWindow turned on (see GtkFixed docs) may
> be just what you want, you can override its expose handler.

Thanks, that does sound like what I need.  So I could use a GtkFixed
w/GdkWindow instead of the GtkDrawingArea.  I shall need to be able to
resize it, but since it ignores child layout, that should be easy.  And I
guess to remove the TextView I can just hide() or destroy() it.  Cool.

So here you have an example of where a GtkFixed is actually a preferable
container. 

-Lars

-- 
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause)| HÃ¥rdgrim of Numenor
"I do not agree with a word that you say, but I   |----------------------------
will defend to the death your right to say it."   | Where are we going, and
    --Evelyn Beatrice Hall paraphrasing Voltaire  | what's with the handbasket?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]