home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / ilstrconge.tcl < prev    next >
Encoding:
Text File  |  1996-05-29  |  4.8 KB  |  230 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Westmount Technology    1994
  4. #
  5. #      File:           @(#)ilstrconge.tcl    1.4
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)ilstrconge.tcl    1.4   07 Nov 1995 Copyright 1994 Westmount Technology
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14. require "ilcongen.tcl"
  15.  
  16. Class IlStrConGen : {IlConGen} {
  17.     method destructor
  18.     constructor
  19.     method generate
  20.     method genComponent
  21.     method nextY
  22.     method nextX
  23.     method attribPath
  24.     method section
  25.     attribute x
  26.     attribute y
  27.     attribute ascFid
  28.     attribute _section
  29. }
  30.  
  31. global IlStrConGen::stepX
  32. set IlStrConGen::stepX ""
  33.  
  34. global IlStrConGen::stepY
  35. set IlStrConGen::stepY ""
  36.  
  37. global IlStrConGen::startX
  38. set IlStrConGen::startX ""
  39.  
  40. global IlStrConGen::startY
  41. set IlStrConGen::startY ""
  42.  
  43. global IlStrConGen::indentX
  44. set IlStrConGen::indentX ""
  45.  
  46.  
  47. method IlStrConGen::destructor {this} {
  48.     set ref [$this _section]
  49.     if {$ref != ""} {
  50.         $ref _contentsGenerator ""
  51.     }
  52.     # Start destructor user section
  53.     # End destructor user section
  54.     $this IlConGen::destructor
  55. }
  56.  
  57. constructor IlStrConGen {class this name section} {
  58.     set this [IlConGen::constructor $class $this $name $section]
  59.     $section _contentsGenerator $this
  60.  
  61.     if {${IlStrConGen::stepX} == ""} {
  62.         global IlStrConGen::stepX
  63.         global IlStrConGen::stepY
  64.         global IlStrConGen::startX
  65.         global IlStrConGen::startY
  66.         global IlStrConGen::indentX
  67.         set IlStrConGen::stepX 96
  68.         set IlStrConGen::stepY 56
  69.         set IlStrConGen::startX 50
  70.         set IlStrConGen::startY 50
  71.         set IlStrConGen::indentX 96
  72.     }
  73.     $this x -1
  74.     $this y -1
  75.  
  76.     return $this
  77. }
  78.  
  79. method IlStrConGen::generate {this} {
  80.  
  81.     # Generate Interleaf attribute-files
  82.     # and put them also in the current section
  83.  
  84.     $this ascFid [$this openAsc]
  85.  
  86.     if {[$this ascFid] == ""} {
  87.         return
  88.     }
  89.  
  90.     set dir [path_name directory [[$this section] docLocation]]
  91.     
  92.  
  93.     set curDir [pwd]
  94.     cd $dir
  95.     if {! [catch {set files [glob .@*]}]} {
  96.         foreach file $files {
  97.             BasicFS::removeFile $file
  98.         }
  99.     }
  100.  
  101.     set comp [[docTool structure] firstComponent]
  102.     for {} {$comp != ""} {set comp [$comp next]} {
  103.         set section [docTool findSection [$comp uiName]]
  104.         if {$section != ""} {
  105.             $this genComponent $section
  106.         }
  107.     }
  108.  
  109.     close [$this ascFid]
  110. }
  111.  
  112. method IlStrConGen::genComponent {this section} {
  113.  
  114.     set dotFile [$this attribPath $section]
  115.  
  116.     set attribs [TextSection new]
  117.     set name [$section uiName]
  118.  
  119.     if {[regsub -all {\(} $name {\\(} nn]} {set name $nn}
  120.     if {[regsub -all {\)} $name {\\)} nn]} {set name $nn}
  121.  
  122.     if {[$section docType] == "Doc"} {
  123.         $this nextY [$section indentation]
  124.     } else {
  125.         $this nextX $name
  126.     }
  127.  
  128.     $attribs append  "(system_attributes\n"
  129.     $attribs append  "  (doc_name $name)\n"
  130.     $attribs append  "  (icon_x [$this x])\n"
  131.     $attribs append  "  (icon_y [$this y])\n"
  132.  
  133.     if {[$section docType] == "Cat"} {
  134.         $attribs append  "  (master_exports components auto_numbers \
  135.                     frames diagramming_objects tables \
  136.                     pages header_footers)"
  137.     }
  138.     $attribs append  ")\n"
  139.     $attribs append  "(attribute_display_list)\n"
  140.     $attribs append  "(attribute_control \"<#0>\")\n"
  141.  
  142.     puts [$this ascFid] ".@$name"
  143.     $attribs write [$this ascFid]
  144.  
  145.     if {[catch {set dot [open $dotFile w]} reason]} {
  146.         wmtkerror "Error on opening '$dotFile' for writing: $reason"
  147.     } else {
  148.         $attribs write $dot
  149.         close $dot
  150.      }
  151. }
  152.  
  153. method IlStrConGen::nextY {this level} {
  154.  
  155.     global IlStrConGen::startY
  156.     global IlStrConGen::stepY
  157.     global IlStrConGen::indentX
  158.  
  159.     set y [$this y]
  160.  
  161.     if {$y == -1} {
  162.         set y ${IlStrConGen::startY}
  163.     } else {
  164.         incr y ${IlStrConGen::stepY}
  165.     }
  166.     
  167.     $this y $y
  168.  
  169.     set x ${IlStrConGen::startX}
  170.  
  171.     if {$level > 0} {
  172.         incr x [expr $level*${IlStrConGen::indentX}]
  173.     }
  174.  
  175.     $this x $x
  176. }
  177.  
  178. method IlStrConGen::nextX {this name} {
  179.  
  180.     global IlStrConGen::startY
  181.     global IlStrConGen::startX
  182.     global IlStrConGen::stepX
  183.  
  184.     if {[$this y] == -1} {
  185.         $this y ${IlStrConGen::startY}
  186.     }
  187.  
  188.     set x [$this x]
  189.  
  190.     if {$x == -1} {
  191.         set x ${IlStrConGen::startX}
  192.     } else {
  193.         set shift [expr 7*[string length $name]]
  194.         if {$shift < ${IlStrConGen::stepX}} {
  195.             incr x ${IlStrConGen::stepX}
  196.         } else {
  197.             incr x $shift
  198.         }
  199.     }
  200.  
  201.     $this x $x
  202. }
  203.  
  204. method IlStrConGen::attribPath {this section} {
  205.  
  206.     set path [$section docLocation]
  207.     set dir  [path_name directory $path]
  208.     set file  ".@[path_name file $path]"
  209.  
  210.     return [path_name concat $dir $file]
  211. }
  212.  
  213. # Do not delete this line -- regeneration end marker
  214.  
  215. method IlStrConGen::section {this args} {
  216.     if {$args == ""} {
  217.         return [$this _section]
  218.     }
  219.     set ref [$this _section]
  220.     if {$ref != ""} {
  221.         $ref _contentsGenerator ""
  222.     }
  223.     set obj [lindex $args 0]
  224.     if {$obj != ""} {
  225.         $obj _contentsGenerator $this
  226.     }
  227.     $this _section $obj
  228. }
  229.  
  230.