Tags:
create new tag
view all tags

.WIDGET APPLY THEME

This subroutine applies a GUI Theme to the the current image.


Usage:

      GOSUB    --- .WIDGET APPLY THEME
      *        Check for errors
      IF       --- .WIDGET APPLY THEME        NE

Description:

This subroutine applies a GUI Theme to the the current image. No parameters are required, however, some setup is needed.

Before you can use this subroutine, you must create at least one MENU process to act as a 'theme'. On the image of the menu process, add various Widgets for the elements you want to standardize. For example, if you want all your buttons to have certain foreground/background/rollover colors, then define a button with the desired attributes. The same applies to Titlebar attributes, background images, items (fields), and so on. If you have standard attributes you want applied to some buttons, but not others, then define another button and give it a name. For example, you might want to have your 'Cancel' buttons look different from other buttons. You could give it the name CANCEL BUTTON. On the images in your application where you want a button to use those attributes, give it the same name. This technique applies to all Widget types. If the subroutine cannot find a match in your theme for a particular name, it will default to the unnamed widget in your theme. In other words, if your theme did not contain a button called CANCEL BUTTON it would use the unnamed button, if there was one.

You can also use 'prefixes' in Widget names. If the Widget name in your theme ends with a period, then this routine will apply the theme to every other widget that begins with that name. For example, if you create a button with a widget name of "NAV.", then the theme will be applied to every button whose name begins with "NAV.", such as "NAV.OK", "NAV.CANCEL", "NAV.NEXT REC" or just "NAV.".

You might want to consider giving this Menu a distinctive name to make it obvious this is not a normal menu, ie, prefix it with a ":" or other special character. The name of this process will be your 'Theme Name'.

Next, you want to set that name somewhere in your application by calling .WIDGET SET THEME. This sets a Detached work field, so you only need to assign it once. You can change this whenever you want. For example, different applications can use different themes just by changing this name. If your Theme Menu is not in the current application, then you should also set the APPLICATION parameter of .WIDGET SET THEME to the application id that contains the Theme Menu. If this is blank, the subroutine will look in the current application. You can also use a theme that is in a different version by setting the VERSION parameter of .WIDGET SET THEME.

Finally, you should add a GOSUB to this subroutine in the Global Pre-Display event point of Inputs and Pre-Display event point of Menus. You can use the .WIDGET MISSING THEME subroutine to help you find these processes.

You can create more than one theme for use in different processes. This is done by first creating another Menu Theme process with the same base name as your main Theme Menu, and then appending a period and some additional characters. For example, you may want all your File Maintenance processes to have a different look from Data Entry processes. You could define 2 additional theme menu processes, one with ".FM" appended to the name, and one with ".DE" appended to the name. In the Input processes where you want to use the ".FM" theme, go to the Image Editor, Window Properties, and put ".FM" as the widget name. Do the same for the Data Entry processes. At runtime, the --- .WIDGET APPLY THEME subroutine will notice the widget name, append it to the base name set with .WIDGET SET THEME, and use that process as the theme. You could also simply change the theme to point to another theme, but since it is Detached, it will retain that new theme until you change it back.

This subroutine copies micro adjustments, resources, all color settings, fonts, font styles, font sizes, text positions, margins, tiling mode, location type, tooltips, and the settings for the Close, Ok and Help buttons to the GUI attributes of the widgets on the current image. It only replaces default settings, so if you have manually set a font, color or other attribute, that will remain unchanged.

Your theme will also apply to the Appx runtime processes (ie, Scan, Disposition, Help, etc).

Comments:

Read what other users have said about this page or add your own comments.


This is fantastic. Just tried it for the first time today. This saves a lot of work and makes your application really uniform without any effort.

-- WimJongejan - 2014-02-20

It is not quite clear in this documentation where to put the subroutine .WIDGET SET THEME but I called it in the start of process of the Startup Menu. Works good.

-- WimJongejan - 2014-02-20

-- JeanNeron - 2012-02-13

Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2014-02-20 - WimJongejan
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback