It is currently Sat Dec 14, 2019 2:55 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: PB v5.45, v5.61 ImageGadget Workaround
PostPosted: Thu Sep 28, 2017 8:22 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2068
Location: Germany
Bug Link ImageGadget : viewtopic.php?f=23&t=69231

Workaround ImageGadget and SetGadgetState over CanvasGadget

Update v0.3
Code:
;-TOP
; Workaround ImageGadget for Linux PB Version v5.45, v5.61 by mk-soft
; Version v0.3

Procedure MyImageGadget(Gadget, x, y, Width, Height, ImageID, Flags=0)
  Protected r1, MyFlags, id
  Select Flags
    Case #PB_Image_Border
      MyFlags = #PB_Canvas_Border
  EndSelect
  r1 = CanvasGadget(Gadget, x, y, Width, Height, MyFlags)
  If r1
    If Gadget = #PB_Any
      id = r1
    Else
      id = Gadget
    EndIf
    If ImageID
      If StartDrawing(CanvasOutput(id))
        DrawImage(ImageID, 0, 0) ;, Width, Height)
        StopDrawing()
      EndIf
    EndIf
  EndIf
  ProcedureReturn r1
EndProcedure

Procedure MySetGadgetState(Gadget, State)
  If GadgetType(Gadget) = #PB_GadgetType_Canvas
    If State
      If StartDrawing(CanvasOutput(Gadget))
        Box(0, 0, GadgetWidth(Gadget), GadgetHeight(Gadget), $F5F0F0)
        DrawImage(State, 0, 0)
        StopDrawing()
      EndIf
    EndIf
  Else
    SetGadgetState(Gadget, State)
  EndIf
EndProcedure

Macro ImageGadget(Gadget, x, y, Width, Height, ImageID, Flags=0)
  MyImageGadget(Gadget, x, y, Width, Height, ImageID, Flags)
EndMacro

Macro SetGadgetState(Gadget, State)
  MySetGadgetState(Gadget, State)
EndMacro

;- Test

If OpenWindow(0, 0, 0, 200, 200, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CreateImage(0, 100, 100, 32, $FFFF)
  CreateImage(1, 80, 80, 32, $FFFF00)
  ImageGadget(0,  10, 10, 100, 100, ImageID(0))
  Repeat
    Define Event.i = WaitWindowEvent()
    Select Event.i
      Case #PB_Event_Gadget
        Define Gad.i = EventGadget()
         Select Gad.i
           Case 0 :
             Select EventType()
               Case #PB_EventType_LeftClick
                 Debug "Clicked ImageGadget"
                 If Not toggle
                   toggle = #True
                   SetGadgetState(0, ImageID(1))
                 Else
                   toggle = #False
                   SetGadgetState(0, ImageID(0))
                 EndIf
             EndSelect
             
         EndSelect
       Case #PB_Event_CloseWindow
         Quit.i = 1
     EndSelect
  Until Quit.i = 1
EndIf

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye