(***********************************************************************
   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 RadioButtonsExample;
{$MODE OBJFPC}
Uses GLib,GDK,GTK,GTKpas;

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

Var Kit       : CMain;
    Window    : CWindow;
    Button    : CButton;
    RButton   : CRadioButton;
    Box1      : CBox;
    Box2      : CBox;
    Separator : CSeparator;

Function CRadioButtonsWin.DeleteEventImpl(aEvent:PGdkEventAny):Gint;
Begin
  inherited DeleteEventImpl(aEvent);
  DeleteEventImpl := 0;
End;
Procedure CRadioButtonsWin.Destroy_;
Begin
  inherited Destroy_;
  Kit.Quit;
End;
Function CRadioButtonsWin.OnQuitButtonClicked(Sender:CButton;Data:GPointer):GBoolean;
Begin
  Window.Destroy_;
End;


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

  Window := CRadioButtonsWin.Create(GTK_WINDOW_TOPLEVEL);
  Window.BorderWidth := 0;
  Window.Title := 'radio buttons';

  Box1 := CVBox.Create(False,0);
  Window.Add(Box1);
  Box1.Show;

  Box2 := CVBox.Create(False,10);
  Box2.BorderWidth := 10;
  Box1.Add(Box2);
  Box2.Show;

  RButton := CRadioButton.Create(PGSList(Nil),'button1');
  Box2.PackStart(RButton,True,True,0);
  RButton.Show;

  RButton := CRadioButton.Create(RButton.Group,'button2');
  RButton.Active := True;
  Box2.PackStart(RButton,True,True,0);
  RButton.Show;

  RButton := CRadioButton.Create(RButton,'button3');
  Box2.PackStart(RButton,True,True,0);
  RButton.Show;

  Separator := CHSeparator.Create;
  Box1.PackStart(Separator,False,True,0);
  Separator.Show;

  Box2 := CVBox.Create(False,10);
  Box2.BorderWidth := 10;
  Box1.PackStart(Box2,False,True,0);
  Box2.Show;

  Button := CButton.Create('close');
  Button.OnClicked := @CRadioButtonsWin(Window).OnQuitButtonClicked;
  Box2.PackStart(Button,True,True,0);
  GTK_WIDGET_SET_FLAGS(PGtkWidget(Button.GtkObject),GTK_CAN_DEFAULT);
  Button.GrabDefault;
  Button.Show;

  Window.Show;

  Kit.Run;
End.

