Shane something interesting to note is that in the flat ide I handle the widgets global.
maybe some widget storage location with grab widget by name? might be handy for the stuff you are talking about.
Just thinking.
cliff

Mailing lists / lazarus / 1999-05
8 messages · 4 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Shane something interesting to note is that in the flat ide I handle the widgets global.
maybe some widget storage location with grab widget by name? might be handy for the stuff you are talking about.
Just thinking.
cliff
I am re-doing the OPENFILE procedure in the Editor.pp file and it seems this has fixed the problem with it crashing when it loads source files. I am having one slight problem yet that I am trying to fix but I plan on updating today or tomorrow when finished...
Shane
>> "Shane Miller" 05/22 12:50 AM >>>
Could someone look at this? Here's the issue:
If you run Lazarus and try to open Editor.pp you probably get an unhandled exception. So What I did was put in a bunch of writeln's in editor.pp so I could see wheere it was crashing. Well, I finally reached a point where if I added another writeln, it wouldn't crash! Then I commented out the writeln and it would crash again. Please try that. If it crashes, look where the last writeln was and trace it a but further, and put in a writeln. Then run it again and load the same file. If it crashes, put in another writeln a bit further on into the program and run it again until it no longer crashes.
It's odd isn't it. PLEASE someone try this OTHER than me! Let me know your thoughts
Shane
Well all we would actually do is grab the control by name and therefore we would have the associated widget along with it.
That should work.
Shane
>> "Baeseman, Cliff" 05/21 9:53 AM >>>
Shane something interesting to note is that in the flat ide I handle the widgets global.
maybe some widget storage location with grab widget by name? might be handy for the stuff you are talking about.
Just thinking.
cliff
Looking at your dialogs.pp file I have some questions. <Enter> :-) I thought the idea…
"Shane Miller" el d�a Fri, 21 May 1999 09:37:49 -0500, escribi�:
Looking at your dialogs.pp file I have some questions. <Enter> :-) I thought the idea was to seperate the GTK from the classes? Now I see a lot of gtk specific calls in dialogs.pp
yep, the easy way :)
Why not create a unit that has a function called CreateControl or something like that. You pass it a fcomponentstyle and it passes back a pointer.
It's not that simple, look at ShowMessage()
Sergio
Could someone look at this? Here's the issue:
If you run Lazarus and try to open Editor.pp you probably get an unhandled exception. So What I did was put in a bunch of writeln's in editor.pp so I could see wheere it was crashing. Well, I finally reached a point where if I added another writeln, it wouldn't crash! Then I commented out the writeln and it would crash again. Please try that. If it crashes, look where the last writeln was and trace it a but further, and put in a writeln. Then run it again and load the same file. If it crashes, put in another writeln a bit further on into the program and run it again until it no longer crashes.
It's odd isn't it. PLEASE someone try this OTHER than me! Let me know your thoughts
Shane
Hi all,
dialogs.pp 0.3 is out
I've tested extensively and is working fine, if something is broke on your pc, you are not following th How-To :)
attached and pasted here:
//==================================================================
//
// Dialogs Unit
//
// Contains : TOpenFileDialog
// TSaveFileDialog
// ShowMessage
//
//-----------------------------------------------------------------
//
// Authors: Sergio A. Kessler
//
// License: in consideration (MPL ?).
//
// Version: 0.3
//
//==================================================================
unit dialogs;
{$mode objfpc}
interface
uses
gtk, classes, Controls, vclGlobals, sysutils;
type
TCustomDialog = class(TWinControl)
private
FUserChoice: (user_thinking, user_ok, user_cancel, user_close);
function gtk_Ok( widget: PGtkWidget) : Boolean; cdecl;
function gtk_Cancel( widget: PGtkWidget) : Boolean; cdecl;
function gtk_Close( widget: PGtkWidget) : Boolean; cdecl;
protected
public
constructor Create(AOwner : TComponent); override;
destructor destroy; override;
end;
TOpenFileDialog = class(TCustomDialog)
private
FFileName : AnsiString;
FTitle: AnsiString;
FFilter: AnsiString;
procedure gtk_create;
procedure gtk_destroy;
public
constructor Create (AOwner : TComponent); override;
destructor destroy; override;
Function Execute : boolean;
property FileName : AnsiString read FFileName write FFileName;
property Title : AnsiString read FTitle write FTitle;
property Filter : AnsiString read FFilter write FFilter;
end;
TSaveFileDialog = class(TOpenFileDialog);
procedure ShowMessage( const msg: AnsiString );
Implementation
var btn_ok: boolean;
//----------------------------------------------------------------------------
function TCustomDialog.gtk_Ok( widget: PGtkWidget) : Boolean; cdecl;
begin
writeln('--> in gtk_ok');
FUserChoice := user_ok;
end;
//----------------------------------------------------------------------------
function TCustomDialog.gtk_Cancel( widget: PGtkWidget) : Boolean; cdecl;
begin
writeln('--> in gtk_cancel');
FUserChoice := user_cancel;
end;
//----------------------------------------------------------------------------
function TCustomDialog.gtk_Close( widget: PGtkWidget) : Boolean; cdecl;
begin
writeln('--> in gtk_close');
FUserChoice := user_close;
end;
//----------------------------------------------------------------------------
constructor TCustomDialog.Create (AOwner : TComponent);
begin
// the TCustomDialog should not create the file_selection
inherited Create(AOwner);
End;
//----------------------------------------------------------------------------
destructor TCustomDialog.destroy;
begin
inherited Destroy;
End;
//----------------------------------------------------------------------------
constructor TOpenFileDialog.Create (AOwner : TComponent);
begin
inherited Create(AOwner);
gtk_create;
end;
//----------------------------------------------------------------------------
destructor TOpenFileDialog.destroy;
begin
gtk_destroy;
inherited Destroy;
end;
//----------------------------------------------------------------------------
Function TOpenFileDialog.Execute : boolean;
begin
if not (GTK_IS_FILE_SELECTION( FComponent)) then gtk_create;
if FTitle '' then
begin
gtk_window_set_title( @((PGtkFileSelection( FComponent))^.Window),
PChar(FTitle));
end;
if FFileName '' then
begin
gtk_file_selection_set_filename( PGtkFileSelection( FComponent),
PChar(FFileName));
end;
if FFilter '' then
begin
gtk_file_selection_complete( PGtkFileSelection( FComponent),
PChar(FFilter));
end;
FUserChoice := user_thinking;
writeln('--> about to file_sel_show');
Show;
repeat
gtk_main_iteration;
until FUserChoice user_thinking;
writeln('--> about to file_sel_hide');
if (FUserChoice user_close) then Hide;
Execute := (FUserChoice = user_ok);
if Execute then
begin
FFileName := gtk_file_selection_get_filename( PGtkFileSelection(
FComponent));
end;
end;
//----------------------------------------------------------------------------
Procedure TOpenFileDialog.gtk_create;
begin
FComponent := gtk_file_selection_new( PChar( FTitle));
gtk_window_set_modal( @((PGtkFileSelection( FComponent))^.Window),
True);gtk_signal_connect_object( gtk_object(
(PGtkFileSelection(FComponent))^.ok_button),
'clicked',
gtk_signal_func( @gtk_ok),
gtk_object( self));gtk_signal_connect_object( gtk_object(
(PGtkFileSelection(FComponent))^.cancel_button),
'clicked',
gtk_signal_func( @gtk_cancel),
gtk_object( self));gtk_signal_connect_object( gtk_object( FComponent), 'destroy',
gtk_signal_func( @gtk_close),
gtk_object( self));end;
//----------------------------------------------------------------------------
Procedure TOpenFileDialog.gtk_destroy;
begin
if (GTK_IS_FILE_SELECTION( FComponent)) then
begin
writeln('--> destroying file_selection');
gtk_signal_handlers_destroy( gtk_object(
(PGtkFileSelection(FComponent))^.ok_button));
gtk_signal_handlers_destroy( gtk_object(
(PGtkFileSelection(FComponent))^.cancel_button));
gtk_signal_handlers_destroy( gtk_object( FComponent));
gtk_widget_destroy( PGtkWidget( FComponent));
end;
end;
{function TCustomDialog.GetFileName : String;
Begin
// this is buggy because you don't know if the widget is destroyed !!
FFileName := gtk_file_selection_get_filename( PGtkFileSelection(
FComponent));
GetFileName := FFileName;
End;}
//----------------------------------------------------------------------------
procedure ShowMessage( const msg: AnsiString );
var dlg: PGtkWidget;
btn: PGtkWidget;
lab: PGtkWidget;
function gtk_btn_ok( widget: PGtkWidget) : Boolean; cdecl;
begin
writeln('--> in gtk_btn_ok');
btn_ok := true;
end;
begin
// this fu* shit is absolutely trivial in Gnome
dlg := gtk_dialog_new;
btn := gtk_button_new_with_label('Ok');
lab := gtk_label_new( PChar(msg));
gtk_box_pack_start( PGtkBox( PGtkDialog( dlg)^.action_area), btn, True,
True, 0);
gtk_box_pack_start( PGtkBox( PGtkDialog( dlg)^.vbox), lab, True, True,
0);
gtk_signal_connect_object( gtk_object( btn),
'clicked',
gtk_signal_func( @gtk_btn_ok),
gtk_object( btn));
gtk_signal_connect_object( gtk_object( dlg),
'destroy',
gtk_signal_func( @gtk_btn_ok),
gtk_object( dlg));
btn_ok := false;
gtk_widget_show( btn);
gtk_widget_show( lab);
gtk_widget_show( dlg);
repeat
gtk_main_iteration;
until btn_ok;
if GTK_IS_DIALOG( dlg) then
begin
gtk_widget_hide( dlg);
gtk_signal_handlers_destroy( gtk_object( btn));
gtk_widget_destroy( dlg);
end;
end;
end.Thats what i am thinking. How do you deal with the methods. Maybe in the same unit with pascal wrappers that take the widget pointer as a parameter. That would eliminate even the method calls from the tree...
more thinking. ;))
Cliff
Looking at your dialogs.pp file I have some questions. <Enter> :-)
I thought the idea was to seperate the GTK from the classes? Now I see a lot of gtk specific calls in dialogs.pp
Why not create a unit that has a function called CreateControl or something like that. You pass it a fcomponentstyle and it passes back a pointer. This way when we want to create Lazarus qith QT widget, we create a unit that replaces the CreateControl with QT's createControl and it create's QT widgets? Also, the set_modal could actually call a procedure in that unit.
This makes perfect sense to me because I see it as helping out when we have to write a QT interface. Nothing in the classes will need to change.
(don't flame too much)
Shane
>> Sergio Kessler 05/21 1:50 AM >>>
Hi all,
dialogs.pp 0.3 is out
I've tested extensively and is working fine, if something is broke on your pc, you are not following th How-To :)
attached and pasted here:
//==================================================================
//
// Dialogs Unit
//
// Contains : TOpenFileDialog
// TSaveFileDialog
// ShowMessage
//
//-----------------------------------------------------------------
//
// Authors: Sergio A. Kessler
//
// License: in consideration (MPL ?).
//
// Version: 0.3
//
//==================================================================
unit dialogs;
{$mode objfpc}
interface
uses
gtk, classes, Controls, vclGlobals, sysutils;
type
TCustomDialog = class(TWinControl)
private
FUserChoice: (user_thinking, user_ok, user_cancel, user_close);
function gtk_Ok( widget: PGtkWidget) : Boolean; cdecl;
function gtk_Cancel( widget: PGtkWidget) : Boolean; cdecl;
function gtk_Close( widget: PGtkWidget) : Boolean; cdecl;
protected
public
constructor Create(AOwner : TComponent); override;
destructor destroy; override;
end;
TOpenFileDialog = class(TCustomDialog)
private
FFileName : AnsiString;
FTitle: AnsiString;
FFilter: AnsiString;
procedure gtk_create;
procedure gtk_destroy;
public
constructor Create (AOwner : TComponent); override;
destructor destroy; override;
Function Execute : boolean;
property FileName : AnsiString read FFileName write FFileName;
property Title : AnsiString read FTitle write FTitle;
property Filter : AnsiString read FFilter write FFilter;
end;
TSaveFileDialog = class(TOpenFileDialog);
procedure ShowMessage( const msg: AnsiString );
Implementation
var btn_ok: boolean;
//----------------------------------------------------------------------------
function TCustomDialog.gtk_Ok( widget: PGtkWidget) : Boolean; cdecl;
begin
writeln('--> in gtk_ok');
FUserChoice := user_ok;
end;
//----------------------------------------------------------------------------
function TCustomDialog.gtk_Cancel( widget: PGtkWidget) : Boolean; cdecl;
begin
writeln('--> in gtk_cancel');
FUserChoice := user_cancel;
end;
//----------------------------------------------------------------------------
function TCustomDialog.gtk_Close( widget: PGtkWidget) : Boolean; cdecl;
begin
writeln('--> in gtk_close');
FUserChoice := user_close;
end;
//----------------------------------------------------------------------------
constructor TCustomDialog.Create (AOwner : TComponent);
begin
// the TCustomDialog should not create the file_selection
inherited Create(AOwner);
End;
//----------------------------------------------------------------------------
destructor TCustomDialog.destroy;
begin
inherited Destroy;
End;
//----------------------------------------------------------------------------
constructor TOpenFileDialog.Create (AOwner : TComponent);
begin
inherited Create(AOwner);
gtk_create;
end;
//----------------------------------------------------------------------------
destructor TOpenFileDialog.destroy;
begin
gtk_destroy;
inherited Destroy;
end;
//----------------------------------------------------------------------------
Function TOpenFileDialog.Execute : boolean;
begin
if not (GTK_IS_FILE_SELECTION( FComponent)) then gtk_create;
if FTitle '' then
begin
gtk_window_set_title( @((PGtkFileSelection( FComponent))^.Window),
PChar(FTitle));
end;
if FFileName '' then
begin
gtk_file_selection_set_filename( PGtkFileSelection( FComponent),
PChar(FFileName));
end;
if FFilter '' then
begin
gtk_file_selection_complete( PGtkFileSelection( FComponent),
PChar(FFilter));
end;
FUserChoice := user_thinking;
writeln('--> about to file_sel_show');
Show;
repeat
gtk_main_iteration;
until FUserChoice user_thinking;
writeln('--> about to file_sel_hide');
if (FUserChoice user_close) then Hide;
Execute := (FUserChoice = user_ok);
if Execute then
begin
FFileName := gtk_file_selection_get_filename( PGtkFileSelection(
FComponent));
end;
end;
//----------------------------------------------------------------------------
Procedure TOpenFileDialog.gtk_create;
begin
FComponent := gtk_file_selection_new( PChar( FTitle));
gtk_window_set_modal( @((PGtkFileSelection( FComponent))^.Window),
True);gtk_signal_connect_object( gtk_object(
(PGtkFileSelection(FComponent))^.ok_button),
'clicked',
gtk_signal_func( @gtk_ok),
gtk_object( self));gtk_signal_connect_object( gtk_object(
(PGtkFileSelection(FComponent))^.cancel_button),
'clicked',
gtk_signal_func( @gtk_cancel),
gtk_object( self));gtk_signal_connect_object( gtk_object( FComponent), 'destroy',
gtk_signal_func( @gtk_close),
gtk_object( self));end;
//----------------------------------------------------------------------------
Procedure TOpenFileDialog.gtk_destroy;
begin
if (GTK_IS_FILE_SELECTION( FComponent)) then
begin
writeln('--> destroying file_selection');
gtk_signal_handlers_destroy( gtk_object(
(PGtkFileSelection(FComponent))^.ok_button));
gtk_signal_handlers_destroy( gtk_object(
(PGtkFileSelection(FComponent))^.cancel_button));
gtk_signal_handlers_destroy( gtk_object( FComponent));
gtk_widget_destroy( PGtkWidget( FComponent));
end;
end;
{function TCustomDialog.GetFileName : String;
Begin
// this is buggy because you don't know if the widget is destroyed !!
FFileName := gtk_file_selection_get_filename( PGtkFileSelection(
FComponent));
GetFileName := FFileName;
End;}
//----------------------------------------------------------------------------
procedure ShowMessage( const msg: AnsiString );
var dlg: PGtkWidget;
btn: PGtkWidget;
lab: PGtkWidget;
function gtk_btn_ok( widget: PGtkWidget) : Boolean; cdecl;
begin
writeln('--> in gtk_btn_ok');
btn_ok := true;
end;
begin
// this fu* shit is absolutely trivial in Gnome
dlg := gtk_dialog_new;
btn := gtk_button_new_with_label('Ok');
lab := gtk_label_new( PChar(msg));
gtk_box_pack_start( PGtkBox( PGtkDialog( dlg)^.action_area), btn, True,
True, 0);
gtk_box_pack_start( PGtkBox( PGtkDialog( dlg)^.vbox), lab, True, True,
0);
gtk_signal_connect_object( gtk_object( btn),
'clicked',
gtk_signal_func( @gtk_btn_ok),
gtk_object( btn));
gtk_signal_connect_object( gtk_object( dlg),
'destroy',
gtk_signal_func( @gtk_btn_ok),
gtk_object( dlg));
btn_ok := false;
gtk_widget_show( btn);
gtk_widget_show( lab);
gtk_widget_show( dlg);
repeat
gtk_main_iteration;
until btn_ok;
if GTK_IS_DIALOG( dlg) then
begin
gtk_widget_hide( dlg);
gtk_signal_handlers_destroy( gtk_object( btn));
gtk_widget_destroy( dlg);
end;
end;
end.