Lazarus

Programming => Packages and Libraries => Topic started by: Derit on March 15, 2014, 08:11:02 am

Title: ButtonEdit Component
Post by: Derit on March 15, 2014, 08:11:02 am
Hi...
This Button EditComponent For Lazarus
https://github.com/derit/ButtonEdit
Download https://github.com/derit/ButtonEdit/archive/master.zip
Title: Re: ButtonEdit Component
Post by: howardpc on March 15, 2014, 08:46:14 am
What are its advantages over TEditButton already in Lazarus?
Title: Re: ButtonEdit Component
Post by: Derit on March 15, 2014, 09:06:30 am
adding a button as a search in the edit  ::)
Title: Re: ButtonEdit Component
Post by: exdatis on March 15, 2014, 10:46:37 am
I tried it on XUbuntu, works nice as TEditButton. Thank you very much!
Title: Re: ButtonEdit Component
Post by: JuhaManninen 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? :)
Title: Re: ButtonEdit Component
Post by: Derit on March 16, 2014, 04:02:20 am
Hi Juha
This component will be developed further to lazarus...  :)
Title: Re: ButtonEdit Component
Post by: JuhaManninen 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.
Title: Re: ButtonEdit Component
Post by: Blaazen 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.
Title: Re: ButtonEdit Component
Post by: Fred vS 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...  ;)
Title: Re: ButtonEdit Component
Post by: Derit 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
Title: Re: ButtonEdit Component
Post by: howardpc on March 16, 2014, 04:55:46 pm
Welcome back Blaazen! We've missed you.
Title: Re: ButtonEdit Component
Post by: Blaazen 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.
Title: Re: ButtonEdit Component
Post by: JuhaManninen 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.
Title: Re: ButtonEdit Component
Post by: Derit 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

Title: Re: ButtonEdit Component
Post by: Bart 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.

See attached diff.

Please comment.

Bart
Title: Re: ButtonEdit Component
Post by: JuhaManninen on March 19, 2014, 04:23:24 pm
I tried to checkout your repo using EasyMercurial, but it failed.
Luckily I could use svn to check it out.

Bart, GitHub uses Git, not Mercurial. I don't know how you managed to use SVN with a Git repo.

Quote
I propose some changes.

Do they apply with the latest version from derit?
For some reason he continues developing this separate package instead of the lazarus branch which I requested.
I think we move the development to Lazarus trunk in any case. If if breaks temporarily, I don't care. It is time to get this component fixed.
Title: Re: ButtonEdit Component
Post by: Leledumbo on March 19, 2014, 05:25:04 pm
Quote
For some reason he continues developing this separate package instead of the lazarus branch which I requested.
Would you please guide him? There might be little communication problem due to his english, but that's just a small problem. The bigger one lies in his experience in version control system (especially writing a patch) and understanding LCL. Seriously I need T*Edit with correct border, align and anchor as well so I don't have to hack again by giving additional BorderSpacing for the button to be visible in certain cases.
Title: Re: ButtonEdit Component
Post by: Bart on March 19, 2014, 06:26:19 pm
Quote
Bart, GitHub uses Git, not Mercurial. I don't know how you managed to use SVN with a Git repo.

This worked. The link to the website he provided offered this option, so I just tried.
Code: [Select]
C:\Users\Bart\LazarusProjecten\derit>svn co https://github.com/derit/
ButtonEdit/trunk ButtonEdit


Quote
If if breaks temporarily, I don't care. It is time to get this component fixed.

It'll break building Lazarus ATM, which would complicate developing this component IMO.
I would propose to develop (inside Lazarus trunk) TButtonEdit.
This way it is easier for all interested parties to contribute.
Currently the code is not mature enough to replace TEditButton.

When done, we could move to the new TButtonEdit and mark TEditButton as deprecated.
(In theory this could possibly be done with some simple search/replace over Lazarus source code...?)

Bart
Title: Re: ButtonEdit Component
Post by: JuhaManninen on March 19, 2014, 07:24:14 pm
Would you please guide him? There might be little communication problem due to his english, but that's just a small problem. The bigger one lies in his experience in version control system (especially writing a patch) and understanding LCL.

Yes, we are having e-mail communication. And yes, there are problems caused by English language and by a version control system.
Initially his code looked very good and I thought he knows version control, too.

I could rename the component and place it to Lazarus trunk myself tomorrow. First I must test that it compiles and mostly works. I will write to derit and agree with him tomorrow.
Bart, after that you can maybe apply your changes somehow. They cannot be applied directly though.
And don't worry, the trunk must compile after every change. Only some functionality can temporarily be broken or missing.
Title: Re: ButtonEdit Component
Post by: Bart on March 19, 2014, 11:46:16 pm
... after that you can maybe apply your changes somehow. They cannot be applied directly though.

Why not?
For starters, you cannot have property Text set Button.Caption as it is now.

And don't worry, the trunk must compile after every change. Only some functionality can temporarily be broken or missing.

In current state it will not compile (that is: when you replace current TEditButton's implementation with TButtonEdit's one).

Bart
Title: Re: ButtonEdit Component
Post by: Derit on March 20, 2014, 08:31:11 am
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
Thanks Suggestion Bart :D
Title: Re: ButtonEdit Component
Post by: Derit on March 20, 2014, 08:36:14 am

Bart, GitHub uses Git, not Mercurial. I don't know how you managed to use SVN with a Git repo.


I use Turtoise Svn ....
Title: Re: ButtonEdit Component
Post by: Bart on March 20, 2014, 04:05:51 pm
I would suggest doing something like this for the transition:

Code: [Select]
unit EditBtn; {$ifdef somedefine} deprecated{$endif}

uses
  {$ifdef somedefine}
  Buttonedit
  {$else}
  ....
  {$endif}
  ;


Interface

type
{$ifdef somedefine}
  TCustomEditButton = ButtonEdit.TCustomButtonEdit;
  TEditButton = ButtonEdit.TBttonEdit;
  TFileNameEdit = ButtonEdit.TFileNameEdit;
  ...
{$else}
  //curent interface
{$endif}

implementation

{$ifNdef somedefine}
//current implementation
{$endif}

end.

Bart
Title: Re: ButtonEdit Component
Post by: Bart on March 20, 2014, 11:30:24 pm
Derit, I see that you have a tendency to apply properties (like Cursor, AutoSize, PopupMenu) to the button only.
Maybe you should rethink that.

At least AutoSize should apply to the whole control IMO.
There may be a necessity to split some properties (like EditCursor, ButtonCursor), but that would increasingly become rather cumbersome.

B.t.w. what license is your code, I assume LGPL like the LCL? You mention "See the file COPYING.modifiedLGPL.txt, included in this distribution", but that file is not in your repo.

Bart
Title: Re: ButtonEdit Component
Post by: JuhaManninen on March 21, 2014, 12:21:52 am
I would suggest doing something like this for the transition:
...

No, I have already done that once and nobody bothered to look at it. Maybe nobody even noticed it is there.
The previous version was there for over a year and anybody could have tested it with NewEditButton define. The events did not work very well but it makes no difference if nobody looks at it.
Now I will either apply it without IFDEFs or then not apply at all.

About the license, all components in LCL are LGPL and Derit has promised to give his component for LCL. It is LGPL then.

I planned to look at the component tonight and maybe apply it but I had no time. It will happen during the weekend...
Title: Re: ButtonEdit Component
Post by: Bart on March 21, 2014, 12:35:39 am
See attached diff.

Bart
Title: Re: ButtonEdit Component
Post by: Bart on March 21, 2014, 12:45:57 am
I would suggest doing something like this for the transition:
...

No, I have already done that once and nobody bothered to look at it. Maybe nobody even noticed it is there.

Well, I didn't notice...

I think this is too big a change to commit at once.
For starters the published properties won't match (they cannot, by design), so even if you can compile the IDE it will crash upon start.
I would like to have the chance to develop this in a more relaxed mannor and time frame, not rushing it.

If you follow my proposal (or just develop it as a separate control, which may in time replace the old one), I will follow up on it and implement it until it either functions well, or turns out to be a dead end.
So you have my commitment as developer.
Derit can still provide patches.

Bart
Title: Re: ButtonEdit Component
Post by: Derit on March 21, 2014, 03:05:19 pm

Well, I didn't notice...

I think this is too big a change to commit at once.
For starters the published properties won't match (they cannot, by design), so even if you can compile the IDE it will crash upon start.
I would like to have the chance to develop this in a more relaxed mannor and time frame, not rushing it.

If you follow my proposal (or just develop it as a separate control, which may in time replace the old one), I will follow up on it and implement it until it either functions well, or turns out to be a dead end.
So you have my commitment as developer.
Derit can still provide patches.

Bart

many changes to it ....
add deprecated to editbutton old one
Title: Re: ButtonEdit Component
Post by: Bart on March 21, 2014, 03:56:31 pm
Personally I forsee many problems because of the different published properties.
This would mean that any Lazarus programm using current TEditButton (descendant) will crash upon loading once we ditch the old implementation. It is unavoidable if we proveed like this.

A better way might be to just write this component, make it better than the old one and then manually replace it where we/the users want it to.
Let the old implementation intact and mark it deprecated once the new one is up and about.

This way we can (right now) decide to add this component to LCL and develop it there (would be my choice).
It could go on a new Tab: "Grouped Controls" (IIRC MAttias invented this name?).
For me now it's a PITA, since many of my proposed changes conflict with derit's work.

I really don't want to (have to) change everything back again, looking at his code now (rev. 8).
@Derit: this is not personally, I rather feel some development decisions regarding this component should be changed, and better do it now than later.

Bart
Title: Re: ButtonEdit Component
Post by: JuhaManninen on March 21, 2014, 05:33:06 pm
Personally I forsee many problems because of the different published properties.

Yes, uhh!
Now I looked properly the recent development of derit's ButtonEdit. It has gone bad.
Last time I looked was the initial version when he started this thread.
It is the 2. commit in the repository, titled: "New Repo", SHA1: e0f751a0f5eba00b65f

What pulled my attention was this in constructor:

  with FEdit do
  begin
    Align := alClient;
    BorderStyle := bsNone;
    Parent := Self;
    ParentColor := True;
    OnChange := @DoEditTextChange;
    OnClick := @DoEditClick;
    OnExit := @DoEditExit;
    OnEnter := @DoEditEnter;
    OnKeyDown := @DoEditKeyDown;
    OnKeyPress := @DoEditKeyPress;
    OnKeyUp := @DoEditKeyUp;
    OnMouseDown := @DoEditMouseDown;
    OnMouseUp := @DoEditMouseUp;
    OnMouseEnter := @DoEditEnter;
    OnMouseLeave := @DoEditMouseLeave;
    OnMouseMove := @DoEditMouseMove;
  end;

and how the Do... methods and the events were done. (The Do... methods should not be virtual though).
I thought, this guy must be clever. He got this right while others have failed.
Even his initial naming "ButtonedEdit" was superior to our current EditButton. (I think we should use the better name and make EditButton a deprecated alias).

After that things started to go wrong for some reason. Working with Lazarus sources did not work well, and this separate component has become worse. Now it is as bad as the Blaazen's version (sorry Blaazen).

I think I under-estimated the difficulty of this task. Sorry everybody about that. Now I see 2 ways to go:

1. I make the component based on commit "New Repo", SHA1: e0f751a0f5eba00b65f.
I can put it inside an IFDEF if really needed.

2. Bart has now a vision of this component and energy to implement it. I suggest Bart takes charge on the issue.
You can use the "New Repo" commit or any other code as a base.
Using IFDEFs is ok. Just don't make a completely separate component because we really need a replacement for the current buggy TEditButton.
Title: Re: ButtonEdit Component
Post by: Bart on March 21, 2014, 06:49:50 pm
Personally I forsee many problems because of the different published properties.

Yes, uhh!
Now I looked properly the recent development of derit's ButtonEdit. It has gone bad.

The problems I mentioned are unavoidable, at least that's what I think.

Last time I looked was the initial version when he started this thread.
It is the 2. commit in the repository, titled: "New Repo", SHA1: e0f751a0f5eba00b65f

I'll have a look.

What pulled my attention was this in constructor:

  with FEdit do
  begin
...
    OnChange := @DoEditTextChange;
    OnClick := @DoEditClick;
...
and how the Do... methods and the events were done. (The Do... methods should not be virtual though).

I would have implemented a custom derived class for the edit control and then override all Doxxx methods to call the Onxxx events that belong to TButtonEdit.
Code: [Select]
type
  TMyEdit = class(TCustomEdit)
  ...
    procedure DoChange(Sender: TObject); override;
  end;
...
procedure TMyEdit.DoChange(Sender: TObject);
begin
  inherited DoChange;
  if assigned TButtonEdit(Owner).OnChange then TButtonEdit(Owner).OnChange(Self);
end;

Even his initial naming "ButtonedEdit" was superior to our current EditButton. (I think we should use the better name and make EditButton a deprecated alias).

I don't mind the TButtonEdit name.

I think I under-estimated the difficulty of this task. Sorry everybody about that. Now I see 2 ways to go:
...
2. Bart has now a vision of this component and energy to implement it. I suggest Bart takes charge on the issue.
You can use the "New Repo" commit or any other code as a base.
Using IFDEFs is ok. Just don't make a completely separate component because we really need a replacement for the current buggy TEditButton.

I'll take a look at the version you mentioned.
Personally I feel more comfortable implementing it as a new component and then when time is ripe replacing the TEditButton's code with it (ifdef-ed or not).
This is mainly because I'm quite sure it'll f.u. the IDE when I try to work on it that way?
But this may just be my ignorance.
Main point of concern here is that I then need to rebuild the LCL with the new define, but I only know how to do that whilst rebuilding the entire IDE...

Bart
Title: Re: ButtonEdit Component
Post by: taazz on March 21, 2014, 07:05:59 pm

Main point of concern here is that I then need to rebuild the LCL with the new define, but I only know how to do that whilst rebuilding the entire IDE...

Bart

How about opening the lclbase and lcl packages and select More>>\recompile clean ?
Title: Re: ButtonEdit Component
Post by: JuhaManninen on March 21, 2014, 10:54:33 pm
I would have implemented a custom derived class for the edit control and then override all Doxxx methods to call the Onxxx events that belong to TButtonEdit.

That may work, too. You can also look at the version I removed in r44433. It does not work.

Quote
Personally I feel more comfortable implementing it as a new component and then when time is ripe replacing the TEditButton's code with it (ifdef-ed or not).
This is mainly because I'm quite sure it'll f.u. the IDE when I try to work on it that way?

The best way to get attention and testers is to break the existing component and the IDE a little. If you develop it as a separate component, nobody will pay attention.

Quote
Main point of concern here is that I then need to rebuild the LCL with the new define, but I only know how to do that whilst rebuilding the entire IDE...

Unit editbtn is in LCLBase. Open it and add "NewEditButton" to its Compiler Options -> Other -> Defines ...
"recompile clean" suggested by taazz does not help if you don't have NewEditButton defined in the package.
You can also use the "Additions and Overrides" in project options to define NewEditButton for packages (if you know how to do it).
Title: Re: ButtonEdit Component
Post by: Derit on March 22, 2014, 03:48:05 am

Yes, uhh!
Now I looked properly the recent development of derit's ButtonEdit. It has gone bad.
Last time I looked was the initial version when he started this thread.
It is the 2. commit in the repository, titled: "New Repo", SHA1: e0f751a0f5eba00b65f

What pulled my attention was this in constructor:

  with FEdit do
  begin
    Align := alClient;
    BorderStyle := bsNone;
    Parent := Self;
    ParentColor := True;
    OnChange := @DoEditTextChange;
    OnClick := @DoEditClick;
    OnExit := @DoEditExit;
    OnEnter := @DoEditEnter;
    OnKeyDown := @DoEditKeyDown;
    OnKeyPress := @DoEditKeyPress;
    OnKeyUp := @DoEditKeyUp;
    OnMouseDown := @DoEditMouseDown;
    OnMouseUp := @DoEditMouseUp;
    OnMouseEnter := @DoEditEnter;
    OnMouseLeave := @DoEditMouseLeave;
    OnMouseMove := @DoEditMouseMove;
  end;

i don't know you like  it
I think it was better than the previous
Title: Re: ButtonEdit Component
Post by: JuhaManninen on March 22, 2014, 08:42:39 am
i don't know you like  it
I think it was better than the previous

What I like is not so important. The important thing is that the component works correctly. How did you test the events?
Title: Re: ButtonEdit Component
Post by: Derit on March 22, 2014, 10:34:11 am
What I like is not so important. The important thing is that the component works correctly. How did you test the events?
before commit I tested each of the events
and it works fine ....
Title: Re: ButtonEdit Component
Post by: Bart on March 22, 2014, 03:51:21 pm
OK, I will take charge of it then.
Next week and this weekend I'm heavily busy with my day job, so probably I'll commit something in first week of april.

@derit: can you please wait until I committed to Lazarus trunk?
Your contribution is greately appreciated!
Q: are you on contributos list yet? If not, can you (if you don't mind it) send me (pm or mail) your full name, after the first commit I can put you on the contributers list (Lazarus: Menu->Hel->About Lazarus->Tab: Contributors)?

@Juha: I'll fiddle around with the overrides or package. If I have specific questions about that I'll ask (you) on devel list.

Bart
Title: Re: ButtonEdit Component
Post by: Derit on March 22, 2014, 06:42:16 pm
OK, I will take charge of it then.
Next week and this weekend I'm heavily busy with my day job, so probably I'll commit something in first week of april.

@derit: can you please wait until I committed to Lazarus trunk?
Your contribution is greately appreciated!
Q: are you on contributos list yet? If not, can you (if you don't mind it) send me (pm or mail) your full name, after the first commit I can put you on the contributers list (Lazarus: Menu->Hel->About Lazarus->Tab: Contributors)?

@Juha: I'll fiddle around with the overrides or package. If I have specific questions about that I'll ask (you) on devel list.

Bart
Thanks for the appreciation  :)
Title: Re: ButtonEdit Component
Post by: Avishai on March 23, 2014, 05:02:23 am
I have been in hospital for the past 2 months and not strong enough to look at the forums so I am sorry if my comments are late.  When I am strong enough, I will take a look at the new ButtonEdit.

A. Has the new button been checked for RightToLeft with both BiDiMode and (for Windows) Mirroring?

B. Has anyone checked the 2 components TStickyLabel and TStickButton that I posted here on the forum and also submitted to BugTracker?  http://bugs.freepascal.org/view.php?id=24716
Title: Re: ButtonEdit Component
Post by: JuhaManninen on March 23, 2014, 09:25:55 am
B. Has anyone checked the 2 components TStickyLabel and TStickButton that I posted here on the forum and also submitted to BugTracker?  http://bugs.freepascal.org/view.php?id=24716

The components have only little advantages compared to LCL's layout system with anchors.
IMO such components belong to some other repository, for example to CCR.
LCL should be slim, not bloated, with only components that are VCL compatible or are needed by IDE itself.

Adding comments to the Mantis issue...
Title: Re: ButtonEdit Component
Post by: Bart on March 23, 2014, 10:25:49 am
I have been in hospital for the past 2 months.

Hope you recover soon!

A. Has the new button been checked for RightToLeft with both BiDiMode and (for Windows) Mirroring?

I'll put it on my ToDo list.

Bart
Title: Re: ButtonEdit Component
Post by: Bart on April 02, 2014, 12:46:13 am
Hi,

I started implementing TButtonEdit in revision 44584.
I still need to test if Lazarus will build with USEBUTTONEDIT defined.
(The component created at runtime seems to work.)

@Derit: if you have patches for the current implementation, please use the bugtracker.

@Juha: the AutoSize mechanism does not work as I want: the containers height seems to be heigher than expected (with smaller fonts), and it is impossible to set Widht when AutoSize is True. Maybe I need to override GetPreferredSize or related function?

Bart
Title: Re: ButtonEdit Component
Post by: Derit on April 02, 2014, 07:45:03 am
Hi,

@Derit: if you have patches for the current implementation, please use the bugtracker.


hi Bart i have patch for this
i will send to bugtracker :D
Title: Re: ButtonEdit Component
Post by: JuhaManninen on April 02, 2014, 07:47:17 am
I will look at it later today ...
Title: Re: ButtonEdit Component
Post by: Blaazen on April 02, 2014, 10:58:53 am
Quote
The AutoSize mechanism does not work as I want: the containers height seems to be heigher than expected (with smaller fonts), and it is impossible to set Widht when AutoSize is True. Maybe I need to override GetPreferredSize or related function?

You need to override CalculatePrefferedSize():

Code: [Select]
procedure TCustomGroupedEditButton.CalculatePreferredSize(var PreferredWidth,
  PreferredHeight: integer; WithThemeSpace: Boolean);
begin
  inherited CalculatePreferredSize(PreferredWidth, PreferredHeight,
    WithThemeSpace);
  PreferredWidth:=0;
end;   
When Preffered Width=0 it means that user can adjust size even if AutoSize is True.

EDIT:
Quote
I started implementing TButtonEdit in revision 44584.
I still need to test if Lazarus will build with USEBUTTONEDIT defined.
Unfortunately no. I got bunch of messages like:
Identifier not found: TCustomEditButton = ButtonEdit.TCustomEditButton;
Identifier not found: TEditButton = ButtonEdit.TEditButton; 
Title: Re: ButtonEdit Component
Post by: Derit on April 02, 2014, 05:04:59 pm
Unfortunately no. I got bunch of messages like:
Identifier not found: TCustomEditButton = ButtonEdit.TCustomEditButton;
Identifier not found: TEditButton = ButtonEdit.TEditButton;

uses ButtonEdit and Create with Code,
i think bart will replace the old Editbutton with new ButtonEdit,
i require code for create ButtonEdit not from component parlete
Title: Re: ButtonEdit Component
Post by: Bart on April 02, 2014, 11:09:14 pm
Well, I got it to compile and even build the IDE (not committed yet), but now I'm stuck.
Every form that has a TEditButton (the old one) on it refuses to load, because the component is not registered.
And I cannot register it (in EditBtn.pas), because it then complains that TEditButton is already  registered.

So, this (renaming the component to TButtonEdit), it seems, is not going to work.

So, how to proceed from here?
Implement it as a separate component and then manually (!) replace all affected components?
Stick with the old name?

Bart
Title: Re: ButtonEdit Component
Post by: Bart on April 02, 2014, 11:45:19 pm
Ah, well.
Fixed building.
Fixed the registering thingy.

Bart
Title: Re: ButtonEdit Component
Post by: JuhaManninen on April 03, 2014, 09:48:23 am
Yes, Blaazen's way for CalculatePreferredSize() works. The behavior then resembles TEdit's behavior.
You must also imitate TEdit's Height calculation inside CalculatePreferredSize() somehow.
Title: Re: ButtonEdit Component
Post by: Blaazen on April 03, 2014, 10:02:07 am
Quote
You must also imitate TEdit's Height calculation inside CalculatePreferredSize() somehow.
Looking to the old code, there were:
Code: [Select]
procedure TCustomGroupedEditButton.AnchorEditAndButton;
begin
  DisableAutoSizing;
  try
    Button.Anchors:=[];
    if IsRightToLeft then begin
      // button + edit
      Button.AnchorParallel(akLeft, 0, Self);
      Edit.AnchorAsAlign(alRight, 0);
      Edit.AnchorToNeighbour(akLeft, 0, Button);
    end else begin
      // edit + button
      Button.AnchorParallel(akRight, 0, Self);
      Edit.AnchorAsAlign(alLeft, 0);
      Edit.AnchorToNeighbour(akRight, 0, Button);
    end;
    Button.AnchorParallel(akTop, 0, Edit);
    Button.AnchorParallel(akBottom, 0, Edit);
  finally
    EnableAutoSizing;
  end;
end;
This method was called from two places:
1) constructor
2) overriden SetBiDiMode method

AFAIR this worked well.
Title: Re: ButtonEdit Component
Post by: JuhaManninen on April 03, 2014, 10:51:47 am
> procedure TCustomGroupedEditButton.AnchorEditAndButton;

That is the code for setting anchors inside the component. It must be dumped in the new component because internal anchors were the main reason for problems.
For example setting border space affected the anchored button.
The new component correctly encapsulates both Edit and Button parts inside its boundaries.
Anchoring is meant for layouting LCL components together.

Now, TEdit's height calculation based on font size is rather complex. Once it is found it must be reused (or copied) for TButtonEdit.
Title: Re: ButtonEdit Component
Post by: Bart on April 03, 2014, 11:05:28 am
The height of the new component responds to the font size when AutoSize = True.
I think this is due to the fact that the container behaves like that when changing the font size. (The font actually is the font of the container, the edit has ParentFont := True).

I will implement the CalculatePreferredSize() solution suggested by Blaazen to fix not being able to set Width when Autosize = True.

Once this (sort of) works, I think we should "kill" the old component (or reverse the conditional defines)?
This way we get much more testing than with the current define, and I suspect there will be regressions that need to be fixed.

Then there is the component palette:
It does not have an proper Icon for TButtonEdit. (should be the same as current TEditButton).
The Icon for TEditButton should be changed somehow to represent that is obsolete.

I don't know how to do that.

Bart
Title: Re: ButtonEdit Component
Post by: Bart on April 03, 2014, 11:19:54 am
I will implement the CalculatePreferredSize() solution suggested by Blaazen to fix not being able to set Width when Autosize = True.

Done in r44590.

Bart
Title: Re: ButtonEdit Component
Post by: Derit on April 03, 2014, 11:20:22 am

Then there is the component palette:
It does not have an proper Icon for TButtonEdit. (should be the same as current TEditButton).
The Icon for TEditButton should be changed somehow to represent that is obsolete.

I don't know how to do that.

Bart
i'm already insert icon to git
for change you use  res file from image folder ....
Title: Re: ButtonEdit Component
Post by: Bart on April 04, 2014, 12:44:38 pm
Then there is the component palette:
It does not have an proper Icon for TButtonEdit. (should be the same as current TEditButton).

Done in r44601.
Actually easier than I thought.

Bart
TinyPortal © 2005-2018