* changes so redrawing and walking with the cursor finally works

correct
This commit is contained in:
peter 1999-12-08 01:03:15 +00:00
parent f7b72f4a8f
commit 6c4b0b264b
3 changed files with 88 additions and 72 deletions

View File

@ -130,11 +130,16 @@ begin
gtk_container_add(PGtkContainer(MainWindow), Notebook); gtk_container_add(PGtkContainer(MainWindow), Notebook);
gtk_widget_show(Notebook); gtk_widget_show(Notebook);
gtk_widget_show(MainWindow); gtk_widget_show(MainWindow);
Pages[0].SetFocus;
gtk_main; gtk_main;
end. end.
{ {
$Log$ $Log$
Revision 1.4 1999-11-15 21:47:36 peter Revision 1.5 1999-12-08 01:03:15 peter
* changes so redrawing and walking with the cursor finally works
correct
Revision 1.4 1999/11/15 21:47:36 peter
* first working keypress things * first working keypress things
Revision 1.3 1999/11/14 21:32:55 peter Revision 1.3 1999/11/14 21:32:55 peter

View File

@ -130,14 +130,14 @@ procedure TGtkSHEdit_Expose(GtkWidget: PGtkWidget; event: PGdkEventExpose; edit:
var var
x1, y1, x2, y2: Integer; x1, y1, x2, y2: Integer;
begin begin
x1 := event^.area.x div edit.CharW; x1:=event^.area.x;
if x1>0 then if x1>0 then
dec(x1); dec(x1,edit.LeftIndent);
x2:=x1+event^.area.width - 1;
x1:=x1 div edit.CharW;
x2:=(x2+edit.CharW-1) div edit.CharW;
y1 := event^.area.y div edit.CharH; y1 := event^.area.y div edit.CharH;
if y1>0 then y2 := (event^.area.y + event^.area.height - 1) div edit.CharH;
dec(y1);
x2 := (event^.area.x + event^.area.width - 1) div edit.CharW+1;
y2 := (event^.area.y + event^.area.height - 1) div edit.CharH+1;
WriteLn(Format('Expose(%d/%d - %d/%d) for %s', [x1, y1, x2, y2, edit.ClassName])); WriteLn(Format('Expose(%d/%d - %d/%d) for %s', [x1, y1, x2, y2, edit.ClassName]));
edit.GdkWnd := edit.PaintBox^.window; edit.GdkWnd := edit.PaintBox^.window;
@ -254,15 +254,15 @@ begin
PGtkObject(PaintBox)^.flags := PGtkObject(PaintBox)^.flags or GTK_CAN_FOCUS; PGtkObject(PaintBox)^.flags := PGtkObject(PaintBox)^.flags or GTK_CAN_FOCUS;
gtk_signal_connect_after(PGtkObject(PaintBox), 'expose-event', gtk_signal_connect(PGtkObject(PaintBox), 'expose-event',
GTK_SIGNAL_FUNC(@TGtkSHEdit_Expose), self); GTK_SIGNAL_FUNC(@TGtkSHEdit_Expose), self);
gtk_signal_connect_after(PGtkObject(PaintBox), 'key-press-event', gtk_signal_connect_after(PGtkObject(PaintBox), 'key-press-event',
GTK_SIGNAL_FUNC(@TGtkSHEdit_KeyPressed), self); GTK_SIGNAL_FUNC(@TGtkSHEdit_KeyPressed), self);
gtk_signal_connect(PGtkObject(PaintBox), 'button-press-event', gtk_signal_connect_after(PGtkObject(PaintBox), 'button-press-event',
GTK_SIGNAL_FUNC(@TGtkSHEdit_KeyPressed), self); GTK_SIGNAL_FUNC(@TGtkSHEdit_KeyPressed), self);
gtk_signal_connect(PGtkObject(PaintBox), 'focus-in-event', gtk_signal_connect_after(PGtkObject(PaintBox), 'focus-in-event',
GTK_SIGNAL_FUNC(@TGtkSHEdit_FocusInEvent), self); GTK_SIGNAL_FUNC(@TGtkSHEdit_FocusInEvent), self);
gtk_signal_connect(PGtkObject(PaintBox), 'focus-out-event', gtk_signal_connect_after(PGtkObject(PaintBox), 'focus-out-event',
GTK_SIGNAL_FUNC(@TGtkSHEdit_FocusOutEvent), self); GTK_SIGNAL_FUNC(@TGtkSHEdit_FocusOutEvent), self);
gtk_widget_show(Widget); gtk_widget_show(Widget);
end; end;
@ -348,11 +348,11 @@ var
procedure doerase; procedure doerase;
begin begin
if rx2>rx1 then if rx2>x1 then
begin begin
SetGCColor(CurColor); SetGCColor(CurColor);
gdk_draw_rectangle(PGdkDrawable(GdkWnd), GC, 1, gdk_draw_rectangle(PGdkDrawable(GdkWnd), GC, 1,
x1 * CharW + LeftIndent, y * CharH, (rx2 - rx1 + 1) * CharW, CharH); rx1 * CharW + LeftIndent, y * CharH, (rx2 - rx1 + 1) * CharW, CharH);
rx1:=rx2; rx1:=rx2;
end; end;
end; end;
@ -363,7 +363,7 @@ var
NewColor: LongWord; NewColor: LongWord;
hs : pchar; hs : pchar;
begin begin
{WriteLn(Format('DrawTextLine(%d) for %s ', [y, ClassName]));} // WriteLn(Format('DrawTextLine(%d) for %s ', [y, ClassName]));
// Erase the (potentially multi-coloured) background // Erase the (potentially multi-coloured) background
@ -447,9 +447,6 @@ begin
end; end;
end; end;
until false; until false;
{ Also draw the cursor }
{ if y=edit.CursorY then
DrawCursor; }
end; end;
@ -462,19 +459,10 @@ end;
procedure TGtkSHEdit.ShowCursor(x, y: Integer); procedure TGtkSHEdit.ShowCursor(x, y: Integer);
var var
r : TGdkRectangle; r : TGdkRectangle;
px,py : integer;
begin begin
writeln('Showcursor ',x,',',y); writeln('Showcursor ',x,',',y);
px := x * CharW + LeftIndent;
py := y * CharH;
SetGCColor(colBlack); SetGCColor(colBlack);
gdk_draw_rectangle(PGdkDrawable(GdkWnd), GC, 1, px, py, 2, CharH); gdk_draw_rectangle(PGdkDrawable(GdkWnd), GC, 1, x*CharW + LeftIndent, y*CharH, 2, CharH);
{ r.x:=x * CharW;
r.y:=y * CharH;
r.Width:=CharW;
r.Height:=CharH;
gtk_widget_draw(PGtkWidget(PaintBox), @r); }
end; end;
@ -519,7 +507,11 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.3 1999-12-08 00:42:54 sg Revision 1.4 1999-12-08 01:03:15 peter
* changes so redrawing and walking with the cursor finally works
correct
Revision 1.3 1999/12/08 00:42:54 sg
* The cursor should be displayed correctly now * The cursor should be displayed correctly now
Revision 1.2 1999/12/06 21:27:27 peter Revision 1.2 1999/12/06 21:27:27 peter

View File

@ -53,93 +53,108 @@ begin
end; end;
procedure TSHTextEdit.CursorUp; procedure TSHTextEdit.CursorUp;
var
l1, l2: Integer;
begin begin
if FCursorY = 0 then if FCursorY = 0 then
FCursorX := 0 FCursorX := 0
else begin else
l1 := FDoc.LineLen[FCursorY];
Dec(FCursorY); Dec(FCursorY);
l2 := FDoc.LineLen[FCursorY]; if FCursorY<Renderer.VertPos then
if FCursorX > l2 then Renderer.VertPos := Renderer.VertPos - 1;
FCursorX := l2;
end;
end; end;
procedure TSHTextEdit.CursorDown; procedure TSHTextEdit.CursorDown;
var
l1, l2: Integer;
begin begin
if FCursorY < FDoc.LineCount - 1 then begin if FCursorY < FDoc.LineCount - 1 then
l1 := FDoc.LineLen[FCursorY]; Inc(FCursorY)
Inc(FCursorY); else
l2 := FDoc.LineLen[FCursorY]; FCursorX := FDoc.LineLen[FCursorY];
if FCursorX > l2 then if FCursorY>Renderer.VertPos+Renderer.PageHeight then
FCursorX := l2; Renderer.VertPos := Renderer.VertPos + 1;
end else
FCursorX := FDoc.LineLen[FCursorY];
end; end;
procedure TSHTextEdit.CursorLeft; procedure TSHTextEdit.CursorLeft;
begin begin
if FCursorX > 0 then if FCursorX > 0 then
Dec(FCursorX) Dec(FCursorX)
else if FCursorY > 0 then begin else
Dec(FCursorY); if FCursorY > 0 then
FCursorX := FDoc.LineLen[FCursorY]; begin
end; Dec(FCursorY);
FCursorX := FDoc.LineLen[FCursorY];
if FCursorY<Renderer.VertPos then
Renderer.VertPos := Renderer.VertPos - 1;
end;
end; end;
procedure TSHTextEdit.CursorRight; procedure TSHTextEdit.CursorRight;
begin begin
Inc(FCursorX); Inc(FCursorX);
if FCursorX > FDoc.LineLen[FCursorY] then if FCursorX > FDoc.LineLen[FCursorY] then
if FCursorY < FDoc.LineCount - 1 then begin if FCursorY < FDoc.LineCount - 1 then
Inc(FCursorY); begin
FCursorX := 0; Inc(FCursorY);
end else FCursorX := 0;
FCursorX := FDoc.LineLen[FCursorY]; if FCursorY>Renderer.VertPos+Renderer.PageHeight then
Renderer.VertPos := Renderer.VertPos + 1;
end
else
FCursorX := FDoc.LineLen[FCursorY];
end; end;
procedure TSHTextEdit.CursorHome; procedure TSHTextEdit.CursorHome;
begin begin
FCursorX := 0; FCursorX := 0;
end; end;
procedure TSHTextEdit.CursorEnd; procedure TSHTextEdit.CursorEnd;
begin begin
FCursorX := FDoc.LineLen[FCursorY]; FCursorX := FDoc.LineLen[FCursorY];
end; end;
procedure TSHTextEdit.CursorPageUp; procedure TSHTextEdit.CursorPageUp;
begin begin
if FCursorY = 0 then if FCursorY = 0 then
FCursorX := 0 FCursorX := 0
else begin else
Dec(FCursorY, Renderer.PageHeight); begin
if FCursorY < 0 then FCursorY := 0; Dec(FCursorY, Renderer.PageHeight);
if FCursorX > FDoc.LineLen[FCursorY] then if FCursorY < 0 then
FCursorX := FDoc.LineLen[FCursorY]; begin
end; FCursorY := 0;
Renderer.VertPos := Renderer.VertPos - Renderer.PageHeight; Renderer.VertPos := 0;
end
else
Renderer.VertPos := Renderer.VertPos - Renderer.PageHeight;
end;
end; end;
procedure TSHTextEdit.CursorPageDown; procedure TSHTextEdit.CursorPageDown;
begin begin
if FCursorY = FDoc.LineCount - 1 then if FCursorY = FDoc.LineCount - 1 then
FCursorX := FDoc.LineLen[FCursorY] FCursorX := FDoc.LineLen[FCursorY]
else begin else
Inc(FCursorY, Renderer.PageHeight); begin
if FCursorY >= FDoc.LineCount then Inc(FCursorY, Renderer.PageHeight);
FCursorY := FDoc.LineCount - 1; if FCursorY >= FDoc.LineCount then
if FCursorX > FDoc.LineLen[FCursorY] then begin
FCursorX := FDoc.LineLen[FCursorY]; FCursorY := FDoc.LineCount - Renderer.PageHeight;
end; if FCursorY < 0 then
Renderer.VertPos := Renderer.VertPos + Renderer.PageHeight; FCursorY:=0;
Renderer.VertPos := FCursorY;
end
else
Renderer.VertPos := Renderer.VertPos + Renderer.PageHeight;
end;
end; end;
procedure TSHTextEdit.EditDelLeft; procedure TSHTextEdit.EditDelLeft;
var var
s: String; s: String;
@ -569,7 +584,11 @@ end;
{ {
$Log$ $Log$
Revision 1.2 1999-11-15 21:47:36 peter Revision 1.3 1999-12-08 01:03:15 peter
* changes so redrawing and walking with the cursor finally works
correct
Revision 1.2 1999/11/15 21:47:36 peter
* first working keypress things * first working keypress things
Revision 1.1 1999/10/29 15:59:04 peter Revision 1.1 1999/10/29 15:59:04 peter