SpeedbarGadget
Re: SpeedbarGadget
Very nice! Well done! Looks great!
Kukulkan
Kukulkan
Re: SpeedbarGadget
Not correct:
If user have > 1 displays.
Code: Select all
*d\MaxItems = DesktopWidth(0)
Re: SpeedbarGadget
Thanks Phantomas,
i just updated the source code. You can download it from the top message.
Uwe
i just updated the source code. You can download it from the top message.
Uwe
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Re: SpeedbarGadget
Hi!
Nice Gadget, but now the line 152produces an IMA if window is dragged to small in hight,
because in line 149sy becomes zero.
Nice Gadget, but now the line 152
Code: Select all
y = (h - 1) * i / sy
because in line 149
Code: Select all
sy = h / (th * 2)
Re: SpeedbarGadget
Thank you, Lord!
Source fixed and uploaded.
Source fixed and uploaded.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Re: SpeedbarGadget
1 word... Cute!
Re: SpeedbarGadget
Hello,
A little command to free the Gadget. It's not really an issue if the SpeedBarGadget() is used on the main window but if it's used in a child window the SpeedBarGadget() will generate a memory leak because the memory is not released when the gadget is destroyed.
When you allocate the memory for extra information needed for the SpeedBarGadget, it's better to use InitializeStructure() instead of NewList to initialize the Linked List.
Otherwise, nice Gadget !
Best regards
Guimauve
A little command to free the Gadget. It's not really an issue if the SpeedBarGadget() is used on the main window but if it's used in a child window the SpeedBarGadget() will generate a memory leak because the memory is not released when the gadget is destroyed.
Code: Select all
Procedure FreeSpeedBarGadget(Gadget)
Protected *d._SpeedBar = GetGadgetData(Gadget)
If *d <> #Null
FreeMemory(*d)
FreeGadget(Gadget)
EndIf
EndProcedure
Code: Select all
Procedure SpeedBarGadget(Gadget, x, y, w, h, Flags=0)
;create new speedbar
Protected f, *d._SpeedBar, desktops, i
;build canvas flags
If Flags & #SpeedBarBorder
f | #PB_Canvas_Border
EndIf
;create additional speedbar object data
*d = AllocateMemory(SizeOf(_SpeedBar))
InitializeStructure(*d, _SpeedBar)
; NewList *d\Values() <--- With InitializeStructure(), NewList is no longer needed !
*d\Canvas = CanvasGadget(Gadget, x, y, w, h, f)
*d\Flags = Flags
*d\Font = FontID(LoadFont(#PB_Any, "", 8))
*d\Maximum = 100
*d\BackColor = $000000
*d\GridColor = $1C1C1C
*d\ValueColor = $0000FF
;store object in gadget data
If Gadget = #PB_Any
SetGadgetData(*d\Canvas, *d)
Else
SetGadgetData(Gadget, *d)
EndIf
;maximum number of values to store is limited to desktop width
desktops = ExamineDesktops()
For i = 0 To desktops - 1
If *d\MaxItems < DesktopWidth(i)
*d\MaxItems = DesktopWidth(i)
EndIf
Next
;return gadget id
ProcedureReturn *d\Canvas
EndProcedure
Best regards
Guimauve
Dear Optimist, Pessimist,
and Realist,
While you guys were
busy arguing about the
glass of water, I DRANK IT !
Sincerely,
the Opportunist
and Realist,
While you guys were
busy arguing about the
glass of water, I DRANK IT !
Sincerely,
the Opportunist
Re: SpeedbarGadget
Hello Guimauve,
thank your your suggestion!
Indeed i have overseen that freeing the objects data memory is required. The structure is 52 bytes of size or double on 64-bit machines. Not a big deal, but i will include a SpeedBarFree() command for that. Btw, i prefer to always start the procedures with the component name (SpeedBar...) so it is easy to find with code completion.
Source code is updated!
Are there any advantages to use InitializeStructure() instead of NewList in my special case?
Best regards
Uwe
thank your your suggestion!
Indeed i have overseen that freeing the objects data memory is required. The structure is 52 bytes of size or double on 64-bit machines. Not a big deal, but i will include a SpeedBarFree() command for that. Btw, i prefer to always start the procedures with the component name (SpeedBar...) so it is easy to find with code completion.
Source code is updated!
Are there any advantages to use InitializeStructure() instead of NewList in my special case?
Best regards
Uwe
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Re: SpeedbarGadget
Hello again,
First, I'm sorry but the command for freeing the gadget isn't right i think. This one will really do the job !
Best regards
Guimauve
First, I'm sorry but the command for freeing the gadget isn't right i think. This one will really do the job !
Code: Select all
Procedure SpeedBarFreeGadget(Gadget)
Protected *d._SpeedBar = GetGadgetData(Gadget)
If *d <> #Null
; All Basic field set to 0
; (it's for a purist, a maniac or a crazy programmer)
*d\Canvas = 0
*d\Flags = 0
*d\MaxItems = 0
*d\Maximum = 0
*d\BackColor = 0
*d\GridColor = 0
*d\ValueColor = 0
*d\SplitsX = 0
*d\SplitsY = 0
*d\Digits = 0
; Freeing the font
If *d\Font <> 0
FreeFont(*d\Font)
*d\Font = 0 ; The same comment as for previous basic fields apply here too !
EndIf
; Deleting all Values elements
ClearList(*d\Values())
FreeMemory(*d)
FreeGadget(Gadget)
EndIf
EndProcedure
Personally I prefer to use NewList, Map and Dim for any Linked List, Map and Dynamic Array used outside structured variable (loose inside a code, inside procedures, and so on) and use InitializeStructure() on structure containing Linked List, Map and Dynamic Array. Furthermore InitializeStructure() has been specifically designed for this purpose.Are there any advantages to use InitializeStructure() instead of NewList in my special case?
Best regards
Guimauve
Dear Optimist, Pessimist,
and Realist,
While you guys were
busy arguing about the
glass of water, I DRANK IT !
Sincerely,
the Opportunist
and Realist,
While you guys were
busy arguing about the
glass of water, I DRANK IT !
Sincerely,
the Opportunist
Re: SpeedbarGadget
First off, I wanted to say that this Gadget is fantastic. I like the look of it, and how it displays data.
I have one question/request/not sure:
Is there any way to increase either the size of the lines or space between the data points so that the actual output can be bigger? I'd love to use this to display data about historical usage on a machine, but an entire day's worth of data is only 143 data points, which fills a really tiny amount. I'm looking at other charting examples I've found on this forum, but so far the vast majority have just confused me or caused me to spend hours trying to add in things like data added during run time.
I have one question/request/not sure:
Is there any way to increase either the size of the lines or space between the data points so that the actual output can be bigger? I'd love to use this to display data about historical usage on a machine, but an entire day's worth of data is only 143 data points, which fills a really tiny amount. I'm looking at other charting examples I've found on this forum, but so far the vast majority have just confused me or caused me to spend hours trying to add in things like data added during run time.
Re: SpeedbarGadget
@Longshot: At the moment this gadget does not support bigger lines. But if you want to fill up the gadget with just 143 data points, e.g. you could add each point twice or more to fill the gadget with a whole day.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Re: SpeedbarGadget
Just found this its very nice..
Is there a way to set the lower/minimum value?
Like if I want from 100-200 instead of 0-200?
Thank you.
Is there a way to set the lower/minimum value?
Like if I want from 100-200 instead of 0-200?
Thank you.
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA