TNTmips

HOME

FREE PRODUCTS
  TNTlite
  TNTatlas
  TNTsim3D

DOWNLOADS
  Release Version
  Development Version
  FTP
  Language Kits
  Sample Geodata
  Reseller Resources
  Promotional

DOCUMENTATION
  Tutorials
  Technical Guides
  Quick Guides

SITE MAP


drawdlg.sml


# DRAWDLG.SML
# Sample script for Building Dialogs in SML.

# Creates and opens a dialog window
# and uses a drawing area.

clear();

# Define global class variables used in procedures.
class XmForm win1;			# parent widget for dialog window.
class XmDrawingArea da;		# drawing area widget.
class GC gc;				# graphics context for drawing area.

# Procedure for redraw of drawing area when exposed.
proc OnRedraw() {

	local numeric radius1, radius2;
	local numeric x, y;

	# A graphics context (GC) is a structure that holds relevant
	# information such as color, line width, and font for 
	# drawing text or graphics in a window.  A GC must be
	# created and activated before drawing, and the GC must be
	# created AFTER the dialog window has actually opened.

	if (!gc) gc = CreateGCForDrawingArea(da); 
	ActivateGC(gc);

	# Draw background white rectangle from lower left corner of
	# drawing area and with same height and width as drawing area.
	SetColorName("white");		# color name from reference file RGB.text.
	FillRect(0,0,da.width,da.height);

	# Draw filled red circle centered on center of drawing area.
	radius1 = SetMin(da.width,da.height) / 2;
	x = da.width / 2;		y = da.height / 2; 

	SetColorRGB(255,0,0);				# RGB values for red color
	FillCircle(x,y,radius1);

	# Draw yellow circle centered on center of drawing area.
	radius2 = radius1 / 2;
	SetColorRGB(255,255,0);				# RGB valuse for yellow color
	SetLineWidth(4);						# Set line width in screen pixels.
	DrawCircle(x,y,radius2);

	SetColorRGB(0,0,0);
	DrawTextSetHeightPixels(15);
	DrawTextSetFont("duck.of");
	DrawTextSimple("Drawing Area",17,da.height-5,90);

}

# Procedure for closing window.
proc OnClose() {
	DialogClose(win1);
	DestroyWidget(win1);
}

# Set up dialog window.
win1 = CreateFormDialog("Dialog with Drawing Area");
win1.MarginHeight = 5;
win1.MarginWidth = 5;

# Create drawing area and attach to window margin 
# on top, left, and right.  Add callback for when
# the drawing area is exposed.
da = CreateDrawingArea(win1,150,225);
da.TopWidget = win1;
da.LeftWidget = win1;
da.RightWidget = win1;
WidgetAddCallback(da.ExposeCallback,OnRedraw);

# Create Close button attached to drawing area on
# on top and to window margin on left and right.
class XmPushButton closeButton;
closeButton = CreatePushButton(win1,"Close");
closeButton.TopWidget = da;
closeButton.TopOffset = 5;
closeButton.leftWidget = win1;
closeButton.rightWidget = win1;
closeButton.bottomWidget = win1;
WidgetAddCallback(closeButton.ActivateCallback,OnClose);

# Open dialog window and keep script active.
# until window is closed.
DialogOpen(win1);
DialogWaitForClose(win1);


Back Home ©MicroImages, Inc. 2008 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

9 May 2008

page update: 14 Aug 07