Algorithmic Solutions > LEDA > LEDA Guide > Windows and Panels > Basic Example

## Basic Example Window

 The following program generates a window W  with height 600 pixels, width 500 pixels (pixel coordinate system) and titel "Demo of Using Window". The x- and y-coordinates of the window are between -1000 and 1000 (user coordinate system). See also Pixel and User Coordinates. Then panel items for text, choice, and a button are inserted in the panel section of the window. The window is opened and displayed. Finally, the result of the algorithm that was chosen in the panel section is drawn in the drawing section of the window. On the right there is a screenshot of the program. Clicking on the picture shows the window in original size. #include <LEDA/core/list.h>
#include <LEDA/geo/point.h>
#include <LEDA/graph/graph.h>
#include <LEDA/graphics/window.h>
#include <LEDA/geo/geo_alg.h>

using namespace leda;

int main()
{
int height=600, width=500;
window W(width,height,"Demo of Using Window");

int xmin=-1000, xmax=1000, ymin=-1000;
W.init(xmin,xmax,ymin);

W.text_item("\\bf\\blue Please Choose an Algorithm and Press 'Run'");
W.text_item("");
W.text_item("The right mouse button terminates the program");
int c=3;
W.choice_item("",c,"Convex Hull","Triangulation","Delaunay Triangulation");
W.text_item("");W.text_item("");
W.button("Run");

W.open(window::center,window::center);W.display();

W.set_node_width(3);

list<point> L;random_points_in_square(25,900,L);

for (;;) {
W.clear();

point p; forall(p,L) W.draw_filled_node(p);

if (c==0) {
list<point> H=CONVEX_HULL(L);

list_item lit;forall_items(lit,H) {
point p=H[lit];point q=H[H.cyclic_succ(lit)];
W.draw_edge(p,q,red);
}
}

if (c==1) {
GRAPH<point,int> T;TRIANGULATE_POINTS(L,T);

edge e;forall_edges(e,T) {
point p=T[T.source(e)], q=T[T.target(e)];
W.draw_edge(p,q,green);
}
}

if (c==2)  {
GRAPH<point,int> DT;DELAUNAY_TRIANG(L,DT);

edge e;forall_edges(e,DT) {
point p=DT[DT.source(e)], q=DT[DT.target(e)];
W.draw_edge(p,q,blue);
}
}

}

W.screenshot("window_demo");

return 0;
}  

Windows and Panels

Pixel and User Coordinates

Panel Items

Linear Lists

Parameterized Graphs

Convex Hulls

Triangulations

Delaunay Triangulations

Graphs and Related Data Types

Geometry

Geometry Algorithms

### Manual Pages:

Manual Page Windows