source: tol/tolbaseBLT/lib/renderpane/nbobjects.tcl @ 56ade3b

1941-docker-image-to-testdevel
Last change on this file since 56ade3b was 56ade3b, checked in by Jorge Pérez <josp.jorge@…>, 10 years ago

fixes #1932, se ha creado la rama trunk/tolbaseBLT copia de trunk/tolbase

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@7330 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[56ade3b]1#-----------------------------------------------------------------------
2# TITLE:
3#       nbobjects.tcl
4#
5# AUTHOR:
6#       Will Duquette
7#
8# DESCRIPTION:
9#       This module contains the parser for Notebook "objects", e.g.,
10#       things found in [!...!] markup.
11#
12#       At some point, this might allow some kind of plug-in
13#       architecture.
14#
15#-----------------------------------------------------------------------
16
17# getobj objstring
18#
19# Parses objstring and returns a list.  The first element is the valid
20# object type, or "error".  The subsequent elements depend on the
21# object type.
22
23proc getobj {objstring} {
24    # FIRST, it must be a valid list.
25    if {[catch {lindex $objstring 0} objectType]} {
26        return [list error "Invalid object: $objstring"]
27    }
28
29    # NEXT, we only have one kind of object at the moment.
30    if {$objectType != "image"} {
31        return [list error "Unrecognized object type: $objstring"]
32    }
33
34    return [ParseImageObject $objstring]
35}
36
37# ParseImageObject obj
38#
39# The first token of obj is "image".  The second is the path to the
40# image file.  The remaining elements are options and values.
41#
42# Returns a list {image path optlist}.  The list contains all
43# options allowed for images, with values.
44
45proc ParseImageObject {obj} {
46    set result [lrange $obj 0 1]
47
48    array set opts {
49        -width 0
50        -height 0
51        -padwidth 0
52        -text ""
53    }
54   
55    foreach {opt val} [lrange $obj 2 end] {
56        if {[info exists opts($opt)]} {
57            if {$opt eq "-text" ||
58                [regexp {^[0-9]+[cimp]?$} $val]} {
59                set opts($opt) $val
60                continue
61            }
62        }
63
64        return [list error "Invalid image option: $opt $val"]
65    }
66
67    lappend result [array get opts]
68   
69    return $result
70}
Note: See TracBrowser for help on using the repository browser.