B4A Library [Class]ClsWheel Input wheels

enrico

Active Member
Licensed User
Longtime User
How can I calculate ItemNb to better fill pnlMainHeight (for bigger screens) ?
 

klaus

Expert
Licensed User
Longtime User
The easiest way would be to add it as a parameter in the Initialize routine and the two lines below:
B4X:
Public Sub Initialize(CallbackModule As Object, Parent As Object, cTitle As String, cWheelNb As Int, cWheelContent() As List, cFontSize As Float, cWheelType As Int, cContinusScrolling As Boolean, cItemNb As Int)
    ItemNb = cItemNb
    ItemNb_2 = Floor(ItemNb / 2)
And add the parameter in the calling routine.
The number must be an odd number.

You might aslo play with the TextSize parameter.
 
Last edited:

enrico

Active Member
Licensed User
Longtime User
So I need a function to calculate the nearest odd integer below a number.
For example if I have 10.8, it has to be 9.

Maybe this ?
floor((x + 1)/2)*2 - 1
 
Last edited:

enrico

Active Member
Licensed User
Longtime User
Ok. I've modified it to pass the Height of the panel :
B4X:
Public Sub Initialize(CallbackModule As Object, Parent As Object, cTitle As String, cWheelNb As Int, cWheelContent() As List, cFontSize As Float, cWheelType As Int, cContinusScrolling As Boolean, cPanelMaxHeight As Int)

And then calculate ItemNb :
B4X:
ItemNb = Floor((PanelMaxHeight/lblHeight + 1)/2)*2 - 1        'Added to set ItemNb according to pnlMainHeight (PanelMaxHeight)

The screen size is good, but now I've some problems with the value selection.
With ItemNb = 9 I get the preceding two places value (sorry for my english).
For example in a time wheel, if I select 05:03, I get 03:01
 

klaus

Expert
Licensed User
Longtime User
You should replace line 876 in Sub getSelection and line 914 in Sub getSelection2 (the number could be different depending on your changes) by :
j = Floor(scvWheel(i).ScrollPosition / lblHeight + 0.5) + ItemNb_2
Replace 2 by ItemNb_2

I wouldn't transmit the pnlMainHeight value because this height is calculated in the class depending on the text size.
I suggest you to calculate ItemNb depending on the physical sceen dimension.
In my opinion you should also adapt the text size to the physical sceen dimension.
Don't forget to calculate ItemNb_2 = Floor(ItemNb / 2) just after ItemNb.
 
Last edited:

Shadow&Max

Active Member
Licensed User
Longtime User
Hi... This is a beautiful class, but I'm trying to get time in AM/PM, Hours & Minutes. I've set DateTime.TimeFormat = "hh:mm" and the wheels in the demo are still showing me 24 hour time. How can I fix this?
 

Harris

Expert
Licensed User
Longtime User
Possible yes.
It would need quite some time to add this and I am not really convinced of the usefullness of this option.
But feel free to adapt it to your wishes, it's an open project.



Horizontal example: directional indicator.
 

Harris

Expert
Licensed User
Longtime User
I understand. Just a thought.
Thanks.
 

Shadow&Max

Active Member
Licensed User
Longtime User
This would need to make new wheel variants.
I have never thought about it because I'm used to the 24 hours display.
Note that even the wheels show 24 hours, the returned value is displayed in the format you set in the program.

I'm not sure how to do this Klaus... Love the class though. What I'd like to do is display hours in 12 or 24 hour based upon their phone settings, and display only 4 items in minutes... 0,15,30,45.

I lived in Europe for a year, so I know about the 24 hour format, but if that's presented to most from the US, they wouldn't know how to deal with it!

Do I create three separate lists to do this???
 

klaus

Expert
Licensed User
Longtime User
You can do it with a Custom wheel.
Look at the attached test program.
Click onto the Label to show the wheel.
You can check the settings and depending on the settings you can initialize either the 24h wheel or the 12AM/PM wheel.
In the whlTimeAmPm_Closed routine you can handle the time string to your needs.
 

Attachments

  • ClsWheelAM_PM.zip
    12.5 KB · Views: 170
  • ClsWheelAM_PM.png
    23.1 KB · Views: 184

Shadow&Max

Active Member
Licensed User
Longtime User
Damn you're good! Thanks Klaus... The only change I made was changing "0" to "12"

I'm trying to figure out how to detect the time format chosen in the phone's setup now.

In terms of Harris' question... it would be very helpful for game and flight controls headings could be changed with a horizontal swipe etc... I don't have any need for it personally, but I can see it's use...
 

klaus

Expert
Licensed User
Longtime User
How to use Scale on it?
If you change the TextSize the views dimensions are automaticaly scaled.
If the wheel becomes too wide or too heigh the text size is changed to fit into the screen.
Perhaps it might be useful to transform it into a custom view, also.
Currently, the wheels class is designed as a pseudo modal input dialog and not as a custom view.
There is no scheddule to transform it also to a custom view.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…