/*----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Fever Framework code. The Initial Developer of the Original Code is Romain Ecarnot. Portions created by Initial Developer are Copyright (C) 2006 the Initial Developer. All Rights Reserved. Contributor(s): Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------*/ import org.aswing.Icon; import com.bourre.events.EventBroadcaster; import com.bourre.events.EventType; import fvaswing.components.alert.FvAlertButton; import fvaswing.components.alert.FvAlertEvent; import fvaswing.components.alert.FvAlertType; import fvaswing.components.alert.FvAlertView; /** * Alert dialog box. * *
The Alert control is modal, which means it will retain * focus until the user closes it. * *
Is connected to Fever Localisation API * * {@code * public function test() : Void * { * var alert : FvAlert = new FvAlert( FvAlertType.OK_ONLY ); * alert.message = "Delete this file"; * alert.title = "Caution"; * alert.addListener( this, _onResult ); * alert.enabledBlurEffect = true; * alert.open( ); * } * * private function _onResult( event : FvAlertEvent ) : Void * { * if( event.getButton() == FvAlert.BUTTON_YES ) * { * //do something * } * } * * } * * @see fvaswing.components.alert.FvAlertType * @see fvaswing.components.alert.FvAlertButton * * @author Romain Ecarnot */ class fvaswing.components.FvAlert extends FvAlertView { //------------------------------------------------------------------------- // Events definition //------------------------------------------------------------------------- /** Event type braodcasted when alert is closed. */ public static var onAlertClosedEvent : EventType = new EventType( 'onAlertClosed' ); //------------------------------------------------------------------------- // Private properties //------------------------------------------------------------------------- private var _oEB : EventBroadcaster; private var _alertType : FvAlertType; private var _defaultFlag : FvAlertButton; private var _logicalFlag : FvAlertButton; private var _alertMessage : String; private var _alertTitle : String; private var _icon : Icon; private var _enabledBlur : Boolean; private var _opened : Boolean; //------------------------------------------------------------------------- // Public Properties //------------------------------------------------------------------------- /** Height of each Alert button, in pixels. */ public static var buttonHeight : Number = 22; /** Width of each Alert button, in pixels. */ public static var buttonWidth : Number = 70; /** * Defines which buttons are displayed in next alert open. * *
Possible values are : *
If no valid flag is passed, use * {@link fvaswing.components.alert.FvAlertType#OK_ONLY}. */ public function get alertType() : FvAlertType { return _alertType; } public function set alertType( type : FvAlertType ) : Void { _alertType = type; } /** * Specify the default button ( button which have the focus when alert open ) * *
Possible values are : *
The buttons label are automatically update */ public function open() : Void { if( _opened ) return; FvAlertView.getInstance()._openDialog( this, _alertType, _alertTitle, _alertMessage, _defaultFlag, _icon, _enabledBlur ); _opened = true; } /** * Closes the alert window. * *
When user click on 'close button', the {@link #ON_ALERT_CLOSED} event * is dispatched with {@link #BUTTON_CANCEL} id. */ public function close() : Void { _dispatchResult( FvAlertButton.CANCEL ); _closeDialog(); } /** * Forces the dialog to be closed. */ public function fireClose( button : FvAlertButton ) : Void { _dispatchResult( button ); } //------------------------------------------------------------------------- // Private implementation //------------------------------------------------------------------------- private function _dispatchResult( id : FvAlertButton ) : Void { _opened = false; _oEB.broadcastEvent( new FvAlertEvent( onAlertClosedEvent, this, id ) ); } }