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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2acad440547c73be,start X-Google-Attributes: gid103376,public X-Google-Thread: 10eb76,2acad440547c73be,start X-Google-Attributes: gid10eb76,public X-Google-ArrivalTime: 1995-03-16 09:24:27 PST Newsgroups: comp.lang.ada,comp.lang.tcl Path: bga.com!news.sprintlink.net!pipex!sunsite.doc.ic.ac.uk!dcs.gla.ac.uk!stevem From: stevem@dcs.gla.ac.uk (Steve McGowan) Subject: Interfacing Ada with C with Tcl/Tk... Message-ID: Organization: Computing Science Dept., Glasgow University, Glasgow, Scotland Date: Thu, 16 Mar 1995 17:17:48 GMT Xref: bga.com comp.lang.ada:11138 comp.lang.tcl:16610 Date: 1995-03-16T17:17:48+00:00 List-Id: Dear All, I am writing a major software simulator in Ada. I also need to interface this Ada code with C code (which I am able to do). Additionally, I need to call various Tcl/Tk widgets from within the Ada code. My way of thinking here is that my C code can interface with the Tcl/Tk stuff, which in turn can be interfaced with my Ada code. The Ada code needs to be able to determine the standard events, such as clicking the mouse button when the cursor is in a particular widget. For example, I'd like to have something like this in my Ada code: declare widget1 : ENTRY_WIDGET; textvalue : string (1..30); . . DisplayWidget(widget1); . IF (MouseButtonClickedInWidget(widget1)) THEN GetTextFromWidget(textvalue, widget1); END IF; . . DestroyWidget(widget1); . The code for 'DisplayWidget', 'MouseButtonClickedInWidget', 'GetTextFromWidget' and 'DestroyWidget' could be Ada functions/procedures that invoke a corresponding C procedure, which in turn interfaces with the appropriate Tcl/Tk widget. However, I'm a bit uncertain as to whether or not I will have control over the widgets from my Ada code, or whether most of the control (ie, of events) will be handled and processed without the Ada code knowing about them. I'll also need to impose various temporal constraints on these events, such as 'sequencing' (eg, enter text in one entry widget, then do the same for another widget, etc); 'order independence' (letting the user select any entry widget, but they must perform the text entry to completion before starting another text entry task, etc). There are 3 other temporal constraints that I need to implement. Currently, I can cater for all 5 in my Ada software, but I need to ensure that these temporal constraints are carried over into the Tcl/Tk environment. I assume that I can just implement 'grabs' to achieve this. Another issue that concerns me is whether or not I should pass widget data structures between my Ada code and my C/Tcl/Tk code. For simplicity, I would like to keep the Ada side as clean as possible. I thought maybe I could define a record type that had 2 elements; 1) a simple (unique) integer value to identify the relevant widget, and 2) a field that contained an access type to the corresponding widget record pointer on the C/Tk/Tcl side...??? Any thoughts will be greatly appreciated!! --Steve ------------------------------------------------------------------------------ "...scalpel.....sutures.....clamp......oopps.....pen....death certificate...." ------------------------------------------------------------------------------