PureBasic Forum
http://forums.purebasic.com/english/

[Module] Switch Gadget (all OS)
http://forums.purebasic.com/english/viewtopic.php?f=27&t=74210
Page 1 of 1

Author:  Thorsten1867 [ Sat Dec 14, 2019 1:21 pm ]
Post subject:  [Module] Switch Gadget (all OS)

SwitchGadget - Module (all OS / DPI / 64Bit)

Image

Code:
;{ _____ Switch - Commands _____
; Switch::Gadget()             - similar to 'ButtonGadget()'
; Switch::GetData()            - similar to 'GetGadgetData()'
; Switch::GetID()              - similar to 'GetGadgetData()', but it uses a string
; Switch::GetState()           - similar to 'GetGadgetState()'
; Switch::Hide()               - similar to 'HideGadget()'
; Switch::SetAutoResizeFlags() - [#MoveX|#MoveY|#Width|#Height]
; Switch::SetAttribute()       - similar to 'SetGadgetAttribute()'
; Switch::SetColor()           - similar to 'SetGadgetColor()'
; Switch::SetData()            - similar to 'SetGadgetData()'
; Switch::SetFont()            - similar to 'SetGadgetFont()'
; Switch::SetID()              - similar to 'SetGadgetData()', but it uses a string
; Switch::SetState()           - similar to 'SetGadgetState()'
;}

Download: SwitchModule.pbi

Author:  davido [ Sat Dec 14, 2019 2:59 pm ]
Post subject:  Re: [Module] Switch Gadget (all OS)

@Thorsten1867,


There appears to be some missing code on line 616:
Code:
                  Switch()\Color\Border = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor grayColor"))
                  Switch()\Color\Button =
                  Switch()\Color\Gadget = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor windowBackgroundColor"))

As a consequence it won't run on OSX.

Author:  Thorsten1867 [ Sat Dec 14, 2019 4:39 pm ]
Post subject:  Re: [Module] Switch Gadget (all OS)

Update: image support

@davido
Bug fixed

Author:  davido [ Sat Dec 14, 2019 8:00 pm ]
Post subject:  Re: [Module] Switch Gadget (all OS)

@Thorsten1867,

Thank you for the update: Works fine, now. :D

Author:  Thorsten1867 [ Fri Dec 27, 2019 10:12 am ]
Post subject:  Re: [Module] Switch Gadget (all OS)

Update: Event #PB_EventType_Change

Code:
Repeat
  Event = WaitWindowEvent()
  Select Event
    Case Switch::#Event_Gadget ;{ Module Events
      Select EventGadget() 
        Case #Switch1
          If EventType() = #PB_EventType_Change
            Debug "Switch 1: " + Str(EventData())
          EndIf 
        Case #Switch2
          Select EventData()
            Case 1 
              Debug "Switch 2: on"
            Case 0
              Debug "Switch 2: off"
          EndSelect   
        Case #Switch3
          Debug "Switch 2: " + Str(EventData())
      EndSelect ;}
  EndSelect       
Until Event = #PB_Event_CloseWindow

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/