browser.tcl

Go to the documentation of this file.
00001 /* !/bin/sh*/
00002 /*  \*/
00003 exec wish "$0" "$@"
00004 
00005 /*  browser.tcl --*/
00006 /* */
00007 /*  A mini XML browser*/
00008 /* */
00009 /*  Copyright (c) 2003 Zveno Pty Ltd*/
00010 /*  http://www.zveno.com/*/
00011 /* */
00012 /*  See the file "LICENSE" in this distribution for information on usage and*/
00013 /*  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.*/
00014 /* */
00015 /*  $Id: browser.tcl,v 1.3 2003/12/09 04:56:40 balls Exp $*/
00016 
00017 package require dom
00018 package require domtree
00019 package require domtext
00020 
00021 ret  Open () {
00022     global tree text doc view
00023 
00024     set fname [tk_getOpenFile]
00025     if {![string length $fname]} {
00026         return {}
00027     }
00028 
00029     set ch [open $fname]
00030     set newdoc [dom::parse [read $ch]]
00031     close $ch
00032 
00033     $tree configure -rootnode {}
00034     $text configure -rootnode {}
00035     catch {dom::destroy $doc}
00036 
00037     set doc $newdoc
00038     if {[lsearch $view tree] >= 0} {
00039     $tree configure -rootnode $doc
00040     }
00041     if {[lsearch $view text] >= 0} {
00042     $text configure -rootnode $doc
00043     }
00044 
00045     return {}
00046 }
00047 
00048 ret  View:tree () {
00049     global view
00050 
00051     set view tree
00052 
00053     .controls.view configure -text {Tree & Text} -command View:both
00054 
00055     return {}
00056 }
00057 ret  View:both () {
00058     global view
00059 
00060     set view {tree text}
00061 
00062     .controls.view configure -text {Tree Only} -command View:tree
00063 
00064     return {}
00065 }
00066 
00067 frame .controls
00068 button .controls.open -text Open -command Open
00069 button .controls.view
00070 View:both
00071 grid .controls.open .controls.view -sticky w
00072 
00073  p =  [panedwindow .panes -orient horizontal]
00074 
00075 grid .controls -row 0 -column 0 -sticky ew
00076 grid $p -row 1 -column 0 -sticky news
00077 grid rowconfigure . 1 -weight 1
00078 grid columnconfigure . 0 -weight 1
00079 
00080 labelframe $p.tree -text {Tree View}
00081 $p add $p.tree -minsize 200
00082  tree =  [domtree::create $p.tree.t \
00083           -yscrollcommand [list $p.tree.y ] \
00084           -xscrollcommand =  [list $p.tree.x ]]
00085 scrollbar =  $p.tree.y -orient vertical -command [list $p.tree.t yview]
00086 scrollbar $p.tree.x -orient horizontal -command [list $p.tree.t xview]
00087 grid $p.tree.t -row 0 -column 0 -sticky news
00088 grid $p.tree.y -row 0 -column 1 -sticky ns
00089 grid $p.tree.x -row 1 -column 0 -sticky ew
00090 grid rowconfigure $p.tree 0 -weight 1
00091 grid columnconfigure $p.tree 0 -weight 1
00092 
00093 labelframe $p.text -text {Source View}
00094 $p add $p.text -minsize 200
00095  text =  [domtext::create $p.text.t \
00096           -yscrollcommand [list $p.text.y ] \
00097           -xscrollcommand =  [list $p.text.x ]]
00098 scrollbar =  $p.text.y -orient vertical -command [list $p.text.t yview]
00099 scrollbar $p.text.x -orient horizontal -command [list $p.text.t xview]
00100 grid $p.text.t -row 0 -column 0 -sticky news
00101 grid $p.text.y -row 0 -column 1 -sticky ns
00102 grid $p.text.x -row 1 -column 0 -sticky ew
00103 grid rowconfigure $p.text 0 -weight 1
00104 grid columnconfigure $p.text 0 -weight 1
00105 
00106 

Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1