- Main Page
- Classes
- Files

- File List

# 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
    00019         class Woopsi : public Gadget {
    00020
    00021         public:
    00027                 static Woopsi *singleton;
    00028
    00036                 Woopsi(GadgetStyle* style = NULL);
    00037
    00041                 virtual ~Woopsi();
    00042
    00047                 void goModal();
    00048
    00055                 virtual void processOneVBL(Gadget* gadget = NULL);
    00056
    00063                 virtual bool swapGadgetDepth(Gadget* gadget);
    00064
    00071                 virtual bool flipScreens(Gadget* gadget);
    00072
    00077                 virtual void eraseRect(Rect rect);
    00078
    00085                 static void registerForVBL(WoopsiTimer* timer);
    00086
    00093                 static void unregisterFromVBL(WoopsiTimer* timer);
    00094
    00100                 static void addToDeleteQueue(Gadget* gadget);
    00101
    00107                 static inline u32 getVBLCount() { return _vblCount; };
    00108
    00113                 inline ContextMenu* getContextMenu() { return _contextMenu; };
    00114
    00119                 void shelveContextMenu();
    00120
    00124                 virtual inline int main(int argc, char* argv[]) {
    00125                         startup();                              // Run any setup code
    00126                         goModal();                              // Run the main Woopsi loop
    00127                         shutdown();                             // Run any shutdown code
    00128
    00129                         return 0;
    00130                 };
    00131
    00137                 void setClickedGadget(Gadget* gadget);
    00138
    00143                 inline Gadget* getClickedGadget() { return _clickedGadget; };
    00144
    00151                 void showKeyboard(KeyboardEventHandler* opener);
    00152
    00158                 void hideKeyboard();
    00159
    00160         protected:
    00161                 bool _lidClosed;
    00163                 static WoopsiArray<WoopsiTimer*> _vblListeners;
    00164                 static WoopsiArray<Gadget*> _deleteQueue;
    00165                 static u32 _vblCount;
    00166                 ContextMenu* _contextMenu;
    00167                 Gadget* _clickedGadget;
    00168                 WoopsiKeyboardScreen* _keyboardScreen;
    00176                 virtual void startup() = 0;
    00177
    00186                 virtual inline void shutdown() {
    00187         #ifdef USING_SDL
    00188                         SDL_Quit();
    00189         #endif
    00190                 };
    00191
    00201                 void handleClick(s16 x, s16 y, Gadget* gadget);
    00202
    00211                 void handleShiftClick(s16 x, s16 y, Gadget* gadget);
    00212
    00216                 void processDeleteQueue();
    00217
    00223                 virtual void handleStylus(Gadget* gadget);
    00224
    00228                 virtual void handleKeys();
    00229
    00239                 void handleKey(bool newPress, bool released, u32& heldTime, KeyCode keyCode);
    00240
    00244                 virtual void handleLid();
    00245
    00249                 virtual void handleVBL();
    00250
    00254                 inline Woopsi(const Woopsi& woopsi) : Gadget(woopsi) { };
    00255         };
    00256 }
    00257
    00261 #define woopsiApplication (Woopsi::singleton)
    00262
    00263 #endif