Recent

Author Topic: Is it possible to use Lazarus stock icon in common actions?  (Read 1785 times)

linuxfan

  • Jr. Member
  • **
  • Posts: 57
Is it possible to use Lazarus stock icon in common actions?
« on: August 10, 2019, 08:10:46 pm »
I am writing a text editor (BTW: SynEdit does already a lot of things...). I would like to put a toolbar with common items in it (open, save...), which will be duplicated also in the main menu. The situation seems to call for an ActionList, so I tried to start with it. But... do I have to search and load every single icon of every TAction I want to include? It would be a pity: Lazarus provides a few standard action, but without no icon already set?

That said, I have little clue. I tried some years ago, in Delphi, to write a program using an ActionList, but without success. Now I am trying again with Lazarus, but I can't find much documentation, so may be I am starting with the wrong foot.

For very common actions like "Save" or "Undo", really I have to load a TImageList with icons I should search who knows where?

TY in advance for any suggestion...

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Is it possible to use Lazarus stock icon in common actions?
« Reply #1 on: August 11, 2019, 11:57:14 am »
Yes, you need to build an image list containing your icons and associate with the TActionList.

The actions in the list can in turn be associated with the TMenuItem's of a main or popup menu, the ToolButtons of the TToolBar etc.

What I usually do is copy all the icons to a folder "MyProject/res/" and (re-)build the image list from there. It's a liittle time consuming at first if you need many icons but it's done just once.

Or you can have pre-built lists ready to be pasted in a forms .lfm/.pas or in a common data module, say a "fileIcons" or "editIcons" or whatever.

It's easier if you use icons collections (famfamfam, silkicons or whatever); then all you need do is unzip the collection, delete the uneeded icons and build the list. :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

linuxfan

  • Jr. Member
  • **
  • Posts: 57
Re: Is it possible to use Lazarus stock icon in common actions?
« Reply #2 on: August 11, 2019, 03:24:32 pm »
Thank you for your precious advice. I will do like you said.

 

TinyPortal © 2005-2018