3 #include "GUIContainer.h" 5 #include "GUIToolTip.h" 6 #include "SpriteRenderer.h" 7 #include "util/mutex.h" 15 #ifndef KEYBUFFER_SIZE 16 #define KEYBUFFER_SIZE 15 20 class CTouchGesturePinch;
22 typedef std::vector<MSG> GUIMsgEventList_type;
25 struct AccelerometerEvent;
26 class TouchEventSession;
63 ATTRIBUTE_METHOD1(
CGUIRoot, GetUIScale_s,
Vector2*) {
float x, y; cls->GetUIScale(&x, &y); p1->x = x; p1->y = y;
return S_OK; }
64 ATTRIBUTE_METHOD1(
CGUIRoot, SetUIScale_s,
Vector2) { cls->SetUIScale(p1.x, p1.y);
return S_OK; }
66 ATTRIBUTE_METHOD1(
CGUIRoot, GetBackBufferSize_s,
Vector2*) { cls->GetBackBufferSize(&(p1->x), &(p1->y));
return S_OK; }
68 ATTRIBUTE_METHOD1(
CGUIRoot, GetMousePosition_s,
Vector2*) {
int x, y; cls->GetMousePosition(&x, &y); p1->x = (float)x; p1->y = (float)y;
return S_OK; }
69 ATTRIBUTE_METHOD1(
CGUIRoot, SetMousePosition_s,
Vector2) { cls->SetMousePosition((
int)(p1.x), (
int)(p1.y));
return S_OK; }
71 ATTRIBUTE_METHOD1(
CGUIRoot, GetHasIMEFocus_s,
bool*) { *p1 = cls->HasIMEFocus();
return S_OK; }
72 ATTRIBUTE_METHOD1(
CGUIRoot, SetHasIMEFocus_s,
bool) { cls->SetHasIMEFocus(p1);
return S_OK; }
74 ATTRIBUTE_METHOD1(
CGUIRoot, GetEnableIME_s,
bool*) { *p1 = cls->GetEnableIME();
return S_OK; }
75 ATTRIBUTE_METHOD1(
CGUIRoot, SetEnableIME_s,
bool) { cls->SetEnableIME(p1);
return S_OK; }
77 ATTRIBUTE_METHOD1(
CGUIRoot, GetUseSystemCursor_s,
bool*) { *p1 = cls->GetUseSystemCursor();
return S_OK; }
78 ATTRIBUTE_METHOD1(
CGUIRoot, SetUseSystemCursor_s,
bool) { cls->SetUseSystemCursor(p1);
return S_OK; }
80 ATTRIBUTE_METHOD1(
CGUIRoot, GetFingerSizePixels_s,
int*) { *p1 = cls->GetFingerSizePixels();
return S_OK; }
81 ATTRIBUTE_METHOD1(
CGUIRoot, SetFingerSizePixels_s,
int) { cls->SetFingerSizePixels(p1);
return S_OK; }
83 ATTRIBUTE_METHOD1(
CGUIRoot, GetFingerStepSizePixels_s,
int*) { *p1 = cls->GetFingerStepSizePixels();
return S_OK; }
84 ATTRIBUTE_METHOD1(
CGUIRoot, SetFingerStepSizePixels_s,
int) { cls->SetFingerStepSizePixels(p1);
return S_OK; }
86 ATTRIBUTE_METHOD1(
CGUIRoot, SendKeyDownEvent_s,
int) { cls->SendKeyDownEvent(p1);
return S_OK; }
87 ATTRIBUTE_METHOD1(
CGUIRoot, SendKeyUpEvent_s,
int) { cls->SendKeyUpEvent(p1);
return S_OK; }
89 ATTRIBUTE_METHOD1(
CGUIRoot, IsMouseButtonSwapped_s,
bool*) { *p1 = cls->IsMouseButtonSwapped();
return S_OK; }
90 ATTRIBUTE_METHOD1(
CGUIRoot, SetMouseButtonSwapped_s,
bool) { cls->SetMouseButtonSwapped(p1);
return S_OK; }
92 ATTRIBUTE_METHOD1(
CGUIRoot, SendInputMethodEvent_s,
const char*) { cls->SendInputMethodEvent(p1);
return S_OK; }
94 ATTRIBUTE_METHOD1(
CGUIRoot, SetMinimumScreenSize_s,
Vector2) { cls->SetMinimumScreenSize((
int)(p1.x), (
int)(p1.y));
return S_OK; }
96 ATTRIBUTE_METHOD1(
CGUIRoot, IsMouseCaptured_s,
bool*) { *p1 = cls->IsMouseCaptured();
return S_OK; }
97 ATTRIBUTE_METHOD1(
CGUIRoot, SetCaptureMouse_s,
bool) { cls->SetCaptureMouse(p1);
return S_OK; }
99 ATTRIBUTE_METHOD1(
CGUIRoot, IsNonClient_s,
bool*) { *p1 = cls->IsNonClient();
return S_OK; }
100 ATTRIBUTE_METHOD1(
CGUIRoot, SetIsNonClient_s,
bool) { cls->SetIsNonClient(p1);
return S_OK; }
106 void SetCaptureMouse(
bool bCapture);
107 bool IsMouseCaptured();
109 bool PushEvent(
const MSG& msg);
110 bool handleTouchEvent(
const TouchEvent& touch);
111 bool handleNonClientTest(
const MouseEvent& mouseEvent);
114 void TranslateMousePointInTouchEvent(
TouchEvent &touch);
122 void SetUIScale(
float fScalingX,
float fScalingY,
bool bEnsureMinimumScreenSize =
true,
bool bNotifySizeChange =
true);
128 void GetUIScale(
float* pfScalingX = NULL,
float* pfScalingY = NULL);
131 void GetBackBufferSize(
float* pWidth,
float* pHeight);
140 void SetMinimumScreenSize(
int nWidth,
int nHeight,
bool bAutoUIScaling =
true);
146 bool UpdateViewport(
int nLeft,
int nTop,
int nWidth,
int nHeight,
bool bForceUpdate =
false);
161 void ClearAllTopLevelControls();
177 static void DeleteGUIObject(
CGUIBase * pObj);
179 static void PostDeleteGUIObject(
CGUIBase * pObj);
192 void DetachGUIElement(
CGUIBase* pChild);
199 int DestroyGUIElement(
CGUIBase* pObj);
207 int DestroyGUIElement(
const char* sID);
214 CGUIBase* GetUIObject(
const char * strObjectName);
215 CGUIBase* GetUIObject(
const std::string& strObjectName);
230 CGUIBase* GetUIObject(
int x,
int y);
240 CGUIBase* GetDefaultObject(
const char *strType);
250 void SetUIKeyFocus(
CGUIBase* control);
260 void SetUIMouseFocus(
CGUIBase* control);
263 void UseDefaultMouseCursor(
bool bUseDefaultMouseCursor);
275 int HandleUserInput();
281 void SendKeyDownEvent(
int nVirtualkey);
282 void SendKeyUpEvent(
int nVirtualkey);
283 void SendInputMethodEvent(
const char* pStr);
286 bool IsMouseButtonSwapped();
287 void SetMouseButtonSwapped(
bool bSwapped);
289 bool DispatchKeyboardMsg(
bool bKeyHandled);
291 void DispatchTouchMouseEvent(
bool &bMouseHandled);
294 virtual bool MsgProc(
MSG *event);
298 virtual void Reset();
303 virtual void DestroyChildren();
316 void AdvanceGUI(
float fElapsedTime);
321 HRESULT OneTimeGUIInit();
322 LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
bool &bNoFurtherProcess);
324 virtual HRESULT Render(
GUIState* pGUIState,
float fElapsedTime);
325 virtual bool OnClick(
int MouseState,
int X,
int Y);
327 virtual HRESULT InitDeviceObjects();
328 HRESULT RestoreDeviceObjects(UINT nBkbufWidth, UINT nBkbufHeight);
329 virtual HRESULT InvalidateDeviceObjects();
330 virtual HRESULT DeleteDeviceObjects();
331 virtual int Release();
332 virtual string ToScript(
int option = 0);
335 void SetMouseInClient(
bool bMouseInClient);
336 bool GetMouseInClient();
338 bool CheckLoadCursor();
343 void InactivateRoot();
348 bool IsKeyboardProcessed();
349 bool IsMouseProcessed();
354 bool IsNonClient()
const;
355 void SetIsNonClient(
bool val);
362 void GetMousePosition(
int* nX,
int* nY)
const;
364 void SetMousePosition(
int nX,
int nY);
367 int GetFingerSizePixels()
const;
368 void SetFingerSizePixels(
int val);
370 int GetFingerStepSizePixels()
const;
371 void SetFingerStepSizePixels(
int val);
373 Matrix4* Get3DViewProjMatrix(){
return &m_matViewProj; };
374 void Set3DViewProjMatrix(
const Matrix4& mat){ m_matViewProj = mat; };
375 #ifdef USE_DIRECTX_RENDERER 376 DEVMODE *GetDisplayMode(){
return &m_displaymode;}
379 void AddToNameMap(
const string& name,
CGUIBase* pObj);
381 void AddToIDMap(
int nID,
CGUIBase* pObj);
383 std::map <string, CGUIBase*> m_namemap;
384 std::map <int, CGUIBase*> m_idmap;
389 static void DeleteInstance(
CGUIRoot* pThis = NULL);
392 void SetRenderImageCursor(
bool bEnable);
395 void SetUseSystemCursor(
bool bUseSystem);
398 bool GetUseSystemCursor();
400 virtual const IType* GetType()
const{
return m_type; }
404 void SetHasIMEFocus(
bool bHasFocus);
408 void SetEnableIME(
bool bHasIME);
413 void EnableClipCursor(
bool bEnable);
416 bool IsCursorClipped();
419 void SetActiveWindow(
CGUIBase* val);
427 virtual int metric(PaintDeviceMetric metric)
const;
428 virtual float GetUIScalingX()
const;
429 virtual float GetUIScalingY()
const;
430 virtual float GetViewportLeft()
const;
431 virtual float GetViewportTop()
const;
441 void Update3DObject(
float fElapsedTime);
444 void UpdateCursorPosition();
446 void TranslateMousePos(
int &inout_x,
int &inout_y);
448 void TranslateTouchEvent(
const TouchEvent &touch);
452 bool AutoLocateTouchClick(
int ui_mouse_x,
int ui_mouse_y,
int &mouse_x,
int &mouse_y);
455 static DWORD WheelScrollLines;
456 static DWORD KeyDelay;
457 static DWORD KeyRepeat;
458 static DWORD MouseDelay;
459 static DWORD MouseRepeat;
460 static DWORD MouseHover;
461 static int MouseThreshold1;
462 static int MouseThreshold2;
463 static DWORD MouseAcceleration;
464 static float MouseSpeed;
494 static const IType* m_type;
498 bool m_bIsCursorClipped;
499 RECT m_rcOldClipRect;
500 bool m_bMouseProcessed;
501 bool m_bKeyboardProcessed;
502 bool m_bMouseCaptured;
505 #ifdef USE_DIRECTX_RENDERER 506 DEVMODE m_displaymode;
509 bool m_bMouseInClient;
510 bool m_bWindowChanging;
511 bool m_bRenderImageCursor;
512 bool m_bUseSystemCursor;
514 vector<int> m_deleteQueue;
520 float m_fViewportLeft;
521 float m_fViewportTop;
522 float m_fViewportWidth;
523 float m_fViewportHeight;
541 int m_nFingerStepSizePixels;
IType is for type information and validating It contains type information of an object.
Definition: Type.h:75
Touch gesture recognizer.
Definition: TouchGesturePinch.h:8
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
bool m_bHasIMEFocus
whether there is a visible IME virtual CGUIIMEEditBox that has key focus.
Definition: GUIRoot.h:534
Definition: EventBinding.h:22
float m_fMinScreenHeight
the minimum screen height.
Definition: GUIRoot.h:531
ParaEngine::mutex m_mutex
mostly for the ime focus.
Definition: GUIRoot.h:548
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: ManagedDef.h:18
std::map< int, int > m_touch_id_to_ui_obj
mapping from touch id to ui object.
Definition: GUIRoot.h:545
float m_fMinScreenWidth
the minimum screen width.
Definition: GUIRoot.h:528
simple mouse event struct
Definition: EventClasses.h:27
Definition: GUIDirectInput.h:106
GUIMsgEventList_type m_events
GUI root's mouse events.
Definition: GUIRoot.h:472
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: GUIRoot.h:55
base object for all 2D GUI objects (1) 2D GUI object are not tested against view frustum, instead it is controlled by visibility tag automatically or through user input.
Definition: GUIBase.h:54
IAttributeFields * m_pLastMouseDownObject
please note this can be the 3d scene object.
Definition: GUIRoot.h:504
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
vector< CGUIContainer * > m_TopLevelCtrls
the top level controls in a array, m_TopCtrl[0] always refers to the top level, m_TopCtrl[1] refers t...
Definition: GUIRoot.h:491
Definition: GUIDirectInput.h:112
touch event
Definition: EventClasses.h:118
m_objResource->m_objArtwork->DrawingRects[0]: client rectangle; m_objResource->m_objArtwork->DrawingR...
Definition: GUIContainer.h:19
base class for a surface to paint to.
Definition: Painter.h:38
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
It's used as parameter to Render method of each GUI object.
Definition: GUIState.h:16
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: GUIRoot.h:59
bool m_bIsNonClient
whether the mouse is in non-client area, we will allow the user to drag the window if this is true...
Definition: GUIRoot.h:538
A common interface for all classes implementing IAttributeFields By implementing this class's virtual...
Definition: IAttributeFields.h:59
The CPaintEngine class provides an abstract definition of how CPainter draws to a given device on a g...
Definition: PaintEngine.h:34
the total 3d vector of force that is currently on the device, including gravity.
Definition: EventClasses.h:162
int m_nFingerSizePixels
touch finger size in pixels.
Definition: GUIRoot.h:540
CGUIContainer * GetTopLevelControl()
get the top level control at level 0
Definition: GUIRoot.h:166
CGUIBase * m_pActiveWindow
last active GUI object object who has onactivate event handler in script.
Definition: GUIRoot.h:552
int m_nLastTouchX
last touch position in mobile version.
Definition: GUIRoot.h:543
bool m_bActive
if the gui is active
Definition: GUIRoot.h:487
cross platform mutex
Definition: mutex.h:95
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object's name
Definition: GUIRoot.h:57
When rendering scene, root scene and the root GUI are rendered in sequence.
Definition: GUIRoot.h:48