Message-ID: <41F72663.5000602 at rftp.com> Date: Tue, 25 Jan 2005 21:10:59 -0800 From: Robert Roessler Organization: Robert's High-performance Software MIME-Version: 1.0 To: Jacques Garrigue CC: lablgtk at kaba.or.jp Subject: Re: writing your own widgets References: <41F6CB4C.8090509 at rftp.com> <20050126.131155.115913197.garrigue at math.nagoya-u.ac.jp> In-Reply-To: <20050126.131155.115913197.garrigue at math.nagoya-u.ac.jp> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Jacques Garrigue wrote: > From: Robert Roessler > >>I notice that the LablGTK version of the GTK+ 2.0 Tutorial somewhat >>conspicuously leaves out "Chapter 21. Writing Your Own Widgets" - is >>this forthcoming, or is there somewhere else to find this material, or >>is it considered for some reason to be unnecessary? > > > (Weak) support for creating Gtk widgets was available in lablgtk1, but > has been dropped in lablgtk2. The immediate reason was that it was > broken because of changes, but the deep reason is that this level is > too low to hope for a reasonably type safe API. > > There are other ways to create your own widgets. > As lablgtk already allows you to override almost all signals on an > existing widget, you can easily change its behaviour at runtime. > If you want to add new signals, which is the main reason to create a > new widget, look at the ML signal mechanism in GUtil. It allows you to > extend a widget with new signals, that look exactly like gtk signals, > but can only be called from ML. In practice this should not be a major > limitation, except if your main program is not written in ML. > > Hope this clarifies the situation. Thanks for the reasoned and thought-out response, Jacques... but, sigh, I asked the wrong question (even though I was *thinking* the correct one in my head)! :) What I am after is probably more of a companion to Chapter 21 from the original [gtk.org] tutorial... what is required (both in LablGTK and C) to WRAP a already-functioning GTK+ widget? To cut to the chase (and hopefully make it easier to answer the "right" question), I want to build a LablGTK wrapper for the Scintilla edit control, which is already buildable as a GTK widget - and yes, I am aware of the Sci-Lab project, but I would like to make something a bit more minimalistic - and/or actually understand *why* all of those classes and modules are present/needed to wrap an existing widget. Further backstory - I have written a full Scintilla lexer for OCaml, and would like to try and build an all-OCaml-platforms version of "OCamlWinPlus" using LablGTK (hence the Scintilla wrapper) - with my own take on it, of course, probably influenced by my Smalltalk work in the past. In turn, how this turns out will help me evaluate the sanity, reasonableness and overall ease of constructing cross-platform apps using OCaml and LablGTK/GTK+... while I have high hopes for this [hopefully winning] combination, I am somewhat concerned by the apparent complexity of doing anything non-trivial in GTK+ - it's *almost* enough to make the Windows GDI (or at least GdiPlus) look reasonable! I am trusting for now that this perceived complexity is just the result of a lack of familiarity... So naturally, I will gladly accept any tips, pointers, hints, examples etc that might be helpful in my quest. :) Robert Roessler robertr@rftp.com http://www.rftp.com