wuench
01-21-2009, 01:08 PM
I decided I needed a little more feedback in my setup. Here is a dialog box I created for my system. It can be used for confirmations or just user notifications and is fully customizable by setting global variables before showing it. So with this I basically have one template that I can reuse throughout my whole setup for notifications, confirmations, and feedback and they will all have a consistent look and feel. Some examples of where I am using it are for playlist add/delete/clear confirmation, movie selection confirmation, etc.
Modes of Operation
Timer - By setting a timer value, the dialog will dismiss itself automatically. The new version uses the SetTimeout command. So you can now have a dialog that timesout as well as responds to command buttons. A timeout will return Timeout in the global variable GVar:Dlg_Result. Also, when the timer is set an animated throbber cursor will appear in the upper right corner.
Button - In this mode you can display 1 or 2 buttons with customizable text/values. When one is clicked the value will be returned in a Global Variable.
Template Click - You can also allow the dialog to be dismissed by clicking on the template itself. This can be enabled along with the 2 buttons above and a value will be returned.
Default Behavior - If you do not set a display time or any buttons, the dialog will automatically display a default Ok button.Global Variables Used
The following global variables are used to control the dialog's behavior. These are automatically deleted by the dialog after they are used, so you will need to set these everytime you invoke the dialog. The only one that isn't deleted is Dlg_Result.
GVar:Dlg_Message - This will be the text message displayed in the dialog.
GVar:Dlg_Title - This will set the dialog's title
GVar:Dlg_Image - This is a path to an icon to be displayed by the dialog (32x32).
GVar:Dlg_Button1Val - This the the text for button 1, if set the button will be displayed (unless DisplayTime is set). This will also be the result returned if Button 1 is clicked to close the dialog.
GVar:Dlg_Button2Val - This the the text for button 2, if set the button will be displayed (unless DisplayTime is set). This will also be the result returned if Button 2 is clicked to close the dialog.
GVar:Dlg_ButtonMainVal - If set the overlay button will be displayed (unless DisplayTime is set). This will also be the result returned if the user clicks anywhere in the dialog to close it.
GVar:Dlg_DisplayTime - This is the time to display the dialog in milliseconds before it auto-dismisses. If set, an animation will be displayed.
GVar:Dlg_Result - This is the result returned by the dialog. If a button is clicked it will be the button's value, otherwise it will be blank (for Timed Mode).Example Images
Ok/Cancel Dialog
http://www.wuench.com/cmine/albums/userpics/Dialog_Box.png
Yes/No Dialog
http://www.wuench.com/cmine/albums/userpics/Dialog_YesNo.png
Timed/Notification Dialog
http://www.wuench.com/cmine/albums/userpics/Timed_Dialog.png
With Buttons
--------------------------------------------------------------------------------
This code will display a dialog with the message "Are you sure you want to clear the
playlist?" and an OK and Cancel button. If the user clicks OK the playlist is cleared if
the user clicks Cancel, the dialog is dismissed and no action is taken.
--------------------------------------------------------------------------------
GlobalVars::SetVariable(GVar:Dlg_Title, Confirm Clear)
GlobalVars::SetVariable(GVar:Dlg_Button1Val, OK)
GlobalVars::SetVariable(GVar:Dlg_Button2Val, Cancel)
GlobalVars::SetVariable(GVar:Dlg_Message, Are you sure you want to clear the playlist?)
GlobalVars::SetVariable(GVar:Dlg_Image, /User/Hardware/Small Icons/Speaker Music)
IntfViewer::InvokePopup(BlueGlass-Pop_Dialog, 255, -1 -1)
If GlobalVars::Exists(GVar:Dlg_Result)
If System::Equals(%(GVar:Dlg_Result), OK)
Devices::FieldWrite(AudioPlayer.ClearPlaylist, True)
End
End
Timed / Auto Close
--------------------------------------------------------------------------------
This code will display a notification dialog with the message "You have a new email
message!" for 2.5 seconds and then the dialog will dismiss itself.
--------------------------------------------------------------------------------
GlobalVars::SetVariable(GVar:Dlg_Title, Email Notification)
GlobalVars::SetVariable(GVar:Dlg_Message, You have a new email message!)
GlobalVars::SetVariable(GVar:Dlg_Image, \User\Hardware\Small Icons\Document)
GlobalVars::SetVariable(GVar:Dlg_DisplayTime, 2500)
IntfViewer::InvokePopup(BlueGlass-Pop_Dialog, 255, -1 -1)
Templates
Here are the templates for the dialog and a template to test the features. These require 2.4.32+.
Modes of Operation
Timer - By setting a timer value, the dialog will dismiss itself automatically. The new version uses the SetTimeout command. So you can now have a dialog that timesout as well as responds to command buttons. A timeout will return Timeout in the global variable GVar:Dlg_Result. Also, when the timer is set an animated throbber cursor will appear in the upper right corner.
Button - In this mode you can display 1 or 2 buttons with customizable text/values. When one is clicked the value will be returned in a Global Variable.
Template Click - You can also allow the dialog to be dismissed by clicking on the template itself. This can be enabled along with the 2 buttons above and a value will be returned.
Default Behavior - If you do not set a display time or any buttons, the dialog will automatically display a default Ok button.Global Variables Used
The following global variables are used to control the dialog's behavior. These are automatically deleted by the dialog after they are used, so you will need to set these everytime you invoke the dialog. The only one that isn't deleted is Dlg_Result.
GVar:Dlg_Message - This will be the text message displayed in the dialog.
GVar:Dlg_Title - This will set the dialog's title
GVar:Dlg_Image - This is a path to an icon to be displayed by the dialog (32x32).
GVar:Dlg_Button1Val - This the the text for button 1, if set the button will be displayed (unless DisplayTime is set). This will also be the result returned if Button 1 is clicked to close the dialog.
GVar:Dlg_Button2Val - This the the text for button 2, if set the button will be displayed (unless DisplayTime is set). This will also be the result returned if Button 2 is clicked to close the dialog.
GVar:Dlg_ButtonMainVal - If set the overlay button will be displayed (unless DisplayTime is set). This will also be the result returned if the user clicks anywhere in the dialog to close it.
GVar:Dlg_DisplayTime - This is the time to display the dialog in milliseconds before it auto-dismisses. If set, an animation will be displayed.
GVar:Dlg_Result - This is the result returned by the dialog. If a button is clicked it will be the button's value, otherwise it will be blank (for Timed Mode).Example Images
Ok/Cancel Dialog
http://www.wuench.com/cmine/albums/userpics/Dialog_Box.png
Yes/No Dialog
http://www.wuench.com/cmine/albums/userpics/Dialog_YesNo.png
Timed/Notification Dialog
http://www.wuench.com/cmine/albums/userpics/Timed_Dialog.png
With Buttons
--------------------------------------------------------------------------------
This code will display a dialog with the message "Are you sure you want to clear the
playlist?" and an OK and Cancel button. If the user clicks OK the playlist is cleared if
the user clicks Cancel, the dialog is dismissed and no action is taken.
--------------------------------------------------------------------------------
GlobalVars::SetVariable(GVar:Dlg_Title, Confirm Clear)
GlobalVars::SetVariable(GVar:Dlg_Button1Val, OK)
GlobalVars::SetVariable(GVar:Dlg_Button2Val, Cancel)
GlobalVars::SetVariable(GVar:Dlg_Message, Are you sure you want to clear the playlist?)
GlobalVars::SetVariable(GVar:Dlg_Image, /User/Hardware/Small Icons/Speaker Music)
IntfViewer::InvokePopup(BlueGlass-Pop_Dialog, 255, -1 -1)
If GlobalVars::Exists(GVar:Dlg_Result)
If System::Equals(%(GVar:Dlg_Result), OK)
Devices::FieldWrite(AudioPlayer.ClearPlaylist, True)
End
End
Timed / Auto Close
--------------------------------------------------------------------------------
This code will display a notification dialog with the message "You have a new email
message!" for 2.5 seconds and then the dialog will dismiss itself.
--------------------------------------------------------------------------------
GlobalVars::SetVariable(GVar:Dlg_Title, Email Notification)
GlobalVars::SetVariable(GVar:Dlg_Message, You have a new email message!)
GlobalVars::SetVariable(GVar:Dlg_Image, \User\Hardware\Small Icons\Document)
GlobalVars::SetVariable(GVar:Dlg_DisplayTime, 2500)
IntfViewer::InvokePopup(BlueGlass-Pop_Dialog, 255, -1 -1)
Templates
Here are the templates for the dialog and a template to test the features. These require 2.4.32+.