1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> pcb-rnd rosetta unit converter (GUI, interactive) </title>
<meta http-equiv="Content-Type" content="text/html;charset=us-ascii">
</head>
<body>
<!-- ******* DO NOT EDIT THIS FILE, it is generated by rosetta_genpages.sh ******* -->
<-- back to the <a href="../index.html">index of Rosetta examples</a>
<h1>unit converter (GUI, interactive)</h1>
Interactive unit converter in a dialog, created via dad().
<H2> Example implementations </H2>
<a href="ex.awk">awk</a>
|
<a href="ex.lua">lua</a>
|
<a href="ex.tcl">tcl</a>
<h2> Explanation, step by step </h2>
Create a function
<i>uconv</i>
that will be registered as an action.
<p> When the action is called, build a dad dialog called "uconv". Make sure there's only one instance of the dialog is created by checking if a dialog by this name already exists.
<p> The dialog is built as a horizontal box to split it to left and right. On the left side there is only a coordinate input box. On the right side there's a vertical box hosting 3 labels where the results will be displayed.
<p>
<img src="uconv.png" alt="uconv dialog box as rendered by gtk2">
<p> The widget IDs of the input and the three result labels are saved in global variables
<i>inp, res1, res2</i>
and
<i>res3</i>
.
<p> Any change on the input will call action "uconv_update", which is also registered by the script. The update code reads the input field with the unit set to "mm", then sets the value of the first label (
<i>res1</i>
) to this text with a "mm" suffix appended. This is repeated two more times for two other unit types.
<p> More details on DAD:
<a href="../../../../../developer/dad/index.html">DAD developer's doc</a>
</body>
</html>
|