* [RFA] iwidgets: update and add "-fraction" option
@ 2002-03-22 9:17 Keith Seitz
2002-03-22 9:31 ` Keith Seitz
2002-04-01 14:35 ` Keith Seitz
0 siblings, 2 replies; 4+ messages in thread
From: Keith Seitz @ 2002-03-22 9:17 UTC (permalink / raw)
To: Insight Maling List
Hi,
I really hated the way this widget worked, so I:
1) merged with current sources (formatting changes, really)
2) Added a sanity check in iwidgets::Feedback::step
3) Added a new "-fraction" option so that we could tell it to display
a fraction instead of just stepping it.
I will submit the "-fraction" patch to the iwidgets maintainers.
(Is Ian still around? Shall we nominate a new or more tcl/tk/tix/itcl
maintainer(s)?)
Keith
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] iwidgets: update and add "-fraction" option
2002-03-22 9:17 [RFA] iwidgets: update and add "-fraction" option Keith Seitz
@ 2002-03-22 9:31 ` Keith Seitz
2002-04-01 14:35 ` Keith Seitz
1 sibling, 0 replies; 4+ messages in thread
From: Keith Seitz @ 2002-03-22 9:31 UTC (permalink / raw)
To: Insight Maling List
On Fri, 22 Mar 2002, Keith Seitz wrote:
> I really hated the way this widget worked, so I:
>
> 1) merged with current sources (formatting changes, really)
> 2) Added a sanity check in iwidgets::Feedback::step
> 3) Added a new "-fraction" option so that we could tell it to display
> a fraction instead of just stepping it.
>
> I will submit the "-fraction" patch to the iwidgets maintainers.
>
> (Is Ian still around? Shall we nominate a new or more tcl/tk/tix/itcl
> maintainer(s)?)
Hmmm. I'll bet someone wants to see the patch! :-)
ChangeLog
2002-03-22 Keith Seitz <keiths@redhat.com>
* iwidgets3.0.0/generic/feedback.itk: Import version 1.5.
(iwidgets::Feedback): Define new option, "-fraction".
(fraction): New configbody.
(step): Cap the step increment at the total number of
requested steps.
Patch
Index: itcl/iwidgets3.0.0/generic/feedback.itk
===================================================================
RCS file: /cvs/src/src/itcl/iwidgets3.0.0/generic/feedback.itk,v
retrieving revision 1.1.1.2
diff -p -r1.1.1.2 feedback.itk
*** itcl/iwidgets3.0.0/generic/feedback.itk 2001/09/09 19:49:08 1.1.1.2
--- itcl/iwidgets3.0.0/generic/feedback.itk 2002/03/22 17:14:55
***************
*** 9,15 ****
# ----------------------------------------------------------------------
# AUTHOR: Kris Raney EMAIL: kraney@spd.dsccc.com
#
! # @(#) $Id: feedback.itk,v 1.2.172.1 2001/05/18 02:21:48 mdejong Exp $
# ----------------------------------------------------------------------
# Copyright (c) 1996 DSC Technologies Corporation
# ======================================================================
--- 9,15 ----
# ----------------------------------------------------------------------
# AUTHOR: Kris Raney EMAIL: kraney@spd.dsccc.com
#
! # @(#) $Id: feedback.itk,v 1.5 2001/08/15 18:32:18 smithc Exp $
# ----------------------------------------------------------------------
# Copyright (c) 1996 DSC Technologies Corporation
# ======================================================================
*************** itk::usual Feedback {
*** 78,90 ****
# ------------------------------------------------------------------
# FEEDBACK
# ------------------------------------------------------------------
! class iwidgets::Feedback {
inherit iwidgets::Labeledwidget
constructor {args} {}
destructor {}
itk_option define -steps steps Steps 10
public {
method reset {}
--- 78,91 ----
# ------------------------------------------------------------------
# FEEDBACK
# ------------------------------------------------------------------
! itcl::class iwidgets::Feedback {
inherit iwidgets::Labeledwidget
constructor {args} {}
destructor {}
itk_option define -steps steps Steps 10
+ itk_option define -fraction fraction Fraction 0
public {
method reset {}
*************** itcl::configbody iwidgets::Feedback::ste
*** 163,168 ****
--- 164,186 ----
}
# ------------------------------------------------------------------
+ # OPTION: -fraction
+ #
+ # Configure the widget to display the given fractional completion
+ # ------------------------------------------------------------------
+ itcl::configbody iwidgets::Feedback::fraction {
+
+ set newval [expr {ceil($itk_option(-steps) * $itk_option(-fraction))}]
+ if {$newval > $itk_option(-steps)} {
+ set newval $itk_option(-steps)
+ }
+ if {$newval != $_stepval} {
+ set _stepval $newval
+ _display
+ }
+ }
+
+ # ------------------------------------------------------------------
# METHODS
# ------------------------------------------------------------------
*************** itcl::configbody iwidgets::Feedback::ste
*** 175,187 ****
itcl::body iwidgets::Feedback::_display {} {
update idletasks
set troughwidth [winfo width $itk_component(trough)]
! set _barwidth [expr \
! (1.0*$troughwidth-(2.0*[$itk_component(trough) cget -borderwidth])) / \
! $itk_option(-steps)]
! set fraction [expr int((1.0*$_stepval)/$itk_option(-steps)*100.0)]
$itk_component(percentage) config -text "$fraction%"
! $itk_component(bar) config -width [expr $_barwidth*$_stepval]
update
}
--- 193,205 ----
itcl::body iwidgets::Feedback::_display {} {
update idletasks
set troughwidth [winfo width $itk_component(trough)]
! set _barwidth [expr {
! (1.0*$troughwidth-(2.0*[$itk_component(trough) cget -borderwidth])) /
! $itk_option(-steps)}]
! set fraction [expr {int((1.0*$_stepval)/$itk_option(-steps)*100.0)}]
$itk_component(percentage) config -text "$fraction%"
! $itk_component(bar) config -width [expr {$_barwidth*$_stepval}]
update
}
*************** itcl::body iwidgets::Feedback::step {{in
*** 208,212 ****
--- 226,233 ----
}
incr _stepval $inc
+ if {$_stepval > $itk_option(-steps)} {
+ set _stepval $itk_option(-steps)
+ }
_display
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] iwidgets: update and add "-fraction" option
2002-03-22 9:17 [RFA] iwidgets: update and add "-fraction" option Keith Seitz
2002-03-22 9:31 ` Keith Seitz
@ 2002-04-01 14:35 ` Keith Seitz
2002-04-01 14:37 ` Keith Seitz
1 sibling, 1 reply; 4+ messages in thread
From: Keith Seitz @ 2002-04-01 14:35 UTC (permalink / raw)
To: Insight Maling List
Since I haven't received any word from Ian or any comments from anyone
else, I will just assume responsibility for everything that Insight uses.
Call me uebermaintainer. Now accepting applications for maintainers.
Keith
On Fri, 22 Mar 2002, Keith Seitz wrote:
> I really hated the way this widget worked, so I:
>
> 1) merged with current sources (formatting changes, really)
> 2) Added a sanity check in iwidgets::Feedback::step
> 3) Added a new "-fraction" option so that we could tell it to display
> a fraction instead of just stepping it.
>
> I will submit the "-fraction" patch to the iwidgets maintainers.
>
> (Is Ian still around? Shall we nominate a new or more tcl/tk/tix/itcl
> maintainer(s)?)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] iwidgets: update and add "-fraction" option
2002-04-01 14:35 ` Keith Seitz
@ 2002-04-01 14:37 ` Keith Seitz
0 siblings, 0 replies; 4+ messages in thread
From: Keith Seitz @ 2002-04-01 14:37 UTC (permalink / raw)
To: Insight Maling List
On Mon, 1 Apr 2002, Keith Seitz wrote:
> On Fri, 22 Mar 2002, Keith Seitz wrote:
>
> > I really hated the way this widget worked, so I:
> >
> > 1) merged with current sources (formatting changes, really)
> > 2) Added a sanity check in iwidgets::Feedback::step
> > 3) Added a new "-fraction" option so that we could tell it to display
> > a fraction instead of just stepping it.
I've committed this change.
ChangeLog
2002-04-01 Keith Seitz <keiths@redhat.com>
* iwidgets3.0.0/generic/feedback.itk: Import version 1.5.
(iwidgets::Feedback): Define new option, "-fraction".
(fraction): New configbody.
(step): Cap the step increment at the total number of
requested steps.
Patch
Index: iwidgets3.0.0/generic/feedback.itk
===================================================================
RCS file: /cvs/src/src/itcl/iwidgets3.0.0/generic/feedback.itk,v
retrieving revision 1.1
retrieving revision 1.2
diff -p -r1.1 -r1.2
*** iwidgets3.0.0/generic/feedback.itk 2000/02/07 00:19:46 1.1
--- iwidgets3.0.0/generic/feedback.itk 2002/04/01 22:36:16 1.2
***************
*** 9,15 ****
# ----------------------------------------------------------------------
# AUTHOR: Kris Raney EMAIL: kraney@spd.dsccc.com
#
! # @(#) $Id: feedback.itk,v 1.2 1999/01/27 18:56:33 jingham Exp $
# ----------------------------------------------------------------------
# Copyright (c) 1996 DSC Technologies Corporation
# ======================================================================
--- 9,15 ----
# ----------------------------------------------------------------------
# AUTHOR: Kris Raney EMAIL: kraney@spd.dsccc.com
#
! # @(#) $Id: feedback.itk,v 1.5 2001/08/15 18:32:18 smithc Exp $
# ----------------------------------------------------------------------
# Copyright (c) 1996 DSC Technologies Corporation
# ======================================================================
*************** itk::usual Feedback {
*** 78,90 ****
# ------------------------------------------------------------------
# FEEDBACK
# ------------------------------------------------------------------
! class iwidgets::Feedback {
inherit iwidgets::Labeledwidget
constructor {args} {}
destructor {}
itk_option define -steps steps Steps 10
public {
method reset {}
--- 78,91 ----
# ------------------------------------------------------------------
# FEEDBACK
# ------------------------------------------------------------------
! itcl::class iwidgets::Feedback {
inherit iwidgets::Labeledwidget
constructor {args} {}
destructor {}
itk_option define -steps steps Steps 10
+ itk_option define -fraction fraction Fraction 0
public {
method reset {}
*************** proc ::iwidgets::feedback {pathName args
*** 109,115 ****
# ------------------------------------------------------------------
# CONSTRUCTOR
# ------------------------------------------------------------------
! body iwidgets::Feedback::constructor {args} {
itk_component add trough {
frame $itk_interior.trough -relief sunken
} {
--- 110,116 ----
# ------------------------------------------------------------------
# CONSTRUCTOR
# ------------------------------------------------------------------
! itcl::body iwidgets::Feedback::constructor {args} {
itk_component add trough {
frame $itk_interior.trough -relief sunken
} {
*************** body iwidgets::Feedback::constructor {ar
*** 138,150 ****
grid rowconfigure $itk_interior 1 -weight 1
grid columnconfigure $itk_interior 0 -weight 1
eval itk_initialize $args
}
# ------------------------------------------------------------------
# DESTRUCTOR
# ------------------------------------------------------------------
! body iwidgets::Feedback::destructor {} {
}
# ------------------------------------------------------------------
--- 139,153 ----
grid rowconfigure $itk_interior 1 -weight 1
grid columnconfigure $itk_interior 0 -weight 1
+ bind $itk_component(hull) <Configure> [itcl::code $this _display]
+
eval itk_initialize $args
}
# ------------------------------------------------------------------
# DESTRUCTOR
# ------------------------------------------------------------------
! itcl::body iwidgets::Feedback::destructor {} {
}
# ------------------------------------------------------------------
*************** body iwidgets::Feedback::destructor {} {
*** 156,166 ****
#
# Set the total number of steps.
# ------------------------------------------------------------------
! configbody iwidgets::Feedback::steps {
step 0
}
# ------------------------------------------------------------------
# METHODS
# ------------------------------------------------------------------
--- 159,186 ----
#
# Set the total number of steps.
# ------------------------------------------------------------------
! itcl::configbody iwidgets::Feedback::steps {
step 0
}
# ------------------------------------------------------------------
+ # OPTION: -fraction
+ #
+ # Configure the widget to display the given fractional completion
+ # ------------------------------------------------------------------
+ itcl::configbody iwidgets::Feedback::fraction {
+
+ set newval [expr {ceil($itk_option(-steps) * $itk_option(-fraction))}]
+ if {$newval > $itk_option(-steps)} {
+ set newval $itk_option(-steps)
+ }
+ if {$newval != $_stepval} {
+ set _stepval $newval
+ _display
+ }
+ }
+
+ # ------------------------------------------------------------------
# METHODS
# ------------------------------------------------------------------
*************** configbody iwidgets::Feedback::steps {
*** 170,182 ****
# Displays the bar in the trough with the width set using the current number
# of steps.
# -----------------------------------------------------------------------------
! body iwidgets::Feedback::_display {} {
set troughwidth [winfo width $itk_component(trough)]
! set _barwidth [expr $troughwidth.0/$itk_option(-steps)]
! set fraction [expr int((1.0*$_stepval)/$itk_option(-steps)*100.0)]
$itk_component(percentage) config -text "$fraction%"
! $itk_component(bar) config -width [expr $_barwidth*$_stepval]
update
}
--- 190,205 ----
# Displays the bar in the trough with the width set using the current number
# of steps.
# -----------------------------------------------------------------------------
! itcl::body iwidgets::Feedback::_display {} {
! update idletasks
set troughwidth [winfo width $itk_component(trough)]
! set _barwidth [expr {
! (1.0*$troughwidth-(2.0*[$itk_component(trough) cget -borderwidth])) /
! $itk_option(-steps)}]
! set fraction [expr {int((1.0*$_stepval)/$itk_option(-steps)*100.0)}]
$itk_component(percentage) config -text "$fraction%"
! $itk_component(bar) config -width [expr {$_barwidth*$_stepval}]
update
}
*************** body iwidgets::Feedback::_display {} {
*** 186,192 ****
#
# Resets the status bar to 0
# ------------------------------------------------------------------
! body iwidgets::Feedback::reset {} {
set _stepval 0
_display
}
--- 209,215 ----
#
# Resets the status bar to 0
# ------------------------------------------------------------------
! itcl::body iwidgets::Feedback::reset {} {
set _stepval 0
_display
}
*************** body iwidgets::Feedback::reset {} {
*** 196,207 ****
#
# Increase the value of the status bar by inc. Default to 1
# ------------------------------------------------------------------
! body iwidgets::Feedback::step {{inc 1}} {
if {$_stepval >= $itk_option(-steps)} {
return
}
incr _stepval $inc
_display
}
--- 219,233 ----
#
# Increase the value of the status bar by inc. Default to 1
# ------------------------------------------------------------------
! itcl::body iwidgets::Feedback::step {{inc 1}} {
if {$_stepval >= $itk_option(-steps)} {
return
}
incr _stepval $inc
+ if {$_stepval > $itk_option(-steps)} {
+ set _stepval $itk_option(-steps)
+ }
_display
}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-04-01 22:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-22 9:17 [RFA] iwidgets: update and add "-fraction" option Keith Seitz
2002-03-22 9:31 ` Keith Seitz
2002-04-01 14:35 ` Keith Seitz
2002-04-01 14:37 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).