Computer Science Canada

[Class] kindof buggy Spinner

Author:  Raknarg [ Sun Aug 12, 2012 6:52 pm ]
Post subject:  [Class] kindof buggy Spinner

This requires two classes I made, the button and custom text classes:
http://compsci.ca/v3/viewtopic.php?t=30797
http://compsci.ca/v3/viewtopic.php?p=263055#263055

To add to my widgets, I made a spinner class, that you're all familiar with: http://en.wikipedia.org/wiki/Spinner_(computing)

it's not the best looking and doesn't work as smoothly as real ones but this isn't too bad. It works, anyways. You can use buttons to change the value or use text (the buggyish part).

Note:
x1, y1, x2, y2: area's coordinates
c, bc, btc, fontc: back colour, border colour, behind-the-text colour, font colour (for the spinner, not the buttons)
minValue, maxValue, value: minimum and maximum values, and the current value.
increment: This is how much you want value to change every time you click a button. It also rounds the number you type in. If your initial value was 1, and you had an increment of 0.5, typing in 1.7 would round it to 1.5. Also I should mention that it woks weird if you have a number like 0.7 as your minimum value. In this case, typing out 1.7 would leave it as 1.7.
font: the font. However, not as an integer, but as a string. It automatically selects the font size for you, so if you want Arial then put in "Arial" not "Arial:10"

Not the best I've ever done, so suggestions would be appreciated

Turing:


import "Spinner.tu"

setscreen ("offscreenonly")

var spinner : ^Spinner
new Spinner, spinner

spinner -> initialize (50, 50, 200, 90, black, grey, white, black, 5, 0, 0, 0.5, "Arial")

loop
    spinner -> update
    spinner -> draw
    View.Update
    cls
end loop


: