line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
## Name: lib/Wx/DemoModules/wxDatePickerCtrl.pm |
3
|
|
|
|
|
|
|
## Purpose: wxPerl demo helper for Wx::DatePickerCtrl |
4
|
|
|
|
|
|
|
## Author: Mattia Barbon |
5
|
|
|
|
|
|
|
## Modified by: |
6
|
|
|
|
|
|
|
## Created: 18/03/2005 |
7
|
|
|
|
|
|
|
## RCS-ID: $Id: wxDatePickerCtrl.pm 2984 2010-10-09 03:25:16Z mdootson $ |
8
|
|
|
|
|
|
|
## Copyright: (c) 2005-2010 Mattia Barbon |
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or |
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself |
11
|
|
|
|
|
|
|
############################################################################# |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1462
|
use Wx::Calendar; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Wx::DemoModules::wxDatePickerCtrl; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use strict; |
18
|
|
|
|
|
|
|
use base qw(Wx::Panel); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Wx qw(:sizer :datepicker :misc); |
21
|
|
|
|
|
|
|
use Wx::Event qw(EVT_DATE_CHANGED); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
|
|
|
|
|
|
my $class = shift; |
25
|
|
|
|
|
|
|
my $this = $class->SUPER::new( $_[0], -1 ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $sizer = Wx::BoxSizer->new( wxVERTICAL ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# 8 Jan 1979 |
30
|
|
|
|
|
|
|
#my $date = Wx::DateTime->newFromDMY( 8, 0, 1979, 1, 1, 1, 1 ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $date = Wx::DateTime->new(); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $calendar = Wx::DatePickerCtrl->new( $this, -1, $date, wxDefaultPosition, wxDefaultSize, wxDP_ALLOWNONE ); |
36
|
|
|
|
|
|
|
$calendar->SetRange( $date, Wx::DateTime->new ); |
37
|
|
|
|
|
|
|
$calendar->SetValue($date); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $textctrl = Wx::TextCtrl->new( $this, -1, 'INVALID DATE' ); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$sizer->Add( $calendar, 0, wxALL, 10 ); |
43
|
|
|
|
|
|
|
$sizer->Add( $textctrl, 0, wxGROW|wxALL, 10 ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
EVT_DATE_CHANGED( $this, $calendar, |
46
|
|
|
|
|
|
|
( $Wx::VERSION > 0.98 ) |
47
|
|
|
|
|
|
|
? sub { |
48
|
|
|
|
|
|
|
$textctrl->SetValue( |
49
|
|
|
|
|
|
|
( $_[1]->GetDate->IsValid ) ? $_[1]->GetDate->FormatDate : 'INVALID DATE' |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
: sub { |
53
|
|
|
|
|
|
|
my $invalid = Wx::DateTime->new(); |
54
|
|
|
|
|
|
|
$textctrl->SetValue( |
55
|
|
|
|
|
|
|
( $_[1]->GetDate->IsEqualTo($invalid) ) ? 'INVALID DATE' : $_[1]->GetDate->FormatDate |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$this->SetSizer( $sizer ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $this; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub add_to_tags { qw(controls/picker) } |
66
|
|
|
|
|
|
|
sub title { 'wxDatePickerCtrl' } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |