+ MCI support for focusArgs, e.g. 'focusTextStyle'
+ TextView initial support for fillChar and justify + Add color support to string_util.js::pad() * Better color handling in Views
This commit is contained in:
@@ -26,13 +26,6 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(name) {
|
||||
return label;
|
||||
};
|
||||
|
||||
// :TODO: probably do something like this and generalize all of this:
|
||||
/*
|
||||
var MCI_ARG_MAP = {
|
||||
'ET' : { 0 : 'maxLength', 1 : 'textStyle' }
|
||||
};
|
||||
*/
|
||||
|
||||
MCIViewFactory.prototype.createFromMCI = function(mci) {
|
||||
assert(mci.code);
|
||||
assert(mci.id > 0);
|
||||
@@ -46,7 +39,6 @@ MCIViewFactory.prototype.createFromMCI = function(mci) {
|
||||
position : { x : mci.position[0], y : mci.position[1] },
|
||||
};
|
||||
|
||||
// :TODO: move this stuff out of the switch to their own methods/objects
|
||||
function setOption(pos, name) {
|
||||
if(mci.args.length > pos && mci.args[pos].length > 0) {
|
||||
options[name] = mci.args[pos];
|
||||
@@ -55,19 +47,19 @@ MCIViewFactory.prototype.createFromMCI = function(mci) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function setFocusOption(pos, name) {
|
||||
if(mci.focusArgs && mci.focusArgs.length > pos && mci.focusArgs[pos].length > 0) {
|
||||
options[name] = mci.focusArgs[pos];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(mci.code) {
|
||||
case 'TL' :
|
||||
// :TODO: convert to setOption()
|
||||
if(mci.args.length > 0) {
|
||||
options.textStyle = mci.args[0];
|
||||
}
|
||||
|
||||
if(mci.args.length > 1) {
|
||||
options.justify = mci.args[1];
|
||||
}
|
||||
|
||||
if(mci.args.length > 2) {
|
||||
options.maxLength = mci.args[2];
|
||||
setOption(0, 'textStyle');
|
||||
setOption(1, 'justify');
|
||||
if(setOption(2, 'maxLength')) {
|
||||
options.maxLength = parseInt(options.maxLength, 10);
|
||||
options.dimens = { width : options.maxLength };
|
||||
}
|
||||
|
||||
@@ -76,29 +68,26 @@ MCIViewFactory.prototype.createFromMCI = function(mci) {
|
||||
|
||||
case 'ET' :
|
||||
if(setOption(0, 'maxLength')) {
|
||||
options.dimens = { width : options.maxLength };
|
||||
options.maxLength = parseInt(options.maxLength, 10);
|
||||
options.dimens = { width : options.maxLength };
|
||||
}
|
||||
|
||||
setOption(1, 'textStyle');
|
||||
|
||||
setFocusOption(0, 'focusTextStyle');
|
||||
|
||||
view = new EditTextView(this.client, options);
|
||||
break;
|
||||
|
||||
case 'PL' :
|
||||
// :TODO: convert to setOption()
|
||||
if(mci.args.length > 0) {
|
||||
options.text = this.getPredefinedViewLabel(mci.args[0]);
|
||||
if(options.text) {
|
||||
if(mci.args.length > 1) {
|
||||
options.textStyle = mci.args[1];
|
||||
}
|
||||
setOption(1, 'textStyle');
|
||||
setOption(2, 'justify');
|
||||
|
||||
if(mci.args.length > 2) {
|
||||
options.justify = mci.args[2];
|
||||
}
|
||||
|
||||
if(mci.args.length > 3) {
|
||||
options.maxLength = mci.args[3];
|
||||
if(setOption(3, 'maxLength')) {
|
||||
options.maxLength = parseInt(options.maxLength, 10);
|
||||
options.dimens = { width : options.maxLength };
|
||||
}
|
||||
|
||||
@@ -107,20 +96,25 @@ MCIViewFactory.prototype.createFromMCI = function(mci) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'BV' :
|
||||
// :TODO: convert to setOption()
|
||||
case 'BN' :
|
||||
if(mci.args.length > 0) {
|
||||
options.text = mci.args[0];
|
||||
options.dimens = { width : options.text.length };
|
||||
options.dimens = { width : parseInt(mci.args[0], 10) };
|
||||
}
|
||||
|
||||
setOption(1, 'textStyle');
|
||||
setOption(2, 'justify');
|
||||
|
||||
setFocusOption(0, 'focusTextStyle');
|
||||
|
||||
view = new ButtonView(this.client, options);
|
||||
break;
|
||||
|
||||
case 'VM' :
|
||||
setOption(0, 'itemSpacing');
|
||||
setOption(1, 'justify');
|
||||
setOption(2, 'textStyle');
|
||||
setOption(0, 'itemSpacing');
|
||||
setOption(1, 'justify');
|
||||
setOption(2, 'textStyle');
|
||||
|
||||
setFocusOption(0, 'focusTextStyle');
|
||||
|
||||
view = new VerticalMenuView(this.client, options);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user