Guidance
指路人
g.yi.org
Software / Reginald / Examples / console.rex

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/*
GUIBEGIN
WINDOW , 81, 238, 400, 200, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Console example
	FONT 8, 400, MS Shell Dlg
	PUSH 5, 8, 40, 14, TABSTOP, , SAY1, , Say 1
	PUSH 51, 8, 40, 14, TABSTOP, , SAY2, , Say 2
	PUSH 99, 8, 40, 14, TABSTOP, , CLEAR, , Clear
	GROUP 145, 1, 250, 25, , , , , Background color
	RADIO 150, 11, 39, 10, AUTO|GROUP, , BackColor, , Black
	RADIO 195, 11, 39, 10, AUTO, , , , White
	RADIO 240, 11, 50, 10, AUTO, , , , Light gray
	RADIO 296, 11, 49, 10, AUTO, , , , Dark gray
	RADIO 351, 11, 39, 10, AUTO, , , , Gray
	PUSH 5, 29, 71, 14, TABSTOP, , TextColor, , Change text color
	PUSH 89, 29, 78, 14, TABSTOP, , PullColor, , Change PULL color
	PUSH 175, 29, 40, 14, TABSTOP, , Pull, , Do PULL
	PUSH 301, 29, 43, 14, TABSTOP, , ChangeFont, , Pick font
	PUSH 348, 29, 46, 14, TABSTOP, , SetFont, , Set Courier
	PUSH 224, 29, 68, 14, TABSTOP, , Pull1, , PULL 1 character
DEND
GUIEND
*/

LIBRARY rexxgui, rxconsole
guierr = "SYNTAX"
guiheading = 1
backcolor = 1
textcolor = 1
pullcolor = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
	guigetmsg()
	CATCH SYNTAX
			CONDITION()
			SIGNAL again
	CATCH HALT
	FINALLY
		guidestroywindow()
END
RETURN

/* Called when the window and its controls are created, but
 * before it is displayed
 */
wm_initdialog:
	/* Get the size of the window */
	guigetctlplacement(guiwindow, , , "width", "height")

	/* We want to place our console under the buttons. So
	 * we need to find where the top of the "lowest" button
	 * appears in the window (ie, its Y position), and its
	 * height. We add these two together and subtract from
	 * the main window height. Now we know how much height
	 * we have free for the console to occupy
	 */
	guigetctlplacement('TextColor', "SayX", "SayY", "SayWidth", "SayHeight")
	sayy = sayy + sayheight
	height = height - sayy

	/* Create a console window embedded into our main window.
	 * We pass our GuiWindow handle as the second arg to
	 * ConCreate(). We also specify the CHILD option. By
	 * not specifying the "NODEFAULT" option, text is output
	 * to this window with a ConSay command... from
	 * anywhere. Text is gotten from this window with a
	 * ConPull command... anywhere.
	 * NOTE: We don't pass a handle variable name because we
	 * don't need it. We can call the other Con functions, omitting
	 * the first arg, and it will operate upon the default console.
	 */
	concreate(, guiwindow, "CHILD", , sayy, width, height)

	/* Don't let Rexx Gui process this event. */
	RETURN ""

/* Called when the SAY 1 button clicked */
wm_click_say1:
	/* Output to the console window */
	consay(, "Button 1 was clicked")
	RETURN

/* Called when the SAY 2 button clicked */
wm_click_say2:
	/* Output to the console window */
	consay(, "Button 2 was clicked")
	RETURN

/* Called when the Clear button clicked */
wm_click_clear:
	conclear()
	RETURN

/* Called when the Text Color button clicked. This
 * changes the color of text we print via ConSay
 * or SAY.
 */
wm_click_textcolor:
	/* We just increment the TextColor count. When
	 * its 1, we set it to mostly Red. When its 2, we set
	 * it to Green. When its 3, we set it to Blue.
	 * When its 4, we roll back to 1. Ie, We cycle through
	 * 3 different colors. Of course, you can select among
	 * millions of colors if you want. 
	 */
	textcolor = textcolor + 1
	IF textcolor > 3 THEN textcolor = 1
	SELECT textcolor
	  WHEN 1 THEN DO
	     red = 180 /* Range for each color value is 0 to 255 */
	     green = 40
	     blue = 40
	  END
	  WHEN 2 THEN DO
	     red = 40
	     green = 180
	     blue = 40
	  END
	  OTHERWISE DO
	     red = 40
	     green = 40
	     blue = 180
	  END
	END
	consetcolor(, , red, green, blue)
	RETURN

/* Called when the PULL Color button clicked */
wm_click_pullcolor:
	/* Set the color of text entered via ConPull. We
	 * do the same thing as per the Text color. But
	 * the PULL color can be different.
	 */
	pullcolor = pullcolor + 1
	IF pullcolor > 3 THEN pullcolor = 1
	SELECT pullcolor
	  WHEN 1 THEN DO
	     red = 180 /* Range for each color value is 0 to 255 */
	     green = 40
	     blue = 40
	  END
	  WHEN 2 THEN DO
	     red = 40
	     green = 180
	     blue = 40
	  END
	  OTHERWISE DO
	     red = 40
	     green = 40
	     blue = 180
	  END
	END
	consetcolor(, "PULL", red, green, blue)
	RETURN

/* Called when one of the Background radio buttons clicked.
 * We have a choice of 5 colors for the background.
 */
wm_click_backcolor:
	guigetctlvalue('BackColor')
	SELECT backcolor
		WHEN 1 THEN str = "BLACK"
		WHEN 2 THEN str = "WHITE"
		WHEN 3 THEN str = "LIGHTGRAY"
		WHEN 4 THEN str = "DARKGRAY"
		OTHERWISE str = "GRAY"
	END
	consetcolor(, "BACK", str)
	RETURN

/* Called when the Do PULL button clicked */
wm_click_pull:
	/* Prompt the user to enter text, then get that
	 * text. ConPull doesn't return until he enters
	 * the text and presses ENTER.
	 */
	consay(, "Enter some text, then press ENTER")
	text = conpull()

	/* Echo what he typed.
	 * Note: If the user closes the window, or aborts
	 * while ConPull is entering text, then HALT will
	 * be raised. So, we'll never get here.
	 */
	consay(, text)
	RETURN

/* Called when the Pick Font button clicked */
wm_click_changefont:
	/* Preset the font dialog to pick and set the font */
	consetfont(, "")
	RETURN

/* Called when the Set Courier button clicked */
wm_click_setfont:
	/* We specifically set the font to "Courier New", height
	 * of 16, and a style of BOLD. Other styles we can add are
	 * ITALIC and UNDERLINE, each separated by a | character,
	 * for example "ITALIC|UNDERLINE"
	 */
	consetfont(, "Courier New", 16, "BOLD")
	RETURN


/* Called when the Do PULL 1 character button clicked */
wm_click_pull1:
	/* Exactly the same as with "Do PULL", but we pass
	 * a second arg which is how many characters we want
	 * the text limited to. Here, that is 1. The allowable
	 * range is 1 to 255.
	 */
	consay(, "Press a key")
	text = conpull(, 1)

	/* We could echo it with one ConSay call as so...
	 * ConSay(, "You pressed the" text "key.")
	 * But by passing a third arg of "NOBREAK" to
	 * ConSay, you can suppress the line feed. So
	 * here is how we can spread the printing across
	 * 3 calls to ConSay, but keep it all on 1 line.
	 */
	consay(, "You pressed the ", "NOBREAK")
	consay(, text, "NOBREAK")
	consay(, " key")
	RETURN
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:33