Page 1 of 4

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

Posted: Tue Jan 30, 2007 6:14 pm
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

Posted: Tue Jan 30, 2007 6:22 pm
by Num3
GRATZ!!!!

:lol: :lol: :lol:

Posted: Tue Jan 30, 2007 6:34 pm
by srod
I've just uploaded a new version - this time you can extract the zip into the correct folders! :oops:

Posted: Tue Jan 30, 2007 6:40 pm
by ts-soft
thanks for the nice code.

where from you have PureBasic 4.2 :wink:

Posted: Tue Jan 30, 2007 6:43 pm
by netmaestro
Excellent, thanks for this!

Posted: Tue Jan 30, 2007 8:38 pm
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!

:)

Posted: Tue Jan 30, 2007 9:23 pm
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

Posted: Tue Jan 30, 2007 9:30 pm
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.

Posted: Tue Jan 30, 2007 9:32 pm
by Flype
that's right. i will do it right now. :)

Posted: Tue Jan 30, 2007 9:51 pm
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.

Posted: Tue Jan 30, 2007 10:03 pm
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. :)

Posted: Tue Jan 30, 2007 10:07 pm
by Flype
no pb, it's as you wish :)

Posted: Tue Jan 30, 2007 10:08 pm
by zikitrake
:shock: Yes! My new project is needy of this lib!

Very thank you!

Posted: Wed Jan 31, 2007 3:51 am
by JCV
thank you! :D

Posted: Wed Jan 31, 2007 12:26 pm
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.