summaryrefslogtreecommitdiffstats
path: root/ksirc/puke/pwidget.pm
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /ksirc/puke/pwidget.pm
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksirc/puke/pwidget.pm')
-rw-r--r--ksirc/puke/pwidget.pm231
1 files changed, 231 insertions, 0 deletions
diff --git a/ksirc/puke/pwidget.pm b/ksirc/puke/pwidget.pm
new file mode 100644
index 00000000..5a73d393
--- /dev/null
+++ b/ksirc/puke/pwidget.pm
@@ -0,0 +1,231 @@
+
+package PWidget;
+@ISA = qw(PBase);
+use strict;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new($class, @_);
+
+ $self->{widgetType} = $::PWIDGET_WIDGET;
+
+ # Default handlers
+ $self->installHandler($::PUKE_WIDGET_EVENT_RESIZE,
+ sub {$self->resizeEvent(@_)});
+ $self->installHandler($::PUKE_WIDGET_EVENT_PAINT,
+ sub {$self->paintEvent(@_)});
+ $self->installHandler($::PUKE_WIDGET_EVENT_MOVE,
+ sub {$self->moveEvent(@_)});
+ $self->installHandler($::PUKE_EVENT_UNKOWN,
+ sub {$self->miscEvent(@_)});
+ # Examplesto listen for mouse events
+ # $self->installHandler($::PUKE_WIDGET_EVENT_MOUSEBUTTONPRESS,
+ # sub {$self->mousePressEvent(@_)});
+ #$self->installHandler($::PUKE_WIDGET_EVENT_MOUSEBUTTONRELEASE,
+ # sub {$self->mouseReleaseEvent(@_)});
+
+
+
+ if($class eq 'PWidget'){
+ $self->create();
+ }
+
+ return $self;
+
+}
+
+sub close {
+ my $self = shift;
+
+ $self->hide();
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_DELETE,
+ 'CallBack' => sub {});
+
+ $self->{DESTROYED} = 1;
+
+}
+
+sub show {
+ my $self = shift;
+
+ # make sure we are runable then show continue.
+ my @ARG = ();
+ # $self->canRun($self, \&PWidget::show, \@ARG) || return;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SHOW);
+}
+
+sub hide {
+ my $self = shift;
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_HIDE);
+}
+
+sub repaint {
+ my $self = shift;
+
+ my $erase = shift; # 1 for erase and reapint
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_REPAINT,
+ 'iArg' => $erase);
+}
+
+sub resize {
+ my $self = shift;
+
+ my $width = shift;
+ my $height = shift;
+
+ my $carg = "$width\t$height";
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_RESIZE,
+ 'cArg' => $carg);
+
+}
+
+sub move {
+ my $self = shift;
+
+ my $x = shift;
+ my $y = shift;
+
+ my $carg = "$x\t$y";
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_MOVE,
+ 'cArg' => $carg);
+
+}
+
+sub setMinimumSize {
+ my $self = shift;
+
+ my $w = shift;
+ my $h = shift;
+
+ my $carg = "$w\t$h";
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SETMINSIZE,
+ 'cArg' => $carg,
+ 'CallBack' => sub {});
+
+}
+
+sub setMaximumSize {
+ my $self = shift;
+
+ my $w = shift;
+ my $h = shift;
+
+ my $carg = "$w\t$h";
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SETMAXSIZE,
+ 'cArg' => $carg,
+ 'CallBack' => sub {});
+
+}
+
+
+sub setCaption {
+ my $self = shift;
+
+ my $text = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SETCAPTION,
+ 'cArg' => $text,
+ 'CallBack' => sub {});
+
+}
+
+sub resizeEvent {
+ my $self = shift;
+
+ my %ARG = %{shift()};
+
+ my($h, $w, $oh, $ow) = unpack("iiii", $ARG{'cArg'});
+ $self->{'height'} = $h;
+ $self->{'width'} = $w;
+
+}
+
+sub paintEvent {
+}
+
+sub moveEvent {
+ my $self = shift;
+
+ my %ARG = %{shift()};
+
+ my($x, $y, $ox, $oy) = unpack("iiii", $ARG{'cArg'});
+ $self->{'x'} = $x;
+ $self->{'y'} = $y;
+
+}
+
+sub miscEvent {
+}
+
+sub backgroundColor {
+ my $self = shift;
+
+ my %arg = $self->sendMessage('iCommand' => $::PUKE_WIDGET_GET_BACKGROUND_COLOUR,
+ 'WaitFor' => 1);
+
+ # print "Got: " . $arg{'cArg'} . "\n";
+
+ $arg{'cArg'} =~ s/\000//g;
+ my ($r, $g, $b) = split(/,/, $arg{'cArg'});
+
+ return ($r, $g, $b);
+}
+
+sub setBackgroundColor {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SET_BACKGROUND_COLOUR,
+ 'cArg' => pack("i3", shift(), shift(), shift()),
+ 'CallBack' => sub {});
+
+}
+
+sub setBackgroundPixmap {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SET_BACKGROUND_PIXMAP,
+ 'cArg' => shift(),
+ 'CallBack' => sub {});
+}
+
+sub setBackgroundMode {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SET_BACKGROUND_MODE,
+ 'iArg' => shift(),
+ 'CallBack' => sub {});
+}
+
+
+sub setEnabled {
+ my $self = shift;
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_SET_ENABLED,
+ 'iArg' => shift(),
+ 'CallBack' => sub {});
+
+}
+
+sub recreate {
+ my $self = shift;
+
+ my $nparent = shift;
+ my $wflags = shift; # Not used!
+
+ $self->sendMessage('iCommand' => $::PUKE_WIDGET_RECREATE,
+ 'iArg' => $nparent ? $nparent->{'iWinId'} : 0,
+ 'cArg' => pack("iii", shift(), shift(), shift()),
+ 'CallBack' => sub {});
+
+}
+
+package main;
+
+1;