Sign in Join

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

Mailing lists / lazarus / 1999-05

new forms.pp

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Sergio Kessler

Hi, I'm playing a little with forms.pp, I'm using
gtk_signal_connect_object and not gtk_signal_connect.

I've simplyfied a little the code, all is working here (ok, that part :)
Take a look and tell me what you think (forms.pp attached).

Also there is no need to disconnect signals one by one, (like in destructor TCustomForm.destroy in forms.pp) gtk_signal_handlers_destroy( GtkObject *object );
disconnects all signals from a widget.

in compileroptions.pp I've changed this

procedure TForm1.mnuViewCompilerSettingsClicked;
begin
 fmCompilerOptions := TfmCompilerOptions.Create( self);
 fmCompilerOptions.Caption := 'Compiler Options2';
 fmCompilerOptions.Show;
 fmCompilerOptions.Destroy;   // should be release, not destroy
end;

and commented the proper line in lazarus.pp
in this way I can do View -> Compiler options all times I want, previously only one time and boom !

Sergio
(3 AM, going to bed...)

| Sergio A. Kessler http://perio.unlp.edu.ar/~sergio -O_O- Keep working at it... you will either succeed, or become an expert. { $Id: forms.pp,v 1.10 1999/05/17 04:16:24 lazarus Exp $} { Forms.pp by Shane Miller } Unit Forms; {$mode objfpc} Interface Uses glib,gdk,gtk,controls,vclglobals,classes,sysutils; Type TNotifyEvent = procedure (Sender : TObject); {CustomForm} TCustomForm = class(TWinControl) private FClientHandle: HWND; FOnDestroy : TNotifyEvent; FOnShow: TNotifyEvent; FOnResize: TNotifyEvent; FOnFocus: TNotifyEvent; onDestroyint : Integer; onShowint : Integer; onFocusint : Integer; onResizeint : Integer; procedure AssignOnDestroy; procedure AssignOnShow; procedure AssignOnFocus; procedure AssignOnResize; procedure DoDestroy; procedure DoShow; procedure DoResize; procedure DoFocus; function gtkOnFocus( widget: PGtkWidget): boolean; cdecl; function gtkOnResize( widget: PGtkWidget): boolean; cdecl; function gtkOnDestroy( widget: PGtkWidget): boolean; cdecl; function gtkOnShow( widget: PGtkWidget): boolean; cdecl; protected procedure Notification(AComponent: TComponent; Operation: TOperation); override; public constructor Create(AOwner: TComponent); override; destructor destroy; override; property Caption; property ClientHandle: HWND read FClientHandle; {events} property OnDestroy: TNotifyEvent read FOnDestroy write FOnDestroy; property OnShow: TNotifyEvent read FOnShow write FOnShow; property OnResize: TNotifyEvent read FOnResize write FOnResize; property OnFocus: TNotifyEvent read FOnFocus write FOnFocus; end; TForm = class(TCustomForm) public constructor Create(AOwner: TComponent); override; destructor Destroy; Override; published property Caption; end; TFormClass = class of TForm; TApplication = class(TComponent) private FTerminate : Boolean; FMainForm : TForm; FList: TList; public constructor Create(AOwner: TComponent); override; procedure CreateForm(NewForm : TFormClass; var ref); procedure Initialize; procedure Run; procedure Terminate; protected end; TProcedure = procedure; var Application : TApplication; InitProcedure : Pointer; Implementation uses guiapi,main; {------------------------------------------------------------------------------} function TCustomForm.gtkOnFocus( widget: PGtkWidget) : Boolean; cdecl; var Temp : Boolean; begin Writeln('Check Focus'); TCustomForm(self).DoFocus; end; {-----------------------------------------------------------------------------} function TCustomForm.gtkOnResize( widget: PGtkWidget) : Boolean;cdecl; var Temp : Boolean; begin Writeln('Check Resize'); TCustomForm(self).DoResize; end; {-----------------------------------------------------------------------------} function TCustomForm.gtkOnDestroy( widget: PGtkWidget) : Boolean; cdecl; var Temp : Boolean; begin Writeln('Check Destroy'); TCustomForm(self).DoDestroy; end; {------------------------------------------------------------------------------} function TCustomForm.gtkOnShow( widget: PGtkWidget) : Boolean; cdecl; var Temp : Boolean; begin Writeln('Check Show'); TCustomForm(self).DoShow; end; {------------------------------------------------------------------------------} procedure TCustomForm.AssignOnDestroy; begin Writeln('Assigning OnDestroy'); writeln('DESTROYINT = '+inttostr(onDestroyInt)); onDestroyint := gtk_signal_connect_object( gtk_Object(fcomponent), 'destroy', gtk_Signal_Func(@gtkOnDestroy), gtk_Object( Self)); end; {------------------------------------------------------------------------------} procedure TCustomForm.AssignOnShow; begin Writeln('Assigning OnShow'); writeln('ShowINT = '+inttostr(onShowInt)); onShowint := gtk_signal_connect_object( gtk_Object(fcomponent), 'show', gtk_Signal_Func(@gtkOnShow), gtk_Object( Self)); end; {------------------------------------------------------------------------------} procedure TCustomForm.AssignOnFocus; begin Writeln('Assigning OnFocus'); writeln('FocusINT = '+inttostr(onFocusInt)); onFocusint := gtk_signal_connect_object( gtk_Object(fcomponent), 'set_focus', gtk_Signal_Func(@gtkOnFocus), gtk_Object( Self)); end; {------------------------------------------------------------------------------} procedure TCustomForm.AssignOnresize; begin Writeln('Assigning Onresize'); writeln('ResizeINT = '+inttostr(onResizeInt)); onResizeint := gtk_signal_connect_object( gtk_Object(fcomponent), 'move_resize', gtk_Signal_Func(@gtkOnresize), gtk_Object( Self)); end; {------------------------------------------------------------------------------} destructor TCustomForm.destroy; begin writeln('Destroying signals for TForm'); gtk_signal_handlers_destroy( gtk_object( FComponent)); inherited Destroy; end; {------------------------------------------------------------------------------} procedure TCustomForm.DoDestroy; Begin Writeln('+++++++++++++++++++++++++++++++++++IN DO DESTROY+++++++++++++++++++++++++++++'); if Assigned (FOnDestroy) then FOnDestroy(Self); end; {------------------------------------------------------------------------------} procedure TCustomForm.DoShow; begin Writeln('+++++++++++++++++++++++++++++++++++IN DO SHOW+++++++++++++++++++++++++++++'); if Assigned (FOnShow) then FOnShow(Self); end; {------------------------------------------------------------------------------} procedure TCustomForm.Doresize; begin Writeln('+++++++++++++++++++++++++++++++++++IN DO Resize+++++++++++++++++++++++++++++'); if Assigned (FOnResize) then FOnResize(Self); end; {------------------------------------------------------------------------------} procedure TCustomForm.DoFocus; begin Writeln('+++++++++++++++++++++++++++++++++++IN DO FOCUS+++++++++++++++++++++++++++++'); if Assigned (FOnFOCUS) then FOnFocus(Self); end; {------------------------------------------------------------------------------} constructor TCustomForm.Create(AOwner : TComponent); begin inherited Create(AOwner); 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; {------------------------------------------------------------------------------} procedure TCustomForm.Notification(AComponent: TComponent; Operation: TOperation); begin inherited Notification(AComponent, Operation); end; {TFORM} {------------------------------------------------------------------------------} constructor TForm.Create(AOwner: TComponent); begin inherited Create(AOwner); end; {-----------------------------------------------------------------------------} destructor TForm.Destroy; begin inherited Destroy; end; {------------------------------------------------------------------------------} {TAPPLICATON} constructor TApplication.Create(AOwner: TComponent); begin inherited Create(AOwner); FTerminate := False; FMainForm := nil; end; procedure TApplication.Initialize; begin if InitProcedure nil then TProcedure(InitProcedure); end; procedure TApplication.Run; begin if FMainForm nil then FMainForm.Show; GUIAPI_HandleEvents; end; procedure TApplication.Terminate; begin FTerminate := True; GUIAPI_App_Terminate; end; procedure TApplication.CreateForm(NewForm : TFormClass; var ref); begin try TForm(ref) := NewForm.Create(Self); except raise; end; if FMainForm = nil then begin TForm(ref) := NewForm.Create(Self); FMainForm := TForm(ref); end else begin; if not assigned(FList) then FList := TList.Create; TForm(ref) := NewForm.Create(Self); FList.Add(TForm(ref)); end; { The next thing to do at this point will be to establish whether this } { is the first form that the TApplication is creating. If it is it sets } { this form as the controling form otherwise it just adds the form to a } { list stored with the Applications } end; {------------------------------------------------------------------------------} procedure RunStartup; begin Application := TApplication.Create(nil); InitProcedure := nil; end; procedure Cleanup; begin Application.Free; Application := nil; end; initialization RunStartup; finalization Cleanup; end. { $Log: forms.pp,v $ Revision 1.10 1999/05/17 04:16:24 lazarus TMemo colors files now. Still crashes once in a while. Certain files seem to make it crash. Try open buttons.pp Revision 1.8 1999/05/15 21:15:04 lazarus *** empty log message *** Revision 1.7 1999/05/14 18:44:10 lazarus *** empty log message *** Revision 1.6 1999/05/14 14:53:05 michael + Removed objpas from uses clause Revision 1.5 1999/05/07 05:46:50 lazarus *** empty log message *** Revision 1.4 1999/05/01 04:33:11 lazarus *** empty log message *** Revision 1.3 1999/05/01 03:55:27 lazarus *** empty log message *** Revision 1.2 1999/04/18 05:42:08 lazarus *** empty log message *** Revision 1.1 1999/04/14 07:31:44 michael + Initial implementation }

Reply by email

Michael A. Hess
to Sergio Kessler
Sergio Kessler wrote
Hi, I'm playing a little with forms.pp, I'm using gtk_signal_connect_object and not gtk_signal_connect.

If I might ask could no one else work on the gtk_signal_connect issues. I am in the process of trying to get it working with the

procedure DoShow({..stuff...}); message 'show';

So that it uses the Dispatcher now built into the FPC Objects. This will help remove the dependence on gtk for this part of the code. It will reside in guiapi.pp.

So far I have everything setup and it should work very nicely if I could just get the DispatchStr feature to work. I keep getting Access violations when every DispatchStr is being called.

Does any one have any pointer on this for me? Does any one have some sample code showing DispatchStr working because I can't get it to work at all and I don't know if it is me or the feature. HELP!

I'm currently working and testing with forms.pp but when I get it working I'll update from CVS and add it to all files that are currently calling gtk_signal_connect.

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

Reply by email

Shane Miller
Show quoted text 9 lines
>in compileroptions.pp I've changed this >procedure TForm1.mnuViewCompilerSettingsClicked; >begin > fmCompilerOptions := TfmCompilerOptions.Create( self); > fmCompilerOptions.Caption := 'Compiler Options2'; > fmCompilerOptions.Show; > fmCompilerOptions.Destroy; // should be release, not destroy >end;

How does that work? The show is not a "modal" show so once it's shown it goes to the destroy line right away and is destroyed....

Shane

Reply by email

Sergio Kessler
to Shane Miller
Shane Miller wrote 12 lines
>>in compileroptions.pp I've changed this >>procedure TForm1.mnuViewCompilerSettingsClicked; >>begin >> fmCompilerOptions := TfmCompilerOptions.Create( self); >> fmCompilerOptions.Caption := 'Compiler Options2'; >> fmCompilerOptions.Show; >> fmCompilerOptions.Destroy; // should be release, not destroy >>end; How does that work? The show is not a "modal" show so once it's shown it goes to the destroy line right away and is destroyed....

Oops, I don't know, but is working here...
I can even play with the form, so I don't think is destroyed after show :)

| Sergio A. Kessler http://perio.unlp.edu.ar/~sergio -O_O- Keep working at it... you will either succeed, or become an expert.

Reply by email

Sergio A. Kessler
to Sergio Kessler

Sergio Kessler el d�a Tue, 18 May 1999 11:01:29 -0300, escribi�:

Show quoted text 13 lines
Shane Miller wrote: > > >>in compileroptions.pp I've changed this > > >>procedure TForm1.mnuViewCompilerSettingsClicked; > >>begin > >> fmCompilerOptions := TfmCompilerOptions.Create( self); > >> fmCompilerOptions.Caption := 'Compiler Options2'; > >> fmCompilerOptions.Show; > >> fmCompilerOptions.Destroy; // should be release, not destroy > >>end; > > How does that work? The show is not a "modal" show so once it's shown it

goes to the destroy line right away and is destroyed....

Oops, I don't know, but is working here... I can even play with the form, so I don't think is destroyed after show :)

well, is easy, Destroy doesn't destroy the widget :)

Sergio

Reply by email