/*---------------------------------------------------------------------------* Project: Horizon File: GuiControlBase.h Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 46365 $ *---------------------------------------------------------------------------*/ #ifndef NN_COMMON_SCENE_GUICONTROLBASE_H_ #define NN_COMMON_SCENE_GUICONTROLBASE_H_ #include "GuiUtil.h" #include "GuiTypes.h" #include namespace scene { class ControlManager; /* Please see man pages for details */ class ControlBase { public: friend class ControlManager; public: /* Please see man pages for details */ ControlBase(ControlType type, u32 id, s32 x, s32 y, u32 width, u32 height, const wchar_t* pText, void* pExtraData, f32 fontScale); /* Please see man pages for details */ virtual ~ControlBase(); /* Please see man pages for details */ ControlType GetType() const { return m_type; } /* Please see man pages for details */ u32 GetId() const { return m_id; } /* Please see man pages for details */ s32 GetX() const { return m_x; } /* Please see man pages for details */ s32 GetY() const { return m_y; } /* Please see man pages for details */ u32 GetWidth() const { return m_width; } /* Please see man pages for details */ u32 GetHeight() const { return m_height; } /* Please see man pages for details */ const wchar_t* GetText() const { return m_pText; } /* Please see man pages for details */ s32 GetTextLength() const { return m_textLength; } /* Please see man pages for details */ nn::util::Color8 GetBorderColor(ControlState state) const { if (state < CONTROL_STATE_MAX) { return m_borderColors[state]; } return nn::util::Color8(); } /* Please see man pages for details */ nn::util::Color8 GetTextColor(ControlState state) const { if (state < CONTROL_STATE_MAX) { return m_textColors[state]; } return nn::util::Color8(); } /* Please see man pages for details */ TextAlign GetTextAlign() const { return m_textAlign; } /* Please see man pages for details */ f32 GetBorderWidth() const { return m_borderWidth; } /* Please see man pages for details */ ControlState GetState() const { return m_state; } /* Please see man pages for details */ void* GetExtraData() const { return m_pExtraData; } /* Please see man pages for details */ ControlManager* GetControlManager() const { return m_pManager; } /* Please see man pages for details */ void SetX(s32 x) { m_x = x; } /* Please see man pages for details */ void SetY(s32 y) { m_y = y; } /* Please see man pages for details */ void SetWidth(u32 width) { if (width > 0) { m_width = width; } } /* Please see man pages for details */ void SetHeight(u32 height) { if (height > 0) { m_height = height; } } /* Please see man pages for details */ void SetText(const wchar_t* pText); /* Please see man pages for details */ void SetFormattedText(const wchar_t* pFormat, ...); /* Please see man pages for details */ void SetBorderColor(ControlState state, nn::util::Color8 color) { if (state < CONTROL_STATE_MAX) { m_borderColors[state] = color; } } /* Please see man pages for details */ void SetTextColor(ControlState state, nn::util::Color8 color) { if (state < CONTROL_STATE_MAX) { m_textColors[state] = color; } } /* Please see man pages for details */ void SetTextAlign(TextAlign textAlign) { m_textAlign = textAlign; } /* Please see man pages for details */ void SetBorderWidth(f32 borderWidth) { m_borderWidth = borderWidth; } /* Please see man pages for details */ void SetState(ControlState state) { if (state < CONTROL_STATE_MAX) { m_state = state; } } /* Please see man pages for details */ void SetExtraData(void* pExtraData) { m_pExtraData = pExtraData; } /* Please see man pages for details */ void SetControlManager(ControlManager* pManager) { m_pManager = pManager; } protected: // Calculate the start position for text rendering. s32 CalculateTextX(s32 offsetL, s32 offsetR); // Calculate the start position for text rendering. s32 CalculateTextY(s32 offset); // Processing when pressed with the stylus virtual void OnPenDown() = 0; // Processing when the stylus is lifted virtual void OnPenUp(bool isIn) = 0; // Processing when sliding with the stylus virtual void OnPenSlide(bool isIn) = 0; // Processing when tapped with the stylus virtual void OnPenTouch() = 0; // Processing during rendering virtual void OnDraw() = 0; protected: // Control type nn::util::SizedEnum4 m_type; // Control ID u32 m_id; // Coordinates s32 m_x; s32 m_y; // Size u32 m_width; u32 m_height; // Text wchar_t* m_pText; // Text length s32 m_textLength; s32 m_textBufferLength; // Text scale f32 m_TextScale; // Text size f32 m_textWidth; f32 m_textHeight; // Border color nn::util::Color8 m_borderColors[CONTROL_STATE_MAX]; // Font color nn::util::Color8 m_textColors[CONTROL_STATE_MAX]; // Text placement nn::util::SizedEnum4 m_textAlign; // Border size f32 m_borderWidth; // Control state nn::util::SizedEnum4 m_state; // Expanded data void* m_pExtraData; // Control manager ControlManager* m_pManager; }; } #endif // NN_COMMON_SCENE_GUICONTROLBASE_H_