Custom themes

Information about development with ProjX.

Custom themes

Postby Development@SIB » Tue Apr 08, 2014 2:29 pm

If you use a ProjX application you'll have different options to change the Look and Feel. The first one will be a custom Swing Look and Feel or custom CSS (HTML5 mode). The second one is extending default ProjX and change the style programatically. The third option is to implement your own Theme.

A theme is not a replacement for Swing Look and Feel or CSS, because you can't change everything. A theme should be used to set default choice editors, checkbox editor, change image mappings, set toolbar button size, ...

It's very easy to create a new theme because there's only an interface with one method:

Code: Select all
public interface ITheme
{
   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   // Method definitions
   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   /**
    * Applies the theme for the given application.
    *
    * @param pApplication the application
    */
   public void apply(Application pApplication);
   
}   // ITheme

Simply implement this interface and set the theme via application parameter.

ProjX supports two built-in themes. The implementations are ClassicTheme and ModernTheme. To switch the default theme, simply set the parameter:

Application.iconstyle to classic or modern

An example implementation could do following:

Code: Select all
public void apply(Application pApplication)
{
   UIImage.setImageMapping(UIImage.SAVE_SMALL, "/com/sibvisions/demo/images/save.png");
   UIImage.setImageMapping(UIImage.SAVE_LARGE, "/com/sibvisions/demo/images/save_l.png");

   UIImage.setImageMapping(UIImage.REDO_SMALL, "/com/sibvisions/demo/images/redo.png");
   UIImage.setImageMapping(UIImage.REDO_LARGE, "/com/sibvisions/demo/images/redo_l.png");
   
   NavigationTable.setDefaultButtonSize(21);
}
User avatar
Development@SIB
 
Posts: 311
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation