Compare commits

...

1 Commits

Author SHA1 Message Date
Bryan Petty
fad893ed70 This commit was manufactured by cvs2svn to create tag 'M_REFERENCE'.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/M_REFERENCE@1021 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1998-11-22 22:32:53 +00:00
30 changed files with 14318 additions and 113 deletions

42
TODO.txt Normal file
View File

@@ -0,0 +1,42 @@
********************* TODO list for wxWindows 2 ******************************
=============================== common ========================================
wxSocket, wxTCP etc..
wxMultiMedia
=============================== generic ======================================
wxTreeCtrl keyboard handling
wxTreeCtrl icon support
wxListCtrl icon support in list mode
================================ MSW ==========================================
Consistent keyboard interface and focus behaviour
currently, the focus is lost all the time (after a MessageBox, for example)
and sometimes TABbing through controls doesn't work
================================ GTK ==========================================
Add support Set colour/baclgroundcolour in GTK widgets
Correct tab navigation (seems to be a GTK feature)
Finish DnD
Add Clipboard
Help system (not sure about this one)
Show accelerator in menus
More controls with bitmaps
Speed up bitmap saving
Add wxBitmapHandler
Fix printing of bitmaps
Implement wxRadioBox layout
Finish wxTextCtrl
Finish native wxTreeCtrl
Implement wxPalette
Implement wxDirDialog
Support cooperation between Qt and wxWindows
Fix toolbar tips
TrueType support (just kidding)

292
docs/gtk/welcome.html Normal file
View File

@@ -0,0 +1,292 @@
<html>
<head><title>wxGTK Homepage</title>
</head>
<body bgcolor=#FFFFFF text=#000000 link=#0020FF vlink=#800000 alink=#007777>
<h1>"wxWindows for the GTK" Homepage</h1>
<hr>
<h3>Current version</h3>
15th May '98: wxGTK v0.12 (alpha-)
<p>
This release is hardly more stable than the one before, but it
has many new features. It's main purpose is actually to prepare
the final merge of the Windows port and the GTK port source
trees into a common tree, developed using CVS. The growing
number of demos which compile and run with wxGTK "although"
being written for wxMSW shows that we seem to be on the right
track. One nice new feature for many potential users is that
wxGTK no longer needs any extra libraries to be installed,
other than the GTK.
<p>
If you have a compiler
better than gcc 2.7.2.2 then you can uncomment a line in src/common/prntbase.cpp
which defines __GOOD_COMPILER__. This should make the printing demo work.
I haven't got such a compiler, so I actually don't know. Somebody reported
problems with version 2.7.2.3 as well.
<p>
<hr>
<h3>Acknowledgements</h3>
I'd like to thank the
<a href="http://www.freiburg.linux.de">Freiburg Linux User Group</a>
for kindly providing
this site and Christian Wetzel in particular for helping me with
this site's administration.
<p>
<hr>
<h3>What is wxWindows?</h3>
wxWindows is a C++ cross-platform GUI toolkit written mainly by Julian Smart.
More information about wxWindows can be found at the
<a href="http://web.ukonline.co.uk/julian.smart/wxwin">wxWindows Homepage</a>.
<p>
The current version of wxWindows (v1.68) supports Windows ('95 and NT), Motif and
XView (aka OpenLook). There is another port (wxXt) available, which uses the
free-ware widget set from the Free Widget Foundation (FSF). Ports have been
started for the Mac, OS/2 and NextStep.
<p>
For different reasons, it was decided to start a complete rewrite of wxWindows,
which will then be called wxWindows 2.0. For a list of new features and changes
from the current version, you may read the wxWindows Homepage (see above).
<p>
Currently, work is being done on four ports of wxWindows 2.0:
<dl>
<li> Windows (wxMSW, main author Julian Smart)
<li> Unix, Motif (wxMotif, main author Markus Holzhem)
<li> Unix, GIMP Toolkit (wxGTK, main author Robert Roebling)
<li> Macintosh (wxMac, main author Greg Whitehead)
</dl>
<p>
wxWindows provides a rich set of classes which help to make cross-platform
GUI programming easy. In many aspect, it is modelled after MFC, making transition
from MFC to wxWindows relatively painless. The main technical
difference between most other free or commercial cross platform libraries is
that wxWindows is a wrapper around existing widget sets, whereas the other
toolkits (Qt, Tk, Java, Amulet, OPaC, JX, Fresko) draw their widgets themselves,
which results in applications having a different look than native applications
for that specific platform.
<p>
There are classes for the following categories
<dl>
<li> Window classes: wxWindow, wxFrame, wxDialogBox, wxPanel, wxCanvas etc.
<li> Widget classes: wxButton, wxCheckbox, wxChoice, wxListBox, wxListCtrl, wxText, wxGauge etc.
<li> Data structures: wxList, wxString, wxHashTable, wxDate etc.
<li> Layout/constraint system
<li> GDI classes: wxPen, wxBrush, wxFont, wxBitmap etc.
<li> Events: wxCommandEvent, wxMouseEvent, wxKeyEvent etc.
<li> Devices contexts: wxCanvasDC, wxPostScriptDC, wxMemoryDC, wxPrinterDC
<li> Base classes for runtime-type information: wxObject
<li> Interprocess communication: wxClient, wxConnection, wxSocket, wxServer etc.
<li> Document-view architecture: wxDocument, wxView, wxDocManager etc.
<li> Printing framework: wxPreviewFrame, wxPrintDialog, wxPrinter etc.
<li> Many helper classes, wxApplication, wxTypeTree, wxPathList etc.
<li> Classes for internationalization
<li> Built-in memory leak checking, log-files
<li> A multitude of functions and macros
</dl>
<hr>
<h3>Copyright</h3>
The choice of a suitable copyright has been subject to endless discussions. It
has always been the aim, to put wxWindows under a copyright, which protects
the work of its authors while at the same time encouraging the use of wxWindows
in as many projects as possible.
<p>
The (so far) last decision has been to put the whole of wxWindows
under a modified (less restrictive) version of the GNU library general
public license.
<p>
The only exception is that wxGTK now contains code (gdk_imlib) which is
under the GNU library general public license. When you make changes to
this part of wxGTK, you'll have to make these changes public (in contrast
to changes to the rest).
<p>
It is obviously encouraged that anybody who uses wxWindows and who
makes any improvements to it will make these changes available to
wxWindows' authors.
<p>
<hr>
<h3>What can I do with wxWindows 2.0?</h3>
wxWindows is still in alpha stage, which means that there are still bugs
waiting for you and several features are not yet (fully) implemented, but
you can expect the interface to be more or less stable, so no major
modifications will have to be made to your source code. wxGTK is already
used in a number of medium sized projects and is it being developped
in close cooperation with the authors of these applications.
<p>
<hr>
<h3>Can I write a GNOME application with wxGTK 2.0?</h3>
Good question. The idea to use wxGTK for the GNOME desktop environment is
quite obvious. When this topic came up on the GNOME mailing list, the GNOME
people have shown an amazingly negative opinion about wxWindows. One reason
might be that several of the main authors of the GNOME-project consider
C++ a "broken language". I don't share that view and I am sure many people
find C++ easier to handle and better suited for GUI programming than C.
<p>
Just recently, the topic of C++ in general and wxGTK in particular appeared
again on the GNOME list. It has shown that - at least - the opinion on C++
on the GNOME list is split.
<p>
There is already a C++ wrapper for the GTK called GTK-- written by Tero Pulkkinen.
It is very small and adds very little overhead to the GTK. If platform
independence is no issue for you and you want to write a small tool
for Linux, you should probably use GTK--. Of course you can use wxGTK
for that, too :-)
<p>
<hr>
<h3>Screenshots</h3>
What would a home page of a GUI be without a screenshot? Well, as wxWindows
is a wrapper around existing widget/item sets, a wxWindows application will
look like any other native Windows, Motif, GTK or Mac application.
<p>
But for those of you, who wouldn't download wxGTK only because there
is no screenshot,
<a href="ftp://ftp.freiburg.linux.de/pub/linux/wxxt/sshot.jpg">here it comes</a>.
<p>
<hr>
<h3>Download 1.68</h3>
Go to the
<a href="ftp://ftp.freiburg.linux.de/pub/linux/wxxt">FTP</a>
section directly.
<p>
There is documentation for version 1.68 in html available.
<a href="ftp://ftp.freiburg.linux.de/pub/linux/wxxt">here</a>. Not yet.
<p>
You can download current wxWindows version 1.68 for Windows, Motif and
XView from
<a href="ftp://ftp.freiburg.linux.de/pub/linux/wxxt">here</a>. Not yet.
<p>
You can download wxXt 1.66d from
<a href="ftp://ftp.freiburg.linux.de/pub/linux/wxxt/wxxt166d.tgz">here</a>.
<p>
<hr>
<h3>Download 2.0 alpha</h3>
There is documentation for version 2.0 in html available.
<a href="ftp://ftp.freiburg.linux.de/pub/linux/wxxt/wxGTK_doc.tgz">here</a>.
<p>
You can download the first alpha for wxWindows 2.0 for Windows from
<a href="ftp://ftp.freiburg.linux.de/pub/linux/wxxt/">here</a>. Not yet.
<p>
You can download the current alpha for wxWindows 2.0 for GTK from
<a href="ftp://ftp.freiburg.linux.de/pub/linux/wxxt/wxGTK-0.12.tgz">here</a>.
<p>
<hr>
<h3>News from wxGTK 0.12</h3>
<p>
PNG, zlib and gdk_imlib code included.
<p>
MDI implementation. More a basis for further testing
than of real value.
<p>
Split "--with-debug" option into two options: "--with-debug_info"
and "--with-debug_flag". The first one sets the "-g" flag when
compiling, the second defines "DEBUG" in setup.h (which is included
from defs.h).
<p>
Merged DocView framework. The sample doesn't compile yet, because
it uses features from wxTextCtrl, which I haven't implemented yet.
<p>
Merged TabCtrl. Doesn't look perfect, but it seems to work.
<p>
Merged remaining classes from the newest wxMSW alpha. (wxDynArray,
wxModule etc.).
<p>
Further updates, bug fixes or additions:
<p>
<dl>
<li> wxYield() (again)
<li> postscript support for bitmaps
<li> spline code merged
<li> several bug fixes
<li> new samples
</dl>
<p>
<hr>
<h3>Known problems</h3>
Missing implementation of:
<dl>
<li>Impossible to set new font in GTK's widgets
<li>Items containing bitmaps
<li>Masks, bitmap handlers (partially done)
<li>Gauge
<li>Combobox
<li>Palettes (colormaps)
<li>Keyboard accelerators for menus
<li>Validation
<li>Clipboard functions
<li>Resources (for use with wxIDE-to-be)
<li>Drag and Drop
<li>Threads, Interprocess communication
<li>Sockets
<li>Database classes
</dl>
<p>
<hr>
<h3>Installation of wxGTK under Linux</h3>
GTK requires an up-to-date version of the
<dl>
<li> GTK (GIMP ToolKit)
</dl>
to be installed as a shared lib on your system. wxGTK is being developped with
version 1.0.1 and it is known not to work with earlier versions.
The GTK library is available from
<a href="ftp://ftp.gtk.org/pub/">somewhere here (gtk.org).</a>
After having typed "make install" the GTK header files should be
in "/usr/local/include". Correct me, if I am wrong.
<p>
Compilation itself works as usual with autoconf:
<dl>
<li> Unpack it to a suitable subdirectory, let's say ~/wxGTK
<li> Type "cd wxGTK"
<li> Type "configure"
<li> Type "make"
</dl>
Some demos use files stored in the source directory of those demos
(e.g. internat uses files in samples/internat) whereas the binaries
will end up in samples/internat/linux. You'll have to copy the binaries
down or call them like "linux/test" from samples/internat. This is
also the case for wxTest (which should display a horse).
<p>
You can create a shared library by adding the option "--with-shared" to
the "configure" command. Afterwards, you'll have to copy the library
~/wxGTK/lib/linux (if you have Linux) to a directory in your LDPATH (e.g. /usr/X11R6/lib)
and run "ldconfig".
<p>
<hr>
<h3>Mailing list for wxGTK</h3>
The mailing list (as well as this page) is called wxxt for more
or less historical reasons.
<p>
You can subsribe to the mailing list by sending a mail to
<a href="mailto:majordomo@wesley.informatik.uni-freiburg.de">majordomo@wesley.informatik.uni-freiburg.de</a>.
This mail must contain the text "subscribe wxxt" in the body (not the subject) of the
mail. You will then get a confirmation that somebody asked majordomo to put you
on the list and you will have to confirm this once again by sending back
the authentisation, which comes in the confirmation mail. The last step
is also described in the actual confirmation mail (I think).
<p>
You can send a mail to the mailing list to the address
<a href="mailto:wxxt@www.freiburg.linux.de">wxxt@www.freiburg.linux.de</a>.
<p>
Unsubscribe by sending "unsubscribe wxxt" to majordomo (see above). Not to
the actual mailing list.
<p>
<hr>
<address>
<br>This page is maintained by <a href="mailto:roebling@sun2.ruf.uni-freiburg.de">Robert Roebling</a>.
Comments, in contrast to junk and flames, welcome.
<p>
Last changed 15th Mai '98.
</address>
</body>
</html>

56
docs/latex/wx/upditer.tex Normal file
View File

@@ -0,0 +1,56 @@
\section{\class{wxUpdateIterator}}\label{wxupdateiterator}
This class is used to iterate through all damaged regions of a window, within an OnPaint call.
To use it, construct an iterator object on the stack and loop through the
regions, testing the object and incrementing the iterator at the end of the loop.
See \helpref{wxScrolledWindow::OnPaint}{wxscrolledwindowonpaint} for an example of use.
\wxheading{Derived from}
\helpref{wxObject}{wxobject}
\wxheading{See also}
\helpref{wxScrolledWindow::OnPaint}{wxscrolledwindowonpaint}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxUpdateIterator::wxUpdateIterator}
\func{}{wxUpdateIterator}{\param{wxWindow* }{window}}
Creates an iterator object.
\membersection{wxUpdateIterator::GetX}
\func{int}{GetX}{\void}
Returns the x value for the current region.
\membersection{wxUpdateIterator::GetY}
\func{int}{GetY}{\void}
Returns the y value for the current region.
\membersection{wxUpdateIterator::GetWidth}
\func{int}{GetWidth}{\void}
Returns the width value for the current region.
\membersection{wxUpdateIterator::GetHeight}
\func{int}{GetWidth}{\void}
Returns the width value for the current region.
\membersection{wxUpdateIterator::operator $++$}
\func{void}{operator $++$}{\void}
Increments the iterator to the next region.

107
docs/latex/wx/winhelp.tex Normal file
View File

@@ -0,0 +1,107 @@
\section{\class{wxWinHelpController}}\label{wxwinhelpcontroller}
This class provides the means to control a WinHelp instance.
Under Windows, wxHelpController is defined to be a synonym for wxWinHelpController.
A help controller allows an application to display help, at the contents
or at a particular topic, and shut the help program down on termination.
This avoids proliferation of many instances of the help viewer whenever the
user requests a different topic via the application's menus or buttons.
Typically, an application will create a help controller instance
when it starts, and immediately call {\bf Initialize}\rtfsp
to associate a filename with it. The help viewer will only get run, however,
just before the first call to display something.
\wxheading{Derivation}
\helpref{wxObject}{wxobject}
\wxheading{See also}
\helpref{wxHelpControllerBase}{wxhelpcontrollerbase}
\wxheading{Include file}
{\tt <wx/help.h>}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxWinHelpController::wxWinHelpController}
\func{}{wxWinHelpController}{\void}
Constructs a help instance object, but does not invoke the help viewer.
\membersection{wxWinHelpController::\destruct{wxWinHelpController}}
\func{}{\destruct{wxWinHelpController}}{\void}
Destroys the help instance, closing down the viewer if it is running.
\membersection{wxWinHelpController::Initialize}\label{wxwinhelpcontrollerinitialize}
\func{void}{Initialize}{\param{const wxString\& }{file}}
Initializes the help instance with a help filename. Does not invoke the help viewer.
This must be called directly after the help instance object is created and before
any attempts to communicate with the viewer.
You may omit the file extension and a suitable one will be chosen.
\membersection{wxWinHelpController::DisplayBlock}\label{wxwinhelpcontrollerdisplayblock}
\func{bool}{DisplayBlock}{\param{long}{ blockNo}}
If the help viewer is not running, runs it and displays the file at the given block number.
The interpretation of {\it blockNo} differs between help viewers. If using Windows Help, this
refers to the context number.
\membersection{wxWinHelpController::DisplayContents}\label{wxwinhelpcontrollerdisplaycontents}
\func{bool}{DisplayContents}{\void}
If the help viewer is not running, runs it and displays the
contents.
\membersection{wxWinHelpController::DisplaySection}\label{wxwinhelpcontrollerdisplaysection}
\func{bool}{DisplaySection}{\param{int}{ sectionNo}}
DisplaySection does not apply to WinHelp.
\membersection{wxWinHelpController::KeywordSearch}\label{wxwinhelpcontrollerkeywordsearch}
\func{bool}{KeywordSearch}{\param{const wxString\& }{keyWord}}
If the help viewer is not running, runs it, and searches for sections matching the given keyword. If one
match is found, the file is displayed at this section. If more than one
match is found, the first topic is displayed (Windows Help).
\membersection{wxWinHelpController::LoadFile}\label{wxwinhelpcontrollerloadfile}
\func{bool}{LoadFile}{\param{const wxString\& }{file = NULL}}
If the help viewer is not running, runs it and loads the given file.
If the filename is not supplied or is
NULL, the file specified in {\bf Initialize} is used. If the viewer is
already displaying the specified file, it will not be reloaded. This
member function may be used before each display call in case the user
has opened another file.
\membersection{wxWinHelpController::OnQuit}\label{wxwinhelpcontrolleronquit}
\func{bool}{OnQuit}{\void}
Overridable member called when this application's viewer is quit by the user.
Not implemented.
\membersection{wxWinHelpController::Quit}\label{wxwinhelpcontrollerquit}
\func{bool}{Quit}{\void}
If the viewer is running, quits it by disconnecting.
For Windows Help, the viewer will only close if no other application is using it.

74
include/wx/fstream.h Normal file
View File

@@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// Name: fstream.h
// Purpose: File stream classes
// Author: Guilhem Lavaux
// Modified by:
// Created: 11/07/98
// RCS-ID: $Id$
// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WXFSTREAM_H__
#define _WX_WXFSTREAM_H__
#ifdef __GNUG__
#pragma interface "fstream.h"
#endif
#include <wx/object.h>
#include <wx/string.h>
#include <wx/stream.h>
#include <wx/file.h>
class wxFileInputStream: public wxInputStream {
public:
wxFileInputStream(const wxString& ifileName);
wxFileInputStream(wxFile& file);
wxFileInputStream(int fd);
virtual ~wxFileInputStream();
virtual char Peek();
bool Ok() const { return m_file->IsOpened(); }
protected:
wxFileInputStream();
size_t OnSysRead(void *buffer, size_t size);
off_t OnSysSeek(off_t pos, wxSeekMode mode);
off_t OnSysTell() const;
protected:
wxFile *m_file;
bool m_file_destroy;
};
class wxFileOutputStream: public wxOutputStream {
public:
wxFileOutputStream(const wxString& fileName);
wxFileOutputStream(wxFile& file);
wxFileOutputStream(int fd);
virtual ~wxFileOutputStream();
// To solve an ambiguity on GCC
inline wxOutputStream& Write(const void *buffer, size_t size)
{ return wxOutputStream::Write(buffer, size); }
void Sync();
bool Ok() const { return m_file->IsOpened(); }
protected:
wxFileOutputStream();
size_t OnSysWrite(const void *buffer, size_t size);
off_t OnSysSeek(off_t pos, wxSeekMode mode);
off_t OnSysTell() const;
protected:
wxFile *m_file;
bool m_file_destroy;
};
#endif

6
install/unix/.cvsignore Normal file
View File

@@ -0,0 +1,6 @@
configure
config.cache
config.status
Linux.system.cache
linux-gnu.system.cache
system.list

64
misc/imlib/im_palette.pal Normal file
View File

@@ -0,0 +1,64 @@
0x0 0x0 0x0
0xff 0xff 0xff
0xdd 0xdd 0xdd
0xbb 0xbb 0xbb
0x99 0x99 0x99
0x77 0x77 0x77
0x55 0x55 0x55
0x33 0x33 0x33
0x88 0x0 0x0
0xcc 0x0 0x0
0xff 0x0 0x0
0xff 0x44 0x0
0xff 0x88 0x0
0xff 0xcc 0x0
0xff 0xff 0x0
0xcc 0xcc 0x0
0x88 0x88 0x0
0x60 0x60 0x0
0x0 0x43 0x0
0x0 0x7f 0x0
0x0 0xcc 0x0
0x0 0xff 0x0
0x0 0x44 0x44
0x0 0x88 0x88
0x0 0xff 0xff
0x0 0x0 0x44
0x0 0x0 0x88
0x0 0x0 0xff
0xff 0xcc 0x97
0xef 0xb1 0x7b
0xdf 0x98 0x5f
0xbf 0x87 0x56
0x9f 0x6b 0x42
0x7f 0x57 0x26
0x5f 0x39 0xc
0x3f 0x1c 0x0
0x21 0x0 0x0
0x0 0x43 0x87
0x2d 0x70 0xaf
0x5a 0x9e 0xd7
0x87 0xcc 0xff
0xff 0xe0 0xba
0x21 0x43 0xf
0x3d 0x5d 0x25
0x59 0x78 0x3a
0x75 0x93 0x4f
0x91 0xae 0x64
0xad 0xc8 0x7a
0xf0 0xa8 0xef
0xd0 0x88 0xd0
0xaf 0x66 0xaf
0x8e 0x44 0x8e
0x6d 0x22 0x6d
0x4b 0x0 0x4b
0xff 0xc0 0xbc
0xff 0x93 0x91
0xff 0x66 0x67
0xd8 0xf2 0xbf
0xff 0xc9 0x68
0xff 0x96 0x67
0xa5 0x60 0xff
0x51 0xff 0x99
0x3f 0xa5 0x63
0x98 0x90 0x67

99
misc/imlib/imrc Normal file
View File

@@ -0,0 +1,99 @@
################################
# Config file for Imlib #
################################
# The file that contains palette entries for a global palette for all Imlib
# based programs.
# options: full path to palette file
PaletteFile /etc/im_palette.pal
# This defines if when the display is greater than 8 bit, that it still remaps
# the images to the palette defined, rather than using "perfect" rendering
# options: yes/no
PaletteOverride no
# If remapping to the palette, whether to use Floyd-Steinberg dithering. Saying
# yes will slow things down though.
# options: yes/no
Dither yes
# when remapping to the palette, saying fast will reduce accuracy, but improve
# speed quite considerably
# options: fast/slow
Remap fast
# This turns on dithering for 15/16 bpp. This makes smooth gradients look much
# smoother - in fact almost perfect. You will find it nigh impossible to tell
# the difference between 15/16bpp dithered and 24bpp. Unless you have extra
# CPU to burn, its not recommended, unless you are a image quality freak, and
# you insist on maximum quality in 15/16bpp. It does slow things down. It
# would be best to leave it off and let the applications themselves allow
# you to select it for certain purposes only.
HighQuality off
# This option if specified off will force MIT-SHM off, otherwise will allow
# Imlib to work it out itself.
Mit-Shm on
# This will turn shared pixmaps on or off (off forces off, on lets imlib
# work it out). This is yet another speedup. leave it on unless it doesn't
# work.. then turn it off.
SharedPixmaps off
# This speeds up rendering considerably, but may not work on your hardware
# due to it bypassing a few layers and byte-twiddling the rendered image data
# manually, and due to endianess, bit-ordering or RGB ordering it may screw up
# and not work, so try it.. if things work great!, if not, wait until a
# renderer for your situation is written, or write one yourself and donate
# it. It's easy to do, just look at rend.c
FastRender on
# This is in fact a workaround due to Solaris's shared memory theories.
# This specifies the maximum size of a shared memory chunk in bytes. If an
# image is larger that this in bytes for the video mode you're in, imlib will
# not use MIT-SHM. if you comment this out, imlib will use as much memory as
# necessary to render the image.
# Shm_Max_Size 1000000
# This turns Image loading (24) bit caching on or off. HIGHLY suggested to be
# turned ON!
Image_Cache on
# Image cache size in bytes. As with any cache, the more, the better. If you
# load the same image more than once. Imlib will used a previously loaded
# copy, and if its freed, the Image_Cache_Size amount of bytes of image data
# are kept even after being freed, in case the same image is loaded again soon
# afterwards. Neat eh?
Image_Cache_Size 4000000
# This turns the pixmap caching system on or off. If on, only well-behaved
# programs that conform to the specs for using Imlib will exhibit the
# behavior as expected. It is suggested to leave this on, as it will boost
# performance considerably, speed-wise and memory-wise. The reason apps need
# to be well-behaved is so that they don't go drawing on, and XFreePixmap'ing
# these pixmaps themselves, because this will trample all over the cache
# and give very horrid effects, or even make the apps crash with segfaults or
# Xlib errors.
Pixmap_Cache on
# Pixmap cache is in **-> BITS <-**... the end result is APPROXIMATELY
# 10000000 bits of pixmap make your Xserver grow by 1Mb of RAM (VERY rough).
# As with any cache, the more, the better. The more you have, the less likely
# it is that you will get cache misses and so performance on scaling the same
# image to commonly used sizes (ie if 3 or 4 sizes of the same image are used)
# will be lightning fast, in fact in some tests I did, in 16bpp up to 38 times
# as fast, and in 8bpp (with dithering on) up to 105 times faster!!! (these
# are nominal figures obtained on my machine. these are MAXIMUM speedup
# results. Results may vary on other machines and according to the way
# programs are written and use Imlib)
Pixmap_Cache_Size 40000000
# This FORCES Imlib to use the hexadecimal visual id stated here if it is
# defined in the imrc. This bypasses Imlib's routines that hunt for the best
# visual. You can obtain a list of visual ID's using the xdpyinfo command.
# You should only need this if Imlib doesn't pick the correct visual or you
# have strange hardware/Xserver combinations.
#ForceVisualID 22
# This allows Imlib to fall back on Imagemagick and/or NETPBM
# utilities if it can't load the file.
Fallback on
# Default Gamma, Brightness and Contrast stuff....
Gamma 1.0
Brightness 1.0
Contrast 1.0
Red_Gamma 1.0
Red_Brightness 1.0
Red_Contrast 1.0
Green_Gamma 1.0
Green_Brightness 1.0
Green_Contrast 1.0
Blue_Gamma 1.0
Blue_Brightness 1.0
Blue_Contrast 1.0

View File

@@ -1,113 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: minimal.cpp
// Purpose: Dynamic events wxWindows sample
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "minimal.cpp"
#pragma interface "minimal.cpp"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
// Define a new application type
class MyApp: public wxApp
{ public:
bool OnInit(void);
};
// Define a new frame type
class MyFrame: public wxFrame
{ public:
MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
public:
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
bool OnClose(void) { return TRUE; }
};
// ID for the menu commands
#define MINIMAL_QUIT 1
#define MINIMAL_TEXT 101
#define MINIMAL_ABOUT 102
// Create a new application object
IMPLEMENT_APP (MyApp)
// `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit(void)
{
// Create the main frame window
MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "Minimal wxWindows App", 50, 50, 450, 340);
frame->Connect( MINIMAL_QUIT, -1, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)MyFrame::OnQuit );
frame->Connect( MINIMAL_ABOUT, -1, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)MyFrame::OnAbout );
// Give it an icon
#ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian"));
#else
frame->SetIcon(wxIcon(mondrian_xpm));
#endif
// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(MINIMAL_ABOUT, "&About");
file_menu->Append(MINIMAL_QUIT, "E&xit");
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
frame->SetMenuBar(menu_bar);
// Make a panel with a message
wxPanel *panel = new wxPanel(frame, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL);
(void)new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), 0);
// Show the frame
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
// My frame constructor
MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h):
wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
{}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
{
wxMessageDialog dialog(this, "This is a minimal sample\nA second line in the message box",
"About Minimal", wxYES_NO|wxCANCEL);
dialog.ShowModal();
}

26
src/gdk_imlib/AUDIT Normal file
View File

@@ -0,0 +1,26 @@
Audit status of gdk_imlib so far:
cache.c appears clean
globals.c appears clean
load.c:
JPEG, PNG, GIF and TIFF loaders seem safe but the underlying
yet libraries have not been checked
Helper stuff should now be safe.
misc.c
The obvious screwups have been remedied with the usual
length checking sscanfs and snprintfs.
Rewrote a little of the parsing code to avoid future problems.
rend.c
Appears ok
save.c
Some stuff has been fixed. The helpers should be safe but
are incomplete
utils.c
Ok this seems clean now. There's a few FIXME's but they are
either new features (helper needs %Q) or bogus but non fatal
stuff

1
src/gdk_imlib/AUTHORS Normal file
View File

@@ -0,0 +1 @@
Rasterdude :-) <raster@redhat.com>

481
src/gdk_imlib/COPYING.LIB Normal file
View File

@@ -0,0 +1,481 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

74
src/gdk_imlib/ChangeLog Normal file
View File

@@ -0,0 +1,74 @@
1998-05-07 Raja R Harinath <harinath@cs.umn.edu>
* save.c (gdk_imlib_save_image): Replaces `snprintf' with
`g_snprintf' calls.
* utils.c (gdk_imlib_create_image_from_data): Likewise.
Tue May 5 15:11:59 1998 Radek Doulik <gis@academy.cas.cz>
* replaced snprintf calls with g_snprintf ones, so it
compiles now on SunOS
Sat Apr 11 12:30:13 1998 George Lebl <jirka@5z.com>
* utils.c: fixed yet one more SIGFPE on alpha
Fri Mar 20 00:02:43 1998 Tom Tromey <tromey@cygnus.com>
* gdk_imlib.h: Replaced `()' with `(void)'.
Sun Mar 15 12:34:45 1998 Owen Taylor <owt1@cornell.edu>
* Makefile.am (INCLUDES): Added GTK_CFLAGS
1998-02-25 Raja R Harinath <harinath@cs.umn.edu>
* Makefile.am (DEFS): Define `SYSTEM_IMRC' too.
1998-02-25 Federico Mena Quintero <federico@nuclecu.unam.mx>
* misc.c (gdk_imlib_copy_image): The drawable passed to gdk_gc_new
should be the dest drawable, not the base imlib window. This
caused BadMatches all over the place (especially in copy_mask).
(gdk_imlib_copy_mask): Likewise.
1998-02-24 Raja R Harinath <harinath@cs.umn.edu>
* Makefile.am (DEFS): New var. Moved stuff from CFLAGS.
(INCLUDES): New var.
1998-02-24 Mark Galassi <rosalia@cygnus.com>
* Makefile.am (libgdk_imlib_la_SOURCES):
(lib_LTLIBRARIES): changed gdk_imlib to use the libtool+automake
formalisms.
* load.c (gdk_imlib_load_image): changed JPEG_PATH to DJPEG_PROG
and removed %s/djpeg, sine DJPEG_PROG is the full program path.
1998-02-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
* Makefile.in (install): Make directory for config files.
* configure.in: Fixed ENL_LIB_SUPPORT function for non-existing libraries.
1998-02-16 Federico Mena Quintero <federico@nuclecu.unam.mx>
* misc.c (gdk_imlib_init): I create a colormap specific to the
visual the base_window will be using. This fixes BadMatch errors
on machines with multiple visual/depth combinations.
1998-02-17 The Rasterman <raster@redhat.com>
* misc.c (gdk_imlib_init) Fixed visual stuff slightly, and Colormap
creation (so it only does so if the visual for the default and the
chosen visual mismatch), added function calls to retrieve Imlib's
visual and Colormap, plus endianess fixes for network displaying.
1998-02-17 The Rasterman <raster@redhat.com>
added system imrc config return function
1998-02-18 The Rasterman <raster@redhat.com>
Fixed load.c - missed a not (!) in an if clause

29
src/gdk_imlib/README Normal file
View File

@@ -0,0 +1,29 @@
-------------------------------------------------------------------------------
I M L I B
1.4
-------------------------------------------------------------------------------
This software is Copyright (C) 1998 By The Rasterman (Carsten Haitzler). I
accept no responsability for anythign this software may or may not do to
your system - you use it completely at your own risk. This software comes
under the LGPL and GPL licences. The library itself is LGPL (all software in
Imlib and gdk_imlib directories) see the COPYING and COPYING.LIB files for
full legal details.
-------------------------------------------------------------------------------
If you have picked up a net release of imlib you should be able to
just follow the instructions in the INSTALL file.
If you are using imlib out of the CVS repository, then you need to
have some extra tools installed, and the configuration process is
lengthier. the HACKING file has all the details for building from a
CVS checkout.
Imlib will run MARKEDLY better if you get certain libraries. Notably,
libjpeg, libpng, libtiff and libgif. For more information please go look at:
http://www.labs.redhat.com/imlib/
This will give links to everything you need or may want for Imlib's optimal
functionality.

496
src/gdk_imlib/cache.c Normal file
View File

@@ -0,0 +1,496 @@
#define _GNU_SOURCE
#include "../gdk_imlib/gdk_imlib.h"
#include "../gdk_imlib/gdk_imlib_private.h"
/* uncomment this to compile imlib's cahce with pixmap accounting output */
/*#define PIXMAP_ACCOUNTING */
void
gdirty_pixmaps(GdkImlibImage * im)
{
struct pixmap_cache *ptr;
ptr = id->cache.pixmap;
while (ptr)
{
if ((ptr->im == im) && ((!ptr->file) || (!strcmp(im->filename, ptr->file))))
ptr->dirty = 1;
ptr = ptr->next;
}
}
void
gdirty_images(GdkImlibImage * im)
{
struct image_cache *ptr;
ptr = id->cache.image;
while (ptr)
{
if ((!strcmp(im->filename, ptr->file)) && (im == ptr->im))
{
ptr->dirty = 1;
return;
}
ptr = ptr->next;
}
}
void
gfind_pixmap(GdkImlibImage * im, int width, int height, GdkPixmap ** pmap, GdkBitmap ** mask)
{
struct pixmap_cache *ptr;
ptr = id->cache.pixmap;
while (ptr)
{
if ((ptr->im == im) && (ptr->width == width) && (ptr->height == height) &&
((!ptr->file) || (!strcmp(im->filename, ptr->file))) &&
(!ptr->dirty))
{
if (ptr->refnum > 0)
ptr->refnum++;
else
{
ptr->refnum++;
id->cache.num_pixmap++;
if (ptr->pmap)
id->cache.used_pixmap -= width * height * id->x.depth;
if (ptr->shape_mask)
id->cache.used_pixmap -= width * height;
if (id->cache.used_pixmap < 0)
{
id->cache.used_pixmap = 0;
fprintf(stderr, "IMLIB: uhoh.. caching problems.... meep meep\n");
}
}
if (ptr->prev)
{
ptr->prev->next = ptr->next;
if (ptr->next)
ptr->next->prev = ptr->prev;
ptr->next = id->cache.pixmap;
ptr->next->prev = ptr;
id->cache.pixmap = ptr;
ptr->prev = NULL;
}
*pmap = ptr->pmap;
*mask = ptr->shape_mask;
return;
}
ptr = ptr->next;
}
*pmap = NULL;
*mask = NULL;
}
GdkImlibImage *
gfind_image(char *file)
{
struct image_cache *ptr;
ptr = id->cache.image;
while (ptr)
{
if ((!strcmp(file, ptr->file)) && (!ptr->dirty))
{
if (ptr->refnum)
ptr->refnum++;
else
{
ptr->refnum++;
id->cache.num_image++;
id->cache.used_image -= ptr->im->rgb_width * ptr->im->rgb_height * 3;
if (id->cache.used_image < 0)
{
id->cache.used_image = 0;
fprintf(stderr, "IMLIB: uhoh.. caching problems.... meep meep\n");
}
}
if (ptr->prev)
{
ptr->prev->next = ptr->next;
if (ptr->next)
ptr->next->prev = ptr->prev;
ptr->next = id->cache.image;
ptr->next->prev = ptr;
id->cache.image = ptr;
ptr->prev = NULL;
}
return ptr->im;
}
ptr = ptr->next;
}
return NULL;
}
void
gfree_pixmappmap(GdkPixmap * pmap)
{
struct pixmap_cache *ptr;
ptr = id->cache.pixmap;
while (ptr)
{
if ((ptr->pmap == pmap) || (ptr->shape_mask == pmap))
{
if (ptr->shape_mask == pmap)
return;
if (ptr->refnum > 0)
{
ptr->refnum--;
if (ptr->refnum == 0)
{
id->cache.num_pixmap--;
if (ptr->pmap)
id->cache.used_pixmap += ptr->width * ptr->height * id->x.depth;
if (ptr->shape_mask)
id->cache.used_pixmap += ptr->width * ptr->height;
}
}
return;
}
ptr = ptr->next;
}
gdk_pixmap_unref(pmap);
}
void
gfree_image(GdkImlibImage * im)
{
struct image_cache *ptr;
ptr = id->cache.image;
while (ptr)
{
if (im == ptr->im)
{
if (ptr->refnum)
{
ptr->refnum--;
if (!ptr->refnum)
{
id->cache.num_image--;
id->cache.used_image += ptr->im->rgb_width * ptr->im->rgb_height * 3;
}
}
return;
}
ptr = ptr->next;
}
gnullify_image(im);
}
void
gflush_image(GdkImlibImage * im)
{
if (im)
im->cache = 0;
}
void
gadd_image(GdkImlibImage * im, char *file)
{
struct image_cache *ptr;
struct image_cache *n;
if ((!im) || (!file))
return;
ptr = id->cache.image;
n = malloc(sizeof(struct image_cache));
if (!n)
return;
n->prev = NULL;
n->next = ptr;
n->file = malloc(strlen(file) + 1);
if (!n->file)
{
free(n);
return;
}
strcpy(n->file, file);
n->im = im;
n->refnum = 1;
n->dirty = 0;
if (n->next)
n->next->prev = n;
id->cache.image = n;
id->cache.num_image++;
}
void
gadd_pixmap(GdkImlibImage * im, int width, int height, XImage * xim, XImage * sxim)
{
struct pixmap_cache *ptr;
struct pixmap_cache *n;
if (!im)
return;
ptr = id->cache.pixmap;
n = malloc(sizeof(struct pixmap_cache));
if (!n)
return;
n->prev = NULL;
n->next = ptr;
n->im = im;
if (im->filename)
{
n->file = malloc(strlen(im->filename) + 1);
if (n->file)
strcpy(n->file, im->filename);
}
else
n->file = NULL;
n->refnum = 1;
n->dirty = 0;
n->width = width;
n->height = height;
n->pmap = im->pixmap;
n->shape_mask = im->shape_mask;
n->xim = xim;
n->sxim = sxim;
if (n->next)
n->next->prev = n;
id->cache.pixmap = n;
id->cache.num_pixmap++;
}
void
gclean_caches()
{
{
struct image_cache *ptr = NULL;
struct image_cache *pptr = NULL;
struct image_cache *last = NULL;
int newlast;
/* find the back of the list */
ptr = id->cache.image;
while (ptr)
{
last = ptr;
ptr = ptr->next;
}
newlast = 0;
ptr = last;
/* remove all images that are tagged non-cachable, and have 0 */
/* references , even if the cache has spare room. */
while (ptr)
{
if (!ptr->refnum)
{
if (!ptr->im->cache)
{
if (ptr == last)
newlast = 1;
id->cache.used_image -= ptr->im->rgb_width * ptr->im->rgb_height * 3;
gnullify_image(ptr->im);
if (pptr)
ptr = pptr->prev;
if (ptr->prev)
ptr->prev->next = ptr->next;
else
id->cache.image = ptr->next;
if (ptr->next)
ptr->next->prev = ptr->prev;
if (ptr->file)
free(ptr->file);
free(ptr);
ptr = NULL;
}
}
if (ptr)
ptr = ptr->prev;
if (newlast)
{
last = NULL;
ptr = id->cache.image;
while (ptr)
{
last = ptr;
ptr = ptr->next;
}
newlast = 0;
ptr = last;
}
}
/* find the back of the list */
ptr = id->cache.image;
last = NULL;
while (ptr)
{
last = ptr;
ptr = ptr->next;
}
newlast = 0;
ptr = last;
/* while the amount of data in the cache is greater than the set */
/* amount, delete the last entry (last used) from the unreferenced */
/* cached 24-bit images */
while (id->cache.used_image > id->cache.size_image)
{
while (ptr)
{
if (ptr->refnum < 1)
{
if (ptr == last)
newlast = 1;
id->cache.used_image -= ptr->im->rgb_width * ptr->im->rgb_height * 3;
gnullify_image(ptr->im);
if (ptr->prev)
ptr->prev->next = ptr->next;
else
id->cache.image = ptr->next;
if (ptr->next)
ptr->next->prev = ptr->prev;
if (ptr->file)
free(ptr->file);
free(ptr);
ptr = NULL;
break;
}
if (ptr)
ptr = ptr->prev;
}
if (newlast)
{
last = NULL;
ptr = id->cache.image;
while (ptr)
{
last = ptr;
ptr = ptr->next;
}
newlast = 0;
ptr = last;
}
if (!ptr)
break;
}
}
{
struct pixmap_cache *ptr;
struct pixmap_cache *last;
int newlast;
#ifdef PIXMAP_ACCOUNTING
int total, total2, num, num2;
printf("--------- Pixmap cashe zise %i / %i with %i pixmaps referenced\n",
id->cache.used_pixmap, id->cache.size_pixmap,
id->cache.num_pixmap);
ptr = id->cache.pixmap;
total = 0;
total2 = 0;
num = 0;
num2 = 0;
while (ptr)
{
printf("Pmap for file %s REFNUM %3i SIZE %4ix%4i PMAP %8x MASK %8x\n",
ptr->file, ptr->refnum, ptr->width, ptr->height, ptr->pmap,
ptr->shape_mask);
if (ptr->refnum > 0)
{
total += (ptr->width * ptr->height * id->x.depth);
if (ptr->shape_mask)
total += (ptr->width * ptr->height);
num++;
}
else
{
total2 += (ptr->width * ptr->height * id->x.depth);
if (ptr->shape_mask)
total2 += (ptr->width * ptr->height);
num2++;
}
ptr = ptr->next;
}
printf("Accounting Data:\n");
printf("*** total pixmap's in cache %i with %i pixmaps\n",
total, num);
printf("*** total unreffed pixmap's in cache %i with %i pixmaps\n\n",
total2, num2);
#endif
/* find the back of the list */
ptr = id->cache.pixmap;
last = NULL;
while (ptr)
{
last = ptr;
ptr = ptr->next;
}
newlast = 0;
ptr = last;
/* while the amount of data in the cache is greater than the set */
/* amount, delete the last entry (last used) from the unreferenced */
/* cached pixmaps */
while (id->cache.used_pixmap > id->cache.size_pixmap)
{
while (ptr)
{
if (ptr->refnum < 1)
{
if (ptr == last)
newlast = 1;
if (ptr->pmap)
id->cache.used_pixmap -= ptr->width * ptr->height * id->x.depth;
if (ptr->shape_mask)
id->cache.used_pixmap -= ptr->width * ptr->height;
if (ptr->pmap)
gdk_pixmap_unref(ptr->pmap);
if (ptr->shape_mask)
gdk_pixmap_unref(ptr->shape_mask);
if (ptr->xim)
XDestroyImage(ptr->xim);
if (ptr->sxim)
XDestroyImage(ptr->sxim);
if (ptr->prev)
ptr->prev->next = ptr->next;
else
id->cache.pixmap = ptr->next;
if (ptr->next)
ptr->next->prev = ptr->prev;
if (ptr->file)
free(ptr->file);
free(ptr);
ptr = NULL;
break;
}
if (ptr)
ptr = ptr->prev;
}
if (newlast)
{
last = NULL;
ptr = id->cache.pixmap;
while (ptr)
{
last = ptr;
ptr = ptr->next;
}
newlast = 0;
ptr = last;
}
if (!ptr)
break;
}
}
}
void
gnullify_image(GdkImlibImage * im)
{
if (!im)
return;
if (im->rgb_data)
free(im->rgb_data);
if (im->alpha_data)
free(im->alpha_data);
if (im->pixmap)
gfree_pixmappmap(im->pixmap);
if (im->filename)
free(im->filename);
free(im);
}

113
src/gdk_imlib/colors.c Normal file
View File

@@ -0,0 +1,113 @@
#define _GNU_SOURCE
#include "../gdk_imlib/gdk_imlib.h"
#include "../gdk_imlib/gdk_imlib_private.h"
void
g_PaletteAlloc(int num, int *cols)
{
XColor xcl;
int i;
int r, g, b;
if (id->palette)
free(id->palette);
id->palette = malloc(sizeof(GdkImlibColor) * num);
if (id->palette_orig)
free(id->palette_orig);
id->palette_orig = malloc(sizeof(GdkImlibColor) * num);
for (i = 0; i < num; i++)
{
r = cols[(i * 3) + 0];
g = cols[(i * 3) + 1];
b = cols[(i * 3) + 2];
xcl.red = (unsigned short)((r << 8) | (r));
xcl.green = (unsigned short)((g << 8) | (g));
xcl.blue = (unsigned short)((b << 8) | (b));
xcl.flags = DoRed | DoGreen | DoBlue;
XAllocColor(id->x.disp, id->x.root_cmap, &xcl);
id->palette[i].r = xcl.red >> 8;
id->palette[i].g = xcl.green >> 8;
id->palette[i].b = xcl.blue >> 8;
id->palette[i].pixel = xcl.pixel;
id->palette_orig[i].r = r;
id->palette_orig[i].g = g;
id->palette_orig[i].b = b;
id->palette_orig[i].pixel = xcl.pixel;
}
id->num_colors = num;
}
gint
gdk_imlib_load_colors(char *file)
{
FILE *f;
char s[256];
int i;
int pal[768];
int r, g, b;
int rr, gg, bb;
f = fopen(file, "r");
if (!f)
{
fprintf(stderr, "GImLib ERROR: Cannot find palette file %s\n", file);
return 0;
}
i = 0;
while (fgets(s, 256, f))
{
if (s[0] == '0')
{
sscanf(s, "%x %x %x", &r, &g, &b);
if (r < 0)
r = 0;
if (r > 255)
r = 255;
if (g < 0)
g = 0;
if (g > 255)
g = 255;
if (b < 0)
b = 0;
if (b > 255)
b = 255;
pal[i++] = r;
pal[i++] = g;
pal[i++] = b;
}
if (i >= 768)
break;
}
fclose(f);
g_PaletteAlloc((i / 3), pal);
if (id->fast_rgb)
free(id->fast_rgb);
id->fast_rgb = malloc(sizeof(int) * 32 * 32 * 32);
for (r = 0; r < 32; r++)
{
for (g = 0; g < 32; g++)
{
for (b = 0; b < 32; b++)
{
rr = (r << 3) | (r >> 2);
gg = (g << 3) | (g >> 2);
bb = (b << 3) | (b >> 2);
INDEX_RGB(r, g, b) = gindex_best_color_match(&rr, &gg, &bb);
}
}
}
return 1;
}
void
gdk_imlib_free_colors()
{
int i;
unsigned long pixels[256];
for (i = 0; i < id->num_colors; i++)
pixels[i] = id->palette[i].pixel;
XFreeColors(id->x.disp, id->x.root_cmap, pixels, id->num_colors, 0);
id->num_colors = 0;
}

2
src/gdk_imlib/config.h Normal file
View File

@@ -0,0 +1,2 @@
#undef PACKAGE
#undef VERSION

78
src/gdk_imlib/gdk_imlib.h Normal file
View File

@@ -0,0 +1,78 @@
#ifndef __GDK_IMLIB_H__
#define __GDK_IMLIB_H__
/* we need this funny include path, because the working directory when */
/* including this might actually be ../gdk/ instead of . */
#include "../gdk_imlib/gdk_imlib_types.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void gdk_imlib_init(void);
void gdk_imlib_init_params(GdkImlibInitParams * p);
gint gdk_imlib_get_render_type(void);
void gdk_imlib_set_render_type(gint rend_type);
gint gdk_imlib_load_colors(char *file);
GdkImlibImage *gdk_imlib_load_image(char *file);
gint gdk_imlib_best_color_match(gint * r, gint * g, gint * b);
gint gdk_imlib_render(GdkImlibImage * image, gint width, gint height);
GdkPixmap *gdk_imlib_copy_image(GdkImlibImage * image);
GdkBitmap *gdk_imlib_copy_mask(GdkImlibImage * image);
GdkPixmap *gdk_imlib_move_image(GdkImlibImage * image);
GdkBitmap *gdk_imlib_move_mask(GdkImlibImage * image);
void gdk_imlib_destroy_image(GdkImlibImage * image);
void gdk_imlib_kill_image(GdkImlibImage * image);
void gdk_imlib_free_colors(void);
void gdk_imlib_free_pixmap(GdkPixmap * pixmap);
void gdk_imlib_free_bitmap(GdkBitmap * bitmap);
void gdk_imlib_get_image_border(GdkImlibImage * image, GdkImlibBorder * border);
void gdk_imlib_set_image_border(GdkImlibImage * image, GdkImlibBorder * border);
void gdk_imlib_get_image_shape(GdkImlibImage * image, GdkImlibColor * color);
void gdk_imlib_set_image_shape(GdkImlibImage * image, GdkImlibColor * color);
gint gdk_imlib_save_image_to_eim(GdkImlibImage * image, char *file);
gint gdk_imlib_add_image_to_eim(GdkImlibImage * image, char *file);
gint gdk_imlib_save_image_to_ppm(GdkImlibImage * image, char *file);
gint gdk_imlib_load_file_to_pixmap(char *filename, GdkPixmap ** pmap, GdkBitmap ** mask);
void gdk_imlib_set_image_modifier(GdkImlibImage * im, GdkImlibColorModifier * mod);
void gdk_imlib_set_image_red_modifier(GdkImlibImage * im, GdkImlibColorModifier * mod);
void gdk_imlib_set_image_green_modifier(GdkImlibImage * im, GdkImlibColorModifier * mod);
void gdk_imlib_set_image_blue_modifier(GdkImlibImage * im, GdkImlibColorModifier * mod);
void gdk_imlib_get_image_modifier(GdkImlibImage * im, GdkImlibColorModifier * mod);
void gdk_imlib_get_image_red_modifier(GdkImlibImage * im, GdkImlibColorModifier * mod);
void gdk_imlib_get_image_green_modifier(GdkImlibImage * im, GdkImlibColorModifier * mod);
void gdk_imlib_get_image_blue_modifier(GdkImlibImage * im, GdkImlibColorModifier * mod);
void gdk_imlib_set_image_red_curve(GdkImlibImage * im, unsigned char *mod);
void gdk_imlib_set_image_green_curve(GdkImlibImage * im, unsigned char *mod);
void gdk_imlib_set_image_blue_curve(GdkImlibImage * im, unsigned char *mod);
void gdk_imlib_get_image_red_curve(GdkImlibImage * im, unsigned char *mod);
void gdk_imlib_get_image_green_curve(GdkImlibImage * im, unsigned char *mod);
void gdk_imlib_get_image_blue_curve(GdkImlibImage * im, unsigned char *mod);
void gdk_imlib_apply_modifiers_to_rgb(GdkImlibImage * im);
void gdk_imlib_changed_image(GdkImlibImage * im);
void gdk_imlib_apply_image(GdkImlibImage * im, GdkWindow * p);
void gdk_imlib_paste_image(GdkImlibImage * im, GdkWindow * p, gint x, gint y, gint w, gint h);
void gdk_imlib_paste_image_border(GdkImlibImage * im, GdkWindow * p, gint x, gint y, gint w, gint h);
void gdk_imlib_flip_image_horizontal(GdkImlibImage * im);
void gdk_imlib_flip_image_vertical(GdkImlibImage * im);
void gdk_imlib_rotate_image(GdkImlibImage * im, gint d);
GdkImlibImage *gdk_imlib_create_image_from_data(unsigned char *data, unsigned char *alpha, gint w, gint h);
GdkImlibImage *gdk_imlib_clone_image(GdkImlibImage * im);
GdkImlibImage *gdk_imlib_clone_scaled_image(GdkImlibImage * im, int w, int h);
gint gdk_imlib_get_fallback(void);
void gdk_imlib_set_fallback(gint fallback);
GdkVisual *gdk_imlib_get_visual(void);
GdkColormap *gdk_imlib_get_colormap(void);
gchar *gdk_imlib_get_sysconfig(void);
GdkImlibImage *gdk_imlib_create_image_from_xpm_data(char **data);
gint gdk_imlib_data_to_pixmap(char **data, GdkPixmap ** pmap, GdkBitmap ** mask);
void gdk_imlib_crop_image(GdkImlibImage * im, gint x, gint y, gint w, gint h);
gint gdk_imlib_save_image(GdkImlibImage * im, char *file, GdkImlibSaveInfo * info);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,226 @@
#ifdef _HAVE_STRING_H
#include <string.h>
#elif _HAVE_STRINGS_H
#include <strings.h>
#endif
#ifndef CONVERT_PATH
#define CONVERT_PATH "/usr/X11/bin"
#endif
#ifndef NETPBM_PATH
#define NETPBM_PATH "/usr/local/bin"
#endif
#ifndef CJPEG_PROG
#define CJPEG_PROG "/usr/bin/cjpeg"
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include <netinet/in.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/time.h>
#include <sys/types.h>
#ifdef _HAVE_STRING_H
#include <string.h>
#elif _HAVE_STRINGS_H
#include <strings.h>
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xos.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/shape.h>
#include <X11/cursorfont.h>
#include <gdk/gdkprivate.h>
#ifdef HAVE_LIBJPEG
#include <jpeglib.h>
#endif
#ifdef HAVE_LIBPNG
#include <../png/png.h>
#endif
#ifdef HAVE_LIBTIFF
#include <tiffio.h>
#endif
#ifdef HAVE_LIBGIF
#include <gif_lib.h>
#endif
#define BYTE_ORD_24_RGB 0
#define BYTE_ORD_24_RBG 1
#define BYTE_ORD_24_BRG 2
#define BYTE_ORD_24_BGR 3
#define BYTE_ORD_24_GRB 4
#define BYTE_ORD_24_GBR 5
struct image_cache
{
gchar *file;
GdkImlibImage *im;
gint refnum;
gchar dirty;
struct image_cache *prev;
struct image_cache *next;
};
struct pixmap_cache
{
GdkImlibImage *im;
gchar *file;
gchar dirty;
gint width, height;
GdkPixmap *pmap;
GdkBitmap *shape_mask;
XImage *xim, *sxim;
gint refnum;
struct pixmap_cache *prev;
struct pixmap_cache *next;
};
typedef struct _xdata
{
Display *disp;
gint screen;
Window root;
Visual *visual;
gint depth;
gint render_depth;
Colormap root_cmap;
gchar shm;
gchar shmp;
gint shm_event;
XImage *last_xim;
XImage *last_sxim;
XShmSegmentInfo last_shminfo;
XShmSegmentInfo last_sshminfo;
Window base_window;
GdkWindow *gdk_win;
GdkColormap *gdk_cmap;
}
Xdata;
typedef struct _imlibdata
{
gint num_colors;
GdkImlibColor *palette;
GdkImlibColor *palette_orig;
unsigned char *fast_rgb;
gint *fast_err;
gint *fast_erg;
gint *fast_erb;
gint render_type;
gint max_shm;
Xdata x;
gint byte_order;
struct _cache
{
gchar on_image;
gint size_image;
gint num_image;
gint used_image;
struct image_cache *image;
gchar on_pixmap;
gint size_pixmap;
gint num_pixmap;
gint used_pixmap;
struct pixmap_cache *pixmap;
}
cache;
gchar fastrend;
gchar hiq;
GdkImlibColorModifier mod, rmod, gmod, bmod;
unsigned char rmap[256], gmap[256], bmap[256];
gchar fallback;
gchar ordered_dither;
}
ImlibData;
extern ImlibData *id;
gint gindex_best_color_match(gint * r, gint * g, gint * b);
void gdirty_pixmaps(GdkImlibImage * im);
void gdirty_images(GdkImlibImage * im);
void gfind_pixmap(GdkImlibImage * im, int width, int height, GdkPixmap ** pmap, GdkBitmap ** mask);
GdkImlibImage *gfind_image(char *file);
void gfree_pixmappmap(GdkPixmap * pmap);
void gfree_image(GdkImlibImage * im);
void gflush_image(GdkImlibImage * im);
void gadd_image(GdkImlibImage * im, char *file);
void gadd_pixmap(GdkImlibImage * im, int width, int height, XImage * xim, XImage * sxim);
void gclean_caches();
void gnullify_image(GdkImlibImage * im);
/* char *g_SplitID(char *file); */
char *g_GetExtension(char *file);
#ifdef HAVE_LIBJPEG
unsigned char *g_LoadJPEG(FILE * f, int *w, int *h);
#endif /* HAVE_LIBJPEG */
#ifdef HAVE_LIBPNG
unsigned char *g_LoadPNG(FILE * f, int *w, int *h, int *t);
#endif /* HAVE_LIBPNG */
#ifdef HAVE_LIBTIFF
unsigned char *g_LoadTIFF(char *f, int *w, int *h, int *t);
#endif /* HAVE_LIBTIFF */
#ifdef HAVE_LIBGIF
unsigned char *g_LoadGIF(char *f, int *w, int *h, int *t);
#endif /* HAVE_LIBGIF */
unsigned char *g_LoadXPM(char *f, int *w, int *h, int *t);
unsigned char *g_LoadPPM(FILE * f, int *w, int *h);
/*
static int gispnm(char *file);
static int gisjpeg(char *file);
static int gispng(char *file);
static int gistiff(char *file);
static int giseim(char *file);
static int gisgif(char *file);
static int gisxpm(char *file);
*/
GdkPixmap *gdk_imlib_pixmap_foreign_new(gint width, gint height, gint depth, Pixmap pmap);
void gcalc_map_tables(GdkImlibImage * im);
void g_PaletteAlloc(int num, int *cols);
FILE *open_helper(const char *, const char *, const char *);
int close_helper(FILE *);
#define INDEX_RGB(r,g,b) id->fast_rgb[(r<<10)|(g<<5)|(b)]
#define COLOR_INDEX(i) id->palette[i].pixel
#define COLOR_RGB(r,g,b) id->palette[INDEX_RGB(r,g,b)].pixel
#define ERROR_RED(rr,i) rr-id->palette[i].r;
#define ERROR_GRN(gg,i) gg-id->palette[i].g;
#define ERROR_BLU(bb,i) bb-id->palette[i].b;
#define DITHER_ERROR(Der1,Der2,Dex,Der,Deg,Deb) \
ter=&(Der1[Dex]);\
(*ter)+=(Der*7)>>4;ter++;\
(*ter)+=(Deg*7)>>4;ter++;\
(*ter)+=(Deb*7)>>4;\
ter=&(Der2[Dex-6]);\
(*ter)+=(Der*3)>>4;ter++;\
(*ter)+=(Deg*3)>>4;ter++;\
(*ter)+=(Deb*3)>>4;ter++;\
(*ter)+=(Der*5)>>4;ter++;\
(*ter)+=(Deg*5)>>4;ter++;\
(*ter)+=(Deb*5)>>4;ter++;\
(*ter)+=Der>>4;ter++;\
(*ter)+=Deg>>4;ter++;\
(*ter)+=Deb>>4;

View File

@@ -0,0 +1,101 @@
#include <gdk/gdk.h>
#ifndef SYSTEM_IMRC
#define SYSTEM_IMRC "/etc/imrc"
#endif /* endef SYSTEM_IMRC */
typedef struct _GdkImlibBorder
{
gint left, right;
gint top, bottom;
}
GdkImlibBorder;
typedef struct _GdkImlibColor
{
gint r, g, b;
gint pixel;
}
GdkImlibColor;
typedef struct _GdkImlibColorModifier
{
gint gamma;
gint brightness;
gint contrast;
}
GdkImlibColorModifier;
typedef struct _GdkImlibImage
{
gint rgb_width, rgb_height;
unsigned char *rgb_data;
unsigned char *alpha_data;
gchar *filename;
/* the below information is private */
gint width, height;
GdkImlibColor shape_color;
GdkImlibBorder border;
GdkPixmap *pixmap;
GdkBitmap *shape_mask;
gchar cache;
GdkImlibColorModifier mod, rmod, gmod, bmod;
unsigned char rmap[256], gmap[256], bmap[256];
}
GdkImlibImage;
typedef struct _GdkImlibSaveInfo
{
int quality;
int scaling;
int xjustification;
int yjustification;
int page_size;
char color;
}
GdkImlibSaveInfo;
typedef struct _GdkImlibInitParams
{
int flags;
int visualid;
char *palettefile;
char sharedmem;
char sharedpixmaps;
char paletteoverride;
char remap;
char fastrender;
char hiquality;
char dither;
int imagecachesize;
int pixmapcachesize;
}
GdkImlibInitParams;
#define PARAMS_VISUALID 1<<0
#define PARAMS_PALETTEFILE 1<<1
#define PARAMS_SHAREDMEM 1<<2
#define PARAMS_SHAREDPIXMAPS 1<<3
#define PARAMS_PALETTEOVERRIDE 1<<4
#define PARAMS_REMAP 1<<5
#define PARAMS_FASTRENDER 1<<6
#define PARAMS_HIQUALITY 1<<7
#define PARAMS_DITHER 1<<8
#define PARAMS_IMAGECACHESIZE 1<<9
#define PARAMS_PIXMAPCACHESIZE 1<<10
#define PAGE_SIZE_EXECUTIVE 0
#define PAGE_SIZE_LETTER 1
#define PAGE_SIZE_LEGAL 2
#define PAGE_SIZE_A4 3
#define PAGE_SIZE_A3 4
#define PAGE_SIZE_A5 5
#define PAGE_SIZE_FOLIO 6
#define RT_PLAIN_PALETTE 0
#define RT_PLAIN_PALETTE_FAST 1
#define RT_DITHER_PALETTE 2
#define RT_DITHER_PALETTE_FAST 3
#define RT_PLAIN_TRUECOL 4
/* a special high-quality renderer for people with 15 and 16bpp that dithers */
#define RT_DITHER_TRUECOL 5

6
src/gdk_imlib/globals.c Normal file
View File

@@ -0,0 +1,6 @@
#define _GNU_SOURCE
#include "../gdk_imlib/gdk_imlib.h"
#include "../gdk_imlib/gdk_imlib_private.h"
ImlibData *id;

1498
src/gdk_imlib/load.c Normal file

File diff suppressed because it is too large Load Diff

1165
src/gdk_imlib/misc.c Normal file

File diff suppressed because it is too large Load Diff

6170
src/gdk_imlib/rend.c Normal file

File diff suppressed because it is too large Load Diff

538
src/gdk_imlib/save.c Normal file
View File

@@ -0,0 +1,538 @@
#define _GNU_SOURCE
#include "../gdk_imlib/config.h"
#include "../gdk_imlib/gdk_imlib.h"
#include "../gdk_imlib/gdk_imlib_private.h"
gint
gdk_imlib_save_image(GdkImlibImage * im, char *file, GdkImlibSaveInfo * info)
{
char *ext;
char cmd[10240];
FILE *f;
GdkImlibSaveInfo defaults;
if (!im || !file)
return 0;
defaults.quality = 208;
defaults.scaling = 1024;
defaults.xjustification = 512;
defaults.yjustification = 512;
defaults.page_size = PAGE_SIZE_LETTER;
defaults.color = 1;
if (!info)
info = &defaults;
ext = g_GetExtension(file);
if ((!strcasecmp(ext, "ppm")) || (!strcasecmp(ext, "pnm")))
{
f = fopen(file, "wb");
if (f)
{
if (!fprintf(f, "P6\n# Created by Imlib\n%i %i\n255\n", im->rgb_width, im->rgb_height))
{
fclose(f);
return 0;
}
if (!fwrite(im->rgb_data, 1, (im->rgb_width * im->rgb_height * 3), f))
{
fclose(f);
return 0;
}
fclose(f);
return 1;
}
}
else if (!strcasecmp(ext, "pgm"))
{
int x, y;
unsigned char *ptr, val;
int v;
f = fopen(file, "wb");
if (f)
{
if (!fprintf(f, "P5\n# Created by Imlib\n%i %i\n255\n", im->rgb_width, im->rgb_height))
{
fclose(f);
return 0;
}
ptr = im->rgb_data;
for (y = 0; y < im->rgb_height; y++)
{
for (x = 0; x < im->rgb_width; x++)
{
v = (int)(*ptr++);
v += (int)(*ptr++);
v += (int)(*ptr++);
val = (unsigned char)(v / 3);
if (!fwrite(&val, 1, 1, f))
{
fclose(f);
return 0;
}
}
}
fclose(f);
return 1;
}
}
else if (!strcasecmp(ext, "ps"))
{
int bx, by, bxx, byy;
int w, h;
int sx = 0, sy = 0;
int tx = 35, ty = 35;
int x, y;
unsigned char *ptr;
int v;
f = fopen(file, "wb");
if (f == NULL)
return 0;
w = im->rgb_width;
h = im->rgb_height;
switch (info->page_size)
{
case PAGE_SIZE_EXECUTIVE:
sx = 540;
sy = 720;
break;
case PAGE_SIZE_LETTER:
sx = 612;
sy = 792;
break;
case PAGE_SIZE_LEGAL:
sx = 612;
sy = 1008;
break;
case PAGE_SIZE_A4:
sx = 595;
sy = 842;
break;
case PAGE_SIZE_A3:
sx = 842;
sy = 1190;
break;
case PAGE_SIZE_A5:
sx = 420;
sy = 595;
break;
case PAGE_SIZE_FOLIO:
sx = 612;
sy = 936;
break;
}
bxx = ((sx - (tx * 2)) * info->scaling) >> 10;
byy = ((h * bxx / w) * info->scaling) >> 10;
if ((((sy - (ty * 2)) * info->scaling) >> 10) < byy)
{
byy = ((sy - (ty * 2)) * info->scaling) >> 10;
bxx = ((w * byy / h) * info->scaling) >> 10;
}
bx = tx + ((((sx - (tx * 2)) - bxx) * info->xjustification) >> 10);
by = ty + ((((sy - (ty * 2)) - byy) * info->yjustification) >> 10);
if (f)
{
fprintf(f, "%%!PS-Adobe-2.0 EPSF-2.0\n");
fprintf(f, "%%%%Title: %s\n", file);
fprintf(f, "%%%%Creator: Imlib by The Rasterman\n");
fprintf(f, "%%%%BoundingBox: %i %i %i %i\n", bx, by, bxx, byy);
fprintf(f, "%%%%Pages: 1\n");
fprintf(f, "%%%%DocumentFonts:\n");
fprintf(f, "%%%%EndComments\n");
fprintf(f, "%%%%EndProlog\n");
fprintf(f, "%%%%Page: 1 1\n");
fprintf(f, "/origstate save def\n");
fprintf(f, "20 dict begin\n");
if (info->color)
{
fprintf(f, "/pix %i string def\n", w * 3);
fprintf(f, "/grays %i string def\n", w);
fprintf(f, "/npixls 0 def\n");
fprintf(f, "/rgbindx 0 def\n");
fprintf(f, "%i %i translate\n", bx, by);
fprintf(f, "%i %i scale\n", bxx, byy);
fprintf(f,
"/colorimage where\n"
"{ pop }\n"
"{\n"
"/colortogray {\n"
"/rgbdata exch store\n"
"rgbdata length 3 idiv\n"
"/npixls exch store\n"
"/rgbindx 0 store\n"
"0 1 npixls 1 sub {\n"
"grays exch\n"
"rgbdata rgbindx get 20 mul\n"
"rgbdata rgbindx 1 add get 32 mul\n"
"rgbdata rgbindx 2 add get 12 mul\n"
"add add 64 idiv\n"
"put\n"
"/rgbindx rgbindx 3 add store\n"
"} for\n"
"grays 0 npixls getinterval\n"
"} bind def\n"
"/mergeprocs {\n"
"dup length\n"
"3 -1 roll\n"
"dup\n"
"length\n"
"dup\n"
"5 1 roll\n"
"3 -1 roll\n"
"add\n"
"array cvx\n"
"dup\n"
"3 -1 roll\n"
"0 exch\n"
"putinterval\n"
"dup\n"
"4 2 roll\n"
"putinterval\n"
"} bind def\n"
"/colorimage {\n"
"pop pop\n"
"{colortogray} mergeprocs\n"
"image\n"
"} bind def\n"
"} ifelse\n");
fprintf(f, "%i %i 8\n", w, h);
fprintf(f, "[%i 0 0 -%i 0 %i]\n", w, h, h);
fprintf(f, "{currentfile pix readhexstring pop}\n");
fprintf(f, "false 3 colorimage\n");
fprintf(f, "\n");
ptr = im->rgb_data;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
v = (int)(*ptr++);
if (v < 0x10)
fprintf(f, "0%x", v);
else
fprintf(f, "%x", v);
v = (int)(*ptr++);
if (v < 0x10)
fprintf(f, "0%x", v);
else
fprintf(f, "%x", v);
v = (int)(*ptr++);
if (v < 0x10)
fprintf(f, "0%x", v);
else
fprintf(f, "%x", v);
}
fprintf(f, "\n");
}
}
else
{
fprintf(f, "/pix %i string def\n", w);
fprintf(f, "/grays %i string def\n", w);
fprintf(f, "/npixls 0 def\n");
fprintf(f, "/rgbindx 0 def\n");
fprintf(f, "%i %i translate\n", bx, by);
fprintf(f, "%i %i scale\n", bxx, byy);
fprintf(f, "%i %i 8\n", w, h);
fprintf(f, "[%i 0 0 -%i 0 %i]\n", w, h, h);
fprintf(f, "{currentfile pix readhexstring pop}\n");
fprintf(f, "image\n");
fprintf(f, "\n");
ptr = im->rgb_data;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
v = (int)(*ptr++);
v += (int)(*ptr++);
v += (int)(*ptr++);
v /= 3;
if (v < 0x10)
fprintf(f, "0%x", v);
else
fprintf(f, "%x", v);
}
fprintf(f, "\n");
}
}
fprintf(f, "\n");
fprintf(f, "showpage\n");
fprintf(f, "end\n");
fprintf(f, "origstate restore\n");
fprintf(f, "%%%%Trailer\n");
fclose(f);
return 1;
}
}
else if ((!strcasecmp(ext, "jpeg")) || (!strcasecmp(ext, "jpg")))
{
#ifdef HAVE_LIBJPEG
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
JSAMPROW row_pointer[1];
int row_stride;
int y;
f = fopen(file, "wb");
if (f)
{
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, f);
cinfo.image_width = im->rgb_width;
cinfo.image_height = im->rgb_height;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, (100 * info->quality) >> 8, TRUE);
jpeg_start_compress(&cinfo, TRUE);
row_stride = cinfo.image_width * 3;
while (cinfo.next_scanline < cinfo.image_height)
{
row_pointer[0] = im->rgb_data + (cinfo.next_scanline * row_stride);
jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
jpeg_finish_compress(&cinfo);
fclose(f);
return 1;
}
#endif
}
else if (!strcasecmp(ext, "png"))
{
#ifdef HAVE_LIBPNG
png_structp png_ptr;
png_infop info_ptr;
unsigned char *data, *ptr;
int x, y;
png_bytep row_ptr;
png_color_8 sig_bit;
f = fopen(file, "wb");
if (f)
{
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if (!png_ptr)
{
fclose(f);
return 0;
}
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
fclose(f);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
return 0;
}
if (setjmp(png_ptr->jmpbuf))
{
fclose(f);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
return 0;
}
png_init_io(png_ptr, f);
png_set_IHDR(png_ptr, info_ptr, im->rgb_width, im->rgb_height, 8,
PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
sig_bit.red = 8;
sig_bit.green = 8;
sig_bit.blue = 8;
sig_bit.alpha = 8;
png_set_sBIT(png_ptr, info_ptr, &sig_bit);
png_write_info(png_ptr, info_ptr);
png_set_shift(png_ptr, &sig_bit);
png_set_packing(png_ptr);
data = malloc(im->rgb_width * 4);
if (!data)
{
fclose(f);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
return 0;
}
for (y = 0; y < im->rgb_height; y++)
{
ptr = im->rgb_data + (y * im->rgb_width * 3);
for (x = 0; x < im->rgb_width; x++)
{
data[(x << 2) + 0] = *ptr++;
data[(x << 2) + 1] = *ptr++;
data[(x << 2) + 2] = *ptr++;
if ((data[(x << 2) + 0] == im->shape_color.r) &&
(data[(x << 2) + 1] == im->shape_color.g) &&
(data[(x << 2) + 2] == im->shape_color.b))
data[(x << 2) + 3] = 0;
else
data[(x << 2) + 3] = 255;
}
row_ptr = data;
png_write_rows(png_ptr, &row_ptr, 1);
}
free(data);
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
fclose(f);
return 1;
}
#endif
}
else if ((!strcasecmp(ext, "tiff")) || (!strcasecmp(ext, "tif")))
{
#ifdef HAVE_LIBTIFF
TIFF *tif;
unsigned char *ptr, *data;
int x, y;
int w;
tif = TIFFOpen(file, "w");
if (tif)
{
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, im->rgb_width);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, im->rgb_height);
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
{
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
w = TIFFScanlineSize(tif);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
TIFFDefaultStripSize(tif, -1));
for (y = 0; y < im->rgb_height; y++)
{
data = im->rgb_data + (y * im->rgb_width * 3);
TIFFWriteScanline(tif, data, y, 0);
}
}
TIFFClose(tif);
return 1;
}
#endif
}
if (id->fallback)
{
f = open_helper("%C/convert pnm:- %s", file, "wb");
if (f)
{
if (!fprintf(f, "P6\n# Created by Imlib\n%i %i\n255\n", im->rgb_width, im->rgb_height))
{
close_helper(f);
return 0;
}
if (!fwrite(im->rgb_data, 1, (im->rgb_width * im->rgb_height * 3), f))
{
close_helper(f);
return 0;
}
if (close_helper(f))
return 0;
return 1;
}
if (!strcasecmp(ext, "jpeg"))
g_snprintf(cmd, sizeof(cmd), "%%H -quality %i -progressive -outfile %%s", 100 * info->quality / 256);
else if (!strcasecmp(ext, "jpg"))
g_snprintf(cmd, sizeof(cmd), "%%H -quality %i -progressive -outfile %%s", 100 * info->quality / 256);
else if (!strcasecmp(ext, "bmp"))
strcpy(cmd, "%Q %N/ppmtobmp >%s");
else if (!strcasecmp(ext, "gif"))
strcpy(cmd, "%Q %N/ppmtogif -interlace >%s");
else if (!strcasecmp(ext, "ilbm"))
strcpy(cmd, "%N/ppmtoilbm -24if -hires -lace -compress >%s");
else if (!strcasecmp(ext, "ilb"))
strcpy(cmd, "%N/ppmtoilbm -24if -hires -lace -compress >%s");
else if (!strcasecmp(ext, "iff"))
strcpy(cmd, "%N/ppmtoilbm -24if -hires -lace -compress >%s");
else if (!strcasecmp(ext, "icr"))
strcpy(cmd, "%N/ppmtoicr >%s");
else if (!strcasecmp(ext, "map"))
strcpy(cmd, "%N/ppmtomap >%s");
else if (!strcasecmp(ext, "mit"))
strcpy(cmd, "%N/ppmtomitsu -sharpness 4 >%s");
else if (!strcasecmp(ext, "mitsu"))
strcpy(cmd, "%N/ppmtomitsu -sharpness 4 >%s");
else if (!strcasecmp(ext, "pcx"))
strcpy(cmd, "%N/ppmtopcx -24bit -packed >%s");
else if (!strcasecmp(ext, "pgm"))
strcpy(cmd, "%N/ppmtopgm >%s");
else if (!strcasecmp(ext, "pi1"))
strcpy(cmd, "%N/ppmtopi1 >%s");
else if (!strcasecmp(ext, "pic"))
strcpy(cmd, "%Q %N/ppmtopict >%s");
else if (!strcasecmp(ext, "pict"))
strcpy(cmd, "%Q %N/ppmtopict >%s");
else if (!strcasecmp(ext, "pj"))
strcpy(cmd, "%N/ppmtopj >%s");
else if (!strcasecmp(ext, "pjxl"))
strcpy(cmd, "%N/ppmtopjxl >%s");
else if (!strcasecmp(ext, "puz"))
strcpy(cmd, "%N/ppmtopuzz >%s");
else if (!strcasecmp(ext, "puzz"))
strcpy(cmd, "%N/ppmtopuzz >%s");
else if (!strcasecmp(ext, "rgb3"))
strcpy(cmd, "%N/ppmtorgb3 >%s");
else if (!strcasecmp(ext, "six"))
strcpy(cmd, "%N/ppmtosixel >%s");
else if (!strcasecmp(ext, "sixel"))
strcpy(cmd, "%N/ppmtosizel >%s");
else if (!strcasecmp(ext, "tga"))
strcpy(cmd, "%N/ppmtotga -rgb >%s");
else if (!strcasecmp(ext, "targa"))
strcpy(cmd, "%N/ppmtotga -rgb >%s");
else if (!strcasecmp(ext, "uil"))
strcpy(cmd, "%N/ppmtouil >%s");
else if (!strcasecmp(ext, "xpm"))
strcpy(cmd, "%Q %N/ppmtoxpm >%s");
else if (!strcasecmp(ext, "yuv"))
strcpy(cmd, "%N/ppmtoyuv >%s");
else if (!strcasecmp(ext, "png"))
strcpy(cmd, "%N/pnmtopng >%s");
else if (!strcasecmp(ext, "ps"))
strcpy(cmd, "%N/pnmtops -center -scale 100 >%s");
else if (!strcasecmp(ext, "rast"))
strcpy(cmd, "%N/pnmtorast -rle >%s");
else if (!strcasecmp(ext, "ras"))
strcpy(cmd, "%N/pnmtorast -rle >%s");
else if (!strcasecmp(ext, "sgi"))
strcpy(cmd, "%N/pnmtosgi >%s");
else if (!strcasecmp(ext, "sir"))
strcpy(cmd, "%N/pnmtosir >%s");
else if (!strcasecmp(ext, "tif"))
strcpy(cmd, "%N/pnmtotiff -lzw >%s");
else if (!strcasecmp(ext, "tiff"))
strcpy(cmd, "%N/pnmtotiff -lzw >%s");
else if (!strcasecmp(ext, "xwd"))
strcpy(cmd, "%N/pnmtoxwd >%s");
else
ext = "";
if (ext[0])
{
f = open_helper(cmd, file, "wb");
if (f)
{
if (!fprintf(f, "P6\n# Created by Imlib\n%i %i\n255\n", im->rgb_width, im->rgb_height))
{
close_helper(f);
return 0;
}
if (!fwrite(im->rgb_data, 1, (im->rgb_width * im->rgb_height * 3), f))
{
close_helper(f);
return 0;
}
if (close_helper(f))
return 0;
return 1;
}
}
}
return 0;
}

1521
src/gdk_imlib/utils.c Normal file

File diff suppressed because it is too large Load Diff

521
src/msw/Y_TAB.C Normal file
View File

@@ -0,0 +1,521 @@
#ifndef lint
static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define yyclearin (yychar=(-1))
#define yyerrok (yyerrflag=0)
#define YYRECOVERING (yyerrflag!=0)
#define YYPREFIX "yy"
#line 2 "../common/parser.y"
#include <string.h>
#include "wx/expr.h"
#ifndef __EXTERN_C__
#define __EXTERN_C__ 1
#endif
#if defined(__cplusplus) || defined(__STDC__)
#if defined(__cplusplus) && defined(__EXTERN_C__)
extern "C" {
#endif
#endif
int yylex(void);
int yylook(void);
int yywrap(void);
int yyback(int *, int);
void yyerror(char *);
/* You may need to put /DLEX_SCANNER in your makefile
* if you're using LEX!
*/
#ifdef LEX_SCANNER
/* int yyoutput(int); */
void yyoutput(int);
#else
void yyoutput(int);
#endif
#if defined(__cplusplus) || defined(__STDC__)
#if defined(__cplusplus) && defined(__EXTERN_C__)
}
#endif
#endif
#line 37 "../common/parser.y"
typedef union {
char *s;
/* struct pexpr *expr; */
} YYSTYPE;
#line 51 "y_tab.c"
#define INTEGER 1
#define WORD 2
#define STRING 3
#define PERIOD 13
#define OPEN 4
#define CLOSE 5
#define COMMA 6
#define NEWLINE 7
#define ERROR 8
#define OPEN_SQUARE 9
#define CLOSE_SQUARE 10
#define EQUALS 11
#define EXP 14
#define YYERRCODE 256
short yylhs[] = { -1,
0, 0, 1, 1, 1, 2, 2, 2, 3, 3,
3, 4, 4, 5, 5, 5, 5, 5, 5, 5,
};
short yylen[] = { 2,
0, 2, 2, 2, 2, 4, 2, 3, 0, 1,
3, 3, 1, 1, 1, 1, 3, 3, 5, 1,
};
short yydefred[] = { 1,
0, 0, 0, 0, 2, 0, 5, 3, 0, 0,
0, 15, 7, 20, 0, 0, 13, 4, 0, 0,
0, 0, 8, 0, 6, 0, 18, 0, 12, 11,
0, 19,
};
short yydgoto[] = { 1,
5, 14, 15, 16, 17,
};
short yysindex[] = { 0,
-2, 9, 2, 1, 0, 10, 0, 0, 11, -5,
17, 0, 0, 0, 14, -1, 0, 0, 33, 38,
41, 16, 0, 11, 0, 29, 0, 40, 0, 0,
44, 0,
};
short yyrindex[] = { 0,
0, 0, 0, 0, 0, 0, 0, 0, 42, 21,
24, 0, 0, 0, 0, 30, 0, 0, 0, 0,
0, 0, 0, 31, 0, 27, 0, 24, 0, 0,
0, 0,
};
short yygindex[] = { 0,
0, 45, -8, 0, 26,
};
#define YYTABLESIZE 254
short yytable[] = { 3,
19, 10, 11, 12, 24, 9, 4, 20, 21, 4,
13, 10, 11, 12, 8, 30, 10, 28, 12, 4,
9, 7, 18, 23, 4, 16, 16, 22, 14, 14,
16, 17, 17, 14, 10, 9, 17, 25, 26, 10,
9, 27, 31, 9, 32, 6, 9, 29, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 2,
};
short yycheck[] = { 2,
9, 1, 2, 3, 6, 4, 9, 13, 14, 9,
10, 1, 2, 3, 13, 24, 1, 2, 3, 9,
4, 13, 13, 10, 9, 5, 6, 11, 5, 6,
10, 5, 6, 10, 5, 5, 10, 5, 1, 10,
10, 1, 14, 4, 1, 1, 5, 22, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 256,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 14
#if YYDEBUG
char *yyname[] = {
"end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE",
"ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP",
};
char *yyrule[] = {
"$accept : commands",
"commands :",
"commands : commands command",
"command : WORD PERIOD",
"command : expr PERIOD",
"command : error PERIOD",
"expr : WORD OPEN arglist CLOSE",
"expr : OPEN_SQUARE CLOSE_SQUARE",
"expr : OPEN_SQUARE arglist CLOSE_SQUARE",
"arglist :",
"arglist : arg",
"arglist : arg COMMA arglist",
"arg : WORD EQUALS arg1",
"arg : arg1",
"arg1 : WORD",
"arg1 : STRING",
"arg1 : INTEGER",
"arg1 : INTEGER PERIOD INTEGER",
"arg1 : INTEGER EXP INTEGER",
"arg1 : INTEGER PERIOD INTEGER EXP INTEGER",
"arg1 : expr",
};
#endif
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
short *yyssp;
YYSTYPE *yyvsp;
YYSTYPE yyval;
YYSTYPE yylval;
short yyss[YYSTACKSIZE];
YYSTYPE yyvs[YYSTACKSIZE];
#define yystacksize YYSTACKSIZE
#line 119 "../common/parser.y"
#include "../common/lex_yy.c"
/*
void yyerror(s)
char *s;
{
syntax_error(s);
}
*/
/* Ansi prototype. If this doesn't work for you... uncomment
the above instead.
*/
void yyerror(char *s)
{
syntax_error(s);
}
/*
* Unfortunately, my DOS version of FLEX
* requires yywrap to be #def'ed, whereas
* the UNIX flex expects a proper function.
*/
/* Not sure if __SC__ is the appropriate thing
* to test
*/
#ifndef __SC__
#ifdef USE_DEFINE
#ifndef yywrap
#define yywrap() 1
#endif
#else if !defined(__alpha) && !defined(__ultrix)
int yywrap() { return 1; }
#endif
#endif
#line 251 "y_tab.c"
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
yyparse()
{
register int yym, yyn, yystate;
#if YYDEBUG
register char *yys;
extern char *getenv();
if (yys = getenv("YYDEBUG"))
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = (-1);
yyssp = yyss;
yyvsp = yyvs;
*yyssp = yystate = 0;
yyloop:
if (yyn = yydefred[yystate]) goto yyreduce;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
yychar = (-1);
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
#ifdef lint
goto yynewerror;
#endif
yynewerror:
yyerror("syntax error");
#ifdef lint
goto yyerrlab;
#endif
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yyssp);
#endif
if (yyssp <= yyss) goto yyabort;
--yyssp;
--yyvsp;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = (-1);
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
yyval = yyvsp[1-yym];
switch (yyn)
{
case 3:
#line 69 "../common/parser.y"
{process_command(proio_cons(make_word(yyvsp[-1].s), NULL)); free(yyvsp[-1].s);}
break;
case 4:
#line 71 "../common/parser.y"
{process_command(yyvsp[-1].s);}
break;
case 5:
#line 73 "../common/parser.y"
{syntax_error("Unrecognized command.");}
break;
case 6:
#line 77 "../common/parser.y"
{yyval.s = proio_cons(make_word(yyvsp[-3].s), yyvsp[-1].s); free(yyvsp[-3].s);}
break;
case 7:
#line 79 "../common/parser.y"
{yyval.s = proio_cons(NULL, NULL);}
break;
case 8:
#line 81 "../common/parser.y"
{yyval.s = yyvsp[-1].s; }
break;
case 9:
#line 85 "../common/parser.y"
{yyval.s = NULL;}
break;
case 10:
#line 87 "../common/parser.y"
{yyval.s = proio_cons(yyvsp[0].s, NULL);}
break;
case 11:
#line 90 "../common/parser.y"
{yyval.s = proio_cons(yyvsp[-2].s, yyvsp[0].s);}
break;
case 12:
#line 94 "../common/parser.y"
{yyval.s = proio_cons(make_word("="), proio_cons(make_word(yyvsp[-2].s), proio_cons(yyvsp[0].s, NULL)));
free(yyvsp[-2].s); }
break;
case 13:
#line 97 "../common/parser.y"
{yyval.s = yyvsp[0].s; }
break;
case 14:
#line 100 "../common/parser.y"
{yyval.s = make_word(yyvsp[0].s); free(yyvsp[0].s);}
break;
case 15:
#line 102 "../common/parser.y"
{yyval.s = make_string(yyvsp[0].s); free(yyvsp[0].s);}
break;
case 16:
#line 104 "../common/parser.y"
{yyval.s = make_integer(yyvsp[0].s); free(yyvsp[0].s);}
break;
case 17:
#line 106 "../common/parser.y"
{yyval.s = make_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); }
break;
case 18:
#line 108 "../common/parser.y"
{yyval.s = make_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); }
break;
case 19:
#line 111 "../common/parser.y"
{yyval.s = make_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s);
free(yyvsp[0].s); }
break;
case 20:
#line 115 "../common/parser.y"
{yyval.s = yyvsp[0].s;}
break;
#line 466 "y_tab.c"
}
yyssp -= yym;
yystate = *yyssp;
yyvsp -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yyssp = YYFINAL;
*++yyvsp = yyval;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yyssp, yystate);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate;
*++yyvsp = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
return (1);
yyaccept:
return (0);
}

355
src/msw/xfspline.inc Normal file
View File

@@ -0,0 +1,355 @@
/*
* File: xfspline.cc
* Purpose:
* Author: Julian Smart
* Created: 1993
* Updated: August 1994
* RCS_ID: $Id$
* Copyright: (c) 1993, AIAI, University of Edinburgh
*/
// Must be a comment as this file is #include\'d by wb_dc.cc
/* static const char sccsid[] = "@(#)xfspline.cc 1.3 5/9/94"; */
/*
* FIG : Facility for Interactive Generation of figures
* Copyright (c) 1985 by Supoj Sutanthavibul
*/
#if USE_SPLINES
////#define wx_round(a) (int)((a)+.5)
//#define wx_round(a) (a)
class wxSpline: public wxObject
{
public:
int type;
wxList *points;
wxSpline(wxList *list);
void DeletePoints(void);
// Doesn't delete points
~wxSpline(void);
};
void wx_draw_open_spline(wxDC *dc, wxSpline *spline);
#if USE_POSTSCRIPT
void wx_draw_open_spline_ps(wxPostScriptDC *dc, wxSpline *s);
#endif
void wx_quadratic_spline(double a1, double b1, double a2, double b2,
double a3, double b3, double a4, double b4);
void wx_clear_stack(void);
int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3,
double *y3, double *x4, double *y4);
void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3,
double x4, double y4);
static bool wx_spline_add_point(double x, double y);
static void wx_spline_draw_point_array(wxDC *dc);
wxSpline *wx_make_spline(int x1, int y1, int x2, int y2, int x3, int y3);
void wxDC::DrawSpline(int n, wxPoint points[])
{
wxList list;
int i;
for (i =0; i < n; i++)
list.Append((wxObject*)&points[i]);
DrawSpline((wxList *)&list);
}
void wxDC::DrawSpline(wxList *list)
{
wxSpline spline(list);
wx_draw_open_spline(this, &spline);
}
wxList wx_spline_point_list;
void wx_draw_open_spline(wxDC *dc, wxSpline *spline)
{
wxPoint *p;
double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
double x1, y1, x2, y2;
wxNode *node = spline->points->First();
p = (wxPoint *)node->Data();
x1 = p->x;
y1 = p->y;
node = node->Next();
p = (wxPoint *)node->Data();
x2 = p->x;
y2 = p->y;
cx1 = (double)((x1 + x2) / 2);
cy1 = (double)((y1 + y2) / 2);
cx2 = (double)((cx1 + x2) / 2);
cy2 = (double)((cy1 + y2) / 2);
wx_spline_add_point(x1, y1);
while ((node = node->Next()) != NULL)
{
p = (wxPoint *)node->Data();
x1 = x2;
y1 = y2;
x2 = p->x;
y2 = p->y;
cx4 = (double)(x1 + x2) / 2;
cy4 = (double)(y1 + y2) / 2;
cx3 = (double)(x1 + cx4) / 2;
cy3 = (double)(y1 + cy4) / 2;
wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
cx1 = cx4;
cy1 = cy4;
cx2 = (double)(cx1 + x2) / 2;
cy2 = (double)(cy1 + y2) / 2;
}
wx_spline_add_point((double)wx_round(cx1), (double)wx_round(cy1));
wx_spline_add_point(x2, y2);
wx_spline_draw_point_array(dc);
}
#if USE_POSTSCRIPT
void wx_draw_open_spline_ps(wxPostScriptDC *dc, wxSpline *s)
{
double a, b, c, d, x1, y1, x2, y2, x3, y3;
wxPoint *p, *q;
wxNode *node = s->points->First();
p = (wxPoint *)node->Data();
x1 = p->x; y1 = p->y;
node = node->Next();
p = (wxPoint *)node->Data();
c = p->x; d = p->y;
x3 = a = (double)(x1 + c) / 2;
y3 = b = (double)(y1 + d) / 2;
*(dc->GetStream()) << "newpath " << x1 << " " << dc->GetYOrigin() - y1 << " moveto " << x3 << " " << dc->GetYOrigin() - y3;
*(dc->GetStream()) << " lineto\n";
dc->CalcBoundingBox((double)x1, (double)(dc->GetYOrigin() - y1));
dc->CalcBoundingBox((double)x3, (double)(dc->GetYOrigin() - y3));
while ((node = node->Next()) != NULL)
{
q = (wxPoint *)node->Data();
x1 = x3; y1 = y3;
x2 = c; y2 = d;
c = q->x; d = q->y;
x3 = (double)(x2 + c) / 2;
y3 = (double)(y2 + d) / 2;
*(dc->GetStream()) << x1 << " " << dc->GetYOrigin() - y1 << " " << x2 << " " << dc->GetYOrigin() - y2 << " ";
*(dc->GetStream()) << x3 << " " << dc->GetYOrigin() - y3 << " DrawSplineSection\n";
dc->CalcBoundingBox((double)x1, (double)(dc->GetYOrigin() - y1));
dc->CalcBoundingBox((double)x3, (double)(dc->GetYOrigin() - y3));
}
/*
* At this point, (x2,y2) and (c,d) are the position of the
* next-to-last and last point respectively, in the point list
*/
*(dc->GetStream()) << c << " " << dc->GetYOrigin() - d << " lineto stroke\n";
}
#endif
/********************* CURVES FOR SPLINES *****************************
The following spline drawing routine is from
"An Algorithm for High-Speed Curve Generation"
by George Merrill Chaikin,
Computer Graphics and Image Processing, 3, Academic Press,
1974, 346-349.
and
"On Chaikin's Algorithm" by R. F. Riesenfeld,
Computer Graphics and Image Processing, 4, Academic Press,
1975, 304-310.
***********************************************************************/
#define half(z1, z2) ((z1+z2)/2.0)
#define THRESHOLD 5
/* iterative version */
void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4,
double b4)
{
register double xmid, ymid;
double x1, y1, x2, y2, x3, y3, x4, y4;
wx_clear_stack();
wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4);
while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) {
xmid = (double)half(x2, x3);
ymid = (double)half(y2, y3);
if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD &&
fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) {
wx_spline_add_point((double)wx_round(x1), (double)wx_round(y1));
wx_spline_add_point((double)wx_round(xmid), (double)wx_round(ymid));
} else {
wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3),
(double)half(x3, x4), (double)half(y3, y4), x4, y4);
wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2),
(double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid);
}
}
}
/* utilities used by spline drawing routines */
typedef struct wx_spline_stack_struct {
double x1, y1, x2, y2, x3, y3, x4, y4;
}
Stack;
#define SPLINE_STACK_DEPTH 20
static Stack wx_spline_stack[SPLINE_STACK_DEPTH];
static Stack *wx_stack_top;
static int wx_stack_count;
void wx_clear_stack(void)
{
wx_stack_top = wx_spline_stack;
wx_stack_count = 0;
}
void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
{
wx_stack_top->x1 = x1;
wx_stack_top->y1 = y1;
wx_stack_top->x2 = x2;
wx_stack_top->y2 = y2;
wx_stack_top->x3 = x3;
wx_stack_top->y3 = y3;
wx_stack_top->x4 = x4;
wx_stack_top->y4 = y4;
wx_stack_top++;
wx_stack_count++;
}
int wx_spline_pop(double *x1, double *y1, double *x2, double *y2,
double *x3, double *y3, double *x4, double *y4)
{
if (wx_stack_count == 0)
return (0);
wx_stack_top--;
wx_stack_count--;
*x1 = wx_stack_top->x1;
*y1 = wx_stack_top->y1;
*x2 = wx_stack_top->x2;
*y2 = wx_stack_top->y2;
*x3 = wx_stack_top->x3;
*y3 = wx_stack_top->y3;
*x4 = wx_stack_top->x4;
*y4 = wx_stack_top->y4;
return (1);
}
static bool wx_spline_add_point(double x, double y)
{
wxPoint *point = new wxPoint ;
point->x = (int) x;
point->y = (int) y;
wx_spline_point_list.Append((wxObject*)point);
return TRUE;
}
static void wx_spline_draw_point_array(wxDC *dc)
{
dc->DrawLines(&wx_spline_point_list, (double)0.0, (double)0.0);
wxNode *node = wx_spline_point_list.First();
while (node)
{
wxPoint *point = (wxPoint *)node->Data();
delete point;
delete node;
node = wx_spline_point_list.First();
}
}
wxSpline::wxSpline(wxList *list)
{
points = list;
}
wxSpline::~wxSpline(void)
{
}
void wxSpline::DeletePoints(void)
{
for(wxNode *node = points->First(); node; node = points->First())
{
wxPoint *point = (wxPoint *)node->Data();
delete point;
delete node;
}
delete points;
}
#if USE_POSTSCRIPT
// Make a 3-point spline
void wxPostScriptDC::DrawSpline(long x1, long y1, long x2, long y2, long x3, long y3)
{
wxList *point_list = new wxList;
wxPoint *point1 = new wxPoint;
point1->x = x1; point1->y = y1;
point_list->Append((wxObject*)point1);
wxPoint *point2 = new wxPoint;
point2->x = x2; point2->y = y2;
point_list->Append((wxObject*)point2);
wxPoint *point3 = new wxPoint;
point3->x = x3; point3->y = y3;
point_list->Append((wxObject*)point3);
wxSpline spline(point_list);
wx_draw_open_spline_ps(this, &spline);
spline.DeletePoints();
}
void wxPostScriptDC::DrawSpline(wxList *list)
{
wxSpline spline(list);
wx_draw_open_spline_ps(this, &spline);
}
void wxPostScriptDC::DrawSpline(int n, wxPoint points[])
{
wxList list;
int i;
for (i =0; i < n; i++)
list.Append((wxObject*)&points[i]);
DrawSpline((wxList *)&list);
}
#endif // USE_POSTSCRIPT
#endif // USE_SPLINES

123
utils/ogl/src/bitmap.cpp Normal file
View File

@@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bitmap.cpp
// Purpose: Bitmap shape class
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "bitmap.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include <wx/wxprec.h>
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#ifdef PROLOGIO
#include <wx/wxexpr.h>
#endif
#include "basic.h"
#include "basicp.h"
#include "canvas.h"
#include "bitmap.h"
#include "misc.h"
/*
* Bitmap object
*
*/
IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape, wxShape)
wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0)
{
m_filename = "";
}
wxBitmapShape::~wxBitmapShape()
{
}
void wxBitmapShape::OnDraw(wxDC& dc)
{
if (!m_bitmap.Ok())
return;
wxMemoryDC tempDC;
tempDC.SelectObject(m_bitmap);
double x, y;
x = WXROUND(m_xpos - m_bitmap.GetWidth() / 2.0);
y = WXROUND(m_ypos - m_bitmap.GetHeight() / 2.0);
dc.Blit(x, y, m_bitmap.GetWidth(), m_bitmap.GetHeight(), &tempDC, 0, 0);
}
void wxBitmapShape::SetSize(double w, double h, bool recursive)
{
if (m_bitmap.Ok())
{
w = m_bitmap.GetWidth();
h = m_bitmap.GetHeight();
}
SetAttachmentSize(w, h);
m_width = w;
m_height = h;
SetDefaultRegionSize();
}
#ifdef PROLOGIO
// Prolog database stuff
char *wxBitmapShape::GetFunctor()
{
return "node_image";
}
void wxBitmapShape::WritePrologAttributes(wxExpr *clause)
{
// Can't really save the bitmap; so instantiate the bitmap
// at a higher level in the application, from a symbol library.
wxRectangleShape::WritePrologAttributes(clause);
clause->AddAttributeValueString("filename", m_filename);
}
void wxBitmapShape::ReadPrologAttributes(wxExpr *clause)
{
wxRectangleShape::ReadPrologAttributes(clause);
clause->GetAttributeValue("filename", m_filename);
}
#endif
// Does the copying for this object
void wxBitmapShape::Copy(wxShape& copy)
{
wxRectangleShape::Copy(copy);
wxASSERT( copy.IsKindOf(CLASSINFO(wxBitmapShape)) ) ;
wxBitmapShape& bitmapCopy = (wxBitmapShape&) copy;
bitmapCopy.m_bitmap = m_bitmap;
bitmapCopy.SetFilename(m_filename);
}
void wxBitmapShape::SetBitmap(const wxBitmap& bm)
{
m_bitmap = bm;
if (m_bitmap.Ok())
SetSize(m_bitmap.GetWidth(), m_bitmap.GetHeight());
}

54
utils/ogl/src/bitmap.h Normal file
View File

@@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bitmap.h
// Purpose: wxBitmapShape
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_BITMAP_H_
#define _OGL_BITMAP_H_
#ifdef __GNUG__
#pragma interface "bitmap.h"
#endif
#include "basic.h"
class wxBitmapShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxBitmapShape)
public:
wxBitmapShape();
~wxBitmapShape();
void OnDraw(wxDC& dc);
#ifdef PROLOGIO
// Prolog database stuff
char *GetFunctor();
void WritePrologAttributes(wxExpr *clause);
void ReadPrologAttributes(wxExpr *clause);
#endif
// Does the copying for this object
void Copy(wxShape& copy);
void SetSize(double w, double h, bool recursive = TRUE);
inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
void SetBitmap(const wxBitmap& bm);
inline void SetFilename(const wxString& f) { m_filename = f; };
inline wxString GetFilename() const { return m_filename; }
private:
wxBitmap m_bitmap;
wxString m_filename;
};
#endif
// _OGL_BITMAP_H_