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

*/

local function AddItem( name, optiontext, overridename )

	optiontext = optiontext or ""
	
	local Panel = vgui.Create( "Panel", PanelList )
	
	local Label = vgui.Create( "Label", Panel )
			Label:SetText( name .. optiontext )
			if ( overridename ) then Label:SetText( overridename .. optiontext ) end
			Label:SetPos( 0, 0 )
			Label:SetSize( 200, 50 )
	
	local Control = vgui.Create( name, Panel )
			Control:SetPos( 200, 15 )
	
	Panel:SetTall( 50 )
		
	return Panel, Control

end


local function OpenTestWindow()

	local w = 400
	local h = 500

	local Window = vgui.Create( "DFrame" )
		Window:SetSize( 400, 500 )
		Window:Center()
		Window:SetTitle( "Derma Initiative Tests" )
		Window:SetVisible( true )
		Window:MakePopup()
		
	local PanelList = vgui.Create( "DPanelList", Window )
		PanelList:EnableVerticalScrollbar()
		PanelList:EnableHorizontal( false )
		PanelList:SetSize( w - 20, h - 50 )
		PanelList:SetPos( 10, 30 )		
		
	local Panel, Control = AddItem( "DButton" )
		Control:SetText( "Button Text!" )
		Control:SetSize( 150, 20 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DImageButton" )
		Control:SetImage( "gui/silkicons/add" )
		Control:SetSize( 16, 16 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DImageButton", " (with bg)" )
		Control:SetDrawBorder( true )
		Control:SetImage( "gui/silkicons/add" )
		Control:SetSize( 16, 16 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DImageButton", " (with bg + border)" )
		Control:SetDrawBorder( true )
		Control:SetDrawBackground( true )
		Control:SetImage( "gui/silkicons/add" )
		Control:SetSize( 16, 16 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DImage" )
		Control:SetImage( "gui/silkicons/add" )
		Control:SetSize( 16, 16 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DSysButton", " (close)" )
		Control:SetType( "close" )
		Control:SetSize( 20, 20 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DSysButton", " (up no border)" )
		Control:SetDrawBorder( false )
		Control:SetType( "up" )
		Control:SetSize( 20, 20 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DSysButton", " (grip no border or bg)" )
		Control:SetDrawBorder( false )
		Control:SetDrawBackground( false )
		Control:SetType( "grip" )
		Control:SetSize( 20, 20 )
	PanelList:AddItem( Panel )
	
	
	local Panel, Control = AddItem( "DButton", "", "DMenu (press button)" )
		Control:SetText( "Menu >" )
		Control:SetSize( 100, 20 )
		Control.DoClick = function ( btn )
		
								local menu = DermaMenu()
								menu:AddOption( "New", function() Msg( "Selected NEW" ) end )
								menu:AddOption( "Load..", function() Msg( "Selected Load" ) end )
								menu:AddOption( "Save..", function() Msg( "Selected Save" ) end )
								menu:AddOption( "Exit", function() Window:Remove() end )
								menu:Open()		
		
						  end
		
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DTextEntry" )
		Control:SetText( "Text Entry Input!" )
		Control:SetSize( 150, 20 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DTextEntry", " (no border)" )
		Control:SetText( "Text Entry Input!" )
		Control:SetDrawBorder( false )
		Control:SetSize( 150, 20 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DTextEntry", " (no border or bg)" )
		Control:SetText( "Text Entry Input!" )
		Control:SetDrawBorder( false )
		Control:SetDrawBackground( false )
		Control:SetSize( 150, 20 )
	PanelList:AddItem( Panel )
	
	local Panel, Control = AddItem( "DTextEntry", " (multiline)" )
		Control:SetText( "Text Entry Input!" )
		Control:SetMultiline( true )
		Control:SetSize( 150, Panel:GetTall() )
		Control.y = 0
	PanelList:AddItem( Panel )
		
		
	PanelList:PerformLayout()

end


concommand.Add( "derma_test", OpenTestWindow )