DgsGridListSetItemImage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} This function sets the image on a grid list item. ==Syntax== <syntaxhighlight lang="lua"> bool dgsGridListSetItemImage( element gridList, int rowIndex,...")
 
(add relative to the example)
 
(7 intermediate revisions by 2 users not shown)
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsGridListSetItemImage( element gridList, int rowIndex, int columnIndex, element texture [, int color = 0xFFFFFFFF, float offsetX = 0, float offsetY = 0, float width, float height)
bool dgsGridListSetItemImage( element gridList, int rowIndex, int columnIndex, element texture [, int color = 0xFFFFFFFF, float offsetX = 0, float offsetY = 0, float width, float height, bool relative ] )
dgsGridListSetItemImage(gridlist,row,column,image,color,offx,offy,w,h)
</syntaxhighlight>  
</syntaxhighlight>  
[[Image:DGSGridListItemImage.png|200px|thumb|right|Item Image]]  
[[Image:DGSGridListItemImage.png|200px|thumb|right|Item Image]]  
Line 12: Line 11:
===Required Arguments===  
===Required Arguments===  
*'''gridList:''' the grid list containing the item you're interested in.
*'''gridList:''' the grid list containing the item you're interested in.
*'''rowIndex:''' the row index of the item.
*'''rowIndex:''' An integer of the row index of the item.
*'''columnIndex:''' the column index of the item.
*'''columnIndex:''' An integer of the column index of the item.
*'''data:''' the data you want to set.
*'''texture:''' A texture element of the item you want to set.
 
===Optional Arguments===
*'''color:''' An integer of the color of the texture.
*'''offsetX :''' A float of the 2D X offset of the image of the item.
*'''offsetY :''' A float of the 2D Y offset of the image of the item.
*'''width:''' A float of the width of the image of the item.
*'''height:''' A float of the height of the image of the item.
*'''relative:''' This is whether sizes and positioning are relative. If this is true, then all offestX, offestY, width and height floats must be between 0 and 1, representing sizes relative to the row.  


===Returns===
===Returns===
Line 20: Line 27:


==Example==
==Example==
This example displays a random item data from the gridlist.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
DGS = exports.dgs
DGS = exports.dgs
function clientsideResourceStart ()
texture = dxCreateTexture("image.png") -- put your texture element here
    local numberList = DGS:dgsCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )
 
    local column = DGS:dgsGridListAddColumn ( numberList, "Column Title", 0.85 )
gridlist = DGS:dgsCreateGridList(300,200,300,400,false)
    if ( column ) then
DGS:dgsSetProperty(gridlist,"rowHeight",30) -- make it thicker to see the image clearer
        local row = DGS:dgsGridListAddRow ( numberList )
DGS:dgsGridListAddColumn(gridlist,"Country",0.2)
        local myItem = DGS:dgsGridListSetItemText ( numberList, row, column, tostring( math.random(0, 10) ^ 100 ) )
DGS:dgsGridListAddColumn(gridlist,"ID",0.7)
        DGS:dgsGridListSetItemData ( numberList, row, column, "Test" )
for i=1,10 do
        local myItemData = DGS:dgsGridListGetItemData ( numberList, row, column )
local row = DGS:dgsGridListAddRow(gridlist)
        outputChatBox ( "My gridlist item data: " .. myItemData )
DGS:dgsGridListSetItemText(gridlist,row,2,tostring(i))
    end
DGS:dgsGridListSetItemImage(gridlist,row,1,texture,tocolor(255,255,255,255),10,5,25,20,false)
end
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{DGSFUNCTIONS}}
{{DGSFUNCTIONS}}

Latest revision as of 12:02, 13 December 2020

This function sets the image on a grid list item.

Syntax

bool dgsGridListSetItemImage( element gridList, int rowIndex, int columnIndex, element texture [, int color = 0xFFFFFFFF, float offsetX = 0, float offsetY = 0, float width, float height, bool relative ] )
Item Image

Required Arguments

  • gridList: the grid list containing the item you're interested in.
  • rowIndex: An integer of the row index of the item.
  • columnIndex: An integer of the column index of the item.
  • texture: A texture element of the item you want to set.

Optional Arguments

  • color: An integer of the color of the texture.
  • offsetX : A float of the 2D X offset of the image of the item.
  • offsetY : A float of the 2D Y offset of the image of the item.
  • width: A float of the width of the image of the item.
  • height: A float of the height of the image of the item.
  • relative: This is whether sizes and positioning are relative. If this is true, then all offestX, offestY, width and height floats must be between 0 and 1, representing sizes relative to the row.

Returns

Returns true if set successfully, false if one of the arguments was invalid.

Example

DGS = exports.dgs
texture = dxCreateTexture("image.png") -- put your texture element here

gridlist = DGS:dgsCreateGridList(300,200,300,400,false)
DGS:dgsSetProperty(gridlist,"rowHeight",30) -- make it thicker to see the image clearer
DGS:dgsGridListAddColumn(gridlist,"Country",0.2)
DGS:dgsGridListAddColumn(gridlist,"ID",0.7)
for i=1,10 do
	local row = DGS:dgsGridListAddRow(gridlist)
	DGS:dgsGridListSetItemText(gridlist,row,2,tostring(i))
	DGS:dgsGridListSetItemImage(gridlist,row,1,texture,tocolor(255,255,255,255),10,5,25,20,false)
end

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips