General discussion about plugins.

Browse, download and discuss plugins for Blumentals code editors

Re: General discussion about plugins.

Postby Aivars » Wed Mar 28, 2018 2:13 pm

1. Use Images and ImageIndex where possible. In case of menus, set Images property of the menu or popup-menu to your ImageList and set ImageIndex of individual menu items to corresponding index in image list.

2. This is how:

Code: Select all
  var B = TBitmap.Create;
  ImgList.GetBitmap(0, B);
  TestImg.Picture.Assign(B);
  delete B;


Note that you will lose half-transprency because unlike TImageList, TBitmap does not support it. What you can do however is use TImageList.Draw to draw on the target canvas, while keeping the background intact.
Here's a code sample that draws on Canvas of a blue TBitmap and then assigns the bitmap to TImage just so that we can see the result:

Code: Select all
  var B = TBitmap.Create;
  B.Width = 32;
  B.Height = 32;
  //paint bitmap blue
  B.Canvas.Brush.Style = bsSolid;
  B.Canvas.Brush.Color = clBlue;
  B.Canvas.Pen.Color = clBlue;
  B.Canvas.Rectangle(0, 0, 32, 32);
  //use TImageList.Draw to draw the icon anywhere while keeping half-transparency
  ImgList.Draw(B.Canvas, 0, 0, i, True);
  //show our results on screen
  TestImg.Picture.Assign(B);
  delete B;


Update: use clBtnFace instead of clBlue for form's color.

A little note: please don't get carried away with the popup-menus, there's a reason that their popularity is vanishing, they have very poor discoverability. We used to right-click every part of the interface years ago because that's what we were trained to do, but nowadays it's different and everything should be buttons and navigation and visible widgets. There are still a lot of places where right-click makes a lot of sense (text editors, file explorers) but it shouldn't be the only option to get to the required action.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2174
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Thu Mar 29, 2018 1:18 am

Thanks for the drawing example.
It worked perfectly for the TImage problem, but only partial for the TPopupMenu items.

Everything looked perfect until you selected an item. Then the icon turned into a square due to the highlighting color not matching.
I solved that in another way, by setting the "Image" property of the TPopupMenu to the TImageList instead of setting individual images on each TMenuItem. Then I just have to set the "ImageIndex" of TMenuItem to get the correct image.

Im only using the TPopupMenu for non-essential features, like clearing and copying output window content. (Something i cloned from the WeBuilder Message Panel :D)
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 486
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby pmk65 » Tue Apr 10, 2018 2:14 pm

A couple 2018 docking related questions:

1) I added a TScrollBox to my docking panel, so that the components inside it are always accessible even when editor is sized down. This works as expected. Only problem is that there's no support for scrolling with mouse wheel (which I do all the time)

Is it possible to implement mouse wheel scrolling using the existing components, similar to what they suggest here?
https://stackoverflow.com/questions/7063461/how-do-i-scroll-a-tscrollbar-using-the-mouse-wheel

Or is this going to be a "feature request"? :D
Best thing would be if it's added as a default behaviour to TScrollBox. (Why wouldn't you have mousewheel support for scrolling like in other components?)
I also tried adding "AutoScroll = true" to the TForm, but the behavior is the same. No mousewheel support.

2) Is there any properties of TDockPanel that shows where the panel is docked?

When the panel is created, there's various positions you can set: "dockPanelFileExplorer","dockPanelInspector", "dockPanelOutput" etc. But they doesn't cover all positions available and the user can move the panels around.

What I need is a way to determine if the panel is placed vertically or horizontally. I tried using the OnResize and OnCanResize events as this would be the ideal place to test for this.(Testing if height>width). But using them in docking panels, crashes WeBuilder.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 486
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Fri Apr 13, 2018 8:39 am

1) That might interfere with the general mouse wheel handler (would probably be fine with normal forms, but might be problematic with the dock forms). I'll add it to suggestions, but frankly that might end up quite complicated and although mouse wheel is nicer, it's not a tragedy to not have it. Maybe you want to reorganize your dock form's UI, e.g. by using tabs, to minimize need for scrolling.

2) No, but you should be able to use OnResize, and I have even tested it with test plugins and there were no crashes. Maybe that was before you were creating docks in the initialization.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2174
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Fri Apr 13, 2018 11:21 pm

1) I can't see how mousewheel support for TForm would interfere with docking panels. All other components (TEdit,TTreeView, TRichEdit etc.) already supports mousewheel scrolling. It's just TForm/TScrollBox that doesn't have it.
My components fit in the panel, but in cases where the editor is resized, it's good practice to make the invisible part available by scrollbars. ;)

2) Yes. Both onResize and OnCanResize works without crashing now. And I can determine if the height is greater than the width as I needed.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 486
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby pmk65 » Sat Apr 14, 2018 5:14 pm

Is it possible to use the "Parent" property of "Sender" to reference parent objects instead of having to define the parent object as a global var?

Something like:
Sender.Parent.Parent.ModalResult = mrCancel; // Close modal window

Instead of (where PSForm is defined as global var):
PSForm.ModalResult = mrCancel; // Close modal window
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 486
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Mon Apr 16, 2018 2:38 pm

You can, but I would not recommend it because 1) PSForm.ModalResult is much clearer for the code reader 2) You become dependent on how your controls are placed on the form, changing their parents (e.g. adding more panels or tabs) would break the functionality.

Having said that, this should work (I haven't tested it):

Code: Select all
(Sender.Parent.Parent as TForm).ModalResult = mrCancel;
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2174
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Previous

Return to Plugins for HTMLPad / Rapid CSS / Rapid PHP / WeBuilder

Who is online

Users browsing this forum: No registered users and 1 guest

cron