summaryrefslogtreecommitdiffstats
path: root/ksirc/puke/plined.pm
blob: fbff6f965afe6408a081fa554142d624b0fa8931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

&::PukeSendMessage($PUKE_WIDGET_LOAD, 
		   $::PUKE_CONTROLLER, 
		   $PWIDGET_LINED,
		   "plined.so",
		   sub { my %ARG = %{shift()};
			 if($ARG{'iArg'} == 1){
			   print "*E* PLineEdit Load failed!\n";
			 }
		       }
		  );

package PLineEdit;
@ISA = qw(PWidget);
use strict;

sub new {
  my $class = shift;
  my $self = $class->SUPER::new($class, @_);

  $self->{widgetType} = $::PWIDGET_LINED;
  $self->{maxLength} = -1;

  if($class eq 'PLineEdit'){
    $self->create();
  }

  $self->installHandler($::PUKE_WIDGET_EVENT_TIMER, sub{});
  $self->installHandler($::PUKE_LINED_GET_TEXT_ACK, sub{
			my %ARG = %{shift()};
			$ARG{'cArg'} =~ s/^([^\000]*).*/$1/;
			$self->{text} = $ARG{'cArg'};});

  return $self;

}

sub setMaxLength {
  my $self = shift;

  my $length = shift;

  $self->{maxLength} = $length;
  $self->sendMessage('iCommand' => $::PUKE_LINED_SET_MAXLENGTH,
		     'iArg' => $length,
		     'CallBack' => sub {my %ARG = %{shift()};
					$self->{maxLength} = $ARG{'iArg'};});
  
}

sub setEchoMode {
  my $self = shift;

  my $mode = shift;

  $self->sendMessage('iCommand' => $::PUKE_LINED_SET_ECHOMODE,
		     'iArg' => $mode,
		     'CallBack' => sub {my %ARG = %{shift()};
					$self->{echoMode} = $ARG{'iArg'};});

}

sub setText {
  my $self = shift;
  
  my $text = shift;
  
  $self->{text} = $text;

  # Don't need the ouput since GET_TEXT_ACK will be called and
  # we'll set it there
  $self->sendMessage('iCommand' => $::PUKE_LINED_SET_TEXT,
		     'cArg' => $text,
		     'CallBack' => sub {});

}

sub text {
  my $self = shift;

  return $self->{text};
}

package main;