Right to left support

Hello,

does the framework support Right to left interfaces?
(ComponentOrientation.RIGHT_TO_LEFT)
It is probably theme dependent?

I would like to use the eclipse(glass) theme with RTL interface (also with standard).
Do I need to write an extension (is it hard)?

Thanks in advance!
Maciej

There is no support at all, and currently I do not plan to add some (because that would be really a lot of work to do it proper for all the themes). I fear an extension would also require a lot of work, even if you only want to support the EclipseTheme.

A “quick and dirty” hack for RTL would include:

  • New painting code for the tabs is required. That means a new TabPainter needs to be implemented.
  • A new TabLayoutManager is required. This layout-manager is responsible for setting location and size of tabs.
  • Luckily reversing the order of the DockActions (the little buttons on the titles) is not that hard, a new implementation of ActionOffer and DockActionSource could do the trick.
  • You may need to implement new DockTitles for reversing the order of title-icon and title-text.

I looked a bit in the code, but please correct me if I am wrong:

[QUOTE=Beni]

  • New painting code for the tabs is required. That means a new TabPainter needs to be implemented.
  • A new TabLayoutManager is required. This layout-manager is responsible for setting location and size of tabs.[/QUOTE]

I can install a custom TabPainter using the EclipseTheme.TAB_PAINTER, like so:
dockController.getProperties().set( EclipseTheme.TAB_PAINTER, RTLTabPainter.FACTORY );
Similarly for the TabLayoutManager:
dockController.getProperties().set( TabPane.LAYOUT_MANAGER, new RTLMenuLineLayout(), Priority.THEME);

[QUOTE=Beni;13591]

  • Luckily reversing the order of the DockActions (the little buttons on the titles) is not that hard, a new implementation of ActionOffer and DockActionSource could do the trick.
  • You may need to implement new DockTitles for reversing the order of title-icon and title-text.[/QUOTE]

I didn’t check very carefullt but I suppose it is done in a similar fashion, e.g DockControler.setDefaultActionOffer?

I think there is one more thing that needs to be changed - the StackDockStation.
The tab order is now reversed, so when a new tab is inserted or the tabs get rearranged
the insert position has to be calculated accordingly.
For example in the drop() and move() methods “insert.right ? 1 : 0” has to be replaces with
“insert.right ? 0 : 1” (the next tab is now to the left). Also in Background.paintOverlay, the insertion has to be calculated differently.
Is there a way to replace the StackDockStation with a custom one?
(I see that BasicCombiner uses StackDockStation directly)

thanks!
Maciej

The first part is correct, the properties are used for that.

Yes. I think the easiest solution is to write a wrapper for „DefaultActionOffer“. Its „getSource“ method would return your custom DockActionSource that wrapps around the source from the default-offer and reverses the order.

I think there is one more thing that needs to be changed - the StackDockStation.
The tab order is now reversed, so when a new tab is inserted or the tabs get rearranged
the insert position has to be calculated accordingly.
For example in the drop() and move() methods „insert.right ? 1 : 0“ has to be replaces with
„insert.right ? 0 : 1“ (the next tab is now to the left). Also in Background.paintOverlay, the insertion has to be calculated differently.
Is there a way to replace the StackDockStation with a custom one?
(I see that BasicCombiner uses StackDockStation directly)

Hm, I did not think of that. StackDockStations are either created by a Combiner or when a layout is loaded by a DockSituation. So you would need to modify both of them.
[ul]
[li]For the persistent layout: call DockFrontend.registerFactory (see CControl.intern() if using Common) or DockSituation.add (only if you create one by yourself, you don’t have access to the ones that are created by the framework) to register a custom factory creating new StackDockStations. For the factory you can extend „StackDockStationFactory“ and override the „createStation“ method.
[/li][li]For the Combiner. Get the DockTheme you use (an instance of EclipseTheme) and call the „setCombiner“ method. You have to provide a new Combiner, copy the source of BasicCombiner to write it.
[/li]
If using Common you have to wrap your EclipseTheme into a CEclipseTheme (new CEclipseTheme(eclipseTheme)). Actually you should access the ThemeMap and install a factory for creating the theme (see CControl.getThemes).
[/ul]
For your new StackDockStation class: I think you only need to override the „drop()“ and „move()“ method. I’m not sure if „paintOverlay“ needs an update: for example if the mouse is over the right side of tab „x“ then the method takes the boundaries of tab „x“ and paints at the right side, and thats how it should look like both in LR and in RL.

[Edit: for the titles: Titles are created by the DockTitleManager (DockController.getDockTitleManager). You would need to register new factories for all the titles you want to replace. The factories are stored in a map, and the keys for that map are String constants defined in the DockStations, for example „FlapDockStation.WINDOW_TITLE_ID“ and „FlapDockStation.BUTTON_TITLE_ID“.]