[lazarus] TCanvas

Sebastian Günther sguenther at gmx.de
Wed Jul 21 12:46:15 EDT 1999


Payne Thomas E CNIN wrote:

> I was specifically looking at (PGdkEventExpose)Event^.area.height in the
> expose_event function
> & (PGdkEventMotion)Event^.state in motion_notify_event
> 
> I need some help beyond this point!!!


This is was KCL is currently doing to work around this compiler bug:

procedure TPaintBox_Expose(GtkWidget: PGtkWidget; event:
PGdkEventExpose;
  PaintBox: TPaintBox); cdecl;
type
  TWordRect = packed record
    x, y, w, h: Word;
  end;
var
  rect: TRect;
  wrect: TWordRect;
  Canvas: TCanvas;
begin
  if (GtkWidget <> nil) and Assigned(PaintBox.Draw) and
    (PaintBox.FCreationState = wcsCreationDone) and
    (PaintBox.BlockDrawingCounter = 0) then begin

    {*** The following should work, but it doesn't (y and height get
wrong)
         - bug in GTK unit? /sg
    rect.Left := event^.area.x;
    rect.Top := event^.area.y;
    rect.Right := rect.Left + event^.area.width;
    rect.Bottom := rect.Top + event^.area.height;}

    Move(PByteArray(event)^[10], wrect, 8);
    rect.Left := wrect.x;
    rect.Top := wrect.y;
    rect.Right := rect.Left + wrect.w;
    rect.Bottom := rect.Top + wrect.h;

    Canvas := TGdkExposeCanvas.Create(PaintBox);
    // WriteLn('Clipping to ', rect.Left, '/', rect.Top, ' - ',
rect.Right, '/', rect.Bottom);
    gdk_gc_set_clip_rectangle(Canvas.priv.gc,
PGdkRectangle(@PByteArray(event)^[10]));
    PaintBox.Draw(PaintBox, Canvas, rect);
    Canvas.Free;
  end;
end;



- Sebastian






More information about the Lazarus mailing list