From e72243280ad8cf9506a58271cec0b30138cbff93 Mon Sep 17 00:00:00 2001 From: fnasser Date: Thu, 1 Feb 2001 04:54:11 +0000 Subject: [PATCH] 2001-01-31 Fernando Nasser * 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. --- gdb/gdbtk/ChangeLog | 9 ++ gdb/gdbtk/library/plugins/rhabout/rhabout.itcl | 41 +++++- gdb/gdbtk/library/pluginwin.itcl | 187 +++++++++++++++++++++++++ 3 files changed, 231 insertions(+), 6 deletions(-) create mode 100644 gdb/gdbtk/library/pluginwin.itcl diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog index 89f7d66e0d..25b8771107 100644 --- a/gdb/gdbtk/ChangeLog +++ b/gdb/gdbtk/ChangeLog @@ -1,5 +1,14 @@ 2001-01-31 Fernando Nasser + * 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 + * 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 96e9adce34..e96fd54fc1 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 0000000000..18574be736 --- /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. +} -- 2.11.0