Kuba,
> I'm contemplating porting XCircuit to C++ using Qt toolkit, using
> Javascript for scripting. This would immediately make it available
> on all major platforms, and make it easier to hack on it (IMHO, no
> flamebaiting intended).
You're not going to get a flame response, at least from me. However,
I do have a fairly low opinion of Qt, not to mention C++, and other
massive cross-platform packages like Gtk (which is generally preferred
over Qt, I gather). Nevertheless, I would also consider Xw to be stone
dead, and Tcl/Tk has plenty of flaws itself. It so happens that I
tackled the Magic VLSI tool first, and since John Ousterhout went on
from developing Magic to developing Tcl/Tk, using a lot of the same
ideas and methods, it was much easier to port Magic to Tcl/Tk than
anything else. Once I had Magic under my belt, I found it relatively
easy to use the same method to convert a number of other programs,
such as xcircuit, IRSIM, and netgen, to Tcl/Tk. I'm certainly partial
to interpreters (excepting SKILL, the worst interpreter language ever
invented), and the nice thing about Tcl/Tk is that not only does it
give me the interpreter, but also takes care of the higher-level
graphics management.
At any rate, I welcome all open source development, and you're welcome
to take xcircuit and do what you like with it. When people can't do
that, it pretty much guarantees instant death of any piece of software
dependent upon some package that happens to go out of fashion.
> I'm trying to figure out where the main entry point is for the code
> that creates the main window. I don't know much about Xw nor Tk, so
> my immediate concern is to know where to look first. All I figured
> out so far is that the code is called as a library that plugs into
> the tcl interpreter.
The Tcl/Tk entry point comes from a script, and the Xw entry point is
embedded. Unfortunately, I found that Tcl/Tk doesn't have a simple
window type for doing nothing but accepting low-level graphics calls
from a custom package extension. So I created one called "tkSimple"
(tkSimple.c). This is a standalone package that registers itself
with Tcl/Tk under the command "simple". The call to "simple" can
be found in the script "wrapper.tcl" (in lib/tcl/ from the source
top-level directory), called from the Tcl procedure "xcircuit::new_window".
The same script (wrapper.tcl) makes the first call to new_window
(see line 2863) to create the initial window. The chain of events
goes as follows:
1) Command line "xcircuit" calls the shell script
2) Shell script launches the tkcon.tcl console,
tells it to load package Tk, and to source the
script "xcircuit.tcl".
3) Script "xcircuit.tcl" sources the file "wrapper.tcl"
(line 210), which defines all of the script procedures
and also creates the "simple" window. Then xcircuit
calls the procedure "xcircuit::start" (line 211), the
source code of which is in tclxcircuit.c (line 9380).
4) Procedure "xcircuit::start" calls subroutine GUI_init.
5) Subroutine GUI_init() uses Tk calls to find the window
created with the "simple" command, adds its own
callback procedures and event handlers, and maps the
window. Tk then handles all of the graphics events in
the window.
The Xw code is completely separate from the Tcl/Tk code, and only gets
compiled when you don't have Tcl/Tk installed, or use the "--without-tcl"
switch when running "configure" before compiling. The Xw chain of
events is much simpler:
1) Command line "xcircuit" runs the xcircuit executable
2) main() is in xtgui.c line 2004. main() calls the Xw
version of GUI_init (xtgui.c line 2034)
3) GUI_init() makes all the usual Xt calls like
XtOpenApplication() and XtAppCreateShell(), and
generates the whole window hierarchy.
Note that when you compile with Tcl/Tk, xcircuit makes *no* calls to Xt
routines, only calls to Tcl/Tk, and low-level drawing commands like
XDrawLines, XFillRectangle, etc.
You may also find this web page helpful: From the Xcircuit main web
page, click on "Reference", then click on the link "XCircuit internal
data structure". It's sketchy, but you may find relevant stuff in
there.
> One benefit of using Qt is that all of the introspection glue between
> scripting languages (even potentially TCL) and core object system is
> already there with zero extra effort. I expect this would cull lots of
> boilerplate code. I really like the sparse and efficient UI, so that
> aspect is my prime concern for preservation.
Tcl/Tk also allows a lot of boilerplate code to be removed, which is why
I have moved much of it into xtgui.c and xtfuncs.c. There are a few
things like "filelist.c" where I preferred to make my own interface,
because I didn't like the one provided by Tk, so some code which you might
otherwise call "boilerplate" is intentional.
I hope that discussion helps.
---Tim
+--------------------------------+-------------------------------------+
| Dr. R. Timothy Edwards (Tim) | email: [email protected] |
| Open Circuit Design, Inc. | web: http://opencircuitdesign.com |
| 22815 Timber Creek Lane | phone: (301) 528-5030 |
| Clarksburg, MD 20871-4001 | cell: (240) 401-0616 |
+--------------------------------+-------------------------------------+
_______________________________________________
Xcircuit-dev mailing list
[email protected]
http://www.opencircuitdesign.com/mailman/listinfo/xcircuit-dev