(***********************************************************************
   This file is part of GTKpas, an OOP wrapper for GTK+ written
   for Pascal.

   Copyright (C) 2000 by Johann Glaser <Johann.Glaser@gmx.at>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program in the file COPYING; if not, write to the 
   Free Software Foundation, Inc., 
   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
***********************************************************************)
Program HelloWorld;
{$MODE OBJFPC}
Uses GLib,GDK,GTK,GTKpas;

Type CHello = Class(CWindow)
                Function DeleteEventImpl(aEvent:PGdkEventAny):Gint; virtual; override;
                Procedure Destroy_; virtual; override;
                Function OnHelloButtonClicked(Sender:CButton;Data:GPointer):GBoolean;
              End;

Var Kit    : CMain;
    Window : CWindow;
    Button : CButton;

Function CHello.DeleteEventImpl(aEvent:PGdkEventAny):Gint;
Begin
  inherited DeleteEventImpl(aEvent);
  WriteLn('delete event occoured');
  DeleteEventImpl := 1;
End;
Procedure CHello.Destroy_;
Begin
  inherited Destroy_;
  WriteLn('Destroy_');
  Kit.Quit;
End;
Function  CHello.OnHelloButtonClicked(Sender:CButton;Data:GPointer):GBoolean;
Begin
  WriteLn('Hello World');
  OnHelloButtonClicked := True;
  Destroy_;
End;

Begin
  Kit := CMain.Create(@ArgC,@ArgV,False);

  Window := CHello.Create(GTK_WINDOW_TOPLEVEL);
  Window.BorderWidth := 10;
  Window.Title := 'Hello World Window';

  Button := CButton.Create('Hello World');
  Button.OnClicked := @CHello(Window).OnHelloButtonClicked;

  Window.Add(Button);
  Button.Show;

  Window.Show;

  Kit.Run;
End.

