⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 allcomponents.pl

📁 PRl教学程序 PRl教学程序 PRl教学程序
💻 PL
字号:
/********************************************************************
    Constraint-based Graphical Programming in B-Prolog
    %
    Illustrate the usage of all the CG components
*********************************************************************/
go:-
    cgArc(Arc), Arc^startAngle #= 20, Arc^arcAngle #= 150,
    cgButton(Button), Button^text #= 'text',
    cgCircle(Circle), 

    cgLabel(Label), Label^text #= 'Label',
    cgLine(Line), Line^x2-Line^x1 #= Line^width, Line^y2-Line^y1 #= Line^height,
    cgOval(Oval), 2*Oval^width #= 3*Oval^height,
    %
    cgPolygon(Polygon), Polygon^n #= 5,
    Polygon^x(1) #= Polygon^x(0),
    Polygon^y(1) #= Polygon^y(0)+Polygon^height/2,
    Polygon^x(2) #= Polygon^x(0)+Polygon^width/2,
    Polygon^y(2) #= Polygon^y(0)+Polygon^height,
    Polygon^x(3) #= Polygon^x(0)+Polygon^width,
    Polygon^y(3) #= Polygon^y(1),
    Polygon^x(4) #= Polygon^x(0)+Polygon^width/2,
    Polygon^y(4) #= Polygon^y(0),
    %
    cgRectangle(Rectangle), 2*Rectangle^width #= 3*Rectangle^height,
    cgRoundRectangle(Rrectangle), 
    Rrectangle^arcWidth #>= Rrectangle^width/4, 
    Rrectangle^arcHeight #>= Rrectangle^height/4,
    %
    cgSquare(Square),
    cgStar(Star),Star^n #= 5,
    %
    cgTextArea(TextArea), TextArea^text #= 'Text field \n line2 \n line3',
    TextArea^rows #= 4, TextArea^columns #= 30,
    cgTextField(TextField), TextField^text #= 'Text Field',
    %
    cgTriangle(Triangle), Triangle^x2 #= Triangle^x1+Triangle^width, Triangle^y2 #= Triangle^y1,
    Triangle^x3 #= Triangle^x1, Triangle^y3 #= Triangle^y1-Triangle^height,
    %
    cgImage(Image), Image^name #= 'animal1.gif',
    %
    Labels=[Larc,Lbutton,Lcircle,Llabel,Lline,Loval,Lpolygon,Lrectangle,Lrrectangle, 
	    Lsquare, Lstar, Ltextarea,Ltextfield, Ltriangle, Limage],
    cgLabels(Labels),
    Texts=['Arc','Button','Circle','Label','Line','Oval','Polygon','Rectangle','RoundRectangle', 
	   'Square', 'Star', 'TextArea','TextField', 'Triangle', 'Image'],
    setTexts(Labels,Texts),

    cgSame(Labels,color,blue),
    %
    cgTable([[Larc,Arc,Button,Lbutton],
	     [Lcircle,Circle,Label,Llabel],
	     [Lline,Line,Oval,Loval],
	     [Lrrectangle,Rrectangle,Rectangle,Lrectangle],
	     [Lpolygon,Polygon,Square,Lsquare],
	     [Lstar,Star,TextArea,Ltextarea],
	     [Ltextfield,TextField,Triangle,Ltriangle],
	     [Limage,Image,_,_]], 20,20),

    cgSame([Larc,Lcircle,Lline,Lpolygon,Lrrectangle,Lstar,Ltextfield,Limage],alignment,'RIGHT'),
    Arc^width #>30, Arc^width #=<50, 
    Button^width #>30, Button^width #=<50, 
    %
    cgStartRecord(allComponents),
    Comps=[Larc,Arc,Button,Lbutton,
	   Lcircle,Circle,Label,Llabel,
	   Lline,Line,Oval,Loval,
	   Lrrectangle,Rrectangle,Rectangle,Lrectangle,
	   Lpolygon,Polygon,Square,Lsquare,
	   Lstar,Star,TextArea,Ltextarea,
	   Ltextfield,TextField,Triangle,Ltriangle,
	   Limage,Image],
    cgPack(Comps),

    cgResize(Comps,NComps,400,400),
    cgShow(NComps),
    cgStopRecord.

setTexts([],[]).
setTexts([L|Ls],[T|Ts]):-
    L^text #= T,
    setTexts(Ls,Ts).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -