Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2000-11

CustomFormEditor

6 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Shane Miller

OK, I added more code for the customformeditor. I added some code in customformeditor.pp for the class TComponentInterface. The problem is I don't know what the hell I am doing when it comes to getting typeinfo and calling GetPropInfo or stuff like that.

Can anyone help me? The TComponentInterface has functions like GetPropvaluebyname but I'm not sure how to go about doing that.

Any help?

Thanks
Shane

>> 11/18/00 07:05PM >>>

I didn't have

{$H+}

in the abstractformeditor definition file so one was sending an ansistring.....

Shane

>> 11/18/00 06:10PM >>>

OK, I started working on the FormEditor stuff but I hit a wall and I know it's something stupid so instead of looking at it for another hour I figured I would ask.

I committed my source to CVS so feel free to pull it.

In the lazrus/designer/abstractformeditor file I have functions in TAbstractFormEditor like

Function Filename : Stirng; virtual; abstract;

Then in TCustomFormEditor I declare a function

Function Filename : String; override;

but when I compile it tells me....

Overloaded methods which are virtual must have the same return type: TCUSTOMFORMEDITOR.FILENAME.

NO What's the deal?

Shane

>> 11/17/00 02:55PM >>>
Shane Miller wrote 6 lines
I don't think we have any controls that fill your needs at this time. I remember there was a GTK grid component created that we were thinking of using. Does anyone remember the site for that?

I'm not positive but it might have been gtkSheet.

http://magnet.fsu.edu/~feiguin/gtk/

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

Michael A. Hess
to Florian Klaempfl: The typeinfo unit is used to set/get published properties of classes at run time without…
Florian Klaempfl wrote
>Can anyone help me? The TComponentInterface has functions like >GetPropvaluebyname but I'm not sure how to go about doing that.

<snip>

Show quoted text 5 lines
Hope this helps a little bit ... If you need more help, feel free to ask. BTW: I propose that this info is stored for future use because I think I explained this already some months ago. But I agree it's quite difficult.

Shane when you get your arms around this why don't you add it to the FAQ page.

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com

Reply by email

Florian Klaempfl
to Shane Miller: OK, I added more code for the customformeditor. I added some code in customformeditor.pp…
you wrote
OK, I added more code for the customformeditor. I added some code in customformeditor.pp for the class TComponentInterface. The problem is I don't know what the hell I am doing when it comes to getting typeinfo and calling GetPropInfo or stuff like that.

The typeinfo unit is used to set/get published properties of classes at run time without
knowing the class declaration. This is quite difficult to do. To get an idea how it works,
have a look at the file tests\test\testrtti.pp in the tests repository of FPC.

Can anyone help me? The TComponentInterface has functions like GetPropvaluebyname but I'm not sure how to go about doing that.

The idea is that you can get the name of all published properties of a class via typinfo.GetPropList. With typinfo.GetPropInfo you can ask for more information about
a property by it's name and then you can use the Get*Prop/Set*Prop funtions to set/get the value of a property of a particular class instance.

I guess the GetPropValueByName funtions has to enculapse this procedure.

Hope this helps a little bit ...
If you need more help, feel free to ask. BTW: I propose that this info is stored for future
use because I think I explained this already some months ago. But I agree it's quite difficult.

Reply by email

Mattias Gaertner
to Stefan Hille: The only thing I did so far with RTTI is a small example of how to query an object.…
Shane Miller wrote
OK, I added more code for the customformeditor. I added some code in

customformeditor.pp for the class TComponentInterface. The problem is I don't know what the hell I am doing when it comes to getting typeinfo and calling GetPropInfo or stuff like that.

Can anyone help me? The TComponentInterface has functions like

GetPropvaluebyname but I'm not sure how to go about doing that.

The TFiler descendents TReader and TWriter in fcl/inc/classesh.inc describes in detail how to read and write all published properties. There is a little overhead because they must also handle ascendent values to avoid redundance, which is of no use for the FormEditor.

All you do it call the ComponentInterface's Set method and pass it a value. The ComponentInterface is used to query the values and set the values for the control. That's it's purpose.

Ok.
Because the Property Editors knows much better than any universal wrapper the boundaries of a value, they will check for validation. So the TComponentInterface don't need much checks.

The control will update it's look/position/size/etc. based on it's new value.

For these examples a rather simply interface is sufficient, because writing to the values (borderstyle, left, top, width, height) will do the tricks automatically.

Let's say the FormEditor has a TButton focused. When it get's focused I send

the OI the TComponentInterface for that control or I call a function letting you know that the control that is active has changed. I could send you the name of the control and you could then call FormEditor's FindComponent passing it the name. I would return to you an TIComponentInterface which would allow you to get a list of all it's methods and properties along with setting/getting the values for these properties.

When something changes in that control you call the ComponentInterface set

passing the NAME of the property and the value. Then I do what I need to and set that property.

I think, instead of names we can take the typinfo/classes structures. This is faster and we don't need to invent the wheel II.

Mattias

Reply by email

Shane Miller

I've commited source that I think will work using RTTI. If you look at the TComponentInterface code in lazarus/customformeditor.pp.

Now I'll try to write a program that uses these......

Shane

Reply by email

Stefan Hille
to Shane Miller: OK, I added more code for the customformeditor. I added some code in customformeditor.pp…
Shane Miller wrote 8 lines
OK, I added more code for the customformeditor. I added some code in customformeditor.pp for the class TComponentInterface. The problem is I don't know what the hell I am doing when it comes to getting typeinfo and calling GetPropInfo or stuff like that. Can anyone help me? The TComponentInterface has functions like GetPropvaluebyname but I'm not sure how to go about doing that. Any help? Thanks Shane

The only thing I did so far with RTTI is a small example of how to query an object. Simply assign this snippet as a callback to a button or so:

procedure TForm1.Button7Click(Sender : TObject);
var
   props : TPropList;
   pprops : PPropList;
   i      : integer;
Begin
   pprops := @props;
   GetPropInfos (Sender.ClassInfo, pprops);
   i := Low (props);
   while assigned (props[i]) and (i < high (props)) do
   begin
      writeln (props[i]^.name);
      inc (i);
   end;
end;

Hope this helps,

Stefan

--------------------------------------------------------- Stefan Hille email: 48155 Muenster voice: 0251/664695

Reply by email