function Gadget(){
this.superClass=container;
this.superClass({});}
Gadget.prototype=new container({});
Gadget.prototype.getDefaultIcon=function(){
if(!isString(this._product_id))return;

var bg_container=new container({});
var image_url=APPLI_PATH+this._product_id+"/icon.png";
bg_container.background=new gbox({width:this.$width,height:40,color:[0,0,0,160],
translate:[0,-232*0.5+20,-0.6],
round_enable:false,round_width:8,round_height:8,});
bg_container.default_app_logo=new gimage({translate:[-20,26,-0.2],width:160,height:112});
bg_container.default_app_logo2=new gimage({translate:[0,6,-0.4],color:[255,255,255,100],width:160,height:112});
bg_container.gadget_title=new gtext({translate:[0,-94,-0.2],width:400,font_size:32,
align:CENTER,omitter:"...",color:[255,255,255,255],});
bg_container._title=this._getTitle();
setf_text(bg_container.gadget_title,bg_container._title);

bg_container.default_app_logo.src=image_url;
bg_container.default_app_logo2.src=image_url;
bg_container.components.push(bg_container.background,bg_container.default_app_logo2,
bg_container.default_app_logo,bg_container.gadget_title);
bg_container.freeResource=function(bool){
if(bool){
this.default_app_logo.org_src=this.default_app_logo.src;
this.default_app_logo.src="";
this.default_app_logo2.src="";
this.gadget_title.org_text=this.gadget_title.text;
setf_text(this.gadget_title,"");}else{
if(this.default_app_logo.org_src){
this.default_app_logo.src=this.default_app_logo.org_src;
this.default_app_logo2.src=this.default_app_logo.org_src;
this.default_app_logo.org_src="";}
if(this.gadget_title.org_text){
setf_text(this.gadget_title,this.gadget_title.org_text);
this.gadget_title.org_text="";}
}
};
if((system.mdl_cfg.with_pen_support_web_browser||system.mdl_cfg.with_pen_support_startup_ui)==true){
this._checkPenSupport(bg_container);}
return bg_container;}
Gadget.prototype.init=function(){
if(!isString(this._product_id))return;
this.default_icon=this.getDefaultIcon();
this.components.push(this.default_icon);
var exist=apps_nvram_file.apps_exist({product_id:this._product_id,filename:"Info.plist"});
if(exist)
this._info_plist=read_file(APPLI_PATH+this._product_id+"/Info.plist");};
Gadget.prototype.isUseFrame=function(){
return true;};
Gadget.prototype.setProductId=function(product_id){
if(isString(product_id))this._product_id=product_id;};
Gadget.prototype.setUniqId=function(uniq_id){
if(isString(uniq_id))this._uniq_id=uniq_id;};
Gadget.prototype.activate=function(bool){};
Gadget.prototype.suspend=function(bool){};
Gadget.prototype.setFullscreen=function(bool){};
Gadget.prototype.destroy=function(){};
Gadget.prototype.vanish=function(){};
Gadget.prototype.remove=function(){};
Gadget.prototype.isInstaller=function(){return false;};
Gadget.prototype.$width=412;
Gadget.prototype.$height=232;
Gadget.prototype.setSize=function(w,h){this.$width=w;this.$height=h;};
Gadget.prototype.$map_w=1;
Gadget.prototype.$map_h=1;
Gadget.prototype.setMapSize=function(w,h){this.$map_w=w;this.$map_h=h;};
Gadget.prototype.voicePlay=function(){
if(!isString(this._product_id))return;
if(!this._info_plist){
var exist=apps_nvram_file.apps_exist({product_id:this._product_id,filename:"Info.plist"});
if(!exist)return;
this._info_plist=read_file(APPLI_PATH+this._product_id+"/Info.plist");}
var is_network_appli=false;
if(isString(this._info_plist)){
try{
var ret=this._info_plist.match(new RegExp("^disclaimer=(.+)$","m"));
if(ret&&ret.length>0&&ret[1].match(new RegExp("^true")))
is_network_appli=true;}catch(e){
console.log(e.message);};}
if(is_network_appli)
VoicePlay(LANG("LT_HOME_NETWORK_APPLICATION")+". "+LANG("LT_VG_NOT_SUPPORTED"));
else
VoicePlay(this._getTitle());}
Gadget.prototype.onFocus=function(is_focused,key,point_env){
if(is_focused){
this.requestFocus([0,0,1],[this.$width,this.$height],0,42,null);}else {
if(this.warn_message){
var start_alpha=this.warn_message.color[3];
var max_count=10;
var da=Math.floor(start_alpha/max_count);
append_timer(this,80,function (obj,count){
if(count>max_count){
delete_timer(obj);
obj.warn_message.visibe_p=false;
obj.warn_message_b.visibe_p=false;
setf_text(obj.warn_message,"");
var index=obj.components.indexOf(obj.warn_message_b);
obj.warn_message=null;
obj.warn_message_b=null;
obj.components.splice(index,2);}else {
if(obj.warn_message.color[3]>da){
obj.warn_message.color[3]-=da;
obj.warn_message_b.color[3]-=da;}
}
force_redraw();});}
}
}
Gadget.prototype.key_hook=function(up_down,key){
return false;}
Gadget.prototype.point_hook=function(type,identifier,x,y,screenX,screenY){
return false;}
Gadget.prototype.launchApl=function(locked_panel,report){
var ret=-1;
if(isString(this._product_id)){
ret=apputil.launch_apl(this._product_id,null,locked_panel,report);}else{
if(!this.warn_message){
this.warn_message=new gtextbox({visible_p:false,width:320,height:200,
font_size:32,color:[0,0,0,255],align:LC_TEXT_ALIGN,
text:LANG("LT_HOME_APP_MESSAGE"),});
this.warn_message_b=new gtextbox({translate:[2,-2,0],visible_p:false,width:320,height:200,align:LC_TEXT_ALIGN,
font_size:32,color:[180,180,180,255],
text:LANG("LT_HOME_APP_MESSAGE"),});
this.components.push(this.warn_message_b,this.warn_message);
var max_count=10;
this.warn_message.color[3]=0;
this.warn_message_b.color[3]=0;
this.warn_message.visible_p=true;
this.warn_message_b.visible_p=true;
append_timer(this,80,function (obj,count){
if(count>max_count){
delete_timer(obj);
obj.warn_message_b.color[3]=255;
obj.warn_message.color[3]=255;}else {
obj.warn_message_b.color[3]+=25;
obj.warn_message.color[3]+=25;}
force_redraw();});}
}
return ret;};
Gadget.prototype.directLaunch=NULL_FUNCTION;
Gadget.prototype.animation=function(count){};
Gadget.prototype.freeResource=function(bool){
if(this.default_icon){
this.default_icon.freeResource(bool);}
};
Gadget.prototype.getStatus=function(){
var status={"movable":true,"removable":true};
if(this.$map_w>1||this.$map_h>1){
status["movable"]=false;
status["removable"]=false;}
if(!isString(this._product_id)){
status["removable"]=false;}
return status;};
Gadget.prototype.setLocked=function(locked){
if(locked==true&&!this._locked_face){
this._locked_face=new gimage({src:IMG_PATH+"locked.png",
translate:[182,90,0],});
this.components.push(this._locked_face);}
try{
this._locked_face.visible_p=locked;}catch(e){
}
};
Gadget.prototype.setFocusFunc=function (focus_moveto){
if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
};
Gadget.prototype.setReportErrorFunc=function (reportError){
if(reportError instanceof Function){
this.reportErrorFunc=reportError;}
};
Gadget.prototype.setRequestConfirmPanelFunc=function (requestConfirmPanel){
if(requestConfirmPanel instanceof Function){
this.requestConfirmPanelFunc=requestConfirmPanel;}
};
Gadget.prototype.setReadProductDataFunc=function (readProductDataFunc){
if(readProductDataFunc instanceof Function){
this.readProductDataFunc=readProductDataFunc;}
};
Gadget.prototype.setLaunchMyselfFunc=function (launchMyself){
if(launchMyself instanceof Function){
this.launchMyself=launchMyself;}
};
Gadget.prototype.setSendBroadcastFunc=function (sendBroadcast){
if(sendBroadcast instanceof Function){
this.sendBroadcast=sendBroadcast;}
};
Gadget.prototype.broadcastReceiver=NULL_FUNCTION;
Gadget.prototype.getGadgetData=function (){
var ret=null;
if(this.readProductDataFunc instanceof Function)
ret=this.readProductDataFunc();
if(ret===null||ret===undefined)
return "";
return ret;};
Gadget.prototype._getTitle=function (){
if(!isString(this._product_id))return "";
if(!this._info_plist){
var exist=apps_nvram_file.apps_exist({product_id:this._product_id,filename:"Info.plist"});
if(!exist)return "";
this._info_plist=read_file(APPLI_PATH+this._product_id+"/Info.plist");}
var body=this._info_plist;
var title="";
try{
if(isString(body)){
try{
title=body.match(new RegExp("^title."+system.locale.language.substr(0,5)+"=(.*)$","m"))[1];}catch(ex_no_key){
try{
title=body.match(new RegExp("^title."+system.locale.language.substr(0,2)+"=(.*)$","m"))[1];}catch(ex_never_key){
try{
title=body.match(new RegExp("^title=(.*)$","m"))[1];}catch(ex_no_title){
console.log("[ERROR] No title in \"Info.plist\". Please check ID="+this._product_id);}
}
}
}else{
console.log("Cannot find \"Info.plist\" of ID");}
}catch(e){
console.log(e.message);}
return title;};
Gadget.prototype._checkPenSupport=function (cont){
if(!isString(this._product_id))return;
if(!this._info_plist)
this._info_plist=read_file(APPLI_PATH+this._product_id+"/Info.plist");
var body=this._info_plist;
try{
if(isString(body)){
try{
var tmp=body.match(new RegExp("^touchpen=(.*)$","m"))[1];
if(tmp=="true"){
cont._pen=new gimage({src:IMG_PATH+"touchpen_support.png",
translate:[182,-20,0],});
cont.components.push(cont._pen);}
}catch(ee){
}
}
}catch(e){
console.log(e.message);}
};
