Danilo's toolbar Pro -converted to PB source! (Updated.)

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Danilo's toolbar Pro -converted to PB source! (Updated.)

Post by srod »

Update: 16 June 2008.
Whilst the library is intended for use as a source code include, it is now compatible with Tailbite. There were problems with those functions taking optional parameters etc.

An important change is that any program using the nxToolbar library in the form of a source code include file must now declare the constant:

Code: Select all

#nxToolbar_USESOURCE
before including the main nxToolbar source file. (See the example program.) This meant that I could keep the optional parameters when using the lib either in source code form or as a Tailbitten library without making any changes to the host program etc.


Update: 10 October 2007.
Large toolbar icons would exhibit a nasty dithering effect. This has been fixed thanks to fangbeast who pointed me in the right direction here!


Bug fix: 27 September 2007.

Fixed a damn cursed bug which took me an age to figure out! :x

The library was inadvertently setting the #CCS_ADJUSTABLE style causing the Windows customising dialogue to show briefly whenever a toolbar was double clicked!


Update: 12 September 2007.
Have added a new command which has no corresponding command in Danilo's original library :

Code: Select all

nxAddTBImage(hTb, hImage)
Basically this library had one real drawback; namely that all images (other than the system icons) used in the toolbars had to reside within a single bitmap. There is one bitmap for the 'normal' button images, one for the 'hot' images and one for the 'disabled' image set. There was no way of adding additional images which were not part of the main image strips.

Hence the addition of the new command.

This command will accept either a SINGLE bitmap image or an icon (both of which can be loaded with Purebasic's LoadImage() etc.) and will add it to the internal lists of images used by the toolbar. In each case the image dimensions must match the toolbar button sizes etc. Use ResizeImage() if you need to.

My advice is to use icons since they usually come armed with a mask for transparency whereas, if you add a bitmap, the library simply uses a 'dummy' mask.

Each new image added with this command is appended to the current list of images and so it's image index will reflect this.

IMPORTANT.
Always add images in the following order :

i) The image strips using the command nxSetTBImage().
ii) Individual custom images (bitmaps or icons) using the command nxAddTBImage().
iii) System icons using the command nxAddTBSysIcons().

Of course, you do not have to add image strips or system icons etc. That is, you can safely leave out any of the above steps i) through iii).

See the example program included with this package which shows how to mix all of the different image types.


Update: 1 feb 2007.
I got fed up with the boring 'standard' tooltips and so have changed the default style and added a function to allow you to change the colours and add a title (with icon) to the tooltips etc. See the 'update 1.2.txt' file for details.


Update: 31 Jan 2007.
Have brought together my original translation and Flype's work into a single package. The download includes full PB source code (ready to use as an 'XincludeFile' etc.) and pre-compiled libraries. Our previous versions were incompatible in that the source code version couldn't readily be Tailbitten and the source attached to the pre-compiled version could not readily be used as an include etc.

Hi,

as a massive fan of Danilo's excellent Toolbar Pro library (written in C, part of the PBOSL package) I use it in just about every application I develop.

However, my latest app, being multithreaded and Unicode compliant, pushed Toolbar Pro to it's limits, and broke it! :)

The problem is that whilst the lack of Unicode support is easy to get around, Toolbar Pro really isn't threadsafe as it relies upon global arrays and of course Danilo is no longer around to update the library.

I've thus taken the source code, ripped out the bits which caused it not to be threadsafe, and converted it to Purebasic source code.

I've tested it a little and it seems to work in my multithreaded app okay.

Apart from the 'threadsafe' alterations, this really is little more than a direct translation from Danilo's original code and so I take no credit for this. The original code was so well written that translation was easy. (Okay, I fixed a couple of memory leaks, so I'll happily take credit for them! :) )

The download (below) includes full source and an example. I've also thrown in a little tool which will happily generate mask images suitable for use with the library.

There's no help manual since you can simply use Danilo's original one which is in the PBOSL package. But, I advise a quick scan through the readme.txt file so that you are aware of the differences between the 2 libraries.

I hope it's useful. Download nxToolbar
Last edited by srod on Mon Jun 16, 2008 11:13 pm, edited 14 times in total.
I may look like a mule, but I'm not a complete ass.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2810
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

GRATZ!!!!

:lol: :lol: :lol:
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I've just uploaded a new version - this time you can extract the zip into the correct folders! :oops:
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

thanks for the nice code.

where from you have PureBasic 4.2 :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Excellent, thanks for this!
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

ts-soft wrote:...where from you have PureBasic 4.2 :wink:
Uhm, seems the smart update is smarter than the average bear!

Doh!

:)
I may look like a mule, but I'm not a complete ass.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Well done srod. can be really useful.

For the communauty i compiled your translated source code to a tailbite compatible one with a very very very few changes.

I used WinXP/PB4.02/jaPBe/Tailbite environment to provide the following files :

. UserLib
. UserLib Unicode
. UserLib ThreadSafe
. UserLib ThreadSafe + Unicode

. And the associated Resident file.

it's here : UserLib_PB40_nxToolbar.zip
Last edited by Flype on Tue Jan 30, 2007 9:54 pm, edited 1 time in total.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Nice one.

You could decrease the size of the libraries though by getting each overloaded function to simply call the main function with specific values for the paramaters etc. This means you don't have to duplicate the code for each overloaded function.
I may look like a mule, but I'm not a complete ass.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

that's right. i will do it right now. :)
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

ok, it's done :wink:

archive updated.


@srod
you might copy the userlib-link in your first post,
and maybe upload it to your website.

best regards.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

@Flype: I've linked to your site at the moment. If you'd prefer that I upload to my own site then I will. :)
I may look like a mule, but I'm not a complete ass.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

no pb, it's as you wish :)
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
zikitrake
Addict
Addict
Posts: 834
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

:shock: Yes! My new project is needy of this lib!

Very thank you!
JCV
Enthusiast
Enthusiast
Posts: 579
Joined: Fri Jun 30, 2006 4:30 pm
Location: Middle East

Post by JCV »

thank you! :D
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome.

Update: 31 Jan 2007.
Have brought together my original translation and Flype's work into a single package. The download includes full PB source code (ready to use as an 'XincludeFile' etc.) and pre-compiled libraries. Our previous versions were incompatible in that the source code version couldn't readily be Tailbitten and the source attached to the pre-compiled version could not readily be used as an include etc.

Because of certain limitations with Tailbite, however, there is one change in how 'optional paramaters' are used. See the 'update 1.1.txt' file for details.

@Flype: I had to switch all the overloaded functions around so that the 'full version' of each function could be called directly if the lib is used as a source code include file. It means that there is now only one copy of the package to maintain etc. :) I didn't recompile the libs however as these remain unaffected.
I may look like a mule, but I'm not a complete ass.
Post Reply