Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 9 made on Saturday June 1, 2019 at 01:15
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Code looks good. Now, on to your TODO's.

To define colors/fonts etc for text, I recommend the following:

In your RESOURCES page where you put all your corner and other images, define some panels with appropriate ProntoScript names like 'Message_Template', and buttons with prontoscript names 'Button_Template' etc..

Next, write a function that simply 'lifts' the values of properties from your RESOURCE widget(s) into the on-screen GUI.addPanel() or GUI.addButton() results.

For example:
var source = myResourceWidget;
var target = myGUIPanel;
var propertiesToCopy = ['color','font','width','label','transparent','visible'];

propertiesToCopy.forEach(function (key){
target[key] = source[key];
});

With this approach, you can visually see how text will appear, etc and design that on your resource page.

If you want different styles of dialogs, can simply create an activity with ProntoScript name 'DIALOG_TEMPLATES'. Inside this activity, you can put pages with ProntoScript names like 'DIALOG_STYLE_1'. Each of these pages has the same number of widgets with expected ProntoScript names.


Then, in your constructor for the dialog box, you could simply specify which 'Template' you wanted to use and then lookup your resource widgets as:

CF.widget('FRAME_TOP_LEFT', myTemplate, 'DIALOG_TEMPLATES'.

Also, I noted that your script uses Verdana or some other font. For the font to be available in your XCF for use by script, you must have this font defined on some widget in the config. Voila, you just created Templates with resource widgets so you've got that covered. Finally, you mentioned about sizing your text. To do this, you require a widget with the font you want to use installed. Again, your Template comes to the rescue as it holds the font you want in the size you want.

All you have to work out is how to do line breaks, etc...

Here is some code you may want to try out. It was written before Philips provided the ability to determine text size. It is based on max characters per line and the base code was originally in the Philips RSS Feed example module.

Hoping it will provide some assistance.


//********************************************************************************
// JavaScript String Extensions
//********************************************************************************
// String extensions for wordwrap + trimming
//String.wordWrap(maxLength: Integer, [breakWith: String = "\n"], [cutWords: Boolean = false]): String
//Returns an string with the extra characters/words "broken".
//maxLengthmaximum amount of characters per line
//breakWithstring that will be added whenever it's needed to break the line
//cutWordsif true, the words will be cut, so the line will have exactly "maxLength" characters, otherwise the words won't be cut
//
if (!String.prototype.wordWrap) {
String.prototype.wordWrap = function wordWrap(m, b, c) {
var i, j, s, r = this.split("\n");
if (m > 0) {
for (i in r) {
for (s = r[i], r[i] = ""; s.length > m; j = c ? m : (j = s.substr(0, m).match(/\S*$/)).input.length - j[0].length || m, r[i] += s.substr(0, j) + ((s = s.substr(j)).length ? b : "")) {};
r[i] += s;
}
}
return r.join("\n");
};
}
if (!String.prototype.wordWrapIntoArray) {
String.prototype.wordWrapIntoArray = function wordWrapIntoArray(m, b, c) {
var i, j, s, r = this.split("\n");
if (m > 0) {
for (i in r) {
for (s = r[i], r[i] = ""; s.length > m; j = c ? m : (j = s.substr(0, m).match(/\S*$/)).input.length - j[0].length || m, r[i] += s.substr(0, j) + ((s = s.substr(j)).length ? b : "")) {};
r[i] += s;
}
}
return r;
};
}
if (!String.prototype.trim) String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
};
if (!String.prototype.ltrim) String.prototype.ltrim = function() {
return this.replace(/^\s+/, "");
};
if (!String.prototype.rtrim) String.prototype.rtrim = function() {
return this.replace(/\s+$/, "");
};
//********************************************************************************
// JavaScript String Extensions
//********************************************************************************

Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse