From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,459eff021680c4f1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-16 18:55:06 PST Path: bga.com!news.sprintlink.net!cs.utexas.edu!swrinde!gatech!newsfeed.pitt.edu!uunet!in1.uu.net!mr.net!usenet From: Newsgroups: comp.lang.ada Subject: Re: Graphical interface for Ada programs Date: Thu, 16 Mar 95 20:25:21 CST Organization: DAINA Engineering Message-ID: <83597.pukite@daina.com> Reply-To: NNTP-Posting-Host: msp2-12.nas.mr.net X-POPMail-Charset: English Date: 1995-03-16T20:25:21-06:00 List-Id: ab@captblood.armstrong.edu wrote: > I would like to build a graphical interface to an > Ada program. The interface would have the usual buttons, > menus, multiple choices, as well as edit subwindows and a > animated display subwindow. > > What do you use for such a combination? Are there any > PD packagages that provide some/all of these > interface-design objects? I will try to explain one method of designing an Ada GUI. Suppose that I want to design an interactive dialog box. I plan to provide initial data to the dialog, then perform some procedures or updates while it is instantiated, and then return some data upon closure. To accomplish all this, I will eventually have to code (either visually or textually) various edit subwindows, check boxes, buttons, etc. to the basic dialog. Here is the list of controls (widgets) that a dialog might contain: Check box : BOOLEAN indication (yes or no) Radio button : set of TYPED (enumerated) values with only one chosen Edit box : text STRING or INTEGER value or FLOAT Slider/Scroll: RANGE of discrete values Push button : PROCEDURE that gets invoked List box : UNCONSTRAINED ARRAY of items Combo box : UNCONSTRAINED ARRAY of items with 0th item separate I can also have composites of these controls: Group box : A RECORD of related controls surrounded by a rectangle Array : A CONSTRAINED ARRAY of check boxes, edits, etc And I can trigger events by clicking on one control which updates another: Event click : A FUNCTION that returns a value to a specific control Notice that I have intentionally upper-cased certain words. In fact, these keywords and a parser allow me a way to map directly from Ada constructs to the appropriate dialog controls. I will give an example of how this works. The Ada package below uniquely specifies a dialog box: with Wintypes; package Select_Shape is subtype Shape_Name is STRING (1..20); type Shapes is array ( POSITIVE range <> ) of Shape_Name; type Intensities is range 1..10; type Colors is ( Red, Green, Blue ); type Dimensions is range 1..3; type Scaling is array ( Dimensions ) of INTEGER; generic with procedure Help ( Window : in Wintypes.HWND ); -- Push button procedure Box ( Window : in Wintypes.HWND; -- parent Window handle List_Name : in STRING; -- Static text List : in out Shapes; -- List box Intensity : in out Intensities; -- Scroll bar or slider Fill : out BOOLEAN; -- Check box Color : in out Colors; -- 3 Radio buttons Scale : in out Scaling ); -- Array of 3 Edits end Select_Shape; This dialog prompts for input on how to display and scale a certain shape. Note that this also gives the directional modes of the data. This specific example may be a bit contrived, but I can usually map a fair share of dialog boxes that I have seen out there with this technique. Of course, finishing up the coding task requires manual effort or a tool. The Ada package body will contain interfacing code; and a resource script file will contain the dialog layout. Plenty of tedious work is involved in interfacing so I prefer to use the automated approach. Fortunately, you can get an automated ("declareware") tool from the PAL if you happen to be Ada coding for Windows. Check out CanAda in the /languages/Ada/swtools directory and make sure you have a floating-point coprocessor enabled PC. It contains a Windows hypertext help file as documentation.