#pragma once #include "KObject.h" #include "K3DTypes.h" #include "KTextPhrase.h" //#include #include class KViewportObject; class KSpriteSeq; class KSpritePrimitive; class KResSprite; class KUIWndManager; class KUIWnd; #ifdef _DEV /// 2011.11.24 윈도우나 컨트롤들이 윈도우 메세지를 처리하고 있을 때, 윈도우나 컨트롤들을 추가/삭제 하고 있는지 조사하기 위한 구조체 - prodongi /// 메세지를 처리 하고 있을 때, 컨트롤들의 루프를 돌고 있기 때문에, 추가/삭제가 되며 안된다. struct KUIValidChecker { public: static bool getIsProcessingMsg() { return isProcessingMsg; } static void setIsProcessingMsg(bool is) { isProcessingMsg = is; } private: static bool isProcessingMsg; }; #endif struct KUIWND_CREATE_ARG { KUIWND_CREATE_ARG() { lpszClassName = ""; lpszID = ""; lpszCaption = ""; lpszToolTip = ""; lpszAniName = ""; lpszSprName = ""; nFrameIndex = 0; dwStyle = 0; dwFlag = 0; dwAnchor = 0; pParent = NULL; pWndManager = NULL; } KUIWND_CREATE_ARG ( LPCSTR _lpszClassName , LPCSTR _lpszID , LPCSTR _lpszCaption , KRect _rcRect , DWORD _dwStyle , DWORD _dwFlag , KUIWnd* _pParent , LPCSTR _lpszAniName , LPCSTR _lpszSprName , KUIWndManager* _pWndManager , int _nFrameIndex = 0 , LPCSTR _lpszToolTip = "" , DWORD _dwAnchor = 0) { lpszClassName = _lpszClassName; lpszID = _lpszID ; lpszCaption = _lpszCaption ; rcRect = _rcRect ; dwStyle = _dwStyle ; dwFlag = _dwFlag ; pParent = _pParent ; lpszAniName = _lpszAniName ; lpszSprName = _lpszSprName ; pWndManager = _pWndManager ; nFrameIndex = _nFrameIndex ; lpszToolTip = _lpszToolTip ; dwAnchor = _dwAnchor; } std::string lpszClassName; std::string lpszID; std::string lpszCaption; std::string lpszToolTip; std::string lpszAniName; std::string lpszSprName; int nFrameIndex; KRect rcRect; DWORD dwStyle; DWORD dwFlag; DWORD dwAnchor; KUIWnd* pParent; KUIWndManager* pWndManager; }; class KUIDragAndDropObject; class KUIWnd : public KObject { public: KUIWnd(void); virtual ~KUIWnd(void); virtual void Create(KUIWND_CREATE_ARG& CREATE_ARG); const std::string& GetClassName() const { return m_sClassName; } // virtual fuctions virtual void Process(DWORD dwTime); virtual void ForcedProcess(DWORD dwTime) {} ; //강제 프로세스 virtual void Render(KViewportObject * pViewport, bool isFront = false ); virtual void PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam ) = 0; /// 자신의 Size가 바뀔때 virtual void OnSizeChangeNofity(const KRect& rcNewRect); /// 자신의 Pos 변경 virtual void OnPosChangeNofity(int XOffset, int YOffset); /// 자신의 Clip Size가 바뀔때 virtual void OnClipChangeNotify(const KRect& rcClipRect); /// 자신의 Alpha 값이 변경 virtual void OnAlphaChangeNotify(float fAlpha); /// Parent의 Size가 바뀔때( size 등이 변경 - 아예 Primitive를 새로 만드므로 Cost High) virtual void OnParentSizeChangeNotify(const KRect& rcNewRect,int nXMove, int nYMove, int nResizeStyle); /// Parent의 Pos가 바뀔때 ( Cost low) virtual void OnParentPosChangeNotify(int XOffset, int YOffset); /// Parent의 Clip Size가 바뀔때 virtual void OnParentClipChangeNotify(const KRect& rcClipRect); virtual void OnParentAlphaChangeNotify(float fAlphaDiff); virtual void OnChangeCaptionNotify(); virtual void OnChangeAniNameNotify(); virtual void OnChagneBackNotify(); virtual void OnFocusNotify() {} virtual void OnKillFocusNotify() {} /** prodongi */ /// @brief 마우스가 컨트롤 영역에 포커스가 on/off‰瑛뻑㎏?발생되는 통지 메세지를 날린다 virtual void OnMouseFocusOnNotify(KUIWnd* /*wnd*/, bool /*focusOn*/) {} // { [sonador] 2007.05.31 #ifdef _KUI_INVALIDATION //! ask whether the window is currently validatory or not. virtual bool IsValidWnd() const { return m_bValidation; } //! validate the window and do some additional action defined in "OnValidate()" function. virtual void ValidateWnd(); //! invalidate the window and do some additional action defined in "OnInvalidate()" function. virtual void InvalidateWnd(); //! set validation flag and don't propagate validation message ** used by window manager virtual void SetValidation( bool validation ) { m_bValidation = validation; } //! this is called in validation. virtual void OnValidate() {} //! this is called in invalidation. virtual void OnInvalidate() {} //! this is called when change show flag virtual void OnShowNotify( bool bShowFlag ) {} #else virtual void InvalidateWnd() {} #endif // } // Input arguments are all global screen coordinates virtual DWORD OnMouseMessage(DWORD dwMessage, int x, int y); virtual DWORD OnKeyMessage(DWORD dwMessage, DWORD dwKeyCode); virtual KUIDragAndDropObject* GetDragObject() { return NULL; } void SetRect(const KRect& rcRect); void SetCorrectionRect(const KRect& rcRect, bool bWithChild = true ); bool IsInRect(int x, int y); bool IsInRectWithChild(int x, int y); void MovePos( int x, int y ); void MovePosOffset(int offsetx, int offsety); const KRect& Resize( const KRect &newrect ); const KRect& ClipRect( const KRect &newrect ); virtual void ChangeAlpha(float fAlpha); float GetAlpha() const { return m_fAlpha; }; bool IsShow() const { return m_bShowFlag; } void SetShow( bool showFlag ); void SetToggleShow() { SetShow( !m_bShowFlag ); } void SetShowChildAll( bool bShow ); bool IsActivate() { return m_bActivate; } void SetActivate( bool bActivate ) { m_bActivate = bActivate; } bool IsDestroy() const { return m_bDestroy;} void SetDestroy(bool bDestroy) { m_bDestroy = bDestroy; } DWORD GetFlag() const { return m_dwFlag; } DWORD SetFlag( DWORD dwFlag ) { return m_dwFlag = dwFlag; } DWORD GetAnchor() const { return m_dwAnchor; } DWORD SetAnchor( DWORD dwAnchor ) { return m_dwAnchor = dwAnchor; } void SetSortValue( int nV ); int GetSortValue() const { return m_nSortValue; } bool HasFocus() const { return m_bHasFocus; } void SetFocus( bool bFocus ); LPCSTR GetID() const { return m_sID.c_str(); } void SetID(LPCSTR lpszID) { m_sID.assign(lpszID); } LPCSTR GetToolTipInfo() const { return m_sTip.c_str(); } void SetStyle( DWORD dwStyle ) { m_dwStyle = dwStyle;} DWORD GetStyle() const { return m_dwStyle;} const KRect &GetRect() const { return m_rcRegion;} const KRect &GetClipRect() const { return m_rcClipArea;} const KRect &GetOriginalOffset() const { return m_rcOriginalOffset; } // 2011.03.18 servantes const KRect& GetBoundingRect() const; /// 2011.02.16 - prodongi /// 2011.06.14 mantis 13132 - prodongi bool getIsWeb() const { return m_isWeb; } void setIsWeb(bool is) { m_isWeb = is; } void SetParent( KUIWnd *pParent ); KUIWnd* GetParent() const {return m_pParent;} KUIWnd* GetChild( const char *_id ) const; KUIWnd* GetFocusChild() const; void ResetChildPosition() { for( std::list< KUIWnd* >::const_iterator it = m_listChild.begin(); it != m_listChild.end(); ++it ) { (*it)->MoveToOriginalPosition(); } } // 2010.08.12 - prodongi size_t GetChildCount() const {return m_listChild.size(); } void MoveToOriginalPosition(); void AddChild( KUIWnd *wnd ); bool RemoveChild( KUIWnd *wnd ); struct CaptionHandler { virtual void onSetCaption( std::string & caption ) = 0; }; static void SetCaptionHandler( CaptionHandler* pCaptionHandler ) { m_pCaptionHandler = pCaptionHandler; } /// 2011.02.23 forceUpdate 추가 - prodongi //void SetCaption( const char *caption, bool bUseCaptionHandler = true ); void SetCaption( const char *caption, bool bUseCaptionHandler = true, bool forceUpdate = false ); //void SetCaption( const char *caption, bool bUseCaptionHandler = true ) //{ // if( m_sOrgCaption != caption ) // 추가. bintitle. 2010.06.03. // { // m_sCaption = caption; // if( m_pCaptionHandler ) m_pCaptionHandler->onSetCaption( m_sCaption ); // OnChangeCaptionNotify(); // } //} LPCSTR GetCaption() const { return m_sCaption.c_str(); } LPCSTR GetOrgCaption() const { return m_sOrgCaption.c_str(); } void SetCaptionAlign(DWORD dwAlign) { m_dwCaptionAlign = dwAlign; if(m_pCaptionPhrase) m_pCaptionPhrase->SetAlign( dwAlign); } KSize GetCaptionPhraseSize() { KSize ksize( 0, 0 ); if( m_pCaptionPhrase ) { const SIZE size = m_pCaptionPhrase->GetTextureSize(); ksize.cx = size.cx; ksize.cy = size.cy; } return ksize; } DWORD GetCaptionAlign() const { return m_dwCaptionAlign; } void SetBack(LPCSTR lpszSprName, LPCSTR lpszAniName, int nIndex = 0); void SetFrameIndex(int nIndex); int SetFrameTextureAnim(DWORD dwElapsedTime, DWORD dwMaxFrame, DWORD dwSpeed, bool bLoop = false, bool bUnShowByEndFrame = true); LPCSTR GetAniName() const { return m_sAniName.c_str(); } LPCSTR GetSprName() const { return m_sSprName.c_str(); } int GetFrameIndex() const { return m_nFrameIndex; } bool BuildPrimitive( KSpritePrimitive *pr, const char *ani_name, int nFrame, const K3DVertex &pos, float visibility ); bool BuildPrimitive( KSpritePrimitive *pr, const char *ani_name, int nFrame, const K3DVertex &pos, float visibility, const KSize &target_size, bool tiling ); // MJ 2004/11/23 차일드 리스트 리턴 const std::list & GetChildList() { return m_listChild; }; // MJ 2004/12/01 // alpha virtual void SetAlphaOpen( DWORD dwTime ); virtual void SetAlphaClose( DWORD dwTime ); DWORD m_dwAlphaTime; bool m_bShowAlpha; bool m_bCloseAlpha; bool m_bText; // MJ 2004/12/02 virtual void SetChildAniName( const char* szName, const char* szValue ); virtual void SetChildCaption( const char* szName, const char* szvalue ); virtual void SetChildCaptionFormat(KUIWnd* child, char const* fmt, ...); /// 2012.05.14 - prodongi virtual void SetChildNumber( const char* szName, int nValue ); virtual void SetChildShow( const char* szName, bool bShow = false ); virtual void SetChildRect( const char* szName, KRect rc ); virtual void SetChildClipRect( const char* szName, KRect rc ); virtual void SetChildresize( const char* szName, KRect rc ); virtual void SetChildToggleShow( const char* szName ); virtual void SetChildTooltip( const char* szName, char const* tooltip ); /// 2012.05.04 - prodongi virtual void SetChildTooltip( KUIWnd* child, char const* tooltip ); /// 2012.05.04 - prodongi virtual void SetAniName( const char* szName ) { m_sAniName = szName; OnChangeAniNameNotify(); }; virtual void SetMovePos( const char* szName, int nX, int nY ); virtual void SetMovePosOffset( const char* szName, int offsetx, int offsety ); /// szName 컨트롤 속성으로 다른 이름의 같은 속성 윈도우 생성, 위치는 다름 virtual KUIWnd* CopyControl( const char* szName, const char* szNewName, RECT rc ); virtual void CopyControl( const char* szName, const char* szNewName, KRect rt ); virtual void SetValidRect( const char* szName, KRect& rt ); virtual void SetChildAlpha( const char* szName, float fAlpha ); virtual void RemoveControl( const char* szName ); virtual void SetTooltipOff(); virtual void InitFocusWnd(); virtual KUIWnd& operator=( const KUIWnd & wnd ); /** 중간에 있는 것을 끝으로 옮겨서, 맨 나중에 찍도록 하려고 하는 것인데, 별로 안 좋은 것임. 컨트롤 구성시 맨나중에 그려지는 것은 나중에 추가 하면 되는 것임. */ void SetChildAsTop( const char* szName ); /// 물론 별로 좋지 않은 함수. 한참 뒤에있는 넘이 만약 제일 아래에 랜더링되야 하는 넘일때 사용하는 함수. void SetChildAsButtom( const char* szName ); static void SetEnterChatMode( bool bValue ) { s_bIsEnterChatMode = bValue; } static bool IsEnterChatMode() { return s_bIsEnterChatMode; } void OnToolTipWnd( KUIWnd* pOnToolTipWnd ); void OffToolTipWnd(); #ifdef _KUI_INVALIDATION void SetPopupWnd( bool bPopup ) { m_bPopupWnd = bPopup; } bool IsPopup() { return m_bPopupWnd; } #endif /// 2011.01.18 - prodongi void setCaptionScroll(bool scroll, bool updateCaption = false, DWORD type = 0, float v = 0.2f, float margin = 0.1f); #ifdef _COUNTRY_ME_ KTextLayout2* GetCaptionPhrase() { return m_pCaptionPhrase; } #else KTextPhrase* GetCaptionPhrase() { return m_pCaptionPhrase; } #endif protected: struct SPRITE_SET* _getSpriteSet(); #ifdef _KUI_INVALIDATION // { [sonador] K3DRenderTarget* _getRenderTarget(); // } #endif void _ClearChildList(); virtual void ClearChild( const char* szName ); void MarkOriginalOffset(); /** prodongi */ private: /// @brief 마우스가 컨트롤 영역에 포커스가 on/off‰瑛뻑㎏?체크해서 통지 메세지를 날린다 void checkMouseFocusOn(KUIWnd* wnd, bool isInRect); protected: void setBoundingControl(); /// 2011.02.16 m_boundingControl을 설정한다 - prodongi protected: bool m_bDestroy; bool m_bShowFlag; // bool m_bEnable; ///< 사용 가/불 능 // { [sonador] 2007.05.31 #ifdef _KUI_INVALIDATION bool m_bValidation; #endif // } DWORD m_dwFlag; ///< KUI_FLAG DWORD m_dwStyle; ///< KUI_STYLE : 같은 수를 사용 하는 플래그가 있던데. DWORD m_dwAnchor; ///< KUI_ANCHOR DWORD m_dwCaptionAlign; ///< KTextRender::FONT_ALIGN KUIWnd* m_pParent; ///< 부모 KRect m_rcCorrectionRect; ///< 교정, 추가 사각 KRect m_rcOriginalOffset; ///< 본래 크기 std::list m_listChild; // Children std::string m_sID; ///< 윈도우 식별 ID std::string m_sClassName; ///< 윈도우 class : edit, button 등등 std::string m_sTip; ///< 팁 Text std::string m_sCaption; ///< 윈도우 제목 std::string m_sOrgCaption; // 윈도우 원본제목. std::string m_sAniName; ///< 애니메이션 이름 std::string m_sSprName; ///< 스프라이트 이름 int m_nFrameIndex; int m_nSortValue; ///< 이 값이 0이 아닐경우 값 기준으로 소팅되어 그려진다. ( 숫자 큰 윈도우가 먼저 그려짐 ) ///< 소팅해서 그리는데는 비용이 드니 어지간하면 0으로 그냥 쓸것. by Testors float m_fZPos; float m_fAlpha; #ifdef _COUNTRY_ME_ KTextLayout2* m_pCaptionPhrase; #else KTextPhrase* m_pCaptionPhrase; #endif KRect m_rcRegion; // Position combined with the parent's position (world position) KRect m_rcClipArea; // Clipping area KRect m_rcCaptionArea; // Title area KUIWndManager* m_pManager; bool m_bHasFocus; ///< Focus KUIWnd* m_pMouseDownWnd; ///< 클릭된 윈도우 KPoint m_ptMouseDown; ///< 클릭된 위치 bool m_bActivate; ///< 현재 게이지가 진행 중인가 static CaptionHandler* m_pCaptionHandler; static bool s_bIsEnterChatMode; KUIWnd* m_pOnToolTipWnd; #ifdef _KUI_INVALIDATION bool m_bPopupWnd; #endif /** prodongi */ /// @brief마우스가 컨트롤 영역에 포커스가 on/off‰榮쩝嗤?저장 bool m_isMouseFocusOn; KUIWnd* m_boundingControl; /// 2011.02.16 nui의 실제 적용 영역이 들어있는 컨트롤 - prodongi /// 2011.06.14 mantis 13132 - prodongi bool m_isWeb; };