1 /* Toy calculator from example 02 turned into a reusable widget.
2 * - by Richard W.M. Jones <rich@annexia.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * $Id: 03_many_toy_calculators.c,v 1.3 2002/09/07 13:46:58 rich Exp $
28 #include "ml_window.h"
29 #include "ml_table_layout.h"
31 #include "toy_calculator.h"
33 /* Main entry point to the app. */
34 static void app_main (ml_session);
37 handle_request (rws_request rq)
39 return ml_entry_point (rq, app_main);
43 app_main (ml_session session)
45 pool pool = ml_session_pool (session);
48 toy_calculator calcs[4];
50 /* Create the top-level window. */
51 w = new_ml_window (session, pool);
53 /* Create a table layout widget to arrange the calculators. */
54 tbl = new_ml_table_layout (pool, 2, 2);
56 /* Create the calculators and pack them into the table layout. */
57 calcs[0] = new_toy_calculator (pool, session);
58 ml_table_layout_pack (tbl, calcs[0], 0, 0);
59 calcs[1] = new_toy_calculator (pool, session);
60 ml_table_layout_pack (tbl, calcs[1], 0, 1);
61 calcs[2] = new_toy_calculator (pool, session);
62 ml_table_layout_pack (tbl, calcs[2], 1, 0);
63 calcs[3] = new_toy_calculator (pool, session);
64 ml_table_layout_pack (tbl, calcs[3], 1, 1);
66 /* Pack the table into the window. */
67 ml_window_pack (w, tbl);