TimeBox formatting
Posted
#1
(In Topic #1388)
Regular

(Setting: TimeBox1.Format = "hh:mm", or TimeBox1.Format = "HH:mm", doesn't work.)
Posted
Guru

EDIT 15:40
Run this in a Graphical application:-
Code (gambas)
- BuildForm
- .Arrangement = Arrange.Vertical
- .Padding = 6
- .Height = 50
- .Width = 124
- .Height = 32
- .Width = 112
- .Height = 32
- .Width = 48
- .Height = 32
- .Width = 16
- .Background = Color.White
- .Alignment = Align.Center
- .Text = ":"
- .Height = 32
- .Width = 48
<IMG src="https://www.cogier.com/gambas/SpinBoxes.png">
</IMG>
Posted
Regular

Posted
Guru

Looking at the code for TimeBox it looks like the new ShowSecond property only hides/shows the last 2 objects the : separator and the last SpinBox.
comp/src/gb.form/.src/Date/TimeBox.class · master · Gambas / gambas · GitLab
(Many compound controls can be hacked/modified in a similar way
Code (gambas)
- ' First Try the new way,,,
- ' if we are here the above method did error so it's older gambas,
- ' Emulate the new property ourselves, get a pointer to the main DrawingArea
- ' in the TimeBox and hide/show the last 2 Children (the seconds spinbox and
- ' the separator), and lastly set seconds value to 0 if hiding.
- hObj.Value = 0
EDIT: i adjusted the code to use the builtin method if it exists in the gambas version
Posted
Regular

Posted
Guru

mandarin said
Indeed . i was not happy with the look though.
Even the new built in TimeBox.ShowSecond property just hides the last 2 objects but does not resize the TimeBox to fit the controls so it changes the button style.
I changed the code to adjust the size when changing, i think it looks better…
Code (gambas)
- ' add or subtract the size of a spacer and a SpinBox
- TB.W += dw.Children[0].W + dw.Children[1].W
- TB.W -= dw.Children[0].W + dw.Children[1].W
- sb.Value = 0
1 guest and 0 members have just viewed this.




