General discussion about plugins.

Browse, download and discuss plugins for Blumentals code editors

Re: General discussion about plugins.

Postby pmk65 » Wed Feb 28, 2018 4:45 pm

Im have a TForm modal window which I want to have control over the resizing.
According to the FastScript specs: https://www.fast-report.com/public_download/fs_en.pdf, then there's a "OnCanResize" and a "OnResize" events available.

The OnResize" works, but is fired too late for my use.

According to web documentation, then "OnCanResize" works like this: "Use OnCanResize to adjust the way a control is resized. If necessary, change the new width and height of the control in the OnCanResize event handler. The OnCanResize event handler also allows applications to indicate that the entire resize should be aborted."

this is exactly what I need, but when I implement it Webuilder crashes with this exception message: List index out of bounds (1). (Doesn't matter if there's no action performed in the callback function. It always crashes.)

Code: Select all
    var PSForm = new TForm(WeBuilder);
        PSForm.ClientHeight = 200;
        PSForm.ClientWidth = 220;
        PSForm.Position = poScreenCenter;
        PSForm.BorderStyle = bsSizeable;
        PSForm.BorderIcons = biSystemMenu;;
        PSForm.OnCanResize = "OnCanResize";


function OnCanResize(Sender) {
    // This callback function makes Webuilder crash.
    // Even if there's no actions performed here!
    //Sender.Width = max(Sender.Width, 600);
    //Sender.Height = max(Sender.Height, 600);
}


Edit: Got it working. Callback handler needed 3 more parameters besides Sender.
http://docwiki.embarcadero.com/Librarie ... esizeEvent
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 516
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby pmk65 » Thu Mar 22, 2018 2:48 am

I have a TMemo/TRichEdit component i use for displaying output.
When I have something to output, I write the new line to the component. But the component doesn't scroll down automatically when I reach the end of the visible part.
On various websites I have read that you'll have to do something like:

SendMessage(RichEditMemo.Handle, WM_VSCROLL, SB_LINEDOWN, 0);

But "SendMessage" is not supported by FastScript, so is there any other way I can get it to scroll down when a line is added?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 516
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Thu Mar 22, 2018 10:18 am

The best way (i.e. without resorting to low-level API) would be to change SelStart to move the cursor to the end of the text.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2208
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Thu Mar 22, 2018 12:32 pm

The current implementation of TMemo and TRichText doesn't have support for selecting text AFIK.
Everything I tried fails. Do you have a working example on how to do this?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 516
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Thu Mar 22, 2018 12:56 pm

Ok, I'll try to write a simple test/demo.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2208
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby Aivars » Thu Mar 22, 2018 1:19 pm

You're right, weirdly SelStart and SelLength are not published properties. I'll try to add them.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2208
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby Aivars » Thu Mar 22, 2018 7:18 pm

Just so that it's easier to understand what's available and what isn't, Beta 4 will allow running plugin that displays reference tree of all pluginscript classes and functions, like so:

pluginscripttree.png
pluginscripttree.png (54.86 KiB) Viewed 538 times
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2208
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Sat Mar 24, 2018 12:33 am

I tried this, but it doesn't scroll. Am I doing it wrong?

Code: Select all
    RichEdit1.Lines.Add(text);
    var len = Length(RichEdit1.Lines.Text);
    RichEdit1.SelLength = 0;
    RichEdit1.SelStart  = len;


Edit: Figured out what was "wrong". All I had to do was to set focus on the RichEdit component. Then it scrolls when content is added. (No need for setting SelStart)

RichEdit1.SetFocus;
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 516
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Sat Mar 24, 2018 11:13 am

Alternatively, without focusing:

Code: Select all
  edRich.Lines.Add(text);
  edRich.SetCaretPos(0, edRich.Lines.Count);


As demonstrated here: viewtopic.php?p=25807#p25807

I would advise to use focus sparingly in any plugin because losing focus from the code editor while programming can be annoying, especially if it happens unexpectedly ;)
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2208
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Sat Mar 24, 2018 2:25 pm

Thanks. I'll go with your method then. :)

BTW: I noticed that the default font size of VCL components inserted by plugin, doesn't match the "build-in" components font size.
The default fontsize of plugin VCL components is -11. What is the fontsize used for the "build-in" components?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 516
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Sat Mar 24, 2018 2:37 pm

Since the font could change in the future, you should probably dynamically copy it from the main form, e.g.

Code: Select all
myform.Font.Size = WeBuilder.Font.Size;
myform.Font.Name = WeBuilder.Font.Name;
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2208
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Sat Mar 24, 2018 4:08 pm

Thanks for the font info.

Another question. Is it possible to load one big image containing all icons and masks, into a TImageList?
If yes, then how do it have to be created, so I also have transparency?

Right now I do something like this to create icons for my TTreeView. But I need to load 2 bmp files for each icon set (image + transparency mask). And if I also have to take various dpi settings into account, that is going to be a lot of code/images.

Code: Select all
    var ImageList1 = new TImageList(WeBuilder);
    ImageList1.SetSize(16,16);
    var Bitmap1 = new TBitmap;
    var Bitmap2 = new TBitmap;
    Bitmap1.Create;
    Bitmap2.Create;
    Bitmap1.LoadFromFile(Script.Path + "/images/execute_icon16.bmp");
    Bitmap2.LoadFromFile(Script.Path + "/images/execute_mask16.bmp");
    ImageList1.Add(Bitmap1, Bitmap2);
    Bitmap2.Free;
    Bitmap1.Free;


Also the icons inserted get masked for transparency, but it has a black edge. Is there any way change this, so I can get full alpha transparency?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 516
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: General discussion about plugins.

Postby Aivars » Sat Mar 24, 2018 6:56 pm

If you want to use a big bitmap, the general idea would be to load it, then create the small bitmaps, then in loop use drawing to draw from the big bitmap to the small bitmap. Although it looks like the functions for drawing just part of the big bitmap haven't been exposed to plugins, this might work: let's suppose the icon that you need is in position (16, 0 -> 32, 16) in the big bitmap. Supposing the smallbitmap is 16x16, you might get away with using smallbitmap.Canvas.Draw(-16, 0, bigbitmap);
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2208
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby Aivars » Tue Mar 27, 2018 1:49 pm

Next version will allow create formatted text in TRichEdit like this:

Code: Select all
  edRich = new TRichEdit(dockForm);
  edRich.Font.Name = "Segoe UI Emoji";


Code: Select all
  edRich.Lines.Add(_t(Round(Random() * 1000)));
  edRich.SelAttributes.Color = clRed;
  edRich.SelAttributes.Style = fsUnderline || fsBold;
  edRich.Lines.Add("♥ Colored ♥");
  edRich.SelAttributes.Color = clGreen;
  edRich.SelAttributes.Height = 20;
  edRich.Lines.Add("☘☘☘");


richedit_colors.png
richedit_colors.png (3.79 KiB) Viewed 483 times


P.S. I'm not a big fan of richedit especially considering that we have Chromium available for use, but I guess sometimes when they work they can be useful.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2208
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: General discussion about plugins.

Postby pmk65 » Wed Mar 28, 2018 1:56 am

The Pixelformer program worked perfect in making 32bit BMP files, but Im still having some problems with TImageList.
I have this code to populate the TImageList. The "icons16.bmp" is an vertical image of 16x16 icons.

Code: Select all
function CreateImageList(size) {
    var ImageList1 = new TImageList(WeBuilder);
    ImageList1.ColorDepth = 6; // cd32Bit
    ImageList1.DrawingStyle = 3; //dsTransparent;
    ImageList1.SetSize(size, size);

    var Bitmap1 = new TBitmap;
    Bitmap1.Create;
    Bitmap1.LoadFromFile(Script.Path + "/images/icons16.bmp");
    var imageCount = Bitmap1.Height / size;

    var Bitmap2 = new TBitmap;
    Bitmap2.Create;
    Bitmap2.Width = size;
    Bitmap2.Height = size;

    for (var i=0;i<imageCount;i++) {
        Bitmap2.Canvas.Draw(0, -size*i, Bitmap1);
        ImageList1.Add(Bitmap2, nil);
    }
    Bitmap2.Free;
    Bitmap1.Free;

    return ImageList1;
}


In can then add it as image to my TBitBtn like this: Imagelist1.GetBitmap(0, BitBtn1.Glyph);
Everything is fine here and the image has correct transparency. It also shows correct transparency when used as TTreeview icons.

Problem 1:
How to get transparency working in other components?

When I add it to a TMenuItem like this: ImageList1.GetBitmap(6, PM1MenuItem1.Bitmap)
it is no longer transparent, but has a white background. (If I use "Bitmap.LoadFromFile" it has the correct transparency.)

And if I load the 32bit BMP file with "Image1.Picture.LoadFromFile" into an TImage object, the image have a black background.

Problem 2:
How do I load an image from my TImageList into an TImage?

I tried:

Imagelist1.GetBitmap(0, Image1.Picture);
Imagelist1.GetBitmap(0, Image1.Bitmap);
Imagelist1.GetBitmap(0, Image1.Picture.Bitmap);

But they all crashes WeBuilder.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 516
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

PreviousNext

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

Who is online

Users browsing this forum: No registered users and 1 guest