[GB.FORM]
* NEW: Add Spinner control icon. * NEW: Spinner.Label is a new property that tell if the spinner must display a label. * NEW: Spinner.Value is the percentage value to display as a label, between 0 and 1. [GB.GUI.AREA] * NEW: ProgressBar: Take the Enabled state into account when drawing the control. git-svn-id: svn://localhost/gambas/trunk@6053 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
e298d6a927
commit
55d7b00615
9 changed files with 103 additions and 19 deletions
BIN
comp/src/gb.form/.hidden/control/spinner.png
Normal file
BIN
comp/src/gb.form/.hidden/control/spinner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 594 B |
|
@ -1869,7 +1869,7 @@ C
|
|||
_Properties
|
||||
C
|
||||
s
|
||||
*,Border{Border.*}=None
|
||||
*,Border{Border.*}=None,Label
|
||||
_DefaultSize
|
||||
C
|
||||
s
|
||||
|
@ -1878,6 +1878,18 @@ Border
|
|||
p
|
||||
i
|
||||
|
||||
Label
|
||||
p
|
||||
b
|
||||
|
||||
Value
|
||||
p
|
||||
f
|
||||
|
||||
Enabled
|
||||
p
|
||||
b
|
||||
|
||||
_new
|
||||
m
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ Component=gb.gui
|
|||
Component=gb.form
|
||||
Component=gb.settings
|
||||
Authors="Benoît Minisini"
|
||||
Environment="GB_GUI=gb.qt"
|
||||
Environment="GB_GUI=gb.gtk3"
|
||||
TabSize=2
|
||||
Translate=1
|
||||
Language=en
|
||||
|
|
|
@ -4,19 +4,25 @@ Export
|
|||
|
||||
Inherits UserControl
|
||||
|
||||
Public Const _Properties As String = "*,Border{Border.*}=None"
|
||||
Public Const _Properties As String = "*,Border{Border.*}=None,Label"
|
||||
Public Const _DefaultSize As String = "8,8"
|
||||
|
||||
Property Border As Integer
|
||||
Property Label As Boolean
|
||||
Property Value As Float
|
||||
Property Enabled As Boolean
|
||||
|
||||
Private $hDrawingArea As DrawingArea
|
||||
Private $fStartTime As Float
|
||||
Private $hTimer As Timer
|
||||
Private $iBorder As Integer
|
||||
Private $bLabel As Boolean
|
||||
Private $fValue As Float
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
$hDrawingArea = New DrawingArea(Me) As "DrawingArea"
|
||||
Start
|
||||
|
||||
End
|
||||
|
||||
|
@ -52,11 +58,9 @@ Public Sub DrawingArea_Draw()
|
|||
D = Frac(Timer - $fStartTime) * Pi(2)
|
||||
Endif
|
||||
|
||||
If Not Me.Enabled Then iFlag += Draw.Disabled
|
||||
|
||||
X = Draw.W / 2
|
||||
Y = Draw.H / 2
|
||||
R = Min(Draw.W, Draw.H) / 2 * 7 / 8
|
||||
X = Paint.W / 2
|
||||
Y = Paint.H / 2
|
||||
R = Min(Paint.W, Paint.H) / 2 * 7 / 8
|
||||
|
||||
Paint.LineWidth = R / 8
|
||||
Paint.LineCap = Paint.LineCapRound
|
||||
|
@ -74,9 +78,14 @@ Public Sub DrawingArea_Draw()
|
|||
|
||||
Next
|
||||
|
||||
If $bLabel Then
|
||||
Paint.Background = Color.Foreground
|
||||
Paint.DrawText(Format($fValue, "0%"), 0, 0, Paint.W, Paint.H, Align.Center)
|
||||
Endif
|
||||
|
||||
DRAW_BORDER:
|
||||
|
||||
If $iBorder Then Style.PaintPanel(0, 0, Draw.W, Draw.H, $iBorder, iFlag)
|
||||
If $iBorder Then Style.PaintPanel(0, 0, Paint.W, Paint.H, $iBorder, iFlag)
|
||||
|
||||
End
|
||||
|
||||
|
@ -98,3 +107,47 @@ Private Sub Border_Write(Value As Integer)
|
|||
$hDrawingArea.Refresh
|
||||
|
||||
End
|
||||
|
||||
Private Function Label_Read() As Boolean
|
||||
|
||||
Return $bLabel
|
||||
|
||||
End
|
||||
|
||||
Private Sub Label_Write(Value As Boolean)
|
||||
|
||||
$bLabel = Value
|
||||
$hDrawingArea.Refresh
|
||||
|
||||
End
|
||||
|
||||
Private Function Value_Read() As Float
|
||||
|
||||
Return $fValue
|
||||
|
||||
End
|
||||
|
||||
Private Sub Value_Write(Value As Float)
|
||||
|
||||
$fValue = Max(0, Min(1, Value))
|
||||
$hDrawingArea.Refresh
|
||||
|
||||
End
|
||||
|
||||
Private Function Enabled_Read() As Boolean
|
||||
|
||||
Return Super.Enabled
|
||||
|
||||
End
|
||||
|
||||
Private Sub Enabled_Write(Value As Boolean)
|
||||
|
||||
If Value = Me.Enabled Then Return
|
||||
Super.Enabled = Value
|
||||
If Value Then
|
||||
Start
|
||||
Else
|
||||
Stop
|
||||
Endif
|
||||
|
||||
End
|
||||
|
|
|
@ -6,3 +6,9 @@ Public Sub Form_Open()
|
|||
Spinner1.Start
|
||||
|
||||
End
|
||||
|
||||
Public Sub Timer1_Timer()
|
||||
|
||||
Spinner1.Value += 0.005
|
||||
|
||||
End
|
||||
|
|
|
@ -5,7 +5,13 @@
|
|||
Background = &HFFFFFF&
|
||||
Arrangement = Arrange.Fill
|
||||
{ Spinner1 Spinner
|
||||
MoveScaled(5,6,18.2857,18.2857)
|
||||
MoveScaled(17,19,18.2857,18.2857)
|
||||
Border = Border.Plain
|
||||
Label = True
|
||||
}
|
||||
{ Timer1 #Timer
|
||||
#MoveScaled(46,8)
|
||||
Enabled = True
|
||||
Delay = 70
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,28 +53,35 @@ Public Sub DrawingArea_Draw()
|
|||
|
||||
Dim F As Integer = Style.FrameWidth
|
||||
Dim W As Float
|
||||
Dim iCol As Integer
|
||||
|
||||
W = (Draw.W - F) * $fValue
|
||||
W = (Paint.W - F) * $fValue
|
||||
|
||||
Paint.FillRect(F, F, Draw.W - F * 2, Draw.H - F * 2, Color.Merge(Color.Background, Color.LightForeground))
|
||||
Paint.FillRect(F, F, W - F, Draw.H - F * 2, Color.SelectedBackground)
|
||||
Style.PaintPanel(0, 0, Draw.W, Draw.H, Border.Sunken)
|
||||
iCol = Color.Merge(Color.Background, Color.LightForeground)
|
||||
If Not Me.Enabled Then iCol = Color.Desaturate(iCol)
|
||||
Paint.FillRect(F, F, Paint.W - F * 2, Paint.H - F * 2, iCol)
|
||||
|
||||
iCol = Color.SelectedBackground
|
||||
If Not Me.Enabled Then iCol = Color.Desaturate(iCol)
|
||||
Paint.FillRect(F, F, W - F, Paint.H - F * 2, iCol)
|
||||
|
||||
Style.PaintPanel(0, 0, Paint.W, Paint.H, Border.Sunken)
|
||||
'Style.PaintPanel(F, F, W, Draw.H - F * 2, Border.Raised)
|
||||
|
||||
If $bLabel Then
|
||||
|
||||
Paint.Save
|
||||
Paint.Rectangle(F, F, W - F, Draw.H - F * 2)
|
||||
Paint.Rectangle(F, F, W - F, Paint.H - F * 2)
|
||||
Paint.Clip
|
||||
Paint.Background = Color.SelectedForeground
|
||||
Paint.DrawText(Format($fValue, "0%"), 0, 0, Draw.W, Draw.H, Align.Center)
|
||||
Paint.DrawText(Format($fValue, "0%"), 0, 0, Paint.W, Paint.H, Align.Center)
|
||||
Paint.Restore
|
||||
|
||||
Paint.Save
|
||||
Paint.Rectangle(F + W, F, Draw.W - F * 2 - W, Draw.H - F * 2)
|
||||
Paint.Rectangle(F + W, F, Paint.W - F * 2 - W, Paint.H - F * 2)
|
||||
Paint.Clip
|
||||
Paint.Background = Color.Foreground
|
||||
Paint.DrawText(Format($fValue, "0%"), 0, 0, Draw.W, Draw.H, Align.Center)
|
||||
Paint.DrawText(Format($fValue, "0%"), 0, 0, Paint.W, Paint.H, Align.Center)
|
||||
Paint.Restore
|
||||
|
||||
Endif
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
Public Sub Form_Open()
|
||||
|
||||
Dim hScrollBar As ScrollBar
|
||||
Dim I As Integer
|
||||
|
||||
Print gvwInfo.W;; gvwInfo.H;; "/";; Me.W;; Me.H
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
MoveScaled(0,0,64,64)
|
||||
{ ProgressBar1 ProgressBar
|
||||
MoveScaled(13,18,32,4)
|
||||
Enabled = False
|
||||
}
|
||||
{ Timer1 #Timer
|
||||
#MoveScaled(36,36)
|
||||
|
|
Loading…
Reference in a new issue