Recent

Author Topic: Non-Visual TStringList Component  (Read 22396 times)

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Non-Visual TStringList Component
« Reply #15 on: November 23, 2013, 05:59:25 pm »
@engkin

Yes, but my solution is simply to use a text editor like NotePad to create/edit R2L text and the paste it into the code editor.  It isn't hard, it's just that it's one of many issues that I have to deal with that eats up time.
Lazarus Trunk / fpc 2.6.2 / Win32

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: Non-Visual TStringList Component
« Reply #16 on: November 23, 2013, 06:29:03 pm »
Quote
..my solution is simply to use a text editor like NotePad to create/edit R2L text and the paste it into the code editor.

And when you need to modify it, take it back to NotePad, do the changes, then pasted again into the code editor.  Sounds fun!

What about commenting you code, same?

Either way the code editor does not support Unicode control characters.


Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Non-Visual TStringList Component
« Reply #17 on: November 23, 2013, 06:36:41 pm »
Yes, working with R2L requires a lot of extra steps.  Copy/Paste, figuring out workarounds, experimenting...  It's just part of the game that you have to get used to.  But it add a lot to the time it takes to create a R2L app.  And the truth is that for MSWindows, Lazarus doesn't really support R2L.  That has been my goal from the beginning.  To add full R2L support, although I don't have the skills needed to do that.  But that doesn't keep me from trying. :)
Lazarus Trunk / fpc 2.6.2 / Win32

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: Non-Visual TStringList Component
« Reply #18 on: November 24, 2013, 12:28:25 am »
Avishai, check this attachment. Drawing the icon took longer time than writing the code. It's not a beautiful icon even!  :-[

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Non-Visual TStringList Component
« Reply #19 on: November 24, 2013, 02:20:20 am »
Thanks engkin, you beat me to it.  I was almost finished, but after reading your code I realize I was trying to over complicate things quite a bit.  It works like a charm and editing R2L strings is so easy now.  It will save me a huge amount of time and aggravation.
Lazarus Trunk / fpc 2.6.2 / Win32

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: Non-Visual TStringList Component
« Reply #20 on: November 24, 2013, 05:26:03 am »
 :-[ I can't claim credit for it. Most of the code was auto completed or generated by the component wizard. The property editor is already implemented.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8114
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Non-Visual TStringList Component
« Reply #21 on: November 24, 2013, 05:29:05 am »
@engkin:
You might want to add it to Lazarus-CCR so everybody can download and test.

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Non-Visual TStringList Component
« Reply #22 on: November 24, 2013, 09:22:31 am »
I just found a great and unexpected side effect to using TSCStringList.

TStringList.Sort does not work for Hebrew.  In fact, I use it to create a 'randomized' list.  But the List Editor has a 'Sort' button and it does a fair job of sorting Hebrew. :)  I wonder how well it would work for Arabic.
Lazarus Trunk / fpc 2.6.2 / Win32

avra

  • Hero Member
  • *****
  • Posts: 1731
    • Additional info
Re: Non-Visual TStringList Component
« Reply #23 on: November 24, 2013, 01:58:11 pm »
You can make use of attached gc unit and example.
Leledumbo, this is very similar to how I wanted to exploit interfaces but you have done it in a simpler and more elegant way. How free is your code for use? Can it be used even in commercial applications? What about changes? If I rename Guard to GC do I have to publish changes? I know that code is short, and some of these questions are dumb, but please give it some license. There are people that don't care about licenses, but there are also people that will not put anything into their work unless it has a proper license that fits. Something like PD, BSD or MPL is desirable  :D, but it's up to you.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Leledumbo

  • Hero Member
  • *****
  • Posts: 8114
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Non-Visual TStringList Component
« Reply #24 on: November 24, 2013, 03:10:54 pm »
Quote
How free is your code for use? Can it be used even in commercial applications? What about changes? If I rename Guard to GC do I have to publish changes?
First, it's not my code. I found it a couple of years ago when looking for garbage collection in object pascal. I can't seem to find the original article anymore...

avra

  • Hero Member
  • *****
  • Posts: 1731
    • Additional info
Re: Non-Visual TStringList Component
« Reply #25 on: November 25, 2013, 11:04:34 am »
Quote
How free is your code for use? Can it be used even in commercial applications? What about changes? If I rename Guard to GC do I have to publish changes?
First, it's not my code. I found it a couple of years ago when looking for garbage collection in object pascal. I can't seem to find the original article anymore...
OK, thanks. I found it here: http://delphi.cjcsoft.net/viewthread.php?tid=48730
I have also bumped into this more complex idea: http://edn.embarcadero.com/article/28217
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7596
Re: Non-Visual TStringList Component
« Reply #26 on: November 25, 2013, 03:03:36 pm »
Isn't simply
Code: [Select]
Type   
   TMyStringList = class(TComponent)
                               fstrlst : TStrings;
                            public
                               constructor create(parent:tsomething); override;  //check for exact paramter
                               destructor  destroy; override;
                           published
                              property strings: tstringlist read fstrlst write fstrlst;
                               end;
                           
                               constructor TMyStringList.create(parent:tsomething);  //check for exact paramter
                              begin
                                 fstrlst:=tstringlist.create;
                              end;
                               destructor  TMyStringList.destroy;
                                begin
                                   fstrlst.free;
                                end;
« Last Edit: November 26, 2013, 02:56:51 pm by marcov »

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: Non-Visual TStringList Component
« Reply #27 on: November 26, 2013, 05:38:43 am »
@engkin:
You might want to add it to Lazarus-CCR so everybody can download and test.

Leledumbo, :) thank you for the encouragement.


Avishai, I don't know if you noticed, but double clicking the component does nothing. I thought it might be a good idea to open the "String Editor Dialog". I attached it here with this post. Again, most of the code was already there, I just needed to rearrange it.


Marcov, yes, it is!
« Last Edit: November 26, 2013, 06:17:44 am by engkin »

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Non-Visual TStringList Component
« Reply #28 on: November 26, 2013, 08:37:57 am »
engkin, THANKS!  I can't understand why it took so long for me to realize that I needed such a component or just how valuable It would be.  It has taken one of my nightmares and turned it into fun.

My approach for writing it was so wrong.  I would have eventually ended up with something that worked, but your code is so clean.
Lazarus Trunk / fpc 2.6.2 / Win32

Windsurfer

  • Sr. Member
  • ****
  • Posts: 362
    • Windsurfer
Re: Non-Visual TStringList Component
« Reply #29 on: November 26, 2013, 01:56:56 pm »
#Avishai,

My apologies for this being off topic.

I am writing a small example program to show how the defaulttranslations unit works, and ask for a favour.

I want to include a right to left language example, but need some strings translated accurately into arabic or hebrew, whichever you prefer, or both.

If you are happy to translate them, they are in the project1.po file in the attachment. The msgstr "" is the part that needs to be completed.

Thanks in anticipation.