Page 1 of 1

Another Vista progress bar

Posted: Sat Mar 01, 2008 3:37 pm
by Michael Vogel
Hi,

just did a small green bar which looks not that bad...

Download: http://sudokuprogram.googlepages.com/ProgressBar.zip

Michael

Code: Select all

; Define

	DataSection
		GreenLeft:		IncludeBinary "Data\GL.bmp"
		GreenMid:		IncludeBinary "Data\GM.bmp"
		GreenRight:	IncludeBinary "Data\GR.bmp"
		GrayLeft:		IncludeBinary "Data\XL.bmp"
		GrayMid:		IncludeBinary "Data\XM.bmp"
		GrayRight:	IncludeBinary "Data\XR.bmp"
		GreenLefto:	IncludeBinary "Data\HL.bmp"
		GreenMido:	IncludeBinary "Data\HM.bmp"
		GreenRighto:	IncludeBinary "Data\HR.bmp"
		GrayLefto:		IncludeBinary "Data\YL.bmp"
		GrayMido:		IncludeBinary "Data\YM.bmp"
		GrayRighto:	IncludeBinary "Data\YR.bmp"
	EndDataSection

	Enumeration 10000
		#Progress_Dummy
		#Progress_GreenLeft
		#Progress_GreenMid
		#Progress_GreenRight
		#Progress_GrayLeft
		#Progress_GrayMid
		#Progress_GrayRight
		#Progress_GreenLefto
		#Progress_GreenMido
		#Progress_GreenRighto
		#Progress_GrayLefto
		#Progress_GrayMido
		#Progress_GrayRighto
	EndEnumeration

	CatchImage(#Progress_GreenLeft,?GreenLeft)
	CatchImage(#Progress_GreenMid,?GreenMid)
	CatchImage(#Progress_GreenRight,?GreenRight)
	CatchImage(#Progress_GrayLeft,?GrayLeft)
	CatchImage(#Progress_GrayMid,?GrayMid)
	CatchImage(#Progress_GrayRight,?GrayRight)
	CatchImage(#Progress_GreenLefto,?GreenLefto)
	CatchImage(#Progress_GreenMido,?GreenMido)
	CatchImage(#Progress_GreenRighto,?GreenRighto)
	CatchImage(#Progress_GrayLefto,?GrayLefto)
	CatchImage(#Progress_GrayMido,?GrayMido)
	CatchImage(#Progress_GrayRighto,?GrayRighto)

	#Progress_SmallHeight=11;	11 Pixel Höhe (klein)
	#Progress_BigHeight=15;		15 Pixel Höhe (groß)
	#Progress_Width=32;			32 Pixel Breite
	#Progress_Double=64;			doppelte Breite
	#Progress_BigOffset=6;			6 Bilder pro Größe

	Enumeration
		#ProgressBar
	EndEnumeration

	Structure ProgressBarType
		Image.l
		ImageID.l
		Gadget.l
		Length.l
		Height.l
		Size.l
	EndStructure

	Global Progress_MaxCount=5
	Global Dim Progress_Database.ProgressBarType(Progress_MaxCount)

; EndDefine

Procedure ProgressBarValue(ID,Value)

	Protected x

	With Progress_Database(ID)
		; Value 0..1023
		If Value<1024
			Value*\Length
			Value>>10
		Else
			Value=\Length-1
		EndIf

		StartDrawing(ImageOutput(\Image))

		; Grauer Balken
		DrawImage(ImageID(#Progress_GrayLeft+\Size),0,0)
		DrawImage(ImageID(#Progress_GrayRight+\Size),\Length-#Progress_Width,0)
		If \Length>#Progress_Double
			DrawImage(ImageID(#Progress_GrayMid+\Size),#Progress_Width,0,\Length-#Progress_Double,\Height)
		EndIf

		; Grüner Balken
		If Value>1
			If Value<#Progress_Double
				x=(Value+1)>>1
				GrabImage(#Progress_GreenLeft+\Size,#Progress_Dummy,0,0,x,\Height)
				DrawImage(ImageID(#Progress_Dummy),0,0)
				GrabImage(#Progress_GreenRight+\Size,#Progress_Dummy,#Progress_Width-x,0,x,\Height)
				DrawImage(ImageID(#Progress_Dummy),Value-x,0)
			Else
				DrawImage(ImageID(#Progress_GreenLeft+\Size),0,0)
				DrawImage(ImageID(#Progress_GreenMid+\Size),#Progress_Width,0,Value-#Progress_Double,\Height)
				DrawImage(ImageID(#Progress_GreenRight+\Size),Value-#Progress_Width,0)
			EndIf
		EndIf

		StopDrawing()
		SetGadgetState(\Gadget,\ImageID)
	EndWith
EndProcedure
Procedure CreateProgressBar(ID,x,y,Length,Size)

	; Length muss mindestens 40 Pixel betragen

	With Progress_Database(ID)
		If Size
			\Size=6
			Size=#Progress_BigHeight
		Else
			\Size=0
			Size=#Progress_SmallHeight
		EndIf

		\Length=Length
		\Height=Size
		\Gadget=ImageGadget(#PB_Any,x,y,Length,Height,Size)
		\Image=CreateImage(#PB_Any,Length,Size)
		\ImageID=ImageID(\Image)
		ProgressBarValue(ID,0)
	EndWith

EndProcedure

Procedure Main()

	OpenWindow(0,0,0,300,100,"Vistabar by Michael Vogel",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)

	CreateGadgetList(WindowID(0))
	CreateProgressBar(0,40,10,220,0)
	CreateProgressBar(1,40,30,220,0)
	CreateProgressBar(2,40,52,110,0)
	CreateProgressBar(3,160,50,100,1)
	CreateProgressBar(4,40,74,220,1)

	While WaitWindowEvent(10)<>#PB_Event_CloseWindow
		ProgressBarValue(0,n>>4)
		ProgressBarValue(1,z)
		ProgressBarValue(2,z<<1)
		ProgressBarValue(3,n>>5)
	n0=n%2048 : If n0>>10 : n0=2048-n0 : EndIf
	ProgressBarValue(4,n0%1024)
	z+1
	n+Random(19)
Wend

EndProcedure

Main()
[/url]

Posted: Sat Mar 01, 2008 3:46 pm
by rsts
Nice - I love this kind of stuff :D

Thanks for sharing.

cheers

Posted: Sat Mar 01, 2008 4:04 pm
by Rook Zimbabwe
Great job! Now if I make it a DLL or a gadget can I call it VistaBar? :D

Posted: Sat Mar 01, 2008 6:53 pm
by eJan
Very nice, thanks!

Posted: Mon Mar 03, 2008 2:34 pm
by Michael Vogel
Just some small points which should be changed in the code...

Remove useless...

Code: Select all

Enumeration 
   #ProgressBar 
EndEnumeration
Change...

Code: Select all

\Size=6; ...to...
\Size=#Progress_BigOffset

;...and...
\Gadget=ImageGadget(#PB_Any,x,y,Length,Height,Size); ...to...
\Gadget=ImageGadget(#PB_Any,x,y,Length,Height,0) 

Posted: Mon Mar 03, 2008 10:57 pm
by Rook Zimbabwe
I don't think so.

While #PB_Any may be simple. Some people like to control the allocation of enumerations. While it is possible to get the number of a gadget with #PB_Any... if you just used Enumeration / Endenumeration... you wouldnot have to and could just use #GadegtID (whatever was in the enumeration) as its pointer.

This is especially useful if you have groups of items enumerated like #Button_0 to #Button_99 (etc.) and want to effect some massive control change.
for x = #Button_0 to #Button_99
disablegadget(x)
next
Less sloppy that way IMUO! - And I am unanimous in that!!! :D

Posted: Tue Mar 04, 2008 8:32 am
by Michael Vogel
You're right - I also use enumerated lists "for normal"...

The only point why I used the PB_Any way was that I thought it can get complicate when adding my routines to an existing program (which already uses a big numbers of IDs)...

...but in fact this would also be no problem, so I agree and would offer to change the #PB_Any to (ID+#Progress_Bar_GadgetID_Offset_Value) or something like that...

otherwise you have to program more complicate things like this...

Code: Select all

for x = 0 to Maximum_Progress_Bars
     DisableProgressBar(x); Inside that: FreeImage(Progress_DataBase(x)\ImageID)
next x

Posted: Tue Mar 04, 2008 8:43 pm
by kinglestat
Very nice

Thanks for sharing

Posted: Wed Mar 05, 2008 9:17 am
by Kwai chang caine
Splendid 8)

Posted: Wed Mar 05, 2008 1:08 pm
by majk
Hi Michael,

thank you for your implementation! You had inspired me to try it for my own.

My Features:
- Skinnable (like yours!)
- Threadsafe
- EnableExplicit
- Speedoptimized (i think someone could do it better. by the way my implementation is a little bit slower than yours)
- No OS specific Funktions
- Easy to use (i hope so)

Some Remarks:
- Linux should work; i have not try it yet
- Speed under Windows XP is okay; 10 times slower than a native
Windows XP Skinned ProgressBarGadget


Image



If anyone like it -> use it ;-)


Download: http://scuttle.absolut-marc.de/progressbar.zip

Code: Select all

;
;
;   Progressbar
;

EnableExplicit

Enumeration
  #mod_progressbar_enum_prgbr_done_left
  #mod_progressbar_enum_prgbr_done_element
  #mod_progressbar_enum_prgbr_done_current
  #mod_progressbar_enum_prgbr_open_element
  #mod_progressbar_enum_prgbr_open_right
EndEnumeration

Structure progressbar
  	Image.l         ; Image
		ImageID.l       ; ImageID
		Gadgetid.l      ; GadgetID
		Width.l
		Height.l
		min.l 
		max.l
		value.l
EndStructure

Structure prgbr_ressources
    type.l
    image.l
    imageid.l
    width.l
EndStructure    

NewList mod_progressbar.progressbar()
NewList mod_prgbr_ressources.prgbr_ressources()

CompilerIf #PB_Compiler_Thread = 1
  ; Support for thread safe
  Define mod_progressbar_mutex.l
  Define mod_prgbr_ressources_mutex.l
  mod_progressbar_mutex       = CreateMutex()
  mod_prgbr_ressources_mutex  = CreateMutex()
CompilerEndIf

Define mod_progressbar_minsize.l                          ; Min possible calculated Size for Progressbar

Define mod_progressbar_image4speed_zeropercent_image.l    ; Optimized4Speed: A   0% Progressbar w = Screenwidth
Define mod_progressbar_image4speed_hundredpercent_image.l ; Optimized4Speed: A 100% Progressbar w = Screenwidth

CompilerIf #PB_Compiler_Thread = 1
  ; Support for thread safe
  Define mod_progressbar_image4speed_mutex.l
  mod_progressbar_image4speed_mutex = CreateMutex()
CompilerEndIf  





Procedure mod_progressbar_internal_prepare4speed()

    ; Prepare for optimization

    Shared mod_progressbar_image4speed_zeropercent_image
    Shared mod_progressbar_image4speed_hundredpercent_image

    Shared mod_prgbr_ressources.prgbr_ressources()
    
    CompilerIf #PB_Compiler_Thread = 1
      Shared mod_prgbr_ressources_mutex.l
      Shared mod_progressbar_image4speed_mutex.l
    CompilerEndIf
    
    Define i_width.l
    Define i_width2.l
    Define i_counter.l
  
    CompilerIf #PB_Compiler_Thread = 1  
      ; Lock Mutex within thread safe environment
      LockMutex(mod_prgbr_ressources_mutex)
      LockMutex(mod_progressbar_image4speed_mutex)
    CompilerEndIf
    
    ExamineDesktops()
    i_width = DesktopWidth(0)
    
    SelectElement(mod_prgbr_ressources(),#mod_progressbar_enum_prgbr_done_left)
    mod_progressbar_image4speed_zeropercent_image     = CreateImage(#PB_Any,i_width,ImageHeight(mod_prgbr_ressources()\image))
    mod_progressbar_image4speed_hundredpercent_image  = CreateImage(#PB_Any,i_width,ImageHeight(mod_prgbr_ressources()\image))  
    
    ; Create 100% Image
    StartDrawing(ImageOutput(mod_progressbar_image4speed_hundredpercent_image))
      ; Done Left
      SelectElement(mod_prgbr_ressources(),#mod_progressbar_enum_prgbr_done_left)
      DrawImage(mod_prgbr_ressources()\imageid,0,0)
      ; Done Element
      i_counter = ImageWidth(mod_prgbr_ressources()\image)
      SelectElement(mod_prgbr_ressources(),#mod_progressbar_enum_prgbr_done_element)
      i_width2  = ImageWidth(mod_prgbr_ressources()\image)
      While i_counter < i_width-1
        DrawImage(mod_prgbr_ressources()\imageid,i_counter,0)
        i_counter + i_width2
      Wend
      ; Open Right
      SelectElement(mod_prgbr_ressources(),#mod_progressbar_enum_prgbr_open_right)
      i_width2 = ImageWidth(mod_prgbr_ressources()\image)
      DrawImage(mod_prgbr_ressources()\imageid,i_width - i_width2,0)
    StopDrawing()
    
    ; Create 0% Image
    StartDrawing(ImageOutput(mod_progressbar_image4speed_zeropercent_image))
      ; Done Left
      SelectElement(mod_prgbr_ressources(),#mod_progressbar_enum_prgbr_done_left)
      DrawImage(mod_prgbr_ressources()\imageid,0,0)
      ; Done Element
      i_counter = 1
      SelectElement(mod_prgbr_ressources(),#mod_progressbar_enum_prgbr_open_element)
      i_width2  = ImageWidth(mod_prgbr_ressources()\image)
      While i_counter < i_width-1
        DrawImage(mod_prgbr_ressources()\imageid,i_counter,0)
        i_counter + i_width2
      Wend
      ; Open Right
      SelectElement(mod_prgbr_ressources(),#mod_progressbar_enum_prgbr_open_right)
      i_width2 = ImageWidth(mod_prgbr_ressources()\image)
      DrawImage(mod_prgbr_ressources()\imageid,i_width - i_width2,0)
    StopDrawing()   
    

    CompilerIf #PB_Compiler_Thread = 1  
      ; Lock Mutex within thread safe environment
      UnlockMutex(mod_progressbar_image4speed_mutex)
      UnlockMutex(mod_prgbr_ressources_mutex)
    CompilerEndIf

EndProcedure

Procedure mod_progressbar_FreeGadget(gadgetid.l)

  Shared mod_progressbar.progressbar()
  
  CompilerIf #PB_Compiler_Thread = 1
    Shared mod_progressbar_mutex.l
  CompilerEndIf
  
  CompilerIf #PB_Compiler_Thread = 1  
    ; Lock Mutex within thread safe environment
    LockMutex(mod_progressbar_mutex)
  CompilerEndIf
  
    ResetList(mod_progressbar())
    ForEach mod_progressbar()
      If mod_progressbar()\gadgetid = gadgetid
          FreeImage(mod_progressbar()\Image)
          FreeGadget(mod_progressbar()\GadgetID)
          DeleteElement(mod_progressbar())
        Break
      EndIf
    Next

  CompilerIf #PB_Compiler_Thread = 1  
    ; Lock Mutex within thread safe environment
    UnlockMutex(mod_progressbar_mutex)
  CompilerEndIf
  
EndProcedure

Procedure mod_progressbar_init()

  ; INIT (or use your own init)

  Shared mod_prgbr_ressources.prgbr_ressources()
  Shared mod_progressbar_minsize.l
    
  CompilerIf #PB_Compiler_Thread = 1
    Shared mod_prgbr_ressources_mutex.l
  CompilerEndIf

  UseJPEGImageDecoder()

  CompilerIf #PB_Compiler_Thread = 1  
    ; Lock Mutex within thread safe environment
    LockMutex(mod_prgbr_ressources_mutex)
  CompilerEndIf
  
    AddElement(mod_prgbr_ressources())
      mod_prgbr_ressources()\type   = #mod_progressbar_enum_prgbr_done_left
      mod_prgbr_ressources()\image  = LoadImage(#PB_Any,"images\prgrb_done_left.jpg")
      mod_prgbr_ressources()\imageid= ImageID(mod_prgbr_ressources()\image)
      mod_prgbr_ressources()\width  = ImageWidth(mod_prgbr_ressources()\image)
      mod_progressbar_minsize + mod_prgbr_ressources()\width

    AddElement(mod_prgbr_ressources())
      mod_prgbr_ressources()\type   = #mod_progressbar_enum_prgbr_done_element
      mod_prgbr_ressources()\image  = LoadImage(#PB_Any,"images\prgrb_done_element.jpg")
      mod_prgbr_ressources()\imageid= ImageID(mod_prgbr_ressources()\image)
      mod_prgbr_ressources()\width  = ImageWidth(mod_prgbr_ressources()\image)
      mod_progressbar_minsize + mod_prgbr_ressources()\width

    AddElement(mod_prgbr_ressources())
      mod_prgbr_ressources()\type   = #mod_progressbar_enum_prgbr_done_current
      mod_prgbr_ressources()\image  = LoadImage(#PB_Any,"images\prgrb_done_current.jpg")
      mod_prgbr_ressources()\imageid= ImageID(mod_prgbr_ressources()\image)
      mod_prgbr_ressources()\width  = ImageWidth(mod_prgbr_ressources()\image)
      mod_progressbar_minsize + mod_prgbr_ressources()\width

    AddElement(mod_prgbr_ressources())
      mod_prgbr_ressources()\type   = #mod_progressbar_enum_prgbr_open_element
      mod_prgbr_ressources()\image  = LoadImage(#PB_Any,"images\prgrb_open_element.jpg")
      mod_prgbr_ressources()\imageid= ImageID(mod_prgbr_ressources()\image)
      mod_prgbr_ressources()\width  = ImageWidth(mod_prgbr_ressources()\image)
      mod_progressbar_minsize + mod_prgbr_ressources()\width

    AddElement(mod_prgbr_ressources())
      mod_prgbr_ressources()\type   = #mod_progressbar_enum_prgbr_open_right
      mod_prgbr_ressources()\image  = LoadImage(#PB_Any,"images\prgrb_open_right.jpg")
      mod_prgbr_ressources()\imageid= ImageID(mod_prgbr_ressources()\image)
      mod_prgbr_ressources()\width  = ImageWidth(mod_prgbr_ressources()\image)
      mod_progressbar_minsize + mod_prgbr_ressources()\width

  CompilerIf #PB_Compiler_Thread = 1  
    ; Lock Mutex within thread safe environment
    UnlockMutex(mod_prgbr_ressources_mutex)
  CompilerEndIf
  
  ; AFTER INIT YOU HAVE TO CALL mod_progressbar_internal_prepare4speed() !
  mod_progressbar_internal_prepare4speed()
  
EndProcedure

Procedure mod_progressbar_GetGadgetState(gadgetid.l)

  Shared mod_progressbar.progressbar()
  
  CompilerIf #PB_Compiler_Thread = 1
    Shared mod_progressbar_mutex.l
  CompilerEndIf
  
  Define retval.l
  
  CompilerIf #PB_Compiler_Thread = 1  
    ; Lock Mutex within thread safe environment
    LockMutex(mod_progressbar_mutex)
  CompilerEndIf
  
    ResetList(mod_progressbar())
    ForEach mod_progressbar()
      If mod_progressbar()\gadgetid = gadgetid
        retval = mod_progressbar()\value
        Break
      EndIf
    Next

  CompilerIf #PB_Compiler_Thread = 1  
    ; Lock Mutex within thread safe environment
    UnlockMutex(mod_progressbar_mutex)
  CompilerEndIf
  
  ProcedureReturn retval
  
EndProcedure

Procedure mod_progressbar_SetGadgetState(gadgetid.l,value.l)
  ;
  ;
  ;
  Shared mod_progressbar.progressbar()
  Shared mod_prgbr_ressources.prgbr_ressources()
  
  Shared mod_progressbar_image4speed_hundredpercent_image
  Shared mod_progressbar_image4speed_zeropercent_image
  
  CompilerIf #PB_Compiler_Thread = 1
    Shared mod_progressbar_mutex.l
    Shared mod_prgbr_ressources_mutex.l
    Shared mod_progressbar_image4speed_mutex.l
  CompilerEndIf
  
  Define i_tmp_image.l          ; procedure internal image
  Define i_tmp_image_x.l        ;
  Define i_tmp_image_w.l
  Define i_tmp_image_h.l
  Define i_pixel.f
  

  CompilerIf #PB_Compiler_Thread = 1  
    ; Lock Mutex within thread safe environment
    LockMutex(mod_progressbar_mutex)
    LockMutex(mod_prgbr_ressources_mutex)
    LockMutex(mod_progressbar_image4speed_mutex)
  CompilerEndIf
  
    ResetList(mod_progressbar())
    ForEach mod_progressbar()
      If mod_progressbar()\gadgetid = gadgetid
        Break
      EndIf
    Next
    
    ; Calc
    
    If value < 0
      value = 0
    EndIf
    
    i_pixel = (mod_progressbar()\width-2)/(mod_progressbar()\max - mod_progressbar()\min) * (value - mod_progressbar()\min) +1
    If i_pixel > mod_progressbar()\width
      i_pixel = mod_progressbar()\width
    EndIf
    
    ; Draw
    
    StartDrawing(ImageOutput(mod_progressbar()\image))
      
      ; Draw DONE Part
      ;SelectElement(mod_prgbr_ressources(),#mod_progressbar_enum_prgbr_done_left)

      i_tmp_image_x = 0
      i_tmp_image_w = i_pixel
      i_tmp_image_h = ImageHeight(mod_progressbar()\image)
      i_tmp_image = GrabImage(mod_progressbar_image4speed_hundredpercent_image,#PB_Any,0,0,i_tmp_image_w,i_tmp_image_h)
      
      DrawImage(ImageID(i_tmp_image),0,0)
      FreeImage(i_tmp_image)
      
      ; Draw OPEN Part

      i_tmp_image_x = ImageWidth(mod_progressbar_image4speed_zeropercent_image)-(mod_progressbar()\width - i_pixel)
      i_tmp_image_w = mod_progressbar()\width - i_pixel
      If i_tmp_image_w > 0
        i_tmp_image = GrabImage(mod_progressbar_image4speed_zeropercent_image,#PB_Any,i_tmp_image_x,0,i_tmp_image_w,i_tmp_image_h)
        DrawImage(ImageID(i_tmp_image),i_pixel,0)
        FreeImage(i_tmp_image)
      EndIf

    StopDrawing()
    
    mod_progressbar()\value = value
    
    SetGadgetState(mod_progressbar()\gadgetid,mod_progressbar()\imageid)
  
  CompilerIf #PB_Compiler_Thread = 1  
    ; UnLock Mutex within thread safe environment
    UnlockMutex(mod_progressbar_image4speed_mutex)
    UnlockMutex(mod_prgbr_ressources_mutex)
    UnlockMutex(mod_progressbar_mutex)
  CompilerEndIf


EndProcedure

Procedure.l mod_progressbar_ProgressbarGadget(gadgetid.l, x.l, y.l, width.l, height.l, min.l, max.l) 
  ;
  ; 
  ;
  
  Shared mod_progressbar.progressbar()
  Shared mod_progressbar_minsize.l
  
  CompilerIf #PB_Compiler_Thread = 1
    Shared mod_progressbar_mutex.l
  CompilerEndIf
  
  Define image.l
  Define gadgetretvalue.l
  
  ; Value Check
  If width < mod_progressbar_minsize
    CompilerIf #PB_Compiler_Debugger = 1
      Debug "Warning: Invalid value for ProgressbarGadget. width < mod_progressbar_minsize !"
    CompilerElse
    width = mod_progressbar_minsize
    CompilerEndIf
  EndIf
  
  If min > max
    CompilerIf #PB_Compiler_Debugger = 1
      Debug "Warning: Invalid value for ProgressbarGadget. min > max !"
    CompilerElse
      min = max
    CompilerEndIf
  EndIf
  
  ; Create Gadget
  gadgetretvalue = ImageGadget(gadgetid,x,y,width,height,0)
  If gadgetretvalue = 0
    ProcedureReturn 0
  EndIf
  If gadgetid = #PB_Any
    gadgetid = gadgetretvalue
  EndIf
  
  ; Create Image
  image = CreateImage(#PB_Any,width,height)
  
  CompilerIf #PB_Compiler_Thread = 1  
    ; Lock Mutex within thread safe environment
    LockMutex(mod_progressbar_mutex)
  CompilerEndIf
  
      AddElement(mod_progressbar())
        mod_progressbar()\Image   = image
        mod_progressbar()\ImageID = ImageID(image)
        mod_progressbar()\Gadgetid= gadgetid
        mod_progressbar()\Width   = width
        mod_progressbar()\Height  = height
        mod_progressbar()\min     = min
        mod_progressbar()\max     = max
    
  CompilerIf #PB_Compiler_Thread = 1  
    ; Unlock Mutex within thread safe environment
    UnlockMutex(mod_progressbar_mutex)
  CompilerEndIf
  
  ; Paint Gadget
  mod_progressbar_SetGadgetState(gadgetid.l,min)
  
  ProcedureReturn gadgetid
  
EndProcedure

Posted: Fri Mar 07, 2008 1:31 pm
by walker
The Progressbar by Michael Vogel works fine on Linux if you change the Datasection to:

Code: Select all

	DataSection
		GreenLeft:		IncludeBinary "Data/GL.bmp"
		GreenMid:		IncludeBinary "Data/GM.bmp"
		GreenRight:	IncludeBinary "Data/GR.bmp"
		GrayLeft:		IncludeBinary "Data/XL.bmp"
		GrayMid:		IncludeBinary "Data/XM.bmp"
		GrayRight:	IncludeBinary "Data/XR.bmp"
		GreenLefto:	IncludeBinary "Data/HL.bmp"
		GreenMido:	IncludeBinary "Data/HM.bmp"
		GreenRighto:	IncludeBinary "Data/HR.bmp"
		GrayLefto:		IncludeBinary "Data/YL.bmp"
		GrayMido:		IncludeBinary "Data/YM.bmp"
		GrayRighto:	IncludeBinary "Data/YR.bmp"
	EndDataSection
and change the line

Code: Select all

\Gadget=ImageGadget(#PB_Any,x,y,Length,Height,Size) 
in the Procedure CreateProgressBar() to

Code: Select all

	\Gadget=ImageGadget(#PB_Any,x,y,Length,Size,0)
I guess this is false on Windows too

Posted: Fri Mar 07, 2008 11:23 pm
by Michael Vogel
Hi walker,
thanks for making the code running on linux as well :)

Michael

PS the "...,0" and some other minor points already have been posted :wink:

PSS everyone is welcome to create other "skins"

Posted: Sat Mar 08, 2008 12:07 pm
by walker
Michael Vogel wrote: PS the "...,0" and some other minor points already have been posted :wink:
:shock: didn't read the thread carefully...... next time i will :wink:

btw.: very nice work 8)