Woopsi 1.0
GUI Framework for Nintendo DS Homebrew

calendar.h

00001 #ifndef _CALENDAR_H_
00002 #define _CALENDAR_H_
00003 
00004 #include <nds.h>
00005 #include "gadget.h"
00006 #include "gadgetstyle.h"
00007 #include "gadgeteventhandler.h"
00008 #include "stickybutton.h"
00009 
00010 #define CALENDAR_ROWS 8
00011 #define CALENDAR_COLS 7
00012 #define CALENDAR_BODY_ROWS 6
00013 
00014 namespace WoopsiUI {
00015 
00016         class Button;
00017         class Label;
00018         class Date;
00019 
00024         class Calendar : public Gadget, public GadgetEventHandler {
00025         public:
00026 
00042                 Calendar(s16 x, s16 y, u16 width, u16 height, u8 day, u8 month, u16 year, u32 flags, GadgetStyle* style = NULL);
00043 
00048                 virtual void handleReleaseEvent(const GadgetEventArgs& e);
00049 
00056                 virtual void setDate(u8 day, u8 month, u16 year);
00057 
00062                 const u8 getDay() const;
00063 
00068                 const u8 getMonth() const;
00069 
00074                 const u16 getYear() const;
00075 
00082                 virtual void getPreferredDimensions(Rect& rect) const;
00083 
00084         protected:
00085                 Date* _date;                                                    
00086                 Date* _visibleDate;                                             
00087                 StickyButton* _selectedDayButton;               
00088                 Button* _leftArrow;                                             
00089                 Button* _rightArrow;                                    
00090                 Label* _monthLabel;                                             
00098                 virtual void drawContents(GraphicsPort* port);
00099 
00106                 virtual void drawBorder(GraphicsPort* port);
00107 
00113                 void onResize(u16 width, u16 height);
00114 
00118                 virtual ~Calendar();
00119 
00123                 virtual void buildGUI();
00124 
00129                 virtual void populateGUI();
00130 
00134                 inline Calendar(const Calendar& calendar) : Gadget(calendar) { };
00135 
00142                 void calculateColumnWidths(s32 spaceWidth, u8* columnWidths);
00143 
00150                 void calculateColumnHeights(s32 spaceHeight, u8* columnHeights);
00151         };
00152 }
00153 
00154 #endif