[Gambas-user] Strange gb.qt5 error
Marco Ancillotti
gambas at servinfo.it
Sat Jan 19 10:54:14 CET 2019
Hi ,
this is my component code reduced to minimal:
---------------------------------------------------------------------------------------------
' Gambas class file
Export
Inherits UserControl
Public Const _Properties As String = "*"
Public Const _DefaultSize As String = "32,6"
Public Const _Group As String = "my"
Public Const _DrawWith As String = "DrawingArea"
Event Open
Private $sText As String
Private $hIcon As Picture
Private $hView As DrawingArea
Private $h_yes As Button
Private $h_no As Button
Private $H As Integer
Private $opened As Boolean
Private $retvalue As Integer
Private $bclick As Boolean
Public Sub _new()
$hView = New DrawingArea(Me) As "View"
$h_yes = New Button($hView) As "YesButton"
$h_yes.H = Desktop.Scale * 4
$h_yes.AutoResize = True
$h_yes.Text = (" yes ")
Try $h_yes.Picture = Picture["icon:/small/apply"]
$h_no = New Button($hView) As "NoButton"
$h_no.H = Desktop.Scale * 4
$h_no.AutoResize = True
$h_no.Text = (" No ")
Try $h_no.Picture = Picture["icon:/small/close"]
Try $hIcon = Picture["icon:/32/warning"]
$opened = False
Me.Proxy = $hView
Me.Hide
End
Public Sub Open(Text As String) As Integer
If $sText = Text Then Return
If $opened = True Then Return
$bclick = False
$retvalue = 0
$sText = Text
$opened = True
Me.H = 1
Me.Show
$H = Max($hIcon.H + Desktop.Scale * 2, Me.Font.RichTextHeight($sText,
Max(16, Me.Parent.ClientW - $hIcon.W - $h_no.W - $h_yes.W -
Desktop.Scale * 6)) + Desktop.Scale * 4)
Me.H = $H
While $bclick = False
Try Wait 0.1
Try IsNull(Me.window)
If Error Then $bclick = True
Wend
Return $retvalue
End
Private Sub Close()
$bclick = True
Wait
Me.Hide
$sText = ""
$opened = False
End
Public Sub View_Arrange()
$h_no.Move($hView.W - $h_no.W - Desktop.Scale, ($H - $h_no.H) \ 2)
$h_yes.Move($hView.W - $h_yes.W - $h_no.W - Desktop.Scale, ($H -
$h_yes.H) \ 2)
End
Public Sub View_Draw()
Dim X, W As Integer
W = Me.W - Desktop.Scale * 2
If $hIcon Then
Paint.DrawPicture($hIcon, Desktop.Scale, Desktop.Scale)
X += $hIcon.W + Desktop.Scale * 3
W -= $hIcon.W - Desktop.Scale * 2
Endif
W = Max(16, Me.Parent.ClientW - $hIcon.W - $h_no.W - $h_yes.W -
Desktop.Scale * 6)
Paint.DrawRichText($sText, X, Desktop.Scale * 2, W, Me.H -
Desktop.Scale * 2, Align.TopLeft)
End
Public Sub YesButton_Click()
$retvalue = 1
Close()
End
Public Sub NoButton_Click()
$retvalue = 0
Close()
End
---------------------------------------------------------------------------------------------
I really need a component because all my form are dynamic build from
config files and are really a lot so I need to reuse the same component.
I would like to have the same result as using a message.question but
instead of a popup I need that the question open on the current form.
I know how to make it using a simple panel but I need to have it in a
component.
I think the problem is in the way I manage return from open function but
I haven't found another way to delay the result to when one button has
been clicked.
Thank's a lot,
marco.
More information about the User
mailing list