File: lifolbl.tcl

package info (click to toggle)
moomps 4.6-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,444 kB
  • ctags: 2,307
  • sloc: tcl: 34,882; sh: 167; makefile: 91
file content (57 lines) | stat: -rw-r--r-- 2,180 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# copyright (C) 1997-2005 Jean-Luc Fontaine (mailto:jfontain@free.fr)
# this program is free software: please read the COPYRIGHT file enclosed in this package or use the Help Copyright menu

# $Id: lifolbl.tcl,v 2.16 2005/01/02 00:45:07 jfontain Exp $


# last-in-first-out label generally used at the bottom of an application window for messages display

class lifoLabel {}

proc lifoLabel::lifoLabel {this parentPath args} composite {[new scrollingLabel $parentPath] $args} {
    set ($this,lifo) [new lifo]
    composite::complete $this
}

proc lifoLabel::~lifoLabel {this} {
    delete $($this,lifo)
}

proc lifoLabel::options {this} {                                                              ;# force initialization of all options
    return [list\
        [list -borderwidth $widget::option(button,borderwidth)]\
        [list -font {helvetica -12}]\
        [list -relief sunken]\
    ]
}

proc lifoLabel::set-relief {this value} {
    composite::configure $composite::($this,base) base -relief $value
}

proc lifoLabel::set-borderwidth {this value} {
    composite::configure $composite::($this,base) base -borderwidth $value
}

proc lifoLabel::set-font {this value} {
    composite::configure $composite::($this,base) -font $value
}

proc lifoLabel::push {this string} {                                                          ;# user procedure for pushing a string
    if {[string length [set current [composite::cget $composite::($this,base) -text]]] > 0} {
        xifo::in $($this,lifo) $current                                                ;# store current string in stack if non empty
    }
    composite::configure $composite::($this,base) -text $string
}

proc lifoLabel::pop {this} {                                                                  ;# user procedure for popping a string
    set string {}
    catch {set string [lifo::out $($this,lifo)]}
    composite::configure $composite::($this,base) -text $string
    return $string
}

proc lifoLabel::flash {this string {seconds 1}} {                                            ;# user procedure for flashing a string
    after [expr {1000 * $seconds}] lifoLabel::pop $this
    push $this $string
}