parent
dac466318f
commit
2d6871ffc5
|
|
@ -1475,6 +1475,7 @@ type tsgtkapi = class(tgtkapis)
|
|||
y := gtk_object_get_data(dc,"viewport.y");
|
||||
pc := gtk_object_get_data(dc,"pen.color");
|
||||
pw := gtk_object_get_data(dc,"pen.width");
|
||||
brc := gtk_object_get_data(dc,"brush.color");
|
||||
if pw>0 then cairo_set_line_width(dc,pw);
|
||||
else cairo_set_line_width(dc,1);
|
||||
if pc=0 then
|
||||
|
|
@ -1491,13 +1492,27 @@ type tsgtkapi = class(tgtkapis)
|
|||
cairo_line_to(dc,r+x,b+y);
|
||||
cairo_line_to(dc,l+x,b+y);
|
||||
cairo_line_to(dc,l+x,t+y);
|
||||
|
||||
if brc=0 then
|
||||
begin
|
||||
cairo_set_source_rgb(dc,0,0,0);
|
||||
end else
|
||||
begin
|
||||
gtk_rgb_color_rgb(brc,rc,gc,bc);
|
||||
cairo_set_source_rgb(dc,rc,gc,bc);
|
||||
end
|
||||
cairo_fill_preserve(dc);
|
||||
if pc=0 then
|
||||
begin
|
||||
cairo_set_source_rgb(dc,0,0,0);
|
||||
end else
|
||||
begin
|
||||
gtk_rgb_color_rgb(pc,rc,gc,bc);
|
||||
cairo_set_source_rgb(dc,rc,gc,bc);
|
||||
end
|
||||
|
||||
cairo_stroke(dc);
|
||||
//return
|
||||
cairo_stroke_preserve(dc);
|
||||
bsh := gtk_object_get_data(dc,"brush.color");
|
||||
gtk_rgb_color_rgb(bsh,rc,gc,bc);
|
||||
cairo_set_source_rgb(dc,rc,gc,bc);
|
||||
cairo_fill(dc);
|
||||
return 1;
|
||||
end
|
||||
Function Ellipse(dc :pointer;l:integer;t:integer;r:integer;b:integer):integer;
|
||||
begin
|
||||
|
|
@ -1517,7 +1532,7 @@ type tsgtkapi = class(tgtkapis)
|
|||
ry := (b-t)/2;
|
||||
cairo_scale(dc,1,ry/rx);
|
||||
cairo_applay_pen_style(dc);
|
||||
cairo_arc(dc, 0, 0, rx, 0, 2 * 3.14);
|
||||
cairo_arc(dc, 0, 0, rx, 0, 2 * pi());
|
||||
if brc=0 then
|
||||
begin
|
||||
cairo_set_source_rgb(dc,0,0,0);
|
||||
|
|
@ -1538,6 +1553,7 @@ type tsgtkapi = class(tgtkapis)
|
|||
cairo_stroke(dc);
|
||||
cairo_scale(dc,1,rx/ry);
|
||||
cairo_translate(dc,0-mx,0-my);
|
||||
return 1;
|
||||
end
|
||||
Function RoundRect(dc :pointer;l:integer;t:integer;r:integer;b:integer;wid:integer;ht:integer):integer;
|
||||
begin
|
||||
|
|
@ -1564,11 +1580,11 @@ type tsgtkapi = class(tgtkapis)
|
|||
cairo_set_source_rgb(dc,rc,gc,bc);
|
||||
end
|
||||
cairo_stroke(dc);//»æÖƱ߿ò
|
||||
return ;
|
||||
return 1;
|
||||
end
|
||||
Function Chord(hdc :pointer;l:integer;t:integer;r:integer;b:integer;wid:integer;ht:integer):integer;
|
||||
begin
|
||||
x := gtk_object_get_data(dc,"viewport.x");
|
||||
x := gtk_object_get_data(dc,"viewport.x");
|
||||
y := gtk_object_get_data(dc,"viewport.y");
|
||||
pc := gtk_object_get_data(dc,"pen.color");
|
||||
pw := gtk_object_get_data(dc,"pen.width");
|
||||
|
|
@ -1782,7 +1798,7 @@ type tsgtkapi = class(tgtkapis)
|
|||
end
|
||||
Function PolyBezier(dc :pointer;points:array of integer;n:integer):integer;
|
||||
begin
|
||||
if length(points)<8 then return 0;
|
||||
if length(points)<4 then return 0;
|
||||
x := gtk_object_get_data(dc,"viewport.x");
|
||||
y := gtk_object_get_data(dc,"viewport.y");
|
||||
pc := gtk_object_get_data(dc,"pen.color");
|
||||
|
|
@ -1798,10 +1814,10 @@ type tsgtkapi = class(tgtkapis)
|
|||
cairo_set_source_rgb(dc,rc,gc,bc);
|
||||
end
|
||||
cairo_applay_pen_style(dc);
|
||||
cairo_move_to(dc,points[0]+x,Points[1]+y);
|
||||
for i := 1 to length(points)-1 step 3 do
|
||||
cairo_move_to(dc,points[0,0]+x,Points[0,1]+y);
|
||||
for i := 1 to length(points)-2 step 3 do
|
||||
begin
|
||||
cairo_curve_to(dc,points[i+0],points[i+1],points[i+2],points[i+3],points[i+4],points[i+5]);
|
||||
cairo_curve_to(dc,points[i,0]+x,points[i,1]+y,points[i+1,0]+x,points[i+1,1]+y,points[i+2,0]+x,points[i+2,1]+y);
|
||||
end
|
||||
cairo_stroke(dc);
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ type tcoolband = class() //
|
|||
return 0;
|
||||
end
|
||||
end
|
||||
fctl;
|
||||
[weakref]fctl;
|
||||
fdragrect;
|
||||
fsizerect;
|
||||
fctlrect;
|
||||
|
|
|
|||
|
|
@ -2575,6 +2575,46 @@ type TcustomCanvas = class(TSLUIBASE)
|
|||
if(ico is class(tcustomicon))and ico.Handle then return _wapi.DrawIcon(FHandle,p[0],p[1],ico.Handle);
|
||||
end
|
||||
end
|
||||
function draw_rect(); //矩形绘制对象
|
||||
begin
|
||||
if HandleAllocated() then requiregdi();
|
||||
return new tshapeRectangle(self(true));
|
||||
end
|
||||
function draw_roundrect();//圆角矩形绘制对象
|
||||
begin
|
||||
if HandleAllocated() then requiregdi();
|
||||
return new tshaperoundrect(self(true));
|
||||
end
|
||||
function draw_frame(); //frame 绘制对象
|
||||
begin
|
||||
if HandleAllocated() then requiregdi();
|
||||
return new tshapeframe(self(true));
|
||||
end
|
||||
function draw_ellipse(); //椭圆绘制对象
|
||||
begin
|
||||
if HandleAllocated() then requiregdi();
|
||||
return new tshapeEllipse(self(true));
|
||||
end
|
||||
function draw_arc(); //arc 绘制
|
||||
begin
|
||||
if HandleAllocated() then requiregdi();
|
||||
return new tshapearc(self(true));
|
||||
end
|
||||
function draw_pie(); //饼 绘制
|
||||
begin
|
||||
if HandleAllocated() then requiregdi();
|
||||
return new tshapepie(self(true));
|
||||
end
|
||||
function draw_chord(); //玄切绘制
|
||||
begin
|
||||
if HandleAllocated() then requiregdi();
|
||||
return new tshapechord(self(true));
|
||||
end
|
||||
function draw_bezier(); //贝塞尔曲线绘制
|
||||
begin
|
||||
if HandleAllocated() then requiregdi();
|
||||
return new tshapeBezier(self(true));
|
||||
end
|
||||
function draw(name_,points,f,m);
|
||||
begin
|
||||
{**
|
||||
|
|
@ -2622,33 +2662,33 @@ type TcustomCanvas = class(TSLUIBASE)
|
|||
if "arc"=_name_1 then
|
||||
begin
|
||||
if len <> 4 then return 0;
|
||||
if not ifnil(f)then SetArcDirection(FHandle,f);
|
||||
if not ifnil(f)then _wapi.SetArcDirection(FHandle,f);
|
||||
ret := _wapi.Arc(FHandle,points[0,0],points[0,1],points[1,0],points[1,1],points[2,0],points[2,1],points[3,0],points[3,1]);
|
||||
end else
|
||||
if(("polygon"=_name_1)or("polyline"=_name_1))then
|
||||
begin
|
||||
if r<2 then return 0;
|
||||
pt := pointtovector(points);
|
||||
//pt := pointtovector(points);
|
||||
if "polygon"=_name_1 then
|
||||
begin
|
||||
if r<3 then return 0;
|
||||
ret := _wapi.Polygon(FHandle,pt,r);
|
||||
ret := _wapi.Polygon(FHandle,points,r);
|
||||
end else
|
||||
ret := _wapi.polyline(FHandle,pt,r);
|
||||
ret := _wapi.polyline(FHandle,points,r);
|
||||
end else
|
||||
if "polypolyline"=_name_1 then
|
||||
begin
|
||||
if ifarray(f)and(sum(f)=length(points))then
|
||||
begin
|
||||
pt := pointtovector(points);
|
||||
ret := _wapi.polypolyline(FHandle,pt,f,m);
|
||||
//pt := pointtovector(points);
|
||||
ret := _wapi.polypolyline(FHandle,points,f,m);
|
||||
end
|
||||
end else
|
||||
if("polybezier"=_name_1)then
|
||||
begin
|
||||
if r<3 then return 0;
|
||||
pt := pointtovector(points);
|
||||
ret := _wapi.PolyBezier(FHandle,pt,r);
|
||||
//pt := pointtovector(points);
|
||||
ret := _wapi.PolyBezier(FHandle,points,r);
|
||||
end
|
||||
return ret;
|
||||
end
|
||||
|
|
@ -2938,6 +2978,232 @@ type TResourcescache=class
|
|||
end
|
||||
end
|
||||
end
|
||||
type tshape = class()
|
||||
function create(dc);
|
||||
begin
|
||||
fcanvas := dc;
|
||||
end
|
||||
function draw();virtual;
|
||||
begin
|
||||
return self(true);
|
||||
end
|
||||
protected
|
||||
[weakref]fcanvas;
|
||||
end
|
||||
type tsepoint = class()
|
||||
function startpoint(p);overload;
|
||||
begin
|
||||
if ifarray(p) and ifnumber(p[0]) and ifnumber(p[1]) then
|
||||
begin
|
||||
fsp := array(p[0],p[1]);
|
||||
end
|
||||
return self(true);
|
||||
end
|
||||
function endpoint(p);overload;
|
||||
begin
|
||||
if ifarray(p) and ifnumber(p[0]) and ifnumber(p[1]) then
|
||||
begin
|
||||
fep := array(p[0],p[1]);
|
||||
end
|
||||
return self(true);
|
||||
end
|
||||
function startpoint(x,y);overload;
|
||||
begin
|
||||
return startpoint(array(x,y));
|
||||
end
|
||||
function endpoint(x,y);overload;
|
||||
begin
|
||||
return endpoint(array(x,y));
|
||||
end
|
||||
function direct(dir);
|
||||
begin
|
||||
fdir := dir;
|
||||
return self(true);
|
||||
end
|
||||
protected
|
||||
fsp;
|
||||
fep;
|
||||
fdir;
|
||||
end
|
||||
type tshaperect = class()
|
||||
function rect(rec);overload;
|
||||
begin
|
||||
if ifarray(rec) and rec[2]>rec[0] and rec[3]>rec[1] then
|
||||
begin
|
||||
frect := array(rec[0],rec[1],rec[2],rec[3]);
|
||||
end
|
||||
return self(true);
|
||||
end
|
||||
function rect(l,t,r,b);overload;
|
||||
begin
|
||||
return rect(array(l,t,r,b));
|
||||
end
|
||||
protected
|
||||
frect;
|
||||
end
|
||||
|
||||
type tshapeEllipse = class(tshape,tshaperect)
|
||||
function create(dc);
|
||||
begin
|
||||
inherited;
|
||||
end
|
||||
function draw();override;
|
||||
begin
|
||||
if fcanvas and fcanvas.HandleAllocated() and frect then
|
||||
begin
|
||||
fcanvas._wapi.Ellipse(fcanvas.handle,frect[0],frect[1],frect[2],frect[3]);
|
||||
end
|
||||
return inherited;
|
||||
end
|
||||
end
|
||||
type tshapeRectangle = class(tshape,tshaperect)
|
||||
function create(dc);
|
||||
begin
|
||||
inherited;
|
||||
froundw := 0;
|
||||
froundh := 0;
|
||||
end
|
||||
function draw();override;
|
||||
begin
|
||||
if fcanvas and fcanvas.HandleAllocated() and frect then
|
||||
begin
|
||||
fcanvas._wapi.Rectangle(fcanvas.handle,frect[0],frect[1],frect[2],frect[3]);
|
||||
end
|
||||
return inherited;
|
||||
end
|
||||
end
|
||||
type tshaperoundrect = class(tshape,tshaperect)
|
||||
function create(dc);
|
||||
begin
|
||||
inherited;
|
||||
end
|
||||
function draw();override;
|
||||
begin
|
||||
if fcanvas and fcanvas.HandleAllocated() and frect then
|
||||
begin
|
||||
fcanvas._wapi.RoundRect(fcanvas.handle,frect[0],frect[1],frect[2],frect[3],froundw,froundh);
|
||||
end
|
||||
return inherited;
|
||||
end
|
||||
function setround(w,h);
|
||||
begin
|
||||
froundw := w;
|
||||
froundh := h;
|
||||
return self(true);
|
||||
end
|
||||
private
|
||||
froundw;
|
||||
froundh;
|
||||
end
|
||||
type tshapeframe = class(tshape,tshaperect)
|
||||
function create(dc);
|
||||
begin
|
||||
inherited;
|
||||
end
|
||||
function draw();override;
|
||||
begin
|
||||
if fcanvas and fcanvas.HandleAllocated() and frect then
|
||||
begin
|
||||
fcanvas._wapi.DrawFrameControl(fcanvas.handle,frect,ftype,fstyle);
|
||||
end
|
||||
return inherited;
|
||||
end
|
||||
function ctltype(fc);
|
||||
begin
|
||||
ftype := fc;
|
||||
return self(true);
|
||||
end
|
||||
function ctlstate(cs);
|
||||
begin
|
||||
fstyle := cs;
|
||||
return self(true);
|
||||
end
|
||||
private
|
||||
ftype;
|
||||
fstyle;
|
||||
end
|
||||
type tshapearc = class(tshape,tshaperect,tsepoint)
|
||||
function create(dc);
|
||||
begin
|
||||
inherited;
|
||||
end
|
||||
function draw();override;
|
||||
begin
|
||||
if fcanvas and fcanvas.HandleAllocated() and fsp and fep and frect then
|
||||
begin
|
||||
if fdir=1 or fdir = 2 then FCanvas._wapi.SetArcDirection(FCanvas.Handle,fdir);
|
||||
fcanvas._wapi.arc(fcanvas.handle,frect[0],frect[1],frect[2],frect[3],fsp[0],fsp[1],fep[0],fep[1]);
|
||||
end
|
||||
return inherited;
|
||||
end
|
||||
end
|
||||
type tshapepie = class(tshape,tshaperect,tsepoint)
|
||||
function create(dc);
|
||||
begin
|
||||
inherited;
|
||||
end
|
||||
function draw();override;
|
||||
begin
|
||||
if fcanvas and fcanvas.HandleAllocated() and fsp and fep and frect then
|
||||
begin
|
||||
if fdir=1 or fdir = 2 then FCanvas._wapi.SetArcDirection(FCanvas.Handle,fdir);
|
||||
fcanvas._wapi.pie(fcanvas.handle,frect[0],frect[1],frect[2],frect[3],fsp[0],fsp[1],fep[0],fep[1]);
|
||||
end
|
||||
return inherited;
|
||||
end
|
||||
end
|
||||
type tshapechord = class(tshape,tshaperect,tsepoint)
|
||||
function create(dc);
|
||||
begin
|
||||
inherited;
|
||||
end
|
||||
function draw();override;
|
||||
begin
|
||||
if fcanvas and fcanvas.HandleAllocated() and fsp and fep and frect then
|
||||
begin
|
||||
if fdir=1 or fdir = 2 then FCanvas._wapi.SetArcDirection(FCanvas.Handle,fdir);
|
||||
fcanvas._wapi.chord(fcanvas.handle,frect[0],frect[1],frect[2],frect[3],fsp[0],fsp[1],fep[0],fep[1]);
|
||||
end
|
||||
return inherited;
|
||||
end
|
||||
end
|
||||
type tshapeBezier = class(tshape)
|
||||
function create(dc);
|
||||
begin
|
||||
inherited;
|
||||
fbpoints := array();
|
||||
end
|
||||
function draw();override;
|
||||
begin
|
||||
if fcanvas and fcanvas.HandleAllocated() and fbpoints then
|
||||
begin
|
||||
fcanvas._wapi.PolyBezier(fcanvas.handle,fbpoints,length(fbpoints));
|
||||
end
|
||||
return inherited;
|
||||
end
|
||||
function startpoint(p);overload;
|
||||
begin
|
||||
if ifarray(p) and ifnumber(p[0]) and ifnumber(p[1]) then
|
||||
begin
|
||||
fbpoints := array((p[0],p[1]));
|
||||
end
|
||||
return self(true);
|
||||
end
|
||||
function startpoint(x,y);overload;
|
||||
begin
|
||||
return startpoint(array(x,y));
|
||||
end
|
||||
function addpoints(ps);
|
||||
begin
|
||||
if ifarray(ps) then
|
||||
begin
|
||||
fbpoints union= ps;
|
||||
end
|
||||
return self(true);
|
||||
end
|
||||
private
|
||||
fbpoints;
|
||||
end
|
||||
function getresourcebyid(id,options);
|
||||
begin
|
||||
{**
|
||||
|
|
|
|||
Loading…
Reference in New Issue