text: //Edit.h
  
  // Copyright Querysoft Limited 2013, 2015
  //
  // Permission is hereby granted, free of charge, to any person or organization
  // obtaining a copy of the software and accompanying documentation covered by
  // this license (the "Software") to use, reproduce, display, distribute,
  // execute, and transmit the Software, and to prepare derivative works of the
  // Software, and to permit third-parties to whom the Software is furnished to
  // do so, all subject to the following:
  // 
  // The copyright notices in the Software and this entire statement, including
  // the above license grant, this restriction and the following disclaimer,
  // must be included in all copies of the Software, in whole or in part, and
  // all derivative works of the Software, unless such copies or derivative
  // works are solely in the form of machine-executable object code generated by
  // a source language processor.
  // 
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  // DEALINGS IN THE SOFTWARE.
  
  //Edit Control
  
  #ifndef WINQL_GUI_WND_EDIT_H_3
  #define WINQL_GUI_WND_EDIT_H_3
  
  #ifdef	__QCMP_OPTIMIZEINCLUDE
  #pragma	__QCMP_OPTIMIZEINCLUDE
  #endif//__QCMP_OPTIMIZEINCLUDE
  
  #include "WinQL/GUI/Views/WindowView.h"
  #include "WinQL/GUI/Windows/WinCtrlWindow.h"
  #include "MammutQOR/Model.h"
  #include "WinQL/GUI/CommonCtrl.h"
  #include "WinQL/GUI/WindowFactory.h"
  #include "WinQL/Application/Graphics/WinQLRectangle.h"
  
  //--------------------------------------------------------------------------------
  namespace nsWin32
  {
  	//--------------------------------------------------------------------------------
  	class __QOR_INTERFACE( __WINQL_GUI ) CEditClass : public CWindowClass
  	{
  	public:
  
  		__QOR_DECLARE_OCLASS_ID( CEditClass );
  
  		CEditClass();
  		virtual ~CEditClass();
  		virtual bool Preregistered();
  		const TCHAR* Name();
  
  	private:
  
  		CEditClass( const CEditClass& );
  		CEditClass& operator = ( const CEditClass& );
  	};
  
  	//--------------------------------------------------------------------------------
  	class __QOR_INTERFACE( __WINQL_GUI ) CEdit : public CWinCtrlWindow
  	{
  	public:
  
  		typedef int ( __QCMP_STDCALLCONVENTION* fpEditWordBreakCallBack )( TCHAR* lpch, int ichCurrent, int cch, int code );
  
  		//Edit Control Notification Codes
  
  		__QCMP_STATIC_CONSTANT( int, EN_SETFOCUS         = 0x0100 );
  		__QCMP_STATIC_CONSTANT( int, EN_KILLFOCUS        = 0x0200 );
  		__QCMP_STATIC_CONSTANT( int, EN_CHANGE           = 0x0300 );
  		__QCMP_STATIC_CONSTANT( int, EN_UPDATE           = 0x0400 );
  		__QCMP_STATIC_CONSTANT( int, EN_ERRSPACE         = 0x0500 );
  		__QCMP_STATIC_CONSTANT( int, EN_MAXTEXT          = 0x0501 );
  		__QCMP_STATIC_CONSTANT( int, EN_HSCROLL          = 0x0601 );
  		__QCMP_STATIC_CONSTANT( int, EN_VSCROLL          = 0x0602 );
  
  #if		(_WIN32_WINNT >= 0x0500)
  		__QCMP_STATIC_CONSTANT( int, EN_ALIGN_LTR_EC     = 0x0700 );
  		__QCMP_STATIC_CONSTANT( int, EN_ALIGN_RTL_EC     = 0x0701 );
  #endif//(_WIN32_WINNT >= 0x0500)
  
  		//Edit Control Messages
  
  		__QCMP_STATIC_CONSTANT( int, EM_GETSEL               = 0x00B0 );
  		__QCMP_STATIC_CONSTANT( int, EM_SETSEL               = 0x00B1 );
  		__QCMP_STATIC_CONSTANT( int, EM_GETRECT              = 0x00B2 );
  		__QCMP_STATIC_CONSTANT( int, EM_SETRECT              = 0x00B3 );
  		__QCMP_STATIC_CONSTANT( int, EM_SETRECTNP            = 0x00B4 );
  		__QCMP_STATIC_CONSTANT( int, EM_SCROLL               = 0x00B5 );
  		__QCMP_STATIC_CONSTANT( int, EM_LINESCROLL           = 0x00B6 );
  		__QCMP_STATIC_CONSTANT( int, EM_SCROLLCARET          = 0x00B7 );
  		__QCMP_STATIC_CONSTANT( int, EM_GETMODIFY            = 0x00B8 );
  		__QCMP_STATIC_CONSTANT( int, EM_SETMODIFY            = 0x00B9 );
  		__QCMP_STATIC_CONSTANT( int, EM_GETLINECOUNT         = 0x00BA );
  		__QCMP_STATIC_CONSTANT( int, EM_LINEINDEX            = 0x00BB );
  		__QCMP_STATIC_CONSTANT( int, EM_SETHANDLE            = 0x00BC );
  		__QCMP_STATIC_CONSTANT( int, EM_GETHANDLE            = 0x00BD );
  		__QCMP_STATIC_CONSTANT( int, EM_GETTHUMB             = 0x00BE );
  		__QCMP_STATIC_CONSTANT( int, EM_LINELENGTH           = 0x00C1 );
  		__QCMP_STATIC_CONSTANT( int, EM_REPLACESEL           = 0x00C2 );
  		__QCMP_STATIC_CONSTANT( int, EM_GETLINE              = 0x00C4 );
  		__QCMP_STATIC_CONSTANT( int, EM_LIMITTEXT            = 0x00C5 );
  		__QCMP_STATIC_CONSTANT( int, EM_CANUNDO              = 0x00C6 );
  		__QCMP_STATIC_CONSTANT( int, EM_UNDO                 = 0x00C7 );
  		__QCMP_STATIC_CONSTANT( int, EM_FMTLINES             = 0x00C8 );
  		__QCMP_STATIC_CONSTANT( int, EM_LINEFROMCHAR         = 0x00C9 );
  		__QCMP_STATIC_CONSTANT( int, EM_SETTABSTOPS          = 0x00CB );
  		__QCMP_STATIC_CONSTANT( int, EM_SETPASSWORDCHAR      = 0x00CC );
  		__QCMP_STATIC_CONSTANT( int, EM_EMPTYUNDOBUFFER      = 0x00CD );
  		__QCMP_STATIC_CONSTANT( int, EM_GETFIRSTVISIBLELINE  = 0x00CE );
  		__QCMP_STATIC_CONSTANT( int, EM_SETREADONLY          = 0x00CF );
  		__QCMP_STATIC_CONSTANT( int, EM_SETWORDBREAKPROC     = 0x00D0 );
  		__QCMP_STATIC_CONSTANT( int, EM_GETWORDBREAKPROC     = 0x00D1 );
  		__QCMP_STATIC_CONSTANT( int, EM_GETPASSWORDCHAR      = 0x00D2 );
  #if(WINVER >= 0x0400)											 
  		__QCMP_STATIC_CONSTANT( int, EM_SETMARGINS           = 0x00D3 );
  		__QCMP_STATIC_CONSTANT( int, EM_GETMARGINS           = 0x00D4 );
  		__QCMP_STATIC_CONSTANT( int, EM_SETLIMITTEXT         = EM_LIMITTEXT );   /* ;win40 Name change */
  		__QCMP_STATIC_CONSTANT( int, EM_GETLIMITTEXT         = 0x00D5 );
  		__QCMP_STATIC_CONSTANT( int, EM_POSFROMCHAR          = 0x00D6 );
  		__QCMP_STATIC_CONSTANT( int, EM_CHARFROMPOS          = 0x00D7 );
  #endif /* WINVER >= 0x0400 */									 
  																
  #if(WINVER >= 0x0500)											
  		__QCMP_STATIC_CONSTANT( int, EM_SETIMESTATUS         = 0x00D8 );
  		__QCMP_STATIC_CONSTANT( int, EM_GETIMESTATUS         = 0x00D9 );
  #endif /* WINVER >= 0x0500 */
  
  		__QOR_DECLARE_OCLASS_ID( CEdit );
  
  		CEdit();
  		virtual ~CEdit();
  
  		virtual void OnCommand( unsigned short wCtrlID, unsigned short wCode );
  
  		virtual void OnSetFocus();
  		virtual void OnKillFocus();
  		virtual void OnChange();
  		virtual void OnUpdate();
  		virtual void OnErrSpace();
  		virtual void OnMaxText();
  		virtual void OnHScroll();
  		virtual void OnVScroll();
  		virtual void OnAlignLTR();
  		virtual void OnAlignRTL();
  
  		bool CanUndo();
  		long CharFromPos( unsigned short wXPos, unsigned short wYPos );
  		void EmptyUndoBuffer();
  		void SetLineFormat( bool bSoftLineBreaks );
  		bool GetCueBanner( wchar_t* wstrBuffer, long lBufferCount );
  		long GetFirstVisibleLine();
  		long GetHandle();
  		//EM_GETHILITE ??TODO:
  
  		long GetIMEStatus( Cmp_uint_ptr TypeOfStatus );
  		long GetLimitText();
  		long GetLine( Cmp_uint_ptr LineIndex, TCHAR* strBuffer, unsigned short wBufferCount );
  		long GetLineCount();
  		long GetMargins();
  		bool GetModified();
  		long GetPasswordChar();
  		void GetFormatRect( CRectangle& rcFormat );
  		long GetSel( unsigned long& dwSelBegin, unsigned long& dwSelEnd );
  		long GetThumb();
  		long GetWordBreakProc();
  		bool HideBaloonTip();
  		void LimitText( Cmp_uint_ptr CharCount );
  		long LineFromChar( Cmp_uint_ptr CharIndex );
  		long GetLineStartIndex( Cmp_uint_ptr Line );
  		long GetLineLength( Cmp_uint_ptr CharIndex );
  		long Scroll( Cmp_uint_ptr HScrollChars, Cmp_long_ptr VScrollLines );
  		long PosFromChar( Cmp_uint_ptr CharIndex );
  		void ReplaceSel( bool bCanUndo, const TCHAR* strText );
  		long Scroll( Cmp_uint_ptr Action );
  		void ScrollCaret();
  		bool SetCueBanner( bool bShowPersist, const wchar_t* wstrCue );
  		void SetHandle( Cmp_uint_ptr MemHandle );
  		//EM_SETHILITE ??TODO:;
  
  		long SetIMEStatus( Cmp_uint_ptr StatusType, Cmp_long_ptr lStatus );
  		void SetLimitText( Cmp_uint_ptr Limit );
  		void SetMargins( Cmp_uint_ptr Margins, unsigned short wLeftMargin, unsigned short wRightMargin );
  		void SetModified( bool bModified );
  		void SetPasswordChar( Cmp_uint_ptr PasswordChar );
  		bool SetReadOnly( bool bReadOnly );
  		void SetFormatRect( CRectangle& rcFormat );
  		void SetFormatRectNP( CRectangle& rcFormat );
  		void SetSel( Cmp_uint_ptr SelBegin, Cmp_long_ptr SelEnd );
  		bool SetTabStops( Cmp_uint_ptr TabCount, unsigned int* pStops );
  		void SetWordBreakProc( fpEditWordBreakCallBack pFunc );
  		/*TODO:
  		bool ShowBaloonTip( EDITBALLOONTIP* pTip );
  		{
  			bool bResult = ( m_Win32MsgHandler.Send( Handle(), (unsigned int) EM_SHOWBALLOONTIP, 0, reinterpret_cast< Cmp_long_ptr >( pTip ) ) ? true : false );
  			return bResult;
  		}
  		*/
  
  		//--------------------------------------------------------------------------------
  		bool UndoR();
  		bool Undo();
  
  	};
  
  	//--------------------------------------------------------------------------------
  	class __QOR_INTERFACE( __WINQL_GUI ) CEditFactory : public CWindowFactory
  	{
  	public:
  
  		//Edit Control Styles
  
  		__QCMP_STATIC_CONSTANT( long, ES_LEFT             = 0x0000L );
  		__QCMP_STATIC_CONSTANT( long, ES_CENTER           = 0x0001L );
  		__QCMP_STATIC_CONSTANT( long, ES_RIGHT            = 0x0002L );
  		__QCMP_STATIC_CONSTANT( long, ES_MULTILINE        = 0x0004L );
  		__QCMP_STATIC_CONSTANT( long, ES_UPPERCASE        = 0x0008L );
  		__QCMP_STATIC_CONSTANT( long, ES_LOWERCASE        = 0x0010L );
  		__QCMP_STATIC_CONSTANT( long, ES_PASSWORD         = 0x0020L );
  		__QCMP_STATIC_CONSTANT( long, ES_AUTOVSCROLL      = 0x0040L );
  		__QCMP_STATIC_CONSTANT( long, ES_AUTOHSCROLL      = 0x0080L );
  		__QCMP_STATIC_CONSTANT( long, ES_NOHIDESEL        = 0x0100L );
  		__QCMP_STATIC_CONSTANT( long, ES_OEMCONVERT       = 0x0400L );
  		__QCMP_STATIC_CONSTANT( long, ES_READONLY         = 0x0800L );
  		__QCMP_STATIC_CONSTANT( long, ES_WANTRETURN       = 0x1000L );
  #if		(WINVER >= 0x0400)
  		__QCMP_STATIC_CONSTANT( long, ES_NUMBER           = 0x2000L );
  #endif	//WINVER >= 0x0400
  
  		__QOR_DECLARE_OCLASS_ID( CEditFactory );
  
  		CEditFactory();
  		virtual ~CEditFactory();
  		virtual CEdit* Create();
  
  		bool GetLeft();
  		void SetLeft( bool bFlag );
  		bool GetCenter();
  		void SetCenter( bool bFlag );
  		bool GetRight();
  		void SetRight( bool bFlag );
  		bool GetMultiLine();
  		void SetMultiLine( bool bFlag );
  		bool GetUpperCase();
  		void SetUpperCase( bool bFlag );
  		bool GetLowerCase();
  		void SetLowerCase( bool bFlag );
  		bool GetPassword();
  		void SetPassword( bool bFlag );
  		bool GetAutoVScroll();
  		void SetAutoVScroll( bool bFlag );
  		bool GetAutoHScroll();
  		void SetAutoHScroll( bool bFlag );
  		bool GetNoHideSel();
  		void SetNoHideSel( bool bFlag );
  		bool GetOEMConvert();
  		void SetOEMConvert( bool bFlag );
  		bool GetReadOnly();
  		void SetReadOnly( bool bFlag );
  		bool GetWantReturn();
  		void SetWantReturn( bool bFlag );
  		bool GetNumber();
  		void SetNumber( bool bFlag );
  
  	};
  
  }//nsWin32
  
  #endif//WINQL_GUI_WND_EDIT_H_3
  