From 45e143dd0cdf465a6f1eb8121435997ff808b860 Mon Sep 17 00:00:00 2001 From: "jean.chalard" Date: Thu, 1 Jan 2009 23:27:32 +0000 Subject: [PATCH] J : * Clean carriage returns. --- JGE/include/JGui.h | 228 ++++++++++++++++++++++----------------------- 1 file changed, 112 insertions(+), 116 deletions(-) diff --git a/JGE/include/JGui.h b/JGE/include/JGui.h index 432e664a4..f516ebb80 100644 --- a/JGE/include/JGui.h +++ b/JGE/include/JGui.h @@ -1,116 +1,112 @@ -//------------------------------------------------------------------------------------- -// -// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. -// -// Licensed under the BSD license, see LICENSE in JGE root for details. -// -// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) -// -//------------------------------------------------------------------------------------- - - -#ifndef _JGUI_H -#define _JGUI_H - -#include "JGE.h" -#include "JSprite.h" - -#define MAX_GUIOBJECT 64 - -#define JGUI_STYLE_LEFTRIGHT 0x01 -#define JGUI_STYLE_UPDOWN 0x02 -#define JGUI_STYLE_WRAPPING 0x04 - -#define JGUI_INITIAL_DELAY 0.4 -#define JGUI_REPEAT_DELAY 0.2 - -class JGuiListener -{ -public: - virtual ~JGuiListener() {} - virtual void ButtonPressed(int controllerId, int controlId) = 0; -}; - - -class JGuiObject -{ -protected: - static JGE* mEngine; - -private: - int mId; - - -public: - JGuiObject(int id); - virtual ~JGuiObject(); - - virtual void Render() = 0; - virtual void Update(float dt); - - virtual void Entering(); // when focus is transferring to this obj - virtual bool Leaving(u32 key); // when focus is transferring away from this obj, true to go ahead - virtual bool ButtonPressed(); // action button pressed, return false to ignore - - int GetId(); -}; - - -class JGuiController -{ -protected: - static JGE* mEngine; - - int mId; - bool mActive; - - - u32 mActionButton; - int mCurr; - int mStyle; - - JSprite* mCursor; - bool mShowCursor; - int mCursorX; - int mCursorY; - - int mBgX; - int mBgY; - const JTexture* mBg; - PIXEL_TYPE mShadingColor; - Rect* mShadingBg; - - JGuiListener* mListener; - u32 mLastKey; - //int mKeyHoldTime; - float mKeyRepeatDelay; - - bool KeyRepeated(u32 key, float dt); - -public: - JGuiObject* mObjects[MAX_GUIOBJECT]; - int mCount; - - JGuiController(int id, JGuiListener* listener); - ~JGuiController(); - - virtual void Render(); - virtual void Update(float dt); - - void Add(JGuiObject* ctrl); - void Remove(int id); - void Remove(JGuiObject* ctrl); - - void SetActionButton(u32 button); - void SetStyle(int style); - void SetCursor(JSprite* cursor); - - bool IsActive(); - void SetActive(bool flag); - - //void SetImageBackground(const JTexture* tex, int x, int y); - //void SetShadingBackground(int x, int y, int width, int height, PIXEL_TYPE color); -}; - - -#endif +//------------------------------------------------------------------------------------- +// +// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. +// +// Licensed under the BSD license, see LICENSE in JGE root for details. +// +// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) +// +//------------------------------------------------------------------------------------- + + +#ifndef _JGUI_H +#define _JGUI_H + +#include "JGE.h" +#include "JSprite.h" + +#define MAX_GUIOBJECT 64 + +#define JGUI_STYLE_LEFTRIGHT 0x01 +#define JGUI_STYLE_UPDOWN 0x02 +#define JGUI_STYLE_WRAPPING 0x04 + +#define JGUI_INITIAL_DELAY 0.4 +#define JGUI_REPEAT_DELAY 0.2 + +class JGuiListener +{ + public: + virtual ~JGuiListener() {} + virtual void ButtonPressed(int controllerId, int controlId) = 0; +}; + + +class JGuiObject +{ + protected: + static JGE* mEngine; + + private: + int mId; + + + public: + JGuiObject(int id); + virtual ~JGuiObject(); + + virtual void Render() = 0; + virtual void Update(float dt); + + virtual void Entering(); // when focus is transferring to this obj + virtual bool Leaving(u32 key); // when focus is transferring away from this obj, true to go ahead + virtual bool ButtonPressed(); // action button pressed, return false to ignore + + int GetId(); +}; + + +class JGuiController +{ + protected: + static JGE* mEngine; + + int mId; + bool mActive; + + + u32 mActionButton; + int mCurr; + int mStyle; + + JSprite* mCursor; + bool mShowCursor; + int mCursorX; + int mCursorY; + + int mBgX; + int mBgY; + const JTexture* mBg; + PIXEL_TYPE mShadingColor; + Rect* mShadingBg; + + JGuiListener* mListener; + //int mKeyHoldTime; + + public: + JGuiObject* mObjects[MAX_GUIOBJECT]; + int mCount; + + JGuiController(int id, JGuiListener* listener); + ~JGuiController(); + + virtual void Render(); + virtual void Update(float dt); + + void Add(JGuiObject* ctrl); + void Remove(int id); + void Remove(JGuiObject* ctrl); + + void SetActionButton(u32 button); + void SetStyle(int style); + void SetCursor(JSprite* cursor); + + bool IsActive(); + void SetActive(bool flag); + + //void SetImageBackground(const JTexture* tex, int x, int y); + //void SetShadingBackground(int x, int y, int width, int height, PIXEL_TYPE color); +}; + + +#endif