DGS OOP Class: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 293: Line 293:
!OOP Functions
!OOP Functions
!POP Functions
!POP Functions
|-
|setSizable
|setSizable
|[[dgsWindowSetSizable]]
|[[dgsWindowSetSizable]]

Revision as of 15:47, 28 January 2019

DGS provides not only POP ( Procedure Oriented Programming ) but also OOP ( Object Oriented Programming ). This page introduces OOP of dgs.

Structure

When using DGS OOP, DGS objects to be operated are no longer elements, instead, they will be tables ( table is the only type whose call methods can be defined in lua ) . Here is the structure of DGS OOP Object:

DGSDxObject = {
	DGSElement = DGSElement -- The actual dgs element
	function1,
	function2,
	...
}
  • The built-in functions are non-modifiable
  • Any variable of the table are get/set via dgsSetProperty/dgsGetProperty ( Exclude DGSElement )
  • After importing DGS OOP Class, there is a table called : DGSClass

Get Started

Instead of using

 label = exports.dgs:dgsCreateLabel(0, 0, 0.5, 0.1, "text", true)
 DGS = exports.dgs
 label = DGS:dgsCreateLabel(0,0,0.5,0.1,"text",true)
 loadstring(exports.dgs:dgsImportFunction())()-- load functions
 label = dgsCreateLabel(0,0,0.5,0.1,"text",true) --create a label

We provides Object Oriented Programming

 loadstring(exports.dgs:dgsImportOOPClass())()-- load OOP class
 window = DGSClass:createWindow(0,0,0.5,0.1,"test",true) --create a window with oop
 label = window:createLabel(0,0,1,1,"label",true) --create a label inside the window
 label.text = "DGS OOP Test" --set text

Functions

Creation Functions

OOP Functions POP Functions
createWindow dgsCreateWindow
create3DInterface dgsCreate3DInterface
createButton dgsCreateButton
createBrowser dgsCreateBrowser
createCheckBox dgsCreateCheckBox
createRadioButton dgsCreateRadioButton
createComboBox dgsCreateComboBox
createEdit dgsCreateEdit
createDetectArea dgsCreateDetectArea
createGridList dgsCreateGridList
createImage dgsCreateImage
createMemo dgsCreateMemo
createLabel dgsCreateLabel
createProgressBar dgsCreateProgressBar
createScrollBar dgsCreateScrollBar
createScrollPane dgsCreateScrollPane
createTabPanel dgsCreateTabPanel
createArrowList dgsCreateArrowList
createSwitchButton dgsCreateSwitchButton

General Functions

OOP Functions POP Functions
getPosition dgsGetPosition
setPosition dgsSetPosition
getParent dgsGetParent
setParent dgsSetParent
getChild dgsGetChild
getChildren dgsGetChildren
getSize dgsGetSize
setSize dgsSetSize
getType dgsGetType
setLayer dgsSetLayer
getLayer dgsSetLayer
setCurrentLayerIndex dgsSetCurrentLayerIndex
getCurrentLayerIndex dgsGetCurrentLayerIndex
getProperty dgsGetProperty
setProperty dgsSetProperty
getProperties dgsGetProperties
setProperties dgsSetProperties
getVisible dgsGetVisible
setVisible dgsGetVisible
getEnabled dgsGetEnabled
setEnabled dgsSetEnabled
getSide dgsGetSide
setSide dgsSetSide
getAlpha dgsGetAlpha
setAlpha dgsSetAlpha
getFont dgsGetFont
setFont dgsSetFont
getText dgsGetText
setText dgsSetText
bringToFront dgsBringToFront
simulateClick dgsSimulateClick
animTo dgsAnimTo
isAniming dgsIsAniming
stopAniming dgsStopAniming
moveTo dgsMoveTo
isMoving dgsIsMoving
stopMoving dgsStopMoving
sizeTo dgsSizeTo
isSizing dgsIsSizing
stopSizing dgsStopSizing
alphaTo dgsAlphaTo
isAlphaing dgsIsAlphaing
stopAlphaing dgsStopAlphaing
getPostGUI dgsGetPostGUI
setPostGUI dgsGetPostGUI
destroy destroyElement
isElement isElement
getElement self.dgsElement
addMoveHandler dgsAddMoveHandler
removeMoveHandler dgsRemoveMoveHandler
isMoveHandled dgsIsMoveHandled
addSizeHandler dgsAddSizeHandler
removeSizeHandler dgsRemoveSizeHandler
isSizeHandled dgsIsSizeHandled
attachToTranslation dgsAttachToTranslation
detachFromTranslation dgsDetachFromTranslation
getTranslationName dgsGetTranslationName
on addEventHandler(Handled By DGS)
removeOn removeEventHandler(Handled By DGS)

Window

OOP Functions POP Functions
setSizable dgsWindowSetSizable
setMovable dgsWindowSetMovable
close dgsCloseWindow
setCloseButtonEnabled dgsWindowSetCloseButtonEnabled
getCloseButtonEnabled dgsWindowGetCloseButtonEnabled
getCloseButton dgsWindowGetCloseButton