Sign in Join

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

Mailing lists / lazarus / 1999-05

HELP PLEASE!

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Nicolas Aragon
to Shane Miller: Here's the problem. This is a wrap up of the SELF problem and the OBjects reference…

Hey people,

If you quote the whole previous message (and several times), it's impossible to know what one is answering to. Help bandwidth saving good cause ;-)

In Editor.pp IO have a TEditor class that contains a TMemo (Memo1). If I create te Memo (Memo1 := TMemo1.Create(fmeditor)) I can access the Memo1 reference ONLY in the procedure that it was created in, not anywhere else!

This sounds very strange. Are you sure you haven't a same named local variable or something alike... sometimes, the more obvious the bug is, the most difficult to realize.

If I create the Memo1 in the TEditor.Create function then I get an error when I try to do a Memo1.Show in the openfile procedure or anywhere else I try to access it....

Hmmm... try to store an integer value, typecasting the pointer:

  memo1 := TMemo( 666 );

...or whatever the trick the compiler needs to eat this. Then try to peek this value doing the reverse typecast from some other point and show it with a writeln. If the value has changed you may be trashing the memory elsewhere!

Is this a problem with my code (using a TStringList to store the fmeditor object) or is it something else?

Sorry I cannot take a deeper look as of now :-(

This is making me think a little. We could use fixed then instead of these darn tables for widget placement.

If only you heard me O:)

Right. We need to send the signal to each child and then in their resize (tcontrol's resize) we need to check their alignment.

Doesn't gtk do this by itself?

I think that a TLISt is already being recorded for each parent and child.

So you aren't doing it yet!! :)

TControl should have a TList to store all its children, accesible by an array property "Controls". This is quite well done in VCL.

I would have liked to make my code work before showing it to anybody else, but I attach it to this message in the hope that it could be useful, at least in order some portions to be c&p'ed.

Be aware that the whole thing doesn't work. Also it's intended to be used with a more complex scheme than that you're currently using, to allow portable code between libraries.

Please notice too that it's untouched for the last three months. The version of gtkcontrols.pp actually in my page is rather modified (it does work BTW).

TControl and a replacement for TComponent (then I was unable to compile fcl) are provided with basic functionality.

And specially... don't laugh at my code!!! :-)

I should really look at the internal GTK code to see how that stuff is implemented.. In this way you could just set the new position during a form resize event.

I've adopted a "prudency" strategy. I store "desired" size and position using them after inserting the control in its parent to put it in place.

When the control is already attached to a parent, I use the gtk functions to retrieve actual size and position since the control could have been moved or resized by other means. It needs more work, though. I think this code is already in my page.

send a RESIZE message to it and then check it's alignment or something and resize it accordingly.

Why not encapsulating gtk boxes as panels? It would work the way as a Delphi VCL TPanel. A little complicated since boxes are here the default and "fixed approach" Delphi's.

I assume we'll want to have a TList or something of all child widgets, then send this mesdsage to each of them..... Thoughts?

My ideas surely will be unuseful without looking at the whole code. I would try to make the orchestra work with few instruments at first and add the rest only when I'm sure the basic melody is tuned. Debugging a big program could be exponentially more difficult than a little one. And having complete basic classes (like TControl) from the beginning, instead of slowly adding functionality could help too.

Just my two cents. Please take this in its worth meassure :)

greetings

Nico

Reply by email

Shane Miller

Here's the problem. This is a wrap up of the SELF problem and the OBjects reference problem.

In Editor.pp IO have a TEditor class that contains a TMemo (Memo1).  If I create te Memo (Memo1 := TMemo1.Create(fmeditor)) I can access the Memo1 reference ONLY in the procedure that it was created in, not anywhere else!  If I create the Memo1 in the TEditor.Create function then I get an error when I try to do a Memo1.Show in the openfile procedure or anywhere else I try to access it....

Is this a problem with my code (using a TStringList to store the fmeditor object) or is it something else?

Shane

>> "Baeseman, Cliff" 05/17 1:00 PM >>>

This is making me think a little. We could use fixed then instead of these darn tables for widget placement. Maybe I should try to move a widget using a fixed type placement. Once again I may have to unparent it before reattaching to the fixed object.

It may make for a slow resize? Not sure the code seems to run pretty fast right now.

Cliff

Earlier message 173 lines
-----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 12:53 PM To: Subject: Re: RE: RE: RE: [lazarus] 10998 bug has been killed Right. We need to send the signal to each child and then in their resize (tcontrol's resize) we need to check their alignment. I think that a TLISt is already being recorded for each parent and child. Perhaps it's defined in TComponent or something though. I thought there was already a list though. Maybe TApplication or TForms? In TApplication you could run though all the controls and see if their parent is SELF (if self worked) and if it is then send them the resize signal. Shane >>> "Baeseman, Cliff" 05/17 12:46 PM >>> so the parent will have to hold a list of the components that have been attached. On a parent resize the parent will loop the list of children and have them emit the resize signal? Just thinking ;) Cliff -----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 12:40 PM To: Subject: Re: RE: RE: [lazarus] 10998 bug has been killed That's not really my issue though. Your talking about resizing a widget and displaying it correctly. I'm talking about a form that contains a memo and a status bar. When the Form is resized, I would like to call the Memo.Resize and the Statusbar.resize so we can check to see if their alignment was alCLient or alBottom or whatever. Somehow when a parent (form) is resized, it has to tell the child widgets to resize too.... Shane >>> "Baeseman, Cliff" 05/17 12:31 PM >>> Ok so you have it working again. Thats good. I have bee trying to move the widget once resize is called but have not been successful. In order to do this the object references need to work properly. steps for dynamic movement I was trying. 1. When add control is called set fParentGrid on the passed child to the parents grid (attached to the form). 2. When resize is called take the new height and width properites do a table attach on the parent grid. This in theory should move the widget to the new location. Maybe I need to call gtk_widget_unparent first to blow the current parent reference away and remove the child from the internal list first.. I should really look at the internal GTK code to see how that stuff is implemented.. In this way you could just set the new position during a form resize event. Cliff -----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 12:16 PM To: Subject: Re: RE: [lazarus] 10998 bug has been killed I changed my GTK so the flags portion is the same as the old version and I can use the '+' sign when dealing with the GTK_SHRINK + GTK_FILL ... and the memo resizes now. Has GTK been changed in CVS so that this will compile on other people's systems? Shane (again) >>> "Baeseman, Cliff" 05/17 12:01 PM >>> We have to get the flags working again in the table attach method. I have it set to fill right now but it should be gtk_fill or gtk_stretch or gtk_expand set for both of the sizing methods. With these three set the widgets will expand and shrink with the parent which is the grid.... Cliff -----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 11:57 AM To: Subject: Re: [lazarus] 10998 bug has been killed I will be updating CVS soon with a version that can open almost all .pp files and color them. Currently I am still having the "self" problem where SELF isn't assigned and therefore I have to generically assign a local variable to "self" which is stored in the unitlist.objects property. I need someone to look at the following: Determine a way to resize the child widget when the parent resizes. For example, open a file using file-open and rtesize the form. The memo stays the same size. We need to send a RESIZE message to it and then check it's alignment or something and resize it accordingly. I assume we'll want to have a TList or something of all child widgets, then send this mesdsage to each of them..... Thoughts? Shane >>> Peter Vreman 05/14 11:37 AM >>> Nothing more to say here ;) Peter _________________________________________________________________ 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 _________________________________________________________________ To unsubscribe: mail an 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 _________________________________________________________________ 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

Shane Miller
>In Editor.pp IO have a TEditor class that contains a TMemo (Memo1). If I create te Memo (Memo1 := TMemo1.Create(fmeditor)) I can access the Memo1 reference ONLY in the procedure that it was created in, not anywhere else! >This sounds very strange. Are you sure you haven't a same named local

variable or something alike... sometimes, the more obvious the bug is, the most difficult to realize.

I agree it sounds odd but take a look at the source out of CVS. It's happening and there are no other local or global variables with the same name.

>If I create the Memo1 in the TEditor.Create function then I get an error when I try to do a Memo1.Show in the openfile procedure or anywhere else I try to access it.... >Hmmm... try to store an integer value, typecasting the pointer:
  memo1 := TMemo( 666 );

...or whatever the trick the compiler needs to eat this. Then try to peek this value doing the reverse typecast from some other point and show it with a writeln. If the value has changed you may be trashing the memory elsewhere!

I will take a look at that and see if it gives me the 666 (or whatever) back.

Shane

Reply by email

Baeseman, Cliff

Nope this is the exact same snag I ran into period...

Not your code it is a compiler thing or something...

Cliff

Earlier message 215 lines
-----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 1:27 PM To: Subject: [lazarus] HELP PLEASE! Here's the problem. This is a wrap up of the SELF problem and the OBjects reference problem. In Editor.pp IO have a TEditor class that contains a TMemo (Memo1). If I create te Memo (Memo1 := TMemo1.Create(fmeditor)) I can access the Memo1 reference ONLY in the procedure that it was created in, not anywhere else! If I create the Memo1 in the TEditor.Create function then I get an error when I try to do a Memo1.Show in the openfile procedure or anywhere else I try to access it.... Is this a problem with my code (using a TStringList to store the fmeditor object) or is it something else? Shane >>> "Baeseman, Cliff" 05/17 1:00 PM >>> This is making me think a little. We could use fixed then instead of these darn tables for widget placement. Maybe I should try to move a widget using a fixed type placement. Once again I may have to unparent it before reattaching to the fixed object. It may make for a slow resize? Not sure the code seems to run pretty fast right now. Cliff -----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 12:53 PM To: Subject: Re: RE: RE: RE: [lazarus] 10998 bug has been killed Right. We need to send the signal to each child and then in their resize (tcontrol's resize) we need to check their alignment. I think that a TLISt is already being recorded for each parent and child. Perhaps it's defined in TComponent or something though. I thought there was already a list though. Maybe TApplication or TForms? In TApplication you could run though all the controls and see if their parent is SELF (if self worked) and if it is then send them the resize signal. Shane >>> "Baeseman, Cliff" 05/17 12:46 PM >>> so the parent will have to hold a list of the components that have been attached. On a parent resize the parent will loop the list of children and have them emit the resize signal? Just thinking ;) Cliff -----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 12:40 PM To: Subject: Re: RE: RE: [lazarus] 10998 bug has been killed That's not really my issue though. Your talking about resizing a widget and displaying it correctly. I'm talking about a form that contains a memo and a status bar. When the Form is resized, I would like to call the Memo.Resize and the Statusbar.resize so we can check to see if their alignment was alCLient or alBottom or whatever. Somehow when a parent (form) is resized, it has to tell the child widgets to resize too.... Shane >>> "Baeseman, Cliff" 05/17 12:31 PM >>> Ok so you have it working again. Thats good. I have bee trying to move the widget once resize is called but have not been successful. In order to do this the object references need to work properly. steps for dynamic movement I was trying. 1. When add control is called set fParentGrid on the passed child to the parents grid (attached to the form). 2. When resize is called take the new height and width properites do a table attach on the parent grid. This in theory should move the widget to the new location. Maybe I need to call gtk_widget_unparent first to blow the current parent reference away and remove the child from the internal list first.. I should really look at the internal GTK code to see how that stuff is implemented.. In this way you could just set the new position during a form resize event. Cliff -----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 12:16 PM To: Subject: Re: RE: [lazarus] 10998 bug has been killed I changed my GTK so the flags portion is the same as the old version and I can use the '+' sign when dealing with the GTK_SHRINK + GTK_FILL ... and the memo resizes now. Has GTK been changed in CVS so that this will compile on other people's systems? Shane (again) >>> "Baeseman, Cliff" 05/17 12:01 PM >>> We have to get the flags working again in the table attach method. I have it set to fill right now but it should be gtk_fill or gtk_stretch or gtk_expand set for both of the sizing methods. With these three set the widgets will expand and shrink with the parent which is the grid.... Cliff -----Original Message----- From: Shane Miller Sent: Monday, May 17, 1999 11:57 AM To: Subject: Re: [lazarus] 10998 bug has been killed I will be updating CVS soon with a version that can open almost all .pp files and color them. Currently I am still having the "self" problem where SELF isn't assigned and therefore I have to generically assign a local variable to "self" which is stored in the unitlist.objects property. I need someone to look at the following: Determine a way to resize the child widget when the parent resizes. For example, open a file using file-open and rtesize the form. The memo stays the same size. We need to send a RESIZE message to it and then check it's alignment or something and resize it accordingly. I assume we'll want to have a TList or something of all child widgets, then send this mesdsage to each of them..... Thoughts? Shane >>> Peter Vreman 05/14 11:37 AM >>> Nothing more to say here ;) Peter _________________________________________________________________ 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 _________________________________________________________________ To unsubscribe: mail an 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 _________________________________________________________________ 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 _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email