Extend IGlass Window Problems

BlitzMax Forums/BlitzMax Programming/Extend IGlass Window Problems

Here's an example, it's still a work in progress.

Remember you need to make the changes I mentiond previously to IGlass's IGL_Window class before this will work!

' This is a class that combines the IGlass elements to create a window that
' allows the selection of tiles.


Include "../IGlass_1.5.2/IGL_Classe/Inc_IGlass.bmx"

Type TileWindow Extends IGL_Window

Field tilesWidth:Int = 0
Field tilesHeight:Int = 0
Field tileSize:Int = 0
Field numTiles:Int = 0
Field tiledImages:TImage
Field sbarTexture:IGL_Scrollbar

Function CreateIt:TileWindow(Caption:String, Px:Int, Py:Int, Tx:Int, Ty:Int)
Local NewWindow:TileWindow

NewWindow=New TileWindow
BLock:Byte=True 'Can be locked in place
BMinimize:Byte=True 'Can be minimized
BClose:Byte=True 'Can be closed
ClassType:Int=IGL_NormalWindow 'Is a normal window
NewWindow.Setup(Caption,Px,Py,Tx,Ty,BLock, BMinimize, BClose, ClassType)
Return NewWindow
End Function


Method SetImages(images:TImage, TileSize:Int, NumTiles:Int )

Self.tileSize = TileSize
Self.numTiles = NumTiles

tiledImages = images

tilesWidth = Tx / tileSize
tilesHeight = Ty / tileSize

sbarTx:Int = 16
sbarPx:Int = sbarTx - 16

sbarTexture = IGL_Scrollbar.Create(Super,"",sbarPx,0,sbarTx,Ty-2,0.0,0.0,Float(NumTiles),1,True)

End Method

Method Refresh()
DebugLog("TileWindow Refresh"+sbarTexture.Value)

Super.Refresh()
'Draw array of textures on texture window
Local posx:Int = Px+16
Local posy:Int = Py+22

Local index:Int = sbarTexture.Value

index:Mod numTiles

For Local x:Int = 0 To tilesWidth-1
For Local y:Int = 0 To tilesHeight-1
DrawImage( tiledImages, posx, posy, index )
index:+1
index:Mod numTiles
posy:+tileSize
Next
posy = Py+22
posx:+tileSize
Next

End Method


End Type

'Rem
'Test Harness

Graphics 640, 480, 0

IGL_InitGUI(1)

' Build an editor window e.g. list of textures and scroll bar!
Global wndTexture:TileWindow
Global tileImage:TImage = LoadAnimImage("C:\spiral.png", 32, 32, 0, 100, FILTEREDIMAGE|MASKEDIMAGE)
'CreateIt:TileWindow(Caption:String,Px:Int,Py:Int,Tx:Int,Ty:Int, images:TImage, TileSize:Int, NumTiles:Int )
wndTexture= New TileWindow.CreateIt("Textures",10,10,145,415)
wndTexture.setImages(tileImage,32,100)
' Why does field not surface in child
wndTexture.Alpha=1.0


While Not KeyHit(KEY_ESCAPE)
Cls
IGL_RefreshGUI()
wndTexture.Refresh()
Flip
FlushMem
Wend

'End Rem