ProgressBar Text colour
Posted
#1
(In Topic #2073)
Enthusiast

Just want to know if there is the possibility to change the progressbars text colour?
Code (gambas)
Progressbar1.text="TEST"
the background and foreground colour is for the progressbar progress…
Just used it in the mp3 Player and maybe who tested it and has a Gambas Version prior 3.20 will get an error
because it exists since 3.20 …
Thanks,
Regards
Yogi
Posted
Administrator



There is your answer and there are no other properties for thatYogi said
the background and foreground colour is for the progressbar progress…
From “ProgressBar Text colour”, March 8th 2026, 5:24 PM
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Enthusiast

gbWilly said
There is your answer and there are no other properties for thatYogi said
the background and foreground colour is for the progressbar progress…
From “ProgressBar Text colour”, March 8th 2026, 5:24 PM
From “Post #14,446”, March 8th 2026, 6:55 PM
Would be a nice feature!
Thanks!
Regards,
Yogi
Posted
Enthusiast

I have no idea if it would be better to inherit from the progressbar class for the text colour of the progressbar.
I copied the progressbar class in my project folder and renamed it. And enhanced the class
with the property and the private variable:
So now if the 'progressbar1.text="TEST" ' and
'progressbar1.textColor=COLOR.RED'
is set, the text appears red.
progressbar1 has to be the new renamed progressbar class,
here we go:
Code (gambas)
- ' Gambas class file
- Inherits UserControl
- '' @{since 3.20}
- '' Return or set the text displayed in the progress bar.
- ''
- '' If not set, which is the default, the value property is displayed as a percentage.
- '---- INSERTED ---------------------
- '------------------------------------------
- Return $bLabel
- $bLabel = Value
- Me.Refresh
- Return $fValue
- $fValue = Value
- Me.Refresh
- ' INSERTED-----------------------------------
- 'Give the default Colour
- $sTextColor = Color.Foreground
- '---------------------------------------------------
- Style.ClipBackground(0, 0, Paint.W, Paint.H)
- 'F = Style.BorderSize
- iCol = Color.SetAlpha(Color.SelectedBackground, 160)
- 'Draw.Foreground = Color.LightForeground
- 'Draw.Rect(0, 0, Paint.W, Paint.H)
- 'Style.PaintPanel(0, 0, Paint.W, Paint.H, Border.Sunken)
- 'Paint.Rectangle(F, F, Paint.W - F * 2, Paint.H - F * 2, DS - F)
- 'Paint.Clip
- HP = Paint.H
- Paint.Save
- Paint.Background = iCol
- Paint.Translate($iPulse - (HP + WP) * 2, 0)
- Paint.MoveTo(0, HP)
- Paint.LineTo(HP, 0)
- Paint.LineTo(WP + HP, 0)
- Paint.LineTo(WP, HP)
- Paint.LineTo(0, HP)
- Paint.Fill
- Paint.Translate(WP * 2, 0)
- Paint.Restore
- sText = $sText
- Paint.Background = Color.SelectedBackground
- Paint.DrawTextShadow(sText, 0, 0, Paint.W, Paint.H, Align.Center, 1)
- Paint.Background = Color.Foreground
- GoSub DRAW_LABEL
- W = Paint.W * $fValue
- sText = $sText
- Paint.FillRect(Paint.W - W, 0, W, Paint.H, iCol)
- ' Paint.Save
- ' Paint.Rectangle(Paint.W - W, 0, W, Paint.H)
- ' Paint.Clip
- ' Paint.Background = Color.SelectedForeground
- ' GoSub DRAW_LABEL
- ' Paint.Restore
- 'Paint.Save
- 'Paint.Rectangle(0, 0, Paint.W - W, Paint.H)
- 'Paint.Clip
- Paint.Background = Color.Foreground
- GoSub DRAW_LABEL
- 'Paint.Restore
- Paint.FillRect(0, 0, W, Paint.H, iCol)
- ' Paint.Save
- ' Paint.Rectangle(0, 0, W, Paint.H)
- ' Paint.Clip
- ' Paint.Background = Color.SelectedForeground
- ' GoSub DRAW_LABEL
- ' Paint.Restore
- 'Paint.Save
- 'Paint.Rectangle(W, 0, Paint.W - W, Paint.H)
- 'Paint.Clip
- Paint.Background = Color.Foreground
- GoSub DRAW_LABEL
- 'Paint.Restore
- DRAW_LABEL:
- '---- CHANGED -----------------------------
- Paint.Background = $sTextColor
- '--------------------------------------------------
- Return $bPulse
- $bPulse = Value
- $hTimerPulse.Delay = 50
- $hTimerPulse.Start
- $fValue = 0
- $iPulse = 0
- $hTimerPulse = Null
- Inc $iPulse
- Me.Refresh
- Return $bBorder
- $bBorder = Value
- Me.Refresh
- Return $sText
- $sText = Value
- Me.Refresh
- '-- INSERTED ------------------------------------------
- Return $sTextColor
- $sTextColor = Value
- Me.Refresh
- '------------------------------------------------------------
Regards,
Yogi
1 guest and 0 members have just viewed this.



