mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-01 19:37:45 +01:00
Added cairomm-1.2.4.
git-svn-id: svn://localhost/ardour2/branches/2.1-staging@1417 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
76450f35b1
commit
2156684ec2
33 changed files with 6488 additions and 0 deletions
10
libs/cairomm/AUTHORS
Normal file
10
libs/cairomm/AUTHORS
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Please do not email us directly - use the mailing list.
|
||||
See http://cairographics.org/lists
|
||||
|
||||
Maintainers:
|
||||
----------
|
||||
Murray Cumming
|
||||
Jonathon Jongsma
|
||||
|
||||
Based on code from Leonard Ritter.
|
||||
|
||||
481
libs/cairomm/COPYING
Normal file
481
libs/cairomm/COPYING
Normal file
|
|
@ -0,0 +1,481 @@
|
|||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 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
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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!
|
||||
724
libs/cairomm/ChangeLog
Normal file
724
libs/cairomm/ChangeLog
Normal file
|
|
@ -0,0 +1,724 @@
|
|||
1.2.4:
|
||||
|
||||
2007-01-17 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* NEWS: updated news for 1.2.4 release
|
||||
* configure.in: bumped version to 1.2.4
|
||||
|
||||
2006-09-27 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/refptr.h: cast_static() and cast_dynamic():
|
||||
Use the refcount_() accessor instead of the member variable,
|
||||
to avoid compilation errors, as we already do in the
|
||||
templated copy constructor.
|
||||
|
||||
1.2.2:
|
||||
|
||||
2006-08-21 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* NEWS: update for 1.2.2
|
||||
* configure.in: bump to next even number (1.2.2)
|
||||
|
||||
2006-08-21 Cedric Gustin <cedric.gustin@gmail.com>
|
||||
|
||||
* cairomm/win32_surface.cc: Explicitly cast Cairo::Format to
|
||||
cairo_format_t.
|
||||
|
||||
2006-08-20 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* Makefile.am: fix up the release announcement template to explain what
|
||||
cairomm is at the top of the email before telling where to get it.
|
||||
* configure.in: post-release bump (1.2.1)
|
||||
|
||||
1.2.0:
|
||||
|
||||
2006-08-20 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* NEWS: Update information about new stuff in 1.2.0
|
||||
* configure.in: bump the release version number to 1.2.0 and the shared
|
||||
library version number to 1:0:0 since interfaces were changed and added and
|
||||
we're now guaranteeing API/ABI stability
|
||||
|
||||
2006-08-20 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* examples/pdf-surface/.cvsignore:
|
||||
* examples/png_file/.cvsignore:
|
||||
* examples/ps-surface/.cvsignore:
|
||||
* examples/svg-surface/.cvsignore: added image files produced by the example
|
||||
programs to .cvsignore
|
||||
|
||||
2006-08-19 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* Makefile.am: get rid of the concept of a snapshot. It doesn't really make
|
||||
that much sense for cairomm, honestly, since we're just a simple wrapper
|
||||
library.
|
||||
|
||||
2006-08-19 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* MSVC/examples/.cvsignore:
|
||||
* MSVC/examples/Makefile.am:
|
||||
* MSVC/examples/pdf-surface/.cvsignore:
|
||||
* MSVC/examples/pdf-surface/Makefile.am:
|
||||
* MSVC/examples/pdf-surface/pdf-surface.vcproj:
|
||||
* MSVC/examples/png_file/.cvsignore:
|
||||
* MSVC/examples/png_file/Makefile.am:
|
||||
* MSVC/examples/png_file/png_file.vcproj:
|
||||
* MSVC/examples/ps-surface/.cvsignore:
|
||||
* MSVC/examples/ps-surface/Makefile.am:
|
||||
* MSVC/examples/ps-surface/ps-surface.vcproj:
|
||||
* MSVC/examples/svg-surface/.cvsignore:
|
||||
* MSVC/examples/svg-surface/Makefile.am:
|
||||
* MSVC/examples/svg-surface/svg-surface.vcproj:
|
||||
* MSVC/examples/text-rotate/.cvsignore:
|
||||
* MSVC/examples/text-rotate/Makefile.am:
|
||||
* MSVC/examples/text-rotate/text-rotate.vcproj:
|
||||
* MSVC/gendef/.cvsignore:
|
||||
* MSVC/gendef/Makefile.am:
|
||||
* MSVC/gendef/gendef.cc:
|
||||
* MSVC/gendef/gendef.vcproj: added a bunch of MSVC / windows-specific things
|
||||
that got missed last time.
|
||||
|
||||
2006-08-18 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/win32_surface.cc:
|
||||
* cairomm/win32_surface.h: add some missing win32 API that I had overlooked:
|
||||
cairo_win32_surface_get_dc() and cairo_win32_surface_create_with_dib(),
|
||||
updated documentation for standard Win32Surface::create() function.
|
||||
|
||||
2006-08-18 Cedric Gustin <cedric.gustin@gmail.com>
|
||||
|
||||
* cairomm/context.cc: Define M_PI for MSVC.
|
||||
* cairomm/scaledfont.cc: Allocate glyph_array as a synamic array
|
||||
as MSVC does not like non-const arguments as array size.
|
||||
* examples/pdf-surface/main.cc, examples/png_file/main.cc,
|
||||
examples/ps-surface/main.cc, examples/svg-surface/main.cc,
|
||||
examples/text-rotate/text-rotate.cc: Define M_PI for MSVC.
|
||||
* configure.in, Makefile.am: Generate Makefiles in the MSVC
|
||||
subdirectories.
|
||||
* .cvsignore: Added Eclipse .project to the list of ignored files.
|
||||
* MSVC/*: Added project and resource files for Visual Studio 2005.
|
||||
|
||||
2006-08-18 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h: API CHANGE: some API was changed to maintain a closer
|
||||
similarity to the underlying cairo API (while also attempting to avoid
|
||||
confusion with the C++ 'new' keyword) in preparation for freezing the
|
||||
cairomm API. Two functions are affected:
|
||||
- Context::clear_path() -> Context::begin_new_path()
|
||||
- Context::new_sub_path() -> Context::begin_new_sub_path()
|
||||
* configure.in: bump the libtool version to indicate API change
|
||||
|
||||
2006-08-15 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/context.cc: remove another TODO. I looked at cairo_append_path,
|
||||
and it just copies the data from the supplied path and appends that to the
|
||||
current path -- it doesn't modify the passed in path -- so it can stay
|
||||
const.
|
||||
|
||||
2006-08-15 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/context.h: remove a FIXME that was resolved on the mailing list
|
||||
|
||||
2006-07-11 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/refptr.h: unref(): Only delete the refcount int when the refcount has
|
||||
reached 0, instead of deleting it every time. Thanks valgrind.
|
||||
|
||||
2006-07-11 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/refptr.h: From-C-object Constructor: Added documentation explaining
|
||||
how/when to use it and when to do an extra reference(). This will help us,
|
||||
though it should rarely be necessary for an application developer to understand
|
||||
it.
|
||||
Made pCppRefcount_ mutable, so that refcount_() can be a const method so that
|
||||
the templated constructor compiles.
|
||||
Added class documentation to explain why we even want to use this class.
|
||||
|
||||
2006-07-05 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/refptr.h: copy constructors: initialize the pCppRefcount_ member
|
||||
variable, using a public refcount_() method when necessary to access a
|
||||
different RefPtr<> specialization.
|
||||
|
||||
2006-07-11 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/refptr.h: Use an int to reference-count the C++ object, and
|
||||
only reference/unreference the object (and hence the underlying C object)
|
||||
when receiving/deleting the C++ object. Without this, we never delete
|
||||
the C++ object. Fixes bug #7442.
|
||||
|
||||
2006-07-09 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* NEWS: add NEWS for 1.1.10 release
|
||||
* configure.in: bump version to 1.1.12
|
||||
|
||||
2006-07-05 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* Makefile.am: Ooops, I had accidentally removed dependency info for
|
||||
release-publish target
|
||||
|
||||
2006-07-05 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/context.h:
|
||||
* cairomm/fontface.h:
|
||||
* cairomm/pattern.h:
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h:
|
||||
* cairomm/xlib_surface.cc:
|
||||
* cairomm/xlib_surface.h: Fix the generic text about reference-counted
|
||||
objects, because we no longer use copy constructors for this. And some
|
||||
pedantic white space changes.
|
||||
|
||||
2006-07-05 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/scaledfont.cc:
|
||||
* cairomm/scaledfont.h: create(): Make the font_matrix and ctm
|
||||
parameters const (they are now const in the C API too). Maybe the font
|
||||
parameter should be const, but maybe there is a reason that it is not
|
||||
const in the C API. Pass FontOptions by const reference instead of
|
||||
by value.
|
||||
glyph_extents(): Pass the vector by const reference instead of by
|
||||
value.
|
||||
I would prefere to make all the extents() functions use return values
|
||||
instead of output parameters, but I suppose this might be slightly
|
||||
less efficient in some circumstances.
|
||||
|
||||
2006-07-05 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/cairomm.h:
|
||||
* cairomm/context.h:
|
||||
* cairomm/path.h:
|
||||
* cairomm/scaledfont.h:
|
||||
* cairomm/surface.h:
|
||||
* cairomm/win32_surface.h:
|
||||
* cairomm/xlib_surface.h: Use @ instead of \ for doxygen
|
||||
commands, to be consistent with gtkmm, which uses it because it is the
|
||||
same as JavaDoc, with which some people are already familiar.
|
||||
|
||||
2006-07-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* Makefile.am: add ability to do snapshot releases to the
|
||||
cairographics.org/snapshots/ directory in addition to official releases
|
||||
* configure.in: bumped the revision to 1.1.10 in preparation for a snapshot
|
||||
release of the 1.2 API
|
||||
* docs/reference/Makefile.am: fixed some distcheck errors
|
||||
|
||||
2006-07-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* .cvsignore, cairomm/.cvsignore: ignore some autotools files and *.swp
|
||||
files (from vim)
|
||||
|
||||
2006-07-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/scaledfont.cc, cairomm/scaledfont.h: wrap ScaledFont, including
|
||||
new API for cairo 1.2
|
||||
* cairomm/Makefile.am: add scaledfont.* to list of sources
|
||||
|
||||
2006-07-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/surface.h: Remove comments stating that PDF, PS, and SVG are
|
||||
experimental surfaces. As of 1.2.0, these three surfaces are officially
|
||||
supported by the cairo library.
|
||||
|
||||
2006-07-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/xlib_surface.h: add a bit more documentation for the new
|
||||
XlibSurface API
|
||||
|
||||
2006-07-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/surface.cc, cairomm/surface.h: added SvgSurface::get_versions()
|
||||
and SvgSurface::version_to_string() API. They're implemented as static
|
||||
members right now.
|
||||
|
||||
2006-06-30 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* configure.in: bumped cairomm version to 0.7.0 and bumped cairo requirement
|
||||
to 1.2.0
|
||||
|
||||
2006-06-30 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/xlib_surface.cc, cairomm/xlib_surface.h: add new get_height() and
|
||||
get_width() API to XlibSurface
|
||||
|
||||
2006-06-27 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/enums.h: Added enum types to support the new get_type() and SVG
|
||||
Version API
|
||||
* cairomm/fontface.cc, cairomm/fontface.h: add new get_type() API
|
||||
* cairomm/pattern.cc, cairomm/pattern.h: add new get_type() API
|
||||
* cairomm/surface.cc, cairomm/surface.h: add new get_type() API and
|
||||
SvgSurface::restrict_to_version() API
|
||||
|
||||
2006-06-26 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/surface.cc, cairomm/surface.h: add new PsSurface and PdfSurface
|
||||
API: set_size, dsc_comment, dsc_begin_setup, dsc_begin_page_setup
|
||||
* cairomm/xlib_surface.cc, cairomm/xlib_surface.h: add new XlibSurface API:
|
||||
get_display, get_drawable, get_screen, get_visual, get_depth
|
||||
|
||||
2006-06-26 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h: Added new Surface and ImageSurface API from 1.1.x
|
||||
snapshots
|
||||
|
||||
2006-06-23 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h: added Context::new_sub_path() and new push/pop group
|
||||
API.
|
||||
|
||||
2006-06-23 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/enums.h: fix stupid error from last commit
|
||||
|
||||
2006-06-23 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/enums.h: add new FORMAT_RGB16_565 format
|
||||
|
||||
2006-06-12 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* configure.in: bump required cairo version to >= 1.1.7
|
||||
* cairomm/surface.cc, cairomm/surface.h: update to new cairo API
|
||||
cairo_surface_set_fallback_resolution
|
||||
|
||||
2006-05-10 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* docs/reference/cairomm.css: minor documentation stylesheet fix
|
||||
|
||||
2006-05-08 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/context.h:
|
||||
* cairomm/path.h: added some preliminary documentation explaining that the
|
||||
caller is responsible for freeing Path objects returned from
|
||||
Context::copy_path() and Context::copy_path_flat().
|
||||
|
||||
2006-05-08 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/cairomm.h: Add doxygen API introduction test here.
|
||||
* docs/reference/Doxyfile.in:
|
||||
* docs/reference/Makefile.am:
|
||||
* docs/reference/cairomm-header.html:
|
||||
* docs/reference/cairomm.css:
|
||||
* docs/reference/introduction.h: fix up some documentation presentation
|
||||
issues that turned up with newer versions of doxygen.
|
||||
|
||||
2006-05-08 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* configure.in: remove check for perl since we're not using any of the
|
||||
gmmproc stuff for cairomm
|
||||
* docs/reference/Makefile.am: add documentation dependency on all of the
|
||||
headers in the cairomm/ directory so that if a header changes the
|
||||
documentation will be rebuilt.
|
||||
|
||||
2006-04-20 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h: mask(pattern) and mask(surface): Make the parameter
|
||||
const, because I am fairly sure that the C function does not change it.
|
||||
|
||||
2006-04-06 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* Makefile.am: Add a brief description of cairomm to the release
|
||||
announcement template
|
||||
|
||||
2006-04-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* docs/reference/Doxyfile.in:
|
||||
* docs/reference/Makefile.am: A couple minor build fixes to make distcheck
|
||||
happy
|
||||
|
||||
2006-04-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* NEWS: add news for 0.6.0 release
|
||||
* configure.in: bump version to 0.6.0
|
||||
|
||||
2006-04-03 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* examples/text-rotate/text-rotate.cc: protect PNG functions with #ifdef in
|
||||
case cairo wasn't compiled with PNG support
|
||||
|
||||
2006-03-31 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* Makefile.am:
|
||||
* docs/Makefile.am:
|
||||
* docs/reference/Makefile.am: add convenience targets for cleaning and
|
||||
rebuilding documentation (doc-clean and doc-rebuild).
|
||||
|
||||
2006-03-30 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* configure.in: enable documentation even if doxygen and/or graphviz
|
||||
are missing, so the docs will be installed when building a release.
|
||||
* docs/reference/Makefile.am: don't remove html directory with `make clean`,
|
||||
so that users of the tarball releases don't destroy the pre-built
|
||||
documentation when running make clean. Change to maintainer-clean
|
||||
|
||||
2006-03-29 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* configure.in: added tests for doxygen and graphviz which displays a
|
||||
warning if the user has --enable-docs set but doesn't have doxygen or
|
||||
graphviz installed.
|
||||
|
||||
2006-03-28 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* cairomm/enums.h: Stop using CAIRO_EXTEND_PAD, as it only exists
|
||||
in the 1.1.1 development branch.
|
||||
|
||||
2006-03-14 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* configure.in:
|
||||
* examples/Makefile.am:
|
||||
* examples/text-rotate/.cvsignore:
|
||||
* examples/text-rotate/Makefile.am:
|
||||
* examples/text-rotate/text-rotate.cc: Added another basic example,
|
||||
borrowed from a test-case in cairo. This one is just a simple example of
|
||||
using text in cairomm
|
||||
|
||||
2006-03-14 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/fontface.h:
|
||||
* cairomm/fontoptions.h:
|
||||
* cairomm/path.h:
|
||||
* cairomm/pattern.h: include <cairo.h> instead of <cairo/cairo.h> since it
|
||||
didn't want to compile on windows without these
|
||||
* cairomm/win32_surface.cc:
|
||||
* cairomm/win32_surface.h: Move the include of cairo-win32.h from the
|
||||
source file to the header since the declaration of create() needs the HDC
|
||||
type definition.
|
||||
With these changes, cairomm should compile the Win32Surface cleanly with
|
||||
mingw on Microsoft Windows
|
||||
|
||||
2006-03-12 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* autogen.sh: Allow overriding aclocal, automake, autoconf and libtoolize
|
||||
using environment variables. Taken from cairo's autogen.sh.
|
||||
|
||||
2006-03-06 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/*.cc, *.h: add vim modelines to set proper indentation for
|
||||
cairomm when using vim
|
||||
|
||||
2006-02-28 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h:
|
||||
* cairomm/enums.h:
|
||||
* cairomm/fontoptions.cc:
|
||||
* cairomm/fontoptions.h:
|
||||
* cairomm/pattern.cc:
|
||||
* cairomm/pattern.h:
|
||||
* cairomm/surface.h: wrapped all of the enum types with cairomm
|
||||
types within the Cairo namespace, so now (for example) the values for
|
||||
Cairo::Format are something like Cairo::FORMAT_ARGB32 instead of the base
|
||||
cairo types like CAIRO_FORMAT_ARGB_32.
|
||||
* examples/png_file/main.cc: fixed example to work with the new namespaced
|
||||
enum types
|
||||
|
||||
2006-02-27 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/exception.h:
|
||||
* docs/reference/Doxyfile.in:
|
||||
* docs/reference/Makefile.am: hide some of the private types and functions
|
||||
from the Doxygen API reference documentation
|
||||
|
||||
2006-02-27 Stefan Kersten <steve@k-hornz.de>
|
||||
|
||||
* cairomm/surface.cc: fix an extra trailing parentheses in
|
||||
GlitzSurface::create()
|
||||
|
||||
2006-02-22 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* examples/README: Write some basic information about each example
|
||||
|
||||
2006-02-22 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* docs/reference/Makefile.am: add target for publishing the API reference
|
||||
to cairographics.org
|
||||
|
||||
2006-02-20 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* Makefile.am: Include MAINTAINERS in distribution. Fixes Bug #5982
|
||||
|
||||
2006-02-17 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* COPYING: Use the text from the Library GPL 2.0, which is the actual
|
||||
license of cairomm. Fixes Bug #5934
|
||||
|
||||
2006-02-17 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* autogen.sh:
|
||||
* cairomm/cairomm.h:
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h:
|
||||
* cairomm/enums.h:
|
||||
* cairomm/exception.cc:
|
||||
* cairomm/exception.h:
|
||||
* cairomm/fontface.cc:
|
||||
* cairomm/fontface.h:
|
||||
* cairomm/fontoptions.cc:
|
||||
* cairomm/fontoptions.h:
|
||||
* cairomm/path.cc:
|
||||
* cairomm/path.h:
|
||||
* cairomm/pattern.cc:
|
||||
* cairomm/pattern.h:
|
||||
* cairomm/private.cc:
|
||||
* cairomm/private.h:
|
||||
* cairomm/refptr.h:
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h:
|
||||
* cairomm/win32_surface.cc:
|
||||
* cairomm/win32_surface.h:
|
||||
* cairomm/xlib_surface.cc:
|
||||
* cairomm/xlib_surface.h: Update FSF's postal address in GPL/LGPL
|
||||
comment headings. Fixes Bug #5933
|
||||
|
||||
2006-02-17 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* examples/*/.cvsignore: Bug #5927: added .cvsignore files to examples
|
||||
directories
|
||||
|
||||
2006-02-17 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* AUTHORS:
|
||||
* INSTALL:
|
||||
* README:
|
||||
* cairomm/exception.cc:
|
||||
* cairomm/exception.h: Remove lingering references to libxml++
|
||||
|
||||
2006-02-17 Danilo Piazzalunga <danilopiazza@gmail.com>
|
||||
|
||||
* configure.in: Bug #5929: Output files in docs subdir only if
|
||||
--enable-docs is set. This prevents configure from generating files which
|
||||
are not cleaned up when --disable-docs is used.
|
||||
Use AC_CONFIG_FILES and AC_OUTPUT as recommended.
|
||||
|
||||
2006-02-16 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* docs/reference/Doxyfile.in:
|
||||
* docs/reference/cairomm.css: added some style customisations to the API
|
||||
doc so that it fits in with the overall Cairo style a bit better
|
||||
|
||||
2006-02-16 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* AUTHORS:
|
||||
* MAINTAINERS: Add my information to the Maintainers and authors file
|
||||
|
||||
0.5.0:
|
||||
|
||||
2006-02-09 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* docs/reference/Makefile.am: added a 'html' target to satisfy the dist
|
||||
rule
|
||||
|
||||
2006-02-08 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/context.h: Added a lot of documentation for the Cairo::Context
|
||||
class taken from the cairo docs. It's not complete, but the basics are all
|
||||
covered now.
|
||||
* docs/reference/Makefile.am: make use of existing Makefile variable
|
||||
* NEWS: update for 0.5.0 release
|
||||
|
||||
2006-02-07 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* Makefile.am: add docs/ subdir
|
||||
* configure.in: added an --enable-docs switch to the configure script
|
||||
(enabled by default), and added AC_OUTPUT directives for the documentation
|
||||
Makefiles, etc.
|
||||
* docs/.cvsignore:
|
||||
* docs/Makefile.am:
|
||||
* docs/reference/.cvsignore:
|
||||
* docs/reference/Doxyfile.in:
|
||||
* docs/reference/Makefile.am:
|
||||
* docs/reference/introduction.h: Added infrastructure to build and install
|
||||
the API documentation for cairomm (based on libxml++ makefiles).
|
||||
|
||||
2006-01-27 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* .cvsignore:
|
||||
* cairomm/.cvsignore: update .cvsignore files
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h: change Surface::create function to take a
|
||||
RefPtr<Surface> instead of Surface&
|
||||
|
||||
2006-01-27 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* examples/pdf-surface/Makefile.am: Remove extra LDADD that was breaking
|
||||
the distcheck.
|
||||
|
||||
2006-01-26 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* examples/ps-surface/main.cc:
|
||||
* examples/svg-surface/main.cc: Correct the text of the messages.
|
||||
|
||||
2006-01-25 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* configure.in:
|
||||
* examples/Makefile.am:
|
||||
* examples/pdf-surface/:
|
||||
* examples/ps-surface/:
|
||||
* examples/svg-surface/: add examples for additional surfaces
|
||||
|
||||
2006-01-24 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/Makefile.am:
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h:
|
||||
* cairomm/xlib_surface.cc:
|
||||
* cairomm/xlib_surface.h:
|
||||
* cairomm/win32_surface.cc:
|
||||
* cairomm/win32_surface.h: Moved XlibSurface and
|
||||
Win32Surface into separate files, not #included by
|
||||
the main cairomm.h file, so that developers do not need to
|
||||
suffer the Xlib.h or Windows namespace pollution unless they really need to.
|
||||
For instance, this fixes the gtkmm 2.9 build which was broken by the
|
||||
Display struct in Xlib.h.
|
||||
|
||||
2006-01-15 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h: backwards-incompatible API change for the Surface
|
||||
types. Cairo::Surface is now a base class for all of the other surface
|
||||
types, and should not be used directly. New Surface types include
|
||||
ImageSurface, XlibSurface, Win32Surface, PdfSurface, PsSurface,
|
||||
SvgSurface, and GlitzSurface.
|
||||
Modified Surface::write_to_png() and Surface::write_to_png_stream() so
|
||||
that they throw exceptions like the other functions instead of returning a
|
||||
cairo_status_t value.
|
||||
Added API documentation for all Surface classes and all member functions
|
||||
of the Surface class heirarchy.
|
||||
* examples/png_file/Makefile.am: added generated PNG file to CLEANFILES
|
||||
* examples/png_file/main.cc: updated the PNG example to use the new
|
||||
ImageSurface class instead of using the Surface class directly.
|
||||
* cairomm/*: Renamed the Cairo::Status type to Cairo::ErrorStatus since it
|
||||
conflicts with a #define Status in XLib and is not used exposed in the API
|
||||
anyway.
|
||||
|
||||
2006-01-06 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h: Added implementation of write_to_png() and
|
||||
write_to_png_stream() when PNG support is available in the base cairo
|
||||
library
|
||||
* examples/png_file/*: Added an example of creating an image surface and
|
||||
saving it to a png image file
|
||||
* examples/Makefile.am: add new example directory to SUBDIRS list
|
||||
* configure.in: added output declaration for examples/png_file/Makefile
|
||||
* examples/makefile.am_fragment: fix leftover libxml boilerplate
|
||||
|
||||
2006-01-03 Jonathon Jongsma <jonathon.jongsma@gmail.com>
|
||||
|
||||
* cairomm/surface.cc: added missing implementations for reference() and
|
||||
unreference() functions
|
||||
|
||||
0.4.0:
|
||||
|
||||
2005-12-17 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/Makefile.am:
|
||||
* cairomm/refptr.h: Add shared
|
||||
reference-counting smartpointer, using
|
||||
the reference-count in the object. A copy
|
||||
of the tried and tested glibmm RefPtr.
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h:
|
||||
* cairomm/fontface.cc:
|
||||
* cairomm/fontface.h:
|
||||
* cairomm/pattern.cc:
|
||||
* cairomm/pattern.h:
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h: Make constructors protected
|
||||
and add public static create() methods that return
|
||||
instances in RefPtr<>s. This allows reference-counted
|
||||
objects to be clearly const or non-const, and allows
|
||||
casting between related types.
|
||||
|
||||
2005-12-17 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h: Change set_dash(void) to
|
||||
unset_dash(). Change rotate_deg() to
|
||||
rotate_degrees(). Change identity_matrix() to
|
||||
set_identity_matrix(). Change new_path() to
|
||||
clear_path().
|
||||
* cairomm/fontface.cc:
|
||||
* cairomm/fontface.h: Comment-out
|
||||
get/set_user_data(), because it seems useless.
|
||||
|
||||
0.3.0:
|
||||
|
||||
2005-12-08 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/pattern.cc:
|
||||
* cairomm/pattern.h: Create a hierarchy of pattern
|
||||
classes, as suggested by the C documentation, because
|
||||
not all functions are meaningful for all pattern types.
|
||||
|
||||
2005-12-07 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h: font_extents(), stroke_extents(),
|
||||
glyph_extents(), fill_extents(): Add get_ prefix and
|
||||
make them const.
|
||||
|
||||
2005-12-07 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h: Add typedef for Matrix, though we
|
||||
probably want to derive a class with a C++-like matrix
|
||||
API, with operator overloading.
|
||||
|
||||
2005-12-07 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/exception.cc:
|
||||
* cairomm/exception.h: Rename to logic_error, because
|
||||
the cairo documentation says that most of them are
|
||||
programming errors, not runtime errors. Derive from
|
||||
std::logic_error because of this.
|
||||
* cairomm/private.cc:
|
||||
* cairomm/private.h: Throw std::bad_alloc for memory
|
||||
errors, and std::io_base::failure for read/write runtime
|
||||
errors, as suggested by the cairo language-binding
|
||||
documentation.
|
||||
|
||||
2005-12-07 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/fontoptions.cc:
|
||||
* cairomm/surface.cc: Check for errors in
|
||||
constructors, as per the error-handling advice in the
|
||||
language bindings section of the cairo documentation.
|
||||
|
||||
2005-12-07 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h: Change mask_surface() to
|
||||
mask() and set_source_surface() to set_source(),
|
||||
as per the method overloading advice in the
|
||||
language bindings section of the cairo documentation.
|
||||
|
||||
0.2.0:
|
||||
|
||||
2005-12-02 Murray Cumming <murrayc@murrayc.com>
|
||||
|
||||
* cairomm/cairomm.h: Put sensible stuff in here,
|
||||
instead of my copy/paste stuff from libxml++.
|
||||
* cairomm/context.cc:
|
||||
* cairomm/context.h:
|
||||
* cairomm/enums.h:
|
||||
* cairomm/exception.cc:
|
||||
* cairomm/exception.h:
|
||||
* cairomm/fontface.cc:
|
||||
* cairomm/fontface.h:
|
||||
* cairomm/fontoptions.cc:
|
||||
* cairomm/fontoptions.h:
|
||||
* cairomm/path.cc:
|
||||
* cairomm/path.h:
|
||||
* cairomm/pattern.cc:
|
||||
* cairomm/pattern.h:
|
||||
* cairomm/private.cc:
|
||||
* cairomm/private.h:
|
||||
* cairomm/surface.cc:
|
||||
* cairomm/surface.h: Add LGPL comment headings.
|
||||
|
||||
8
libs/cairomm/MAINTAINERS
Normal file
8
libs/cairomm/MAINTAINERS
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Please use the mailing list (cairo@cairographics.org) rather than emailing
|
||||
developers directly.
|
||||
|
||||
Murray Cumming
|
||||
Email: murrayc@murrayc.com
|
||||
|
||||
Jonathon Jongsma
|
||||
Email: jonathon.jongsma@gmail.com
|
||||
81
libs/cairomm/NEWS
Normal file
81
libs/cairomm/NEWS
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
1.2.4:
|
||||
|
||||
* Fixed an error that prevented Cairo::RefPtr<>::cast_static() and
|
||||
Cairo::RefPtr<>::cast_dynamic() from compiling.
|
||||
|
||||
1.2.2:
|
||||
|
||||
* Fixed an issue when compiling on windows with MSVC
|
||||
|
||||
1.2.0:
|
||||
|
||||
* This is the first release that guarantees API and ABI stability
|
||||
* Changed API:
|
||||
- Context::clear_path() is now Context::begin_new_path()
|
||||
- Context::new_sub_path() is now Context::begin_new_sub_path()
|
||||
* new API:
|
||||
- Win32Surface::get_dc()
|
||||
- Win32Surface::create() for device-independent bitmaps
|
||||
* Bugfixes
|
||||
- fixed a memory leak where C++ wrapper objects were not being destroyed
|
||||
* Fixes for compiling with MSVC (also includes project and resource files for
|
||||
Visual Studio 2005. See the MSVC/ directory)
|
||||
|
||||
1.1.10:
|
||||
|
||||
* API:
|
||||
- Wrap new API from cairo 1.2
|
||||
- Wrap ScaledFont
|
||||
* Improved Documentation
|
||||
* Build fixes
|
||||
|
||||
0.6.0:
|
||||
|
||||
* API:
|
||||
- enumerations are now wrapped within the Cairo namespace. So, for example,
|
||||
CAIRO_FORMAT_ARGB32 becomes Cairo::FORMAT_ARGB32
|
||||
* Examples: added simple text example translated from Cairo.
|
||||
* Bugfixes for the Glitz and Windows backends.
|
||||
* Build and installation improvements (Danilo Piazzalunga)
|
||||
|
||||
0.5.0:
|
||||
|
||||
* Surface:
|
||||
- Created derived classes for PDF, PS, SVG, Glitz,
|
||||
X11 and Win32 surfaces, which are only available if your copy
|
||||
of cairo supports those surfaces. The X11 and Win32 Surface headers
|
||||
must be #included explicitly.
|
||||
(Jonathon Jongsma)
|
||||
- Added write_to_png() and write_to_png_stream(), available when PNG
|
||||
support is available in Cairo.
|
||||
(Jonathon Jongsma)
|
||||
* Examples: Added PNG, PDF, PS, and SVG Surface examples.
|
||||
(Jonathon Jongsma)
|
||||
* Added API documentation generation with doxygen (Jonathon Jongsma)
|
||||
|
||||
0.4.0:
|
||||
|
||||
* Add Cairo::RefPtr<> and use all reference-counted
|
||||
objects via it. Use the static create() methods
|
||||
instead of new for these classes.
|
||||
* Context:
|
||||
- Change set_dash(void) to unset_dash().
|
||||
- Change rotate_deg() to rotate_degrees().
|
||||
- Change identity_matrix() to set_identity_matrix().\
|
||||
- Change new_path() to clear_path().
|
||||
* FontFace: Remove get/set_user_data(), because it seems useless.
|
||||
|
||||
0.3.0:
|
||||
|
||||
* Context:
|
||||
- Change mask_surface() to mask() and
|
||||
set_source_surface() to set_source().
|
||||
- Add typedef for Matrix, but a real Matrix
|
||||
class would be nice.
|
||||
* Pattern: Created hierarchy of classes.
|
||||
* Check for errors in constructors.
|
||||
* Exception: Rename to logic_error, and throw
|
||||
std::bad_alloc or std::io_base::failure instead
|
||||
when appropriate.
|
||||
(Murray Cumming)
|
||||
|
||||
13
libs/cairomm/README
Normal file
13
libs/cairomm/README
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
cairomm
|
||||
-------------
|
||||
|
||||
This library provides a C++ interface to cairo.
|
||||
|
||||
Read the file 'INSTALL' for instructions to compile and install the library.
|
||||
|
||||
See the examples directory for example code.
|
||||
|
||||
Use pkg-config to discover the necessary include and linker arguments. For instance,
|
||||
pkg-config cairomm-1.0 --cflags --libs
|
||||
Ideally you would use PKG_CHECK_MODULES in your configure.ac file.
|
||||
See http://www.openismus.com for generic help with that.
|
||||
22
libs/cairomm/SConscript
Normal file
22
libs/cairomm/SConscript
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- python -*-
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import glob
|
||||
|
||||
cairomm_files = glob.glob('cairomm/*.cc')
|
||||
|
||||
Import('env libraries install_prefix')
|
||||
cairomm = env.Copy()
|
||||
cairomm.Merge([libraries['cairo']])
|
||||
|
||||
libcairomm = cairomm.SharedLibrary('cairomm', cairomm_files)
|
||||
Default(libcairomm)
|
||||
|
||||
env.Alias('install', env.Install(os.path.join(install_prefix, env['LIBDIR'], 'ardour2'), libcairomm))
|
||||
|
||||
env.Alias('tarball', env.Distribute (env['DISTTREE'],
|
||||
[ 'SConscript'] +
|
||||
cairomm_files +
|
||||
glob.glob('cairomm/*.h')
|
||||
))
|
||||
12
libs/cairomm/cairomm-1.0.pc.in
Normal file
12
libs/cairomm/cairomm-1.0.pc.in
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: cairomm
|
||||
Description: C++ wrapper for cairo
|
||||
Requires: cairo
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lcairomm-1.0
|
||||
Cflags: -I${includedir}/cairomm-1.0
|
||||
|
||||
43
libs/cairomm/cairomm/cairomm.h
Normal file
43
libs/cairomm/cairomm/cairomm.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_H
|
||||
#define __CAIROMM_H
|
||||
|
||||
/** @mainpage Cairomm: A C++ wrapper for the cairo graphics library
|
||||
*
|
||||
* @section License
|
||||
* Cairomm is available under the terms of the LGPL license
|
||||
*
|
||||
* @section Introduction
|
||||
* If you're just beginning to learn cairomm, a good place to start is with the
|
||||
* Cairo::Surface and Cairo::Context classes. In general terms, you draw onto
|
||||
* a Surface using the graphics settings specified in your Context.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cairomm/context.h>
|
||||
#include <cairomm/surface.h>
|
||||
#include <cairomm/fontoptions.h>
|
||||
#include <cairomm/pattern.h>
|
||||
#include <cairomm/path.h>
|
||||
#include <cairomm/enums.h>
|
||||
|
||||
#endif //__CAIROMM_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
669
libs/cairomm/cairomm/context.cc
Normal file
669
libs/cairomm/cairomm/context.cc
Normal file
|
|
@ -0,0 +1,669 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/context.h>
|
||||
#include <cairomm/private.h>
|
||||
|
||||
/* M_PI is defined in math.h in the case of Microsoft Visual C++ */
|
||||
#if defined(_MSC_VER)
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
Context::Context(const RefPtr<Surface>& target)
|
||||
: m_cobject(0)
|
||||
{
|
||||
m_cobject = cairo_create(target->cobj());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
RefPtr<Context> Context::create(const RefPtr<Surface>& target)
|
||||
{
|
||||
return RefPtr<Context>(new Context(target));
|
||||
}
|
||||
|
||||
Context::Context(cairo_t* cobject, bool has_reference)
|
||||
: m_cobject(0)
|
||||
{
|
||||
if(has_reference)
|
||||
m_cobject = cobject;
|
||||
else
|
||||
m_cobject = cairo_reference(cobject);
|
||||
}
|
||||
|
||||
Context::~Context()
|
||||
{
|
||||
if(m_cobject)
|
||||
cairo_destroy(m_cobject);
|
||||
}
|
||||
|
||||
|
||||
void Context::reference() const
|
||||
{
|
||||
cairo_reference(m_cobject);
|
||||
}
|
||||
|
||||
void Context::unreference() const
|
||||
{
|
||||
cairo_destroy(m_cobject);
|
||||
}
|
||||
|
||||
void Context::save()
|
||||
{
|
||||
cairo_save(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::restore()
|
||||
{
|
||||
cairo_restore(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_operator(Operator op)
|
||||
{
|
||||
cairo_set_operator(m_cobject, static_cast<cairo_operator_t>(op));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_source(const RefPtr<const Pattern>& source)
|
||||
{
|
||||
cairo_set_source(m_cobject, const_cast<cairo_pattern_t*>(source->cobj()));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_source_rgb(double red, double green, double blue)
|
||||
{
|
||||
cairo_set_source_rgb(m_cobject, red, green, blue);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_source_rgba(double red, double green, double blue,
|
||||
double alpha)
|
||||
{
|
||||
cairo_set_source_rgba(m_cobject, red, green, blue, alpha);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_source(const RefPtr<Surface>& surface, double x, double y)
|
||||
{
|
||||
cairo_set_source_surface(m_cobject, surface->cobj(), x, y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_tolerance(double tolerance)
|
||||
{
|
||||
cairo_set_tolerance(m_cobject, tolerance);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_antialias(Antialias antialias)
|
||||
{
|
||||
cairo_set_antialias(m_cobject, static_cast<cairo_antialias_t>(antialias));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_fill_rule(FillRule fill_rule)
|
||||
{
|
||||
cairo_set_fill_rule(m_cobject, static_cast<cairo_fill_rule_t>(fill_rule));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_line_width(double width)
|
||||
{
|
||||
cairo_set_line_width(m_cobject, width);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_line_cap(LineCap line_cap)
|
||||
{
|
||||
cairo_set_line_cap(m_cobject, static_cast<cairo_line_cap_t>(line_cap));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_line_join(LineJoin line_join)
|
||||
{
|
||||
cairo_set_line_join(m_cobject, static_cast<cairo_line_join_t>(line_join));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_dash(std::valarray<double>& dashes, double offset)
|
||||
{
|
||||
cairo_set_dash(m_cobject, &dashes[0], dashes.size(), offset);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::unset_dash()
|
||||
{
|
||||
cairo_set_dash(m_cobject, NULL, 0, 0.0);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_miter_limit(double limit)
|
||||
{
|
||||
cairo_set_miter_limit(m_cobject, limit);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::translate(double tx, double ty)
|
||||
{
|
||||
cairo_translate(m_cobject, tx, ty);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::scale(double sx, double sy)
|
||||
{
|
||||
cairo_scale(m_cobject, sx, sy);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::rotate(double angle_radians)
|
||||
{
|
||||
cairo_rotate(m_cobject, angle_radians);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::rotate_degrees(double angle_degrees)
|
||||
{
|
||||
cairo_rotate(m_cobject, angle_degrees * M_PI/180.0);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::transform(const Matrix& matrix)
|
||||
{
|
||||
cairo_transform(m_cobject, &matrix);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_matrix(const Matrix& matrix)
|
||||
{
|
||||
cairo_set_matrix(m_cobject, &matrix);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_identity_matrix()
|
||||
{
|
||||
cairo_identity_matrix(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::user_to_device(double& x, double& y)
|
||||
{
|
||||
cairo_user_to_device(m_cobject, &x, &y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::user_to_device_distance(double& dx, double& dy)
|
||||
{
|
||||
cairo_user_to_device_distance(m_cobject, &dx, &dy);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::device_to_user(double& x, double& y)
|
||||
{
|
||||
cairo_device_to_user(m_cobject, &x, &y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::device_to_user_distance(double& dx, double& dy)
|
||||
{
|
||||
cairo_device_to_user_distance(m_cobject, &dx, &dy);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::begin_new_path()
|
||||
{
|
||||
cairo_new_path(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::begin_new_sub_path()
|
||||
{
|
||||
cairo_new_sub_path(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::move_to(double x, double y)
|
||||
{
|
||||
cairo_move_to(m_cobject, x, y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::line_to(double x, double y)
|
||||
{
|
||||
cairo_line_to(m_cobject, x, y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::curve_to(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
cairo_curve_to(m_cobject, x1, y1, x2, y2, x3, y3);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::arc(double xc, double yc, double radius, double angle1, double angle2)
|
||||
{
|
||||
cairo_arc(m_cobject, xc, yc, radius, angle1, angle2);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::arc_negative(double xc, double yc, double radius, double angle1, double angle2)
|
||||
{
|
||||
cairo_arc_negative(m_cobject, xc, yc, radius, angle1, angle2);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::rel_move_to(double dx, double dy)
|
||||
{
|
||||
cairo_rel_move_to(m_cobject, dx, dy);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::rel_line_to(double dx, double dy)
|
||||
{
|
||||
cairo_rel_line_to(m_cobject, dx, dy);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::rel_curve_to(double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
|
||||
{
|
||||
cairo_rel_curve_to(m_cobject, dx1, dy1, dx2, dy2, dx3, dy3);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::rectangle(double x, double y, double width, double height)
|
||||
{
|
||||
cairo_rectangle(m_cobject, x, y, width, height);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::close_path()
|
||||
{
|
||||
cairo_close_path(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::paint()
|
||||
{
|
||||
cairo_paint(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::paint_with_alpha(double alpha)
|
||||
{
|
||||
cairo_paint_with_alpha(m_cobject, alpha);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::mask(const RefPtr<const Pattern>& pattern)
|
||||
{
|
||||
cairo_mask(m_cobject, const_cast<cairo_pattern_t*>(pattern->cobj()));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::mask(const RefPtr<const Surface>& surface, double surface_x, double surface_y)
|
||||
{
|
||||
cairo_mask_surface(m_cobject, const_cast<cairo_surface_t*>(surface->cobj()), surface_x, surface_y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::stroke()
|
||||
{
|
||||
cairo_stroke(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::stroke_preserve()
|
||||
{
|
||||
cairo_stroke_preserve(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::fill()
|
||||
{
|
||||
cairo_fill(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::fill_preserve()
|
||||
{
|
||||
cairo_fill_preserve(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::copy_page()
|
||||
{
|
||||
cairo_copy_page(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::show_page()
|
||||
{
|
||||
cairo_show_page(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
bool Context::in_stroke(double x, double y) const
|
||||
{
|
||||
const bool result = cairo_in_stroke(m_cobject, x, y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Context::in_fill(double x, double y) const
|
||||
{
|
||||
const bool result = cairo_in_fill(m_cobject, x, y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Context::get_stroke_extents(double& x1, double& y1, double& x2, double& y2) const
|
||||
{
|
||||
cairo_stroke_extents(m_cobject, &x1, &y1, &x2, &y2);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::get_fill_extents(double& x1, double& y1, double& x2, double& y2) const
|
||||
{
|
||||
cairo_fill_extents(m_cobject, &x1, &y1, &x2, &y2);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::reset_clip()
|
||||
{
|
||||
cairo_reset_clip(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::clip()
|
||||
{
|
||||
cairo_clip(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::clip_preserve()
|
||||
{
|
||||
cairo_clip_preserve(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::select_font_face(const std::string& family, FontSlant slant, FontWeight weight)
|
||||
{
|
||||
cairo_select_font_face (m_cobject, family.c_str(),
|
||||
static_cast<cairo_font_slant_t>(slant),
|
||||
static_cast<cairo_font_weight_t>(weight));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_font_size(double size)
|
||||
{
|
||||
cairo_set_font_size(m_cobject, size);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_font_matrix(const Matrix& matrix)
|
||||
{
|
||||
cairo_set_font_matrix(m_cobject, &matrix);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::get_font_matrix(Matrix& matrix) const
|
||||
{
|
||||
cairo_get_font_matrix(m_cobject, &matrix);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_font_options(const FontOptions& options)
|
||||
{
|
||||
cairo_set_font_options(m_cobject, options.cobj());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::show_text(const std::string& utf8)
|
||||
{
|
||||
cairo_show_text(m_cobject, utf8.c_str());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::show_glyphs(const std::vector<Glyph>& glyphs)
|
||||
{
|
||||
cairo_show_glyphs(m_cobject, const_cast<cairo_glyph_t*>(&glyphs[0]), glyphs.size());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
RefPtr<FontFace> Context::get_font_face()
|
||||
{
|
||||
cairo_font_face_t* cfontface = cairo_get_font_face(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return RefPtr<FontFace>(new FontFace(cfontface, false /* does not have reference */));
|
||||
}
|
||||
|
||||
RefPtr<const FontFace> Context::get_font_face() const
|
||||
{
|
||||
cairo_font_face_t* cfontface = cairo_get_font_face(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return RefPtr<const FontFace>(new FontFace(cfontface, false /* does not have reference */));
|
||||
}
|
||||
|
||||
void Context::get_font_extents(FontExtents& extents) const
|
||||
{
|
||||
cairo_font_extents(m_cobject, &extents);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::set_font_face(const RefPtr<const FontFace>& font_face)
|
||||
{
|
||||
cairo_set_font_face(m_cobject, const_cast<cairo_font_face_t*>(font_face->cobj()));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::get_text_extents(const std::string& utf8, TextExtents& extents) const
|
||||
{
|
||||
cairo_text_extents(m_cobject, utf8.c_str(), &extents);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::get_glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents) const
|
||||
{
|
||||
cairo_glyph_extents(m_cobject, const_cast<cairo_glyph_t*>(&glyphs[0]), glyphs.size(), &extents);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::text_path(const std::string& utf8)
|
||||
{
|
||||
cairo_text_path(m_cobject, utf8.c_str());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::glyph_path(const std::vector<Glyph>& glyphs)
|
||||
{
|
||||
cairo_glyph_path(m_cobject, const_cast<cairo_glyph_t*>(&glyphs[0]), glyphs.size());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
Operator Context::get_operator() const
|
||||
{
|
||||
const Operator result = static_cast<Operator>(cairo_get_operator(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
RefPtr<Pattern> Context::get_source()
|
||||
{
|
||||
cairo_pattern_t* pattern = cairo_get_source(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return RefPtr<Pattern>(new Pattern(pattern, false /* does not have reference */));
|
||||
}
|
||||
|
||||
RefPtr<const Pattern> Context::get_source() const
|
||||
{
|
||||
cairo_pattern_t* pattern = cairo_get_source(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return RefPtr<const Pattern>(new Pattern(pattern, false /* does not have reference */));
|
||||
}
|
||||
|
||||
double Context::get_tolerance() const
|
||||
{
|
||||
const double result = cairo_get_tolerance(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
Antialias Context::get_antialias() const
|
||||
{
|
||||
const Antialias result = static_cast<Antialias>(cairo_get_antialias(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Context::get_current_point(double& x, double& y) const
|
||||
{
|
||||
cairo_get_current_point(m_cobject, &x, &y);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
FillRule Context::get_fill_rule() const
|
||||
{
|
||||
const FillRule result = static_cast<FillRule>(cairo_get_fill_rule(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
double Context::get_line_width() const
|
||||
{
|
||||
const double result = cairo_get_line_width(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
LineCap Context::get_line_cap() const
|
||||
{
|
||||
const LineCap result = static_cast<LineCap>(cairo_get_line_cap(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
LineJoin Context::get_line_join() const
|
||||
{
|
||||
const LineJoin result = static_cast<LineJoin>(cairo_get_line_join(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
double Context::get_miter_limit() const
|
||||
{
|
||||
const double result = cairo_get_miter_limit(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Context::get_matrix(Matrix& matrix)
|
||||
{
|
||||
cairo_get_matrix(m_cobject, &matrix);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
RefPtr<Surface> Context::get_target()
|
||||
{
|
||||
cairo_surface_t* surface = cairo_get_target(const_cast<cairo_t*>(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return RefPtr<Surface>(new Surface(surface, false /* does not have reference */));
|
||||
}
|
||||
|
||||
RefPtr<const Surface> Context::get_target() const
|
||||
{
|
||||
cairo_surface_t* surface = cairo_get_target(const_cast<cairo_t*>(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return RefPtr<const Surface>(new Surface(surface, false /* does not have reference */));
|
||||
}
|
||||
|
||||
Path* Context::copy_path() const
|
||||
{
|
||||
cairo_path_t* cresult = cairo_copy_path(const_cast<cairo_t*>(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return new Path(cresult, true /* take ownership */); //The caller must delete it.
|
||||
}
|
||||
|
||||
Path* Context::copy_path_flat() const
|
||||
{
|
||||
cairo_path_t* cresult = cairo_copy_path_flat(const_cast<cairo_t*>(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return new Path(cresult, true /* take ownership */); //The caller must delete it.
|
||||
}
|
||||
|
||||
void Context::append_path(const Path& path)
|
||||
{
|
||||
cairo_append_path(m_cobject, const_cast<cairo_path_t*>(path.cobj()));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::push_group()
|
||||
{
|
||||
cairo_push_group(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Context::push_group_with_content(Content content)
|
||||
{
|
||||
cairo_push_group_with_content(m_cobject, static_cast<cairo_content_t>(content));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
RefPtr<Pattern> Context::pop_group()
|
||||
{
|
||||
cairo_pattern_t* pattern = cairo_pop_group(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return RefPtr<Pattern>(new Pattern(pattern));
|
||||
}
|
||||
|
||||
void Context::pop_group_to_source()
|
||||
{
|
||||
cairo_pop_group_to_source(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
RefPtr<Surface> Context::get_group_target()
|
||||
{
|
||||
cairo_surface_t* surface = cairo_get_group_target(m_cobject);
|
||||
// surface can be NULL if you're not between push/pop group calls
|
||||
if (surface == NULL)
|
||||
{
|
||||
// FIXME: is this really the right way to handle this?
|
||||
throw_exception(CAIRO_STATUS_NULL_POINTER);
|
||||
}
|
||||
return RefPtr<Surface>(new Surface(surface, false));
|
||||
}
|
||||
|
||||
RefPtr<const Surface> Context::get_group_target() const
|
||||
{
|
||||
cairo_surface_t* surface = cairo_get_group_target(m_cobject);
|
||||
// surface can be NULL if you're not between push/pop group calls
|
||||
if (surface == NULL)
|
||||
{
|
||||
// FIXME: is this really the right way to handle this?
|
||||
throw_exception(CAIRO_STATUS_NULL_POINTER);
|
||||
}
|
||||
return RefPtr<const Surface>(new Surface(surface, false));
|
||||
}
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
931
libs/cairomm/cairomm/context.h
Normal file
931
libs/cairomm/cairomm/context.h
Normal file
|
|
@ -0,0 +1,931 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_CONTEXT_H
|
||||
#define __CAIROMM_CONTEXT_H
|
||||
|
||||
#include <cairomm/surface.h>
|
||||
#include <cairomm/fontface.h>
|
||||
#include <cairomm/pattern.h>
|
||||
#include <cairomm/path.h>
|
||||
#include <valarray>
|
||||
#include <vector>
|
||||
#include <cairo.h>
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
typedef cairo_glyph_t Glyph; //A simple struct.
|
||||
typedef cairo_font_extents_t FontExtents; //A simple struct.
|
||||
typedef cairo_text_extents_t TextExtents; //A simple struct.
|
||||
typedef cairo_matrix_t Matrix; //A simple struct. //TODO: Derive and add operator[] and operator. matrix multiplication?
|
||||
|
||||
/** Context is the main class used to draw in cairomm.
|
||||
* In the simplest case, create a Context with its target Surface, set its
|
||||
* drawing options (line width, color, etc), create shapes with methods like
|
||||
* move_to() and line_to(), and then draw the shapes to the Surface using
|
||||
* methods such as stroke() or fill().
|
||||
*
|
||||
* Context is a reference-counted object that should be used via Cairo::RefPtr.
|
||||
*/
|
||||
class Context
|
||||
{
|
||||
protected:
|
||||
explicit Context(const RefPtr<Surface>& target);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
*
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit Context(cairo_t* cobject, bool has_reference = false);
|
||||
|
||||
static RefPtr<Context> create(const RefPtr<Surface>& target);
|
||||
|
||||
virtual ~Context();
|
||||
|
||||
/** Makes a copy of the current state of the Context and saves it on an
|
||||
* internal stack of saved states. When restore() is called, it will be
|
||||
* restored to the saved state. Multiple calls to save() and restore() can be
|
||||
* nested; each call to restore() restores the state from the matching paired
|
||||
* save().
|
||||
*
|
||||
* It isn't necessary to clear all saved states before a cairo_t is freed.
|
||||
* Any saved states will be freed when the Context is destroyed.
|
||||
*
|
||||
* @sa restore()
|
||||
*/
|
||||
void save();
|
||||
|
||||
/** Restores cr to the state saved by a preceding call to save() and removes
|
||||
* that state from the stack of saved states.
|
||||
*
|
||||
* @sa save()
|
||||
*/
|
||||
void restore();
|
||||
|
||||
/** Sets the compositing operator to be used for all drawing operations. See
|
||||
* Operator for details on the semantics of each available compositing
|
||||
* operator.
|
||||
*
|
||||
* @param op a compositing operator, specified as a Operator
|
||||
*/
|
||||
void set_operator(Operator op);
|
||||
|
||||
/** Sets the source pattern within the Context to source. This Pattern will
|
||||
* then be used for any subsequent drawing operation until a new source
|
||||
* pattern is set.
|
||||
*
|
||||
* Note: The Pattern's transformation matrix will be locked to the user space
|
||||
* in effect at the time of set_source(). This means that further
|
||||
* modifications of the current transformation matrix will not affect the
|
||||
* source pattern.
|
||||
*
|
||||
* @param source a Pattern to be used as the source for subsequent drawing
|
||||
* operations.
|
||||
*
|
||||
* @sa Pattern::set_matrix()
|
||||
* @sa set_source_rgb()
|
||||
* @sa set_source_rgba()
|
||||
* @sa set_source(const RefPtr<Surface>& surface, double x, double y)
|
||||
*/
|
||||
void set_source(const RefPtr<const Pattern>& source);
|
||||
|
||||
/** Sets the source pattern within the Context to an opaque color. This
|
||||
* opaque color will then be used for any subsequent drawing operation until
|
||||
* a new source pattern is set.
|
||||
*
|
||||
* The color components are floating point numbers in the range 0 to 1. If
|
||||
* the values passed in are outside that range, they will be clamped.
|
||||
*
|
||||
* @param red red component of color
|
||||
* @param green green component of color
|
||||
* @param blue blue component of color
|
||||
*
|
||||
* @sa set_source_rgba()
|
||||
* @sa set_source()
|
||||
*/
|
||||
void set_source_rgb(double red, double green, double blue);
|
||||
|
||||
/** Sets the source pattern within the Context to a translucent color. This
|
||||
* color will then be used for any subsequent drawing operation until a new
|
||||
* source pattern is set.
|
||||
*
|
||||
* The color and alpha components are floating point numbers in the range 0
|
||||
* to 1. If the values passed in are outside that range, they will be
|
||||
* clamped.
|
||||
*
|
||||
* @param red red component of color
|
||||
* @param green green component of color
|
||||
* @param blue blue component of color
|
||||
* @param alpha alpha component of color
|
||||
*
|
||||
* @sa set_source_rgb()
|
||||
* @sa set_source()
|
||||
*/
|
||||
void set_source_rgba(double red, double green, double blue, double alpha);
|
||||
|
||||
/** This is a convenience function for creating a pattern from a Surface and
|
||||
* setting it as the source
|
||||
*
|
||||
* The x and y parameters give the user-space coordinate at which the Surface
|
||||
* origin should appear. (The Surface origin is its upper-left corner before
|
||||
* any transformation has been applied.) The x and y patterns are negated and
|
||||
* then set as translation values in the pattern matrix.
|
||||
*
|
||||
* Other than the initial translation pattern matrix, as described above, all
|
||||
* other pattern attributes, (such as its extend mode), are set to the
|
||||
* default values as in Context::create(const RefPtr<Surface>& target). The
|
||||
* resulting pattern can be queried with get_source() so that these
|
||||
* attributes can be modified if desired, (eg. to create a repeating pattern
|
||||
* with Pattern::set_extend()).
|
||||
*
|
||||
* @param surface : a Surface to be used to set the source pattern
|
||||
* @param x : User-space X coordinate for surface origin
|
||||
* @param y : User-space Y coordinate for surface origin
|
||||
*/
|
||||
void set_source(const RefPtr<Surface>& surface, double x, double y);
|
||||
|
||||
/** Sets the tolerance used when converting paths into trapezoids. Curved
|
||||
* segments of the path will be subdivided until the maximum deviation
|
||||
* between the original path and the polygonal approximation is less than
|
||||
* tolerance. The default value is 0.1. A larger value will give better
|
||||
* performance, a smaller value, better appearance. (Reducing the value from
|
||||
* the default value of 0.1 is unlikely to improve appearance significantly.)
|
||||
*
|
||||
* @param tolerance the tolerance, in device units (typically pixels)
|
||||
*/
|
||||
void set_tolerance(double tolerance);
|
||||
|
||||
/** Set the antialiasing mode of the rasterizer used for drawing shapes. This
|
||||
* value is a hint, and a particular backend may or may not support a
|
||||
* particular value. At the current time, no backend supports
|
||||
* CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes.
|
||||
*
|
||||
* Note that this option does not affect text rendering, instead see
|
||||
* FontOptions::set_antialias().
|
||||
*
|
||||
* @param antialias the new antialiasing mode
|
||||
*/
|
||||
void set_antialias(Antialias antialias);
|
||||
|
||||
/** Set the current fill rule within the cairo Context. The fill rule is used
|
||||
* to determine which regions are inside or outside a complex (potentially
|
||||
* self-intersecting) path. The current fill rule affects both fill() and
|
||||
* clip(). See FillRule for details on the semantics of each available fill
|
||||
* rule.
|
||||
*
|
||||
* @param fill_rule a fill rule, specified as a FillRule
|
||||
*/
|
||||
void set_fill_rule(FillRule fill_rule);
|
||||
|
||||
/** Sets the current line width within the cairo Context. The line width
|
||||
* specifies the diameter of a pen that is circular in user-space.
|
||||
*
|
||||
* As with the other stroke parameters, the current line cap style is
|
||||
* examined by stroke(), stroke_extents(), and stroke_to_path(), but does not
|
||||
* have any effect during path construction.
|
||||
*
|
||||
* @param width a line width, as a user-space value
|
||||
*/
|
||||
void set_line_width(double width);
|
||||
|
||||
/** Sets the current line cap style within the cairo Context. See
|
||||
* LineCap for details about how the available line cap styles are drawn.
|
||||
*
|
||||
* As with the other stroke parameters, the current line cap style is
|
||||
* examined by stroke(), stroke_extents(), and stroke_to_path(), but does not
|
||||
* have any effect during path construction.
|
||||
*
|
||||
* @param line_cap a line cap style, as a LineCap
|
||||
*/
|
||||
void set_line_cap(LineCap line_cap);
|
||||
|
||||
/** Sets the current line join style within the cairo Context. See LineJoin
|
||||
* for details about how the available line join styles are drawn.
|
||||
*
|
||||
* As with the other stroke parameters, the current line join style is
|
||||
* examined by stroke(), stroke_extents(), and stroke_to_path(), but does not
|
||||
* have any effect during path construction.
|
||||
*
|
||||
* @param line_join a line joint style, as a LineJoin
|
||||
*/
|
||||
void set_line_join(LineJoin line_join);
|
||||
|
||||
/** Sets the dash pattern to be used by stroke(). A dash pattern is specified
|
||||
* by dashes, an array of positive values. Each value provides the user-space
|
||||
* length of altenate "on" and "off" portions of the stroke. The offset
|
||||
* specifies an offset into the pattern at which the stroke begins.
|
||||
*
|
||||
* If dashes is empty dashing is disabled. If the size of dashes is 1, a
|
||||
* symmetric pattern is assumed with alternating on and off portions of the
|
||||
* size specified by the single value in dashes.
|
||||
*
|
||||
* It is invalid for any value in dashes to be negative, or for all values to
|
||||
* be 0. If this is the case, an exception will be thrown
|
||||
*
|
||||
* @param dashes an array specifying alternate lengths of on and off portions
|
||||
* @param offset an offset into the dash pattern at which the stroke should start
|
||||
*
|
||||
* @exception
|
||||
*/
|
||||
void set_dash(std::valarray<double>& dashes, double offset);
|
||||
|
||||
/** This function disables a dash pattern that was set with set_dash()
|
||||
*/
|
||||
void unset_dash();
|
||||
void set_miter_limit(double limit);
|
||||
|
||||
/** Modifies the current transformation matrix (CTM) by translating the
|
||||
* user-space origin by (tx, ty). This offset is interpreted as a user-space
|
||||
* coordinate according to the CTM in place before the new call to
|
||||
* cairo_translate. In other words, the translation of the user-space origin
|
||||
* takes place after any existing transformation.
|
||||
*
|
||||
* @param tx amount to translate in the X direction
|
||||
* @param ty amount to translate in the Y direction
|
||||
*/
|
||||
void translate(double tx, double ty);
|
||||
|
||||
/** Modifies the current transformation matrix (CTM) by scaling the X and Y
|
||||
* user-space axes by sx and sy respectively. The scaling of the axes takes
|
||||
* place after any existing transformation of user space.
|
||||
*
|
||||
* @param sx scale factor for the X dimension
|
||||
* @param sy scale factor for the Y dimension
|
||||
*/
|
||||
void scale(double sx, double sy);
|
||||
|
||||
/** Modifies the current transformation matrix (CTM) by rotating the
|
||||
* user-space axes by angle radians. The rotation of the axes takes places
|
||||
* after any existing transformation of user space. The rotation direction
|
||||
* for positive angles is from the positive X axis toward the positive Y
|
||||
* axis.
|
||||
*
|
||||
* @param angle angle (in radians) by which the user-space axes will be
|
||||
* rotated
|
||||
*/
|
||||
void rotate(double angle_radians);
|
||||
|
||||
/** A convenience wrapper around rotate() that accepts angles in degrees
|
||||
*
|
||||
* @param angle_degrees angle (in degrees) by which the user-space axes
|
||||
* should be rotated
|
||||
*/
|
||||
void rotate_degrees(double angle_degres);
|
||||
|
||||
/** Modifies the current transformation matrix (CTM) by applying matrix as an
|
||||
* additional transformation. The new transformation of user space takes
|
||||
* place after any existing transformation.
|
||||
*
|
||||
* @param matrix a transformation to be applied to the user-space axes
|
||||
*/
|
||||
void transform(const Matrix& matrix);
|
||||
|
||||
/** Modifies the current transformation matrix (CTM) by setting it equal to
|
||||
* matrix.
|
||||
*
|
||||
* @param matrix a transformation matrix from user space to device space
|
||||
*/
|
||||
void set_matrix(const Matrix& matrix);
|
||||
|
||||
/** Resets the current transformation matrix (CTM) by setting it equal to the
|
||||
* identity matrix. That is, the user-space and device-space axes will be
|
||||
* aligned and one user-space unit will transform to one device-space unit.
|
||||
*/
|
||||
void set_identity_matrix();
|
||||
|
||||
/** Transform a coordinate from user space to device space by multiplying the
|
||||
* given point by the current transformation matrix (CTM).
|
||||
*
|
||||
* @param x X value of coordinate (in/out parameter)
|
||||
* @param y Y value of coordinate (in/out parameter)
|
||||
*/
|
||||
void user_to_device(double& x, double& y);
|
||||
|
||||
/** Transform a distance vector from user space to device space. This
|
||||
* function is similar to user_to_device() except that the translation
|
||||
* components of the CTM will be ignored when transforming (dx,dy).
|
||||
*
|
||||
* @param dx X component of a distance vector (in/out parameter)
|
||||
* @param dy Y component of a distance vector (in/out parameter)
|
||||
*/
|
||||
void user_to_device_distance(double& dx, double& dy);
|
||||
|
||||
/** Transform a coordinate from device space to user space by multiplying the
|
||||
* given point by the inverse of the current transformation matrix (CTM).
|
||||
*
|
||||
* @param x X value of coordinate (in/out parameter)
|
||||
* @param y Y value of coordinate (in/out parameter)
|
||||
*/
|
||||
void device_to_user(double& x, double& y);
|
||||
|
||||
/** Transform a distance vector from device space to user space. This
|
||||
* function is similar to device_to_user() except that the translation
|
||||
* components of the inverse CTM will be ignored when transforming (dx,dy).
|
||||
*
|
||||
* @param dx X component of a distance vector (in/out parameter)
|
||||
* @param dy Y component of a distance vector (in/out parameter)
|
||||
*/
|
||||
void device_to_user_distance(double& dx, double& dy);
|
||||
|
||||
/** Clears the current path. After this call there will be no current point.
|
||||
*/
|
||||
void begin_new_path();
|
||||
|
||||
/** Begin a new subpath. Note that the existing path is not affected. After
|
||||
* this call there will be no current point.
|
||||
*
|
||||
* In many cases, this call is not needed since new subpaths are frequently
|
||||
* started with move_to().
|
||||
*
|
||||
* A call to begin_new_sub_path() is particularly useful when beginning a new
|
||||
* subpath with one of the arc() calls. This makes things easier as it is no
|
||||
* longer necessary to manually compute the arc's initial coordinates for a
|
||||
* call to move_to().
|
||||
*/
|
||||
void begin_new_sub_path();
|
||||
|
||||
/** If the current subpath is not empty, begin a new subpath. After this call
|
||||
* the current point will be (x, y).
|
||||
*
|
||||
* @param x the X coordinate of the new position
|
||||
* @param y the Y coordinate of the new position
|
||||
*/
|
||||
void move_to(double x, double y);
|
||||
|
||||
/** Adds a line to the path from the current point to position (x, y) in
|
||||
* user-space coordinates. After this call the current point will be (x, y).
|
||||
*
|
||||
* @param x the X coordinate of the end of the new line
|
||||
* @param y the Y coordinate of the end of the new line
|
||||
*/
|
||||
void line_to(double x, double y);
|
||||
|
||||
/** Adds a cubic Bezier spline to the path from the current point to position
|
||||
* (x3, y3) in user-space coordinates, using (x1, y1) and (x2, y2) as the
|
||||
* control points. After this call the current point will be (x3, y3).
|
||||
*
|
||||
* @param x1 the X coordinate of the first control point
|
||||
* @param y1 the Y coordinate of the first control point
|
||||
* @param x2 the X coordinate of the second control point
|
||||
* @param y2 the Y coordinate of the second control point
|
||||
* @param x3 the X coordinate of the end of the curve
|
||||
* @param y3 the Y coordinate of the end of the curve
|
||||
*/
|
||||
void curve_to(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
|
||||
/** Adds a circular arc of the given radius to the current path. The arc is
|
||||
* centered at (xc, yc), begins at angle1 and proceeds in the direction of
|
||||
* increasing angles to end at angle2. If angle2 is less than angle1 it will
|
||||
* be progressively increased by 2*M_PI until it is greater than angle1.
|
||||
*
|
||||
* If there is a current point, an initial line segment will be added to the
|
||||
* path to connect the current point to the beginning of the arc.
|
||||
*
|
||||
* Angles are measured in radians. An angle of 0 is in the direction of the
|
||||
* positive X axis (in user-space). An angle of M_PI radians (90 degrees) is
|
||||
* in the direction of the positive Y axis (in user-space). Angles increase
|
||||
* in the direction from the positive X axis toward the positive Y axis. So
|
||||
* with the default transformation matrix, angles increase in a clockwise
|
||||
* direction.
|
||||
*
|
||||
* (To convert from degrees to radians, use degrees * (M_PI / 180.).)
|
||||
*
|
||||
* This function gives the arc in the direction of increasing angles; see
|
||||
* arc_negative() to get the arc in the direction of decreasing angles.
|
||||
*
|
||||
* The arc is circular in user-space. To achieve an elliptical arc, you can
|
||||
* scale the current transformation matrix by different amounts in the X and
|
||||
* Y directions. For example, to draw an ellipse in the box given by x, y,
|
||||
* width, height:
|
||||
*
|
||||
* @code
|
||||
* context->save();
|
||||
* context->translate(x, y);
|
||||
* context->scale(width / 2.0, height / 2.0);
|
||||
* context->arc(0.0, 0.0, 1.0, 0.0, 2 * M_PI);
|
||||
* context->restore();
|
||||
* @endcode
|
||||
*
|
||||
* @param xc X position of the center of the arc
|
||||
* @param yc Y position of the center of the arc
|
||||
* @param radius the radius of the arc
|
||||
* @param angle1 the start angle, in radians
|
||||
* @param angle2 the end angle, in radians
|
||||
*/
|
||||
void arc(double xc, double yc, double radius, double angle1, double angle2);
|
||||
|
||||
/** Adds a circular arc of the given radius to the current path. The arc is
|
||||
* centered at (xc, yc), begins at angle1 and proceeds in the direction of
|
||||
* decreasing angles to end at angle2. If angle2 is greater than angle1 it
|
||||
* will be progressively decreased by 2*M_PI until it is greater than angle1.
|
||||
*
|
||||
* See arc() for more details. This function differs only in the direction of
|
||||
* the arc between the two angles.
|
||||
*
|
||||
* @param xc X position of the center of the arc
|
||||
* @param yc Y position of the center of the arc
|
||||
* @param radius the radius of the arc
|
||||
* @param angle1 the start angle, in radians
|
||||
* @param angle2 the end angle, in radians
|
||||
*/
|
||||
void arc_negative(double xc, double yc, double radius, double angle1, double angle2);
|
||||
|
||||
/** If the current subpath is not empty, begin a new subpath. After this call
|
||||
* the current point will offset by (x, y).
|
||||
*
|
||||
* Given a current point of (x, y),
|
||||
* @code
|
||||
* rel_move_to(dx, dy)
|
||||
* @endcode
|
||||
* is logically equivalent to
|
||||
* @code
|
||||
* move_to(x + dx, y + dy)
|
||||
* @endcode
|
||||
*
|
||||
* @param dx the X offset
|
||||
* @param dy the Y offset
|
||||
*/
|
||||
void rel_move_to(double dx, double dy);
|
||||
|
||||
/** Relative-coordinate version of line_to(). Adds a line to the path from
|
||||
* the current point to a point that is offset from the current point by (dx,
|
||||
* dy) in user space. After this call the current point will be offset by
|
||||
* (dx, dy).
|
||||
*
|
||||
* Given a current point of (x, y),
|
||||
* @code
|
||||
* rel_line_to(dx, dy)
|
||||
* @endcode
|
||||
* is logically equivalent to
|
||||
* @code
|
||||
* line_to(x + dx, y + dy).
|
||||
* @endcode
|
||||
*
|
||||
* @param dx the X offset to the end of the new line
|
||||
* @param dy the Y offset to the end of the new line
|
||||
*/
|
||||
void rel_line_to(double dx, double dy);
|
||||
|
||||
/** Relative-coordinate version of curve_to(). All offsets are relative to
|
||||
* the current point. Adds a cubic Bezier spline to the path from the current
|
||||
* point to a point offset from the current point by (dx3, dy3), using points
|
||||
* offset by (dx1, dy1) and (dx2, dy2) as the control points. After this
|
||||
* call the current point will be offset by (dx3, dy3).
|
||||
*
|
||||
* Given a current point of (x, y),
|
||||
* @code
|
||||
* rel_curve_to(dx1, dy1, dx2, dy2, dx3, dy3)
|
||||
* @endcode
|
||||
* is logically equivalent to
|
||||
* @code
|
||||
* curve_to(x + dx1, y + dy1, x + dx2, y + dy2, x + dx3, y + dy3).
|
||||
* @endcode
|
||||
*
|
||||
* @param dx1 the X offset to the first control point
|
||||
* @param dy1 the Y offset to the first control point
|
||||
* @param dx2 the X offset to the second control point
|
||||
* @param dy2 the Y offset to the second control point
|
||||
* @param dx3 the X offset to the end of the curve
|
||||
* @param dy3 the Y offset to the end of the curve
|
||||
*/
|
||||
void rel_curve_to(double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
|
||||
|
||||
/** Adds a closed-subpath rectangle of the given size to the current path at
|
||||
* position (x, y) in user-space coordinates.
|
||||
*
|
||||
* This function is logically equivalent to:
|
||||
*
|
||||
* @code
|
||||
* context->move_to(x, y);
|
||||
* context->rel_line_to(width, 0);
|
||||
* context->rel_line_to(0, height);
|
||||
* context->rel_line_to(-width, 0);
|
||||
* context->close_path();
|
||||
* @endcode
|
||||
*
|
||||
* @param x the X coordinate of the top left corner of the rectangle
|
||||
* @param y the Y coordinate to the top left corner of the rectangle
|
||||
* @param width the width of the rectangle
|
||||
* @param height the height of the rectangle
|
||||
*/
|
||||
void rectangle(double x, double y, double width, double height);
|
||||
|
||||
/** Adds a line segment to the path from the current point to the beginning
|
||||
* of the current subpath, (the most recent point passed to move_to()), and
|
||||
* closes this subpath.
|
||||
*
|
||||
* The behavior of close_path() is distinct from simply calling line_to()
|
||||
* with the equivalent coordinate in the case of stroking. When a closed
|
||||
* subpath is stroked, there are no caps on the ends of the subpath. Instead,
|
||||
* there is a line join connecting the final and initial segments of the
|
||||
* subpath.
|
||||
*/
|
||||
void close_path();
|
||||
|
||||
/** A drawing operator that paints the current source everywhere within the
|
||||
* current clip region.
|
||||
*/
|
||||
void paint();
|
||||
|
||||
/** A drawing operator that paints the current source everywhere within the
|
||||
* current clip region using a mask of constant alpha value alpha. The effect
|
||||
* is similar to paint(), but the drawing is faded out using the alpha
|
||||
* value.
|
||||
*
|
||||
* @param alpha an alpha value, between 0 (transparent) and 1 (opaque)
|
||||
*/
|
||||
void paint_with_alpha(double alpha);
|
||||
|
||||
/** A drawing operator that paints the current source using the alpha channel
|
||||
* of pattern as a mask. (Opaque areas of mask are painted with the source,
|
||||
* transparent areas are not painted.)
|
||||
*
|
||||
* @param pattern a Pattern
|
||||
*/
|
||||
void mask(const RefPtr<const Pattern>& pattern);
|
||||
|
||||
/** A drawing operator that paints the current source using the alpha channel
|
||||
* of surface as a mask. (Opaque areas of surface are painted with the
|
||||
* source, transparent areas are not painted.)
|
||||
*
|
||||
* @param surface a Surface
|
||||
* @param surface_x X coordinate at which to place the origin of surface
|
||||
* @param surface_y Y coordinate at which to place the origin of surface
|
||||
*/
|
||||
void mask(const RefPtr<const Surface>& surface, double surface_x, double surface_y);
|
||||
|
||||
/** A drawing operator that strokes the current Path according to the current
|
||||
* line width, line join, line cap, and dash settings. After stroke(),
|
||||
* the current Path will be cleared from the cairo Context.
|
||||
*
|
||||
* @sa set_line_width()
|
||||
* @sa set_line_join()
|
||||
* @sa set_line_cap()
|
||||
* @sa set_dash()
|
||||
* @sa stroke_preserve().
|
||||
*/
|
||||
void stroke();
|
||||
|
||||
/** A drawing operator that strokes the current Path according to the current
|
||||
* line width, line join, line cap, and dash settings. Unlike stroke(),
|
||||
* stroke_preserve() preserves the Path within the cairo Context.
|
||||
*
|
||||
* @sa set_line_width()
|
||||
* @sa set_line_join()
|
||||
* @sa set_line_cap()
|
||||
* @sa set_dash()
|
||||
* @sa stroke_preserve().
|
||||
*/
|
||||
void stroke_preserve();
|
||||
|
||||
/** A drawing operator that fills the current path according to the current
|
||||
* fill rule, (each sub-path is implicitly closed before being filled). After
|
||||
* fill(), the current path will be cleared from the cairo context.
|
||||
*
|
||||
* @sa set_fill_rule()
|
||||
* @sa fill_preserve()
|
||||
*/
|
||||
void fill();
|
||||
|
||||
/** A drawing operator that fills the current path according to the current
|
||||
* fill rule, (each sub-path is implicitly closed before being filled).
|
||||
* Unlike fill(), fill_preserve() preserves the path within the
|
||||
* cairo Context.
|
||||
*
|
||||
* @sa set_fill_rule()
|
||||
* @sa fill().
|
||||
*/
|
||||
void fill_preserve();
|
||||
void copy_page();
|
||||
void show_page();
|
||||
bool in_stroke(double x, double y) const;
|
||||
bool in_fill(double x, double y) const;
|
||||
void get_stroke_extents(double& x1, double& y1, double& x2, double& y2) const;
|
||||
void get_fill_extents(double& x1, double& y1, double& x2, double& y2) const;
|
||||
|
||||
/** Reset the current clip region to its original, unrestricted state. That
|
||||
* is, set the clip region to an infinitely large shape containing the target
|
||||
* surface. Equivalently, if infinity is too hard to grasp, one can imagine
|
||||
* the clip region being reset to the exact bounds of the target surface.
|
||||
*
|
||||
* Note that code meant to be reusable should not call reset_clip() as it
|
||||
* will cause results unexpected by higher-level code which calls clip().
|
||||
* Consider using save() and restore() around clip() as a more robust means
|
||||
* of temporarily restricting the clip region.
|
||||
*/
|
||||
void reset_clip();
|
||||
|
||||
/** Establishes a new clip region by intersecting the current clip region
|
||||
* with the current Path as it would be filled by fill() and according to the
|
||||
* current fill rule.
|
||||
*
|
||||
* After clip(), the current path will be cleared from the cairo Context.
|
||||
*
|
||||
* The current clip region affects all drawing operations by effectively
|
||||
* masking out any changes to the surface that are outside the current clip
|
||||
* region.
|
||||
*
|
||||
* Calling clip() can only make the clip region smaller, never larger. But
|
||||
* the current clip is part of the graphics state, so a temporary restriction
|
||||
* of the clip region can be achieved by calling cairo_clip() within a
|
||||
* save()/restore() pair. The only other means of increasing the size of the
|
||||
* clip region is reset_clip().
|
||||
*
|
||||
* @sa set_fill_rule()
|
||||
*/
|
||||
void clip();
|
||||
|
||||
/** Establishes a new clip region by intersecting the current clip region
|
||||
* with the current path as it would be filled by fill() and according to the
|
||||
* current fill rule.
|
||||
*
|
||||
* Unlike clip(), cairo_clip_preserve preserves the path within the cairo
|
||||
* Context.
|
||||
*
|
||||
* @sa clip()
|
||||
* @sa set_fill_rule()
|
||||
*/
|
||||
void clip_preserve();
|
||||
void select_font_face(const std::string& family, FontSlant slant, FontWeight weight);
|
||||
void set_font_size(double size);
|
||||
void set_font_matrix(const Matrix& matrix);
|
||||
void get_font_matrix(Matrix& matrix) const;
|
||||
void set_font_options(const FontOptions& options);
|
||||
void show_text(const std::string& utf8);
|
||||
void show_glyphs(const std::vector<Glyph>& glyphs);
|
||||
RefPtr<FontFace> get_font_face();
|
||||
RefPtr<const FontFace> get_font_face() const;
|
||||
void get_font_extents(FontExtents& extents) const;
|
||||
void set_font_face(const RefPtr<const FontFace>& font_face);
|
||||
void get_text_extents(const std::string& utf8, TextExtents& extents) const;
|
||||
void get_glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents) const;
|
||||
void text_path(const std::string& utf8);
|
||||
void glyph_path(const std::vector<Glyph>& glyphs);
|
||||
|
||||
/** Gets the current compositing operator for a cairo Context
|
||||
*/
|
||||
Operator get_operator() const;
|
||||
|
||||
/** Gets the current source pattern for the Context
|
||||
*/
|
||||
RefPtr<Pattern> get_source();
|
||||
RefPtr<const Pattern> get_source() const;
|
||||
|
||||
/** Gets the current tolerance value, as set by set_tolerance()
|
||||
*/
|
||||
double get_tolerance() const;
|
||||
|
||||
/** Gets the current shape antialiasing mode, as set by set_antialias()
|
||||
*/
|
||||
Antialias get_antialias() const;
|
||||
|
||||
/** Gets the current point of the current path, which is conceptually the
|
||||
* final point reached by the path so far.
|
||||
*
|
||||
* The current point is returned in the user-space coordinate system. If
|
||||
* there is no defined current point then x and y will both be set to 0.0.
|
||||
*
|
||||
* Most path construction functions alter the current point. See the
|
||||
* following for details on how they affect the current point: clear_path(),
|
||||
* move_to(), line_to(), curve_to(), arc(), rel_move_to(), rel_line_to(),
|
||||
* rel_curve_to(), arc(), and text_path()
|
||||
*
|
||||
* @param x return value for X coordinate of the current point
|
||||
* @param y return value for Y coordinate of the current point
|
||||
*/
|
||||
void get_current_point (double& x, double& y) const;
|
||||
|
||||
/** Gets the current fill rule, as set by set_fill_rule().
|
||||
*/
|
||||
FillRule get_fill_rule() const;
|
||||
|
||||
/** Gets the current line width, as set by set_line_width()
|
||||
*/
|
||||
double get_line_width() const;
|
||||
|
||||
/** Gets the current line cap style, as set by set_line_cap()
|
||||
*/
|
||||
LineCap get_line_cap() const;
|
||||
|
||||
/** Gets the current line join style, as set by set_line_join()
|
||||
*/
|
||||
LineJoin get_line_join() const;
|
||||
|
||||
/** Gets the current miter limit, as set by set_miter_limit()
|
||||
*/
|
||||
double get_miter_limit() const;
|
||||
|
||||
/** Stores the current transformation matrix (CTM) into matrix.
|
||||
*
|
||||
* @param matrix return value for the matrix
|
||||
*/
|
||||
void get_matrix(Matrix& matrix);
|
||||
|
||||
/** Gets the target surface associated with this Context.
|
||||
*
|
||||
* @exception
|
||||
*/
|
||||
RefPtr<Surface> get_target();
|
||||
|
||||
/** Gets the target surface associated with this Context.
|
||||
*
|
||||
* @exception
|
||||
*/
|
||||
RefPtr<const Surface> get_target() const;
|
||||
|
||||
//TODO: Copy or reference-count a Path somethow instead of asking the caller to delete it?
|
||||
/** Creates a copy of the current path and returns it to the user.
|
||||
*
|
||||
* @todo See cairo_path_data_t for hints on how to iterate over the returned
|
||||
* data structure.
|
||||
*
|
||||
* @note The caller owns the Path object returned from this function. The
|
||||
* Path object must be freed when you are finished with it.
|
||||
*/
|
||||
Path* copy_path() const;
|
||||
|
||||
/** Gets a flattened copy of the current path and returns it to the user
|
||||
*
|
||||
* @todo See cairo_path_data_t for hints on how to iterate over the returned
|
||||
* data structure.
|
||||
*
|
||||
* This function is like copy_path() except that any curves in the path will
|
||||
* be approximated with piecewise-linear approximations, (accurate to within
|
||||
* the current tolerance value). That is, the result is guaranteed to not have
|
||||
* any elements of type CAIRO_PATH_CURVE_TO which will instead be
|
||||
* replaced by a series of CAIRO_PATH_LINE_TO elements.
|
||||
*
|
||||
* @note The caller owns the Path object returned from this function. The
|
||||
* Path object must be freed when you are finished with it.
|
||||
*/
|
||||
Path* copy_path_flat() const;
|
||||
|
||||
/** Append the path onto the current path. The path may be either the return
|
||||
* value from one of copy_path() or copy_path_flat() or it may be constructed
|
||||
* manually.
|
||||
*
|
||||
* @param path path to be appended
|
||||
*/
|
||||
void append_path(const Path& path);
|
||||
|
||||
/** Temporarily redirects drawing to an intermediate surface known as a group.
|
||||
* The redirection lasts until the group is completed by a call to pop_group()
|
||||
* or pop_group_to_source(). These calls provide the result of any drawing to
|
||||
* the group as a pattern, (either as an explicit object, or set as the source
|
||||
* pattern).
|
||||
*
|
||||
* This group functionality can be convenient for performing intermediate
|
||||
* compositing. One common use of a group is to render objects as opaque
|
||||
* within the group, (so that they occlude each other), and then blend the
|
||||
* result with translucence onto the destination.
|
||||
*
|
||||
* Groups can be nested arbitrarily deep by making balanced calls to
|
||||
* push_group()/pop_group(). Each call pushes/pops the new target group
|
||||
* onto/from a stack.
|
||||
*
|
||||
* The push_group() function calls save() so that any changes to the graphics
|
||||
* state will not be visible outside the group, (the pop_group functions call
|
||||
* restore()).
|
||||
*
|
||||
* By default the intermediate group will have a content type of
|
||||
* CONTENT_COLOR_ALPHA. Other content types can be chosen for the group by
|
||||
* using push_group_with_content() instead.
|
||||
*
|
||||
* As an example, here is how one might fill and stroke a path with
|
||||
* translucence, but without any portion of the fill being visible under the
|
||||
* stroke:
|
||||
*
|
||||
* @code
|
||||
* cr->push_group();
|
||||
* cr->set_source(fill_pattern);
|
||||
* cr->fill_preserve();
|
||||
* cr->set_source(stroke_pattern);
|
||||
* cr->stroke();
|
||||
* cr->pop_group_to_source();
|
||||
* cr->paint_with_alpha(alpha);
|
||||
* @endcode
|
||||
*/
|
||||
void push_group();
|
||||
|
||||
/**
|
||||
* Temporarily redirects drawing to an intermediate surface known as a
|
||||
* group. The redirection lasts until the group is completed by a call
|
||||
* to pop_group() or pop_group_to_source(). These calls provide the result of
|
||||
* any drawing to the group as a pattern, (either as an explicit object, or set
|
||||
* as the source pattern).
|
||||
*
|
||||
* The group will have a content type of @content. The ability to control this
|
||||
* content type is the only distinction between this function and push_group()
|
||||
* which you should see for a more detailed description of group rendering.
|
||||
*
|
||||
* @param content: indicates the type of group that will be created
|
||||
*/
|
||||
void push_group_with_content(Content content);
|
||||
|
||||
/**
|
||||
* Terminates the redirection begun by a call to push_group() or
|
||||
* push_group_with_content() and returns a new pattern containing the results
|
||||
* of all drawing operations performed to the group.
|
||||
*
|
||||
* The pop_group() function calls restore(), (balancing a call to save() by
|
||||
* the push_group function), so that any changes to the graphics state will
|
||||
* not be visible outside the group.
|
||||
*
|
||||
* @return a (surface) pattern containing the results of all drawing
|
||||
* operations performed to the group.
|
||||
**/
|
||||
RefPtr<Pattern> pop_group();
|
||||
|
||||
/**
|
||||
* Terminates the redirection begun by a call to push_group() or
|
||||
* push_group_with_content() and installs the resulting pattern as the source
|
||||
* pattern in the given cairo Context.
|
||||
*
|
||||
* The behavior of this function is equivalent to the sequence of operations:
|
||||
*
|
||||
* @code
|
||||
* RefPtr<Pattern> group = cr->pop_group();
|
||||
* cr->set_source(group);
|
||||
* @endcode
|
||||
*
|
||||
* but is more convenient as their is no need for a variable to store
|
||||
* the short-lived pointer to the pattern.
|
||||
*
|
||||
* The pop_group() function calls restore(), (balancing a call to save() by
|
||||
* the push_group function), so that any changes to the graphics state will
|
||||
* not be visible outside the group.
|
||||
**/
|
||||
void pop_group_to_source();
|
||||
|
||||
/**
|
||||
* Gets the target surface for the current group as started by the most recent
|
||||
* call to push_group() or push_group_with_content().
|
||||
*
|
||||
* This function will return NULL if called "outside" of any group rendering
|
||||
* blocks, (that is, after the last balancing call to pop_group() or
|
||||
* pop_group_to_source()).
|
||||
*
|
||||
* @exception
|
||||
*
|
||||
**/
|
||||
RefPtr<Surface> get_group_target();
|
||||
|
||||
/**
|
||||
* Same as the non-const version but returns a reference to a const Surface
|
||||
*/
|
||||
RefPtr<const Surface> get_group_target() const;
|
||||
|
||||
/** The base cairo C type that is wrapped by Cairo::Context
|
||||
*/
|
||||
typedef cairo_t cobject;
|
||||
|
||||
/** Gets a pointer to the base C type that is wrapped by the Context
|
||||
*/
|
||||
inline cobject* cobj() { return m_cobject; }
|
||||
|
||||
/** Gets a pointer to the base C type that is wrapped by the Context
|
||||
*/
|
||||
inline const cobject* cobj() const { return m_cobject; }
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
///For use only by the cairomm implementation.
|
||||
inline ErrorStatus get_status() const
|
||||
{ return cairo_status(const_cast<cairo_t*>(cobj())); }
|
||||
|
||||
void reference() const;
|
||||
void unreference() const;
|
||||
#endif //DOXYGEN_IGNORE_THIS
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
cobject* m_cobject;
|
||||
};
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_CONTEXT_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
201
libs/cairomm/cairomm/enums.h
Normal file
201
libs/cairomm/cairomm/enums.h
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_ENUMS_H
|
||||
#define __CAIROMM_ENUMS_H
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
//This is only used internally, but it must be in a public header because we inline some methods.
|
||||
typedef cairo_status_t ErrorStatus;
|
||||
#endif //DOXYGEN_IGNORE_THIS
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OPERATOR_CLEAR = CAIRO_OPERATOR_CLEAR,
|
||||
|
||||
OPERATOR_SOURCE = CAIRO_OPERATOR_SOURCE,
|
||||
OPERATOR_OVER = CAIRO_OPERATOR_OVER,
|
||||
OPERATOR_IN = CAIRO_OPERATOR_IN,
|
||||
OPERATOR_OUT = CAIRO_OPERATOR_OUT,
|
||||
OPERATOR_ATOP = CAIRO_OPERATOR_ATOP,
|
||||
|
||||
OPERATOR_DEST = CAIRO_OPERATOR_DEST,
|
||||
OPERATOR_DEST_OVER = CAIRO_OPERATOR_DEST_OVER,
|
||||
OPERATOR_DEST_IN = CAIRO_OPERATOR_DEST_IN,
|
||||
OPERATOR_DEST_OUT = CAIRO_OPERATOR_DEST_OUT,
|
||||
OPERATOR_DEST_ATOP = CAIRO_OPERATOR_DEST_ATOP,
|
||||
|
||||
OPERATOR_XOR = CAIRO_OPERATOR_XOR,
|
||||
OPERATOR_ADD = CAIRO_OPERATOR_ADD,
|
||||
OPERATOR_SATURATE = CAIRO_OPERATOR_SATURATE
|
||||
} Operator;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ANTIALIAS_DEFAULT = CAIRO_ANTIALIAS_DEFAULT,
|
||||
ANTIALIAS_NONE = CAIRO_ANTIALIAS_NONE,
|
||||
ANTIALIAS_GRAY = CAIRO_ANTIALIAS_GRAY,
|
||||
ANTIALIAS_SUBPIXEL = CAIRO_ANTIALIAS_SUBPIXEL
|
||||
} Antialias;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FILL_RULE_WINDING = CAIRO_FILL_RULE_WINDING,
|
||||
FILL_RULE_EVEN_ODD = CAIRO_FILL_RULE_EVEN_ODD
|
||||
} FillRule;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LINE_CAP_BUTT = CAIRO_LINE_CAP_BUTT,
|
||||
LINE_CAP_ROUND = CAIRO_LINE_CAP_ROUND,
|
||||
LINE_CAP_SQUARE = CAIRO_LINE_CAP_SQUARE
|
||||
} LineCap;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LINE_JOIN_MITER = CAIRO_LINE_JOIN_MITER,
|
||||
LINE_JOIN_ROUND = CAIRO_LINE_JOIN_ROUND,
|
||||
LINE_JOIN_BEVEL = CAIRO_LINE_JOIN_BEVEL
|
||||
} LineJoin;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FONT_SLANT_NORMAL = CAIRO_FONT_SLANT_NORMAL,
|
||||
FONT_SLANT_ITALIC = CAIRO_FONT_SLANT_ITALIC,
|
||||
FONT_SLANT_OBLIQUE = CAIRO_FONT_SLANT_OBLIQUE
|
||||
} FontSlant;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FONT_WEIGHT_NORMAL = CAIRO_FONT_WEIGHT_NORMAL,
|
||||
FONT_WEIGHT_BOLD = CAIRO_FONT_WEIGHT_BOLD
|
||||
} FontWeight;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CONTENT_COLOR = CAIRO_CONTENT_COLOR,
|
||||
CONTENT_ALPHA = CAIRO_CONTENT_ALPHA,
|
||||
CONTENT_COLOR_ALPHA = CAIRO_CONTENT_COLOR_ALPHA
|
||||
} Content;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FORMAT_ARGB32 = CAIRO_FORMAT_ARGB32,
|
||||
FORMAT_RGB24 = CAIRO_FORMAT_RGB24,
|
||||
FORMAT_A8 = CAIRO_FORMAT_A8,
|
||||
FORMAT_A1 = CAIRO_FORMAT_A1,
|
||||
FORMAT_RGB16_565 = CAIRO_FORMAT_RGB16_565
|
||||
} Format;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EXTEND_NONE = CAIRO_EXTEND_NONE,
|
||||
EXTEND_REPEAT = CAIRO_EXTEND_REPEAT,
|
||||
EXTEND_REFLECT = CAIRO_EXTEND_REFLECT,
|
||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,1,1)
|
||||
EXTEND_PAD = CAIRO_EXTEND_PAD
|
||||
#endif /* CAIRO_VERSION > CAIRO_VERSION_ENCODE(1,1,1) */
|
||||
} Extend;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FILTER_FAST = CAIRO_FILTER_FAST,
|
||||
FILTER_GOOD = CAIRO_FILTER_GOOD,
|
||||
FILTER_BEST = CAIRO_FILTER_BEST,
|
||||
FILTER_NEAREST = CAIRO_FILTER_NEAREST,
|
||||
FILTER_BILINEAR = CAIRO_FILTER_BILINEAR,
|
||||
FILTER_GAUSSIAN = CAIRO_FILTER_GAUSSIAN
|
||||
} Filter;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUBPIXEL_ORDER_DEFAULT = CAIRO_SUBPIXEL_ORDER_DEFAULT,
|
||||
SUBPIXEL_ORDER_RGB = CAIRO_SUBPIXEL_ORDER_RGB,
|
||||
SUBPIXEL_ORDER_BGR = CAIRO_SUBPIXEL_ORDER_BGR,
|
||||
SUBPIXEL_ORDER_VRGB = CAIRO_SUBPIXEL_ORDER_VRGB,
|
||||
SUBPIXEL_ORDER_VBGR = CAIRO_SUBPIXEL_ORDER_VBGR
|
||||
} SubpixelOrder;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HINT_STYLE_DEFAULT = CAIRO_HINT_STYLE_DEFAULT,
|
||||
HINT_STYLE_NONE = CAIRO_HINT_STYLE_NONE,
|
||||
HINT_STYLE_SLIGHT = CAIRO_HINT_STYLE_SLIGHT,
|
||||
HINT_STYLE_MEDIUM = CAIRO_HINT_STYLE_MEDIUM,
|
||||
HINT_STYLE_FULL = CAIRO_HINT_STYLE_FULL
|
||||
} HintStyle;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HINT_METRICS_DEFAULT = CAIRO_HINT_METRICS_DEFAULT,
|
||||
HINT_METRICS_OFF = CAIRO_HINT_METRICS_OFF,
|
||||
HINT_METRICS_ON = CAIRO_HINT_METRICS_ON
|
||||
} HintMetrics;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SURFACE_TYPE_IMAGE = CAIRO_SURFACE_TYPE_IMAGE,
|
||||
SURFACE_TYPE_PDF = CAIRO_SURFACE_TYPE_PDF,
|
||||
SURFACE_TYPE_PS = CAIRO_SURFACE_TYPE_PS,
|
||||
SURFACE_TYPE_XLIB = CAIRO_SURFACE_TYPE_XLIB,
|
||||
SURFACE_TYPE_XCB = CAIRO_SURFACE_TYPE_XCB,
|
||||
SURFACE_TYPE_GLITZ = CAIRO_SURFACE_TYPE_GLITZ,
|
||||
SURFACE_TYPE_QUARTZ = CAIRO_SURFACE_TYPE_QUARTZ,
|
||||
SURFACE_TYPE_WIN32 = CAIRO_SURFACE_TYPE_WIN32,
|
||||
SURFACE_TYPE_BEOS = CAIRO_SURFACE_TYPE_BEOS,
|
||||
SURFACE_TYPE_DIRECTFB = CAIRO_SURFACE_TYPE_DIRECTFB,
|
||||
SURFACE_TYPE_SVG = CAIRO_SURFACE_TYPE_SVG
|
||||
} SurfaceType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PATTERN_TYPE_SOLID = CAIRO_PATTERN_TYPE_SOLID,
|
||||
PATTERN_TYPE_SURFACE = CAIRO_PATTERN_TYPE_SURFACE,
|
||||
PATTERN_TYPE_LINEAR = CAIRO_PATTERN_TYPE_LINEAR,
|
||||
PATTERN_TYPE_RADIAL = CAIRO_PATTERN_TYPE_RADIAL
|
||||
} PatternType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FONT_TYPE_TOY = CAIRO_FONT_TYPE_TOY,
|
||||
FONT_TYPE_FT = CAIRO_FONT_TYPE_FT,
|
||||
FONT_TYPE_WIN32 = CAIRO_FONT_TYPE_WIN32,
|
||||
FONT_TYPE_ATSUI = CAIRO_FONT_TYPE_ATSUI
|
||||
} FontType;
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_ENUMS_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
49
libs/cairomm/cairomm/exception.cc
Normal file
49
libs/cairomm/cairomm/exception.cc
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/exception.h>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
inline static const char* string_or_empty(const char* text)
|
||||
{
|
||||
return (text ? text : "");
|
||||
}
|
||||
|
||||
//TODO: Is it wise to assume that the string is ASCII, as expected by std::logic_error?
|
||||
logic_error::logic_error(ErrorStatus status)
|
||||
: std::logic_error( string_or_empty(cairo_status_to_string((cairo_status_t)m_status)) ),
|
||||
m_status(status)
|
||||
{
|
||||
}
|
||||
|
||||
logic_error::~logic_error() throw()
|
||||
{}
|
||||
|
||||
/*
|
||||
const char* logic_error::what() const throw()
|
||||
{
|
||||
//Hopefully this is a const char* to a static string.
|
||||
return cairo_status_to_string((cairo_status_t)m_status);
|
||||
}
|
||||
*/
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
46
libs/cairomm/cairomm/exception.h
Normal file
46
libs/cairomm/cairomm/exception.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIRO_EXCEPTION_H
|
||||
#define __CAIRO_EXCEPTION_H
|
||||
|
||||
#include <cairomm/enums.h>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
class logic_error: public std::logic_error
|
||||
{
|
||||
public:
|
||||
explicit logic_error(ErrorStatus status);
|
||||
virtual ~logic_error() throw();
|
||||
|
||||
//virtual const char* what() const throw();
|
||||
|
||||
private:
|
||||
ErrorStatus m_status;
|
||||
};
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif // __CAIRO_EXCEPTION_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
74
libs/cairomm/cairomm/fontface.cc
Normal file
74
libs/cairomm/cairomm/fontface.cc
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/fontface.h>
|
||||
#include <cairomm/private.h>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
FontFace::FontFace(cairo_font_face_t* cobject, bool has_reference)
|
||||
: m_cobject(0)
|
||||
{
|
||||
if(has_reference)
|
||||
m_cobject = cobject;
|
||||
else
|
||||
m_cobject = cairo_font_face_reference(cobject);
|
||||
}
|
||||
|
||||
FontFace::~FontFace()
|
||||
{
|
||||
if(m_cobject)
|
||||
cairo_font_face_destroy(m_cobject);
|
||||
}
|
||||
|
||||
void FontFace::reference() const
|
||||
{
|
||||
cairo_font_face_reference(m_cobject);
|
||||
}
|
||||
|
||||
void FontFace::unreference() const
|
||||
{
|
||||
cairo_font_face_destroy(m_cobject);
|
||||
}
|
||||
|
||||
/*
|
||||
void* FontFace::get_user_data(const cairo_user_data_key_t *key)
|
||||
{
|
||||
void* result = cairo_font_face_get_user_data(m_cobject, key);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void FontFace::set_user_data(const cairo_user_data_key_t* key, void *user_data, cairo_destroy_func_t destroy)
|
||||
{
|
||||
const ErrorStatus status = (ErrorStatus)cairo_font_face_set_user_data(m_cobject, key, user_data, destroy);
|
||||
check_status_and_throw_exception(status);
|
||||
}
|
||||
*/
|
||||
|
||||
FontType FontFace::get_type() const
|
||||
{
|
||||
cairo_font_type_t font_type = cairo_font_face_get_type(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return static_cast<FontType>(font_type);
|
||||
}
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
79
libs/cairomm/cairomm/fontface.h
Normal file
79
libs/cairomm/cairomm/fontface.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_FONTFACE_H
|
||||
#define __CAIROMM_FONTFACE_H
|
||||
|
||||
#include <cairomm/enums.h>
|
||||
#include <cairo.h>
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
/**
|
||||
* This is a reference-counted object that should be used via Cairo::RefPtr.
|
||||
*/
|
||||
class FontFace
|
||||
{
|
||||
protected:
|
||||
|
||||
//TODO?: FontFace(cairo_font_face_t *target);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
|
||||
*/
|
||||
explicit FontFace(cairo_font_face_t* cobject, bool has_reference = false);
|
||||
|
||||
|
||||
virtual ~FontFace();
|
||||
|
||||
/* Don't wrap these until we know what they are good for.
|
||||
void* get_user_data(const cairo_user_data_key_t *key);
|
||||
|
||||
void set_user_data(const cairo_user_data_key_t *key, void *user_data, cairo_destroy_func_t destroy);
|
||||
*/
|
||||
|
||||
FontType get_type() const;
|
||||
|
||||
typedef cairo_font_face_t cobject;
|
||||
inline cobject* cobj() { return m_cobject; }
|
||||
inline const cobject* cobj() const { return m_cobject; }
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
///For use only by the cairomm implementation.
|
||||
inline ErrorStatus get_status() const
|
||||
{ return cairo_font_face_status(const_cast<cairo_font_face_t*>(cobj())); }
|
||||
#endif //DOXYGEN_IGNORE_THIS
|
||||
|
||||
void reference() const;
|
||||
void unreference() const;
|
||||
|
||||
protected:
|
||||
|
||||
cobject* m_cobject;
|
||||
};
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_FONTFACE_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
159
libs/cairomm/cairomm/fontoptions.cc
Normal file
159
libs/cairomm/cairomm/fontoptions.cc
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/fontoptions.h>
|
||||
#include <cairomm/private.h>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
FontOptions::FontOptions()
|
||||
: m_cobject(0)
|
||||
{
|
||||
m_cobject = cairo_font_options_create();
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
FontOptions::FontOptions(cairo_font_options_t* cobject, bool take_ownership)
|
||||
: m_cobject(0)
|
||||
{
|
||||
if(take_ownership)
|
||||
m_cobject = cobject;
|
||||
else
|
||||
m_cobject = cairo_font_options_copy(cobject);
|
||||
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
FontOptions::FontOptions(const FontOptions& src)
|
||||
{
|
||||
//Reference-counting, instead of copying by value:
|
||||
if(!src.m_cobject)
|
||||
m_cobject = 0;
|
||||
else
|
||||
m_cobject = cairo_font_options_copy(src.m_cobject);
|
||||
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
FontOptions::~FontOptions()
|
||||
{
|
||||
if(m_cobject)
|
||||
cairo_font_options_destroy(m_cobject);
|
||||
}
|
||||
|
||||
|
||||
FontOptions& FontOptions::operator=(const FontOptions& src)
|
||||
{
|
||||
//Reference-counting, instead of copying by value:
|
||||
|
||||
if(this == &src)
|
||||
return *this;
|
||||
|
||||
if(m_cobject == src.m_cobject)
|
||||
return *this;
|
||||
|
||||
if(m_cobject)
|
||||
{
|
||||
cairo_font_options_destroy(m_cobject);
|
||||
m_cobject = 0;
|
||||
}
|
||||
|
||||
if(!src.m_cobject)
|
||||
return *this;
|
||||
|
||||
m_cobject = cairo_font_options_copy(src.m_cobject);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool FontOptions::operator==(const FontOptions& src) const
|
||||
{
|
||||
return cairo_font_options_equal(m_cobject, src.cobj());
|
||||
}
|
||||
|
||||
void FontOptions::merge(const FontOptions& src)
|
||||
{
|
||||
cairo_font_options_merge(m_cobject, src.cobj());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
unsigned long FontOptions::hash() const
|
||||
{
|
||||
const unsigned long result = cairo_font_options_hash(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void FontOptions::set_antialias(Antialias antialias)
|
||||
{
|
||||
cairo_font_options_set_antialias(m_cobject, static_cast<cairo_antialias_t>(antialias));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
Antialias FontOptions::get_antialias() const
|
||||
{
|
||||
const Antialias result = static_cast<Antialias>(cairo_font_options_get_antialias(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void FontOptions::set_subpixel_order(SubpixelOrder subpixel_order)
|
||||
{
|
||||
cairo_font_options_set_subpixel_order(m_cobject, static_cast<cairo_subpixel_order_t>(subpixel_order));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
SubpixelOrder FontOptions::get_subpixel_order() const
|
||||
{
|
||||
const SubpixelOrder result = static_cast<SubpixelOrder>(cairo_font_options_get_subpixel_order(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void FontOptions::set_hint_style(HintStyle hint_style)
|
||||
{
|
||||
cairo_font_options_set_hint_style(m_cobject, static_cast<cairo_hint_style_t>(hint_style));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
HintStyle FontOptions::get_hint_style() const
|
||||
{
|
||||
const HintStyle result = static_cast<HintStyle>(cairo_font_options_get_hint_style(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void FontOptions::set_hint_metrics(HintMetrics hint_metrics)
|
||||
{
|
||||
cairo_font_options_set_hint_metrics(m_cobject,
|
||||
static_cast<cairo_hint_metrics_t>(hint_metrics));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
HintMetrics FontOptions::get_hint_metrics() const
|
||||
{
|
||||
const HintMetrics result =
|
||||
static_cast<HintMetrics>(cairo_font_options_get_hint_metrics(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
81
libs/cairomm/cairomm/fontoptions.h
Normal file
81
libs/cairomm/cairomm/fontoptions.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_FONTOPTIONS_H
|
||||
#define __CAIROMM_FONTOPTIONS_H
|
||||
|
||||
#include <cairomm/enums.h>
|
||||
#include <string>
|
||||
#include <cairo.h>
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
/** How a font should be rendered.
|
||||
*/
|
||||
class FontOptions
|
||||
{
|
||||
public:
|
||||
FontOptions();
|
||||
explicit FontOptions(cairo_font_options_t* cobject, bool take_ownership = false);
|
||||
FontOptions(const FontOptions& src);
|
||||
|
||||
virtual ~FontOptions();
|
||||
|
||||
FontOptions& operator=(const FontOptions& src);
|
||||
|
||||
bool operator ==(const FontOptions& src) const;
|
||||
//bool operator !=(const FontOptions& src) const;
|
||||
|
||||
void merge(const FontOptions& other);
|
||||
|
||||
unsigned long hash() const;
|
||||
|
||||
void set_antialias(Antialias antialias);
|
||||
Antialias get_antialias() const;
|
||||
|
||||
void set_subpixel_order(SubpixelOrder subpixel_order);
|
||||
SubpixelOrder get_subpixel_order() const;
|
||||
|
||||
void set_hint_style(HintStyle hint_style);
|
||||
HintStyle get_hint_style() const;
|
||||
|
||||
void set_hint_metrics(HintMetrics hint_metrics);
|
||||
HintMetrics get_hint_metrics() const;
|
||||
|
||||
typedef cairo_font_options_t cobject;
|
||||
inline cobject* cobj() { return m_cobject; }
|
||||
inline const cobject* cobj() const { return m_cobject; }
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
///For use only by the cairomm implementation.
|
||||
inline ErrorStatus get_status() const
|
||||
{ return cairo_font_options_status(const_cast<cairo_font_options_t*>(cobj())); }
|
||||
#endif //DOXYGEN_IGNORE_THIS
|
||||
|
||||
protected:
|
||||
|
||||
cobject* m_cobject;
|
||||
};
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_FONTOPTIONS_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
98
libs/cairomm/cairomm/path.cc
Normal file
98
libs/cairomm/cairomm/path.cc
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/path.h>
|
||||
#include <cairomm/private.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
/*
|
||||
Path::Path()
|
||||
: m_cobject(0)
|
||||
{
|
||||
m_cobject = cairo_path_create();
|
||||
}
|
||||
*/
|
||||
|
||||
Path::Path(cairo_path_t* cobject, bool take_ownership)
|
||||
: m_cobject(0)
|
||||
{
|
||||
if(take_ownership)
|
||||
m_cobject = cobject;
|
||||
else
|
||||
{
|
||||
std::cerr << "cairomm: Path::Path(): copying of the underlying cairo_path_t* is not yet implemented." << std::endl;
|
||||
//m_cobject = cairo_path_copy(cobject);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Path::Path(const Path& src)
|
||||
{
|
||||
//Reference-counting, instead of copying by value:
|
||||
if(!src.m_cobject)
|
||||
m_cobject = 0;
|
||||
else
|
||||
m_cobject = cairo_path_copy(src.m_cobject);
|
||||
}
|
||||
*/
|
||||
|
||||
Path::~Path()
|
||||
{
|
||||
if(m_cobject)
|
||||
cairo_path_destroy(m_cobject);
|
||||
}
|
||||
|
||||
/*
|
||||
Path& Path::operator=(const Path& src)
|
||||
{
|
||||
//Reference-counting, instead of copying by value:
|
||||
|
||||
if(this == &src)
|
||||
return *this;
|
||||
|
||||
if(m_cobject == src.m_cobject)
|
||||
return *this;
|
||||
|
||||
if(m_cobject)
|
||||
{
|
||||
cairo_path_destroy(m_cobject);
|
||||
m_cobject = 0;
|
||||
}
|
||||
|
||||
if(!src.m_cobject)
|
||||
return *this;
|
||||
|
||||
m_cobject = cairo_path_copy(src.m_cobject);
|
||||
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
bool Path::operator==(const Path& src) const
|
||||
{
|
||||
return cairo_path_equal(m_cobject, src.cobj());
|
||||
}
|
||||
*/
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
72
libs/cairomm/cairomm/path.h
Normal file
72
libs/cairomm/cairomm/path.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_PATH_H
|
||||
#define __CAIROMM_PATH_H
|
||||
|
||||
#include <cairomm/enums.h>
|
||||
#include <string>
|
||||
#include <cairo.h>
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
/** A data structure for holding a path.
|
||||
* Use Context::copy_path() or Context::copy_path_flat() to instantiate a new
|
||||
* Path. The application is responsible for freeing the Path object when it is
|
||||
* no longer needed.
|
||||
*
|
||||
* @todo There's currently no way to access the path data without reverting to
|
||||
* the C object (see cobj())
|
||||
*/
|
||||
class Path
|
||||
{
|
||||
public:
|
||||
//Path();
|
||||
explicit Path(cairo_path_t* cobject, bool take_ownership = false);
|
||||
//Path(const Path& src);
|
||||
|
||||
virtual ~Path();
|
||||
|
||||
//Path& operator=(const Path& src);
|
||||
|
||||
//bool operator ==(const Path& src) const;
|
||||
//bool operator !=(const Path& src) const;
|
||||
|
||||
typedef cairo_path_t cobject;
|
||||
inline cobject* cobj() { return m_cobject; }
|
||||
inline const cobject* cobj() const { return m_cobject; }
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
///For use only by the cairomm implementation.
|
||||
//There is no *_status() function for this object:
|
||||
//inline ErrorStatus get_status() const
|
||||
//{ return cairo_path_status(const_cast<cairo_path_t*>(cobj())); }
|
||||
#endif //DOXYGEN_IGNORE_THIS
|
||||
|
||||
protected:
|
||||
|
||||
cobject* m_cobject;
|
||||
};
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_PATH_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
219
libs/cairomm/cairomm/pattern.cc
Normal file
219
libs/cairomm/cairomm/pattern.cc
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/pattern.h>
|
||||
#include <cairomm/private.h>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
Pattern::Pattern()
|
||||
: m_cobject(0)
|
||||
{
|
||||
}
|
||||
|
||||
Pattern::Pattern(cairo_pattern_t* cobject, bool has_reference)
|
||||
: m_cobject(0)
|
||||
{
|
||||
if(has_reference)
|
||||
m_cobject = cobject;
|
||||
else
|
||||
m_cobject = cairo_pattern_reference(cobject);
|
||||
}
|
||||
|
||||
Pattern::~Pattern()
|
||||
{
|
||||
if(m_cobject)
|
||||
cairo_pattern_destroy(m_cobject);
|
||||
}
|
||||
|
||||
void Pattern::reference() const
|
||||
{
|
||||
cairo_pattern_reference(m_cobject);
|
||||
}
|
||||
|
||||
void Pattern::unreference() const
|
||||
{
|
||||
cairo_pattern_destroy(m_cobject);
|
||||
}
|
||||
|
||||
void Pattern::set_matrix(const cairo_matrix_t &matrix)
|
||||
{
|
||||
cairo_pattern_set_matrix(m_cobject, &matrix);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Pattern::get_matrix(cairo_matrix_t &matrix) const
|
||||
{
|
||||
cairo_pattern_get_matrix(m_cobject, &matrix);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
PatternType Pattern::get_type() const
|
||||
{
|
||||
cairo_pattern_type_t pattern_type = cairo_pattern_get_type(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return static_cast<PatternType>(pattern_type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SolidPattern::SolidPattern(cairo_pattern_t* cobject, bool has_reference)
|
||||
: Pattern(cobject, has_reference)
|
||||
{
|
||||
}
|
||||
|
||||
SolidPattern::~SolidPattern()
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<SolidPattern> SolidPattern::create_rgb(double red, double green, double blue)
|
||||
{
|
||||
cairo_pattern_t* cobject = cairo_pattern_create_rgb(red, green, blue);
|
||||
check_status_and_throw_exception(cairo_pattern_status(cobject));
|
||||
return RefPtr<SolidPattern>(new SolidPattern(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
RefPtr<SolidPattern> SolidPattern::create_rgba(double red, double green, double blue, double alpha)
|
||||
{
|
||||
cairo_pattern_t* cobject = cairo_pattern_create_rgba(red, green, blue, alpha);
|
||||
check_status_and_throw_exception(cairo_pattern_status(cobject));
|
||||
return RefPtr<SolidPattern>(new SolidPattern(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
|
||||
SurfacePattern::SurfacePattern(const RefPtr<Surface>& surface)
|
||||
{
|
||||
m_cobject = cairo_pattern_create_for_surface(surface->cobj());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
RefPtr<SurfacePattern> SurfacePattern::create(const RefPtr<Surface>& surface)
|
||||
{
|
||||
return RefPtr<SurfacePattern>(new SurfacePattern(surface));
|
||||
}
|
||||
|
||||
SurfacePattern::SurfacePattern(cairo_pattern_t* cobject, bool has_reference)
|
||||
: Pattern(cobject, has_reference)
|
||||
{
|
||||
}
|
||||
|
||||
SurfacePattern::~SurfacePattern()
|
||||
{
|
||||
}
|
||||
|
||||
void SurfacePattern::set_extend(Extend extend)
|
||||
{
|
||||
cairo_pattern_set_extend(m_cobject, (cairo_extend_t)extend);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
Extend SurfacePattern::get_extend() const
|
||||
{
|
||||
const Extend result = static_cast<Extend>(cairo_pattern_get_extend(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
void SurfacePattern::set_filter(Filter filter)
|
||||
{
|
||||
cairo_pattern_set_filter(m_cobject, (cairo_filter_t)filter);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
Filter SurfacePattern::get_filter() const
|
||||
{
|
||||
Filter result = static_cast<Filter>(cairo_pattern_get_filter(m_cobject));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Gradient::Gradient()
|
||||
{
|
||||
}
|
||||
|
||||
Gradient::Gradient(cairo_pattern_t* cobject, bool has_reference)
|
||||
: Pattern(cobject, has_reference)
|
||||
{
|
||||
}
|
||||
|
||||
Gradient::~Gradient()
|
||||
{
|
||||
}
|
||||
|
||||
void Gradient::add_color_stop_rgb(double offset, double red, double green, double blue)
|
||||
{
|
||||
cairo_pattern_add_color_stop_rgb(m_cobject, offset, red, green, blue);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Gradient::add_color_stop_rgba(double offset, double red, double green, double blue, double alpha)
|
||||
{
|
||||
cairo_pattern_add_color_stop_rgba(m_cobject, offset, red, green, blue, alpha);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
LinearGradient::LinearGradient(double x0, double y0, double x1, double y1)
|
||||
{
|
||||
m_cobject = cairo_pattern_create_linear(x0, y0, x1, y1);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
RefPtr<LinearGradient> LinearGradient::create(double x0, double y0, double x1, double y1)
|
||||
{
|
||||
return RefPtr<LinearGradient>(new LinearGradient(x0, y0, x1, y1));
|
||||
}
|
||||
|
||||
LinearGradient::LinearGradient(cairo_pattern_t* cobject, bool has_reference)
|
||||
: Gradient(cobject, has_reference)
|
||||
{
|
||||
}
|
||||
|
||||
LinearGradient::~LinearGradient()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RadialGradient::RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)
|
||||
{
|
||||
m_cobject = cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
RefPtr<RadialGradient> RadialGradient::create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)
|
||||
{
|
||||
return RefPtr<RadialGradient>(new RadialGradient(cx0, cy0, radius0, cx1, cy1, radius1));
|
||||
}
|
||||
|
||||
RadialGradient::RadialGradient(cairo_pattern_t* cobject, bool has_reference)
|
||||
: Gradient(cobject, has_reference)
|
||||
{
|
||||
}
|
||||
|
||||
RadialGradient::~RadialGradient()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
189
libs/cairomm/cairomm/pattern.h
Normal file
189
libs/cairomm/cairomm/pattern.h
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_PATTERN_H
|
||||
#define __CAIROMM_PATTERN_H
|
||||
|
||||
#include <cairomm/surface.h>
|
||||
#include <cairomm/enums.h>
|
||||
#include <cairo.h>
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
/**
|
||||
* This is a reference-counted object that should be used via Cairo::RefPtr.
|
||||
*/
|
||||
class Pattern
|
||||
{
|
||||
protected:
|
||||
//Use derived constructors.
|
||||
|
||||
//TODO?: Pattern(cairo_pattern_t *target);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
|
||||
*/
|
||||
explicit Pattern(cairo_pattern_t* cobject, bool has_reference = false);
|
||||
|
||||
virtual ~Pattern();
|
||||
|
||||
void set_matrix(const cairo_matrix_t &matrix);
|
||||
void get_matrix(cairo_matrix_t &matrix) const;
|
||||
PatternType get_type() const;
|
||||
|
||||
typedef cairo_pattern_t cobject;
|
||||
inline cobject* cobj() { return m_cobject; }
|
||||
inline const cobject* cobj() const { return m_cobject; }
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
///For use only by the cairomm implementation.
|
||||
inline ErrorStatus get_status() const
|
||||
{ return cairo_pattern_status(const_cast<cairo_pattern_t*>(cobj())); }
|
||||
#endif //DOXYGEN_IGNORE_THIS
|
||||
|
||||
void reference() const;
|
||||
void unreference() const;
|
||||
|
||||
protected:
|
||||
//Used by derived types only.
|
||||
Pattern();
|
||||
|
||||
cobject* m_cobject;
|
||||
};
|
||||
|
||||
class SolidPattern : public Pattern
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance.
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
|
||||
*/
|
||||
explicit SolidPattern(cairo_pattern_t* cobject, bool has_reference = false);
|
||||
|
||||
static RefPtr<SolidPattern> create_rgb(double red, double green, double blue);
|
||||
static RefPtr<SolidPattern> create_rgba(double red, double green, double blue, double alpha);
|
||||
|
||||
//TODO?: SolidPattern(cairo_pattern_t *target);
|
||||
virtual ~SolidPattern();
|
||||
};
|
||||
|
||||
class SurfacePattern : public Pattern
|
||||
{
|
||||
protected:
|
||||
|
||||
explicit SurfacePattern(const RefPtr<Surface>& surface);
|
||||
|
||||
//TODO?: SurfacePattern(cairo_pattern_t *target);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
|
||||
*/
|
||||
explicit SurfacePattern(cairo_pattern_t* cobject, bool has_reference = false);
|
||||
|
||||
|
||||
virtual ~SurfacePattern();
|
||||
|
||||
static RefPtr<SurfacePattern> create(const RefPtr<Surface>& surface);
|
||||
|
||||
void set_extend(Extend extend);
|
||||
Extend get_extend() const;
|
||||
void set_filter(Filter filter);
|
||||
Filter get_filter() const;
|
||||
};
|
||||
|
||||
class Gradient : public Pattern
|
||||
{
|
||||
protected:
|
||||
//Use derived constructors.
|
||||
|
||||
//TODO?: Gradient(cairo_pattern_t *target);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
|
||||
*/
|
||||
explicit Gradient(cairo_pattern_t* cobject, bool has_reference = false);
|
||||
|
||||
virtual ~Gradient();
|
||||
|
||||
void add_color_stop_rgb(double offset, double red, double green, double blue);
|
||||
void add_color_stop_rgba(double offset, double red, double green, double blue, double alpha);
|
||||
|
||||
protected:
|
||||
Gradient();
|
||||
};
|
||||
|
||||
class LinearGradient : public Gradient
|
||||
{
|
||||
protected:
|
||||
|
||||
LinearGradient(double x0, double y0, double x1, double y1);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
|
||||
*/
|
||||
explicit LinearGradient(cairo_pattern_t* cobject, bool has_reference = false);
|
||||
|
||||
//TODO?: LinearGradient(cairo_pattern_t *target);
|
||||
virtual ~LinearGradient();
|
||||
|
||||
static RefPtr<LinearGradient> create(double x0, double y0, double x1, double y1);
|
||||
};
|
||||
|
||||
class RadialGradient : public Gradient
|
||||
{
|
||||
protected:
|
||||
|
||||
RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
|
||||
*/
|
||||
explicit RadialGradient(cairo_pattern_t* cobject, bool has_reference = false);
|
||||
|
||||
|
||||
//TODO?: RadialGradient(cairo_pattern_t *target);
|
||||
virtual ~RadialGradient();
|
||||
|
||||
static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
|
||||
};
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_PATTERN_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
76
libs/cairomm/cairomm/private.cc
Normal file
76
libs/cairomm/cairomm/private.cc
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/private.h>
|
||||
#include <cairomm/exception.h>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
void throw_exception(ErrorStatus status)
|
||||
{
|
||||
switch(status)
|
||||
{
|
||||
case CAIRO_STATUS_SUCCESS:
|
||||
// we should never get here, but just in case
|
||||
break;
|
||||
|
||||
case CAIRO_STATUS_NO_MEMORY:
|
||||
throw std::bad_alloc();
|
||||
break;
|
||||
|
||||
// Programmer error
|
||||
case CAIRO_STATUS_INVALID_RESTORE:
|
||||
case CAIRO_STATUS_INVALID_POP_GROUP:
|
||||
case CAIRO_STATUS_NO_CURRENT_POINT:
|
||||
case CAIRO_STATUS_INVALID_MATRIX:
|
||||
//No longer in API?: case CAIRO_STATUS_NO_TARGET_SURFACE:
|
||||
case CAIRO_STATUS_INVALID_STRING:
|
||||
case CAIRO_STATUS_SURFACE_FINISHED:
|
||||
//No longer in API?: case CAIRO_STATUS_BAD_NESTING:
|
||||
throw Cairo::logic_error(status);
|
||||
break;
|
||||
|
||||
// Language binding implementation:
|
||||
case CAIRO_STATUS_NULL_POINTER:
|
||||
case CAIRO_STATUS_INVALID_PATH_DATA:
|
||||
case CAIRO_STATUS_SURFACE_TYPE_MISMATCH:
|
||||
throw Cairo::logic_error(status);
|
||||
break;
|
||||
|
||||
// Other
|
||||
case CAIRO_STATUS_READ_ERROR:
|
||||
case CAIRO_STATUS_WRITE_ERROR:
|
||||
{
|
||||
//The Cairo language binding advice suggests that these are stream errors
|
||||
//that should be mapped to their C++ equivalents.
|
||||
const char* error_message = cairo_status_to_string(status);
|
||||
throw std::ios_base::failure( error_message ? error_message : std::string() );
|
||||
}
|
||||
|
||||
default:
|
||||
throw Cairo::logic_error(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
50
libs/cairomm/cairomm/private.h
Normal file
50
libs/cairomm/cairomm/private.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_PRIVATE_H
|
||||
#define __CAIROMM_PRIVATE_H
|
||||
|
||||
#include <cairomm/enums.h>
|
||||
#include <cairomm/exception.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
void throw_exception(ErrorStatus status);
|
||||
|
||||
//We inline this because it is called so often.
|
||||
inline void check_status_and_throw_exception(ErrorStatus status)
|
||||
{
|
||||
if(status != CAIRO_STATUS_SUCCESS)
|
||||
throw_exception(status); //This part doesn't need to be inline because it would rarely be called.
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void check_object_status_and_throw_exception(const T& object)
|
||||
{
|
||||
//get_status() is normally an inlined member method.
|
||||
check_status_and_throw_exception(object.get_status());
|
||||
}
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_PRIVATE_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
391
libs/cairomm/cairomm/refptr.h
Normal file
391
libs/cairomm/cairomm/refptr.h
Normal file
|
|
@ -0,0 +1,391 @@
|
|||
// -*- c++ -*-
|
||||
#ifndef _cairo_REFPTR_H
|
||||
#define _cairo_REFPTR_H
|
||||
|
||||
/* $Id: refptr.h,v 1.6 2006/09/27 18:38:57 murrayc Exp $ */
|
||||
|
||||
/* Copyright 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
/** RefPtr<> is a reference-counting shared smartpointer.
|
||||
*
|
||||
* Reference counting means that a shared reference count is incremented each
|
||||
* time a RefPtr is copied, and decremented each time a RefPtr is destroyed,
|
||||
* for instance when it leaves its scope. When the reference count reaches
|
||||
* zero, the contained object is deleted
|
||||
*
|
||||
* cairomm uses RefPtr so that you don't need to remember
|
||||
* to delete the object explicitly, or know when a method expects you to delete
|
||||
* the object that it returns, and to prevent any need to manually reference
|
||||
* and unreference() cairo objects.
|
||||
*/
|
||||
template <class T_CppObject>
|
||||
class RefPtr
|
||||
{
|
||||
public:
|
||||
/** Default constructor
|
||||
*
|
||||
* Afterwards it will be null and use of -> will cause a segmentation fault.
|
||||
*/
|
||||
inline RefPtr();
|
||||
|
||||
/// Destructor - decrements reference count.
|
||||
inline ~RefPtr();
|
||||
|
||||
/** For use only in the internal implementation of cairomm, gtkmm, etc.
|
||||
*
|
||||
* This takes ownership of @a pCppObject, so it will be deleted when the
|
||||
* last RefPtr is deleted, for instance when it goes out of scope.
|
||||
*
|
||||
* This assumes that @a pCppObject already has a starting reference for its underlying cairo object,
|
||||
* so that destruction of @a @pCppObject will cause a corresponding unreference of its underlying
|
||||
* cairo object. For instance, a cairo_*_create() function usually provides a starting reference,
|
||||
* but a cairo_*_get_*() function requires the caller to manually reference the returned object.
|
||||
* In this case, you should call reference() on @a pCppObject before passing it to this constructor.
|
||||
*/
|
||||
explicit inline RefPtr(T_CppObject* pCppObject);
|
||||
|
||||
/** Copy constructor
|
||||
*
|
||||
* This increments the shared reference count.
|
||||
*/
|
||||
inline RefPtr(const RefPtr<T_CppObject>& src);
|
||||
|
||||
/** Copy constructor (from different, but castable type).
|
||||
*
|
||||
* Increments the reference count.
|
||||
*/
|
||||
template <class T_CastFrom>
|
||||
inline RefPtr(const RefPtr<T_CastFrom>& src);
|
||||
|
||||
/** Swap the contents of two RefPtr<>.
|
||||
* This method swaps the internal pointers to T_CppObject. This can be
|
||||
* done safely without involving a reference/unreference cycle and is
|
||||
* therefore highly efficient.
|
||||
*/
|
||||
inline void swap(RefPtr<T_CppObject>& other);
|
||||
|
||||
/// Copy from another RefPtr:
|
||||
inline RefPtr<T_CppObject>& operator=(const RefPtr<T_CppObject>& src);
|
||||
|
||||
/** Copy from different, but castable type).
|
||||
*
|
||||
* Increments the reference count.
|
||||
*/
|
||||
template <class T_CastFrom>
|
||||
inline RefPtr<T_CppObject>& operator=(const RefPtr<T_CastFrom>& src);
|
||||
|
||||
/// Tests whether the RefPtr<> point to the same underlying instance.
|
||||
inline bool operator==(const RefPtr<T_CppObject>& src) const;
|
||||
|
||||
/// See operator==().
|
||||
inline bool operator!=(const RefPtr<T_CppObject>& src) const;
|
||||
|
||||
/** Dereferencing.
|
||||
*
|
||||
* Use the methods of the underlying instance like so:
|
||||
* <code>refptr->memberfun()</code>.
|
||||
*/
|
||||
inline T_CppObject* operator->() const;
|
||||
|
||||
/** Test whether the RefPtr<> points to any underlying instance.
|
||||
*
|
||||
* Mimics usage of ordinary pointers:
|
||||
* @code
|
||||
* if (ptr)
|
||||
* do_something();
|
||||
* @endcode
|
||||
*/
|
||||
inline operator bool() const;
|
||||
|
||||
/// Set underlying instance to 0, decrementing reference count of existing instance appropriately.
|
||||
inline void clear();
|
||||
|
||||
|
||||
/** Dynamic cast to derived class.
|
||||
*
|
||||
* The RefPtr can't be cast with the usual notation so instead you can use
|
||||
* @code
|
||||
* ptr_derived = RefPtr<Derived>::cast_dynamic(ptr_base);
|
||||
* @endcode
|
||||
*/
|
||||
template <class T_CastFrom>
|
||||
static inline RefPtr<T_CppObject> cast_dynamic(const RefPtr<T_CastFrom>& src);
|
||||
|
||||
/** Static cast to derived class.
|
||||
*
|
||||
* Like the dynamic cast; the notation is
|
||||
* @code
|
||||
* ptr_derived = RefPtr<Derived>::cast_static(ptr_base);
|
||||
* @endcode
|
||||
*/
|
||||
template <class T_CastFrom>
|
||||
static inline RefPtr<T_CppObject> cast_static(const RefPtr<T_CastFrom>& src);
|
||||
|
||||
/** Cast to non-const.
|
||||
*
|
||||
* The RefPtr can't be cast with the usual notation so instead you can use
|
||||
* @code
|
||||
* ptr_unconst = RefPtr<UnConstType>::cast_const(ptr_const);
|
||||
* @endcode
|
||||
*/
|
||||
template <class T_CastFrom>
|
||||
static inline RefPtr<T_CppObject> cast_const(const RefPtr<T_CastFrom>& src);
|
||||
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
|
||||
// Warning: This is for internal use only. Do not manually modify the
|
||||
// reference count with this pointer.
|
||||
inline int* refcount_() const { return pCppRefcount_; }
|
||||
|
||||
#endif // DOXYGEN_IGNORE_THIS
|
||||
|
||||
private:
|
||||
void unref();
|
||||
|
||||
T_CppObject* pCppObject_;
|
||||
mutable int* pCppRefcount_;
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
|
||||
// RefPtr<>::operator->() comes first here since it's used by other methods.
|
||||
// If it would come after them it wouldn't be inlined.
|
||||
|
||||
template <class T_CppObject> inline
|
||||
T_CppObject* RefPtr<T_CppObject>::operator->() const
|
||||
{
|
||||
return pCppObject_;
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
RefPtr<T_CppObject>::RefPtr()
|
||||
:
|
||||
pCppObject_(0),
|
||||
pCppRefcount_(0)
|
||||
{}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
RefPtr<T_CppObject>::~RefPtr()
|
||||
{
|
||||
unref();
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
void RefPtr<T_CppObject>::unref()
|
||||
{
|
||||
if(pCppRefcount_)
|
||||
{
|
||||
--(*pCppRefcount_);
|
||||
|
||||
if(*pCppRefcount_ == 0)
|
||||
{
|
||||
if(pCppObject_)
|
||||
{
|
||||
delete pCppObject_;
|
||||
pCppObject_ = 0;
|
||||
}
|
||||
|
||||
delete pCppRefcount_;
|
||||
pCppRefcount_ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T_CppObject> inline
|
||||
RefPtr<T_CppObject>::RefPtr(T_CppObject* pCppObject)
|
||||
:
|
||||
pCppObject_(pCppObject),
|
||||
pCppRefcount_(0)
|
||||
{
|
||||
if(pCppObject)
|
||||
{
|
||||
pCppRefcount_ = new int;
|
||||
*pCppRefcount_ = 1; //This will be decremented in the destructor.
|
||||
}
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
RefPtr<T_CppObject>::RefPtr(const RefPtr<T_CppObject>& src)
|
||||
:
|
||||
pCppObject_ (src.pCppObject_),
|
||||
pCppRefcount_(src.pCppRefcount_)
|
||||
{
|
||||
if(pCppObject_ && pCppRefcount_)
|
||||
++(*pCppRefcount_);
|
||||
}
|
||||
|
||||
// The templated ctor allows copy construction from any object that's
|
||||
// castable. Thus, it does downcasts:
|
||||
// base_ref = derived_ref
|
||||
template <class T_CppObject>
|
||||
template <class T_CastFrom>
|
||||
inline
|
||||
RefPtr<T_CppObject>::RefPtr(const RefPtr<T_CastFrom>& src)
|
||||
:
|
||||
// A different RefPtr<> will not allow us access to pCppObject_. We need
|
||||
// to add a get_underlying() for this, but that would encourage incorrect
|
||||
// use, so we use the less well-known operator->() accessor:
|
||||
pCppObject_ (src.operator->()),
|
||||
pCppRefcount_(src.refcount_())
|
||||
{
|
||||
if(pCppObject_ && pCppRefcount_)
|
||||
++(*pCppRefcount_);
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
void RefPtr<T_CppObject>::swap(RefPtr<T_CppObject>& other)
|
||||
{
|
||||
T_CppObject *const temp = pCppObject_;
|
||||
int* temp_count = pCppRefcount_;
|
||||
|
||||
pCppObject_ = other.pCppObject_;
|
||||
pCppRefcount_ = other.pCppRefcount_;
|
||||
|
||||
other.pCppObject_ = temp;
|
||||
other.pCppRefcount_ = temp_count;
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(const RefPtr<T_CppObject>& src)
|
||||
{
|
||||
// In case you haven't seen the swap() technique to implement copy
|
||||
// assignment before, here's what it does:
|
||||
//
|
||||
// 1) Create a temporary RefPtr<> instance via the copy ctor, thereby
|
||||
// increasing the reference count of the source object.
|
||||
//
|
||||
// 2) Swap the internal object pointers of *this and the temporary
|
||||
// RefPtr<>. After this step, *this already contains the new pointer,
|
||||
// and the old pointer is now managed by temp.
|
||||
//
|
||||
// 3) The destructor of temp is executed, thereby unreferencing the
|
||||
// old object pointer.
|
||||
//
|
||||
// This technique is described in Herb Sutter's "Exceptional C++", and
|
||||
// has a number of advantages over conventional approaches:
|
||||
//
|
||||
// - Code reuse by calling the copy ctor.
|
||||
// - Strong exception safety for free.
|
||||
// - Self assignment is handled implicitely.
|
||||
// - Simplicity.
|
||||
// - It just works and is hard to get wrong; i.e. you can use it without
|
||||
// even thinking about it to implement copy assignment whereever the
|
||||
// object data is managed indirectly via a pointer, which is very common.
|
||||
|
||||
RefPtr<T_CppObject> temp (src);
|
||||
this->swap(temp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T_CppObject>
|
||||
template <class T_CastFrom>
|
||||
inline
|
||||
RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(const RefPtr<T_CastFrom>& src)
|
||||
{
|
||||
RefPtr<T_CppObject> temp (src);
|
||||
this->swap(temp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
bool RefPtr<T_CppObject>::operator==(const RefPtr<T_CppObject>& src) const
|
||||
{
|
||||
return (pCppObject_ == src.pCppObject_);
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
bool RefPtr<T_CppObject>::operator!=(const RefPtr<T_CppObject>& src) const
|
||||
{
|
||||
return (pCppObject_ != src.pCppObject_);
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
RefPtr<T_CppObject>::operator bool() const
|
||||
{
|
||||
return (pCppObject_ != 0);
|
||||
}
|
||||
|
||||
template <class T_CppObject> inline
|
||||
void RefPtr<T_CppObject>::clear()
|
||||
{
|
||||
RefPtr<T_CppObject> temp; // swap with an empty RefPtr<> to clear *this
|
||||
this->swap(temp);
|
||||
}
|
||||
|
||||
template <class T_CppObject>
|
||||
template <class T_CastFrom>
|
||||
inline
|
||||
RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_dynamic(const RefPtr<T_CastFrom>& src)
|
||||
{
|
||||
T_CppObject *const pCppObject = dynamic_cast<T_CppObject*>(src.operator->());
|
||||
|
||||
if(pCppObject && src.refcount_())
|
||||
++(*(src.refcount_()));
|
||||
|
||||
return RefPtr<T_CppObject>(pCppObject); //TODO: Does an unnecessary extra reference() on the C object.
|
||||
}
|
||||
|
||||
template <class T_CppObject>
|
||||
template <class T_CastFrom>
|
||||
inline
|
||||
RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_static(const RefPtr<T_CastFrom>& src)
|
||||
{
|
||||
T_CppObject *const pCppObject = static_cast<T_CppObject*>(src.operator->());
|
||||
|
||||
if(pCppObject && src.refcount_())
|
||||
++(*(src.refcount_()));
|
||||
|
||||
return RefPtr<T_CppObject>(pCppObject); //TODO: Does an unnecessary extra reference() on the C object.
|
||||
}
|
||||
|
||||
template <class T_CppObject>
|
||||
template <class T_CastFrom>
|
||||
inline
|
||||
RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_const(const RefPtr<T_CastFrom>& src)
|
||||
{
|
||||
T_CppObject *const pCppObject = const_cast<T_CppObject*>(src.operator->());
|
||||
|
||||
if(pCppObject && src.refcount_())
|
||||
++(*(src.refcount_()));
|
||||
|
||||
return RefPtr<T_CppObject>(pCppObject); //TODO: Does an unnecessary extra reference() on the C object.
|
||||
}
|
||||
|
||||
#endif /* DOXYGEN_IGNORE_THIS */
|
||||
|
||||
/** @relates Glib::RefPtr */
|
||||
template <class T_CppObject> inline
|
||||
void swap(RefPtr<T_CppObject>& lhs, RefPtr<T_CppObject>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
|
||||
#endif /* _cairo_REFPTR_H */
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
104
libs/cairomm/cairomm/scaledfont.cc
Normal file
104
libs/cairomm/cairomm/scaledfont.cc
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/* Copyright (C) 2006 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/scaledfont.h>
|
||||
#include <cairomm/private.h> // for check_status_and_throw_exception
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
ScaledFont::ScaledFont(cobject* cobj, bool has_reference)
|
||||
{
|
||||
if(has_reference)
|
||||
m_cobject = cobj;
|
||||
else
|
||||
m_cobject = cairo_scaled_font_reference(cobj);
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> ScaledFont::create(FontFace& font_face, const Matrix& font_matrix,
|
||||
const Matrix& ctm, const FontOptions& options)
|
||||
{
|
||||
cairo_scaled_font_t* cobj = cairo_scaled_font_create(font_face.cobj(), &font_matrix, &ctm, options.cobj());
|
||||
check_status_and_throw_exception(cairo_scaled_font_status(cobj));
|
||||
return RefPtr<ScaledFont>(new ScaledFont(cobj, false));
|
||||
}
|
||||
|
||||
void ScaledFont::extents(FontExtents& extents) const
|
||||
{
|
||||
cairo_scaled_font_extents(m_cobject, static_cast<cairo_font_extents_t*>(&extents));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void ScaledFont::text_extents(const std::string& utf8, TextExtents& extents) const
|
||||
{
|
||||
cairo_scaled_font_text_extents(m_cobject, utf8.c_str(), static_cast<cairo_text_extents_t*>(&extents));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void ScaledFont::glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents)
|
||||
{
|
||||
// copy the data from the vector to a standard C array. I don't believe
|
||||
// this will be a frequently used function so I think the performance hit is
|
||||
// more than offset by the increased flexibility of the STL interface.
|
||||
|
||||
// Use new to allocate memory as MSCV complains about non-const array size with
|
||||
// Glyph glyph_array[glyphs.size()]
|
||||
Glyph* glyph_array= new Glyph[glyphs.size()];
|
||||
std::copy(glyphs.begin(), glyphs.end(), glyph_array);
|
||||
|
||||
cairo_scaled_font_glyph_extents(m_cobject, glyph_array, glyphs.size(),
|
||||
static_cast<cairo_text_extents_t*>(&extents));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
delete[] glyph_array;
|
||||
}
|
||||
|
||||
RefPtr<FontFace> ScaledFont::get_font_face() const
|
||||
{
|
||||
cairo_font_face_t* face = cairo_scaled_font_get_font_face(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return RefPtr<FontFace>(new FontFace(face, true));
|
||||
}
|
||||
|
||||
void ScaledFont::get_font_options(FontOptions& options) const
|
||||
{
|
||||
cairo_scaled_font_get_font_options(m_cobject, options.cobj());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void ScaledFont::get_font_matrix(Matrix& font_matrix) const
|
||||
{
|
||||
cairo_scaled_font_get_font_matrix(m_cobject,
|
||||
static_cast<cairo_matrix_t*>(&font_matrix));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void ScaledFont::get_ctm(Matrix& ctm) const
|
||||
{
|
||||
cairo_scaled_font_get_ctm(m_cobject, static_cast<cairo_matrix_t*>(&ctm));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
FontType ScaledFont::get_type() const
|
||||
{
|
||||
cairo_font_type_t font_type = cairo_scaled_font_get_type(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return static_cast<FontType>(font_type);
|
||||
}
|
||||
|
||||
} // namespace Cairo
|
||||
// vim: ts=2 sw=2 et
|
||||
153
libs/cairomm/cairomm/scaledfont.h
Normal file
153
libs/cairomm/cairomm/scaledfont.h
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/* Copyright (C) 2006 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_SCALEDFONT_H
|
||||
#define __CAIROMM_SCALEDFONT_H
|
||||
|
||||
#include <cairomm/context.h>
|
||||
#include <cairomm/fontoptions.h>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} ScaledFontType;
|
||||
|
||||
/** A ScaledFont is a font scaled to a particular size and device resolution. It
|
||||
* is most useful for low-level font usage where a library or application wants
|
||||
* to cache a reference to a scaled font to speed up the computation of metrics.
|
||||
*/
|
||||
class ScaledFont
|
||||
{
|
||||
|
||||
public:
|
||||
/** The underlying C cairo object type */
|
||||
typedef cairo_scaled_font_t cobject;
|
||||
|
||||
/** Provides acces to the underlying C cairo object */
|
||||
inline cobject* cobj() { return m_cobject; }
|
||||
|
||||
/** Provides acces to the underlying C cairo object */
|
||||
inline const cobject* cobj() const { return m_cobject; }
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
// For use only by the cairomm implementation.
|
||||
inline ErrorStatus get_status() const
|
||||
{ return cairo_scaled_font_status(const_cast<cairo_scaled_font_t*>(cobj())); }
|
||||
|
||||
// for RefPtr
|
||||
void reference() const { cairo_scaled_font_reference(m_cobject); }
|
||||
void unreference() const { cairo_scaled_font_destroy(m_cobject); }
|
||||
#endif //DOXYGEN_IGNORE_THIS
|
||||
|
||||
/** Createa C++ wrapper object from the C instance. This C++ object should
|
||||
* then be given to a RefPtr.
|
||||
*/
|
||||
explicit ScaledFont(cobject* cobj, bool has_reference = false);
|
||||
|
||||
/** Creates a ScaledFont object from a font face and matrices that describe
|
||||
* the size of the font and the environment in which it will be used.
|
||||
*
|
||||
* @param font_face A font face.
|
||||
* @param font_matrix font space to user space transformation matrix for the
|
||||
* font. In the simplest case of a N point font, this matrix is just a scale
|
||||
* by N, but it can also be used to shear the font or stretch it unequally
|
||||
* along the two axes. See Context::set_font_matrix().
|
||||
* @param ctm user to device transformation matrix with which the font will be
|
||||
* used.
|
||||
* @param options: options to use when getting metrics for the font and
|
||||
* rendering with it.
|
||||
*/
|
||||
static RefPtr<ScaledFont> create(FontFace& font_face, const Matrix& font_matrix,
|
||||
const Matrix& ctm, const FontOptions& options);
|
||||
|
||||
/** Gets the metrics for a ScaledFont */
|
||||
void extents(FontExtents& extents) const;
|
||||
|
||||
/** Gets the extents for a string of text. The extents describe a user-space
|
||||
* rectangle that encloses the "inked" portion of the text drawn at the origin
|
||||
* (0,0) (as it would be drawn by Context::show_text() if the cairo graphics
|
||||
* state were set to the same font_face, font_matrix, ctm, and font_options as
|
||||
* the ScaledFont object). Additionally, the x_advance and y_advance values
|
||||
* indicate the amount by which the current point would be advanced by
|
||||
* Context::show_text().
|
||||
*
|
||||
* Note that whitespace characters do not directly contribute to the size of
|
||||
* the rectangle (extents.width and extents.height). They do contribute
|
||||
* indirectly by changing the position of non-whitespace characters. In
|
||||
* particular, trailing whitespace characters are likely to not affect the
|
||||
* size of the rectangle, though they will affect the x_advance and y_advance
|
||||
* values.
|
||||
*
|
||||
* @param utf8 a string of text, encoded in UTF-8
|
||||
* @param extents Returns the extents of the given string
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
void text_extents(const std::string& utf8, TextExtents& extents) const;
|
||||
|
||||
/** Gets the extents for an array of glyphs. The extents describe a user-space
|
||||
* rectangle that encloses the "inked" portion of the glyphs, (as they would
|
||||
* be drawn by Context::show_glyphs() if the cairo graphics state were set to the
|
||||
* same font_face, font_matrix, ctm, and font_options as the ScaledFont
|
||||
* object). Additionally, the x_advance and y_advance values indicate the
|
||||
* amount by which the current point would be advanced by Context::show_glyphs().
|
||||
*
|
||||
* Note that whitespace glyphs do not contribute to the size of the rectangle
|
||||
* (extents.width and extents.height).
|
||||
*
|
||||
* @param glyphs A vector of glyphs to calculate the extents of
|
||||
* @param extents Returns the extents for the array of glyphs
|
||||
**/
|
||||
void glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents);
|
||||
|
||||
/** The FontFace with which this ScaledFont was created.
|
||||
* @since 1.2
|
||||
*/
|
||||
RefPtr<FontFace> get_font_face() const;
|
||||
|
||||
/** Gets the FontOptions with which the ScaledFont was created.
|
||||
* @since 1.2
|
||||
*/
|
||||
void get_font_options(FontOptions& options) const;
|
||||
|
||||
/** Gets the font matrix with which the ScaledFont was created.
|
||||
* @since 1.2
|
||||
*/
|
||||
void get_font_matrix(Matrix& font_matrix) const;
|
||||
|
||||
/** Gets the CTM with which the ScaledFont was created.
|
||||
* @since 1.2
|
||||
*/
|
||||
void get_ctm(Matrix& ctm) const;
|
||||
|
||||
/** Gets the type of scaled Font
|
||||
* @since 1.2
|
||||
*/
|
||||
FontType get_type() const;
|
||||
|
||||
protected:
|
||||
/** The underlying C cairo object that is wrapped by this ScaledFont */
|
||||
cobject* m_cobject;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __CAIROMM_SCALEDFONT_H
|
||||
// vim: ts=2 sw=2 et
|
||||
382
libs/cairomm/cairomm/surface.cc
Normal file
382
libs/cairomm/cairomm/surface.cc
Normal file
|
|
@ -0,0 +1,382 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/surface.h>
|
||||
#include <cairomm/private.h>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
Surface::Surface(cairo_surface_t* cobject, bool has_reference)
|
||||
: m_cobject(0)
|
||||
{
|
||||
if(has_reference)
|
||||
m_cobject = cobject;
|
||||
else
|
||||
m_cobject = cairo_surface_reference(cobject);
|
||||
}
|
||||
|
||||
Surface::~Surface()
|
||||
{
|
||||
if(m_cobject)
|
||||
cairo_surface_destroy(m_cobject);
|
||||
}
|
||||
|
||||
void Surface::finish()
|
||||
{
|
||||
cairo_surface_finish(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Surface::get_font_options(FontOptions& options) const
|
||||
{
|
||||
cairo_font_options_t* cfontoptions = cairo_font_options_create();
|
||||
cairo_surface_get_font_options(m_cobject, cfontoptions);
|
||||
options = FontOptions(cfontoptions);
|
||||
cairo_font_options_destroy(cfontoptions);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Surface::flush()
|
||||
{
|
||||
cairo_surface_flush(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Surface::mark_dirty()
|
||||
{
|
||||
cairo_surface_mark_dirty(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Surface::mark_dirty(int x, int y, int width, int height)
|
||||
{
|
||||
cairo_surface_mark_dirty_rectangle(m_cobject, x, y, width, height);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Surface::set_device_offset(double x_offset, double y_offset)
|
||||
{
|
||||
cairo_surface_set_device_offset(m_cobject, x_offset, y_offset);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void Surface::get_device_offset(double& x_offset, double& y_offset) const
|
||||
{
|
||||
cairo_surface_get_device_offset(const_cast<cobject*>(m_cobject), &x_offset, &y_offset);
|
||||
}
|
||||
|
||||
void Surface::set_fallback_resolution(double x_pixels_per_inch, double y_pixels_per_inch)
|
||||
{
|
||||
cairo_surface_set_fallback_resolution(m_cobject, x_pixels_per_inch, y_pixels_per_inch);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
SurfaceType Surface::get_type() const
|
||||
{
|
||||
cairo_surface_type_t surface_type = cairo_surface_get_type(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return static_cast<SurfaceType>(surface_type);
|
||||
}
|
||||
|
||||
#ifdef CAIRO_HAS_PNG_FUNCTIONS
|
||||
void Surface::write_to_png(const std::string& filename)
|
||||
{
|
||||
ErrorStatus status = cairo_surface_write_to_png(m_cobject, filename.c_str());
|
||||
check_status_and_throw_exception(status);
|
||||
}
|
||||
|
||||
void Surface::write_to_png(cairo_write_func_t write_func, void *closure)
|
||||
{
|
||||
ErrorStatus status = cairo_surface_write_to_png_stream(m_cobject, write_func, closure);
|
||||
check_status_and_throw_exception(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Surface::reference() const
|
||||
{
|
||||
cairo_surface_reference(m_cobject);
|
||||
}
|
||||
|
||||
void Surface::unreference() const
|
||||
{
|
||||
cairo_surface_destroy(m_cobject);
|
||||
}
|
||||
|
||||
RefPtr<Surface> Surface::create(const RefPtr<Surface> other, Content content, int width, int height)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_surface_create_similar(other->m_cobject, (cairo_content_t)content, width, height);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<Surface>(new Surface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImageSurface::ImageSurface(cairo_surface_t* cobject, bool has_reference)
|
||||
: Surface(cobject, has_reference)
|
||||
{ }
|
||||
|
||||
ImageSurface::~ImageSurface()
|
||||
{
|
||||
// surface is destroyed in base class
|
||||
}
|
||||
|
||||
RefPtr<ImageSurface> ImageSurface::create(Format format, int width, int height)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_image_surface_create((cairo_format_t)format, width, height);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
RefPtr<ImageSurface> ImageSurface::create(unsigned char* data, Format format, int width, int height, int stride)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_image_surface_create_for_data(data, (cairo_format_t)format, width, height, stride);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
#ifdef CAIRO_HAS_PNG_FUNCTIONS
|
||||
|
||||
RefPtr<ImageSurface> ImageSurface::create_from_png(std::string filename)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_image_surface_create_from_png(filename.c_str());
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
RefPtr<ImageSurface> ImageSurface::create_from_png(cairo_read_func_t read_func, void *closure)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_image_surface_create_from_png_stream(read_func, closure);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
#endif // CAIRO_HAS_PNG_FUNCTIONS
|
||||
|
||||
int ImageSurface::get_width() const
|
||||
{
|
||||
const int result = cairo_image_surface_get_width(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
int ImageSurface::get_height() const
|
||||
{
|
||||
const int result = cairo_image_surface_get_height(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned char* ImageSurface::get_data()
|
||||
{
|
||||
return cairo_image_surface_get_data(m_cobject);
|
||||
}
|
||||
|
||||
const unsigned char* ImageSurface::get_data() const
|
||||
{
|
||||
return cairo_image_surface_get_data(m_cobject);
|
||||
}
|
||||
|
||||
Format ImageSurface::get_format() const
|
||||
{
|
||||
return static_cast<Format>(cairo_image_surface_get_format(m_cobject));
|
||||
}
|
||||
|
||||
int ImageSurface::get_stride() const
|
||||
{
|
||||
return cairo_image_surface_get_stride(m_cobject);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* THE FOLLOWING SURFACE TYPES ARE EXPERIMENTAL AND NOT FULLY SUPPORTED
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef CAIRO_HAS_PDF_SURFACE
|
||||
|
||||
PdfSurface::PdfSurface(cairo_surface_t* cobject, bool has_reference) :
|
||||
Surface(cobject, has_reference)
|
||||
{}
|
||||
|
||||
PdfSurface::~PdfSurface()
|
||||
{
|
||||
// surface is destroyed in base class
|
||||
}
|
||||
|
||||
RefPtr<PdfSurface> PdfSurface::create(std::string filename, double width_in_points, double height_in_points)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_pdf_surface_create(filename.c_str(), width_in_points, height_in_points);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<PdfSurface>(new PdfSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
RefPtr<PdfSurface> PdfSurface::create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_pdf_surface_create_for_stream(write_func, closure, width_in_points, height_in_points);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<PdfSurface>(new PdfSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
void PdfSurface::set_size(double width_in_points, double height_in_points)
|
||||
{
|
||||
cairo_pdf_surface_set_size(m_cobject, width_in_points, height_in_points);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
#endif // CAIRO_HAS_PDF_SURFACE
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef CAIRO_HAS_PS_SURFACE
|
||||
|
||||
PsSurface::PsSurface(cairo_surface_t* cobject, bool has_reference) :
|
||||
Surface(cobject, has_reference)
|
||||
{}
|
||||
|
||||
PsSurface::~PsSurface()
|
||||
{
|
||||
// surface is destroyed in base class
|
||||
}
|
||||
|
||||
RefPtr<PsSurface> PsSurface::create(std::string filename, double width_in_points, double height_in_points)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_ps_surface_create(filename.c_str(), width_in_points, height_in_points);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<PsSurface>(new PsSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
RefPtr<PsSurface> PsSurface::create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_ps_surface_create_for_stream(write_func, closure, width_in_points, height_in_points);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<PsSurface>(new PsSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
void PsSurface::set_size(double width_in_points, double height_in_points)
|
||||
{
|
||||
cairo_ps_surface_set_size(m_cobject, width_in_points, height_in_points);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
|
||||
void PsSurface::dsc_comment(std::string comment)
|
||||
{
|
||||
cairo_ps_surface_dsc_comment(m_cobject, comment.c_str());
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void PsSurface::dsc_begin_setup()
|
||||
{
|
||||
cairo_ps_surface_dsc_begin_setup(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void PsSurface::dsc_begin_page_setup()
|
||||
{
|
||||
cairo_ps_surface_dsc_begin_page_setup(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
|
||||
#endif // CAIRO_HAS_PS_SURFACE
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
|
||||
SvgSurface::SvgSurface(cairo_surface_t* cobject, bool has_reference) :
|
||||
Surface(cobject, has_reference)
|
||||
{}
|
||||
|
||||
SvgSurface::~SvgSurface()
|
||||
{
|
||||
// surface is destroyed in base class
|
||||
}
|
||||
|
||||
RefPtr<SvgSurface> SvgSurface::create(std::string filename, double width_in_points, double height_in_points)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_svg_surface_create(filename.c_str(), width_in_points, height_in_points);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<SvgSurface>(new SvgSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
RefPtr<SvgSurface> SvgSurface::create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_svg_surface_create_for_stream(write_func, closure, width_in_points, height_in_points);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<SvgSurface>(new SvgSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
void SvgSurface::restrict_to_version(SvgVersion version)
|
||||
{
|
||||
cairo_svg_surface_restrict_to_version(m_cobject, static_cast<cairo_svg_version_t>(version));
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
const std::vector<SvgVersion> SvgSurface::get_versions()
|
||||
{
|
||||
cairo_svg_version_t const *versions;
|
||||
int num_versions;
|
||||
cairo_svg_get_versions(&versions, &num_versions);
|
||||
|
||||
// Just copy the version array out into a std::vector. This is a rarely used
|
||||
// function and the array of versions is going to be very small, so there's no
|
||||
// real performance hit.
|
||||
std::vector<SvgVersion> vec;
|
||||
for (int i = 0; i < num_versions; ++i)
|
||||
{
|
||||
vec.push_back(static_cast<SvgVersion>(versions[i]));
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::string SvgSurface::version_to_string(SvgVersion version)
|
||||
{
|
||||
return std::string(cairo_svg_version_to_string(static_cast<cairo_svg_version_t>(version)));
|
||||
}
|
||||
|
||||
#endif // CAIRO_HAS_SVG_SURFACE
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef CAIRO_HAS_GLITZ_SURFACE
|
||||
|
||||
GlitzSurface::GlitzSurface(cairo_surface_t* cobject, bool has_reference)
|
||||
: Surface(cobject, has_reference)
|
||||
{ }
|
||||
|
||||
GlitzSurface::~GlitzSurface()
|
||||
{
|
||||
// surface is destroyed in base class
|
||||
}
|
||||
|
||||
RefPtr<GlitzSurface> GlitzSurface::create(glitz_surface_t *surface)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_glitz_surface_create(surface);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<GlitzSurface>(new GlitzSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
#endif // CAIRO_HAS_GLITZ_SURFACE
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
631
libs/cairomm/cairomm/surface.h
Normal file
631
libs/cairomm/cairomm/surface.h
Normal file
|
|
@ -0,0 +1,631 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_SURFACE_H
|
||||
#define __CAIROMM_SURFACE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cairomm/enums.h>
|
||||
#include <cairomm/exception.h>
|
||||
#include <cairomm/fontoptions.h>
|
||||
#include <cairomm/refptr.h>
|
||||
|
||||
//See xlib_surface.h for XlibSurface.
|
||||
//See win32_surface.h for Win32Surface.
|
||||
|
||||
#ifdef CAIRO_HAS_PDF_SURFACE
|
||||
#include <cairo-pdf.h>
|
||||
#endif // CAIRO_HAS_PDF_SURFACE
|
||||
#ifdef CAIRO_HAS_PS_SURFACE
|
||||
#include <cairo-ps.h>
|
||||
#endif // CAIRO_HAS_PS_SURFACE
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
#include <cairo-svg.h>
|
||||
#endif // CAIRO_HAS_SVG_SURFACE
|
||||
|
||||
// Experimental surfaces
|
||||
#ifdef CAIRO_HAS_GLITZ_SURFACE
|
||||
#include <cairo-glitz.h>
|
||||
#endif // CAIRO_HAS_GLITZ_SURFACE
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
/** A cairo surface represents an image, either as the destination of a drawing
|
||||
* operation or as source when drawing onto another surface. There are
|
||||
* different subtypes of cairo surface for different drawing backends. This
|
||||
* class is a base class for all subtypes and should not be used directly
|
||||
*
|
||||
* Surfaces are reference-counted objects that should be used via Cairo::RefPtr.
|
||||
*/
|
||||
class Surface
|
||||
{
|
||||
public:
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
*
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit Surface(cairo_surface_t* cobject, bool has_reference = false);
|
||||
|
||||
virtual ~Surface();
|
||||
|
||||
/** Retrieves the default font rendering options for the surface. This allows
|
||||
* display surfaces to report the correct subpixel order for rendering on
|
||||
* them, print surfaces to disable hinting of metrics and so forth. The
|
||||
* result can then be used with cairo_scaled_font_create().
|
||||
*
|
||||
* @param options a FontOptions object into which to store the retrieved
|
||||
* options. All existing values are overwritten
|
||||
*/
|
||||
void get_font_options(FontOptions& options) const;
|
||||
|
||||
/** This function finishes the surface and drops all references to external
|
||||
* resources. For example, for the Xlib backend it means that cairo will no
|
||||
* longer access the drawable, which can be freed. After calling
|
||||
* finish() the only valid operations on a surface are getting and setting
|
||||
* user data and referencing and destroying it. Further drawing to the
|
||||
* surface will not affect the surface but will instead trigger a
|
||||
* CAIRO_STATUS_SURFACE_FINISHED error.
|
||||
*
|
||||
* When the Surface is destroyed, cairo will call finish() if it hasn't been
|
||||
* called already, before freeing the resources associated with the Surface.
|
||||
*/
|
||||
void finish();
|
||||
|
||||
/** Do any pending drawing for the surface and also restore any temporary
|
||||
* modifications cairo has made to the surface's state. This function must
|
||||
* be called before switching from drawing on the surface with cairo to
|
||||
* drawing on it directly with native APIs. If the surface doesn't support
|
||||
* direct access, then this function does nothing.
|
||||
*/
|
||||
void flush();
|
||||
|
||||
/** Tells cairo to consider the data buffer dirty.
|
||||
*
|
||||
* In particular, if you've created an ImageSurface with a data buffer that
|
||||
* you've allocated yourself and you draw to that data buffer using means
|
||||
* other than cairo, you must call mark_dirty() before doing any additional
|
||||
* drawing to that surface with cairo.
|
||||
*
|
||||
* Note that if you do draw to the Surface outside of cairo, you must call
|
||||
* flush() before doing the drawing.
|
||||
*/
|
||||
void mark_dirty();
|
||||
|
||||
/** Marks a rectangular area of the given surface dirty.
|
||||
*
|
||||
* @param x X coordinate of dirty rectangle
|
||||
* @param y Y coordinate of dirty rectangle
|
||||
* @param width width of dirty rectangle
|
||||
* @param height height of dirty rectangle
|
||||
*/
|
||||
void mark_dirty(int x, int y, int width, int height);
|
||||
|
||||
/** Sets an offset that is added to the device coordinates determined by the
|
||||
* CTM when drawing to surface. One use case for this function is when we
|
||||
* want to create a Surface that redirects drawing for a portion of
|
||||
* an onscreen surface to an offscreen surface in a way that is completely
|
||||
* invisible to the user of the cairo API. Setting a transformation via
|
||||
* cairo_translate() isn't sufficient to do this, since functions like
|
||||
* Cairo::Context::device_to_user() will expose the hidden offset.
|
||||
*
|
||||
* Note that the offset only affects drawing to the surface, not using the
|
||||
* surface in a surface pattern.
|
||||
*
|
||||
* @param x_offset the offset in the X direction, in device units
|
||||
* @param y_offset the offset in the Y direction, in device units
|
||||
*/
|
||||
void set_device_offset(double x_offset, double y_offset);
|
||||
|
||||
/** Returns a previous device offset set by set_device_offset().
|
||||
*/
|
||||
void get_device_offset(double& x_offset, double& y_offset) const;
|
||||
|
||||
/** Sets the fallback resolution of the image in dots per inch
|
||||
*
|
||||
* @param x_pixels_per_inch Pixels per inch in the x direction
|
||||
* @param y_pixels_per_inch Pixels per inch in the y direction
|
||||
*/
|
||||
void set_fallback_resolution(double x_pixels_per_inch, double y_pixels_per_inch);
|
||||
|
||||
SurfaceType get_type() const;
|
||||
|
||||
#ifdef CAIRO_HAS_PNG_FUNCTIONS
|
||||
|
||||
/** Writes the contents of surface to a new file filename as a PNG image.
|
||||
*
|
||||
* @note For this function to be available, cairo must have been compiled
|
||||
* with PNG support
|
||||
*
|
||||
* @param filename the name of a file to write to
|
||||
*/
|
||||
void write_to_png(const std::string& filename);
|
||||
|
||||
/** Writes the Surface to the write function.
|
||||
*
|
||||
* @note For this function to be available, cairo must have been compiled
|
||||
* with PNG support
|
||||
*
|
||||
* @param write_func The function to be called when the backend needs to
|
||||
* write data to an output stream
|
||||
* @param closure closure data for the write function
|
||||
*/
|
||||
void write_to_png(cairo_write_func_t write_func, void *closure); //TODO: Use a sigc::slot?
|
||||
|
||||
#endif // CAIRO_HAS_PNG_FUNCTIONS
|
||||
|
||||
|
||||
/** The underlying C cairo surface type
|
||||
*/
|
||||
typedef cairo_surface_t cobject;
|
||||
/** Provides acces to the underlying C cairo surface
|
||||
*/
|
||||
inline cobject* cobj() { return m_cobject; }
|
||||
/** Provides acces to the underlying C cairo surface
|
||||
*/
|
||||
inline const cobject* cobj() const { return m_cobject; }
|
||||
|
||||
#ifndef DOXYGEN_IGNORE_THIS
|
||||
///For use only by the cairomm implementation.
|
||||
inline ErrorStatus get_status() const
|
||||
{ return cairo_surface_status(const_cast<cairo_surface_t*>(cobj())); }
|
||||
|
||||
void reference() const;
|
||||
void unreference() const;
|
||||
#endif //DOXYGEN_IGNORE_THIS
|
||||
|
||||
/** Create a new surface that is as compatible as possible with an existing
|
||||
* surface. The new surface will use the same backend as other unless that is
|
||||
* not possible for some reason.
|
||||
*
|
||||
* @param other an existing surface used to select the backend of the new surface
|
||||
* @param content the content for the new surface
|
||||
* @param width width of the new surface, (in device-space units)
|
||||
* @param height height of the new surface (in device-space units)
|
||||
* @return a RefPtr to the newly allocated surface.
|
||||
*/
|
||||
static RefPtr<Surface> create(const RefPtr<Surface> other, Content content, int width, int height);
|
||||
|
||||
protected:
|
||||
/** The underlying C cairo surface type that is wrapped by this Surface
|
||||
*/
|
||||
cobject* m_cobject;
|
||||
};
|
||||
|
||||
|
||||
/** Image surfaces provide the ability to render to memory buffers either
|
||||
* allocated by cairo or by the calling code. The supported image formats are
|
||||
* those defined in Cairo::Format
|
||||
*
|
||||
* An ImageSurface is the most generic type of Surface and the only one that is
|
||||
* available by default. You can either create an ImageSurface whose data is
|
||||
* managed by Cairo, or you can create an ImageSurface with a data buffer that
|
||||
* you allocated yourself so that you can have full access to the data.
|
||||
*
|
||||
* When you create an ImageSurface with your own data buffer, you are free to
|
||||
* examine the results at any point and do whatever you want with it. Note that
|
||||
* if you modify anything and later want to continue to draw to the surface
|
||||
* with cairo, you must let cairo know via Cairo::Surface::mark_dirty()
|
||||
*
|
||||
* Note that like all surfaces, an ImageSurface is a reference-counted object that should be used via Cairo::RefPtr.
|
||||
*/
|
||||
class ImageSurface : public Surface
|
||||
{
|
||||
protected:
|
||||
//TODO?: Surface(cairo_surface_t *target);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference Whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit ImageSurface(cairo_surface_t* cobject, bool has_reference = false);
|
||||
|
||||
virtual ~ImageSurface();
|
||||
|
||||
/** Gets the width of the ImageSurface in pixels
|
||||
*/
|
||||
int get_width() const;
|
||||
|
||||
/** Gets the height of the ImageSurface in pixels
|
||||
*/
|
||||
int get_height() const;
|
||||
|
||||
/**
|
||||
* Get a pointer to the data of the image surface, for direct
|
||||
* inspection or modification.
|
||||
*
|
||||
* Return value: a pointer to the image data of this surface or NULL
|
||||
* if @surface is not an image surface.
|
||||
*/
|
||||
unsigned char* get_data();
|
||||
const unsigned char* get_data() const;
|
||||
|
||||
/** gets the format of the surface
|
||||
*/
|
||||
Format get_format() const;
|
||||
|
||||
/**
|
||||
* Return value: the stride of the image surface in bytes (or 0 if
|
||||
* @surface is not an image surface). The stride is the distance in
|
||||
* bytes from the beginning of one row of the image data to the
|
||||
* beginning of the next row.
|
||||
*/
|
||||
int get_stride() const;
|
||||
|
||||
|
||||
/** Creates an image surface of the specified format and dimensions. The
|
||||
* initial contents of the surface is undefined; you must explicitely clear
|
||||
* the buffer, using, for example, Cairo::Context::rectangle() and
|
||||
* Cairo::Context::fill() if you want it cleared.
|
||||
*
|
||||
* Use this function to create the surface if you don't need access to the
|
||||
* internal data and want cairo to manage it for you. Since you don't have
|
||||
* access to the internal data, the resulting surface can only be saved to a
|
||||
* PNG image file (if cairo has been compiled with PNG support) or as a
|
||||
* source surface (see Cairo::SurfacePattern).
|
||||
*
|
||||
* @param format format of pixels in the surface to create
|
||||
* @param width width of the surface, in pixels
|
||||
* @param height height of the surface, in pixels
|
||||
* @return a RefPtr to the newly created surface.
|
||||
*/
|
||||
static RefPtr<ImageSurface> create(Format format, int width, int height);
|
||||
|
||||
/** Creates an image surface for the provided pixel data. The output buffer
|
||||
* must be kept around until the Surface is destroyed or finish() is called
|
||||
* on the surface. The initial contents of buffer will be used as the inital
|
||||
* image contents; you must explicitely clear the buffer, using, for example,
|
||||
* Cairo::Context::rectangle() and Cairo::Context::fill() if you want it
|
||||
* cleared.
|
||||
*
|
||||
* If you want to be able to manually manipulate or extract the data after
|
||||
* drawing to the surface with Cairo, you should use this function to create
|
||||
* the Surface. Since you own the internal data, you can do anything you
|
||||
* want with it.
|
||||
*
|
||||
* @param data a pointer to a buffer supplied by the application in which
|
||||
* to write contents.
|
||||
* @param format the format of pixels in the buffer
|
||||
* @param width the width of the image to be stored in the buffer
|
||||
* @param height the height of the image to be stored in the buffer
|
||||
* @param stride the number of bytes between the start of rows in the
|
||||
* buffer. Having this be specified separate from width allows for padding at
|
||||
* the end of rows, or for writing to a subportion of a larger image.
|
||||
* @return a RefPtr to the newly created surface.
|
||||
*/
|
||||
static RefPtr<ImageSurface> create(unsigned char* data, Format format, int width, int height, int stride);
|
||||
|
||||
#ifdef CAIRO_HAS_PNG_FUNCTIONS
|
||||
|
||||
/** Creates a new image surface and initializes the contents to the given PNG
|
||||
* file.
|
||||
*
|
||||
* @note For this function to be available, cairo must have been compiled
|
||||
* with PNG support.
|
||||
*
|
||||
* @param filename name of PNG file to load
|
||||
* @return a RefPtr to the new cairo_surface_t initialized with the
|
||||
* contents of the PNG image file.
|
||||
*/
|
||||
static RefPtr<ImageSurface> create_from_png(std::string filename);
|
||||
|
||||
/** Creates a new image surface from PNG data read incrementally via the
|
||||
* read_func function.
|
||||
*
|
||||
* @note For this function to be available, cairo must have been compiled
|
||||
* with PNG support.
|
||||
*
|
||||
* @param read_func function called to read the data of the file
|
||||
* @param closure data to pass to read_func.
|
||||
* @return a RefPtr to the new cairo_surface_t initialized with the
|
||||
* contents of the PNG image file.
|
||||
*/
|
||||
static RefPtr<ImageSurface> create_from_png(cairo_read_func_t read_func, void *closure);
|
||||
|
||||
#endif // CAIRO_HAS_PNG_FUNCTIONS
|
||||
|
||||
};
|
||||
|
||||
|
||||
#ifdef CAIRO_HAS_PDF_SURFACE
|
||||
|
||||
/** A PdfSurface provides a way to render PDF documents from cairo. This
|
||||
* surface is not rendered to the screen but instead renders the drawing to a
|
||||
* PDF file on disk.
|
||||
*
|
||||
* @note For this Surface to be available, cairo must have been compiled with
|
||||
* PDF support
|
||||
*/
|
||||
class PdfSurface : public Surface
|
||||
{
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
*
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit PdfSurface(cairo_surface_t* cobject, bool has_reference = false);
|
||||
virtual ~PdfSurface();
|
||||
|
||||
/** Creates a PdfSurface with a specified dimensions that will be saved as
|
||||
* the given filename
|
||||
*
|
||||
* @param filename The name of the PDF file to save the surface to
|
||||
* @param width_in_points The width of the PDF document in points
|
||||
* @param height_in_points The height of the PDF document in points
|
||||
*/
|
||||
static RefPtr<PdfSurface> create(std::string filename, double width_in_points, double height_in_points);
|
||||
|
||||
/** Creates a PdfSurface with a specified dimensions that will be written to
|
||||
* the given write function instead of saved directly to disk
|
||||
*
|
||||
* @param write_func The function to be called when the backend needs to
|
||||
* write data to an output stream
|
||||
* @param closure closure data for the write function
|
||||
* @param width_in_points The width of the PDF document in points
|
||||
* @param height_in_points The height of the PDF document in points
|
||||
*/
|
||||
static RefPtr<PdfSurface> create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
|
||||
|
||||
/**
|
||||
* Changes the size of a PDF surface for the current (and subsequent) pages.
|
||||
*
|
||||
* This function should only be called before any drawing operations have been
|
||||
* performed on the current page. The simplest way to do this is to call this
|
||||
* function immediately after creating the surface or immediately after
|
||||
* completing a page with either Context::show_page() or Context::copy_page().
|
||||
*
|
||||
* @param width_in_points new surface width, in points (1 point == 1/72.0 inch)
|
||||
* @param height_in_points new surface height, in points (1 point == 1/72.0 inch)
|
||||
**/
|
||||
void set_size(double width_in_points, double height_in_points);
|
||||
|
||||
};
|
||||
|
||||
#endif // CAIRO_HAS_PDF_SURFACE
|
||||
|
||||
|
||||
#ifdef CAIRO_HAS_PS_SURFACE
|
||||
|
||||
/** A PsSurface provides a way to render PostScript documents from cairo. This
|
||||
* surface is not rendered to the screen but instead renders the drawing to a
|
||||
* PostScript file on disk.
|
||||
*
|
||||
* @note For this Surface to be available, cairo must have been compiled with
|
||||
* PostScript support
|
||||
*/
|
||||
class PsSurface : public Surface
|
||||
{
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
*
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit PsSurface(cairo_surface_t* cobject, bool has_reference = false);
|
||||
virtual ~PsSurface();
|
||||
|
||||
/** Creates a PsSurface with a specified dimensions that will be saved as the
|
||||
* given filename
|
||||
*
|
||||
* @param filename The name of the PostScript file to save the surface to
|
||||
* @param width_in_points The width of the PostScript document in points
|
||||
* @param height_in_points The height of the PostScript document in points
|
||||
*/
|
||||
static RefPtr<PsSurface> create(std::string filename, double width_in_points, double height_in_points);
|
||||
|
||||
/** Creates a PsSurface with a specified dimensions that will be written to
|
||||
* the given write function instead of saved directly to disk
|
||||
*
|
||||
* @param write_func The function to be called when the backend needs to
|
||||
* write data to an output stream
|
||||
* @param closure closure data for the write function
|
||||
* @param width_in_points The width of the PostScript document in points
|
||||
* @param height_in_points The height of the PostScript document in points
|
||||
*/
|
||||
static RefPtr<PsSurface> create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
|
||||
|
||||
/**
|
||||
* Changes the size of a PostScript surface for the current (and
|
||||
* subsequent) pages.
|
||||
*
|
||||
* This function should only be called before any drawing operations have been
|
||||
* performed on the current page. The simplest way to do this is to call this
|
||||
* function immediately after creating the surface or immediately after
|
||||
* completing a page with either Context::show_page() or Context::copy_page().
|
||||
*
|
||||
* @param width_in_points new surface width, in points (1 point == 1/72.0 inch)
|
||||
* @param height_in_points new surface height, in points (1 point == 1/72.0 inch)
|
||||
*/
|
||||
void set_size(double width_in_points, double height_in_points);
|
||||
|
||||
/** Emit a comment into the PostScript output for the given surface. See the
|
||||
* cairo reference documentation for more information.
|
||||
*
|
||||
* @param comment a comment string to be emitted into the PostScript output
|
||||
*/
|
||||
void dsc_comment(std::string comment);
|
||||
|
||||
/**
|
||||
* This function indicates that subsequent calls to dsc_comment() should direct
|
||||
* comments to the Setup section of the PostScript output.
|
||||
*
|
||||
* This function should be called at most once per surface, and must be called
|
||||
* before any call to dsc_begin_page_setup() and before any drawing is performed
|
||||
* to the surface.
|
||||
*/
|
||||
void dsc_begin_setup();
|
||||
|
||||
/** This function indicates that subsequent calls to dsc_comment() should
|
||||
* direct comments to the PageSetup section of the PostScript output.
|
||||
*
|
||||
* This function call is only needed for the first page of a surface. It
|
||||
* should be called after any call to dsc_begin_setup() and before any drawing
|
||||
* is performed to the surface.
|
||||
*/
|
||||
void dsc_begin_page_setup();
|
||||
|
||||
};
|
||||
|
||||
#endif // CAIRO_HAS_PS_SURFACE
|
||||
|
||||
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SVG_VERSION_1_1 = CAIRO_SVG_VERSION_1_1,
|
||||
SVG_VERSION_1_2 = CAIRO_SVG_VERSION_1_2
|
||||
} SvgVersion;
|
||||
|
||||
/** A SvgSurface provides a way to render Scalable Vector Graphics (SVG) images
|
||||
* from cairo. This surface is not rendered to the screen but instead renders
|
||||
* the drawing to an SVG file on disk.
|
||||
*
|
||||
* @note For this Surface to be available, cairo must have been compiled with
|
||||
* SVG support
|
||||
*/
|
||||
class SvgSurface : public Surface
|
||||
{
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
*
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit SvgSurface(cairo_surface_t* cobject, bool has_reference = false);
|
||||
virtual ~SvgSurface();
|
||||
|
||||
|
||||
/** Creates a SvgSurface with a specified dimensions that will be saved as the
|
||||
* given filename
|
||||
*
|
||||
* @param filename The name of the SVG file to save the surface to
|
||||
* @param width_in_points The width of the SVG document in points
|
||||
* @param height_in_points The height of the SVG document in points
|
||||
*/
|
||||
static RefPtr<SvgSurface> create(std::string filename, double width_in_points, double height_in_points);
|
||||
|
||||
/** Creates a SvgSurface with a specified dimensions that will be written to
|
||||
* the given write function instead of saved directly to disk
|
||||
*
|
||||
* @param write_func The function to be called when the backend needs to
|
||||
* write data to an output stream
|
||||
* @param closure closure data for the write function
|
||||
* @param width_in_points The width of the SVG document in points
|
||||
* @param height_in_points The height of the SVG document in points
|
||||
*/
|
||||
static RefPtr<SvgSurface> create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
|
||||
|
||||
/**
|
||||
* Restricts the generated SVG file to the given version. See get_versions()
|
||||
* for a list of available version values that can be used here.
|
||||
*
|
||||
* This function should only be called before any drawing operations have been
|
||||
* performed on the given surface. The simplest way to do this is to call this
|
||||
* function immediately after creating the surface.
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
void restrict_to_version(SvgVersion version);
|
||||
|
||||
/** Retrieves the list of SVG versions supported by cairo. See
|
||||
* restrict_to_version().
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
static const std::vector<SvgVersion> get_versions();
|
||||
|
||||
/** Get the string representation of the given version id. The returned string
|
||||
* will be empty if version isn't valid. See get_versions() for a way to get
|
||||
* the list of valid version ids.
|
||||
*
|
||||
* Since: 1.2
|
||||
*/
|
||||
static std::string version_to_string(SvgVersion version);
|
||||
};
|
||||
|
||||
#endif // CAIRO_HAS_SVG_SURFACE
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* THE FOLLOWING SURFACE TYPES ARE EXPERIMENTAL AND NOT FULLY SUPPORTED
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef CAIRO_HAS_GLITZ_SURFACE
|
||||
|
||||
/** A GlitzSurface provides a way to render to the X Window System using Glitz.
|
||||
* This provides a way to use OpenGL-accelerated graphics from cairo. If you
|
||||
* want to use hardware-accelerated graphics within the X Window system, you
|
||||
* should use this Surface type.
|
||||
*
|
||||
* @note For this Surface to be available, cairo must have been compiled with
|
||||
* Glitz support
|
||||
*
|
||||
* @warning This is an experimental surface. It is not yet marked as a fully
|
||||
* supported surface by the cairo library
|
||||
*/
|
||||
class GlitzSurface : public Surface
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
*
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit GlitzSurface(cairo_surface_t* cobject, bool has_reference = false);
|
||||
|
||||
virtual ~GlitzSurface();
|
||||
|
||||
/** Creates a new GlitzSurface
|
||||
*
|
||||
* @param surface a glitz surface type
|
||||
*/
|
||||
static RefPtr<GlitzSurface> create(glitz_surface_t *surface);
|
||||
|
||||
};
|
||||
|
||||
#endif // CAIRO_HAS_GLITZ_SURFACE
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_SURFACE_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
59
libs/cairomm/cairomm/win32_surface.cc
Normal file
59
libs/cairomm/cairomm/win32_surface.cc
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/win32_surface.h>
|
||||
#include <cairomm/private.h>
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
#ifdef CAIRO_HAS_WIN32_SURFACE
|
||||
|
||||
Win32Surface::Win32Surface(cairo_surface_t* cobject, bool has_reference) :
|
||||
Surface(cobject, has_reference)
|
||||
{}
|
||||
|
||||
Win32Surface::~Win32Surface()
|
||||
{
|
||||
// surface is destroyed in base class
|
||||
}
|
||||
|
||||
HDC Win32Surface::get_dc() const
|
||||
{
|
||||
return cairo_win32_surface_get_dc(m_cobject);
|
||||
}
|
||||
|
||||
RefPtr<Win32Surface> Win32Surface::create(HDC hdc)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_win32_surface_create(hdc);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
RefPtr<Win32Surface> Win32Surface::create(Format format, int width, int height)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_win32_surface_create_with_dib((cairo_format_t)format, width, height);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
#endif // CAIRO_HAS_WIN32_SURFACE
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
96
libs/cairomm/cairomm/win32_surface.h
Normal file
96
libs/cairomm/cairomm/win32_surface.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_WIN32_SURFACE_H
|
||||
#define __CAIROMM_WIN32_SURFACE_H
|
||||
|
||||
#include <cairomm/surface.h>
|
||||
#include <cairomm/enums.h>
|
||||
|
||||
#ifdef CAIRO_HAS_WIN32_SURFACE
|
||||
#include <cairo-win32.h>
|
||||
#endif
|
||||
|
||||
// This header is not included by cairomm.h because it requires Windows headers that
|
||||
// tend to pollute the namespace with non-prefixed #defines and typedefs.
|
||||
// You may include it directly if you need to use this API.
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
#ifdef CAIRO_HAS_WIN32_SURFACE
|
||||
|
||||
/** A Win32Surface provides a way to render within Microsoft Windows. If you
|
||||
* want to draw to the screen within a Microsoft Windows application, you
|
||||
* should use this Surface type.
|
||||
*
|
||||
* @note For this Surface to be available, cairo must have been compiled with
|
||||
* Win32 support
|
||||
*/
|
||||
class Win32Surface : public Surface
|
||||
{
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
*
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit Win32Surface(cairo_surface_t* cobject, bool has_reference = false);
|
||||
virtual ~Win32Surface();
|
||||
|
||||
/** Returns the HDC associated with this surface, or NULL if none. Also
|
||||
* returns NULL if the surface is not a win32 surface.
|
||||
*
|
||||
* @return HDC or NULL if no HDC available.
|
||||
*/
|
||||
HDC get_dc() const;
|
||||
|
||||
/** Creates a cairo surface that targets the given DC. The DC will be queried
|
||||
* for its initial clip extents, and this will be used as the size of the
|
||||
* cairo surface. Also, if the DC is a raster DC, it will be queried for its
|
||||
* pixel format and the cairo surface format will be set appropriately.
|
||||
*
|
||||
* @param hdc the DC to create a surface for
|
||||
* @return the newly created surface
|
||||
*/
|
||||
static RefPtr<Win32Surface> create(HDC hdc);
|
||||
|
||||
/** Creates a device-independent-bitmap surface not associated with any
|
||||
* particular existing surface or device context. The created bitmap will be
|
||||
* unititialized.
|
||||
*
|
||||
* @param format format of pixels in the surface to create
|
||||
* @param width width of the surface, in pixels
|
||||
* @param height height of the surface, in pixels
|
||||
* @return the newly created surface
|
||||
*/
|
||||
static RefPtr<Win32Surface> create(Format format, int width, int height);
|
||||
|
||||
};
|
||||
|
||||
#endif // CAIRO_HAS_WIN32_SURFACE
|
||||
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_WIN32_SURFACE_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
137
libs/cairomm/cairomm/xlib_surface.cc
Normal file
137
libs/cairomm/cairomm/xlib_surface.cc
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cairomm/xlib_surface.h>
|
||||
#include <cairomm/private.h>
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
#ifdef CAIRO_HAS_XLIB_SURFACE
|
||||
|
||||
XlibSurface::XlibSurface(cairo_surface_t* cobject, bool has_reference) :
|
||||
Surface(cobject, has_reference)
|
||||
{}
|
||||
|
||||
XlibSurface::~XlibSurface()
|
||||
{
|
||||
// surface is destroyed in base class
|
||||
}
|
||||
|
||||
RefPtr<XlibSurface> XlibSurface::create(Display* dpy, Drawable drawable, Visual* visual, int width, int height)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_xlib_surface_create(dpy, drawable, visual, width, height);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
RefPtr<XlibSurface> XlibSurface::create(Display* dpy, Pixmap bitmap, Screen* screen, int width, int height)
|
||||
{
|
||||
cairo_surface_t* cobject = cairo_xlib_surface_create_for_bitmap(dpy, bitmap, screen, width, height);
|
||||
check_status_and_throw_exception(cairo_surface_status(cobject));
|
||||
return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
|
||||
}
|
||||
|
||||
void XlibSurface::set_size(int width, int height)
|
||||
{
|
||||
cairo_xlib_surface_set_size(m_cobject, width, height);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
void XlibSurface::set_drawable(Drawable drawable, int width, int height)
|
||||
{
|
||||
cairo_xlib_surface_set_drawable(m_cobject, drawable, width, height);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
}
|
||||
|
||||
Drawable XlibSurface::get_drawable() const
|
||||
{
|
||||
Drawable drawable = cairo_xlib_surface_get_drawable(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
const Display* XlibSurface::get_display() const
|
||||
{
|
||||
const Display* dpy = cairo_xlib_surface_get_display(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return dpy;
|
||||
}
|
||||
|
||||
Display* XlibSurface::get_display()
|
||||
{
|
||||
Display* dpy = cairo_xlib_surface_get_display(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return dpy;
|
||||
}
|
||||
|
||||
Screen* XlibSurface::get_screen()
|
||||
{
|
||||
Screen* screen = cairo_xlib_surface_get_screen(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return screen;
|
||||
}
|
||||
|
||||
const Screen* XlibSurface::get_screen() const
|
||||
{
|
||||
const Screen* screen = cairo_xlib_surface_get_screen(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return screen;
|
||||
}
|
||||
|
||||
Visual* XlibSurface::get_visual()
|
||||
{
|
||||
Visual* visual = cairo_xlib_surface_get_visual(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return visual;
|
||||
}
|
||||
|
||||
const Visual* XlibSurface::get_visual() const
|
||||
{
|
||||
const Visual* visual = cairo_xlib_surface_get_visual(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return visual;
|
||||
}
|
||||
|
||||
int XlibSurface::get_depth() const
|
||||
{
|
||||
int depth = cairo_xlib_surface_get_depth(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return depth;
|
||||
}
|
||||
|
||||
int XlibSurface::get_height() const
|
||||
{
|
||||
int h = cairo_xlib_surface_get_height(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return h;
|
||||
}
|
||||
|
||||
int XlibSurface::get_width() const
|
||||
{
|
||||
int w = cairo_xlib_surface_get_width(m_cobject);
|
||||
check_object_status_and_throw_exception(*this);
|
||||
return w;
|
||||
}
|
||||
|
||||
#endif // CAIRO_HAS_XLIB_SURFACE
|
||||
|
||||
} //namespace Cairo
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
148
libs/cairomm/cairomm/xlib_surface.h
Normal file
148
libs/cairomm/cairomm/xlib_surface.h
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/* Copyright (C) 2005 The cairomm Development Team
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAIROMM_XLIB_SURFACE_H
|
||||
#define __CAIROMM_XLIB_SURFACE_H
|
||||
|
||||
#include <cairomm/surface.h>
|
||||
|
||||
// This header is not included by cairomm.h because it requires X headers that
|
||||
// tend to pollute the namespace with non-prefixed #defines and typedefs.
|
||||
// You may include it directly if you need to use this API.
|
||||
|
||||
#ifdef CAIRO_HAS_XLIB_SURFACE
|
||||
#include <cairo-xlib.h> //Needed for the X11 "Display" struct (which pollutes the namespace because it has no prefix.)
|
||||
#endif
|
||||
|
||||
|
||||
namespace Cairo
|
||||
{
|
||||
|
||||
#ifdef CAIRO_HAS_XLIB_SURFACE
|
||||
|
||||
/** An XlibSurface provides a way to render to the X Window System using XLib.
|
||||
* If you want to draw to the screen within an application that uses the X
|
||||
* Window system, you should use this Surface type.
|
||||
*
|
||||
* @note For this surface to be availabe, cairo must have been compiled with
|
||||
* support for XLib Surfaces
|
||||
*/
|
||||
class XlibSurface : public Surface
|
||||
{
|
||||
public:
|
||||
|
||||
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
||||
* given to a RefPtr.
|
||||
*
|
||||
* @param cobject The C instance.
|
||||
* @param has_reference whether we already have a reference. Otherwise, the
|
||||
* constructor will take an extra reference.
|
||||
*/
|
||||
explicit XlibSurface(cairo_surface_t* cobject, bool has_reference = false);
|
||||
virtual ~XlibSurface();
|
||||
|
||||
/** Creates an Xlib surface that draws to the given drawable. The way that
|
||||
* colors are represented in the drawable is specified by the provided
|
||||
* visual.
|
||||
*
|
||||
* @note If drawable is a Window, then the function
|
||||
* cairo_xlib_surface_set_size must be called whenever the size of the window
|
||||
* changes.
|
||||
*
|
||||
* @param dpy an X Display
|
||||
* @param drawable an X Drawable, (a Pixmap or a Window)
|
||||
* @param visual the visual to use for drawing to drawable. The depth of the visual must match the depth of the drawable. Currently, only TrueColor visuals are fully supported.
|
||||
* @param width the current width of drawable.
|
||||
* @param height the current height of drawable.
|
||||
* @return A RefPtr to the newly created surface
|
||||
*/
|
||||
static RefPtr<XlibSurface> create(Display* dpy, Drawable drawable, Visual* visual, int width, int height);
|
||||
|
||||
/** Creates an Xlib surface that draws to the given bitmap. This will be
|
||||
* drawn to as a CAIRO_FORMAT_A1 object.
|
||||
*
|
||||
* @param dpy an X Display
|
||||
* @param bitmap an X Drawable, (a depth-1 Pixmap)
|
||||
* @param screen the X Screen associated with bitmap
|
||||
* @param width the current width of bitmap.
|
||||
* @param height the current height of bitmap.
|
||||
* @return A RefPtr to the newly created surface
|
||||
*/
|
||||
static RefPtr<XlibSurface> create(Display *dpy, Pixmap bitmap, Screen *screen, int width, int height);
|
||||
|
||||
/** Informs cairo of the new size of the X Drawable underlying the surface.
|
||||
* For a surface created for a Window (rather than a Pixmap), this function
|
||||
* must be called each time the size of the window changes. (For a subwindow,
|
||||
* you are normally resizing the window yourself, but for a toplevel window,
|
||||
* it is necessary to listen for ConfigureNotify events.)
|
||||
*
|
||||
* A Pixmap can never change size, so it is never necessary to call this
|
||||
* function on a surface created for a Pixmap.
|
||||
*
|
||||
* @param width the new width of the surface
|
||||
* @param height the new height of the surface
|
||||
*/
|
||||
void set_size(int width, int height);
|
||||
|
||||
/** Informs cairo of a new X Drawable underlying the surface. The drawable
|
||||
* must match the display, screen and format of the existing drawable or the
|
||||
* application will get X protocol errors and will probably terminate. No
|
||||
* checks are done by this function to ensure this compatibility.
|
||||
*
|
||||
* @param drawable the new drawable for the surface
|
||||
* @param width the width of the new drawable
|
||||
* @param height the height of the new drawable
|
||||
*/
|
||||
void set_drawable(Drawable drawable, int width, int height);
|
||||
|
||||
/** gets the Drawable object associated with this surface */
|
||||
Drawable get_drawable() const;
|
||||
|
||||
/** Get the X Display for the underlying X Drawable. */
|
||||
const Display* get_display() const;
|
||||
/** Get the X Display for the underlying X Drawable. */
|
||||
Display* get_display();
|
||||
|
||||
/** Get the X Screen for the underlying X Drawable */
|
||||
Screen* get_screen();
|
||||
/** Get the X Screen for the underlying X Drawable */
|
||||
const Screen* get_screen() const;
|
||||
|
||||
/** Get the X Visual for the underlying X Drawable */
|
||||
Visual* get_visual();
|
||||
/** Get the X Visual for the underlying X Drawable */
|
||||
const Visual* get_visual() const;
|
||||
|
||||
/** Get the number of bits used to represent each pixel value. */
|
||||
int get_depth() const;
|
||||
|
||||
/** Get the height in pixels of the X Drawable underlying the surface */
|
||||
int get_height() const;
|
||||
|
||||
/** Get the width in pixels of the X Drawable underlying the surface */
|
||||
int get_width() const;
|
||||
|
||||
};
|
||||
|
||||
#endif // CAIRO_HAS_XLIB_SURFACE
|
||||
|
||||
} // namespace Cairo
|
||||
|
||||
#endif //__CAIROMM_XLIB_SURFACE_H
|
||||
|
||||
// vim: ts=2 sw=2 et
|
||||
Loading…
Add table
Add a link
Reference in a new issue