Recent

Author Topic: ButtonEdit Component  (Read 28873 times)

Derit

  • Jr. Member
  • **
  • Posts: 55
ButtonEdit Component
« on: March 15, 2014, 08:11:02 am »
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

howardpc

  • Hero Member
  • *****
  • Posts: 3202
Re: ButtonEdit Component
« Reply #1 on: March 15, 2014, 08:46:14 am »
What are its advantages over TEditButton already in Lazarus?

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: ButtonEdit Component
« Reply #2 on: March 15, 2014, 09:06:30 am »
adding a button as a search in the edit  ::)
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
Re: ButtonEdit Component
« Reply #3 on: March 15, 2014, 10:46:37 am »
I tried it on XUbuntu, works nice as TEditButton. Thank you very much!

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3654
  • I like bugs.
Re: ButtonEdit Component
« Reply #4 on: March 15, 2014, 03:54:29 pm »
adding a button as a search in the edit  ::)

Well, TEditButton in LCL also has a similar button. (See howardpc's question).
I guess you did not realize LCL has such a component. You even named your internal button as TEditButton which clashes with the LCL component name.

Now, amazingly, your design is good while TEditButton's design is bad. That is because it inherits from TCustomEdit (actually TCustomMaskEdit) and the button is placed outside the component. The resize handles are in wrong places and alignment goes wrong. See:
  http://bugs.freepascal.org/view.php?id=12155
and its related issues.
There was an experimental version in trunk which I just removed. It could be tested with a define NewEditButton.
It was a dead end because the events were done "upside-down" and did not work. In your component they are done correctly.
There is another interesting implementation from Flávio Etrusco which creates a recursive loop in LCL layout system. See the issue report.

Would you be interested to improve your component further and make it a replacement of TEditButton in LCL?
Events of TEdit must be duplicated and forwarded, that is the way to go. You have already implemented many but I think more is needed.

I see you have already forked Graeme's Lazarus mirror in GitHub. You could make your new TEditButton replacement there.
In fact your naming "TButtonedEdit" is better and could be used. TEditButton could be a deprecated alias for it.
Once you can build Lazarus itself with the new component and all its derivatives (TFilenameEdit, TDateEdit, TCalcEdit, filteredits etc.) in various IDE forms work as expected, it is very likely good.

It would be true distributed development using Git. I have promised to support it, see:
  http://wiki.lazarus.freepascal.org/Creating_A_Patch#Using_a_forked_Git_repository_directly
but nobody yet has offered his GitHub fork.
It would make you a pioneer and also a hero because you solve a long-standing issue that was supposed to be fixed in Lazarus 1.0 already.
Tempting, ha? :)

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: ButtonEdit Component
« Reply #5 on: March 16, 2014, 04:02:20 am »
Hi Juha
This component will be developed further to lazarus...  :)
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3654
  • I like bugs.
Re: ButtonEdit Component
« Reply #6 on: March 16, 2014, 10:12:11 am »
This component will be developed further to lazarus...  :)

Ok, cool!
You do it in Lazarus Git mirror, right? Did you find the lcl/editbtn.pas source?
Please keep me informed of your progress and ask questions if you feel so. You can use also personal mails / messages.

Blaazen

  • Hero Member
  • *****
  • Posts: 2782
  • POKE 54296,15
    • Eye-Candy Controls
Re: ButtonEdit Component
« Reply #7 on: March 16, 2014, 03:27:23 pm »
Hello,

this is very similar to m old NewEditButton implementation. Difference is that here is used TCustomControl as a container while I used TWinControl. TWinControl has lesser overhead since it has no canvas. In your implementation can be TCustomControl replaced with TWinControl too, it compiles. It only need to set Edit.BorderStyle to bsSingle.
But the most difficult part are definitely events and messages. Without it will not TEditButton descendants work properly.

Have a nice day.

BTW it's my first post after seven month so I'll try to be a little more active here again.
Lazarus 2.1.0 r61214:62238 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: ButtonEdit Component
« Reply #8 on: March 16, 2014, 04:42:07 pm »
Quote
BTW it's my first post after seven month so I'll try to be a little more active here again.

Welcome back home, Professor...  ;)
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: ButtonEdit Component
« Reply #9 on: March 16, 2014, 04:50:28 pm »
Hello,

this is very similar to m old NewEditButton implementation. Difference is that here is used TCustomControl as a container while I used TWinControl. TWinControl has lesser overhead since it has no canvas. In your implementation can be TCustomControl replaced with TWinControl too, it compiles. It only need to set Edit.BorderStyle to bsSingle.
But the most difficult part are definitely events and messages. Without it will not TEditButton descendants work properly.

Have a nice day.

BTW it's my first post after seven month so I'll try to be a little more active here again.
better use TCustomControl because its properties can in their own custom :D
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

howardpc

  • Hero Member
  • *****
  • Posts: 3202
Re: ButtonEdit Component
« Reply #10 on: March 16, 2014, 04:55:46 pm »
Welcome back Blaazen! We've missed you.

Blaazen

  • Hero Member
  • *****
  • Posts: 2782
  • POKE 54296,15
    • Eye-Candy Controls
Re: ButtonEdit Component
« Reply #11 on: March 16, 2014, 05:14:49 pm »
Quote
better use TCustomControl because its properties can in their own custom

They don't differ so much:
Code: [Select]
{ TCustomControl }

  TCustomControl = class(TWinControl)
  private
    FCanvas: TCanvas;
    FOnPaint: TNotifyEvent;
  protected
    class procedure WSRegisterClass; override;
    procedure WMPaint(var Message: TLMPaint); message LM_PAINT;
    procedure DestroyWnd; override;
    procedure PaintWindow(DC: HDC); override;
    procedure FontChanged(Sender: TObject); override;
    procedure SetColor(Value: TColor); override;
    procedure Paint; virtual;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  public
    property Canvas: TCanvas read FCanvas write FCanvas;
    property BorderStyle;
    property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
  end;     
As you can see, it's mainly the canvas. And canvas is not really needed in case of TEditButton.
Lazarus 2.1.0 r61214:62238 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3654
  • I like bugs.
Re: ButtonEdit Component
« Reply #12 on: March 17, 2014, 08:24:53 pm »
this is very similar to m old NewEditButton implementation. Difference is that here is used TCustomControl as a container while I used TWinControl.

TCustomControl is easy to change for TWinControl. However, your version had a much bigger difference. It forwarded the edit control events in wrong direction and they did not work.

Derit's first version looked good but now I think he got over-excited and he has problems with revision control, and his code also changed to worse.
Derit, just take it easy, no hurry. Learn to use the tools. It will be good.

I can promise that this component will be fixed for Lazarus 1.4. If not otherwise, I will do it myself. I was just hoping that someone else does it because there are so many _almost_ good versions already, and I could concentrate on my other ToDo items.

Quote
BTW it's my first post after seven month so I'll try to be a little more active here again.

Ok. Good to have you back.

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: ButtonEdit Component
« Reply #13 on: March 18, 2014, 02:15:07 am »
TCustomControl is easy to change for TWinControl. However, your version had a much bigger difference. It forwarded the edit control events in wrong direction and they did not work.

Derit's first version looked good but now I think he got over-excited and he has problems with revision control, and his code also changed to worse.
Derit, just take it easy, no hurry. Learn to use the tools. It will be good.

I can promise that this component will be fixed for Lazarus 1.4. If not otherwise, I will do it myself. I was just hoping that someone else does it because there are so many _almost_ good versions already, and I could concentrate on my other ToDo items.
I will increase this component it better :D

Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

Bart

  • Hero Member
  • *****
  • Posts: 3547
    • Bart en Mariska's Webstek
Re: ButtonEdit Component
« Reply #14 on: March 19, 2014, 03:57:10 pm »
Hi,

I tried to checkout your repo using EasyMercurial, but it failed.
Luckily I could use svn to check it out.

I propose some changes.
  • Visually I made it so that it does not look like the button is inside the edit
  • Property Color now only sets/gest color of the TEdit
  • I used a more common method to set initial width/height
  • Property Text now reflects text in edit
  • Introduced property ButtonCaption

See attached diff.

Please comment.

Bart