function LockPasswordPanel(action_func,cancel_func,focus_moveto){
this.superClass=container;
this.superClass({
components:[
this.background=new gbox({width:1920+1,height:1080+1,
color:[0,0,0,0],}),
this.frame=new actor({
base_col:[COL_POP_BORDER,COL_POP_BORDER],
base_col_width:2,
bg_image:[
this.bg_c=new gbox({color:COL_POP_A}),
]}),
this.message=new gtextbox({visible_p:false,align:LC_TEXT_ALIGN,
color:COL_TEXT_ONBASE,}),
this.title=new gtext({font_size:36,font_name:"F015T-bold",
color:COL_TEXT_SUB_ONBASE,
visible_p:false,align:LC_TEXT_ALIGN,}),
this.pass_back=new gbox({width:280,height:60,color:COL_BTN,
translate:[0,-60,0],}),
this.input_cursor=new gbox({translate:[0,-60,0],
width:46,height:56,color:COL_POINT_ONBASE}),
this.pass_dammy=new gtext({width:280,height:60,
color:COL_TEXT_ONBASE,translate:[0,-60-4,0],text:"  *  *  *  *",
font_size:54}),
]
});
this.input_cursor.setText=function(str){
var len=(str||"").length;
if(len>3*3)len=3*3;
this.translate[0]=len*58/3-97;};
this.input_cursor.setText("");
this.visible_p=false;
this.focus_moveto=focus_moveto;
this.cursor=0;
if(typeof action_func=="function")this.doAction=action_func;
if(typeof cancel_func=="function")this.cancelAction=cancel_func;
this.setSize(this.width,this.height);};
LockPasswordPanel.prototype=new container({});
LockPasswordPanel.prototype.IMG_PATH=IMG_PATH;
LockPasswordPanel.prototype.passwd=[];LockPasswordPanel.prototype.tmp_passwd=null;LockPasswordPanel.prototype.key_block=false;
LockPasswordPanel.prototype.width=940;LockPasswordPanel.prototype.height=400;
LockPasswordPanel.prototype.cursor=null;LockPasswordPanel.prototype.focus_moveto=function(){console.log("No function to move focus.");};

LockPasswordPanel.prototype.LOCK_MODE_ALWAYS=0;LockPasswordPanel.prototype.LOCK_MODE_PRESET=1;
LockPasswordPanel.prototype.free=function(){
setf_text(this.message,"");
setf_text(this.title,"");
setf_text(this.pass_dammy,"")
this.input_cursor.setText("");
this.components.splice(0,this.components.length);};
LockPasswordPanel.prototype.setTitle=function(s){
this.title_text=s;
setf_text(this.title,s);
this.title.visible_p=true;};
LockPasswordPanel.prototype.setdoAction=function(action_func){
if(typeof action_func=="function")this.doAction=action_func;};
LockPasswordPanel.prototype.setMessageText=function(s){
this.message_text=s;
setf_text(this.message,s);
this.message.visible_p=true;};
LockPasswordPanel.prototype.setShow=function(b,mode){
this.tmp_passwd=null;
this.passwd=[];
this.mode=this.LOCK_MODE_ALWAYS;
if(mode)this.mode=mode;
if(b){
var pin=system.apps.read_lock_pin();
if((pin==-1)&&(this.mode==this.LOCK_MODE_PRESET)){
this.doAction(false);
return false;}
useNumKey(true);
this.setTitle(LANG("LT_CHILD_LOCK_PIN_ENTRY"));
if(pin!=-1){
this.setMessageText(LANG("LT_PLS_ENTER_PIN_FOR_ACCESS"));}else{
this.setMessageText(LANG("LT_PLS_ENTER_NEW_PIN"));}
this.visible_p=true;
this._showBackground(true);}else{
this.input_cursor.setText("");
useNumKey(false);
this.visible_p=false;
delete_timer(this);
this.background.color[3]=0;}
force_redraw();
return true;};
LockPasswordPanel.prototype.isShow=function(b){
return this.visible_p;};
LockPasswordPanel.prototype.setTranslate=function(x,y,z){
this.translate[0]=x;
this.translate[1]=y;
this.translate[2]=z;};
LockPasswordPanel.prototype.setTranslate_bg=function(x,y,z){
this.background.translate[0]=x;
this.background.translate[1]=y;
this.background.translate[2]=z;};
LockPasswordPanel.prototype.setSize=function(w,h){
w=Math.floor(w);
h=Math.floor(h);
this.width=w;
this.height=h;
this.bg_c.width=w-28;
this.bg_c.height=h-28;
this.title.width=this.width-120;
this.title.translate[1]=this.height/2-60;
if(this.title_text){
setf_text(this.title,this.title_text);}
this.message.width=this.width-120;
this.message.height=(this.title.translate[1]-20);
this.message.translate[1]=(this.title.translate[1]-30)-this.message.height/2;
if(this.message_text){
setf_text(this.message,this.message_text);}
};
LockPasswordPanel.prototype.onFocus=function(b,keysym){
if(b==true){
this.correctFocus();}else{
return true;}
};
LockPasswordPanel.prototype.pass_error=function(is_0000){
this.tmp_passwd=null
this.passwd=[];
this.setMessageText(
LANG("LT_PIN_INCORRECT")+"\n"
+(is_0000?LANG("LT_PIN_INVALID")+"\n":"")
+LANG("LT_PLS_START_AGAIN")
);
this.input_cursor.setText("");};
LockPasswordPanel.prototype.pass_again=function(){
this.passwd=[];
this.setMessageText(
LANG("LT_PLS_ENTER_NEW_PIN_CONFIRM")
);
this.input_cursor.setText("");};
LockPasswordPanel.prototype.key_hook=function(updown,keysym){
if(updown!=KEY_PRESS)return false;
if(this.key_block==true)return true;
var ret=true;
switch(keysym){
case TXK_D1:this.passwd.push("1");break;
case TXK_D2:this.passwd.push("2");break;
case TXK_D3:this.passwd.push("3");break;
case TXK_D4:this.passwd.push("4");break;
case TXK_D5:this.passwd.push("5");break;
case TXK_D6:this.passwd.push("6");break;
case TXK_D7:this.passwd.push("7");break;
case TXK_D8:this.passwd.push("8");break;
case TXK_D9:this.passwd.push("9");break;
case TXK_D0:this.passwd.push("0");break;
case TXK_UP:
case TXK_DOWN:
case TXK_LEFT:
case TXK_RIGHT:
return false;

case TXK_ENTER:
return true;
case TXK_RETURN:
if(this.cancelAction){
this.tmp_passwd=null
this.passwd.length=0;
this.passwd=[];
this.cancelAction();
ret=true;}else{
ret=false;}
break;
default:
ret=false;}
var t="";
if(this.passwd.length==1&&system.apps.read_lock_pin()!=-1){
this.setMessageText(LANG("LT_PLS_ENTER_PIN_FOR_ACCESS"));}else if(this.passwd.length>4){
this.pass_error();}
for(var i=0;i<this.passwd.length;i++){
t+="  *";}
this.input_cursor.setText(t);
force_redraw();

if(this.passwd.length==4){
var pin=system.apps.read_lock_pin();var pass=parseInt(this.passwd.join(""),10);
if(pin==pass){
this.key_block=true;
append_timer(this,500,function(obj){
delete_timer(obj);
obj.key_block=false;
obj.passwd=[];
obj.doAction();});
ret=true;}else if(pin==-1){
console.log("NO Password. (invalid_0000 = "+
system.mdl_cfg.invalid_pin_0000+")");
if(this.tmp_passwd==null){
if(pass==0&&system.mdl_cfg.invalid_pin_0000==true){
this.pass_error(true);}else{
this.tmp_passwd=pass;
this.pass_again();}
}else{
if(this.tmp_passwd==pass){
system.apps.write_lock_pin(pass);
this.key_block=true;
append_timer(this,500,function(obj){
delete_timer(obj);
obj.key_block=false;
obj.passwd=[];
obj.doAction();});
ret=true;}else{
this.pass_error();}
}
}else{
this.pass_error();}
}

return ret;};
LockPasswordPanel.prototype.correctFocus=function(){
var position=[this.translate[0]+this.pass_back.translate[0],
this.translate[1]+this.pass_back.translate[1],
this.translate[2]+this.pass_back.translate[2]];
this.focus_moveto(position,[this.pass_back.width,this.pass_back.height],
0,30,null);};
LockPasswordPanel.prototype._showBackground=function(bool){
var da=12;
var max_count=10;
if(bool==true){
if(SU_IS_SLOW_ANIM){
this.background.color[3]=127;
force_redraw();
return;}
append_timer(this,60,function (obj,count){
if(count>max_count){
delete_timer(obj);
this.background.color[3]=127;}else {
this.background.color[3]+=da;}
force_redraw();});}else {
if(SU_IS_SLOW_ANIM){
this.background.color[3]=0;
force_redraw();
return;}
append_timer(this,60,function (obj,count){
if(count>max_count){
delete_timer(obj);
this.background.color[3]=0;}else {
if(this.background.color[3]>da)this.background.color[3]-=da;}
force_redraw();});}
}
provide("pkg_password");
