Demo entry 2393845

x11

   

Submitted by anonymous on Aug 18, 2015 at 10:03
Language: Modula-2. Code size: 1.1 kB.

MODULE xm;

IMPORT	x11, InOut;

TYPE	LineType  = (single, double, dotted);
	Colour	  = (red, green, blue, cyan, magenta, yellow, black, white);
	ButtName  = ARRAY [0..15] OF CHAR;

	ButtonRec = RECORD
 		      x0, y0, 
		      width, height	: CARDINAL;
		      border		: LineType;
		      foreground,
		      background	: Colour;
		      name		: ButtName;
		      leftbutton,
		      middlebutton,
		      rightbutton	: PROCEDURE
		    END;

VAR	ButtonData		: ARRAY [0..15] OF ButtonRec;
	Buttons			: CARDINAL;


PROCEDURE DefineButton (x, y, w, h : CARDINAL; Name : ButtName) : CARDINAL;

BEGIN
  i := Buttons;
  IF  i < 16  THEN  INC (Buttons)  ELSE  RETURN  127  END;
  WITH  ButtonData [i]  DO
    x0 := x;
    y0 := y;
    width := w;
    height := h;
    name := Name;
  END;
  RETURN i
END DefineButton;

PROCEDURE MakeButton (button : CARDINAL);

VAR	x, y, w, h		: CARDINAL;

BEGIN
  x := ButtonData [button].x0;
  y := ButtonData [button].y0;
  w := ButtonData [button].width;
  h := ButtonData [button].height;
  x11.FillRect (x, y, w, h);
  x11.PrintString (x+10, y+10, ButtonData [button].name);
END MakeButton;


BEGIN
  
END xm.

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).