- Main Page
- Classes
- Files

- File List

# C:/Documents and Settings/Administrator/Desktop/woopsi-src-0.40/Woopsi/libwoopsi/include/woopsi.h

    00001 #ifndef _WOOPSI_H_
    00002 #define _WOOPSI_H_
    00003
    00004 #include <nds.h>
    00005 #include <vector>
    00006 #include "gadget.h"
    00007
    00008 namespace WoopsiUI {
    00009
    00010         class Screen;
    00011         class ContextMenu;
    00012         class WoopsiTimer;
    00013
    00017         class Woopsi : public Gadget {
    00018
    00019         public:
    00025                 static Woopsi *singleton;
    00026
    00031                 Woopsi(FontBase* font = NULL);
    00032
    00036                 virtual ~Woopsi();
    00037
    00045                 virtual inline void startup() { };
    00046
    00051                 void goModal();
    00052
    00061                 virtual inline void shutdown() {
    00062         #ifdef USING_SDL
    00063                         SDL_Quit();
    00064         #endif
    00065                 };
    00066
    00073                 virtual void processOneVBL(Gadget* gadget = NULL);
    00074
    00081                 virtual void draw(Rect clipRect);
    00082
    00089                 virtual bool click(s16 x, s16 y);
    00090
    00097                 virtual bool shiftClick(s16 x, s16 y);
    00098
    00105                 virtual bool release(s16 x, s16 y);
    00106
    00115                 virtual bool drag(s16 x, s16 y, s16 vX, s16 vY);
    00116
    00123                 virtual bool swapGadgetDepth(Gadget* gadget);
    00124
    00131                 virtual bool flipScreens(Gadget* gadget);
    00132
    00137                 virtual void eraseRect(Rect rect);
    00138
    00143                 static FontBase* getSystemFont();
    00144
    00151                 static void registerForVBL(WoopsiTimer* timer);
    00152
    00159                 static void unregisterFromVBL(WoopsiTimer* timer);
    00160
    00166                 static void addToDeleteQueue(Gadget* gadget);
    00167
    00173                 static inline u32 getVBLCount() { return _vblCount; };
    00174
    00179                 inline ContextMenu* getContextMenu() { return _contextMenu; };
    00180
    00185                 void shelveContextMenu();
    00186
    00190                 virtual inline int main(int argc, char* argv[]) {
    00191                         startup();                              // Run any setup code
    00192                         goModal();                              // Run the main Woopsi loop
    00193                         shutdown();                             // Run any shutdown code
    00194
    00195                         return 0;
    00196                 };
    00197
    00203                 inline void setClickedGadget(Gadget* gadget) {
    00204
    00205                         // Do we have a clicked gadget already?
    00206                         if (_clickedGadget != NULL) {
    00207
    00208                                 // Ensure that the existing clicked gadget is released *outside* its bounds
    00209                                 _clickedGadget->release(_clickedGadget->getX() - 10, 0);
    00210                         }
    00211
    00212                         // Update the pointer
    00213                         _clickedGadget = gadget;
    00214                 };
    00215
    00220                 inline Gadget* getClickedGadget() { return _clickedGadget; };
    00221
    00222         protected:
    00223                 bool _lidClosed;
    00225                 static WoopsiArray<WoopsiTimer*> _vblListeners;
    00226                 static WoopsiArray<Gadget*> _deleteQueue;
    00227                 static FontBase* _systemFont;
    00228                 static u32 _vblCount;
    00229                 ContextMenu* _contextMenu;
    00230                 Gadget* _clickedGadget;
    00236                 virtual void closeChild(Gadget* gadget);
    00237
    00242                 virtual void shelveChild(Gadget* gadget);
    00243
    00247                 void processDeleteQueue();
    00248
    00254                 virtual void handleStylus(Gadget* gadget);
    00255
    00259                 virtual void handleKeys();
    00260
    00264                 virtual void handleLid();
    00265
    00269                 virtual void handleVBL();
    00270
    00278                 virtual bool click(s16 x, s16 y, Gadget* gadget);
    00279
    00287                 virtual bool shiftClick(s16 x, s16 y, Gadget* gadget);
    00288
    00292                 inline Woopsi(const Woopsi& woopsi) : Gadget(woopsi) { };
    00293         };
    00294 }
    00295
    00299 #define woopsiApplication (Woopsi::singleton)
    00300
    00301 #endif