Page 1 of 1

Dual Status in SysTray

Posted: Mon Oct 31, 2011 11:59 pm
by jamirokwai
Hi there,

while developing my DropMeFTP further, I added the following ProgressBar to the SysTray...
Feel free to use. I think, this will only work on Mac OS X, as the SysTray-Icon is 54x22 Pixels.

edit: Thanks, guys. Seems to work on Windows and Linux, too.

Code: Select all

Global menuletimage
Global systray

Procedure Draw_On_Menulet(top.f,topsize.f,bottom.f,bottomsize.f)
  If StartDrawing(ImageOutput(menuletimage))
    DrawingMode(#PB_2DDrawing_AllChannels)
    Box(0, 0,ImageWidth(menuletimage),ImageHeight(menuletimage),RGBA(0,0,0,0))
    Box(2, 4,ImageWidth(menuletimage) - 4,6,RGBA(0,96,0,255))
    Box(2,13,ImageWidth(menuletimage) - 4,6,RGBA(0,0,96,255))
    Box(2, 4,top / topsize * (ImageWidth(menuletimage) - 4),6,RGBA(0,192,0,255))
    Box(2,13,bottom / bottomsize * (ImageWidth(menuletimage) - 4),6,RGBA(0,0,192,255))
    StopDrawing()
  EndIf
  ChangeSysTrayIcon(systray,ImageID(menuletimage))
  SysTrayIconToolTip(systray, "Current file: " + Str(top) + " of " + Str(topsize) + #CR$ + "All files: " + Str(bottom) + " of " + Str(bottomsize))
EndProcedure

Procedure Create_Menulet_Bar(win,width,height)
  menuletimage = CreateImage(#PB_Any, width + 4, height, 32)
  If StartDrawing(ImageOutput(menuletimage))
    DrawingMode(#PB_2DDrawing_AllChannels)
    Box(0,0,width + 4,height,RGBA(0,0,0,0))
    StopDrawing()
  EndIf
  If Not IsSysTrayIcon(Systray)
    Systray = AddSysTrayIcon(#PB_Any, WindowID(win), ImageID(menuletimage))
  EndIf
EndProcedure

OpenWindow(0,100,100,100,100,"test")
Create_Menulet_Bar(0,50,22)   ; create a Menulet for the Window 0 with Size width x height, e.g. 50,22
i = 0
j = 0
Repeat
  j + Random(5)
  If j >= 50
    i + 5
    j = 0
  EndIf  

  ; Draw and update the Menulet with j (top) and i (bottom), 50 is for setting the maximum width
  ; you may also insert 1234567 bytes of 987654 bytes. Try it
  Draw_On_Menulet(j,50,i,50)
  While WaitWindowEvent(10) : Wend
  Delay(10)
Until i = 50

Re: Dual Status in SysTray - Mac only?

Posted: Tue Nov 01, 2011 12:02 am
by Polo
Nice!

On MacOSX however, it would look better if you were actually displaying these progress bars directly on your dock icon.
Not sure how to do that, but some apps do it and it's quite good :)

Re: Dual Status in SysTray - Mac only?

Posted: Tue Nov 01, 2011 12:21 am
by jamirokwai
Polo wrote:Nice!

On MacOSX however, it would look better if you were actually displaying these progress bars directly on your dock icon.
Not sure how to do that, but some apps do it and it's quite good :)
Yeah,

but on my Air, the Dock is always hidden. Hence, I wouldn't see the tiny bar...
Maybe I will go, and try to add dock-bars in another release :-)

Re: Dual Status in SysTray - Mac only?

Posted: Tue Nov 01, 2011 6:42 pm
by em_uk
Works fine on Win7 x64.

Re: Dual Status in SysTray - Mac only?

Posted: Tue Nov 01, 2011 9:33 pm
by Kwai chang caine
Works fine on XP SP3
Thanks for sharing

Re: Dual Status in SysTray - Mac only?

Posted: Tue Nov 01, 2011 9:39 pm
by idle
works fine ubuntu nice :mrgreen: