#include <pjsr/StdButton.jsh>
#include <pjsr/StdIcon.jsh>
function FooBarDialog()
{
this.__base__ = Dialog;
this.__base__();
this.info_Label = new Label( this );
this.info_Label.text = "This is a FooBar dialog.";
//
this.ok_Button = new PushButton( this );
this.ok_Button.text = "OK";
this.ok_Button.icon = this.scaledResource( ":/icons/ok.png" );
this.ok_Button.onClick = function()
{
this.dialog.ok();
};
this.cancel_Button = new PushButton( this );
this.cancel_Button.text = "Cancel";
this.cancel_Button.icon = this.scaledResource( ":/icons/cancel.png" );
this.cancel_Button.onClick = function()
{
this.dialog.cancel();
};
this.buttons_Sizer = new HorizontalSizer;
this.buttons_Sizer.spacing = 8;
this.buttons_Sizer.addStretch();
this.buttons_Sizer.add( this.ok_Button );
this.buttons_Sizer.add( this.cancel_Button );
//
this.sizer = new VerticalSizer;
this.sizer.margin = 8;
this.sizer.spacing = 8;
this.sizer.add( this.info_Label );
this.sizer.addSpacing( 8 );
this.sizer.add( this.buttons_Sizer );
this.windowTitle = "FooBar";
this.adjustToContents();
this.setFixedSize();
/*
* Event received when the dialog window is closed.
* Returns true if the dialog can be closed; false to ignore the event.
*/
this.onClose = function()
{
return (new MessageBox( "Do you really want to exit FooBar?",
"FooBar Dialog", StdIcon_Question, StdButton_No, StdButton_Yes )).execute() == StdButton_Yes;
};
}
FooBarDialog.prototype = new Dialog;
function main()
{
console.show();
console.writeln( "The FooBar dialog returned: ", (new FooBarDialog).execute() );
}
main();