1 | # ---------------------------------------------------------------------- |
---|
2 | # COMPONENT: image - represents a picture image |
---|
3 | # |
---|
4 | # This object represents a Tk image. It is convenient to have it |
---|
5 | # expressed as an Itcl object, so it can be managed just like a |
---|
6 | # curve, table, etc. |
---|
7 | # ====================================================================== |
---|
8 | # AUTHOR: Michael McLennan, Purdue University |
---|
9 | # Copyright (c) 2004-2005 Purdue Research Foundation |
---|
10 | # |
---|
11 | # See the file "license.terms" for information on usage and |
---|
12 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | # ====================================================================== |
---|
14 | package require Itcl |
---|
15 | package require BLT |
---|
16 | |
---|
17 | namespace eval Rappture { # forward declaration } |
---|
18 | |
---|
19 | itcl::class Rappture::Image { |
---|
20 | constructor {xmlobj path} { # defined below } |
---|
21 | destructor { # defined below } |
---|
22 | |
---|
23 | public method tkimage {} { return $_image } |
---|
24 | public method hints {{keyword ""}} |
---|
25 | |
---|
26 | private variable _xmlobj "" ;# ref to lib obj with curve data |
---|
27 | private variable _image "" ;# underlying image data |
---|
28 | } |
---|
29 | |
---|
30 | # ---------------------------------------------------------------------- |
---|
31 | # CONSTRUCTOR |
---|
32 | # ---------------------------------------------------------------------- |
---|
33 | itcl::body Rappture::Image::constructor {xmlobj path} { |
---|
34 | if {![Rappture::library isvalid $xmlobj]} { |
---|
35 | error "bad value \"$xmlobj\": should be LibraryObj" |
---|
36 | } |
---|
37 | set _xmlobj $xmlobj |
---|
38 | set data [string trim [$xmlobj get $path.current]] |
---|
39 | if {[string length $data] == 0} { |
---|
40 | set _image [image create photo] |
---|
41 | } else { |
---|
42 | set _image [image create photo -data $data] |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | # ---------------------------------------------------------------------- |
---|
47 | # DESTRUCTOR |
---|
48 | # ---------------------------------------------------------------------- |
---|
49 | itcl::body Rappture::Image::destructor {} { |
---|
50 | image delete $_image |
---|
51 | } |
---|
52 | |
---|
53 | # ---------------------------------------------------------------------- |
---|
54 | # USAGE: hints ?<keyword>? |
---|
55 | # |
---|
56 | # Returns a list of key/value pairs for various hints about showing |
---|
57 | # this image. If a particular <keyword> is specified, then it returns |
---|
58 | # the hint for that <keyword>, if it exists. |
---|
59 | # ---------------------------------------------------------------------- |
---|
60 | itcl::body Rappture::Image::hints {{keyword ""}} { |
---|
61 | return "" |
---|
62 | } |
---|