Garry's Mod Wiki

DPanel

Description

A simple rectangular box, commonly used for parenting other elements to. Pretty much all elements are based on this.

View source

Parent

Derives methods, etc not listed on this page from Panel.

Methods

Returns the panel's background color. By default this returns nil even though the default background color is white
Returns whether or not the panel is disabled.
We advise against using this. It may be changed or removed in a future update. You should use DPanel:GetPaintBackground instead. Returns whether or not the panel background is being drawn. Alias of DPanel:GetPaintBackground.
Used internally by DMenu. Returns whether the frame is part of a derma menu or not. If this is true, CloseDermaMenus will not be called when the frame is clicked, and thus any open menus will remain open.
Returns whether or not the panel background is being drawn.
We advise against using this. It may be changed or removed in a future update. Does nothing. Returns value set by DPanel:SetTabbingDisabled.
DPanel:SetBackgroundColor( table color )
Sets the background color of the panel.
DPanel:SetDisabled( boolean disabled )
Sets whether or not to disable the panel.
DPanel:SetDrawBackground( boolean draw )
We advise against using this. It may be changed or removed in a future update. You should use DPanel:SetPaintBackground instead. Sets whether or not to draw the panel background. Alias of DPanel:SetPaintBackground.
DPanel:SetIsMenu( boolean isMenu )
Used internally by DMenu. Sets whether the frame is part of a derma menu or not. If this is set to true, CloseDermaMenus will not be called when the frame is clicked, and thus any open menus will remain open.
DPanel:SetPaintBackground( boolean paint )
Sets whether or not to paint/draw the panel background.
DPanel:SetTabbingDisabled( boolean draw )
We advise against using this. It may be changed or removed in a future update. Does nothing.
DPanel:UpdateColours()
We advise against using this. It may be changed or removed in a future update. Does nothing.

Example

Creates a DPanel and adds a DLabel to it

local DPanel = vgui.Create( "DPanel" ) DPanel:SetPos( 10, 30 ) -- Set the position of the panel DPanel:SetSize( 200, 200 ) -- Set the size of the panel local DLabel = vgui.Create( "DLabel", DPanel ) DLabel:SetPos( 10, 10 ) -- Set the position of the label DLabel:SetText( "I'm a DLabel inside a DPanel! :)" ) -- Set the text of the label DLabel:SizeToContents() -- Size the label to fit the text in it DLabel:SetDark( 1 ) -- Set the colour of the text inside the label to a darker one
Output: