Hi Boris,
On Mar 30, 2004, at 7:05 PM, Borislav Iordanov wrote:
> Hi,
>
> I've added a few things jlib/swing.scm that I needed (toolbar and
> togglebutton). The additions simply follow the established pattern.
> What
> is the process of submitting a patch? I'm not familiar at all how those
> patch file are made and applied :(
Just send me the swing.scm file and I'll look it over and
check in the changes....
>
> And a question: what would be an elegant way to define a paint
> procedure
> for a generic component. Right now, my program has only one Java class
> that extends Jcomponent only in order to override the painProc method
> (which invokes a scheme procedure). It would be nice to have something
> like this:
>
> (component
> (paint (lambda (graphics) ...do the painting)))
It would be nice, but alas the awt toolkits was designed so that
the user must subclass a component to change the paint method.
IBM's SWT seems to be better designed in this regard as it has an
.addPaintListener method which allows one to add a listener which is
called whenever the component needs to be painted.
http://www.erights.org/javadoc/org/eclipse/swt/widgets/
Control.html#addPaintListener(org.eclipse.swt.events.PaintListener)
Just what we'd
like for swing. We should probably create SWT version of jlib
(although it is not as convenient as SWT is not part of the standard
Java distribution).
For the Swing toolkit we could use the javax.swing.RepaintManager class
to implement a paintListener pattern for Swing....
The idea (which I haven't tested) would be to define a wrapper
class SchemeRepaintManager which would allow the user
to specify the RepaintManager methods functionality using
Scheme procedures. Then one could use
RepaintManager.setCurrentManager(MyManager)
to set the manager for the current threadgroup.
The new manager could implement a paint listener
that would allow users to associate scheme procedures to
repaint methods (e.g. MyManager.paintDirtyRegions could
be overridden to call the appropriate paint listeners or
the default paint procedures on all components which have
dirty regions.
So it looks possible, but it doesn't look extremely easy...
---Tim---
>
> Isn't something of the sort that (canvas) and jlib.SchemeCanvas should
> be doing. But I'm not sure it works. There is paintHandler method in
> SchemeCanvas, but it doesn't seem to be set anywhere in the generic
> construction processing in swing.scm.
SchemeCanvas is a subclass of Canvas that allows one to manipulate
an offscreen buffer directly, and the repaint method has been
overridden to
copy the offscreen buffer to the screen. Its not too fancy, but quite
useful.
Hope this helps, (and send me your revised Swing.scm, I have some other
extensions, JTables, that need to be added to it as well....)
---Tim---
>
> Thanks,
> Boris
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Jscheme-user mailing list
> Jsc...@li...
> https://lists.sourceforge.net/lists/listinfo/jscheme-user
|