Page 1 of 1

SpinGadget: Add an Increment value

Posted: Fri Oct 23, 2009 2:44 am
by IdeasVacuum
SpinGadget(#Gadget, x, y, Width, Height, Minimum, Maximum, Increment [, Flags])

So, when #PB_Spin_Numeric flag is set, instead of the default increment of 1, Developer can specify 0.1, 2, 10, 100 etc.

IdeasVacuum

Re: SpinGadget: Add an Increment value

Posted: Fri Oct 23, 2009 3:50 am
by PB
No, that's the coder's responsibility. All the SpinGadget does is go up or down; it's the coder who then changes the value by whatever increment they desire.

Re: SpinGadget: Add an Increment value

Posted: Fri Oct 23, 2009 10:50 am
by Kaeru Gaman
not correct.

I pimped the manual example to make a test:

Code: Select all

#Win_1 = 0
#Gad_Spin = 0

If Not OpenWindow(#Win_1, 0, 0, 140, 70, "SpinGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  End
EndIf
  SpinGadget     (#Gad_Spin, 20, 20, 100, 25, 0, 255)
  SetGadgetState (#Gad_Spin, 64) : SetGadgetText(#Gad_Spin, "64")

Repeat
  Event = WaitWindowEvent()
  EvGad = EventGadget()
  EvTyp = EventType()

  Select Event
    Case #PB_Event_CloseWindow
      EXIT = #True
    Case #PB_Event_Gadget
      Select EvGad
        Case #Gad_Spin
          Select EvTyp
            Case #PB_EventType_Change
            ; ** manual User input
              SetGadgetText( #Gad_Spin, Str( GetGadgetState( #Gad_Spin )))
            Case 1
            ; ** UP pressed
              SetGadgetState( #Gad_Spin, GetGadgetState( #Gad_Spin ) +3 )
              SetGadgetText( #Gad_Spin, Str( GetGadgetState( #Gad_Spin )))
            Case -1
            ; ** DOWN pressed
              SetGadgetState( #Gad_Spin, GetGadgetState( #Gad_Spin ) -3 )
              SetGadgetText( #Gad_Spin, Str( GetGadgetState( #Gad_Spin )))
          EndSelect
      EndSelect
  EndSelect
Until EXIT
as you see, I alter the current value by 3 to get a step of 4
the up/Down Event itself already changes the state by 1

... but I think those are SysInternals, I doubt it could be PureBasic's responsability to offer alternate step sizes.

Re: SpinGadget: Add an Increment value

Posted: Wed Nov 18, 2009 1:50 pm
by IdeasVacuum
...I don't see it as wrong, a wish is a wish after all! :? Other languages I use do have this facility.

Re: SpinGadget: Add an Increment value

Posted: Wed Nov 18, 2009 2:16 pm
by Kaeru Gaman
my remark "not correct" was the answer to "it's the coder who then changes the value by whatever increment they desire",
because the inc/dec of 1 is as shown directly connected with the event.

I just don't know if this step of 1 is connected with PureBasic's internals or with the OS' internals.
if the first, an alternate stepvalue would be easy to implement.
if the latter, it would mean to put some extra eventhandling upon the implementation, maybe via callback or whatever...