Skip to content

Latest commit

 

History

History
885 lines (625 loc) · 23.1 KB

KGUI.md

File metadata and controls

885 lines (625 loc) · 23.1 KB

Indexing

Item: ItemNull ItemText

ItemNull


SetVisible Show Hide PtInItem SetRelX SetRelY GetRelX GetRelY SetAbsX SetAbsY GetAbsX GetAbsY SetW SetH GetW GetH SetRelPos GetRelPos SetAbsPos GetAbsPos SetSize GetSize SetPosType GetPosType IsVisible GetName SetName SetTip GetTip SetUserData GetUserData RegisterEvent ClearEvent EnableScale Scale LockShowAndHide SetAlpha GetAlpha GetParent GetRoot GetType GetIndex SetIndex ExchangeIndex GetTreePath SetAreaTestFile SetIntPos IsIntPos IsLink GetLinkInfo SetLinkInfo GetAniParamID IsValid __eq GetBaseType

  • SetVisible

Set Item Visibility.

(void) ItemNull:SetVisible(bool bVisible)

ItemNull:SetVisible(false)
  • Show

Show Item, same as :SetVisible(true).

(void) ItemNull:Show()

ItemNull:Show()
  • Hide

Hide Item, same as :SetVisible(false).

(void) ItemNull:Hide()

ItemNull:Hide()
  • PtInItem

Judge if a given screen position is in this Item. Always use with Cursor.GetPos().

(bool bIsInItem) ItemNull:PtInItem(number nX, number nY)

local bIsInItem = ItemNull:PtInItem(600, 800)
local bIsInItem = ItemNull:PtInItem(Cursor.GetPos())
  • SetRelX

Set Item's relative X (to its parent).

(void) ItemNull:SetRelX(number nX)

ItemNull:SetRelX(10)
  • SetRelY

Set Item's relative Y (to its parent).

(void) ItemNull:SetRelY(number nY)

ItemNull:SetRelY(10)
  • GetRelX

Get Item's relative X (to its parent).

(number nX) ItemNull:GetRelX()

local nX = ItemNull:GetRelX()
  • GetRelY

Get Item's relative Y (to its parent).

(number nY) ItemNull:GetRelY()

local nY = ItemNull:GetRelY()
  • SetAbsX

Set Item's absolute X (to the screen).

(void) ItemNull:SetAbsX(number nX)

ItemNull:SetAbsX(10)
  • SetAbsY

Set Item's absolute Y (to the screen).

(void) ItemNull:SetAbsY(number nY)

ItemNull:SetAbsY(10)
  • GetAbsX

Get Item's absolute X (to the screen).

(number nX) ItemNull:GetAbsX()

local nX = ItemNull:GetAbsX()
  • GetAbsY

Get Item's absolute Y (to the screen).

(number nY) ItemNull:GetAbsY()

local nY = ItemNull:GetAbsY()
  • SetW

Set Item's width.

(void) ItemNull:SetW(number nW)

ItemNull:SetW(100)
  • SetH

Set Item's height.

(void) ItemNull:SetH(number nW)

ItemNull:SetH(100)
  • GetW

Get Item's width.

(number nW) ItemNull:GetW()

local nW = ItemNull:GetW()
  • GetH

Get Item's height.

(number nH) ItemNull:GetH()

local nH = ItemNull:GetH()
  • SetRelPos

Set Item's relative position. The union of :SetRelX and :SetRelY.

(void) ItemNull:SetRelPos(number nX, number nY)

ItemNull:SetRelPos(100, 200)
  • GetRelPos

Get Item's relative position. The union of :GetRelX and :GetRelY.

(number nX, number nY) ItemNull:GetRelPos()

local nX, nY = ItemNull:GetRelPos()
  • SetAbsPos

Set Item's relative position. The union of :SetAbsX and :SetAbsY.

(void) ItemNull:SetAbsPos(number nX, number nY)

ItemNull:SetAbsPos(500, 300)
  • GetAbsPos

Get Item's relative position. The union of :GetAbsX and :GetAbsY.

(number nX, number nY) ItemNull:GetAbsPos()

local nX, nY = ItemNull:GetAbsPos()
  • SetSize

Set Item's size. The union of :SetW and :SetH.

(void) ItemNull:SetSize(number nW, number nH)

ItemNull:SetSize(600, 800)
  • GetSize

Get Item's size. The union of :GetW and :GetH.

(number nW, number nH) ItemNull:GetSize()

local nW, nH = ItemNull:GetSize()
  • SetPosType

Set Item's position type. See the enum of ITEM_POSITION.

(void) ItemNull:SetPosType()

ItemNull:SetPosType(ITEM_POSITION.RIGHT_BOTTOM)
  • GetPosType

Get Item's position type. See the enum of ITEM_POSITION.

(enum nPosType) ItemNull:GetPosType()

local nPosType = ItemNull:GetPosType()
  • IsVisible

Get Item's visibility.

(bool bVisible) ItemNull:IsVisible()

local bVisible = ItemNull:IsVisible()
  • GetName

Get Item's name.

(string szName) ItemNull:GetName()

local szName = ItemNull:GetName()
  • SetName

Set Item's name.

(void) ItemNull:SetName(string szName)

ItemNull:SetName("Item_001")
  • SetTip

Set Item's tip. When mouse enter it, the tip will be shown.

(void) ItemNull:SetTip(string szTip)

ItemNull:SetTip('<text>text="this is a tip"</text>')
  • GetTip

Get Item's tip.

(string szTip) ItemNull:GetTip()

local szTip = ItemNull:GetTip()
  • SetUserData

Set a number to the Item.

(void) ItemNull:SetUserData(number nData)

ItemNull:SetUserData(27)
  • GetUserData

Get Item's userdata.

(number nData) ItemNull:GetUserData()

local nData = ItemNull:GetUserData()
  • RegisterEvent

Register an ui event so that this item is able to response the specified ui event such as mouse click event.

(void) ItemNull:RegisterEvent(number nUIEvent)

ItemNull:RegisterEvent(256)
  • ClearEvent

Clear all ui event on this Item.

(void) ItemNull:ClearEvent()

ItemNull:ClearEvent()
  • EnableScale

Set if this Item can be scaled.

(void) ItemNull:EnableScale(bool bEnableScale)

ItemNull:EnableScale(true)
  • Scale

Scale an Item. Please noticed that it's children will also be scaled. And remember to save the scale to some place because there is no api to get current scale level. The working principle of this api is just traverse all its children and itself and make their width and height multiplied with the given scale value.

(void) ItemNull:Scale(number fScaleX, number fScaleY)

ItemNull:Scale(0.7, 0.9)
  • LockShowAndHide

Set if this Item's default visibility is invisible.

(void) ItemNull:LockShowAndHide(bool bEnable)

ItemNull:LockShowAndHide(true)
  • SetAlpha

Set its alpha. The value can be set between 0 and 255.

(void) ItemNull:SetAlpha(number nAlpha)

ItemNull:SetAlpha(255)
  • GetAlpha

Get its alpha value (0 - 255).

(number nAlpha) ItemNull:GetAlpha()

local nAlpha = ItemNull:GetAlpha()
  • GetParent

Get its parent node. It will return null if it has no parent.

(KGUI OBJECT pParent) ItemNull:GetParent()

local hParent = ItemNull:GetParent()
  • GetRoot

Get its root parent node (the frame).

(KGUI Frame pFrame) ItemNull:GetRoot()

local hFrame = ItemNull:GetRoot()
  • GetType

Get its ui type, such as WndWindow, Handle, Text, etc.

(string szType) ItemNull:GetType()

local szType = ItemNull:GetType()
  • GetIndex

Get its index. The value will between 0 and the count of its brothers.

(number nIndex) ItemNull:GetIndex()

local nIndex = ItemNull:GetIndex()
  • SetIndex

Set its index. The value must between 0 and the count of its brothers.

(void) ItemNull:SetIndex(number nIndex)

ItemNull:SetIndex(0)
  • ExchangeIndex

Exchange the index with one of its brothers.

  • (void) ItemNull:ExchangeIndex(number nIndex)
  • (void) ItemNull:ExchangeIndex(KGUI Object pBrotherItem)
ItemNull:ExchangeIndex(0)
ItemNull:ExchangeIndex(ItemNull:GetParent():Lookup(0))
  • GetTreePath

Get the tree path of this Item.

(string szWndTreePath, string szHandleTreePath) ItemNull:GetTreePath()

local szWndTreePath, szHandleTreePath = ItemNull:GetTreePath()
  • IsValid

Check if this Item is still vaild. Once the Item get destroyed, this api will return false.

(bool bValid) ItemNull:IsValid()

local bValid = ItemNull:IsValid()
  • GetBaseType

Get its base type. The value can be Item or Wnd.

(string szBaseType) ItemNull:GetBaseType()

local szBaseType = ItemNull:GetBaseType()

ItemText


SetFontScheme GetFontScheme SetRange SetTime SetNumber GetNumber SetText GetText GetTextLen SetVAlign GetVAlign SetHAlign GetHAlign SetRowSpacing GetRowSpacing SetMultiLine IsMultiLine FormatTextForDraw AutoSize SetCenterEachLine IsCenterEachLine SetFontSpacing GetFontSpacing SetRichText IsRichText GetFontScale SetFontScale SetFontID SetFontColor SetFontBorder SetFontShadow GetFontID GetFontColor GetFontBoder GetFontProjection GetTextExtent GetTextPosExtent

  • SetFontScheme

Set text font scheme.
This api will load pFontScheme by nFontID, and then call this:
:SetFontID(pFontScheme->nFontID)
:SetFontColor(pFontScheme->GetFontColor())
:SetFontBorder(pFontScheme->nBorderSize, pFontScheme->GetBoderColor())
:SetFontShadow(pFontScheme->nShadowOffset, pFontScheme->GetShadowColor())
:SetFontScale(pFontScheme->fScale)

(void) ItemText:SetFontScheme(number nFont)

ItemText:SetFontScheme(192)
  • GetFontScheme

Get text font scheme.

(number nFont) ItemText:GetFontScheme()

local nFont = ItemText:GetFontScheme()
  • SetRange

Set text as range format. Notice that this api is the same as :SetText(nValue1 .. szDelimiter .. nVlaue2). But this api is high performanced than :SetText cause there is no intermediate string when concat string.

  • (void) ItemText:SetRange(number nValue, string szDelimiter)
  • (void) ItemText:SetRange(number nValue1, string szDelimiter, number nValue2)
ItemText:SetRange(5, "%")
ItemText:SetRange(5, "/", 100)
  • SetTime

Set text as time format. Notice that this api is the same as :SetText(("%02d:%02d:%02d"):format(TimeToHMS(nTime))). But this api is high performanced than :SetText cause there is no intermediate string when concat string.

(void) ItemText:SetTime(number nTimeStamp)

ItemText:SetTime(GetCurrentTime())
  • SetNumber

Set text as pure number. Notice that this api is the same as :SetText(tostring(nNumber)). But this api is high performanced than :SetText cause there is no intermediate string when concat string.

(void) ItemText:SetNumber(number nNumber)

ItemText:SetNumber(213928)
  • GetNumber

Get text as pure number. Notice that this api is the same as tonumber(:GetText()). But this api is high performanced than :SetText cause there is no intermediate string when concat string.

(number nNumber) ItemText:GetNumber()

local nNumber = ItemText:GetNumber()
  • SetText

Set display text.

(void) ItemText:SetText(string szText)

ItemText:SetText("This is a text.")
  • GetText

Get display text.

(string szText) ItemText:GetText()

local szText = ItemText:GetText()
  • GetTextLen

Get the length of display text.

(number nLen) ItemText:GetTextLen()

local nLen = ItemText:GetTextLen()
  • SetVAlign

Set text vertical alignment. Enum: 0-top, 1-center, 2-bottom. Notice that you may need to call :FormatTextForDraw() for apply the change and redraw text immediately.

(void) ItemText:SetVAlign(number nAlign)

ItemText:SetVAlign(1)
  • GetVAlign

Get text vertical alignment.

(number nAlign) ItemText:GetVAlign()

local nAlign = ItemText:GetVAlign()
  • SetHAlign

Set text horizontal alignment. Enum: 0-left, 1-middle, 2-right. Notice that you may need to call :FormatTextForDraw() for apply the change and redraw text immediately.

(void) ItemText:SetHAlign(number nAlign)

ItemText:SetHAlign(1)
  • GetHAlign

Get text horizontal alignment.

(number nAlign) ItemText:GetHAlign()

local nAlign = ItemText:GetHAlign()
  • SetRowSpacing

Set the spacing of two rows.

(void) ItemText:SetRowSpacing(number nSpacing)

ItemText:SetRowSpacing(3)
  • GetRowSpacing

Get the spacing of two rows.

(number nSpacing) ItemText:GetRowSpacing()

local nSpacing = ItemText:GetRowSpacing()
  • SetMultiLine

Set if this text control supports multiline display. Support multiline display means that when the width of the inner text reaches the width of the control, it will auto wrap.

(void) ItemText:SetMultiLine(bool bMultiline)

ItemText:SetMultiLine(true)
  • IsMultiLine

Get if it supports multiline.

(bool bMultiline) ItemText:IsMultiLine()

local bMultiline = ItemText:IsMultiLine()
  • FormatTextForDraw

Format and redraw the text. When you change the style of text (such as alignment and row spacing), you need to call this api to apply style immediately.

(void) ItemText:FormatTextForDraw()

ItemText:FormatTextForDraw()
  • AutoSize

Auto set its width and height by its inner text.

(void) ItemText:AutoSize()

ItemText:AutoSize()
  • SetCenterEachLine

Set whether to keep center of each line in this text while drawing.

(void) ItemText:SetCenterEachLine(bool bCenter)

ItemText:SetCenterEachLine(true)
  • IsCenterEachLine

Get whether to keep center of each line in this text while drawing.

(bool bCenter) ItemText:IsCenterEachLine()

local bCenter = ItemText:IsCenterEachLine()
  • SetFontSpacing

Set the spacing between two characters.

(void) ItemText:SetFontSpacing(number nSpacing)

ItemText:SetFontSpacing(5)
  • GetFontSpacing

Get the spacing between two characters.

(number nSpacing) ItemText:GetFontSpacing()

local nSpacing = ItemText:GetFontSpacing()
  • SetRichText

Set whether this Text supports rich text.

(void) ItemText:SetRichText(bool bRichText)

ItemText:SetRichText(true)
  • IsRichText

Get whether this Text supports rich text.

(bool bRichText) ItemText:IsRichText()

local bRichText = ItemText:IsRichText()
  • GetFontScale

Get scale.

(number fScale) ItemText:GetFontScale()

local fScale = ItemText:GetFontScale()
  • SetFontScale

Get scale. Notice that :Scale is unavailable on Text control because drawing font is in a different way with drawing other controls.

(void) ItemText:SetFontScale(number fScale)

ItemText:SetFontScale(2.0)
  • SetFontID

Set font id.

(void) ItemText:SetFontID(number nFontID)

ItemText:SetFontID(1)
  • SetFontColor

Set font color.

(void) ItemText:SetFontColor(number nR, number nG, number nB)

ItemText:SetFontColor(255, 255, 0)
  • SetFontBorder

Set font border.

(void) ItemText:SetFontBorder(number nBorderSize, number nR, number nG, number nB)

ItemText:SetFontColor(1, 255, 255, 0)
  • SetFontShadow

Set font shadow.

(void) ItemText:SetFontShadow(number nShadowOffset, number nR, number nG, number nB)

ItemText:SetFontShadow(1, 255, 255, 0)
  • GetFontID

Get font id.

(number nFontID) ItemText:GetFontID()

local nFontID = ItemText:GetFontID()
  • GetFontColor

Get font color.

(number nR, number nG, number nB) ItemText:GetFontColor()

local nR, nG, nB = ItemText:GetFontColor()
  • GetFontBoder

Get font border.

(number nBorderSize, number nR, number nG, number nB) ItemText:GetFontBoder()

local nBorderSize, nR, nG, nB = ItemText:GetFontBoder()
  • GetFontProjection

Get font shadow. (I don't know why this api is not named as GetFontShadow).

(number nShadowOffset, number nR, number nG, number nB) ItemText:GetFontProjection()

local nShadowOffset, nR, nG, nB = ItemText:GetFontProjection()
  • GetTextExtent

Get the width and height of the inner text from offset 0 to nOffset. If nOffset equals with -1, the size of all text will be returned.

(number nW, number nH) ItemText:GetTextExtent([number nOffset])

local nW, nH = ItemText:GetTextExtent() -- Get all text size
local nW, nH = ItemText:GetTextExtent(3) -- Get text size from offset zero to three
  • GetTextPosExtent

Get the character offset of its inner text from a position offset (nOffset). If nOffset is not given, the count of all text will be returned.

(number nOffset) ItemText:GetTextPosExtent([number nPosX])

local nCount = ItemText:GetTextPosExtent()     -- Get the count of all of the text.
local nOffset = ItemText:GetTextPosExtent(80)  -- Get the count of the text from offset zero to offset 80 pixels.