* Major restructuring and simplifications

This commit is contained in:
sg 1999-12-30 21:03:25 +00:00
parent ebab323aef
commit 83856ede6a

View File

@ -1,22 +1,15 @@
{
$Id$
$Id$
GTK (demo) implementation for shedit
Copyright (C) 1999 Sebastian Guenther (sguenther@gmx.de)
GTK (demo) implementation for shedit
Copyright (C) 1999 Sebastian Guenther (sg@freepascal.org)
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.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
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; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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.
}
{$MODE objfpc}
@ -28,73 +21,52 @@ uses
Doc_text, shedit, sh_pas, sh_xml,
GDK, GTK, GtkSHEdit;
type
TGtkSHTextEdit = class(TGtkSHEdit)
public
constructor Create(ADoc: TTextDoc);
end;
TGtkSHPasEdit = class(TGtkSHEdit)
public
constructor Create(ADoc: TTextDoc);
end;
TGtkSHXMLEdit = class(TGtkSHEdit)
public
constructor Create(ADoc: TTextDoc);
end;
constructor TGtkSHTextEdit.Create(ADoc: TTextDoc);
var
e: TSHTextEdit;
function CreateTextEditWidget(ADoc: TTextDoc): TGtkSHWidget;
begin
inherited Create;
e := TSHTextEdit.Create(ADoc, Self);
SetEdit(e);
Result := TGtkSHWidget.Create(ADoc, TSHTextEdit);
end;
constructor TGtkSHPasEdit.Create(ADoc: TTextDoc);
function CreatePasEditWidget(ADoc: TTextDoc): TGtkSHWidget;
var
e: TSHPasEdit;
begin
inherited Create;
e := TSHPasEdit.Create(ADoc, Self);
SetEdit(e);
Result := TGtkSHWidget.Create(ADoc, TSHPasEdit);
e := Result.Edit as TSHPasEdit;
e.shSymbol := AddSHStyle('Symbol', colBrown, colDefault, fsNormal);
e.shKeyword := AddSHStyle('Keyword', colBlack, colDefault, fsBold);
e.shComment := AddSHStyle('Comment', colDarkCyan, colDefault, fsItalics);
e.shDirective := AddSHStyle('Directive', colRed, colDefault, fsItalics);
e.shNumbers := AddSHStyle('Numbers', colDarkMagenta, colDefault, fsNormal);
e.shCharacters := AddSHStyle('Characters', colDarkBlue, colDefault, fsNormal);
e.shStrings := AddSHStyle('Strings', colBlue, colDefault, fsNormal);
e.shAssembler := AddSHStyle('Assembler', colDarkGreen, colDefault, fsNormal);
e.shSymbol := Result.AddSHStyle('Symbol', colBrown, colDefault, fsNormal);
e.shKeyword := Result.AddSHStyle('Keyword', colBlack, colDefault, fsBold);
e.shComment := Result.AddSHStyle('Comment', colDarkCyan, colDefault, fsItalics);
e.shDirective := Result.AddSHStyle('Directive', colRed, colDefault, fsItalics);
e.shNumbers := Result.AddSHStyle('Numbers', colDarkMagenta, colDefault, fsNormal);
e.shCharacters := Result.AddSHStyle('Characters', colDarkBlue, colDefault, fsNormal);
e.shStrings := Result.AddSHStyle('Strings', colBlue, colDefault, fsNormal);
e.shAssembler := Result.AddSHStyle('Assembler', colDarkGreen, colDefault, fsNormal);
end;
constructor TGtkSHXMLEdit.Create(ADoc: TTextDoc);
function CreateXMLEditWidget(ADoc: TTextDoc): TGtkSHWidget;
var
e: TSHXMLEdit;
begin
inherited Create;
e := TSHXMLEdit.Create(ADoc, Self);
SetEdit(e);
Result := TGtkSHWidget.Create(ADoc, TSHXMLEdit);
e := Result.Edit as TSHXMLEdit;
e.shTag := AddSHStyle('Tag', colBlack, colDefault, fsBold);
e.shTagName := AddSHStyle('Tag Name', colBlack, colDefault, fsBold);
e.shDefTagName := AddSHStyle('Definition Tag Name', colDarkGreen, colDefault, fsBold);
e.shArgName := AddSHStyle('Argument Name', colBrown, colDefault, fsNormal);
e.shString := AddSHStyle('String', colBlue, colDefault, fsNormal);
e.shReference := AddSHStyle('Reference', colDarkMagenta, colDefault, fsNormal);
e.shInvalid := AddSHStyle('Invalid', colRed, colDefault, fsNormal);
e.shComment := AddSHStyle('Comment', colDarkCyan, colDefault, fsItalics);
e.shCDATA := AddSHStyle('CDATA', colDarkGreen, colDefault, fsNormal);
e.shTag := Result.AddSHStyle('Tag', colBlack, colDefault, fsBold);
e.shTagName := Result.AddSHStyle('Tag Name', colBlack, colDefault, fsBold);
e.shDefTagName := Result.AddSHStyle('Definition Tag Name', colDarkGreen, colDefault, fsBold);
e.shArgName := Result.AddSHStyle('Argument Name', colBrown, colDefault, fsNormal);
e.shString := Result.AddSHStyle('String', colBlue, colDefault, fsNormal);
e.shReference := Result.AddSHStyle('Reference', colDarkMagenta, colDefault, fsNormal);
e.shInvalid := Result.AddSHStyle('Invalid', colRed, colDefault, fsNormal);
e.shComment := Result.AddSHStyle('Comment', colDarkCyan, colDefault, fsItalics);
e.shCDATA := Result.AddSHStyle('CDATA', colDarkGreen, colDefault, fsNormal);
end;
var
MainWindow, Notebook: PGtkWidget;
Pages: array[0..2] of TGtkSHEdit;
PasDoc, XMLDoc: TTextDoc;
Pages: array[0..2] of TGtkSHWidget;
PasDoc, XMLDoc, TxtDoc: TTextDoc;
procedure OnMainWindowDestroyed; cdecl;
begin
@ -112,15 +84,14 @@ begin
gtk_signal_connect(PGtkObject(MainWindow), 'destroy', GTK_SIGNAL_FUNC(@OnMainWindowDestroyed), nil);
// Set up documents
PasDoc := TTextDoc.Create;
PasDoc.LoadFromFile('gtkdemo.pp');
XMLDoc := TTextDoc.Create;
XMLDoc.LoadFromFile('gtkdemo.pp');
PasDoc := TTextDoc.Create; PasDoc.LoadFromFile('gtkdemo.pp');
XMLDoc := TTextDoc.Create; XMLDoc.LoadFromFile('simple.xml');
TxtDoc := TTextDoc.Create; TxtDoc.LoadFromFile('README');
// Create notebook pages (editor widgets)
Pages[0] := TGtkSHPasEdit.Create(PasDoc);
Pages[1] := TGtkSHXMLEdit.Create(XMLDoc);
Pages[2] := TGtkSHTextEdit.Create(PasDoc);
Pages[0] := CreatePasEditWidget (PasDoc);
Pages[1] := CreateXMLEditWidget (XMLDoc);
Pages[2] := CreateTextEditWidget(TxtDoc);
// Create notebook
Notebook := gtk_notebook_new;
@ -133,9 +104,14 @@ begin
Pages[0].SetFocus;
gtk_main;
end.
{
$Log$
Revision 1.6 1999-12-22 22:28:08 peter
Revision 1.7 1999-12-30 21:03:25 sg
* Major restructuring and simplifications
Revision 1.6 1999/12/22 22:28:08 peter
* updates for cursor setting
* button press event works