Recent

Author Topic: Toolbar buttons  (Read 632 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 1358
Toolbar buttons
« on: January 26, 2020, 10:52:01 am »
Historically, I've always regarded toolbars as rather a toy, but in the current case I'm trying to duplicate a piece of Windows software (to read a Mastech 2115B meter) for Linux etc. so want to make it look the same.

Given a TImageList with 16x16 and 32x32 bitmaps, how do I tell the toolbar buttons to use the latter?

How do I implement a toolbar button that I can drop onto another component to get context-sensitive help to pop up?

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

wp

  • Hero Member
  • *****
  • Posts: 7636
Re: Toolbar buttons
« Reply #1 on: January 26, 2020, 11:25:07 am »
You seem to be using Laz 2.0+ - otherwise it would not be possible to combine both 16x16 and 32x32 images in the same imagelist. Then the control which uses the imagelist should have a property ImagesWidth; setting this to 32 means that the 32x32 images will be used; setting it to 16 means that the 16x16 images will be used; and setting it to 0 means that the width specified in the imagelist as ImageList.Width will be used. (The height scales accordingly to keep the aspect ratio intact).
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

MarkMLl

  • Hero Member
  • *****
  • Posts: 1358
Re: Toolbar buttons
« Reply #2 on: January 26, 2020, 12:07:00 pm »
Then the control which uses the imagelist should have a property ImagesWidth; setting this to 32 means that the 32x32 images will be used; setting it to 16 means that the 16x16 images will be used; and setting it to 0 means that the width specified in the imagelist as ImageList.Width will be used. (The height scales accordingly to keep the aspect ratio intact).

Thanks, that was it: I'd been incorrectly focussing on the ButtonHeight and ButtonWidth properties. Interestingly, a result of that is that any images which weren't supplied to the imagelist as 32x32 aren't displayed... from my POV it's down to me to find a source of decent icons rather than messing around with automatic scaling etc... does anybody have any suggestions which are LGPL-compatible?

I'd still apreciate any suggestions anybody has regarding a dropable button for a context-sensitive "what's this?" feature.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

wp

  • Hero Member
  • *****
  • Posts: 7636
Re: Toolbar buttons
« Reply #3 on: January 26, 2020, 01:38:26 pm »
I don't quite understand what you mean...

When the ImageList of v2.0+ has been set up for 16x16 and 32x32 images (use the "New resolution" button in the ImageList editor) then images missing of a specified resolution will be scaled from the other size provided. Since upcaling usually produces poorer quality than downscaling it is recommend to provide as many images as possible in the larger size. The same image at several sizes can be added to the ImageList simultaneously by using the "Add more resolutions" button and multi-selecting the corresponding icons in the file dialog (in any order). (Therefore it is a good idea to store the same image motive at all sizes in the same directory, and not to collect each size in the same directory -- what I did initially...)

I usually get icons from the icons8.com site (https://icons8.com/icons). Using a "Custom..." button they can be scaled to any size < 100 pixels before downloading. The download window also allows to install an offline tool which makes it very conventient to get the images by drag and drop. The icons are free, a link to their site must be provided, though (https://icons8.com/license/) -- no idea if this is LGPL compatible.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

MarkMLl

  • Hero Member
  • *****
  • Posts: 1358
Re: Toolbar buttons
« Reply #4 on: January 26, 2020, 03:16:35 pm »
I don't quite understand what you mean...

I've got a handful of icons as 48x48 PNG, and one as 32x32 PNG, in an imagelist scaled to 16x16 and 32x32. Im putting them on a row of toolbuttons. If I tell the toolbar to explicitly use 32, only the one represented by the 32x32 PNG appears. If I tell the toolbar to use 16... then only the one represented by the 32x32 PNG appears, rendered as 16x16. If I tell the toolbar to use the default of 0... Hmm, it still only displays the single 32x32 PNG. I think I'll just assume it's broken, it's more hassle than it's worth and I've got far more important things to do with my time.

I usually get icons from the icons8.com site (https://icons8.com/icons). Using a "Custom..." button they can be scaled to any size < 100 pixels before downloading. The download window also allows to install an offline tool which makes it very conventient to get the images by drag and drop. The icons are free, a link to their site must be provided, though (https://icons8.com/license/) -- no idea if this is LGPL compatible.

Thanks. Very poor match for the native (Linux gtk2/Qt) icons though.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

 

TinyPortal © 2005-2018