/*   _                                
    ( )                               
   _| |   __   _ __   ___ ___     _ _ 
 /'_` | /'__`\( '__)/' _ ` _ `\ /'_` )
( (_| |(  ___/| |   | ( ) ( ) |( (_| |
`\__,_)`\____)(_)   (_) (_) (_)`\__,_) 

	DTextEntry
	
	In Engine Commands:
	
	self:SetMultiline( bool )
	self:IsMultiline()

*/

PANEL = {}

AccessorFunc( PANEL, "m_bAllowEnter", 		"EnterAllowed" )

AccessorFunc( PANEL, "m_bBorder", 			"DrawBorder" )
AccessorFunc( PANEL, "m_bBackground", 		"DrawBackground" )

AccessorFunc( PANEL, "m_colText", 			"TextColor" )
AccessorFunc( PANEL, "m_colHighlight", 		"HighlightColor" )
AccessorFunc( PANEL, "m_colCursor", 		"CursorColor" )

/*---------------------------------------------------------

---------------------------------------------------------*/
function PANEL:Init()

	//
	// We're going to draw these ourselves in 
	// the skin system - so disable them here.
	// This will leave it only drawing text.
	//
	self:SetPaintBorderEnabled( false )
	self:SetPaintBackgroundEnabled( false )
	
	//
	// These are Lua side commands
	// Defined above using AccessorFunc
	//
	self:SetDrawBorder( true )
	self:SetDrawBackground( true )
	self:SetEnterAllowed( true )
	
	
	// Nicer default height
	self:SetTall( 20 )

end

function PANEL:OnKeyCodeTyped( code )

	if ( code == KEY_ENTER && !self:IsMultiline() && self:GetEnterAllowed() ) then
	
		self:FocusNext()
		self:OnEnter()
		
	end

end

/*---------------------------------------------------------
	OnEnter
---------------------------------------------------------*/
function PANEL:OnEnter()

	// For override

end


/*---------------------------------------------------------
	Paint
---------------------------------------------------------*/
function PANEL:Paint()

	derma.SkinHook( "Paint", "TextEntry", self )
	return false

end

/*---------------------------------------------------------
   Name: ApplySchemeSettings
---------------------------------------------------------*/
function PANEL:ApplySchemeSettings()

	derma.SkinHook( "Scheme", "TextEntry", self )

end

/*---------------------------------------------------------
   Name: PerformLayout
---------------------------------------------------------*/
function PANEL:PerformLayout()

	derma.SkinHook( "Layout", "TextEntry", self )

end

derma.DefineControl( "DTextEntry", "A simple TextEntry control", PANEL, "TextEntry" )