comp.lang.ada
 help / color / mirror / Atom feed
* Interfacing Ada with C with Tcl/Tk (Repost)
@ 1995-03-20 13:06 Steve McGowan
  0 siblings, 0 replies; only message in thread
From: Steve McGowan @ 1995-03-20 13:06 UTC (permalink / raw)



(This article did not even turn up on my home site, so apologies
if you've seen it before!!)


-------------------begin-------------------

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...."

------------------------------------------------------------------------------


---------------end-----------------------






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-03-20 13:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-03-20 13:06 Interfacing Ada with C with Tcl/Tk (Repost) Steve McGowan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox