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