GDB (API)
/home/stan/gdb/src/gdb/gdbtk/library/warning.tcl
Go to the documentation of this file.
00001 # Warning dialog for GDBtk.
00002 # Copyright (C) 1998, 1999 Cygnus Solutions
00003 #
00004 # This program is free software; you can redistribute it and/or modify it
00005 # under the terms of the GNU General Public License (GPL) as published by
00006 # the Free Software Foundation; either version 2 of the License, or (at
00007 # your option) any later version.
00008 #
00009 # This program is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 # GNU General Public License for more details.
00013 
00014 
00015 # -----------------------------------------------------------------------------
00016 # NAME:
00017 #       class WarningDlg
00018 #
00019 # DESC:
00020 #       This class implements a warning dialog.  It has an optional checkbox
00021 #       that the user can select to disable all warnings of the same type.
00022 #
00023 # ARGS:
00024 # -ignorable "class"      - Causes an ignorable dialog to be created.
00025 #                         "class" is the warning class that will be either
00026 #                         displayed or ignored.  It may be any string, so
00027 #                         long as the same string is used for all related
00028 #                         warning messages.
00029 #
00030 # -message "msg"          - Message to be displayed.
00031 # -----------------------------------------------------------------------------
00032 #
00033 
00034 itcl::class WarningDlg {
00035   inherit ManagedWin ModalDialog
00036 
00037   public {
00038     variable ignorable ""
00039     variable message ""
00040     method constructor {args}{}
00041   }
00042 
00043   protected common ignore
00044 }
00045  
00046 # -----------------------------------------------------------------------------
00047 # NAME: 
00048 #       WarningDlg::constructor
00049 #
00050 # DESC: 
00051 #       Creates the warning dialog.
00052 # -----------------------------------------------------------------------------
00053 itcl::body WarningDlg::constructor {args} {
00054   debug $args
00055   window_name "Warning"
00056   eval itk_initialize $args
00057 
00058   if {$ignorable == ""} {
00059     tk_messageBox -message $message -type ok -icon warning -default ok \
00060       -parent [winfo toplevel $itk_interior]
00061     delete
00062     return
00063   } else {
00064     if {[info exists ignore($ignorable)]} {
00065       if {$ignore($ignorable)} { 
00066   delete
00067   return 
00068       }
00069     } else {
00070       set ignore($ignorable) 0
00071     }
00072   }
00073   
00074   frame $itk_interior.f
00075   frame $itk_interior.f.a -relief raised -bd 1
00076   frame $itk_interior.f.b -relief raised -bd 1
00077   set f $itk_interior.f.a
00078   
00079  
00080   label $f.bitmap -bitmap warning
00081   label $f.lab -text $message
00082   pack $f.bitmap $f.lab -side left -padx 10 -pady 10
00083 
00084   if {$ignorable != ""} {
00085     checkbutton $itk_interior.f.b.ignore -text "Don't show this warning again" \
00086       -variable [scope ignore($ignorable)] -anchor w 
00087   }
00088   
00089   button $itk_interior.f.b.ok -text OK -underline 0 -command [code $this unpost]
00090   bind $itk_interior.f.b.ok <Return> \
00091     "$itk_interior.f.b.ok flash; $itk_interior.f.b.ok invoke"
00092   focus $itk_interior.f.b.ok
00093 
00094   if {$ignorable != ""} {
00095     pack $itk_interior.f.b.ignore
00096   }
00097 
00098   pack $itk_interior.f.b.ok -expand yes -side left 
00099   pack $itk_interior.f.a 
00100   pack $itk_interior.f.b  -fill x
00101   pack $itk_interior.f
00102 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines