Recent

Author Topic: ButtonEdit Component  (Read 35947 times)

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: ButtonEdit Component
« Reply #30 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

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: ButtonEdit Component
« Reply #31 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 ?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: ButtonEdit Component
« Reply #32 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).
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: ButtonEdit Component
« Reply #33 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
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: ButtonEdit Component
« Reply #34 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?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: ButtonEdit Component
« Reply #35 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 ....
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: ButtonEdit Component
« Reply #36 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

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: ButtonEdit Component
« Reply #37 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  :)
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: ButtonEdit Component
« Reply #38 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
Lazarus Trunk / fpc 2.6.2 / Win32

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: ButtonEdit Component
« Reply #39 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...
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: ButtonEdit Component
« Reply #40 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

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: ButtonEdit Component
« Reply #41 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

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: ButtonEdit Component
« Reply #42 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
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: ButtonEdit Component
« Reply #43 on: April 02, 2014, 07:47:17 am »
I will look at it later today ...
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: ButtonEdit Component
« Reply #44 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; 
« Last Edit: April 02, 2014, 11:03:48 am by Blaazen »
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 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/

 

TinyPortal © 2005-2018