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

Type CArrowWin = Class(CWindow)
                Function DeleteEventImpl(aEvent:PGdkEventAny):Gint; virtual; override;
                Procedure Destroy_; virtual; override;
              End;

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

Function CArrowWin.DeleteEventImpl(aEvent:PGdkEventAny):Gint;
Begin
  inherited DeleteEventImpl(aEvent);
  DeleteEventImpl := 0;
End;
(* It's a good idea to do this for all windows. *)
Procedure CArrowWin.Destroy_;
Begin
  inherited Destroy_;
  Kit.Quit;
End;

(* Create an Arrow widget with the specified parameters
 * and pack it into a button *)
Function CreateArrowButton(ArrowType:TGtkArrowType;ShadowType:TGtkShadowType):CButton;
Var Button : CButton;
    Arrow  : CArrow;
Begin
  Button := CButton.Create;
  Arrow  := CArrow.Create(ArrowType,ShadowType);

  Button.Add(Arrow);

  Arrow.Show;
  Button.Show;

  CreateArrowButton := Button;
End;

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

  Window := CArrowWin.Create(GTK_WINDOW_TOPLEVEL);
  Window.Title := 'Arrow Buttons';
  (* Sets the border width of the window. *)
  Window.BorderWidth := 10;

  (* Create a box to hold the arrows/buttons *)
  Box := CHBox.Create(False,0);
  Box.BorderWidth := 2;
  Window.Add(Box);
  (* Pack and show all our widgets *)
  Box.Show;

  Button := CreateArrowButton(GTK_ARROW_UP, GTK_SHADOW_IN);
  Box.PackStart(Button, FALSE, FALSE, 3);

  Button := CreateArrowButton(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
  Box.PackStart(Button, FALSE, FALSE, 3);
  
  Button := CreateArrowButton(GTK_ARROW_LEFT, GTK_SHADOW_ETCHED_IN);
  Box.PackStart(Button, FALSE, FALSE, 3);
  
  Button := CreateArrowButton(GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_OUT);
  Box.PackStart(Button, FALSE, FALSE, 3);
  
  Window.Show;

  (* Rest in gtk_main and wait for the fun to begin! *)
  Kit.Run;
End.

