From 70aeb8761364b1a14434e927450ada76207f82f9 Mon Sep 17 00:00:00 2001 From: damien Date: Sat, 3 Mar 2001 04:29:02 +0000 Subject: uated --- clock.pm | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'clock.pm') diff --git a/clock.pm b/clock.pm index 54ee8b50..c9033f74 100755 --- a/clock.pm +++ b/clock.pm @@ -20,10 +20,15 @@ my $window = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel; my $vbox = new Gtk::VBox(0,0); $window->add($vbox); $window->signal_connect ( delete_event => \&quit_global ); - +my $hbox = new Gtk::HBox(0,0); +$vbox->pack_start($hbox, 1, 1, 0); +my $calendar = new Gtk::Calendar; +$hbox->pack_start($calendar, 1, 1, 0); +my $vbox2 = new Gtk::VBox(0,0); +$hbox->pack_start($vbox2, 1, 1, 0); my $drawing_area = new Gtk::DrawingArea; $drawing_area->size(200,200); -$vbox->pack_start($drawing_area, 1, 1, 0); +$vbox2->pack_start($drawing_area, 1, 1, 0); $drawing_area->set_events(['button_press_mask', 'button_release_mask', "pointer_motion_mask" ]); $drawing_area->signal_connect ( expose_event => \&expose_event ); $drawing_area->signal_connect ( configure_event => \&configure_event ); @@ -31,6 +36,39 @@ $drawing_area->signal_connect ( button_press_event => sub { $pressed=1 }); $drawing_area->signal_connect ( button_release_event => sub { $first=1; $pressed=0 }); $drawing_area->signal_connect ( motion_notify_event => \&motion_event ); +my $hbox11 = new Gtk::HBox(1,0); +$vbox2->pack_start($hbox11, 0, 0, 10); +my $hbox2 = new Gtk::HBox(1,0); +$hbox11->pack_start($hbox2, 0, 0, 0); +my $adj_h = new Gtk::Adjustment 0.0, 0.0, 23.0, 1.0, 5.0, 0.0; +my $spinner_h = new Gtk::SpinButton $adj_h, 0, 0; +$spinner_h->set_wrap(1); +$hbox2->pack_start($spinner_h, 0, 0, 0); +my $adj_m = new Gtk::Adjustment 0.0, 0.0, 59.0, 1.0, 5.0, 0.0; +my $spinner_m = new Gtk::SpinButton $adj_m, 0, 0; +$spinner_m->set_wrap(1); +$hbox2->pack_start($spinner_m, 0, 0, 0); +my $adj_s = new Gtk::Adjustment 0.0, 0.0, 59.0, 1.0, 5.0, 0.0; +my $spinner_s = new Gtk::SpinButton $adj_s, 0, 0; +$spinner_s->set_wrap(1); +$hbox2->pack_start($spinner_s, 0, 0, 0); + +my $bbox = new Gtk::HButtonBox; +$bbox->set_layout(-end); +$vbox->pack_start($bbox, 1, 1, 5); +my $button_ok = new Gtk::Button "OK"; +$bbox->add($button_ok ); +my $button_cancel = new Gtk::Button "Cancel"; +$bbox->add($button_cancel ); +my $button_reset = new Gtk::Button "Reset"; +$button_reset->signal_connect ( clicked => sub { + $timer=Gtk->timeout_add(120, sub { time_to_rad(); Repaint($drawing_area) }); + time_to_rad(); Repaint($drawing_area); + $button_reset->set_sensitive(0); + }); +$bbox->add($button_reset); +$button_reset->set_sensitive(0); + $window->show_all; $timer=Gtk->timeout_add(120, sub { time_to_rad(); Repaint($drawing_area) }); @@ -40,8 +78,11 @@ Gtk->main; sub motion_event { my ($widget, $event) = @_; $pressed or return; - $first and Gtk->timeout_remove($timer); - $first and $Radian = determine_radian($event->{'x'}, $event->{'y'}); + if ($first) { + Gtk->timeout_remove($timer); + $Radian = determine_radian($event->{'x'}, $event->{'y'}); + $button_reset->set_sensitive(1); + } $$Radian=-atan2(($event->{'x'}-$midx),($event->{'y'}-$midy)) + $pi; Repaint($widget); @@ -100,7 +141,7 @@ sub Repaint $drawing_area->allocation->[3]); $midx = $drawing_area->allocation->[2] / 2; $midy = $drawing_area->allocation->[3] / 2; - $radius = $midx < $midy ? $midx : $midy; + $radius = $midx < $midy ? $midx -10 : $midy - 10; my $nHour; my $gray_gc = $drawing_area->style->bg_gc('normal'); -- cgit v1.2.1