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: 2452
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: 678
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: 678
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: 2452
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: 678
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: 678
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: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Wed May 02, 2018 11:03 am

Is there any way to open a FTP document using Documents.OpenDocument() ?
For my current plugin, Im saving the name of open documents. Works well with local files, but it doesn't work for FTP files AFIK.

Also is there any way to detect when the WeBuilder program is opened/closed?
The "exit" and "ready" signals are close, but they also fires when a plugin is enabled/disabled. Or is there any way, I in the "exit/ready" callbacks can detect if it's a plugin enable/disable?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Wed May 02, 2018 1:57 pm

It can be done, you just need to replace the last slash with |. Here's how you would open file /tmp/file.txt from connection called "server2":

Code: Select all
Documents.OpenDocument("FTP::server2\\/tmp|file.txt");


If plugin is disabled or uninstalled, then "disabled" or "uninstalled" signal is sent right before "exit" signal.
If plugin is enabled or installed then "enabled" or "installed" signal is sent right before "ready" signal.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Wed May 02, 2018 2:26 pm

Aivars wrote:It can be done, you just need to replace the last slash with |. Here's how you would open file /tmp/file.txt from connection called "server2":

Code: Select all
Documents.OpenDocument("FTP::server2\\/tmp|file.txt");


And you don't have to supply credentials like user/pass?

Aivars wrote:If plugin is disabled or uninstalled, then "disabled" or "uninstalled" signal is sent right before "exit" signal.
If plugin is enabled or installed then "enabled" or "installed" signal is sent right before "ready" signal.


Great. I ended up with setting a global var in "enabled" and "disabled". And then checking that in "exit" and "ready", so I could skip the action there.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Wed May 02, 2018 3:01 pm

If FTP connection has password stored then you don't have to enter it, otherwise the password is asked. You can't open files from any random FTP server, just the ones that user has stored in FTP Connections.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Wed May 02, 2018 11:06 pm

Aivars wrote:If FTP connection has password stored then you don't have to enter it, otherwise the password is asked. You can't open files from any random FTP server, just the ones that user has stored in FTP Connections.


Perfect. Then I don't have to worry about that. :D

A question about Document.Close / Document.Save:

If I call Document.Close(true), does that mean that the document will NOT BE SAVED if it contains modifications? Or does it AUTOSAVE the document without prompting?

I want to to do a "silent" save, regardless of document being modified or not.
So if Document.Close(true) doesn't save, I'll probably have to call Document.Save first.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Thu May 03, 2018 10:52 am

If NoSaving parameter is true then the document won't be saved.

You can use Editor.Modified to check if saving is required.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Mon May 07, 2018 3:36 pm

Aivars wrote:If NoSaving parameter is true then the document won't be saved.

You can use Editor.Modified to check if saving is required.


Thanks for clearing that up. That explained why my documents didn't get saved :)

Another question:
If I use the new TScriptableJsExecuter, in what "protocol" is the file loaded? "file://", "http://"
As some 3rd-party scripts can only be executed in the correct protocol.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Tue May 08, 2018 12:48 pm

If you leave DefaultUrl empty in Script.CreateScriptableJsExecuter(DefaultUrl) then about:blank is used. I'm not sure what protocol that is permissions-wise :)
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2452
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

PreviousNext

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

Who is online

Users browsing this forum: No registered users and 1 guest