Leser: 3
8 Einträge, 1 Seite |
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
package LoginFenster;
use strict;
use Tk;
use vars qw($VERSION);
$VERSION = 0.01;
use Alias qw(attr);
use vars qw($MW);
my %felder = (
MW=>undef,
);
sub new {
my $that = shift;
my $class = ref($that)||$that;
my $self = {
%felder,
};
bless $self, $class;
init();
return $self;
}
sub init {
$MW = tkinit(-title=> 'Anmeldung');
#...
MainLoop;
}
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
package Tray; use Win32::GUI; use Alias qw(attr); use vars qw($BILD $TEXT $CONTROLLER $WIN32 @FUNKTIONEN); my %felder = ( BILD => undef, TEXT => undef, CONTROLLER => undef, WIN32 => undef, FUNKTIONEN => [], ); sub new { my $that = shift; my $bildPfad = shift; my $text = shift; $CONTROLLER = shift; my $class = ref($that)||$that; my $self = { %felder, }; bless $self, $class; initWin($bildPfad, $text); return $self; } sub initWin { my $bildPfad = shift; my $text = shift; my $mw; $WIN32 = new Win32::GUI::DialogBox( -width => 0, -height => 0, -name => 'TrayWindow' ); my $icon_nr = 0; my @icon = (new Win32::GUI::Icon( $bildPfad )); new Win32::GUI::NotifyIcon( $WIN32, -name => "Notify", -id => 255, -icon => $icon[$icon_nr], -tip => $text, -onClick => sub { clicked(); }, #-onRightClick => sub { context_menu($mw, $main_win32); } ); -onRightClick => sub { context_menu(); } ); } #Rechtsklickmenü aufrufen sub context_menu { #my $mw = shift; #my $popup = $mw->Menu( Name => 'popupMenu', -tearoff => 0 ); $popup->command( -label => 'Verbindung trennen', -command => sub { &clean_exit } ); $popup->Popup( -popover => 'cursor', -popanchor => 'nw' ); return 1; } #Hauptfenster verstecken / anzeigen sub clicked { $CONTROLLER->tray_clicked(); } #Icon verändern sub toggle_icon { $icon_nr = !$icon_nr; Win32::GUI::NotifyIcon::Modify( $WIN32, -id => 255, -icon => $icon[$icon_nr], -tip => ' verändertes Icon ' ); } #TrayIcon erntfernen und Beenden sub clean_exit { $WIN32->Notify->Delete( -id => 255 ); CORE::exit; } 1;
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
package LoginFenster; use strict; use Tk; use vars qw($VERSION); $VERSION = 0.01; use Alias qw(attr); use vars qw($MW); my %felder = ( MW=>undef, ); sub new { my $that = shift; my $class = ref($that)||$that; my $self = { %felder, }; bless $self, $class; init(); return $self; } sub init { $MW = tkinit(-title=> 'Anmeldung'); #... MainLoop; } sub isHidden { if ($MW->state eq 'withdrawn'){ return 1; } return 0; } sub raiseup { $MW->deiconify; $MW->raise; $MW->focus; } sub hide { $MW->withdraw; } sub toggle { if(isHidden()){ raiseup(); } else{ hide(); } } 1;
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
package Controller; use Tray; use LoginFenster; use Alias qw(attr); use vars qw($TRAY $LF $SELF); my %felder = ( $TRAY = undef, $LF = undef, $SELF = undef, ); sub new { my $that = shift; my $bildPfad = shift; my $text = shift; my $class = ref($that)||$that; my $self = { %felder, }; bless $self, $class; $SELF = $self; init(); return $self; } sub init { $TRAY = Tray->new('c:\\pfad', 'text', $SELF); $LF = LoginFenster->new(); # $LF->show(); print ref($LF); } sub tray_clicked { $LF->toggle(); } 1;
8 Einträge, 1 Seite |