To: rich at annexia.org Cc: lablgtk at kaba.or.jp Subject: Re: containers & subclasses of widgets In-Reply-To: <20030703144222.GA15588 at redhat.com> References: <20030703144222.GA15588 at redhat.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030705105542O.garrigue at kurims.kyoto-u.ac.jp> Date: Sat, 05 Jul 2003 10:55:42 +0900 From: Jacques Garrigue Lines: 59 I answer several questions together: From: Richard Jones > The problem is that table#children gives me a list of widgets. How can > I usefully convert these to vboxes without doing a forbidden downcast? > (My first thought was that container ought to be a polymorphic class, > but of course that wouldn't allow you to store different types of > widgets in a single container.) Downcasts are illegal for caml classes, but they are ok for raw gtk objects (the Gtk approach is dynamic). So you just have to unwrap, cast, and rewrap. let w = List.hd table#children in let vb = new GPack.box (GtkPack.Box.cast w#as_widget) in ... This is one are case you need to look into the Gtk* modules. [ Your problems with drawing areas ] The problem with drawing areas is that you cannot draw on them when they are not realized, and you cannot (really) realize them if they are not contained in a toplevel window. A good idiom would be: let create_drawing_area () = let da = GMisc.drawing_area () in let drawable = lazy (new GDraw.drawable da#misc#window) in let repaint _ = (Lazy.force drawable)#polygon ~filled:true [ 10,100; 35,35; 100,10; 165,35; 190,100; 165,165; 100,190; 35,165; 10,100 ]; true in da#event#connect#expose ~callback:repaint; da Note also that expose is only called when an expose XEvent comes. If you add your area after the window is drawn, then no expose event will come. So it might be a good idea to add: da#connect#realize ~callback:(fun () -> ignore (repaint())); [ About version of ml_gdk.c ] 1.73 is for lablgtk2. But there are only few changes in ml_gdk.c between lablgtk1 and 2, so this patch should apply anyway. [ Metawidgets ] I answer in another mail. Jacques