To complement bg and fg in the Text widget, here's a quick patch that adds the same to RichText. Though perhaps this could / should be moved to the TextWidget base class instead.
I would have added Javascript support too but there doesn't seem to be a TextWidgetPeer.js.
diff -r 73783f732179 src/fwt/fan/RichText.fan
--- a/src/fwt/fan/RichText.fan Wed Apr 13 11:44:09 2016 -0400
+++ b/src/fwt/fan/RichText.fan Thu Apr 14 13:39:16 2016 +0100
@@ -142,6 +142,18 @@
set { model.text = it }
}
+ **
+ ** The current foreground color for text.
+ ** Defaults to null (system default)
+ **
+ native Color? fg
+
+ **
+ ** The current background color of text field
+ ** Defaults to null (system default)
+ **
+ native Color? bg
+
//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////
diff -r 73783f732179 src/fwt/java/RichTextPeer.java
--- a/src/fwt/java/RichTextPeer.java Wed Apr 13 11:44:09 2016 -0400
+++ b/src/fwt/java/RichTextPeer.java Thu Apr 14 13:39:16 2016 +0100
@@ -162,6 +162,23 @@
public void set(Widget w, int v) { ((StyledText)w).setTabs(v); }
};
+ public fan.gfx.Color fg(RichText self) { return fg.get(); }
+ public void fg(RichText self, fan.gfx.Color v) { fg.set(v); }
+ public final Prop.ColorProp fg = new Prop.ColorProp(this)
+ {
+ public void set(Widget w, org.eclipse.swt.graphics.Color v) { ((StyledText)w).setForeground(v); }
+ };
+
+ public fan.gfx.Color bg(RichText self) { return bg.get(); }
+ public void bg(RichText self, fan.gfx.Color v) { bg.set(v); }
+ public final Prop.ColorProp bg = new Prop.ColorProp(this)
+ {
+ public void set(Widget w, org.eclipse.swt.graphics.Color v) {
+ ((StyledText)w).setBackground(v);
+ ((StyledText)w).setMarginColor(v);
+ }
+ };
+
//////////////////////////////////////////////////////////////////////////
// Selection
//////////////////////////////////////////////////////////////////////////
SlimerDudeSun 28 May 2017
Bump!
I'm still keen on adding fg and bg to fwt's RichText widget, either through the above patch or other means.
RichText does need a bg for it fills the gaps between the text and the window. Here's a comparison of what a program looks like with the patch, and without.
I think we can all agree that that with looks better than without!
SlimerDude Thu 14 Apr 2016
Hi,
To complement
bg
andfg
in the Text widget, here's a quick patch that adds the same to RichText. Though perhaps this could / should be moved to theTextWidget
base class instead.I would have added Javascript support too but there doesn't seem to be a
TextWidgetPeer.js
.SlimerDude Sun 28 May 2017
Bump!
I'm still keen on adding
fg
andbg
to fwt'sRichText
widget, either through the above patch or other means.RichText does need a
bg
for it fills the gaps between the text and the window. Here's a comparison of what a program looks like with the patch, and without.I think we can all agree that that with looks better than without!
andy Wed 31 May 2017
Steve - open an PR and I can merge it
SlimerDude Fri 2 Jun 2017
Cool, thanks for merging the Pull Request.