Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
To do that, just open a window with the #PB_Window_Background flag, then you can use Get/SetWindowTitle() to change the browser window title. Once Set/GetWindowColor() will be supported, you will be able to change the background window. Then only an image will be missing, a new command could be done for that.
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
Thanks Fred, this already works! Very nice!Fred wrote:To do that, just open a window with the #PB_Window_Background flag,
Code: Select all
If OpenWindow(0,0,0,0,0,"",#PB_Window_Background)
SetWindowTitle(0,"Window example")
CreateImage(0,DesktopWidth(0),DesktopHeight(0),24,0)
If StartDrawing(ImageOutput(0))
For y = 0 To OutputHeight() Step 20
Box(0,y ,OutputWidth(),10,RGB($40,$40,$40))
Box(0,y+10,OutputWidth(),10,RGB($50,$50,$50))
Next
StopDrawing()
EndIf
ImageGadget(0,0,0,DesktopWidth(0),DesktopHeight(0),ImageID(0))
For i = 0 To 5
ButtonGadget(#PB_Any,20,20+i*25,100,20,"Button "+Str(i+1))
Next i
progress = ProgressBarGadget(#PB_Any,130,20,200,20,0,100)
SetGadgetState(progress,40)
OpenWindow(1,200,80,400,200,"Window",#PB_Window_Tool|#PB_Window_SizeGadget,WindowID(0))
EndIf
Could this be added, and also an event for browser window size change? In this case I could also
re-generate the background image for the ImageGadget().
BTW: Shouldn't SpiderBasic constants be named #SB_XXXX? Using #PB_ is a bit weird for SB.
Maybe better to use #SB_ mainly and for compatibility to PB define the #PB_ constants additionally.
cya,
...Danilo
...Danilo
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
I think than if we rename the constants, we can forget about any crossplatform code between SB and PB. I agree it's a bit wierd, but IHMO it worths it.
About the size window event, it should work:
About the size window event, it should work:
Code: Select all
Procedure BackgroundResize()
Debug "Resize: "+WindowWidth(0) + "x" + WindowHeight(0)
EndProcedure
If OpenWindow(0,0,0,0,0,"",#PB_Window_Background)
BindEvent(#PB_Event_SizeWindow, @BackgroundResize(), 0)
SetWindowTitle(0,"Window example")
CreateImage(0,DesktopWidth(0),DesktopHeight(0),24,0)
If StartDrawing(ImageOutput(0))
For y = 0 To OutputHeight() Step 20
Box(0,y ,OutputWidth(),10,RGB($40,$40,$40))
Box(0,y+10,OutputWidth(),10,RGB($50,$50,$50))
Next
StopDrawing()
EndIf
ImageGadget(0,0,0,DesktopWidth(0),DesktopHeight(0),ImageID(0))
For i = 0 To 5
ButtonGadget(#PB_Any,20,20+i*25,100,20,"Button "+Str(i+1))
Next i
progress = ProgressBarGadget(#PB_Any,130,20,200,20,0,100)
SetGadgetState(progress,40)
OpenWindow(1,200,80,400,200,"Window",#PB_Window_Tool|#PB_Window_SizeGadget,WindowID(0))
EndIf
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
Thanks, it works. SetGadgetState() for ImageGadget() doesn't seem to work,Fred wrote:About the size window event, it should work:
so I can't update the background picture.
Code: Select all
Procedure CreateBackground()
CreateImage(0,WindowWidth(0),WindowHeight(0),24,0)
If StartDrawing(ImageOutput(0))
For y = 0 To OutputHeight() Step 20
Box(0,y ,OutputWidth(),10,RGB($40,$40,$40))
Box(0,y+10,OutputWidth(),10,RGB($50,$50,$50))
Next
StopDrawing()
EndIf
EndProcedure
Procedure BackgroundResize()
;Debug "Resize: "+WindowWidth(0) + "x" + WindowHeight(0)
CreateBackground()
ResizeGadget(0,0,0,WindowWidth(0),WindowHeight(0))
SetGadgetState(0,ImageID(0))
Debug GadgetWidth(0) ; correct size, but image not updated/refreshed
;UseGadgetList(WindowID(0))
;ImageGadget(0,0,0,DesktopWidth(0),DesktopHeight(0),ImageID(0))
EndProcedure
If OpenWindow(0,0,0,0,0,"",#PB_Window_Background)
BindEvent(#PB_Event_SizeWindow, @BackgroundResize(), 0)
SetWindowTitle(0,"Window example")
CreateBackground()
ImageGadget(0,0,0,DesktopWidth(0),DesktopHeight(0),ImageID(0))
For i = 0 To 5
ButtonGadget(#PB_Any,20,20+i*25,100,20,"Button "+Str(i+1))
Next i
progress = ProgressBarGadget(#PB_Any,130,20,200,20,0,100)
SetGadgetState(progress,40)
OpenWindow(1,200,80,400,200,"Window",#PB_Window_Tool|#PB_Window_SizeGadget,WindowID(0))
EndIf
cya,
...Danilo
...Danilo
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
> Shouldn't SpiderBasic constants be named #SB_XXXX? Using #PB_ is a bit weird for SB
Isn't it for compatibility with PureBasic? So we can code an app for desktops
that will also run in the browser, without needing CompilerIf every few lines?
Isn't it for compatibility with PureBasic? So we can code an app for desktops
that will also run in the browser, without needing CompilerIf every few lines?
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
Did you miss the next line?PB. wrote:> Shouldn't SpiderBasic constants be named #SB_XXXX? Using #PB_ is a bit weird for SB
Isn't it for compatibility with PureBasic? So we can code an app for desktops
that will also run in the browser, without needing CompilerIf every few lines?
Danilo wrote:Maybe better to use #SB_ mainly and for compatibility to PB define the #PB_ constants additionally.
cya,
...Danilo
...Danilo
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
Thank you @Danilo.
I've test it to WindowColor and change in your Code:
I've test it to WindowColor and change in your Code:
Code: Select all
If OpenWindow(0,0,0,0,0,"",#PB_Window_Background)
SetWindowTitle(0,"Window example")
CreateImage(0,DesktopWidth(0),DesktopHeight(0),24,0)
If StartDrawing(ImageOutput(0))
For y = 0 To OutputHeight() Step 20
Box(0,y ,OutputWidth(),10,RGB($40,$40,$40))
Box(0,y+10,OutputWidth(),10,RGB($50,$50,$50))
Next
StopDrawing()
EndIf
ImageGadget(0,0,0,DesktopWidth(0),DesktopHeight(0),ImageID(0))
For i = 0 To 5
ButtonGadget(#PB_Any,20,20+i*25,100,20,"Button "+Str(i+1))
Next i
progress = ProgressBarGadget(#PB_Any,130,20,200,20,0,100)
SetGadgetState(progress,40)
OpenWindow(1,200,80,400,200,"Window",#PB_Window_Tool|#PB_Window_SizeGadget,WindowID(0))
CreateImage(1,WindowWidth(1),WindowHeight(1),24,RGB(255,0,0))
If StartDrawing(ImageOutput(1))
Box(1,0,0,OutputWidth())
StopDrawing()
EndIf
ImageGadget(1,0,0,WindowWidth(1),WindowHeight(1),ImageID(1))
EndIf
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
SetWindowTitle(0, "Window0 w/PB fn") ;<-- Why does this change the browser page title?
Code: Select all
Macro SetDesktopTitle(title_txt)
; 'title' fails since it is a JS keyword.
!document.title = title_txt;
EndMacro
Procedure.s GetDesktopTitle()
!return document.title;
EndProcedure
;Debug GetDesktopTitle()
SetDesktopTitle("BrowserPage w/JS")
;Debug GetDesktopTitle()
If OpenWindow(0,0,0,0,0,"blah",#PB_Window_Background)
CreateImage(0,DesktopWidth(0),DesktopHeight(0),24,0)
If StartDrawing(ImageOutput(0))
For y = 0 To OutputHeight() Step 20
Box(0,y ,OutputWidth(),10,RGB($40,$40,$40))
Box(0,y+10,OutputWidth(),10,RGB($50,$50,$50))
Next
StopDrawing()
EndIf
ImageGadget(0,0,0,DesktopWidth(0),DesktopHeight(0),ImageID(0))
For i = 0 To 5
ButtonGadget(#PB_Any,20,20+i*25,100,20,"Button "+Str(i+1))
Next i
progress = ProgressBarGadget(#PB_Any,130,20,200,20,0,100)
SetGadgetState(progress,40)
OpenWindow(1,200,80,400,200,"Window1",#PB_Window_Tool|#PB_Window_SizeGadget,WindowID(0))
CreateImage(1,WindowWidth(1),WindowHeight(1),24,RGB(255,0,0))
If StartDrawing(ImageOutput(1))
Box(1,0,0,OutputWidth())
StopDrawing()
EndIf
ImageGadget(1,0,0,WindowWidth(1),WindowHeight(1),ImageID(1))
EndIf
SetWindowTitle(0, "Window0 w/PB fn") ;<-- Why does this change the browser page title?
SetWindowTitle(1, "Window1 w/PB fn")
When working toward the solution of a problem, it always helps if you know the answer. ~ ?
An expert is one who knows more and more about less and less until he knows absolutely everything about nothing. ~ Weber
An expert is one who knows more and more about less and less until he knows absolutely everything about nothing. ~ Weber
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
skywalk wrote:SetWindowTitle(0, "Window0 w/PB fn") ;<-- Why does this change the browser page title?
Greetings ... Peter[color=#AA0000]Fred[/color] wrote:just open a window with the #PB_Window_Background flag, then you can use Get/SetWindowTitle() to change the browser window title.
Re: Set/GetDesktopTitle() and Set/GetDesktopBackgroundColor
Ahh, that was confusing me?
Code: Select all
If OpenWindow(0,0,0,0,0,"Title Ignored",#PB_Window_Background) ; Title = SpiderApp if #PB_Window_Background
When working toward the solution of a problem, it always helps if you know the answer. ~ ?
An expert is one who knows more and more about less and less until he knows absolutely everything about nothing. ~ Weber
An expert is one who knows more and more about less and less until he knows absolutely everything about nothing. ~ Weber