Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sun Nov 19, 2017 1:43 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Apr 26, 2010 1:19 am 
Offline

Joined: Fri Sep 18, 2009 10:59 pm
Posts: 19
Location: Mumbai, India.
Hi,

I have made an complex application on QTERM-G75 touchscreen. It uses around 400 different objects. All the visual objects vary widely in their appearances (i.e. in terms of background color and foreground color). Now as a new requirement, I am supposed to provide day-mode and night-mode of operation. For achieving this I am required to change background and foreground colors of these objects.

My doubts are as follows:

1. How can I achieve this more easily instead of reassigning foreground, background and other colors to 100s of objects everytime the mode is switched from day-mode to night-mode or vice-versa.

2. Can I create something like variables of type color and initialize all the objects using this small set of variables. Also, each time I change the values assigned to these variables, it shall automatically reflect at all the places where they are used. Is something like this possible?

3. Can you suggest some other way in which this functionality - day-mdoe and night-mode can be achieved? Which one is the best and efficient method to achieve this?

Thank you.

-Jay


Top
 Profile  
 
PostPosted: Mon Apr 26, 2010 6:48 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Qlarity objects from 2.0 onward are "themeable". You will notice that by default nearly all properties are set to a meta color value instead of a specific color. For example when you create a ButtonV2 object, its background will be "clr_buttonbackground" instead of say "251". The intent is that it be possible to mass change object colors. In Layout View (I know you are looking for runtime changes, but be patient here), if you select Edit->Edit Named Colors, a dialog appears where you can modify what color clr_buttonbackground actually resolves to. If you change that color in that dialog and press OK, all objects that use clr_buttonbackground will redraw themselves with the new color.

It is also possible to add new named colors via that dialog. For example, if you need red tinted button, you could add clr_redbuttonbg and set an appropriate color.

Now, to take advantage of this you will need to edit your workspace so that all objects which should have a day and a night setting use named colors instead of specific colors.

If you play with the named color dialog for a bit, you may notice that there are "themes". A theme is a set of values for the named colors (and borders in the named border dialog). You could create a theme called "day theme" and "night theme" or use existing themes (e.g. "bright" and "midnight" which were designed with this in mind).

Now if you want to change the theme at runtime, there are a couple of different options. I am going to suggest what I think may be the simplest option. If you select Tools->Theme Selection Listbox, you can insert a listbox object into your workspace that has all the code necessary to completely change the theme of your workspace. Qlarity Foundry will present you with a UI to select which themes you want to present. Simply uncheck all but your day and night themes.

If you don't want the user to select a theme from the list, simply disable the object and move it somewhere out of the way. Whenever you want to change themes in your program, simply issue a line of code like:

ts_themelist.selected = 1

and that item in the listbox will be programatically selected and the theme will change (note the listbox is zero index based). All of your objects will redraw with the new theme (this can take a second or two depending on the complexity of your workspace).

If you do edit your themes later, you will need to create a new theme listbox, since the listbox created is a snapshot of the theme state at the time of creation. If you would rather edit your themes manually in code, look at the SelChanged event for that listbox to see how it is done (note the use of := and = in the assignment statements in that event)

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group