[lazarus] create

Baeseman, Cliff Cliff.Baeseman at greenheck.com
Tue May 18 18:57:16 EDT 1999


Well we have two options for the create component thing. One is to use the
construct that we are using and
the other is to pass the widget assignment up to fcomponent from the
implementation level such as in TCustomMemo.Create. The one we are using
allows us to add the widgets in one central location vs many units.

Two different approaches which is correct. The one we have specified here
makes it easier to build compound objects based from many different widgets
such as in the TMemo implementation without including units.

????

Cliff


-----Original Message-----
From: Sergio A. Kessler [mailto:sak at perio.unlp.edu.ar]
Sent: Tuesday, May 18, 1999 5:15 PM
To: Lazarus mailing list
Subject: [lazarus] create



Hey, what the heck is this ?

Procedure TControl.CreateComponent(AOwner : TComponent);
...
case fCompStyle of

csAlignment: Begin
		fComponent := gtk_alignment_new(0.5,0.5,0,0);
		gtk_widget_show(fComponent);
       	     end;

csButton: begin
   fComponent := gtk_button_new_with_label('Button');
   gtk_object_set_data(GTK_OBJECT (fComponent), PChar(Name), fComponent);
   end;
...

this should be managed by the components themselves, if
not every time we add a widget, we need to modify this
thingy.
And every time we create a widget, the code should traverse
this code, slowing downs things without need.

it shouldn't be:

constructor TCustomForm.Create(AOwner : TComponent);
begin
inherited Create(AOwner);

+  fComponent := gtk_window_new( GTK_WINDOW_DIALOG);
+  // set the window policies 
+  gtk_window_set_policy (GTK_WINDOW (fComponent), 1, 1, 0);
+  gtk_window_set_title(pGtkWindow(fComponent),'Caption');

  If AOwner = nil then
     fCompStyle := csMainForm
     else
     fCompStyle := csForm;
   Top := 1;
   Left := 1;
   Width := 120;
   Height := 120;
     	  Writeln('CreateComponent being called for TFORM');
	  CreateComponent(AOwner);
 { Assign  Signals }
   AssignOnDestroy;
   AssignOnShow;
   AssignOnFocus;
   AssignOnResize;
end;

the same with Destroy

TipNote: try to use // comments in one line comments, sometimes I want
to comment a block and I found nested comments in the hard way  :)

Sergio

_________________________________________________________________
     To unsubscribe: mail lazarus-request at miraclec.com with
                "unsubscribe" as the Subject
    archives at http://www.miraclec.com/list_archives/lazarus






More information about the Lazarus mailing list