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

{$LINKLIB glib}
{$LINKLIB gdk}
{$LINKLIB gtk-1.2}
 
Type CLabelWin = Class(CWindow)
                Function DeleteEventImpl(aEvent:PGdkEventAny):Gint; virtual; override;
                Procedure Destroy_; virtual; override;
              End;

Var Kit       : CMain;
    Window    : CWindow;
    VBox      : CBox;
    HBox      : CBox;
    Frame     : CFrame;
    TheLabel  : CLabel;

Function CLabelWin.DeleteEventImpl(aEvent:PGdkEventAny):Gint;
Begin
  inherited DeleteEventImpl(aEvent);
  DeleteEventImpl := 0;
End;
Procedure CLabelWin.Destroy_;
Begin
  inherited Destroy_;
  Kit.Quit;
End;

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

  Window := CLabelWin.Create(GTK_WINDOW_TOPLEVEL);
  Window.Title := 'Label';
  Window.BorderWidth := 5;

  VBox := CVBox.Create(False,5);
  HBox := CHBox.Create(False,5);
  Window.Add(HBox);
  HBox.PackStart(VBox,False,False,0);

  Frame := CFrame.Create('Normal Label');
  TheLabel := CLabel.Create('This is a Normal label');
  Frame.Add(TheLabel);
  VBox.PackStart(Frame, FALSE, FALSE, 0);
  
  Frame := CFrame.Create('Multi-line Label');
  TheLabel := CLabel.Create('This is a Multi-line label.'^J'Second line'^J +
                            'Third line');
  Frame.Add(TheLabel);
  VBox.PackStart(Frame, FALSE, FALSE, 0);
  
  Frame := CFrame.Create('Left Justified Label');
  TheLabel := CLabel.Create('This is a Left-Justified'^J +
			    'Multi-line label.'^J'Third      line');
  TheLabel.Justify := GTK_JUSTIFY_LEFT;
  Frame.Add(TheLabel);
  VBox.PackStart(Frame, FALSE, FALSE, 0);
  
  Frame := CFrame.Create('Right Justified Label');
  TheLabel := CLabel.Create('This is a Right-Justified'^J'Multi-line label.'^J +
			 'Fourth line, (j/k)');
  TheLabel.Justify := GTK_JUSTIFY_RIGHT;
  Frame.Add(TheLabel);
  VBox.PackStart(Frame, FALSE, FALSE, 0);

  VBox := CVBox.Create(FALSE, 5);
  HBox.PackStart(VBox, FALSE, FALSE, 0);
  Frame := CFrame.Create('Line wrapped label');
  TheLabel := CLabel.Create('This is an example of a line-wrapped label.  It ' +
                            'should not be taking up the entire             ' + { big space to test spacing }
			    'width allocated to it, but automatically ' +
			    'wraps the words to fit.  ' +
			    'The time has come, for all good men, to come to ' +
			    'the aid of their party.  ' +
			    'The sixth sheik''s six sheep''s sick.'^J +
			    '     It supports multiple paragraphs correctly, ' +
			    'and  correctly   adds '+
			    'many          extra  spaces. ');
  TheLabel.LineWrap := True;
  Frame.Add(TheLabel);
  VBox.PackStart(Frame, FALSE, FALSE, 0);
  
  Frame := CFrame.Create('Filled, wrapped label');
  TheLabel := CLabel.Create('This is an example of a line-wrapped, filled label.  ' +
			    'It should be taking '+
			    'up the entire              width allocated to it.  ' +
			    'Here is a sentence to prove '+
			    'my point.  Here is another sentence. '+
			    'Here comes the sun, do de do de do.'^J +
			    '    This is a new paragraph.'^J+
			    '    This is another newer, longer, better ' +
			    'paragraph.  It is coming to an end, '+
			    'unfortunately.');
  TheLabel.Justify := GTK_JUSTIFY_FILL;
  TheLabel.LineWrap := True;
  Frame.Add(TheLabel);
  VBox.PackStart(Frame, FALSE, FALSE, 0);
  
  Frame := CFrame.Create('Underlined label');
  TheLabel := CLabel.Create('This label is underlined!'^J +
			    'This one is underlined in quite a funky fashion');
  TheLabel.Justify := GTK_JUSTIFY_LEFT;
  TheLabel.Pattern := '_________________________ _ _________ _ ______     __ _______ ___';
  Frame.Add(TheLabel);
  VBox.PackStart(Frame, FALSE, FALSE, 0);
  
  Window.ShowAll;

  Kit.Run;
End.

