summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Nasser <fnasser@redhat.com>2001-02-01 04:54:11 +0000
committerFernando Nasser <fnasser@redhat.com>2001-02-01 04:54:11 +0000
commitaee134396fac69631a2457af75004c306fcc2c8c (patch)
tree4352236a1ccc7d1a621df77897a50b404a9eac57
parent313978a0bb6635f8e4e48218fc327484f1164e27 (diff)
downloadgdb-aee134396fac69631a2457af75004c306fcc2c8c.tar.gz
2001-01-31 Fernando Nasser <fnasser@redhat.com>
* library/pluginwin.itcl: New file. Implements the PluginWindow class that provides some basic functionality for plug-ins. * library/plugins/rhabout/rhabout.itcl: Inherit from the new PluginWindow class. Remove code dependent on ModalDlg. (constructor): Creates menus and a toolbar to show how these PluginWindow components are used.
-rw-r--r--gdb/gdbtk/ChangeLog9
-rw-r--r--gdb/gdbtk/library/plugins/rhabout/rhabout.itcl41
-rw-r--r--gdb/gdbtk/library/pluginwin.itcl187
3 files changed, 231 insertions, 6 deletions
diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog
index 89f7d66e0d1..25b87711072 100644
--- a/gdb/gdbtk/ChangeLog
+++ b/gdb/gdbtk/ChangeLog
@@ -1,5 +1,14 @@
2001-01-31 Fernando Nasser <fnasser@redhat.com>
+ * library/pluginwin.itcl: New file. Implements the PluginWindow
+ class that provides some basic functionality for plug-ins.
+ * library/plugins/rhabout/rhabout.itcl: Inherit from the new
+ PluginWindow class. Remove code dependent on ModalDlg.
+ (constructor): Creates menus and a toolbar to show how these
+ PluginWindow components are used.
+
+2001-01-31 Fernando Nasser <fnasser@redhat.com>
+
* library/plugins/rhabout.tcl: Add load for optional sample C command
procedure.
* library/plugins/rhabout/rhabout.itcl (constructor): Try calling
diff --git a/gdb/gdbtk/library/plugins/rhabout/rhabout.itcl b/gdb/gdbtk/library/plugins/rhabout/rhabout.itcl
index 96e9adce341..e96fd54fc1b 100644
--- a/gdb/gdbtk/library/plugins/rhabout/rhabout.itcl
+++ b/gdb/gdbtk/library/plugins/rhabout/rhabout.itcl
@@ -1,8 +1,39 @@
class RHAbout {
- inherit ManagedWin ModalDialog
+# inherit PluginWindow ModalDialog
+ inherit PluginWindow
constructor {args} {
global gdb_ImageDir
- set f [frame $itk_interior.f]
+
+ # What about a menu?
+ $menubar menubar_new_menu file "File" 0
+ $menubar menubar_add_menu_command None "Close" \
+ [code $this destroy_toplevel] \
+ -underline 1
+ $menubar menubar_new_menu help "Help" 0
+ $menubar menubar_add_menu_command Other "Help Topics" \
+ {HtmlViewer::open_help index.html} \
+ -underline 0
+ $menubar menubar_add_menu_separator
+ $menubar menubar_add_menu_command Other "About GDB..." \
+ {ManagedWin::open About -transient} \
+ -underline 0
+
+ # The menu only shows up if you do this:
+ $menubar menubar_show
+
+ # Do you want a toolbar?
+ $toolbar toolbar_add_button con Other {ManagedWin::open Console} \
+ "Console (Ctrl+N)" -image console_img
+
+ # The toolbar will only show up if you do this:
+ $toolbar toolbar_show
+
+ # Now, fill the childsite with some graphics and text
+
+ # Remember to use the childsite, do not pack in the widget hull
+ set f [childsite]
+
+ # Put in some graphics
label $f.image1 -bg white -image \
[image create photo -file [file join $gdb_ImageDir insight.gif]]
@@ -13,11 +44,9 @@ class RHAbout {
catch {append text [rhabout_extra_text]}
message $f.m -bg white -fg black -text $text -aspect 500 -relief flat
- pack $f.image1 $f.m $itk_interior.f -fill both -expand yes
+ pack $f.image1 $f.m -fill both -expand yes
pack $itk_interior
- bind $f.image1 <1> [code $this unpost]
- bind $f.m <1> [code $this unpost]
- window_name "About Cygnus Insight"
+ window_name "About Red Hat Insight"
}
# Don't quit if this is the last window. The only way that this can
diff --git a/gdb/gdbtk/library/pluginwin.itcl b/gdb/gdbtk/library/pluginwin.itcl
new file mode 100644
index 00000000000..18574be7367
--- /dev/null
+++ b/gdb/gdbtk/library/pluginwin.itcl
@@ -0,0 +1,187 @@
+# PluginWindow
+# Copyright 2001 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License (GPL) as published by
+# the Free Software Foundation; either version 2 of the License, or (at
+# your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# ----------------------------------------------------------------------
+# Implements a menu and a toolbar that are attached to a source window.
+#
+# PUBLIC ATTRIBUTES:
+#
+#
+# METHODS:
+#
+# configure ....... used to change public attributes
+#
+# PRIVATE METHODS
+#
+# X11 OPTION DATABASE ATTRIBUTES
+#
+#
+# ----------------------------------------------------------------------
+
+class PluginWindow {
+ inherit ManagedWin
+
+ # ------------------------------------------------------------------
+ # CONSTRUCTOR - create widget
+ # ------------------------------------------------------------------
+ constructor {args} {
+
+ # Create a menu widget for the plug-in window
+ set menubar [GDBMenuBar $itk_interior.menubar]
+
+ # Create a toolbar widget for the plug-in window
+ set toolbar [GDBToolBar $itk_interior.toolbar]
+
+ # Pack the toolbar
+ pack $toolbar -expand 1 -fill both
+
+ # Create a frame for the subclass to use
+ set child [frame $itk_interior.child]
+
+ # Pack the childsite
+ pack $child -expand 1 -fill both
+
+ eval itk_initialize $args
+ add_hook gdb_idle_hook "$this stopped"
+ add_hook gdb_busy_hook "$this running"
+ add_hook gdb_no_inferior_hook "$this no_inferior"
+ }
+
+ # ------------------------------------------------------------------
+ # DESTRUCTOR - destroy window containing widget
+ # ------------------------------------------------------------------
+ destructor {
+ remove_hook gdb_idle_hook "$this stopped"
+ remove_hook gdb_busy_hook "$this running"
+ remove_hook gdb_no_inferior_hook "$this no_inferior"
+
+ #destroy $this
+ }
+
+ # ------------------------------------------------------------------
+ # ACCESSOR METHOD - Retrieve childsite
+ # ------------------------------------------------------------------
+ method childsite {} {
+ return $child
+ }
+
+ ####################################################################
+ #
+ # State control methods used by both the menu and the toolbar
+ #
+ ####################################################################
+
+ # ------------------------------------------------------------------
+ # METHOD: stopped
+ # Invoked when there is an inferior and it has stopped
+ # ------------------------------------------------------------------
+ method stopped {} {
+ debug
+ enable_ui 1
+ }
+
+ # ------------------------------------------------------------------
+ # METHOD: running
+ # Invoked when gdb is going to run the inferior
+ # ------------------------------------------------------------------
+ method running {} {
+ debug
+ enable_ui 0
+ }
+
+ # ------------------------------------------------------------------
+ # METHOD: no_inferior
+ # Invoked when gdb detects the inferior is gone
+ # ------------------------------------------------------------------
+ method no_inferior {} {
+ debug
+ enable_ui 2
+ }
+
+ ####################################################################
+ # The following method enables/disables both menus and buttons.
+ ####################################################################
+
+ # ------------------------------------------------------------------
+ # METHOD: enable_ui - enable/disable the appropriate buttons and menus
+ # Called from the busy, idle, and no_inferior hooks.
+ #
+ # on must be:
+ # value Control Other State
+ # 0 off off gdb is busy
+ # 1 on on gdb has inferior, and is idle
+ # 2 off on gdb has no inferior, and is idle
+ # ------------------------------------------------------------------
+ public method enable_ui {on} {
+ global tcl_platform
+ debug "$on"
+
+ # Do the enabling so that all the disabling happens first, this way if a
+ # button belongs to two groups, enabling takes precedence, which is
+ # probably right.
+
+ switch $on {
+ 0 {
+ # Busy
+ set enable_list {Control disabled \
+ Other disabled}
+ }
+ 1 {
+ # Idle, with inferior
+ set enable_list {Control normal \
+ Other normal}
+ }
+ 2 {
+ # Idle, no inferior
+ set enable_list {Control disabled \
+ Other normal}
+ }
+ default {
+ debug "Unknown type: $on in enable_ui"
+ return
+ }
+ }
+
+ $menubar set_class_state $enable_list
+ $toolbar set_class_state $enable_list
+ }
+
+ ####################################################################
+ #
+ # PRIVATE DATA
+ #
+ ####################################################################
+
+ # The childsite
+ private variable child
+
+ ####################################################################
+ #
+ # PROTECTED DATA
+ #
+ ####################################################################
+
+ # The GdbMenuBar component
+ protected variable menubar
+
+ # The GdbToolBar component
+ protected variable toolbar
+
+ ####################################################################
+ #
+ # PUBLIC DATA
+ #
+ ####################################################################
+
+ # None.
+}