Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 51f7de0838007e2876221e819c82d833 > files > 575

sketch-0.6.13-2mdk.ppc.rpm

<html>
<head>
<title>Developer's Guide: The Design of Sketch</title>
</head>
<body bgcolor=white text=black link=blue vlink=navy alink=red>
<TABLE WIDTH="100%">
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
<TR>
<TD ALIGN="left"><A HREF="devguide-1.html">Introduction</A></TD>
<TD ALIGN="center"><A HREF="devguide.html">Developer's Guide</A></TD>
<TD ALIGN="right"><A HREF="devguide-3.html">General Remarks</A></TD>
</TR>
</TABLE>
<HR NOSHADE>
<H1><FONT face="Helvetica,Arial"><A NAME="N1"></A>The Design of Sketch</font></H1>
<P>Sketch is written almost completely in Python, an object oriented
interpreted programming language. Python can easily be extended by
modules written in C to increase performance and Sketch uses this fact
to implement some time critical functions and Python objects in C.</P>
<P>The source code of Sketch can be divided roughly into these parts:
<DL>
<DT><B>User Interface</B><DD>
<P>Sketch currently uses the Tk Toolkit via
the Tkinter module from the standard Python library. Sketch
only uses some generic widgets like buttons, menus and
scrollbars and none of the more sophisticated widgets like Tk's
Text or Canvas widgets. The main widget where the drawing is
displayed is a Tk widget that is almost entirely implemented in
Python using a C-module that provides GCs, Pixmaps, Fonts etc as
Python objects (This module is heavily based on the Xt module).</P>
<P>Sketch also has some classes that provide a more abstract
interface to generic GUI elements like buttons and menus that
hopefully make it relatively simple to switch to another
toolkit. In fact I already switched toolkits once, from
Xt/Athena to Tk, which was simpler than I had expected...</P>

<DT><B>Graphics Devices</B><DD>
<P>Sketch defines several classes for
drawing into a window or into a PostScript file that share a
common, generic interface. This allows us to use the same code
for drawing on the screen and for printing.</P>

<DT><B>Document- and Graphics Objects</B><DD>
<P>These objects represent
entire documents and the parts thereof in an abstract way. This
representation is independent of any particular output device or
operating system.</P>

<DT><B>File IO</B><DD>
<P>Sketch has classes and functions for reading
drawings in several formats (well, just three as of this
writing). Sketch of course defines its own special format and
can read and write this. In addition, there is currently partial
support for reading XFig files and Adobe Illustrator (AI) files.
Many common drawing programs for MS Windows can export drawings
in Illustrator format. Two examples of this file format can also
be found in ghostscript's examples directory as tiger.ps and
golfer.ps (Sketch can read these).</P>
<P>For reading bitmap graphics Sketch uses the Python Imaging
Library so that it should be able to read everything that this
library can read.</P>

<DT><B>Miscellaneous</B><DD>
<P>There are some modules that provide objects
representing 2D points/vectors, rectangles, affine
transformations, fonts and font-metrics, etc.</P>

</DL>
</P>
<P>Sketch uses a variation of the model/view/controller concept. The
document and graphics object classes form the model which represents the
drawing in a device independent way and which can be manipulated through
a specific set of methods. The class <tt>SketchCanvas</tt> serves both as
the main view and controller. It manages a window graphics device that
is used to display that drawing and it accepts user input in the form of
mouse and keyboard events and translates them into method invocations on
the document object.</P>

<HR NOSHADE>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="left"><A HREF="devguide-1.html">Introduction</A></TD>
<TD ALIGN="center"><A HREF="devguide.html">Developer's Guide</A></TD>
<TD ALIGN="right"><A HREF="devguide-3.html">General Remarks</A></TD>
</TR>
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
</TABLE>
</body>
</html>