Custom Image with WPToolBar

  • So we want to use our own images for WPtoolbar. After doing some research looks like we have few options

    1)Create own tool bar. And then on click of each tool button call WPRichText's text cursor procedures like this.
    WPRichText1.TextCursor.CurrAttribute.AInc(WPAT_LineHeight, 50, 100);

    2) use WPImageList and attach it with WPtoolBar
    WPImageList takes one PNG image that has all the images.

    So here is my questions.

    1. Where can I get all the procedures for different functionality that existing toolbar buttons do.

    2. Looks like I have to create one large png file that has all the images. How can I do this?

    3. Please let us know if there are other ways to get our own images to toolbar buttons.

    Thank You.

    • Offizieller Beitrag

    1. When you open the unit wpctrrich.pas you will find (as described in manual) procedure ontoolbariconselection which is the default for all actions and toolbar buttons. Since the event can be attached to twptichtext it is also possible to override selected actions.

    2. A good program to create a png file that large is photoline, http://www.pl32.com

    3. You can add buttons to the twptoolbar which will be arraged with the ohers.

  • Thanks for reply. I was thinking of adding buttons to twpToolBar. Now the next question I have is how can I make buttons toggle like twpToolBar buttons do. So if a text is selected that is already bold then I should show Bold button as pressed and vice versa.

    Thanks.

  • I also tried by connecting to WPImageList that has one PNG image that has all the images. But I see no changes to button image.

    So if I have 2 buttons , I should have only 2 images in that 1 png file. right?
    What am I doing wrong?

    Also I looked at your demo example mini editor/mini.dpr. This has a WPiamgeList but its not used at all. Please advice.

    Thanks.

    • Offizieller Beitrag

    That image list is not like the TImagelist.

    In the collection Images it is possible to load a PNG image list as supply for buttons at different button heights. The TWPToolbar will load the best matching images from that collection. It will load the images from predefined indexes. The PNG Image list is expected to consists of x buttons arranges one under each other. We created lists of buttons at 24 and 48 pixel height, which will be provided with registered version. Please use that image as template for your modification.

    The property "ButtonHeight" in TWPToolbar and the defined item height of the imagelist items must match. If "ButtonHeight" is larger, the next smaller images from the list will be used.

  • So I already did all the steps you mentioned and its not working. Do you have any good working example please. I don't see any in demo directory where icon changes. Can you please give proper steps for this.

    Also if I create my own tool bar how can I toggle button like WPToolBar buttons do. For example if my cursor is on already Bold text then I want my Bold button pressed.

    Thanks.

    • Offizieller Beitrag
    Zitat

    Also if I create my own tool bar how can I toggle button like WPToolBar buttons do. For example if my cursor is on already Bold text then I want my Bold button pressed.

    You can set the state in the event OnChangeCharAttr -

    For the images- you need to use the predefined image list, alter the icons you want but keep the rest. The order must be the same!

  • I did used predefined imagelist provided by WPCubed. And I modied the one that I need to change. I then loaded it to WPImageList. I connected this ImageList to WPtoolbar which is connected to WPRichText. Still its not working.

    Can you please provide a working example? Thanks.