Canvas and transparent background gadgets

Just starting out? Need help? Post your questions and find answers here.
FlatEarth

Canvas and transparent background gadgets

Post by FlatEarth »

Hi
Why is the background of the checkbox, option, panel and ... transparent when added to the canvas container?
Is there an easy way to prevent this? like window.

Code: Select all

If OpenWindow(0, 0, 0, 600, 600, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  SetWindowColor(0,RGB(80,255,255))
  
  ;CheckBoxGadget(1,30,30,100,30,"chk") 
  OptionGadget(1,30,30,100,30,"Opt")
  
  
  CanvasGadget(0, 200, 200, 200, 200,#PB_Canvas_Container|#PB_Canvas_Border)
  If StartDrawing(CanvasOutput(0))
    Box(0,0,200,200,RGB(80,255,255))
    StopDrawing()
  EndIf  
  
  ;CheckBoxGadget(2,30,30,100,30,"chk") 
  OptionGadget(2,30,30,100,30,"Opt")
  
  CloseGadgetList()
  
  Repeat
    
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Canvas and transparent background gadgets

Post by IdeasVacuum »

Tested on PB5.72x64, Windows7

You are right FlatEarth! I hope this is intentional because it is of course what we want :)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
FlatEarth

Re: Canvas and transparent background gadgets

Post by FlatEarth »

Thanks IdeasVacuum,
It could be a bug for CanvasGadget? because it works properly in ContainerGadget.

Code: Select all

If OpenWindow(0, 0, 0, 600, 600, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  SetWindowColor(0,RGB(80,255,255))
 
  ;CheckBoxGadget(1,30,30,100,30,"chk")
  OptionGadget(1,30,30,100,30,"Opt")
 
 
  ContainerGadget(0, 200, 200, 200, 200)
  
  ;CheckBoxGadget(2,30,30,100,30,"chk")
  OptionGadget(2,30,30,100,30,"Opt")
 
  CloseGadgetList()
  
  SetGadgetColor(0,#PB_Gadget_BackColor, RGB(80,255,255))
  Repeat
   
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
User avatar
Derren
Enthusiast
Enthusiast
Posts: 313
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Canvas and transparent background gadgets

Post by Derren »

You really want a non-transparent background for gadgets on Canvas?
Or are you looking for a way to have transparent gadgets on a window?

For the canvas you simply need to draw a box before you place your gadget.

Code: Select all

If OpenWindow(0, 0, 0, 600, 600, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  SetWindowColor(0,RGB(80,255,255))
 
  ;CheckBoxGadget(1,30,30,100,30,"chk")
  OptionGadget(1,30,30,100,30,"Opt")
 
 
  CanvasGadget(0, 200, 200, 200, 200,#PB_Canvas_Container|#PB_Canvas_Border)
  If StartDrawing(CanvasOutput(0))
  		Box(0,0,200,200,RGB(80,255,255))
  		
  		Box(30,30,100,30,$FFFFFF) ; <-- you would need to get the default window color somehow, if that's what you want.
  		
    StopDrawing()
  EndIf 
 
  ;CheckBoxGadget(2,30,30,100,30,"chk")
  
  
  
  OptionGadget(2,30,30,100,30,"Opt")
 
  CloseGadgetList()
 
  Repeat
   
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
FlatEarth

Re: Canvas and transparent background gadgets

Post by FlatEarth »

I found this way and it is more suitable for me.

Code: Select all

If OpenWindow(0, 0, 0, 600, 600, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  SetWindowColor(0,RGB(80,255,255))
  
  CheckBoxGadget(1,30,30,100,30,"chk")
  OptionGadget(2,30,70,100,30,"Opt")

  CanvasGadget(0, 200, 200, 200, 200,#PB_Canvas_Container|#PB_Canvas_Border)
  If StartDrawing(CanvasOutput(0))
    Box(0,0,200,200,RGB(80,255,255))        
    StopDrawing()
  EndIf
  
  CheckBoxGadget(3,30,30,100,30,"chk")
  OptionGadget(4,30,70,100,30,"Opt")
  
  SetWindowTheme_(GadgetID(3),0,@"")
  SetWindowTheme_(GadgetID(4),0,@"") 
  
  CloseGadgetList()
  
  Repeat
    
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
@Derren : Thanks for your idea.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Canvas and transparent background gadgets

Post by IdeasVacuum »

With my brief test, the TrackBar Gadget is an obstacle. The Help lists Frame, Checkbox and Option Gadgets as being opaque (Windows OS) but they are not. It also lists Text and Hyperlink Gadgets, but you can change their background colour anyway.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply