This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
[RFA] library/managedwin.it{h,b} cleanup #1
- To: Insight Maling List <insight at sources dot redhat dot com>
- Subject: [RFA] library/managedwin.it{h,b} cleanup #1
- From: Keith Seitz <keiths at cygnus dot com>
- Date: Wed, 28 Feb 2001 19:13:31 -0800 (PST)
Hi,
I am cleaning a little house on these files: updating copyrights,
"masssaging" for readability, adding comments, removing dead code, etc.
These changes are strictly non-functional changes which affect only these
two files. Changes to be made to ManagedWin which affect other files to
follow.
Comments? (Yes, I have begun a Tcl programming style guide for Insight...)
Keith
ChangeLog:
2001-02-28 Keith Seitz <keiths@cygnus.com>
* library/managedwin.ith: Move all implementations into
managedwin.itb.
(public variable nosize): Delete.
(freeze_me, thaw_me, make_icon_window): Prepend with
underscore to remind people these are not public
methods/procs.
(protected variable Top, screenwidth, screenheight): Ditto
for these variables.
(protected common manage_active, mainwindow): Delete.
(enable): Delete.
(reconfig): Add empty body.
* library/managedwin.itb: Move all implementations from
header here.
Update all references to renamed variables/methods/procs.
(destructor, restart, shutdown, _open, find) Let
Itcl tell us which ManagedWins we have lying around.
(enable): Delete.
(reconfig): It's empty. Moved empty body to header.
Patch:
Index: managedwin.ith
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/managedwin.ith,v
retrieving revision 1.2
diff -p -p -r1.2 managedwin.ith
*** managedwin.ith 2000/03/28 01:59:40 1.2
--- managedwin.ith 2001/03/01 03:11:16
***************
*** 1,5 ****
# Managed window class definition for GDBtk.
! # Copyright 1998, 1999 Cygnus Solutions
#
# 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
--- 1,5 ----
# Managed window class definition for GDBtk.
! # Copyright 1998, 1999, 2000, 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
*************** class ManagedWin {
*** 16,31 ****
inherit itk::Widget
public {
! method reconfig {}
method destroy_toplevel {}
method quit_if_last {} {return 1}
- method enable {on}
method pickle {}
method reveal {}
method window_name {wname {iname ""}}
- variable nosize 0
-
proc find {win}
proc open {args}
proc open_dlg {class args}
--- 16,31 ----
inherit itk::Widget
public {
! method constructor {args}
! method destructor {}
!
! method reconfig {} {}
method destroy_toplevel {}
method quit_if_last {} {return 1}
method pickle {}
method reveal {}
method window_name {wname {iname ""}}
proc find {win}
proc open {args}
proc open_dlg {class args}
*************** class ManagedWin {
*** 35,105 ****
proc shutdown {}
}
- protected {
- proc dont_remember_size {} {
- return 0
- }
- method freeze_me {}
- method thaw_me {}
-
- variable Top
- }
-
- private {
- proc _create {class args}
- proc _open {class args}
- proc make_icon_window {name {file "gdbtk_icon"}}
- }
-
protected {
! # manage_active - list of active window objects
! common manage_active ""
# this is the counter of TopLevelWins open
# when it hits 0, exit.
common numTopWins 0
! common screenwidth
! common screenheight
! common mainwindow
! }
!
! constructor {args} {
! debug "$this args=$args"
! lappend manage_active $this
! set Top [winfo toplevel $itk_interior]
!
! }
! destructor {
! set infoList [after info]
!
! # remove object from list
! set i [lsearch -exact $manage_active $this]
! if {$i != -1} {
! set manage_active [lreplace $manage_active $i $i]
! }
!
! # save geometry
! set g [wm geometry [winfo toplevel [namespace tail $this]]]
! pref setd gdb/geometry/[namespace tail $this] $g
!
! # If no toplevels remain, quit. However, check the quit_if_last
! # flag since we might be doing something like displaying a
! # splash screen at startup...
!
! if {!$numTopWins && [quit_if_last]} {
! # save window positions of remaining windows
! foreach obj $manage_active {
! set g [wm geometry [winfo toplevel [namespace tail $obj]]]
! pref setd gdb/geometry/[namespace tail $obj] $g
! }
! pref_save
! gdb_force_quit
! } else {
! destroy_toplevel
! }
! }
}
--- 35,60 ----
proc shutdown {}
}
protected {
! # The Tk's toplevel window for this ManagedWin
! variable _top
# this is the counter of TopLevelWins open
# when it hits 0, exit.
common numTopWins 0
! common _screenwidth
! common _screenheight
! method _freeze_me {}
! method _thaw_me {}
! proc dont_remember_size {} { return 0 }
! }
+ private {
+ proc _create {class args}
+ proc _open {class args}
+ proc _make_icon_window {name {file "gdbtk_icon"}}
+ }
}
Index: managedwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/managedwin.itb,v
retrieving revision 1.9
diff -p -p -r1.9 managedwin.itb
*** managedwin.itb 2001/01/04 17:55:48 1.9
--- managedwin.itb 2001/03/01 03:11:27
***************
*** 1,5 ****
# Managed window for GDBtk.
! # Copyright 1998, 1999 Cygnus Solutions
#
# 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
--- 1,5 ----
# Managed window for GDBtk.
! # Copyright 1998, 1999, 2000, 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
***************
*** 12,20 ****
# GNU General Public License for more details.
! body ManagedWin::reconfig {} {}
body ManagedWin::window_name {wname {iname ""}} {
set top [winfo toplevel [namespace tail $this]]
wm title $top $wname
--- 12,55 ----
# GNU General Public License for more details.
! # ------------------------------------------------------------
! # PUBLIC METHOD: constructor
! # ------------------------------------------------------------
! body ManagedWin::constructor {args} {
! #debug "$this args=$args"
! set _top [winfo toplevel $itk_interior]
! }
+ # ------------------------------------------------------------
+ # PUBLIC METHOD: destructor
+ # ------------------------------------------------------------
+ body ManagedWin::destructor {} {
+ # save geometry
+ set g [wm geometry [winfo toplevel [namespace tail $this]]]
+ pref setd gdb/geometry/[namespace tail $this] $g
+
+ # If no toplevels remain, quit. However, check the quit_if_last
+ # flag since we might be doing something like displaying a
+ # splash screen at startup...
+
+ if {!$numTopWins && [quit_if_last]} {
+ # save window positions of remaining windows
+ foreach obj [itcl_info objects -isa ManagedWin] {
+ set g [wm geometry [winfo toplevel [namespace tail $obj]]]
+ pref setd gdb/geometry/[namespace tail $obj] $g
+ }
+ pref_save
+ gdb_force_quit
+ } else {
+ destroy_toplevel
+ }
+ }
+
+ # ------------------------------------------------------------
+ # PUBLIC METHOD: window_name - Set the name of the window
+ # (and optionally it's icon's name)
+ # ------------------------------------------------------------
body ManagedWin::window_name {wname {iname ""}} {
set top [winfo toplevel [namespace tail $this]]
wm title $top $wname
*************** body ManagedWin::window_name {wname {ina
*** 26,38 ****
}
# ------------------------------------------------------------
! # pickle - This is the base class pickle method. It returns a
! # a command that can be used to recreate this particular window.
# ------------------------------------------------------------
body ManagedWin::pickle {} {
return [list ManagedWin::open [namespace tail [info class]]]
}
body ManagedWin::reveal {} {
# Do this update to flush all changes before deiconifying the window.
update idletasks
--- 61,77 ----
}
# ------------------------------------------------------------
! # PUBLIC METHOD: pickle - This is the base class pickle
! # method. It returns a command that can be used to recreate
! # this particular window.
# ------------------------------------------------------------
body ManagedWin::pickle {} {
return [list ManagedWin::open [namespace tail [info class]]]
}
+ # ------------------------------------------------------------
+ # PUBLIC METHOD: reveal
+ # ------------------------------------------------------------
body ManagedWin::reveal {} {
# Do this update to flush all changes before deiconifying the window.
update idletasks
*************** body ManagedWin::reveal {} {
*** 48,60 ****
# This can actually be confusing to the user.
}
body ManagedWin::restart {} {
# This is needed in case we've called "gdbtk_busy" before the restart.
# This will configure the stop/run button as necessary
after idle gdbtk_idle
# call the reconfig method for each object
! foreach obj $manage_active {
if {[catch {$obj reconfig} msg]} {
dbug W "reconfig failed for $obj - $msg"
}
--- 87,102 ----
# This can actually be confusing to the user.
}
+ # ------------------------------------------------------------
+ # PUBLIC PROC: restart
+ # ------------------------------------------------------------
body ManagedWin::restart {} {
# This is needed in case we've called "gdbtk_busy" before the restart.
# This will configure the stop/run button as necessary
after idle gdbtk_idle
# call the reconfig method for each object
! foreach obj [itcl_info objects -isa ManagedWin] {
if {[catch {$obj reconfig} msg]} {
dbug W "reconfig failed for $obj - $msg"
}
*************** body ManagedWin::restart {} {
*** 62,75 ****
}
# ------------------------------------------------------------------
! # shutdown - This writes all the active windows to the preferences file,
! # so they can be restored at startup.
! # FIXME: Currently assumes only ONE window per type...
# ------------------------------------------------------------------
-
body ManagedWin::shutdown {} {
set activeWins {}
! foreach win $manage_active {
if {[$win isa ManagedWin]} {
lappend activeWins [$win pickle]
}
--- 104,116 ----
}
# ------------------------------------------------------------------
! # PUBLIC PROC: shutdown - This writes all the active windows to
! # the preferences file, so they can be restored at startup.
! # FIXME: Currently assumes only ONE window per type...
# ------------------------------------------------------------------
body ManagedWin::shutdown {} {
set activeWins {}
! foreach win [itcl_info objects -isa ManagedWin] {
if {[$win isa ManagedWin]} {
lappend activeWins [$win pickle]
}
*************** body ManagedWin::shutdown {} {
*** 78,87 ****
}
# ------------------------------------------------------------------
! # startup - This restores all the windows that were opened at shutdown.
! # FIXME: Currently assumes only ONE window per type...
# ------------------------------------------------------------------
-
body ManagedWin::startup {} {
debug "Got active list [pref get gdb/window/active]"
--- 119,128 ----
}
# ------------------------------------------------------------------
! # PUBLIC PROC: startup - This restores all the windows that were
! # opened at shutdown.
! # FIXME: Currently assumes only ONE window per type...
# ------------------------------------------------------------------
body ManagedWin::startup {} {
debug "Got active list [pref get gdb/window/active]"
*************** body ManagedWin::startup {} {
*** 100,105 ****
--- 141,149 ----
}
}
+ # ------------------------------------------------------------
+ # PUBLIC PROC: open_dlg
+ # ------------------------------------------------------------
body ManagedWin::open_dlg {class args} {
set newwin [eval _open $class $args]
*************** body ManagedWin::open_dlg {class args} {
*** 108,115 ****
$newwin post
}
}
-
body ManagedWin::open {class args} {
set newwin [eval _open $class $args]
--- 152,161 ----
$newwin post
}
}
+ # ------------------------------------------------------------
+ # PUBLIC PROC: open
+ # ------------------------------------------------------------
body ManagedWin::open {class args} {
set newwin [eval _open $class $args]
*************** body ManagedWin::open {class args} {
*** 125,130 ****
--- 171,179 ----
return $newwin
}
+ # ------------------------------------------------------------
+ # PRIVATE PROC: _open
+ # ------------------------------------------------------------
body ManagedWin::_open { class args } {
debug "$class $args"
*************** body ManagedWin::_open { class args } {
*** 132,138 ****
if {!$force} {
# check all windows for one of this type
! foreach obj $manage_active {
if {[$obj isa $class]} {
$obj reveal
return $obj
--- 181,187 ----
if {!$force} {
# check all windows for one of this type
! foreach obj [itcl_info objects -isa ManagedWin] {
if {[$obj isa $class]} {
$obj reveal
return $obj
*************** body ManagedWin::_open { class args } {
*** 144,149 ****
--- 193,201 ----
return [eval _create $class $args]
}
+ # ------------------------------------------------------------
+ # PRIVATE PROC: _create
+ # ------------------------------------------------------------
body ManagedWin::_create { class args } {
set win [string tolower $class]
*************** body ManagedWin::_create { class args }
*** 183,189 ****
return ""
}
! wm maxsize $top $screenwidth $screenheight
wm minsize $top 20 20
if {$over != ""} {
--- 235,241 ----
return ""
}
! wm maxsize $top $_screenwidth $_screenheight
wm minsize $top 20 20
if {$over != ""} {
*************** body ManagedWin::_create { class args }
*** 207,213 ****
} elseif {$::tcl_platform(platform) == "unix"} {
# Modal dialogs DONT get Icons...
if {[pref get gdb/use_icons] && ![$newwin isa ModalDialog]} {
! set icon [make_icon_window ${top}_icon]
wm iconwindow $top $icon
bind $icon <Double-1> "$newwin reveal"
}
--- 259,265 ----
} elseif {$::tcl_platform(platform) == "unix"} {
# Modal dialogs DONT get Icons...
if {[pref get gdb/use_icons] && ![$newwin isa ModalDialog]} {
! set icon [_make_icon_window ${top}_icon]
wm iconwindow $top $icon
bind $icon <Double-1> "$newwin reveal"
}
*************** body ManagedWin::_create { class args }
*** 230,239 ****
set w 0; set h 0; set x 0; set y 0
if {![catch {scan $g "%dx%d%d%d" w h x y} res]} {
if {$x < 0} {
! set x [expr $screenwidth + $x]
}
if {$y < 0} {
! set y [expr $screenheight + $y]
}
# If the window is transient, then don't reset its size, since
--- 282,291 ----
set w 0; set h 0; set x 0; set y 0
if {![catch {scan $g "%dx%d%d%d" w h x y} res]} {
if {$x < 0} {
! set x [expr $_screenwidth + $x]
}
if {$y < 0} {
! set y [expr $_screenheight + $y]
}
# If the window is transient, then don't reset its size, since
*************** body ManagedWin::_create { class args }
*** 249,255 ****
} else {
set g "${w}x${h}+${x}+${y}"
}
! if {[expr $x+50] < $screenwidth && [expr $y+20] < $screenheight} {
wm geometry $top $g
wm positionfrom $top user
}
--- 301,307 ----
} else {
set g "${w}x${h}+${x}+${y}"
}
! if {[expr $x+50] < $_screenwidth && [expr $y+20] < $_screenheight} {
wm geometry $top $g
wm positionfrom $top user
}
*************** body ManagedWin::_create { class args }
*** 262,310 ****
return $newwin
}
body ManagedWin::find { win } {
debug "$win"
set res ""
! foreach obj $manage_active {
if {[$obj isa $win]} {
lappend res $obj
}
}
return $res
}
-
- body ManagedWin::enable { on } {
- }
!
body ManagedWin::init {} {
debug
wm withdraw .
! set screenheight [winfo screenheight .]
! set screenwidth [winfo screenwidth .]
}
body ManagedWin::destroy_toplevel {} {
! after idle "update idletasks;destroy $Top"
}
! body ManagedWin::freeze_me {} {
! $Top configure -cursor watch
::update idletasks
}
! body ManagedWin::thaw_me {} {
! $Top configure -cursor {}
::update idletasks
}
# ------------------------------------------------------------------
! # make_icon_window - create a small window with an icon in
! # it for use by certain Unix window managers.
# ------------------------------------------------------------------
!
! body ManagedWin::make_icon_window {name {file "gdbtk_icon"}} {
if {![winfo exists $name]} {
toplevel $name
label $name.im -image \
--- 314,372 ----
return $newwin
}
+ # ------------------------------------------------------------
+ # PUBLIC PROC: find
+ # ------------------------------------------------------------
body ManagedWin::find { win } {
debug "$win"
set res ""
! foreach obj [itcl_info objects -isa ManagedWin] {
if {[$obj isa $win]} {
lappend res $obj
}
}
return $res
}
! # ------------------------------------------------------------
! # PUBLIC PROC: init
! # ------------------------------------------------------------
body ManagedWin::init {} {
debug
wm withdraw .
! set _screenheight [winfo screenheight .]
! set _screenwidth [winfo screenwidth .]
}
+ # ------------------------------------------------------------
+ # PUBLIC METHOD: destroy_toplevel
+ # ------------------------------------------------------------
body ManagedWin::destroy_toplevel {} {
! after idle "update idletasks;destroy $_top"
}
! # ------------------------------------------------------------
! # PRIVATE METHOD: _freeze_me
! # ------------------------------------------------------------
! body ManagedWin::_freeze_me {} {
! $_top configure -cursor watch
::update idletasks
}
! # ------------------------------------------------------------
! # PRIVATE METHOD: _thaw_me
! # ------------------------------------------------------------
! body ManagedWin::_thaw_me {} {
! $_top configure -cursor {}
::update idletasks
}
# ------------------------------------------------------------------
! # PRIVATE PROC: _make_icon_window - create a small window with an
! # icon in it for use by certain Unix window managers.
# ------------------------------------------------------------------
! body ManagedWin::_make_icon_window {name {file "gdbtk_icon"}} {
if {![winfo exists $name]} {
toplevel $name
label $name.im -image \