Woopsi 1.0 GUI Framework for Nintendo DS Homebrew

- 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         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
    00049                 void goModal();
    00050
    00057                 virtual void processOneVBL(Gadget* gadget = NULL);
    00058
    00065                 virtual bool swapGadgetDepth(Gadget* gadget);
    00066
    00073                 virtual bool flipScreens(Gadget* gadget);
    00074
    00081                 static void registerForVBL(WoopsiTimer* timer);
    00082
    00089                 static void unregisterFromVBL(WoopsiTimer* timer);
    00090
    00096                 static void addToDeleteQueue(Gadget* gadget);
    00097
    00104                 static inline u32 getVBLCount() { return _vblCount; };
    00105
    00110                 inline ContextMenu* getContextMenu() { return _contextMenu; };
    00111
    00116                 void shelveContextMenu();
    00117
    00121                 virtual inline int main(int argc, char* argv[]) {
    00122                         startup();                              // Run any setup code
    00123                         goModal();                              // Run the main Woopsi loop
    00124                         shutdown();                             // Run any shutdown code
    00125
    00126                         return 0;
    00127                 };
    00128
    00134                 void setClickedGadget(Gadget* gadget);
    00135
    00140                 inline Gadget* getClickedGadget() { return _clickedGadget; };
    00141
    00148                 void showKeyboard(KeyboardEventHandler* opener);
    00149
    00155                 void hideKeyboard();
    00156
    00161                 DamagedRectManager* getDamagedRectManager() { return _damagedRectManager; };
    00162
    00163         protected:
    00164                 bool _lidClosed;
    00166                 static WoopsiArray<WoopsiTimer*> _vblListeners;
    00167                 static WoopsiArray<Gadget*> _deleteQueue;
    00168                 static u32 _vblCount;
    00169                 ContextMenu* _contextMenu;
    00170                 Gadget* _clickedGadget;
    00171                 WoopsiKeyboardScreen* _keyboardScreen;
    00172                 DamagedRectManager* _damagedRectManager;
    00178                 virtual void startup() = 0;
    00179
    00189                 virtual inline void shutdown() {
    00190         #ifdef USING_SDL
    00191                         SDL_Quit();
    00192         #endif
    00193                 };
    00194
    00204                 void handleClick(s16 x, s16 y, Gadget* gadget);
    00205
    00214                 void handleShiftClick(s16 x, s16 y, Gadget* gadget);
    00215
    00219                 void processDeleteQueue();
    00220
    00226                 virtual void handleStylus(Gadget* gadget);
    00227
    00231                 virtual void handleKeys();
    00232
    00242                 void handleKey(bool newPress, bool released, s32& heldTime, KeyCode keyCode);
    00243
    00247                 virtual void handleLid();
    00248
    00252                 virtual void handleVBL();
    00253
    00257                 inline Woopsi(const Woopsi& woopsi) : Gadget(woopsi) { };
    00258         };
    00259 }
    00260
    00264 #define woopsiApplication (Woopsi::singleton)
    00265
    00266 #endif