Forum > LCL

Subclassing Widgets

(1/2) > >>

VTwin:
I am migrating from REALbasic where I had a small library of widgets that I subclassed to modify their behavior. These could be imported and used in the layout.

In Lazarus I don't see a mechanism to do this. Instead I have started to write wrapper (if that is the correct term) classes that are initialized with widgets in TForm.Create. A simple example is adding a method to select all rows in a TListView. Something like:


--- Code: ---constructor TListForm1.Create(AOwner: TComponent);
begin
  inherited;
  fListViewWrapper := TListViewWrapper.Create(ListView1);
end;

procedure TListForm1.DoSelectAll;
begin
   fListViewWrapper.SelectAll;
end;

--- End code ---

This works fine, but I'm wondering if I'm overlooking a more obvious solution. Any comments appreciated.

Cheers,
Frederick

Martin_fr:
Create a new Package.

then in the package window, press "Add" and choose "new component"

JD:

--- Quote from: Frederick on February 26, 2011, 04:43:10 pm ---I am migrating from REALbasic where I had a small library of widgets that I subclassed to modify their behavior. These could be imported and used in the layout.
        ........................
        ........................

Cheers,
Frederick

--- End quote ---

Hi Frederick, I'm interested to know why you are migrating from RealBasic to Lazarus. Is it a "cost" thing or is it a functionality thing or maybe even something else? I played a little with RealBasic but I had already discovered Lazarus so I did not take it any further.

Cheers,

JD

VTwin:

--- Quote from: Martin_fr on February 26, 2011, 05:25:17 pm ---Create a new Package.

then in the package window, press "Add" and choose "new component"

--- End quote ---

Wow! That is exactly what I was looking for.

I have a lot to learn, thanks Martin.

VTwin:

--- Quote ---Hi Frederick, I'm interested to know why you are migrating from RealBasic to Lazarus. Is it a "cost" thing or is it a functionality thing or maybe even something else? I played a little with RealBasic but I had already discovered Lazarus so I did not take it any further.

Cheers,

JD

--- End quote ---

I used to use TurboPascal way back, and then migrated through various C++ packages on both Windows and Mac, but really needed a simple cross-platform tool. I use Mac exclusively myself, but need to support Windows. REALbasic is honestly exceptional for cross-platform development, and I have been using it pretty much since it first came out.

Money is not really the issue, as I can use an academic license, but the cost did get me looking for alternatives. They become more expensive all the time, and they went to a subscription model. You can only install it on two computers which have to be connected to the internet, so if I have it installed on two computers, I can't put it on my laptop when I travel. Then there is the question of plugins, which can be the only way to optimize some functions. For most things you don't notice, but FPC's code is much more highly optimized when I need speed. Plugins are a pain to write, and require frequent updates.

I like the idea of using open source code, and since Lazarus is based on Dephi it has a large potential user base, and a large and active community of developers. It terms of code availability, there seem to be a large number of sources. If I look hard enough, I seem to be able to find just about anything I need. I am very impressed, although I have yet to attempt cross-compiling.

I did try Python for a few months, and thought that seemed promising, but getting working code to my users in a simple package seemed extremely difficult.

Last, I'm always a little embarrassed to admit I code in BASIC, never cared much for C++, and have always had a soft spot for Pascal.

Cheers

Navigation

[0] Message Index

[#] Next page

Go to full version