Woopsi 1.3
Nintendo DS Gui Framework
libwoopsi/include/woopsi.h
00001 #ifndef _WOOPSI_H_
00002 #define _WOOPSI_H_
00003 
00004 #include <nds.h>
00005 #include "gadget.h"
00006 #include "gadgetstyle.h"
00007 
00008 namespace WoopsiUI {
00009 
00010     class Screen;
00011     class ContextMenu;
00012     class WoopsiTimer;
00013     class WoopsiKeyboardScreen;
00014     class KeyboardEventHandler;
00015     class DamagedRectManager;
00016 
00021     class Woopsi : public Gadget {
00022 
00023     public:
00029         static Woopsi *singleton;
00030         
00038         Woopsi(GadgetStyle* style = NULL);
00039         
00043         virtual ~Woopsi();
00044 
00051         virtual void processOneVBL(Gadget* gadget = NULL);
00052 
00059         virtual bool flipScreens(Gadget* gadget);
00060 
00067         void registerForVBL(WoopsiTimer* timer);
00068 
00075         void unregisterFromVBL(WoopsiTimer* timer);
00076 
00082         void addToDeleteQueue(Gadget* gadget);
00083 
00090         inline u32 getVBLCount() { return _vblCount; };
00091 
00096         inline ContextMenu* getContextMenu() { return _contextMenu; };
00097 
00102         void shelveContextMenu();
00103 
00107         virtual inline int main(int argc, char* argv[]) {
00108             startup();              // Run any setup code
00109             goModal();              // Run the main Woopsi loop
00110             shutdown();             // Run any shutdown code
00111 
00112             return 0;
00113         };
00114 
00120         void setClickedGadget(Gadget* gadget);
00121 
00126         inline Gadget* getClickedGadget() { return _clickedGadget; };
00127 
00134         void showKeyboard(KeyboardEventHandler* opener);
00135         
00141         void hideKeyboard();
00142 
00147         DamagedRectManager* getDamagedRectManager() { return _damagedRectManager; };
00148 
00149     protected:
00150         bool _lidClosed;                                    
00152         WoopsiArray<WoopsiTimer*> _vblListeners;            
00153         WoopsiArray<Gadget*> _deleteQueue;                  
00154         u32 _vblCount;                                      
00155         ContextMenu* _contextMenu;                          
00156         Gadget* _clickedGadget;                             
00157         WoopsiKeyboardScreen* _keyboardScreen;              
00158         DamagedRectManager* _damagedRectManager;            
00164         virtual void startup() = 0;
00165 
00175         virtual inline void shutdown() {
00176     #ifdef USING_SDL
00177             SDL_Quit();
00178     #endif
00179         };
00180 
00190         void handleClick(s16 x, s16 y, Gadget* gadget);
00191 
00200         void handleShiftClick(s16 x, s16 y, Gadget* gadget);
00201 
00205         void processDeleteQueue();
00206 
00212         virtual void handleStylus(Gadget* gadget);
00213 
00217         virtual void handleKeys();
00218 
00228         void handleKey(bool newPress, bool released, s32& heldTime, KeyCode keyCode);
00229 
00233         virtual void handleLid();
00234 
00238         virtual void handleVBL();
00239 
00243         inline Woopsi(const Woopsi& woopsi) : Gadget(woopsi) { };
00244     };
00245 }
00246 
00250 #define woopsiApplication (Woopsi::singleton)
00251 
00252 #endif
 All Classes Functions Variables Enumerations Enumerator