OSDN Git Service

* dll_init.cc (dll_global_dtors): Add an additional test to avoid walking the
[pf3gnuchains/pf3gnuchains4x.git] / gdb / gdbtk / library / pluginwin.itcl
1 # PluginWindow
2 # Copyright (C) 2001, 2008 Red Hat, Inc.
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 # Implements a menu and a toolbar that are attached to a source window.
16 #
17 #   PUBLIC ATTRIBUTES:
18 #
19 #
20 #   METHODS:
21 #
22 #     configure ....... used to change public attributes
23 #
24 #   PRIVATE METHODS
25 #
26 #   X11 OPTION DATABASE ATTRIBUTES
27 #
28 #
29 # ----------------------------------------------------------------------
30
31 itcl::class PluginWindow {
32   inherit ManagedWin GDBEventHandler
33
34   # ------------------------------------------------------------------
35   #  CONSTRUCTOR - create widget
36   # ------------------------------------------------------------------
37   constructor {args} {
38
39     # Create a menu widget for the plug-in window
40     set menubar [GDBMenuBar $itk_interior.menubar]
41
42     # Create a toolbar widget for the plug-in window
43     set toolbar [GDBToolBar $itk_interior.toolbar]
44
45     # Pack the toolbar
46     pack $toolbar -expand 1 -fill both
47
48     # Create a frame for the subclass to use
49     set child [frame $itk_interior.child]
50
51     # Pack the childsite
52     pack $child -expand 1 -fill both
53
54     eval itk_initialize $args
55     add_hook gdb_no_inferior_hook [code $this no_inferior]
56   }
57
58   # ------------------------------------------------------------------
59   #  DESTRUCTOR - destroy window containing widget
60   # ------------------------------------------------------------------
61   destructor {
62     remove_hook gdb_no_inferior_hook [code $this no_inferior]
63
64     #destroy $this
65   }
66
67   # ------------------------------------------------------------------
68   #  ACCESSOR METHOD - Retrieve childsite
69   # ------------------------------------------------------------------
70   public method childsite {} {
71     return $child
72   }
73
74   # Don't automatically reload plugins.
75   protected method _ignore_on_save {} { return 1 }
76
77   ####################################################################
78   #
79   # State control methods used by both the menu and the toolbar
80   # 
81   ####################################################################
82
83   # ------------------------------------------------------------------
84   #  METHOD:  idle - handle IdleEvent
85   # ------------------------------------------------------------------
86   protected method idle {event} {
87     debug "PluginWindow::idle"
88     enable_ui 1
89   }
90
91   # ------------------------------------------------------------------
92   #  METHOD:  busy - BusyEvent handler
93   #             Invoked when gdb is going to run the inferior
94   # ------------------------------------------------------------------
95   public method busy {event} {
96     debug "PluginWindow::busy"
97     enable_ui 0
98   }
99
100   # ------------------------------------------------------------------
101   #  METHOD:  no_inferior
102   #             Invoked when gdb detects the inferior is gone 
103   # ------------------------------------------------------------------
104   protected method no_inferior {} {
105     debug 
106     enable_ui 2
107   }
108
109   ####################################################################
110   # The following method enables/disables both menus and buttons.
111   ####################################################################
112
113   # ------------------------------------------------------------------
114   # METHOD:  enable_ui - enable/disable the appropriate buttons and menus
115   # Called from the busy, idle, and no_inferior hooks.
116   #
117   # on must be:
118   # value      Control    Other     State
119   #   0          off       off      gdb is busy
120   #   1          on        on       gdb has inferior, and is idle
121   #   2          off       on       gdb has no inferior, and is idle
122   # ------------------------------------------------------------------
123   public method enable_ui {on} {
124     debug "$on"
125
126     # Do the enabling so that all the disabling happens first, this way if a
127     # button belongs to two groups, enabling takes precedence, which is
128     #  probably right.
129
130     switch $on {
131       0 {
132         # Busy
133         set enable_list {Control disabled \
134                            Other disabled}
135       }
136       1 {
137         # Idle, with inferior
138         set enable_list {Control normal \
139                            Other normal}
140       }
141       2 {
142         # Idle, no inferior
143         set enable_list {Control disabled \
144                            Other normal}
145       }
146       default {
147         debug "Unknown type: $on in enable_ui"
148         return
149       }
150     }
151
152     $menubar set_class_state $enable_list
153     $toolbar set_class_state $enable_list
154   }
155
156   ####################################################################
157   #
158   #  PRIVATE DATA
159   #
160   ####################################################################
161
162   # The childsite
163   private variable child
164
165   ####################################################################
166   #
167   #  PROTECTED DATA
168   #
169   ####################################################################
170
171   # The GdbMenuBar component
172   protected variable menubar
173
174   # The GdbToolBar component
175   protected variable toolbar
176
177   ####################################################################
178   #
179   #  PUBLIC DATA
180   #
181   ####################################################################
182
183   # None.
184 }