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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
# =============================================================================
#
# File: Frame.tcl
# Project: TkDesk
#
# Started: 04.11.98
# Changed: 04.11.98
# Author: cb
#
# Description: Implements a generic Frame class which instantiates
# a Tk frame widget to be used be subclasses implementing
# megawidgets.
#
# Copyright (C) 1998 Christian Bolik
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# See the file "COPYING" in the base directory of this distribution
# for more.
#
# =============================================================================
# -----------------------------------------------------------------------------
# class Frame
# Instantiates a Tk frame widget. Subclasses can access this widget
# through protected variable frame. An external interface is provided
# via the getFrame method.
#
itcl_class Frame {
constructor {args} {
#puts "Frame $this"
#puts "class [::$this info class]"
eval configure $args
if {[info tclversion] >= 8.0} {
set frame [::frame [namespace tail $this]-frame \
-class [namespace tail [$this info class]]]
} else {
set frame [::frame [string trimleft $this-frame ":"] \
-class [::$this info class]]
}
#puts "frame: $frame"
}
destructor {
catch {destroy $frame}
}
# ----- Methods and Procs -------------------------------------------------
method config {args} {
eval configure $args
}
method cget {var} {
return [set [string trimleft $var -]]
}
method getFrame {} {
return $frame
}
# ----- Class Variables --------------------------------------------------
protected variable frame ""
public variable bd {} {
config -borderwidth $bd
}
public variable borderwidth {} {
if [winfo exists $frame] {
$frame config -bd $borderwidth
}
}
public variable bg {} {
config -background $bg
}
public variable background {} {
if [winfo exists $frame] {
$frame config -bg $background
}
}
public variable relief {} {
if [winfo exists $frame] {
$frame config -relief $relief
}
}
}
|