[lazarus] create

Sergio A. Kessler sak at perio.unlp.edu.ar
Tue May 18 18:16:57 EDT 1999



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






More information about the Lazarus mailing list