MovieBox.Mode (gb.qt4)
Property Mode As Integer
Return or set the picture display mode.
It is one of the following constants:
MovieBox.Normal
|
The picture is displayed at it’s original size. No attempt is made to fit the picture to the size of the MovieBox.
|
MovieBox.Fill
|
The picture is stretched to fit both the width and height of the MovieBox. Proportionality of the picture is not maintained.
|
MovieBox.Cover
|
The picture proportionality is maintained. The entire MovieBox height and width is filled.
|
MovieBox.Contain
|
The picture proportionality is maintained. The entire picture is displayed and stretched for best fit.
|
MovieBox.Repeat
|
The picture is displayed at it’s original size and repeated. The entire MovieBox height and width is filled.
|
Example
' This demonstrates the PictureBox.Mode constants
' This code needs to be copied to a 'Graphical application'.
Private HBox1 As HBox
Private HBox2 As HBox
Private LabelMode As Label
Private PictureBox1 As PictureBox
Private SliderMode As Slider
Public Sub Form_Open()
With Me
.Height = 600
.Width = 800
.Arrangement = Arrange.Vertical
.Padding = 5
End With
With HBox1 = New HBox(Me)
.Height = 21
End With
With New Label(HBox1)
.Expand = True
.Height = 28
.Text = "Move slider to change PictureBox Mode"
.Font.Bold = True
End With
With LabelMode = New Label(HBox1)
.Expand = True
.Font.Bold = True
.Alignment = Align.Right
End With
With HBox2 = New HBox(Me)
.Height = 28
End With
With SliderMode = New Slider(HBox2) As "SliderMode"
.MaxValue = 4
.Mark = True
.Width = 180
End With
If Not Exist("/tmp/test.png") Then
Me.Show
Me.Title = "Please wait downloading image...."
Wait 0.5
If Not Component.IsLoaded("gb.net.curl") Then Component.Load("gb.net.curl")
File.save("/tmp/test.png", Object.New("HttpClient").Download("https://gambas.one/files/test.png"))
End If
With PictureBox1 = New PictureBox(Me)
.Expand = True
.Picture = Picture["/tmp/test.png"]
End With
SliderMode.Value = 4
End
Public Sub SliderMode_Change()
Dim sText As String[] = ["Normal", "Fill", "Cover", "Contain", "Repeat"]
PictureBox1.Mode = SliderMode.Value
LabelMode.Text = "PictureBox1.Mode = PictureBox." & sText[SliderMode.Value]
Me.Title = sText[SliderMode.Value]
End