~ubuntu-branches/ubuntu/warty/perl-tk/warty

« back to all changes in this revision

Viewing changes to demos/demos/widget_lib/arrows.pl

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Zander
  • Date: 2004-03-14 13:54:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314135444-prc09u2or4dbr3to
Tags: 1:800.025-2
Add xlibs-dev to Build-Depends:,
Closes: #237942

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    );
18
18
 
19
19
    my $c = $TOP->Canvas(
20
 
        -width       => '500', 
 
20
        -width       => '500',
21
21
        -height      => '350',
22
22
        -relief      => 'sunken',
23
23
        -borderwidth => 2,
70
70
            sub {$ainfo{move_sub} = \&{"arrow_move${n}"}}
71
71
        );
72
72
    }
73
 
    
 
73
 
74
74
    # Bindings to move a resize box and redraw the arrow.
75
75
 
76
76
    $c->bind('box', '<B1-Motion>' =>
84
84
 
85
85
    my($c) = @_;
86
86
 
87
 
    my $i = $c->create(qw/text .6i .1i -anchor n -text/ => "Range error!");
 
87
    my $i = $c->createText(qw/.6i .1i -anchor n -text/ => "Range error!");
88
88
    $c->after(4000, sub { $c->delete($i) });
89
89
 
90
90
} # end errow_err
164
164
    # Create the arrow and outline.
165
165
 
166
166
    $c->delete('all');
167
 
    $c->create('line', $v->{x1}, $v->{'y'}, $v->{x2}, $v->{'y'}, 
 
167
    $c->createLine($v->{x1}, $v->{'y'}, $v->{x2}, $v->{'y'},
168
168
               -width => 10*$v->{width},
169
169
               -arrowshape => [10*$v->{a}, 10*$v->{b}, 10*$v->{c}],
170
170
               -arrow => 'last', @{$v->{bigLineStyle}});
171
171
    my $xtip = $v->{x2}-10*$v->{b};
172
172
    my $deltaY =  10*$v->{c}+5*$v->{width};
173
 
    $c->create('line', $v->{x2}, $v->{'y'}, $xtip, $v->{'y'}+$deltaY,
 
173
    $c->createLine($v->{x2}, $v->{'y'}, $xtip, $v->{'y'}+$deltaY,
174
174
               $v->{x2}-10*$v->{a}, $v->{'y'}, $xtip, $v->{'y'}-$deltaY,
175
175
               $v->{x2}, $v->{'y'}, -width => 2, -capstyle => 'round',
176
176
               -joinstyle => 'round');
177
177
 
178
178
    # Create the boxes for reshaping the line and arrowhead.
179
179
 
180
 
    $c->create('rectangle', $v->{x2}-10*$v->{a}-5, $v->{'y'}-5,
 
180
    $c->createRectangle($v->{x2}-10*$v->{a}-5, $v->{'y'}-5,
181
181
               $v->{x2}-10*$v->{a}+5, $v->{'y'}+5, @{$v->{boxStyle}},
182
182
               -tags => ['box1', 'box']);
183
 
    $c->create('rectangle', $xtip-5, $v->{'y'}-$deltaY-5, $xtip+5,
 
183
    $c->createRectangle($xtip-5, $v->{'y'}-$deltaY-5, $xtip+5,
184
184
               $v->{'y'}-$deltaY+5, @{$v->{boxStyle}},
185
185
               -tags => ['box2', 'box']);
186
 
    $c->create('rectangle', $v->{x1}-5, $v->{'y'}-5*$v->{width}-5,
 
186
    $c->createRectangle($v->{x1}-5, $v->{'y'}-5*$v->{width}-5,
187
187
               $v->{x1}+5, $v->{'y'}-5*$v->{width}+5, @{$v->{boxStyle}},
188
188
               -tags => ['box3', 'box']);
189
189
 
190
190
    # Create three arrows in actual size with the same parameters
191
191
 
192
 
    $c->create('line', $v->{x2}+50, 0, $v->{x2}+50, 1000, -width => 2);
 
192
    $c->createLine($v->{x2}+50, 0, $v->{x2}+50, 1000, -width => 2);
193
193
    my $tmp = $v->{x2}+100;
194
 
    $c->create('line', $tmp, $v->{'y'}-125, $tmp, $v->{'y'}-75,
 
194
    $c->createLine($tmp, $v->{'y'}-125, $tmp, $v->{'y'}-75,
195
195
               -width => $v->{width}, -arrow => 'both',
196
196
               -arrowshape => [$v->{a}, $v->{b}, $v->{c}]);
197
 
    $c->create('line', $tmp-25, $v->{'y'}, $tmp+25, $v->{'y'},
 
197
    $c->createLine($tmp-25, $v->{'y'}, $tmp+25, $v->{'y'},
198
198
               -width => $v->{width}, -arrow => 'both',
199
199
               -arrowshape =>[$v->{a}, $v->{b}, $v->{c}]);
200
 
    $c->create('line', $tmp-25, $v->{'y'}+75, $tmp+25, $v->{'y'}+125,
 
200
    $c->createLine($tmp-25, $v->{'y'}+75, $tmp+25, $v->{'y'}+125,
201
201
               -width => $v->{width}, -arrow => 'both',
202
202
               -arrowshape => [$v->{a}, $v->{b}, $v->{c}]);
203
203
    $c->itemconfigure($cur, @{$v->{activeStyle}}) if $cur =~ /box?/;
206
206
    # dimensions.
207
207
 
208
208
    $tmp = $v->{x2}+10;
209
 
    $c->create('line', $tmp, $v->{'y'}-5*$v->{width}, $tmp, $v->{'y'}-$deltaY,
 
209
    $c->createLine($tmp, $v->{'y'}-5*$v->{width}, $tmp, $v->{'y'}-$deltaY,
210
210
               -arrow => 'both', -arrowshape => $v->{smallTips});
211
 
    $c->create('text', $v->{x2}+15, $v->{'y'}-$deltaY+5*$v->{c},
 
211
    $c->createText($v->{x2}+15, $v->{'y'}-$deltaY+5*$v->{c},
212
212
               -text => $v->{c}, -anchor => 'w');
213
213
    $tmp =  $v->{x1}-10;
214
 
    $c->create('line', $tmp, $v->{'y'}-5*$v->{width}, $tmp,
 
214
    $c->createLine($tmp, $v->{'y'}-5*$v->{width}, $tmp,
215
215
               $v->{'y'}+5*$v->{width}, -arrow => 'both',
216
216
               -arrowshape => $v->{smallTips});
217
 
    $c->create('text', $v->{x1}-15, $v->{'y'}, -text => $v->{width},
 
217
    $c->createText($v->{x1}-15, $v->{'y'}, -text => $v->{width},
218
218
               -anchor => 'e');
219
219
    $tmp = $v->{'y'}+5*$v->{width}+10*$v->{c}+10;
220
 
    $c->create('line', $v->{x2}-10*$v->{a}, $tmp, $v->{x2}, $tmp,
 
220
    $c->createLine($v->{x2}-10*$v->{a}, $tmp, $v->{x2}, $tmp,
221
221
               -arrow => 'both', -arrowshape => $v->{smallTips});
222
 
    $c->create('text', $v->{x2}-5*$v->{a}, $tmp+5, -text => $v->{a},
 
222
    $c->createText($v->{x2}-5*$v->{a}, $tmp+5, -text => $v->{a},
223
223
               -anchor => 'n');
224
224
    $tmp = $tmp+25;
225
 
    $c->create('line', $v->{x2}-10*$v->{b}, $tmp, $v->{x2}, $tmp, 
 
225
    $c->createLine($v->{x2}-10*$v->{b}, $tmp, $v->{x2}, $tmp,
226
226
               -arrow => 'both', -arrowshape => $v->{smallTips});
227
 
    $c->create('text', $v->{x2}-5*$v->{b}, $tmp+5, -text => $v->{b},
 
227
    $c->createText($v->{x2}-5*$v->{b}, $tmp+5, -text => $v->{b},
228
228
               -anchor => 'n');
229
229
 
230
 
    $c->create('text', $v->{x1}, 310, -text => "-width =>  $v->{width}",
 
230
    $c->createText($v->{x1}, 310, -text => "-width =>  $v->{width}",
231
231
               -anchor => 'w',
232
232
               -font => '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*');
233
 
    $c->create('text', $v->{x1}, 330,
 
233
    $c->createText($v->{x1}, 330,
234
234
               -text => "-arrowshape =>  [$v->{a}, $v->{b}, $v->{c}]",
235
235
               -anchor => 'w',
236
236
               -font => '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*');
238
238
    $v->{count}++;
239
239
 
240
240
} # end arrow_setup
241
 
    
 
241
 
242
242
1;