summaryrefslogtreecommitdiffstats
path: root/ksirc/puke/palistbox.pm
blob: e1dcb69193dd8053ffab4954cb6e9741c1fd557b (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

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


package PAListBox; 
@ISA = qw(PListBox);
use strict;

if($PListBox::usage == undef){
    $PListBox::usage = 0;
}

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

  $self->{widgetType} = $::PWIDGET_ALISTBOX;

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

  $self->installHandler($::PUKE_LISTBOX_SELECTED_ACK, sub{$self->selected(@_)});

  return $self;

}

sub DESTROY { 
    my $self = shift;
    $self->SUPER::DESTROY(@_);
    $PAListBox::usage--;
    if($PAListBox::usage == 0){
        &::PukeSendMessage($::PUKE_WIDGET_UNLOAD,
                           0,
                           $::PWIDGET_ALISTBOX,
                           "",
                           sub {}
                          );

    }
}

sub inSort {
  my $self = shift;
  my $text = shift;
  my $top = shift;

  $self->sendMessage('iCommand' => $::PUKE_LISTBOX_INSERT_SORT,
		     'cArg' => $text,
                     'iArg' => $text >= 1 ? 1 : 0,
                     'CallBack' => sub {});

}

sub isTop {
  my $self = shift;
  my $text = shift;

  my %ret = $self->sendMessage('iCommand' => $::PUKE_ALISTBOX_ISTOP,
			       'cArg' => $text,
			       'CallBack' => sub {});

  return $ret{'iArg'};

}

sub findNick {
  my $self = shift;
  my $text = shift;

  my %ret = $self->sendMessage('iCommand' => $::PUKE_ALISTBOX_FIND_NICK,
			       'cArg' => $text,
			       'CallBack' => sub {},
			       'WaitFor' => 1);

  return $ret{'iArg'};
  
}

sub smallHighligh {
  my $self = shift;
  my $text = shift;
  my $highlight = shift;

  $self->sendMessage('iCommand' => $::PUKE_ALISTBOX_SMALL_HIGHLIGHT,
		     'cArg' => $text,
		     'iArg' => $highlight,
		     'CallBack' => sub {});  

}

sub bigHighligh {
  my $self = shift;
  my $text = shift;
  my $highlight = shift;

  $self->sendMessage('iCommand' => $::PUKE_ALISTBOX_BIG_HIGHLIGHT,
		     'cArg' => $text,
		     'iArg' => $highlight,
		     'CallBack' => sub {});  

}


package main; 

1;