OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [gdbtk/] [library/] [warning.tcl] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Warning dialog for GDBtk.
2
# Copyright 1998, 1999 Cygnus Solutions
3
#
4
# This program is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License (GPL) as published by
6
# the Free Software Foundation; either version 2 of the License, or (at
7
# your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
 
14
 
15
# -----------------------------------------------------------------------------
16
# NAME:
17
#       class WarningDlg
18
#
19
# DESC:
20
#       This class implements a warning dialog.  It has an optional checkbox
21
#       that the user can select to disable all warnings of the same type.
22
#
23
# ARGS:
24
#       -ignorable "class"      - Causes an ignorable dialog to be created.
25
#                               "class" is the warning class that will be either
26
#                               displayed or ignored.  It may be any string, so
27
#                               long as the same string is used for all related
28
#                               warning messages.
29
#
30
#       -message "msg"          - Message to be displayed.
31
# -----------------------------------------------------------------------------
32
#
33
 
34
class WarningDlg {
35
  inherit ManagedWin ModalDialog
36
 
37
  public {
38
    variable ignorable ""
39
    variable message ""
40
    method constructor {args}
41
  }
42
 
43
  protected common ignore
44
}
45
 
46
# -----------------------------------------------------------------------------
47
# NAME: 
48
#       WarningDlg::constructor
49
#
50
# DESC: 
51
#       Creates the warning dialog.
52
# -----------------------------------------------------------------------------
53
body WarningDlg::constructor {args} {
54
  debug $args
55
  window_name "Warning"
56
  eval itk_initialize $args
57
 
58
  if {$ignorable == ""} {
59
    tk_messageBox -message $message -type ok -icon warning -default ok \
60
      -parent [winfo toplevel $itk_interior]
61
    delete
62
    return
63
  } else {
64
    if {[info exists ignore($ignorable)]} {
65
      if {$ignore($ignorable)} {
66
        delete
67
        return
68
      }
69
    } else {
70
      set ignore($ignorable) 0
71
    }
72
  }
73
 
74
  frame $itk_interior.f
75
  frame $itk_interior.f.a -relief raised -bd 1
76
  frame $itk_interior.f.b -relief raised -bd 1
77
  set f $itk_interior.f.a
78
 
79
 
80
  label $f.bitmap -bitmap warning
81
  label $f.lab -text $message
82
  pack $f.bitmap $f.lab -side left -padx 10 -pady 10
83
 
84
  if {$ignorable != ""} {
85
    checkbutton $itk_interior.f.b.ignore -text "Don't show this warning again" \
86
      -variable [scope ignore($ignorable)] -anchor w
87
  }
88
 
89
  button $itk_interior.f.b.ok -text OK -underline 0 -command [code $this unpost]
90
  bind $itk_interior.f.b.ok <Return> \
91
    "$itk_interior.f.b.ok flash; $itk_interior.f.b.ok invoke"
92
  focus $itk_interior.f.b.ok
93
 
94
  if {$ignorable != ""} {
95
    pack $itk_interior.f.b.ignore
96
  }
97
 
98
  pack $itk_interior.f.b.ok -expand yes -side left
99
  pack $itk_interior.f.a
100
  pack $itk_interior.f.b  -fill x
101
  pack $itk_interior.f
102
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.