I've been looking at SWT text styling capabilities lately. Some API bits seem to be missing in fwt. The main missing part in RichText widget is the pixel precision reporting - used to control scrolling, to supply viewport information and synchronization of other widgets with the actual view.
Do you plan to add this functionality or rather to provide another way around? My first impression is that this stuff (in eclipse, for instance) is used in very low level way - mostly to use Canvas / Graphics component to pixel-position text and widgets, then render using double buffering manually...
Another thing - most things in fwt seem to be constructed inline. In JFace most components expect an explicit parent in constructor to allow more flexible placement. What is the recommended way for fwt (re-parenting is not supported)?
brianWed 19 Nov 2008
So did you confirm that Eclipse's Java editor does use the StyledText widget? I started trying to dig thru the code and never confirmed that.
We really want the fwt to be the low level toolkit akin to the swt. Sometimes the swt is too low level, but already fwt provides a lot for the higher level model APIs like what JFace provides.
In the case of RichText - I've found swt StyledText very lacking. I should probably just write my own RichText widget in pure Fan and it would be a lot more flexible - but not something I have time for right now. Can you suggest some specific APIs you'd like to add to RichText? You can send me a patch to review. Since we have to make this portable b/w Swing and .NET we want to keep things as generic as possible. But we definitely need the ability to either a) paint onto the RichText itself or b) get pixel alignment.
Another thing - most things in fwt seem to be constructed inline. In JFace most components expect an explicit parent in constructor to allow more flexible placement.
Actually it is swt which is inflexible. SWT requires you to pass your parent to the constructor of every widget - this was a design compromise in SWT to make their lives easier. It turns out to be a huge pain for developers. FWT lets you create widgets whenever you want and mount them as needed. You can't mount a given widget under more than parent, but you can unmount and remount - so reparenting is supported. Not sure what you were asking here.
katoxThu 20 Nov 2008
So did you confirm that Eclipse's Java editor does use the StyledText widget? I started trying to dig thru the code and never confirmed that.
They definitely use StyledText. But as you already mentioned it is quite underpowered so they use a lot of ancillary code. And (judging from some code snippets and comments) there was a different solution historically.
Can you suggest some specific APIs you'd like to add to RichText? You can send me a patch to review. Since we have to make this portable b/w Swing and .NET we want to keep things as generic as possible. But we definitely need the ability to either a) paint onto the RichText itself or b) get pixel alignment.
I'll try to get some stuff together by wrapping a few more low level SWT functions. The biggest issue is to get viewports in sync with other widgets. It would probably need some sort of synchronization events. The problem is that there is nearly no connection between the text representation and the model itself (you don't know what is visible etc.). Once there is some solution I can try to come up with some API enhancements.
>But we definitely need the ability to either a) paint onto the RichText itself
I think they use a transparent canvas to achieve that. Quite reasonable.
or b) get pixel alignment.
This would cover the majority of common usages.
You can't mount a given widget under more than parent, but you can unmount and remount - so reparenting is supported. Not sure what you were asking here.
Great, I wasn't sure about this. Could you point me to an example, please? I must be doing something wrong.
brianThu 20 Nov 2008
Great, I wasn't sure about this. Could you point me to an example, please? I must be doing something wrong.
You just need to remove (or replace the widget). You can check Widget.parent - it should be null before you add to a parent (and should be null when you remove a widget).
katox Wed 19 Nov 2008
I've been looking at SWT text styling capabilities lately. Some API bits seem to be missing in
fwt
. The main missing part in RichText widget is the pixel precision reporting - used to control scrolling, to supply viewport information and synchronization of other widgets with the actual view.In eclipse code it is mostly used indirectly via JFaceTextUtil class.
Do you plan to add this functionality or rather to provide another way around? My first impression is that this stuff (in eclipse, for instance) is used in very low level way - mostly to use Canvas / Graphics component to pixel-position text and widgets, then render using double buffering manually...
Another thing - most things in fwt seem to be constructed inline. In JFace most components expect an explicit parent in constructor to allow more flexible placement. What is the recommended way for
fwt
(re-parenting is not supported)?brian Wed 19 Nov 2008
So did you confirm that Eclipse's Java editor does use the StyledText widget? I started trying to dig thru the code and never confirmed that.
We really want the fwt to be the low level toolkit akin to the swt. Sometimes the swt is too low level, but already fwt provides a lot for the higher level model APIs like what JFace provides.
In the case of RichText - I've found swt StyledText very lacking. I should probably just write my own RichText widget in pure Fan and it would be a lot more flexible - but not something I have time for right now. Can you suggest some specific APIs you'd like to add to RichText? You can send me a patch to review. Since we have to make this portable b/w Swing and .NET we want to keep things as generic as possible. But we definitely need the ability to either a) paint onto the RichText itself or b) get pixel alignment.
Actually it is swt which is inflexible. SWT requires you to pass your parent to the constructor of every widget - this was a design compromise in SWT to make their lives easier. It turns out to be a huge pain for developers. FWT lets you create widgets whenever you want and mount them as needed. You can't mount a given widget under more than parent, but you can unmount and remount - so reparenting is supported. Not sure what you were asking here.
katox Thu 20 Nov 2008
They definitely use StyledText. But as you already mentioned it is quite underpowered so they use a lot of ancillary code. And (judging from some code snippets and comments) there was a different solution historically.
I'll try to get some stuff together by wrapping a few more low level SWT functions. The biggest issue is to get viewports in sync with other widgets. It would probably need some sort of synchronization events. The problem is that there is nearly no connection between the text representation and the model itself (you don't know what is visible etc.). Once there is some solution I can try to come up with some API enhancements.
>But we definitely need the ability to either a) paint onto the RichText itself
I think they use a transparent canvas to achieve that. Quite reasonable.
This would cover the majority of common usages.
Great, I wasn't sure about this. Could you point me to an example, please? I must be doing something wrong.
brian Thu 20 Nov 2008
You just need to remove (or replace the widget). You can check
Widget.parent
- it should be null before you add to a parent (and should be null when you remove a widget).