Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Riena/Look and Feel"

(Look&Feel for Riena)
(Dialog =)
Line 91: Line 91:
 
== Look&Feel Keys ==
 
== Look&Feel Keys ==
 
The class org.eclipse.riena.ui.swt.lnf.LnfKeyConstants defa
 
The class org.eclipse.riena.ui.swt.lnf.LnfKeyConstants defa
=== Dialog ====
+
=== Dialog ===
  
 
[[Image:lnfDialogTitleBar.png]]
 
[[Image:lnfDialogTitleBar.png]]
  
 
[[Category:Riena]]
 
[[Category:Riena]]

Revision as of 08:21, 27 April 2009

Riena Project > Look & Feel

Look&Feel for Riena

Riena provides a Look&Feel for the controls of the navigation. The Riena Look&Feel remembers the Look&Feel of Swing.

A Look&Feel of Riena consists of the Look&Feel with a Theme. The Theme provides the colors, fonts, images and some other settings. In the Look&Feel other renderers for some controls can be set.

Custom Look&Feel

In your own Look&Feel you must set your Theme and an ID.

The following steps are necessary:

  1. Extent the class RienaDefaultLnf
  2. Create and set the Theme
  3. Return the ID

Example:

public class ExampleLnf extends RienaDefaultLnf {
 
  public ExampleLnf() {
    super();
    setTheme(new ExampleTheme());
  }
 
  @Override
  protected String getLnfId() {
    return ExampleLnf;
  }
 
}

To set your custom Look&Feel call the static method setLnf(lnf) of the class LnfManager. The recommended place to do that is the constructor of the Riena Application (SwtApplication):

Example:

public SwtExampleApplication() {
  super();
  LnfManager.setLnf(new ExampleLnf());
}

Custom Theme

To write your own Theme you must implements the interface ILnfTheme.

The interface has the following four methods:

addCustomColors(Map<String, ILnfResource> table)

addCustomFonts(Map<String, ILnfResource> table)

addCustomImages(Map<String, ILnfResource> table)

addCustomSettings(Map<String, Object> table)

These methods must be implemented to define the colors, fonts, images and settings for the controls of the navigation.

It is recommend to extent the default theme of Riena, DefaultRienaTheme. All necessary resources and settings are already defined in the default theme. You must only put your own defaults into the tables of the Look&Feel.

The following line e.g. specifies the background color of a sub module:

table.put(ILnfKeyConstants.SUB_MODULE_BACKGROUND,new ColorLnfResource(186, 193, 225));

All existing keys for the Look&Feel you can find in the interface ILnfKeyConstants. It is not possible to add colors from the type org.eclipse.swt.graphics.Color. The colors must be wrapped from an instance of the class ColorLnfResource. This helps the Look&Feel to dispose all resources of the Look&Feel. Also wrappers for fonts and images exist.

Custom Renderer

For nearly every control of the navigation a renderer is used to paint it. This renderers can be replaced by own implementations. To write your own renderer please extent an existing default renderer

To set your own renderer you can use extensions. Therefore Riena provides an extension points: org.eclipse.riena.ui.swt.lnfrenderer

This extension can only have renderer elements. A renderer element has the following three attributes:

lnfkey              Key of the Look&Feel for the renderer (see LnfKeyConstants)

lnfid               ID of the your own Look&Feel (see getLnfId())

class              Class of the RendererExample:

<extension point="org.eclipse.riena.ui.swt.lnfrenderer">
  <renderer class="org.eclipse.riena.example. application.ExampleModuleGroupRenderer"
            lnfid="ExampleLnf"
            lnfkey="ModuleGroup.renderer">
  </renderer>
</extension>

Look&Feel Keys

The class org.eclipse.riena.ui.swt.lnf.LnfKeyConstants defa

Dialog

LnfDialogTitleBar.png

Back to the top