~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to ext/tk/lib/tkextlib/tcllib/diagrams.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2010-07-31 17:08:39 UTC
  • mfrom: (1.1.4 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100731170839-j034dmpdqt1cc4p6
Tags: 1.9.2~svn28788-1
* New release based on upstream snapshot from the 1.9.2 branch,
  after 1.9.2 RC2. That branch is (supposed to be) binary-compatible
  with the 1.9.1 branch.
  + Builds fine on i386. Closes: #580852.
* Upgrade to Standards-Version: 3.9.1. No changes needed.
* Updated generated incs.
* Patches that still need work:
  + Unclear status, need more investigation:
   090729_fix_Makefile_deps.dpatch
   090803_exclude_rdoc.dpatch
   203_adjust_base_of_search_path.dpatch
   902_define_YAML_in_yaml_stringio.rb.dpatch
   919_common.mk_tweaks.dpatch
   931_libruby_suffix.dpatch
   940_test_thread_mutex_sync_shorter.dpatch
  + Maybe not needed anymore, keeping but not applying.
   102_skip_test_copy_stream.dpatch (test doesn't block anymore?)
   104_skip_btest_io.dpatch (test doesn't block anymore?)
   201_gem_prelude.dpatch (we don't use that rubygems anyway?)
   202_gem_default_dir.dpatch (we don't use that rubygems anyway?)
   940_test_file_exhaustive_fails_as_root.dpatch
   940_test_priority_fails.dpatch
   100518_load_libc_libm.dpatch
* Add disable-tests.diff: disable some tests that cause failures on FreeBSD.
  Closes: #590002, #543805, #542927.
* However, many new failures on FreeBSD. Since that version is still an
  improvement, add the check that makes test suite failures non-fatal on
  FreeBSD again. That still needs to be investigated.
* Re-add 903_skip_base_ruby_check.dpatch
* Add build-dependency on ruby1.8 and drop all pre-generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#  tkextlib/tcllib/diagrams.rb
 
3
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
 
4
#
 
5
#   * Part of tcllib extension
 
6
#   * Draw diagrams
 
7
#
 
8
 
 
9
require 'tk'
 
10
require 'tkextlib/tcllib.rb'
 
11
 
 
12
# TkPackage.require('Diagrams', '0.3')
 
13
TkPackage.require('Diagrams')
 
14
 
 
15
module Tk::Tcllib
 
16
  module Diagrams
 
17
    PACKAGE_NAME = 'Diagrams'.freeze
 
18
    def self.package_name
 
19
      PACKAGE_NAME
 
20
    end
 
21
 
 
22
    def self.package_version
 
23
      begin
 
24
        TkPackage.require('Diagrams')
 
25
      rescue
 
26
        ''
 
27
      end
 
28
    end
 
29
  end
 
30
end
 
31
 
 
32
class << Tk::Tcllib::Diagrams
 
33
  include TkCore
 
34
 
 
35
  def drawin(canvas)
 
36
    tk_call('::Diagrams::drawin', canvas)
 
37
    canvas
 
38
  end
 
39
  alias draw_in drawin
 
40
 
 
41
  def saveps(filename)
 
42
    tk_call('::Diagrams::saveps', filename)
 
43
    filename
 
44
  end
 
45
  alias save_ps saveps
 
46
 
 
47
  def direction(dir)
 
48
    tk_call('::Diagrams::direction', dir)
 
49
    dir
 
50
  end
 
51
 
 
52
  def currentpos(pos)
 
53
    list(tk_call('::Diagrams::currentpos', pos))
 
54
  end
 
55
  alias current_pos currentpos
 
56
  alias currentpos= currentpos
 
57
  alias current_pos= currentpos
 
58
 
 
59
  def getpos(anchor, obj)
 
60
    list(tk_call('::Diagrams::getpos', anchor, obj))
 
61
  end
 
62
  alias get_pos getpos
 
63
 
 
64
  def position(x, y)
 
65
    list(tk_call('::Diagrams::position', x, y))
 
66
  end
 
67
 
 
68
  def box(text, width=nil, height=nil)
 
69
    if width || height
 
70
      width  = '' unless width
 
71
      height = '' unless height
 
72
      list(tk_call('::Diagrams::box', text, width, height))
 
73
    else
 
74
      list(tk_call('::Diagrams::box', text))
 
75
    end
 
76
  end
 
77
 
 
78
  def plaintext(text, width=nil, height=nil)
 
79
    if width || height
 
80
      width  = '' unless width
 
81
      height = '' unless height
 
82
      list(tk_call('::Diagrams::plaintext', text, width, height))
 
83
    else
 
84
      list(tk_call('::Diagrams::plaintext', text))
 
85
    end
 
86
  end
 
87
 
 
88
  def circle(text, radius=nil)
 
89
    if radius
 
90
      list(tk_call('::Diagrams::circle', text, radius))
 
91
    else
 
92
      list(tk_call('::Diagrams::circle', text))
 
93
    end
 
94
  end
 
95
 
 
96
  def slanted(text, width=nil, height=nil, angle=nil)
 
97
    if width || height || angle
 
98
      width  = '' unless width
 
99
      height = '' unless height
 
100
      if angle
 
101
        list(tk_call('::Diagrams::slanted', text, width, height, angle))
 
102
      else
 
103
        list(tk_call('::Diagrams::slanted', text, width, height))
 
104
      end
 
105
    else
 
106
      list(tk_call('::Diagrams::slanted', text))
 
107
    end
 
108
  end
 
109
 
 
110
  def diamond(text, width=nil, height=nil)
 
111
    if width || height
 
112
      width  = '' unless width
 
113
      height = '' unless height
 
114
      list(tk_call('::Diagrams::diamond', text, width, height))
 
115
    else
 
116
      list(tk_call('::Diagrams::diamond', text))
 
117
    end
 
118
  end
 
119
 
 
120
  def drum(text, width=nil, height=nil)
 
121
    if width || height
 
122
      width  = '' unless width
 
123
      height = '' unless height
 
124
      list(tk_call('::Diagrams::drum', text, width, height))
 
125
    else
 
126
      list(tk_call('::Diagrams::drum', text))
 
127
    end
 
128
  end
 
129
 
 
130
  def arrow(text=nil, length=nil, head=nil)
 
131
    if length || head
 
132
      text   = '' unless text
 
133
      length = '' unless length
 
134
      list(tk_call('::Diagrams::arrow', text, length, head))
 
135
    else
 
136
      if text
 
137
        list(tk_call('::Diagrams::arrow', text))
 
138
      else
 
139
        list(tk_call('::Diagrams::arrow'))
 
140
      end
 
141
    end
 
142
  end
 
143
 
 
144
  def line(*args)
 
145
    ary = []
 
146
    args.each{|arg|
 
147
      if arg.kind_of?(Array) && arg.length == 2  # [length, angle]
 
148
        ary.concat arg
 
149
      else # ["POSITION", x, y] or length or angle
 
150
        ary << arg
 
151
      end
 
152
    }
 
153
    list(tk_call('::Diagrams::line', *ary))
 
154
  end
 
155
 
 
156
  def bracket(dir, dist, from_pos, to_pos)
 
157
    list(tk_call('::Diagrams::bracket', dir, dist, from_pos, to_pos))
 
158
  end
 
159
 
 
160
  def attach(anchor=None)
 
161
    tk_call('::Diagrams::attach', anchor)
 
162
  end
 
163
 
 
164
  def color(name=None)
 
165
    tk_call('::Diagrams::color', name)
 
166
  end
 
167
 
 
168
  def fillcolor(name=None)
 
169
    tk_call('::Diagrams::fillcolor', name)
 
170
  end
 
171
 
 
172
  def textcolor(name=None)
 
173
    tk_call('::Diagrams::textcolor', name)
 
174
  end
 
175
 
 
176
  def usegap(mode=None)
 
177
    bool(tk_call('::Diagrams::usegap', mode))
 
178
  end
 
179
  alias use_gap usegap
 
180
 
 
181
  def xgap(val=None)
 
182
    number(tk_call('::Diagrams::xgap', val))
 
183
  end
 
184
 
 
185
  def ygap(val=None)
 
186
    number(tk_call('::Diagrams::ygap', val))
 
187
  end
 
188
 
 
189
  def textfont(fnt=None)
 
190
    tk_call('::Diagrams::textfont', fnt)
 
191
  end
 
192
 
 
193
  def linewidth(pixels=None)
 
194
    number(tk_call('::Diagrams::linewidth', pixels))
 
195
  end
 
196
 
 
197
  def linestyle(style=None)
 
198
    tk_call('::Diagrams::linestyle', style)
 
199
  end
 
200
 
 
201
  def pushstate
 
202
    tk_call('::Diagrams::pushstate')
 
203
  end
 
204
  alias push_state pushstate
 
205
 
 
206
  def popstate
 
207
    tk_call('::Diagrams::popstate')
 
208
  end
 
209
  alias pop_state popstate
 
210
 
 
211
  def computepos
 
212
    list(tk_call('::Diagrams::computepos'))
 
213
  end
 
214
  alias compute_pos computepos
 
215
 
 
216
  def boxcoords(x1, y1, x2, y2)
 
217
    list(tk_call('::Diagrams::boxcoords', x1, y1, x2, y2))
 
218
  end
 
219
 
 
220
  def moveobject(obj)
 
221
    list(tk_call('::Diagrams::moveobject', obj))
 
222
  end
 
223
  alias move_object moveobject
 
224
end