Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
244 chris 1
#ifndef __WIDGETMANAGER_H__
2
#define __WIDGETMANAGER_H__
3
 
4
#include "Common.h"
5
#include "KeyCodes.h"
6
#include "WidgetContainer.h"
7
 
8
namespace Sexy
9
{
10
 
11
class Widget;
12
class Image;
13
class MemoryImage;
14
class SexyAppBase;
15
class Graphics;
16
 
17
typedef std::list<Widget*> WidgetList;
18
 
19
enum
20
{
21
        WIDGETFLAGS_UPDATE                      = 1,
22
        WIDGETFLAGS_MARK_DIRTY          = 2,
23
        WIDGETFLAGS_DRAW                        = 4,
24
        WIDGETFLAGS_CLIP                        = 8,   
25
        WIDGETFLAGS_ALLOW_MOUSE         = 16,
26
        WIDGETFLAGS_ALLOW_FOCUS         = 32,  
27
};
28
 
29
class PreModalInfo
30
{
31
public:
32
        Widget*                                 mBaseModalWidget;
33
        Widget*                                 mPrevBaseModalWidget;
34
        Widget*                                 mPrevFocusWidget;
35
        FlagsMod                                mPrevBelowModalFlagsMod;
36
};
37
 
38
typedef std::list<PreModalInfo> PreModalInfoList;
39
 
40
typedef std::vector<std::pair<Widget*, int> > DeferredOverlayVector;
41
 
42
class WidgetManager : public WidgetContainer
43
{
44
public:
45
        Widget*                                 mDefaultTab;
46
 
47
        Graphics*                               mCurG;
48
        SexyAppBase*                    mApp;
49
        MemoryImage*                    mImage;
50
        MemoryImage*                    mTransientImage;
51
        bool                                    mLastHadTransients;    
52
        Widget*                                 mPopupCommandWidget;   
53
        DeferredOverlayVector   mDeferredOverlayWidgets;
54
        int                                             mMinDeferredOverlayPriority;
55
 
56
        bool                                    mHasFocus;
57
        Widget*                                 mFocusWidget;
58
        Widget*                                 mLastDownWidget;
59
        Widget*                                 mOverWidget;
60
        Widget*                                 mBaseModalWidget;
61
        FlagsMod                                mLostFocusFlagsMod;
62
        FlagsMod                                mBelowModalFlagsMod;
63
        FlagsMod                                mDefaultBelowModalFlagsMod;
64
        PreModalInfoList                mPreModalInfoList;
65
        Rect                                    mMouseDestRect;
66
        Rect                                    mMouseSourceRect;
67
        bool                                    mMouseIn;
68
        int                                             mLastMouseX;
69
        int                                             mLastMouseY;
70
        int                                             mDownButtons;
71
        int                                             mActualDownButtons;
72
        int                                             mLastInputUpdateCnt;
73
 
74
        bool                                    mKeyDown[0xFF];
75
        int                                             mLastDownButtonId;     
76
 
77
        int                                             mWidgetFlags;
78
 
79
protected:
80
        int                                             GetWidgetFlags();
81
        void                                    MouseEnter(Widget* theWidget);
82
        void                                    MouseLeave(Widget* theWidget);
83
 
84
protected:
85
        void                                    SetBaseModal(Widget* theWidget, const FlagsMod& theBelowFlagsMod);
86
 
87
public:
88
        WidgetManager(SexyAppBase* theApplet);
89
        virtual ~WidgetManager();
90
 
91
        void                                    FreeResources();               
92
        void                                    AddBaseModal(Widget* theWidget, const FlagsMod& theBelowFlagsMod);
93
        void                                    AddBaseModal(Widget* theWidget);
94
        void                                    RemoveBaseModal(Widget* theWidget);
95
        void                                    Resize(const Rect& theMouseDestRect, const Rect& theMouseSourceRect);
96
        void                                    DisableWidget(Widget* theWidget);      
97
        Widget*                                 GetAnyWidgetAt(int x, int y, int* theWidgetX, int* theWidgetY);
98
        Widget*                                 GetWidgetAt(int x, int y, int* theWidgetX, int* theWidgetY);
99
        void                                    SetFocus(Widget* aWidget);
100
        void                                    GotFocus();    
101
        void                                    LostFocus();   
102
        void                                    InitModalFlags(ModalFlags* theModalFlags);
103
        void                                    DrawWidgetsTo(Graphics* g);
104
        void                                    DoMouseUps(Widget* theWidget, ulong theDownCode);      
105
        void                                    DoMouseUps();
106
        void                                    DeferOverlay(Widget* theWidget, int thePriority);
107
        void                                    FlushDeferredOverlayWidgets(int theMaxPriority);
108
 
109
        bool                                    DrawScreen();
110
        bool                                    UpdateFrame();                         
111
        bool                                    UpdateFrameF(float theFrac);
112
        void                                    SetPopupCommandWidget(Widget* theList);
113
        void                                    RemovePopupCommandWidget();    
114
        void                                    MousePosition(int x, int y);   
115
        void                                    RehupMouse();
116
        void                                    RemapMouse(int& theX, int& theY);
117
        bool                                    MouseUp(int x, int y, int theClickCount);
118
        bool                                    MouseDown(int x, int y, int theClickCount);
119
        bool                                    MouseMove(int x, int y);
120
        bool                                    MouseDrag(int x, int y);
121
        bool                                    MouseExit(int x, int y);
122
        void                                    MouseWheel(int theDelta);
123
        bool                                    KeyChar(SexyChar theChar);
124
        bool                                    KeyDown(KeyCode key);
125
        bool                                    KeyUp(KeyCode key);
126
 
127
        bool                                    IsLeftButtonDown();
128
        bool                                    IsMiddleButtonDown();
129
        bool                                    IsRightButtonDown();
130
};
131
 
132
}
133
 
134
#endif // __WIDGETMANAGER_H__