# jalert.tcl - notification panel
#
######################################################################
# Copyright 1992-1999 by Jay Sekora.  This file may be freely        #
# distributed, modified or unmodified, for any purpose, provided     #
# that this copyright notice is retained verbatim in all copies and  #
# no attempt is made to obscure the authorship of this file.  If you #
# distribute any modified versions, I ask, but do not require, that  #
# you clearly mark any changes you make as such and that you provide #
# your users with instructions for getting the original sources.     #
######################################################################

package provide aq 0.1

# following has side-effect of making sure ::aq namespace is defined
namespace eval ::aq {
  namespace export {[a-z]*}
  catch {
    package require jldb
    # following likely to fail, because done by other libraries too
    namespace import ::jldb::shortcuts::*
  }
}

######################################################################
# ::aq::alert ?options? - alert box
# options include
#   -title (default "Alert")
#   -text (default "Alert!" - not really optional)
######################################################################

proc ::aq::alert { args } {
  ::aq::parse_args {
    {title "Alert"}
    {text "Alert!"}
  }
  set w [::aq::new_toplevel .alert]
  
  set old_focus [focus]			;# so we can restore original focus
  
  wm title $w $title
  wm transient $w .
  
  message $w.msg -width 300 -anchor w -text $text
  ::aq::buttonbar $w.b -default ok \
    -buttons [format {{ok OK {destroy {%s}}}} $w]
  
  pack $w.msg -side top -fill both -expand yes -padx 10 -pady 10
  pack [::aq::rule $w -width 200] -side top -fill x
  pack $w.b -side bottom -fill both
  
  ::aq::dialogue $w		;# position in centre of screen
  
  ::aq::default_button $w.b.ok $w
  update

  grab $w
  focus $w
  tkwait window $w
  focus -force $old_focus		;# can't figure out a better way...
}
