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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [gdbtcl/] [modal.tcl] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Modal dialog class 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
# Implements the post and unpost behavior of a Modal Dialog.
17
#
18
# For now the point behind this is to control calling 
19
# ide_grab_support.  If you call disable all the windows of an
20
# application but one, destroy that window, THEN re-enable the
21
# windows, Windows brings the last enabled window in the last
22
# active application to the foreground (Doh!).
23
#
24
# ----------------------------------------------------------------------
25
 
26
class ModalDialog {
27
  # This is the variable we vwait on when the dialog is posted.  
28
  # It is set to 1 in the unpost method, and to -1 in the destructor.
29
 
30
  private variable unpost_notification 0
31
 
32
  destructor {
33
    debug "  UNPOST $this"
34
    set unpost_notification -1
35
  }
36
 
37
  # ------------------------------------------------------------------
38
  #  METHOD:  unpost - unposts the dialog box...
39
  # ------------------------------------------------------------------
40
  public method unpost {} {
41
    after idle [list set [scope unpost_notification] 1]
42
  }
43
 
44
  # ------------------------------------------------------------------
45
  #  METHOD:  cancel - This just unposts the dialog box...
46
  #           If you want to programatically cancel a dialog
47
  #           selection, for instance if the app is going away
48
  #           use this rather than unpost.  That way a sub-class
49
  #           that actually has to do some work can override it.
50
  # ------------------------------------------------------------------
51
  public method cancel {} {
52
    ModalDialog::unpost
53
  }
54
 
55
 
56
  # ------------------------------------------------------------------
57
  #  METHOD:  post - posts the dialog box...
58
  # ------------------------------------------------------------------
59
  public method post {{on_top 0} {expire 0}} {
60
 
61
    debug "POST $this"
62
    set top [winfo toplevel [namespace tail $this]]
63
    wm protocol $top WM_DELETE_WINDOW [code $this cancel]
64
 
65
    if {$on_top} {
66
      after 500 keep_raised $top
67
    }
68
 
69
    ide_grab_support disable_except $top
70
    focus $top
71
    grab set $top
72
 
73
    if {$expire > 0} {
74
      set afterID [after $expire [code $this cancel]]
75
    }
76
 
77
    vwait [scope unpost_notification]
78
 
79
    if {$afterID != ""} {
80
      after cancel $afterID
81
      set afterID ""
82
    }
83
 
84
    grab release $top
85
 
86
    # Enable all the windows in the application BEFORE
87
    # you destroy this one, or Windows will bring another
88
    # app to the foreground.
89
 
90
    ide_grab_support enable_all
91
 
92
    # We can get here either by someone calling unpost (if an OK button
93
    # is clicked or whatever), or by someone destroying the dialog (for
94
    # instance by using the Window Manager.)  Only delete the object if
95
    # we are not already in the process of doing this.
96
 
97
    if {$unpost_notification == 1} {
98
      ::delete object $this
99
    }
100
  }
101
 
102
  public variable expire -1 ;# If this is set to a number > 0, the
103
                             # dialog will time out after this interval.
104
  private variable afterID ""; # The id for the expiration after event.
105
}

powered by: WebSVN 2.1.0

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