summaryrefslogtreecommitdiff
path: root/apps/plugins/calendar.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-07-27 06:19:01 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-07-27 06:19:01 +0000
commit98c7b81471efc1e757a44490dc0bc9f86855dfcd (patch)
treee06b12f8ddee3957592a2d226ea54550b43cacb5 /apps/plugins/calendar.c
parent6a635ce6eda3e3598b2b69e9e45c652b3b5da952 (diff)
downloadrockbox-98c7b81471efc1e757a44490dc0bc9f86855dfcd.tar.gz
rockbox-98c7b81471efc1e757a44490dc0bc9f86855dfcd.zip
Adapted to new event handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4958 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/calendar.c')
-rw-r--r--apps/plugins/calendar.c79
1 files changed, 48 insertions, 31 deletions
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index 3748ac5dae..92aac21f7a 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -49,6 +49,8 @@ struct shown {
49 49
50static bool use_system_font = false; 50static bool use_system_font = false;
51 51
52static bool been_in_usb_mode = false;
53
52/* leap year -- account for gregorian reformation in 1752 */ 54/* leap year -- account for gregorian reformation in 1752 */
53static int is_leap_year(int yr) 55static int is_leap_year(int yr)
54{ 56{
@@ -306,7 +308,7 @@ static void load_memo(struct shown *shown)
306 308
307static bool save_memo(int changed, bool new_mod, struct shown *shown) 309static bool save_memo(int changed, bool new_mod, struct shown *shown)
308{ 310{
309 int fp,fq; 311 int fp,fq;
310 fp = rb->open("/.rockbox/.memo",O_RDONLY | O_CREAT); 312 fp = rb->open("/.rockbox/.memo",O_RDONLY | O_CREAT);
311 fq = rb->open("/.rockbox/~temp",O_RDWR | O_CREAT | O_TRUNC); 313 fq = rb->open("/.rockbox/~temp",O_RDWR | O_CREAT | O_TRUNC);
312 if ( (fq != -1) && (fp != -1) ) 314 if ( (fq != -1) && (fp != -1) )
@@ -410,29 +412,32 @@ static void add_memo(struct shown *shown, int type)
410static bool edit_memo(int change, struct shown *shown) 412static bool edit_memo(int change, struct shown *shown)
411{ 413{
412 bool exit = false; 414 bool exit = false;
413 rb->lcd_clear_display(); 415 int button;
414 if (memos_in_shown_memory > 0) 416
415 {
416 rb->lcd_puts(0,0,"Remove : Up");
417 rb->lcd_puts(0,1,"Edit : Down");
418 rb->lcd_puts(0,2,"New :");
419 rb->lcd_puts(2,3,"weekly : Left");
420 rb->lcd_puts(2,4,"monthly : Play");
421 rb->lcd_puts(2,5,"annually : Right");
422 rb->lcd_puts(2,6,"one off : On");
423 }
424 else
425 {
426 rb->lcd_puts(0,0,"New :");
427 rb->lcd_puts(2,1,"weekly : Left");
428 rb->lcd_puts(2,2,"monthly : Play");
429 rb->lcd_puts(2,3,"anualy : Right");
430 rb->lcd_puts(2,4,"one off : On");
431 }
432 rb->lcd_update();
433 while (!exit) 417 while (!exit)
434 { 418 {
435 switch (rb->button_get(true)) 419 rb->lcd_clear_display();
420 if (memos_in_shown_memory > 0)
421 {
422 rb->lcd_puts(0,0,"Remove : Up");
423 rb->lcd_puts(0,1,"Edit : Down");
424 rb->lcd_puts(0,2,"New :");
425 rb->lcd_puts(2,3,"weekly : Left");
426 rb->lcd_puts(2,4,"monthly : Play");
427 rb->lcd_puts(2,5,"annually : Right");
428 rb->lcd_puts(2,6,"one off : On");
429 }
430 else
431 {
432 rb->lcd_puts(0,0,"New :");
433 rb->lcd_puts(2,1,"weekly : Left");
434 rb->lcd_puts(2,2,"monthly : Play");
435 rb->lcd_puts(2,3,"anualy : Right");
436 rb->lcd_puts(2,4,"one off : On");
437 }
438 rb->lcd_update();
439 button = rb->button_get(true);
440 switch (button)
436 { 441 {
437 case BUTTON_OFF: 442 case BUTTON_OFF:
438 return false; 443 return false;
@@ -473,8 +478,10 @@ static bool edit_memo(int change, struct shown *shown)
473 } 478 }
474 break; 479 break;
475 480
476 case SYS_USB_CONNECTED: 481 default:
477 return true; 482 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
483 been_in_usb_mode = true;
484 break;
478 } 485 }
479 } 486 }
480 return false; 487 return false;
@@ -542,6 +549,8 @@ static bool any_events(struct shown *shown, bool force)
542{ 549{
543 int lines_displayed = 0; 550 int lines_displayed = 0;
544 bool exit=false; 551 bool exit=false;
552 int button;
553
545 update_memos_shown(shown); 554 update_memos_shown(shown);
546 if (memos_in_shown_memory > 0) 555 if (memos_in_shown_memory > 0)
547 show_lines(lines_displayed,shown); 556 show_lines(lines_displayed,shown);
@@ -552,7 +561,8 @@ static bool any_events(struct shown *shown, bool force)
552 rb->lcd_update(); 561 rb->lcd_update();
553 while (!exit) 562 while (!exit)
554 { 563 {
555 switch (rb->button_get(true)) 564 button = rb->button_get(true);
565 switch (button)
556 { 566 {
557 case BUTTON_DOWN: 567 case BUTTON_DOWN:
558 if (memos_in_shown_memory > 0) 568 if (memos_in_shown_memory > 0)
@@ -582,8 +592,11 @@ static bool any_events(struct shown *shown, bool force)
582 case BUTTON_OFF: 592 case BUTTON_OFF:
583 return false; 593 return false;
584 594
585 case SYS_USB_CONNECTED: 595 default:
586 return true; 596 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
597 been_in_usb_mode = true;
598 show_lines(lines_displayed,shown);
599 break;
587 } 600 }
588 } 601 }
589 return false; 602 return false;
@@ -648,6 +661,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
648 struct today today; 661 struct today today;
649 struct shown shown; 662 struct shown shown;
650 bool exit = false; 663 bool exit = false;
664 int button;
665
651 TEST_PLUGIN_API(api); 666 TEST_PLUGIN_API(api);
652 (void)(parameter); 667 (void)(parameter);
653 668
@@ -659,7 +674,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
659 draw_calendar(&shown); 674 draw_calendar(&shown);
660 while (!exit) 675 while (!exit)
661 { 676 {
662 switch (rb->button_get(true)) 677 button = rb->button_get(true);
678 switch (button)
663 { 679 {
664 case BUTTON_OFF: 680 case BUTTON_OFF:
665 return false; 681 return false;
@@ -700,13 +716,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
700 draw_calendar(&shown); 716 draw_calendar(&shown);
701 break; 717 break;
702 718
703 case SYS_USB_CONNECTED: 719 default:
704 rb->usb_screen(); 720 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
721 been_in_usb_mode = true;
705 draw_calendar(&shown); 722 draw_calendar(&shown);
706 break; 723 break;
707 } 724 }
708 } 725 }
709 return false; 726 return been_in_usb_mode?PLUGIN_USB_CONNECTED:PLUGIN_OK;
710} 727}
711 728
712#endif 729#endif