djo / XScalaWT (http://coconut-palm-software.com/the_new_visual_editor/doku.php)
XScalaWT is the merging of XSWT and Glimmer using Scala as a source language rather than XML. The result is a strongly-typed DSL for creating SWT GUIs using Scala. License: Eclipse Public License
| commit 46: | b1acaf1d3c50 |
| parent 45: | 570c4b6da02e |
| branch: | default |
Added Function to ModifyListener implicit conversion
Changed (Δ851 bytes):
raw changeset »
src/com/coconut_palm_software/xscalawt/XScalaWT.scala (19 lines added, 0 lines removed)
Up to file-list src/com/coconut_palm_software/xscalawt/XScalaWT.scala:
| … | … | @@ -320,6 +320,8 @@ object XScalaWT { |
320 |
320 |
|
321 |
321 |
// Event handling here |
322 |
322 |
|
323 |
// SelectionListener------------------------------------------------------------- |
|
324 |
||
323 |
325 |
def addSelectionListener[T <: {def addSelectionListener(l : SelectionListener)}](l : SelectionListener)(subject:T) = { |
324 |
326 |
subject.addSelectionListener(l) |
325 |
327 |
} |
| … | … | @@ -341,6 +343,23 @@ object XScalaWT { |
341 |
343 |
override def widgetSelected(e : SelectionEvent) = func.apply(e) |
342 |
344 |
} |
343 |
345 |
|
346 |
// ModifyListener----------------------------------------------------------------- |
|
347 |
||
348 |
def addModifyListener[T <: {def addModifyListener(l : ModifyListener)}](l : ModifyListener)(subject : T) = { |
|
349 |
subject.addModifyListener(l) |
|
350 |
} |
|
351 |
||
352 |
private class ModifyListenerForwarder(l : (ModifyEvent => Unit)) extends ModifyListener { |
|
353 |
override def modifyText(e : ModifyEvent) = l(e) |
|
354 |
} |
|
355 |
||
356 |
implicit def modifyFn2addModifyListener[T <: {def addModifyListener(l : ModifyListener)}](l : (ModifyEvent => Unit))(subject : T) = |
|
357 |
subject.addModifyListener(new ModifyListenerForwarder(l)) |
|
358 |
||
359 |
implicit def func2ModifyListener[T <: { def apply(e : ModifyEvent) }](func : T) = new ModifyListener() { |
|
360 |
override def modifyText(e : ModifyEvent) = func.apply(e) |
|
361 |
} |
|
362 |
||
344 |
363 |
// Convenience methods |
345 |
364 |
implicit def int2Color(swtColorConstant : Int) = Display.getDefault.getSystemColor(swtColorConstant) |
346 |
365 |
def display = Display.getDefault |
