Page 1 of 1

[Solved] Frame or container gadget with background

Posted: Fri Jun 07, 2024 4:20 pm
by Num3
Hi guys,

Long time no post!

I want some ideas on how to make a better looking frame or panel gadget. I would like to mimic the one in the image, that uses a gradient.
I was thinking on creating an image and place the gadgets over it, or if possible set the container background with the gradient.

Image

Re: Frame or container gadget with background

Posted: Fri Jun 07, 2024 5:12 pm
by RASHAD
Hi
For Windows

Code: Select all

Result = LoadImage(0, "girl2.bmp")
hBrush = CreatePatternBrush_(ImageID(0))

Procedure sizeCB()
  ResizeGadget(1,#PB_Ignore,#PB_Ignore,WindowWidth(0)-20,WindowHeight(0)-20)
EndProcedure

OpenWindow(0,0,0,640,480,"", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered) 
ContainerGadget(1, 10,10,620,460) 
  StringGadget(2,10,10,100,24,"") 
  ButtonGadget(3,120,10,50,24,"OK") 
CloseGadgetList()
SetClassLongPtr_(GadgetID(1), #GCL_HBRBACKGROUND, hBrush)

BindEvent(#PB_Event_SizeWindow,@sizeCB())

Repeat
  Select WaitWindowEvent(1)
    Case #PB_Event_CloseWindow
      Quit = 1
  EndSelect
Until Quit = 1

Re: Frame or container gadget with background

Posted: Fri Jun 07, 2024 5:38 pm
by Num3
Nice!

I cooked this one up in the mean time :D

Code: Select all

#Font = 0

If OpenWindow(0, 0, 0, 600, 600, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  font=LoadFont(#Font,"Segoe UI",11,#PB_Font_HighQuality)
  
  If font
    SetGadgetFont(#PB_Default,FontID(#Font))
  EndIf
  
  CanvasGadget(0, 10, 10, WindowWidth(0)-20, WindowHeight(0)-20,#PB_Canvas_Container)
  If StartDrawing(CanvasOutput(0))
     
    DrawingMode(#PB_2DDrawing_Gradient)      
    BackColor($D8D8DD)
    FrontColor($FFFFFF)    
    LinearGradient(0, 50, 0, WindowHeight(0)-20)        		
    Box(0,0,WindowWidth(0)-20,WindowHeight(0)-20,$FFFFFF) ; <-- you would need to get the default window color somehow, if that's what you want.
    
    DrawingMode(#PB_2DDrawing_Default)  
    
    LineXY(0,0,0,WindowHeight(0)-20,$A0A0A0)
    LineXY(0,0,WindowWidth(0)-20,0,$A0A0A0)
    LineXY(WindowWidth(0)-21,0,WindowWidth(0)-21,WindowWidth(0)-21,$A0A0A0)
    LineXY(0,WindowHeight(0)-21,WindowWidth(0)-21,WindowHeight(0)-21,$A0A0A0)
    
    StopDrawing()
  EndIf 
  
  OptionGadget(2,30,30,100,30,"Option")
  ButtonGadget(3,30, 80 , 100, 50, "Click Me",#PB_Button_Default)
  StringGadget(4,30, 140, 300, 30, "Sample text")
  StringGadget(5,30, 180, 300, 30, "Sample text 2")
  
  CloseGadgetList()
  
  DisableGadget(0,false)
  
  Repeat
    
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf