[cairo-commit] cairo-demo/cairo-in-motion AUTHORS, NONE, 1.1 BUGS, NONE, 1.1 COPYING, NONE, 1.1 ChangeLog, NONE, 1.1 INSTALL, NONE, 1.1 Makefile, NONE, 1.1 NEWS, NONE, 1.1 README, NONE, 1.1 TODO, NONE, 1.1 cairo-in-motion.glade, NONE, 1.1 cairo-in-motion.png, NONE, 1.1 cairo-samples.cpp, NONE, 1.1 cairo-samples.h, NONE, 1.1 cairo_logo.svg, NONE, 1.1 freedesktop.svg, NONE, 1.1 gotroot.png, NONE, 1.1 home.svg, NONE, 1.1 main.cpp, NONE, 1.1 sample-list-store.cpp, NONE, 1.1 sample-list-store.h, NONE, 1.1

Mirco Müller commit at pdx.freedesktop.org
Fri Sep 30 03:04:13 PDT 2005


Committed by: macslow

Update of /cvs/cairo/cairo-demo/cairo-in-motion
In directory gabe:/tmp/cvs-serv23778/cairo-in-motion

Added Files:
	AUTHORS BUGS COPYING ChangeLog INSTALL Makefile NEWS README 
	TODO cairo-in-motion.glade cairo-in-motion.png 
	cairo-samples.cpp cairo-samples.h cairo_logo.svg 
	freedesktop.svg gotroot.png home.svg main.cpp 
	sample-list-store.cpp sample-list-store.h 
Log Message:
a little learning toy usable for testing out code-smidgens of cairo-effects


--- NEW FILE: AUTHORS ---
Mirco "MacSlow" Mueller <macslow at bangang.de>
--- NEW FILE: BUGS ---
main.cpp: on_font_set() doesn't handle all font-attributes (slant, weight)
that can be found under the sun, it's just a quick hack to get some font-
-attributes over to CairoSamples

main.cpp: I don't know how to initially highlight/select the first (or just any)
row in the samples-TreeView

dragging of the handle-points isn't implemented yet

yes, I know it's currently slow as hell

--- NEW FILE: COPYING ---
GNU GENERAL PUBLIC LICENSE Version 2, June 1991

Copyright (C) 1989, 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.

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, 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 software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, 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 redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
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 give any other recipients of the Program a copy of this License
along with the Program.

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 Program or any portion
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) 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; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, 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 executable.  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.

If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.

  5. 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 Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program 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.

  7. 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 Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program 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 Program.

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.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program 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.

  9. The Free Software Foundation may publish revised and/or new versions
of the 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 Program
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 Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, 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

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
--- NEW FILE: ChangeLog ---
2005-09-30 Mirco Mueller <macslow at bangang.de>

	Made the initial release on my blog at http://macslow.mine.nu and checked
	it in at cvs.cairographics.org (/cvs/cairo/cairo-demo/cairo-in-motion)
--- NEW FILE: INSTALL ---
There is no "install" make-target. Just compile it with "make" and run it from
its directory.
--- NEW FILE: Makefile ---
APP=cairo-in-motion
CC=c++

CFLAGS= -Wall -Os `pkg-config --cflags libsvg-cairo gtkmm-2.4 libglademm-2.4`

LDFLAGS=	`pkg-config --libs libsvg-cairo gtkmm-2.4 libglademm-2.4`

SRC = main.cpp \
	  cairo-samples.cpp \
	  sample-list-store.cpp

OBJ = $(SRC:.cpp=.o)

all: $(APP)

$(APP):  $(OBJ)
	$(CC) $(LDFLAGS) $(OBJ) -o $(APP)
	strip $(APP)

.cpp.o:
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -f $(OBJ) *~ $(APP)


--- NEW FILE: NEWS ---

--- NEW FILE: README ---
General Information:

	"cairo in motion" came to life because I wanted to learn about cairo in the
first place. Furhtermore I wanted to give it a handy/simple UI so people
(including me) can toy around with some of cairo's attributes and settings
without messing around in the code, recompile it, test it out and so on. For
this I also sticked my nose a bit into libglademm/gtkmm.

	There are three main areas in "cairo in motion". On the top-left you can
change certain attributes which are taken into account by the cairo-sample
displayed in the drawing-area on the right. Not every attribute is used by some
examples though. On the bottom-left you have a list-view with all cairo-samples
compiled into "cairo in motion". I regarded making them run-time loadable as a
bit of an overkill for such a simple testbed. The same goes for the attributes.
They aren't dynamic. One could make these two things fully dynamic of course.
Maybe I'll do that some day when I'm too bored. You can trigger the display of
one of the cairo-samples by either double-clicking with the LMB on its entry in
the list view or highlight the entry with the cursor-keys and hit RETURN to
start it. Finally there's the drawing-area on the right side. If you see
"handles" (small red spots with a black outline) in the drawing-area, you can
drag these around with the mouse (LMB-drag). Your dragging with the mouse
overrides any animation that may take place. The rest (menubar) is
selfexplanatory (I hope :)

About The Code:

	main.cpp isn't that intersting and also not very elegant I admit. The main
interest is in the cairo-*.cpp/h files. I grabbed a good bit of code from the
"cairo snippets" found at:

	http://cairographics.org/samples/snippets.html

	In addition to that I altered some of those examples in order to have them
behave in an interactive manner and also added snippets of my own.

Library Requirements:

	cairo 1.1.1 (grabbed as HEAD from cairographics.org-CVS)
	libsvg 0.1.4 (grabbed as HEAD from cairographics.org-CVS)
	libsvg-cairo 0.1.6 (grabbed as HEAD from cairographics.org-CVS)
	gtk+ 2.8.3
	gtkmm 2.8.0
	libglade 2.5.1
	libglademm 2.6.1

Other Stuff I Used:

	g++ 4.0.0
	Eclipse 3.1 (with CDT 3.0)
	Fedora Core 4

If you have any questions, don't hesitate to drop me a line via eMail. And
please fix my BUGS ;-)

Share and enjoy!

Best regards...

MacSlow
--- NEW FILE: TODO ---
support for glitz-surfaces would be nice, so one can switch between "normal" and
glitz-surfaces at runtime to see the impact on performance

fps-couter

class CairoSamples should be a bit more sophisticated in dealing with the
function-pointers to all the included samples, this would also make do_sample()
a lot leaner

doing a fully dynamic (runtime-) loading of the samples would be the ultimate
goal, thus also ghosting (or hiding) those controlling widgets that don't affect
a particular sample

more cool-looking animated samples

--- NEW FILE: cairo-in-motion.glade ---
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkWindow" id="mainWindow">
  <property name="visible">True</property>
  <property name="title" translatable="yes">cairo in motion</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="icon_name"></property>
  <property name="decorated">True</property>
  <property name="skip_taskbar_hint">False</property>
  <property name="skip_pager_hint">False</property>
  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
[...1148 lines suppressed...]
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.</property>
  <property name="website">http://macslow.mine.nu</property>
  <property name="website_label" translatable="yes">http://maclsow.mine.nu</property>
  <property name="authors">Mirco &quot;MacSlow&quot; Mueller &lt;macslow at bangang.de&gt;</property>
  <property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with your names, one name per line.">translator-credits</property>
  <property name="logo">cairo-in-motion.png</property>
</widget>

</glade-interface>

--- NEW FILE: cairo-in-motion.png ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: cairo-samples.cpp ---
// "cairo in motion" is a testbed for animated vector-drawing
// using cairo within a gtk+-environment
//
// Copyright (C) 2005 Mirco Mueller <macslow at bangang.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

[...2002 lines suppressed...]
{
	if (!m_pCairoContext)
		return false;

	draw_background ();

	cairo_move_to (m_pCairoContext, 0.3f, 0.3f);
	cairo_line_to (m_pCairoContext, 0.7f, 0.3f);

	cairo_line_to (m_pCairoContext, 0.5f, 0.3f);
	cairo_line_to (m_pCairoContext, 0.5f, 0.7f);

	cairo_set_line_width (m_pCairoContext, m_fLineWidth);
	cairo_set_line_cap  (m_pCairoContext, m_cairoCapStyle);
	cairo_set_line_join  (m_pCairoContext, m_cairoJoinStyle);
	cairo_set_source_rgb (m_pCairoContext, 0.0f, 0.0f, 0.0f);
	cairo_stroke (m_pCairoContext);
       
	return true;
}

--- NEW FILE: cairo-samples.h ---
// "cairo in motion" is a testbed for animated vector-drawing
// using cairo within a gtk+-environment
//
// Copyright (C) 2005 Mirco Mueller <macslow at bangang.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#ifndef _CAIROSAMPLES_H_
#define _CAIROSAMPLES_H_

#include <cairo.h>
#include <string>
#include <gdkmm.h>

#include "sample-list-store.h"

typedef struct _HandlePoint
{
	double x;
	double y;
} HandlePoint;

class CairoSamples
{
	public:
		CairoSamples ();
		~CairoSamples ();

		typedef struct _Entry
		{
			std::string	name;
		} Entry;

		enum Sample
		{
			CurveRectangle = 0,
			FillAndStroke,
			FillAndStroke2,
			Fontmania,
			Gradient,
			Image,
			ImagePattern,
			LibSVG,
			MovingArc,
			MovingArcNegative,
			MovingCairoLogo,
			MovingClip,
			MovingClipImage,
			MovingCurveTo,
			MovingGradient,
			MovingGradient2,
			OperatorAdd,
			OperatorAtop,
			OperatorAtopReverse,
			OperatorIn,
			OperatorInReverse,
			OperatorOut,
			OperatorOutReverse,
			OperatorOver,
			OperatorOverReverse,
			OperatorSaturate,
			OperatorXor,
			Path,
			PatternFill,
			SetLineCap,
			SetLineJoin,
			TextAlignCenter,
			Text,
			TextExtents,
			XxxClipRectangle,
			XxxDash,
			XxxLongLines,
			XxxMultiSegmentCaps,
			XxxSelfIntersect,
			NumberOfSamples
		};

		enum DashStyle
		{
			DashOff = 0,
			Dotted,
			Dashed,
			DashDotDash,
			DashedFunky
		};

		void do_animation_step ();
		void set_context (cairo_t* pCairoContext);
		void normalize_canvas (double fWidth, double fHeight) const;
		void set_bg_svg (std::string strSVGFileName) const;
		bool do_sample (Sample sample) const;
		void set_cap_style (cairo_line_cap_t cairoCapStyle);
		void set_join_style (cairo_line_join_t cairoJoinStyle);
		void set_dash_style (DashStyle dashStyle);
		void set_operator (cairo_operator_t cairoOperator);
		void set_extend_mode (cairo_extend_t cairoExtendMode);
		void set_filter_mode (cairo_filter_t cairoFilterMode);
		void set_line_width (double fLineWidth);
		void set_bg_color (Gdk::Color bgColor);
		void set_font_family (std::string strFontFamily);
		void set_font_size (double fFontSize);
		void set_font_weight (cairo_font_weight_t cairoFontWeight);
		void set_font_slant (cairo_font_slant_t cairoFontSlant);
		void set_some_text (std::string strSomeText);
		void set_image_file_name (std::string strFileName);
		void set_svg_file_name (std::string strFileName);
		void add_samples_to_list_store (SampleListStore* pSampleListStore);
		std::string get_sample_name (Sample sample) const;

	private:
		void update_var (double* pfValue,
						 double fLowerLimit,
						 double fUpperLimit,
						 double* pfStep,
						 double fGrow,
						 double fShrink);
		HandlePoint get_center () const;
		HandlePoint get_point1 () const;
		HandlePoint get_point2 () const;
		HandlePoint get_point3 () const;
		HandlePoint get_point4 () const;
		double get_radius () const;
		double get_angle_1 () const;
		double get_angle_2 () const;
		void draw_background () const;
		void draw_background (Gdk::Color color) const;
		void draw_handle (double fX, double fY) const;
		void draw_handle (HandlePoint* pPoint) const;
		bool sample_not_found () const;
		bool curve_rectangle () const;
		bool fill_and_stroke () const;
		bool fill_and_stroke2 () const;
		bool fontmania () const;
		bool gradient () const;
		bool image () const;
		bool image_pattern () const;
		bool libsvg () const;
		bool moving_arc () const;
		bool moving_arc_negative () const;
		bool moving_cairo_logo () const;
		bool moving_clip () const;
		bool moving_clip_image () const;
		bool moving_curve_to () const;
		bool moving_gradient () const;
		bool moving_gradient2 () const;
		bool operator_add () const;
		bool operator_atop () const;
		bool operator_atop_reverse () const;
		bool operator_in () const;
		bool operator_in_reverse () const;
		bool operator_out () const;
		bool operator_out_reverse () const;
		bool operator_over () const;
		bool operator_over_reverse () const;
		bool operator_saturate () const;
		bool operator_xor () const;
		bool path () const;
		bool pattern_fill () const;
		bool set_line_cap () const;
		bool set_line_join () const;
		bool text_align_center () const;
		bool text () const;
		bool text_extents () const;
		bool xxx_clip_rectangle () const;
		bool xxx_dash () const;
		bool xxx_long_lines () const;
		bool xxx_multi_segment_caps () const;
		bool xxx_self_intersect () const;

	protected:
		HandlePoint			m_center;
		HandlePoint			m_point1;
		HandlePoint			m_point2;
		HandlePoint			m_point3;
		HandlePoint			m_point4;
		double				m_fRadius;
		double				m_fAngle1;
		double				m_fAngle2;
		double				m_centerXStep;
		double				m_centerYStep;
		double				m_point1XStep;
		double				m_point1YStep;
		double				m_point2XStep;
		double				m_point2YStep;
		double				m_point3XStep;
		double				m_point3YStep;
		double				m_point4XStep;
		double				m_point4YStep;
		double				m_fRadiusStep;
		double				m_fAngle1Step;
		double				m_fAngle2Step;
		cairo_t*			m_pCairoContext;
		cairo_line_cap_t	m_cairoCapStyle;
		cairo_line_join_t	m_cairoJoinStyle;
		DashStyle			m_dashStyle;
		cairo_operator_t	m_cairoOperator;
		cairo_extend_t		m_cairoExtendMode;
		cairo_filter_t		m_cairoFilterMode;
		double				m_fLineWidth;
		Gdk::Color			m_bgColor;
		std::string			m_strFontFamily;
		double				m_fFontSize;
		cairo_font_weight_t	m_cairoFontWeight;
		cairo_font_slant_t	m_cairoFontSlant;
		std::string			m_strSomeText;
		std::string			m_strImageFileName;
		std::string			m_strSvgFileName;
		std::vector<Entry>	m_sampleList;
};

#endif /*_CAIROSAMPLES_H_*/

--- NEW FILE: cairo_logo.svg ---
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.0"
   x="0.0000000"
   y="0.0000000"
   width="310.00000"
   height="410.00000"
   id="svg1498">
  <defs
     id="cairo-artwork_defs">
    <g
       id="hacker_emblem">
      <g
         style="fill:#ffffff;stroke:none"
         id="hacker_emblem_grid">
        <rect
           width="6.0000000"
           height="0.10000000"
           x="-2.9500000"
           y="-3.0500000"
           id="rect1503" />
        <rect
           width="0.10000000"
           height="6.0000000"
           x="2.9500000"
           y="-2.9500000"
           id="rect1505" />
        <rect
           width="6.0000000"
           height="0.10000000"
           x="-3.0500000"
           y="2.9500000"
           id="rect1507" />
        <rect
           width="0.10000000"
           height="6.0000000"
           x="-3.0500000"
           y="-3.0500000"
           id="rect1509" />
        <rect
           width="0.10000000"
           height="5.9000001"
           x="-1.0500000"
           y="-2.9500000"
           id="rect1511" />
        <rect
           width="0.10000000"
           height="5.9000001"
           x="0.94999999"
           y="-2.9500000"
           id="rect1513" />
        <rect
           width="1.9000000"
           height="0.10000000"
           x="-2.9500000"
           y="-1.0500000"
           id="rect1515" />
        <rect
           width="1.9000000"
           height="0.10000000"
           x="-0.94999999"
           y="-1.0500000"
           id="rect1517" />
        <rect
           width="1.9000000"
           height="0.10000000"
           x="1.0500000"
           y="-1.0500000"
           id="rect1519" />
        <rect
           width="1.9000000"
           height="0.10000000"
           x="-2.9500000"
           y="0.94999999"
           id="rect1521" />
        <rect
           width="1.9000000"
           height="0.10000000"
           x="-0.94999999"
           y="0.94999999"
           id="rect1523" />
        <rect
           width="1.9000000"
           height="0.10000000"
           x="1.0500000"
           y="0.94999999"
           id="rect1525" />
      </g>
      <g
         style="fill:#ffffff"
         id="hacker_emblem_dots">
        <circle
           cx="0.0000000"
           cy="-2.0000000"
           r="0.69999999"
           id="circle1528" />
        <circle
           cx="2.0000000"
           cy="0.0000000"
           r="0.69999999"
           id="circle1530" />
        <circle
           cx="-2.0000000"
           cy="2.0000000"
           r="0.69999999"
           id="circle1532" />
        <circle
           cx="0.0000000"
           cy="2.0000000"
           r="0.69999999"
           id="circle1534" />
        <circle
           cx="2.0000000"
           cy="2.0000000"
           r="0.69999999"
           id="circle1536" />
      </g>
    </g>
    <g
       style="fill:#3b80ae"
       id="scarab">
      <g
         transform="translate(-150.0000,-170.0000)"
         id="g1539">
        <path
           d="M 205.59900,94.567000 C 205.59900,82.899000 180.68500,73.438000 149.97100,73.438000 C 119.24800,73.438000 94.347000,82.898000 94.347000,94.567000 C 94.347000,104.77000 119.24800,101.91300 149.97100,101.91300 C 180.68500,101.91300 205.59900,104.23300 205.59900,94.567000 z "
           id="scarab_head" />
        <path
           d="M 136.42300,161.50600 C 136.42300,161.50600 149.17400,174.08300 149.97000,174.86800 C 152.23200,172.63600 163.51500,161.50600 163.51500,161.50600 C 170.65000,154.47000 250.62600,155.10700 254.58100,155.14300 C 254.11200,148.84500 253.32700,142.67100 252.25600,136.62400 C 237.07300,117.34500 209.44500,104.39900 177.77100,104.39900 L 122.25300,104.39900 C 90.508000,104.39900 62.814000,117.41000 47.655000,136.76900 C 46.601000,142.76900 45.826000,148.89700 45.359000,155.14300 C 49.321000,155.10600 129.28800,154.47000 136.42300,161.50600 z "
           id="scarab_torso" />
        <path
           d="M 149.97000,301.18700 C 151.97500,276.45800 158.35600,197.70400 158.37500,197.46600 C 158.28500,197.24700 151.89700,181.88800 149.97000,177.25200 C 148.03400,181.90700 141.65400,197.24700 141.56200,197.46600 C 141.58200,197.70400 147.96500,276.45800 149.97000,301.18700 z "
           id="scarab_spine" />
        <path
           d="M 140.40300,197.14900 L 149.26500,175.83900 L 135.57900,162.34000 C 129.92900,156.76700 68.505000,156.10500 45.320000,156.32100 L 45.314000,155.69900 C 45.160000,157.84300 45.043000,160.00100 44.964000,162.17400 C 44.888000,164.38100 55.356000,166.88000 55.356000,168.89100 C 55.356000,171.21000 44.899000,173.97500 44.997000,176.52200 C 47.990000,249.87100 93.527000,308.15300 149.36900,308.57000 L 140.34900,197.28000 L 140.40300,197.14900 z "
           id="scarab_wing_left" />
        <path
           d="M 244.58500,168.89100 C 244.58500,166.88000 255.05200,164.38500 254.97600,162.17600 C 254.89700,160.00200 254.78100,157.84400 254.62500,155.69700 L 254.62100,156.32100 C 231.43500,156.10500 170.01300,156.76600 164.36100,162.33800 L 150.67300,175.84000 L 159.58800,197.27800 L 150.57100,308.56800 C 206.42500,308.15100 251.94900,249.87000 254.94400,176.51900 C 255.04000,173.97600 244.58500,171.20900 244.58500,168.89100 z "
           id="scarab_wing_right" />
        <path
           d="M 44.506000,141.12000 C 40.371000,140.26400 39.611000,139.58000 36.571000,138.20000 C 26.981000,134.83600 26.195000,132.71900 20.491000,126.34000 C 13.065000,118.03400 7.8300000,106.19800 3.3910000,96.877000 C -0.18500000,89.352000 -0.59300000,80.468000 0.53100000,72.604000 C 1.5220000,65.669000 7.6750000,59.735000 12.605000,53.684000 C 18.449000,46.493000 22.961000,38.862000 30.529000,32.330000 C 38.265000,25.648000 53.732000,22.521000 56.697000,12.682000 C 57.860000,8.8190000 54.334000,1.7660000 61.482000,0.0000000 C 61.116000,4.7030000 65.121000,8.4770000 63.879000,13.575000 C 62.750000,18.202000 59.511000,19.386000 54.268000,22.674000 C 46.704000,27.420000 35.902000,31.453000 29.520000,36.639000 C 22.345000,42.466000 25.151000,50.410000 18.951000,56.696000 C 16.950000,58.726000 11.050000,61.402000 9.8140000,63.526000 C 7.9530000,66.725000 9.5170000,73.098000 9.6980000,76.646000 C 10.123000,84.930000 15.286000,90.890000 19.253000,98.691000 C 23.405000,106.83200 25.682000,114.10000 32.664000,121.21000 C 36.847000,125.47200 44.093000,126.01200 48.874000,131.85700 L 45.319000,136.04300 L 44.506000,141.12000 z "
           id="scarab_leg_front_left" />
        <path
           d="M 43.940000,191.92200 L 43.131000,184.57600 C 33.625000,179.99700 32.792000,174.80400 22.393000,172.11000 C -1.3350000,165.95900 1.0320000,183.36000 6.8610000,198.48300 C 12.537000,213.20900 15.098000,228.71300 21.206000,243.27800 C 24.011000,249.96600 28.125000,256.49100 35.504000,258.40500 C 35.876000,249.97000 34.587000,247.75400 29.391000,241.48600 C 24.996000,236.19300 26.065000,228.93800 23.319000,222.98200 C 19.738000,215.17800 19.123000,207.33600 16.040000,199.48000 C 14.677000,196.00100 7.7100000,185.51400 9.5880000,181.61900 C 12.771000,175.01600 18.766000,181.53600 21.767000,183.69600 C 25.985000,186.73200 28.234000,185.91900 33.448000,186.59400 C 34.041000,186.67300 37.005000,188.75600 43.940000,191.92200 z "
           id="scarab_leg_middle_left" />
        <path
           d="M 65.839000,257.06300 L 63.068000,252.22600 C 56.388000,261.15400 56.075000,268.45400 53.012000,275.57300 C 47.735000,287.83600 52.855000,304.42400 62.866000,313.24900 C 68.918000,318.62400 78.773000,322.86700 85.988000,326.38500 C 96.023000,331.27700 106.10100,337.67100 117.32400,339.78100 C 119.80600,340.24700 126.12200,341.07600 124.01700,336.25900 C 123.04200,334.02200 115.92600,331.66800 113.87100,330.52500 C 105.55900,325.90200 97.494000,320.00100 89.729000,314.34900 C 80.231000,307.48700 68.886000,303.16300 61.418000,293.66500 C 58.364000,289.78000 57.874000,288.74300 58.602000,284.27500 C 59.295000,280.01200 59.946000,275.10100 60.843000,270.83600 C 61.855000,266.02900 63.274000,261.37800 65.839000,257.06300 z "
           id="scarab_leg_back_left" />
        <path
           d="M 255.48700,141.12000 C 259.62100,140.26400 260.38300,139.58000 263.42300,138.20000 C 273.00600,134.83600 273.79200,132.71900 279.49400,126.34000 C 286.92200,118.03400 292.15500,106.19800 296.60900,96.877000 C 300.18300,89.352000 300.59200,80.468000 299.46900,72.604000 C 298.47700,65.669000 292.31200,59.735000 287.38200,53.684000 C 281.53900,46.493000 277.02600,38.862000 269.46300,32.330000 C 261.72800,25.648000 246.26100,22.521000 243.29600,12.682000 C 242.13500,8.8190000 245.66000,1.7660000 238.51100,0.0000000 C 238.87700,4.7030000 234.87400,8.4770000 236.11500,13.575000 C 237.24600,18.202000 240.48300,19.386000 245.72600,22.674000 C 253.28900,27.420000 264.09300,31.453000 270.47300,36.639000 C 277.64300,42.466000 274.83500,50.410000 281.03600,56.696000 C 283.03700,58.726000 288.93700,61.402000 290.17500,63.526000 C 292.03400,66.725000 290.47000,73.098000 290.28800,76.646000 C 289.86400,84.930000 284.70000,90.890000 280.73500,98.691000 C 276.58300,106.83200 274.30400,114.10000 267.33100,121.21000 C 263.14700,125.47200 255.90200,126.01200 251.12000,131.85700 L 254.67600,136.04300 L 255.48700,141.12000 z "
           id="scarab_leg_front_right" />
        <path
           d="M 256.05300,191.92200 L 256.86300,184.57600 C 266.37000,179.99700 267.20300,174.80400 277.59300,172.11000 C 301.33400,165.95900 298.96700,183.36000 293.12700,198.48300 C 287.45100,213.20900 284.88900,228.71300 278.78000,243.27800 C 275.97600,249.96600 271.86900,256.49100 264.48900,258.40500 C 264.11800,249.97000 265.40700,247.75400 270.60200,241.48600 C 274.99200,236.19300 273.92100,228.93800 276.66800,222.98200 C 280.24800,215.17800 280.86500,207.33600 283.94600,199.48000 C 285.30900,196.00100 292.27600,185.51400 290.39900,181.61900 C 287.21500,175.01600 281.22000,181.53600 278.21800,183.69600 C 274.00100,186.73200 271.76000,185.91900 266.54600,186.59400 C 265.95100,186.67300 262.98600,188.75600 256.05300,191.92200 z "
           id="scarab_leg_middle_right" />
        <path
           d="M 234.15500,257.06300 L 236.92600,252.22600 C 243.60500,261.15400 243.91700,268.45400 246.98300,275.57300 C 252.25700,287.83600 247.13700,304.42400 237.12900,313.24900 C 231.07400,318.62400 221.22600,322.86700 214.01200,326.38500 C 203.97800,331.27700 193.88500,337.67100 182.66100,339.78100 C 180.18000,340.24700 173.87200,341.07600 175.97000,336.25900 C 176.94600,334.02200 184.06200,331.66800 186.11600,330.52500 C 194.42800,325.90200 202.50800,320.00100 210.27100,314.34900 C 219.76900,307.48700 231.10900,303.16300 238.57600,293.66500 C 241.63100,289.78000 242.11900,288.74300 241.39400,284.27500 C 240.69800,280.01200 240.04800,275.10100 239.15000,270.83600 C 238.13700,266.02900 236.71800,261.37800 234.15500,257.06300 z "
           id="scarab_leg_back_right" />
      </g>
    </g>
    <radialGradient
       cx="0.0000000"
       cy="0.0000000"
       r="60.000000"
       fx="0.0000000"
       fy="0.0000000"
       id="gradient_radial_dung"
       gradientUnits="userSpaceOnUse">
      <stop
         style="stop-color:#9a9a9a;stop-opacity:1.0000000"
         offset="0.0000000"
         id="stop1553" />
      <stop
         style="stop-color:#bababa;stop-opacity:1.0000000"
         offset="0.69999999"
         id="stop1555" />
      <stop
         style="stop-color:#ffffff;stop-opacity:1.0000000"
         offset="0.94999999"
         id="stop1557" />
    </radialGradient>
    <g
       id="dung">
      <circle
         cx="0.0000000"
         cy="0.0000000"
         r="60.000000"
         style="fill:url(#gradient_radial_dung)"
         id="circle1560" />
      <g
         transform="translate(-61.00000,-61.00000)"
         id="g1562">
        <path
           d="M 0.0000000,61.000000 C 0.0000000,94.636000 27.364000,122.00000 61.000000,122.00000 C 94.636000,122.00000 122.00000,94.636000 122.00000,61.000000 C 122.00000,27.364000 94.636000,0.0000000 61.000000,0.0000000 C 27.364000,0.0000000 0.0000000,27.364000 0.0000000,61.000000 z M 2.0000000,61.000000 C 2.0000000,28.467000 28.467000,2.0000000 61.000000,2.0000000 C 93.532000,2.0000000 120.00000,28.467000 120.00000,61.000000 C 120.00000,93.533000 93.532000,120.00000 61.000000,120.00000 C 28.467000,120.00000 2.0000000,93.533000 2.0000000,61.000000 z "
           style="fill:#8a8a8a"
           id="path1564" />
      </g>
      <use
         transform="scale(9.000000,9.000000)"
         id="use1566"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#hacker_emblem" />
    </g>
    <g
       id="cairo_logo">
      <use
         transform="translate(0.000000,-140.0000)"
         id="use1569"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(0.000000,30.00000)"
         id="use1571"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_dung-centered">
      <use
         id="use1574"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(0.000000,170.0000)"
         id="use1576"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_scarab-centered">
      <use
         transform="translate(0.000000,-175.8500)"
         id="use1579"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(0.000000,-5.850000)"
         id="use1581"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_top-centered">
      <use
         transform="translate(0.000000,60.00000)"
         id="use1584"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(0.000000,230.0000)"
         id="use1586"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_bottom-centered">
      <use
         transform="translate(0.000000,-340.0000)"
         id="use1589"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(0.000000,-170.0000)"
         id="use1591"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_right-centered">
      <use
         transform="translate(-150.0000,-140.0000)"
         id="use1594"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(-150.0000,30.00000)"
         id="use1596"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_left-centered">
      <use
         transform="translate(150.0000,-140.0000)"
         id="use1599"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(150.0000,30.00000)"
         id="use1601"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_topleft-centered">
      <use
         transform="translate(150.0000,60.00000)"
         id="use1604"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(150.0000,230.0000)"
         id="use1606"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_topright-centered">
      <use
         transform="translate(-150.0000,60.00000)"
         id="use1609"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(-150.0000,230.0000)"
         id="use1611"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_bottomleft-centered">
      <use
         transform="translate(150.0000,-340.0000)"
         id="use1614"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(150.0000,-170.0000)"
         id="use1616"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       id="cairo_logo_bottomright-centered">
      <use
         transform="translate(-150.0000,-340.0000)"
         id="use1619"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#dung" />
      <use
         transform="translate(-150.0000,-170.0000)"
         id="use1621"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#scarab" />
    </g>
    <g
       transform="translate(0.000000,-97.00000)"
       id="cairo_text">
      <g
         transform="scale(0.148400,0.148400)"
         id="g1624">
        <g
           transform="translate(-1139.000,-208.5000)"
           id="g1626">
          <path
             d="M 412.00000,433.00000 C 385.00000,422.00000 336.00000,413.00000 298.00000,413.00000 C 142.00000,413.00000 38.000000,525.00000 38.000000,680.00000 C 38.000000,826.00000 144.00000,947.00000 298.00000,947.00000 C 332.00000,947.00000 377.00000,944.00000 416.00000,926.00000 L 409.00000,842.00000 C 380.00000,861.00000 340.00000,871.00000 308.00000,871.00000 C 187.00000,871.00000 138.00000,771.00000 138.00000,680.00000 C 138.00000,583.00000 197.00000,489.00000 302.00000,489.00000 C 332.00000,489.00000 368.00000,496.00000 404.00000,511.00000 L 412.00000,433.00000"
             transform="translate(65.00000,0.000000)"
             id="path1628" />
          <path
             d="M 109.00000,541.00000 C 147.00000,509.00000 204.00000,489.00000 257.00000,489.00000 C 351.00000,489.00000 383.00000,534.00000 383.00000,622.00000 C 346.00000,620.00000 320.00000,620.00000 283.00000,620.00000 C 186.00000,620.00000 46.000000,660.00000 46.000000,788.00000 C 46.000000,899.00000 123.00000,947.00000 233.00000,947.00000 C 319.00000,947.00000 369.00000,900.00000 391.00000,869.00000 L 393.00000,869.00000 L 393.00000,935.00000 L 481.00000,935.00000 C 479.00000,920.00000 477.00000,893.00000 477.00000,835.00000 L 477.00000,624.00000 C 477.00000,485.00000 418.00000,413.00000 272.00000,413.00000 C 207.00000,413.00000 151.00000,433.00000 104.00000,461.00000 L 109.00000,541.00000 M 383.00000,737.00000 C 383.00000,813.00000 334.00000,871.00000 241.00000,871.00000 C 198.00000,871.00000 146.00000,842.00000 146.00000,788.00000 C 146.00000,698.00000 272.00000,690.00000 323.00000,690.00000 C 343.00000,690.00000 363.00000,692.00000 383.00000,692.00000 L 383.00000,737.00000"
             transform="translate(486.7500,0.000000)"
             id="path1630" />
          <path
             d="M 92.000000,935.00000 L 186.00000,935.00000 L 186.00000,425.00000 L 92.000000,425.00000 L 92.000000,935.00000 M 88.000000,261.00000 C 88.000000,232.83348 110.83348,210.00000 139.00000,210.00000 C 167.16652,210.00000 190.00000,232.83348 190.00000,261.00000 C 190.00000,289.16652 167.16652,312.00000 139.00000,312.00000 C 110.83348,312.00000 88.000000,289.16652 88.000000,261.00000"
             transform="translate(1000.000,0.000000)"
             id="path1632" />
          <path
             d="M 80.000000,935.00000 L 174.00000,935.00000 L 174.00000,703.00000 C 174.00000,575.00000 229.00000,495.00000 313.00000,495.00000 C 329.00000,495.00000 348.00000,497.00000 365.00000,504.00000 L 365.00000,420.00000 C 345.00000,416.00000 331.00000,413.00000 303.00000,413.00000 C 249.00000,413.00000 195.00000,451.00000 170.00000,504.00000 L 168.00000,504.00000 L 168.00000,425.00000 L 80.000000,425.00000 L 80.000000,935.00000"
             transform="translate(1234.250,0.000000)"
             id="path1634" />
          <path
             d="M 46.000000,680.00000 C 46.000000,826.00000 152.00000,947.00000 306.00000,947.00000 C 459.00000,947.00000 565.00000,826.00000 565.00000,680.00000 C 565.00000,525.00000 461.00000,413.00000 306.00000,413.00000 C 150.00000,413.00000 46.000000,525.00000 46.000000,680.00000 M 146.00000,680.00000 C 146.00000,583.00000 205.00000,489.00000 306.00000,489.00000 C 406.00000,489.00000 465.00000,583.00000 465.00000,680.00000 C 465.00000,771.00000 416.00000,871.00000 306.00000,871.00000 C 195.00000,871.00000 146.00000,771.00000 146.00000,680.00000"
             transform="translate(1610.000,0.000000)"
             id="path1636" />
        </g>
      </g>
    </g>
    <g
       transform="translate(0.000000,-71.00000)"
       id="cairo_text_small">
      <g
         transform="scale(8.500000e-2,8.500000e-2)"
         id="g1639">
        <g
           transform="translate(-1139.000,-208.5000)"
           id="g1641">
          <path
             d="M 412.00000,433.00000 C 385.00000,422.00000 336.00000,413.00000 298.00000,413.00000 C 142.00000,413.00000 38.000000,525.00000 38.000000,680.00000 C 38.000000,826.00000 144.00000,947.00000 298.00000,947.00000 C 332.00000,947.00000 377.00000,944.00000 416.00000,926.00000 L 409.00000,842.00000 C 380.00000,861.00000 340.00000,871.00000 308.00000,871.00000 C 187.00000,871.00000 138.00000,771.00000 138.00000,680.00000 C 138.00000,583.00000 197.00000,489.00000 302.00000,489.00000 C 332.00000,489.00000 368.00000,496.00000 404.00000,511.00000 L 412.00000,433.00000"
             transform="translate(-151.0000,0.000000)"
             id="path1643" />
          <path
             d="M 109.00000,541.00000 C 147.00000,509.00000 204.00000,489.00000 257.00000,489.00000 C 351.00000,489.00000 383.00000,534.00000 383.00000,622.00000 C 346.00000,620.00000 320.00000,620.00000 283.00000,620.00000 C 186.00000,620.00000 46.000000,660.00000 46.000000,788.00000 C 46.000000,899.00000 123.00000,947.00000 233.00000,947.00000 C 319.00000,947.00000 369.00000,900.00000 391.00000,869.00000 L 393.00000,869.00000 L 393.00000,935.00000 L 481.00000,935.00000 C 479.00000,920.00000 477.00000,893.00000 477.00000,835.00000 L 477.00000,624.00000 C 477.00000,485.00000 418.00000,413.00000 272.00000,413.00000 C 207.00000,413.00000 151.00000,433.00000 104.00000,461.00000 L 109.00000,541.00000 M 383.00000,737.00000 C 383.00000,813.00000 334.00000,871.00000 241.00000,871.00000 C 198.00000,871.00000 146.00000,842.00000 146.00000,788.00000 C 146.00000,698.00000 272.00000,690.00000 323.00000,690.00000 C 343.00000,690.00000 363.00000,692.00000 383.00000,692.00000 L 383.00000,737.00000"
             transform="translate(379.5000,0.000000)"
             id="path1645" />
          <path
             d="M 92.000000,935.00000 L 186.00000,935.00000 L 186.00000,425.00000 L 92.000000,425.00000 L 92.000000,935.00000 M 88.000000,261.00000 C 88.000000,232.83348 110.83348,210.00000 139.00000,210.00000 C 167.16652,210.00000 190.00000,232.83348 190.00000,261.00000 C 190.00000,289.16652 167.16652,312.00000 139.00000,312.00000 C 110.83348,312.00000 88.000000,289.16652 88.000000,261.00000"
             transform="translate(1000.000,0.000000)"
             id="path1647" />
          <path
             d="M 80.000000,935.00000 L 174.00000,935.00000 L 174.00000,703.00000 C 174.00000,575.00000 229.00000,495.00000 313.00000,495.00000 C 329.00000,495.00000 348.00000,497.00000 365.00000,504.00000 L 365.00000,420.00000 C 345.00000,416.00000 331.00000,413.00000 303.00000,413.00000 C 249.00000,413.00000 195.00000,451.00000 170.00000,504.00000 L 168.00000,504.00000 L 168.00000,425.00000 L 80.000000,425.00000 L 80.000000,935.00000"
             transform="translate(1341.500,0.000000)"
             id="path1649" />
          <path
             d="M 46.000000,680.00000 C 46.000000,826.00000 152.00000,947.00000 306.00000,947.00000 C 459.00000,947.00000 565.00000,826.00000 565.00000,680.00000 C 565.00000,525.00000 461.00000,413.00000 306.00000,413.00000 C 150.00000,413.00000 46.000000,525.00000 46.000000,680.00000 M 146.00000,680.00000 C 146.00000,583.00000 205.00000,489.00000 306.00000,489.00000 C 406.00000,489.00000 465.00000,583.00000 465.00000,680.00000 C 465.00000,771.00000 416.00000,871.00000 306.00000,871.00000 C 195.00000,871.00000 146.00000,771.00000 146.00000,680.00000"
             transform="translate(1826.000,0.000000)"
             id="path1651" />
        </g>
      </g>
    </g>
    <g
       id="cairo_logo_with_text">
      <use
         transform="translate(0.000000,-245.0000)"
         id="use1654"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#cairo_logo_top-centered" />
      <use
         transform="translate(0.000000,245.0000)"
         id="use1656"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#cairo_text" />
    </g>
    <g
       id="cairo_banner">
      <use
         id="use1659"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#cairo_logo_bottomleft-centered" />
      <use
         transform="translate(0.000000,42.00000)"
         style="fill:#000000"
         id="use1661"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#cairo_text_small" />
      <use
         id="use1663"
         x="0.0000000"
         y="0.0000000"
         width="310.00000"
         height="410.00000"
         xlink:href="#cairo_logo_bottomleft-centered" />
    </g>
  </defs>
  <g
     transform="translate(5.000000,5.000000)"
     id="g1665">
    <use
       id="use1667"
       x="0.0000000"
       y="0.0000000"
       width="310.00000"
       height="410.00000"
       xlink:href="#cairo_logo_topleft-centered" />
  </g>
</svg>

--- NEW FILE: freedesktop.svg ---
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.0"
   x="0.0000000"
   y="0.0000000"
   width="111.60000"
   height="96.112503"
   id="svg968">
  <defs
     id="defs970" />
  <g
     transform="translate(14.09647,16.85030)"
     style="fill:#ffffff;stroke:#3b80ae;stroke-width:2.4588001;"
     id="g862">
    <g
       id="g864">
      <path
         d="M 85.277000,40.796000 C 87.335000,48.680000 82.610000,56.738000 74.726000,58.795000 L 27.143000,71.210000 C 19.259000,73.267000 11.200000,68.543000 9.1430000,60.658000 L 1.6950000,32.108000 C -0.36200000,24.224000 4.3620000,16.166000 12.246000,14.109000 L 59.830000,1.6950000 C 67.714000,-0.36200000 75.772000,4.3620000 77.829000,12.246000 L 85.278000,40.796000 L 85.277000,40.796000 z "
         style="stroke:#bababa;"
         id="path866" />
      <path
         d="M 80.444000,39.778000 C 82.193000,47.632000 78.628000,53.399000 70.940000,55.225000 L 28.704000,66.245000 C 21.135000,68.641000 14.615000,65.064000 12.866000,57.409000 L 6.5300000,33.127000 C 4.7810000,24.982000 7.2390000,20.238000 16.033000,17.680000 L 58.270000,6.6610000 C 66.414000,4.8350000 72.359000,8.0240000 74.108000,15.496000 L 80.444000,39.778000 L 80.444000,39.778000 z "
         style="fill:#3b80ae;stroke:none;"
         id="path868" />
    </g>
    <path
       d="M 45.542000,51.793000 L 24.104000,31.102000 L 62.204000,26.709000 L 45.542000,51.793000 z "
       style="opacity:0.49999997;fill:none;stroke:#ffffff;"
       id="path871" />
    <path
       d="M 72.325000,28.769000 C 72.730000,30.319000 71.800000,31.905000 70.250000,32.310000 L 57.919000,35.527000 C 56.368000,35.931000 54.782000,35.002000 54.377000,33.451000 L 52.082000,24.650000 C 51.677000,23.099000 52.606000,21.513000 54.158000,21.108000 L 66.488000,17.891000 C 68.039000,17.486000 69.625000,18.416000 70.030000,19.967000 L 72.325000,28.768000 L 72.325000,28.769000 z "
       id="path873" />
    <path
       d="M 36.510000,33.625000 C 37.006000,35.525000 35.865000,37.469000 33.965000,37.965000 L 18.853000,41.908000 C 16.952000,42.404000 15.008000,41.264000 14.513000,39.364000 L 11.699000,28.578000 C 11.203000,26.677000 12.343000,24.734000 14.243000,24.238000 L 29.356000,20.296000 C 31.257000,19.800000 33.201000,20.939000 33.696000,22.840000 L 36.510000,33.626000 L 36.510000,33.625000 z "
       id="path875" />
    <path
       d="M 52.493000,53.208000 C 52.771000,54.273000 52.133000,55.362000 51.068000,55.640000 L 42.600000,57.848000 C 41.536000,58.125000 40.447000,57.488000 40.169000,56.422000 L 38.592000,50.379000 C 38.315000,49.315000 38.952000,48.226000 40.017000,47.947000 L 48.485000,45.738000 C 49.549000,45.461000 50.639000,46.099000 50.916000,47.164000 L 52.493000,53.207000 L 52.493000,53.208000 z "
       id="path877" />
  </g>
</svg>

--- NEW FILE: gotroot.png ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: home.svg ---
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg
   style="fill:#000000;fill-opacity:0.5;stroke:none"
   width="595.275591"
   height="841.889764"
   id="svg32"
   sodipodi:docbase="/home/mira/"
   sodipodi:docname="/home/mira/HOME.SVG"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs
     id="defs34">
    <linearGradient
       id="linearGradient60">
      <stop
         style="stop-color:#fffa00;stop-opacity:1;"
         offset="0.000000"
         id="stop61" />
      <stop
         style="stop-color:#ffffff;stop-opacity:1;"
         offset="1.000000"
         id="stop62" />
    </linearGradient>
    <linearGradient
       id="linearGradient57">
      <stop
         style="stop-color:#b55f07;stop-opacity:1;"
         offset="0.000000"
         id="stop58" />
      <stop
         style="stop-color:#ffba00;stop-opacity:1;"
         offset="1.000000"
         id="stop59" />
    </linearGradient>
    <linearGradient
       id="linearGradient129">
      <stop
         style="stop-color:#ffffff;stop-opacity:0.803922;"
         offset="0.000000"
         id="stop130" />
      <stop
         style="stop-color:#000000;stop-opacity:0;"
         offset="1.000000"
         id="stop131" />
    </linearGradient>
    <linearGradient
       xlink:href="#linearGradient129"
       id="linearGradient132"
       x1="0.29393"
       y1="0.125996"
       x2="0.85623"
       y2="1.0028" />
    <linearGradient
       xlink:href="#linearGradient129"
       id="linearGradient142"
       x1="0.877848"
       y1="0.382857"
       x2="0.014196"
       y2="0.388571" />
    <linearGradient
       xlink:href="#linearGradient129"
       id="linearGradient48"
       x1="1.45453"
       y1="0.508571"
       x2="0.0661232"
       y2="0.542857" />
    <linearGradient
       x1="0.493086"
       y1="0.428571"
       x2="0.57144"
       y2="0.514286"
       xlink:href="#linearGradient129"
       id="linearGradient49" />
    <linearGradient
       x1="0.450624"
       y1="0.428571"
       x2="0.407689"
       y2="0.474286"
       xlink:href="#linearGradient129"
       id="linearGradient50" />
    <linearGradient
       xlink:href="#linearGradient57"
       id="linearGradient53"
       x1="-0.0101793"
       y1="0.611429"
       x2="0.631844"
       y2="0.6" />
    <linearGradient
       xlink:href="#linearGradient129"
       id="linearGradient54"
       x1="1.09466"
       y1="0.125"
       x2="0.413062"
       y2="0.8125" />
    <linearGradient
       xlink:href="#linearGradient60"
       id="linearGradient59"
       x1="0.0823339"
       y1="0.125714"
       x2="0.724897"
       y2="0.891429" />
  </defs>
  <sodipodi:namedview
     id="base" />
  <path
     style="fill:#ffed44; fill-opacity:1; fill-rule:evenodd; stroke:none; stroke-opacity:1; stroke-width:1px; stroke-linejoin:miter; stroke-linecap:butt; "
     id="path19"
     d="M 98.6818 379.556 C 101.447 395.138 84.4659 397.304 82.3 403.801 C 97.6078 414.826 57.854 431.626 65.2632 436.565 C 70.5236 441.168 148.734 472.689 161.588 473.915 C 240.299 489.097 403.639 478.246 433.526 464.086 C 469.341 443.926 487.452 441.74 493.153 431.978 C 489.778 423.883 458.119 408.779 464.978 402.491 C 459.263 395.348 434.63 396.088 440.077 380.867 C 422.813 375.934 436.705 380.835 424.351 371.693 C 419.735 370.539 418.532 360.553 413.866 360.553 C 371.778 332.301 166.405 341.551 122.927 365.141 C 116.725 377.474 105.928 377.141 98.6818 379.556 z "
     sodipodi:nodetypes="cccccccccccc"
     transform="translate(5.27831,-15.4344)" />
  <rect
     style="stroke:#8484ff; fill:none; fill-opacity:1; fill-rule:evenodd; stroke-opacity:1; stroke-width:1px; stroke-linejoin:miter; stroke-linecap:butt; "
     id="rect322"
     x="64.935965"
     y="48.972789"
     width="433.132119"
     height="433.133400"
     rx="0.000000"
     ry="0.000000" />
  <path
     style="fill:#000000; fill-opacity:0.226601; fill-rule:evenodd; stroke:none; stroke-opacity:1; stroke-width:1px; stroke-linejoin:miter; stroke-linecap:butt; "
     id="path20"
     d="M 225.111 407.241 C 228.073 419.986 212.055 451.321 217.613 456.879 C 281.229 443.591 300.561 434.871 335.561 459.827 C 339.593 453.779 374.563 408.648 366.277 404.293 C 353.465 400.361 276.113 399.27 225.111 407.241 z "
     sodipodi:nodetypes="ccccc"
     transform="matrix(2.12227,0,0,0.789554,-343.775,81.6276)" />
  <path
     style="fill:url(#linearGradient59); fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-opacity:1; stroke-width:14.5pt; stroke-linejoin:miter; stroke-linecap:butt; "
     id="path12"
     d="M 139.308 203.944 C 139.308 201.575 233.721 127.785 287.618 89.0777 C 340.114 127.448 429.823 199.485 428.59 203.184 C 427.653 210.677 428.798 374.969 428.283 383.488 C 415.177 382.832 337.394 381.715 313.611 381.522 C 313.968 371.038 315.048 273.863 315.048 269.785 C 314.282 268.254 258.781 267.567 249.267 268.877 C 249.469 274.22 245.964 373.813 246.117 384.143 C 231.965 384.007 150.448 384.799 140.619 384.799 C 138.95 383.964 139.308 210.497 139.308 203.944 z "
     sodipodi:nodetypes="cccccccccc"
     transform="translate(0,13.5963)" />
  <path
     style="fill:#000000; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-opacity:1; stroke-width:1px; stroke-linejoin:miter; stroke-linecap:butt; "
     d="M 309.679 156.109 C 309.679 168.769 298.083 179.044 283.795 179.044 C 269.508 179.044 257.912 168.769 257.912 156.109 C 257.912 143.45 269.508 133.175 283.795 133.175 C 298.083 133.175 309.679 143.45 309.679 156.109 z "
     id="path16"
     transform="translate(0,14.9069)" />
  <path
     style="fill:#a1282e; fill-opacity:1; fill-rule:evenodd; stroke:none; stroke-opacity:1; stroke-width:1px; stroke-linejoin:miter; stroke-linecap:butt; "
     id="path14"
     d="M 72.3299 188.884 C 87.562 179.955 240.512 75.6699 253.51 69.0917 C 264.238 78.2487 396.189 209.005 404.353 216.036 C 410.737 211.966 404.443 203.725 408.287 194.647 C 401.148 185.404 264.361 56.8171 255.8 47.4144 C 244.34 55.045 78.1907 159.083 68.6151 166.448 C 74.0568 172.658 67.755 182.607 72.3299 188.884 z "
     sodipodi:nodetypes="ccccccc"
     transform="matrix(1.05933,-0.0878478,0.0876177,1.06211,13.6183,42.8198)" />
  <path
     style="fill:url(#linearGradient53); fill-opacity:1; fill-rule:evenodd; stroke:none; stroke-opacity:1; stroke-width:1px; stroke-linejoin:miter; stroke-linecap:butt; "
     id="path52"
     d="M 314.921 282.031 C 312.822 291.009 314.806 370.492 311.972 393.099 C 297.149 394.161 258.567 395.719 247.1 392.116 C 247.009 376.947 246.785 292.175 248.083 282.03 C 260.599 283.408 308.18 281.048 314.921 282.031 z "
     sodipodi:nodetypes="ccccc"
     transform="matrix(0.88331,0,0,1.06005,31.4699,-13.415)" />
  <path
     transform="translate(-2.94871,2.94871)"
     style="fill:none; fill-opacity:1; fill-rule:evenodd; stroke:#ffc200; stroke-opacity:1; stroke-width:5.6pt; stroke-linejoin:miter; stroke-linecap:butt; "
     d="M 312.464 168.751 C 312.464 182.179 300.574 193.078 285.925 193.078 C 271.276 193.078 259.387 182.179 259.387 168.751 C 259.387 155.322 271.276 144.424 285.925 144.424 C 300.574 144.424 312.464 155.322 312.464 168.751 z "
     id="path56" />
  <path
     sodipodi:type="arc"
     style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient54);stroke-opacity:1;stroke-width:5pt;stroke-linejoin:miter;stroke-linecap:butt;"
     id="path63"
     cx="283.795469"
     cy="171.289836"
     rx="28.504240"
     ry="24.572621"
     transform="matrix(0.942528,0,0,0.973333,15.3273,3.39476)" />
  <path
     style="fill:url(#linearGradient132);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-opacity:1;stroke-width:1px;stroke-linejoin:miter;stroke-linecap:butt;"
     id="path64"
     d="M 99.4081 237.963 C 109.883 231.977 120.469 220.777 132.251 216.85 C 129.812 253.364 130.29 237.086 129.905 262.595 C 170.232 247.472 239.132 165.447 257.756 175.797 C 307.535 207.834 333.293 221.542 356.286 240.31 C 386.728 243.837 435.162 238.56 436.047 218.023 C 443.49 221.244 447.659 227.348 461.852 235.617 C 461.383 227.759 462.036 219.197 460.679 209.813 C 440.956 193.304 300.875 82.9514 285.909 69.0578 C 263.711 84.8091 128.039 190.672 99.4081 210.986 C 100.258 218.929 99.4081 227.159 99.4081 237.963 z "
     sodipodi:nodetypes="ccccccccccc"
     transform="translate(2.63912,-0.000394997)" />
</svg>

--- NEW FILE: main.cpp ---
// "cairo in motion" is a testbed for animated vector-drawing
// using cairo within a gtk+-environment
//
// Copyright (C) 2005 Mirco Mueller <macslow at bangang.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#include <libglademm/xml.h>
#include <gtkmm.h>
#include <iostream>
#include <sstream>
#include <math.h>

#include "cairo-samples.h"
#include "sample-list-store.h"

// widgets we get from the .glade file
Gtk::Window* pMainWindow = NULL;
Gtk::Dialog* pAboutDialog = NULL;
Gtk::Statusbar* pMainStatusBar = NULL;
Gtk::ComboBox* pCapStyleComboBox = NULL;
Gtk::ComboBox* pJoinStyleComboBox = NULL;
Gtk::ComboBox* pDashStyleComboBox = NULL;
Gtk::ComboBox* pOperatorComboBox = NULL;
Gtk::ComboBox* pExtendModeComboBox = NULL;
Gtk::ComboBox* pFilterModeComboBox = NULL;
Gtk::HScale* pLineWidthHScale = NULL;
Gtk::ColorButton* pBGColorColorButton = NULL;
Gtk::ToggleButton* pAnimateToggleButton = NULL;
Gtk::FontButton* pFontFontButton = NULL;
Gtk::TreeView* pSamplesTreeView = NULL;
Gtk::DrawingArea* pMainDrawingArea = NULL;
Gtk::Entry* pTextEntry = NULL;
Gtk::FileChooserButton* pImageFileFileChooserButton = NULL;
Gtk::FileChooserButton* pSvgFileFileChooserButton = NULL;

// those here are just used to give some proper default values to everything
// later during runtime most of those here aren't touch anymore... rather the
// values are directly passed to the class CairoSamples
cairo_line_cap_t m_capStyle = CAIRO_LINE_CAP_ROUND;
cairo_line_join_t m_joinStyle = CAIRO_LINE_JOIN_ROUND;
CairoSamples::DashStyle m_dashStyle = CairoSamples::DashOff;
cairo_operator_t m_operator = CAIRO_OPERATOR_CLEAR;
cairo_extend_t m_extendMode = CAIRO_EXTEND_REPEAT;
cairo_filter_t m_filterMode = CAIRO_FILTER_GOOD;
double m_fLineWidth = 0.01f;
Gdk::Color m_bgColor ("#B0B0B0");
std::string m_strFontFamily = "Sans";
int m_iFontSize = 35;
cairo_font_weight_t m_fontWeight = CAIRO_FONT_WEIGHT_NORMAL;
cairo_font_slant_t m_fontSlant = CAIRO_FONT_SLANT_NORMAL;
std::string m_strImageFileName = "/home/mirco/workspace/cairo-in-motion/gotroot.png";
std::string m_strSvgFileName = "/home/mirco/workspace/cairo-in-motion/freedesktop.svg";
std::string m_strSomeText = "laber";

// additional stuff we need/use for the cairo-drawing
Gdk::Window* m_pGdkWindow = NULL;
bool m_bAnimate = true;
cairo_t* m_pCairoContext = NULL;
CairoSamples* m_pCairoSamples = NULL;
SampleListStore* m_pSampleListStore = NULL;
int m_iSample = 10;
sigc::connection timeoutHandlerConnection;

void on_quit_menu_item ()
{
	pMainStatusBar->push ("quit requested");

	if (pMainWindow)
		pMainWindow->hide (); //hide() will cause main::run() to end.
	else
		std::cout << "ehm... no valid pointer to main-window" << std::endl;
}

void on_info_menu_item ()
{
	pMainStatusBar->push ("info requested");

	if (pAboutDialog)
		pAboutDialog->show ();
	else
		std::cout << "ehm... no valid pointer to about-dialog" << std::endl;
}

void on_cap_style_changed ()
{
	switch (pCapStyleComboBox->get_active_row_number ())
	{
		case CAIRO_LINE_CAP_BUTT :
			m_pCairoSamples->set_cap_style (CAIRO_LINE_CAP_BUTT);
			pMainStatusBar->push ("cap-style changed to CAIRO_LINE_CAP_BUTT");
		break;

		case CAIRO_LINE_CAP_ROUND :
			m_pCairoSamples->set_cap_style (CAIRO_LINE_CAP_ROUND);
			pMainStatusBar->push ("cap-style changed to CAIRO_LINE_CAP_ROUND");
		break;

		case CAIRO_LINE_CAP_SQUARE :
			m_pCairoSamples->set_cap_style (CAIRO_LINE_CAP_SQUARE);
			pMainStatusBar->push ("cap-style changed to CAIRO_LINE_CAP_SQUARE");
		break;
	}

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_join_style_changed ()
{
	switch (pJoinStyleComboBox->get_active_row_number ())
	{
		case CAIRO_LINE_JOIN_MITER :
			m_pCairoSamples->set_join_style (CAIRO_LINE_JOIN_MITER);
			pMainStatusBar->push ("join-style changed to CAIRO_LINE_JOIN_MITER");
		break;

		case CAIRO_LINE_JOIN_ROUND :
			m_pCairoSamples->set_join_style (CAIRO_LINE_JOIN_ROUND);
			pMainStatusBar->push ("join-style changed to CAIRO_LINE_JOIN_ROUND");
		break;

		case CAIRO_LINE_JOIN_BEVEL :
			m_pCairoSamples->set_join_style (CAIRO_LINE_JOIN_BEVEL);
			pMainStatusBar->push ("join-style changed to CAIRO_LINE_JOIN_BEVEL");
		break;
	}

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_dash_style_changed ()
{
	switch (pDashStyleComboBox->get_active_row_number ())
	{
		case CairoSamples::DashOff :
			m_pCairoSamples->set_dash_style (CairoSamples::DashOff);
			pMainStatusBar->push ("dash-style changed to DashOff");
		break;

		case CairoSamples::Dotted :
			m_pCairoSamples->set_dash_style (CairoSamples::Dotted);
			pMainStatusBar->push ("dash-style changed to Dotted");
		break;

		case CairoSamples::Dashed :
			m_pCairoSamples->set_dash_style (CairoSamples::Dashed);
			pMainStatusBar->push ("dash-style changed to Dashed");
		break;

		case CairoSamples::DashDotDash :
			m_pCairoSamples->set_dash_style (CairoSamples::DashDotDash);
			pMainStatusBar->push ("dash-style changed to DashDotDash");
		break;

		case CairoSamples::DashedFunky :
			m_pCairoSamples->set_dash_style (CairoSamples::DashedFunky);
			pMainStatusBar->push ("dash-style changed to DashedFunky");
		break;
	}

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_operator_changed ()
{
	switch (pOperatorComboBox->get_active_row_number ())
	{
		case CAIRO_OPERATOR_CLEAR :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_CLEAR);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_CLEAR");
		break;

		case CAIRO_OPERATOR_SOURCE :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_SOURCE);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_SOURCE");
		break;

		case CAIRO_OPERATOR_OVER :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_OVER);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_OVER");
		break;

		case CAIRO_OPERATOR_IN :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_IN);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_IN");
		break;

		case CAIRO_OPERATOR_OUT :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_OUT);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_OUT");
		break;

		case CAIRO_OPERATOR_ATOP :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_ATOP);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_ATOP");
		break;

		case CAIRO_OPERATOR_DEST :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_DEST);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_DEST");
		break;

		case CAIRO_OPERATOR_DEST_OVER :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_DEST_OVER);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_DEST_OVER");
		break;

		case CAIRO_OPERATOR_DEST_IN :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_DEST_IN);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_DEST_IN");
		break;

		case CAIRO_OPERATOR_DEST_OUT :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_DEST_OUT);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_DEST_OUT");
		break;

		case CAIRO_OPERATOR_DEST_ATOP :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_DEST_ATOP);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_DEST_ATOP");
		break;

		case CAIRO_OPERATOR_XOR :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_XOR);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_XOR");
		break;

		case CAIRO_OPERATOR_ADD :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_ADD);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_ADD");
		break;

		case CAIRO_OPERATOR_SATURATE :
			m_pCairoSamples->set_operator (CAIRO_OPERATOR_SATURATE);
			pMainStatusBar->push ("operator changed to CAIRO_OPERATOR_SATURATE");
		break;
	}

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}	

void on_extend_mode_changed ()
{
	switch (pExtendModeComboBox->get_active_row_number ())
	{
		case CAIRO_EXTEND_NONE :
			m_pCairoSamples->set_extend_mode (CAIRO_EXTEND_NONE);
			pMainStatusBar->push ("extend-mode changed to CAIRO_EXTEND_NONE");
		break;

		case CAIRO_EXTEND_REPEAT :
			m_pCairoSamples->set_extend_mode (CAIRO_EXTEND_REPEAT);
			pMainStatusBar->push ("extend-mode changed to CAIRO_EXTEND_REPEAT");
		break;

		case CAIRO_EXTEND_REFLECT :
			m_pCairoSamples->set_extend_mode (CAIRO_EXTEND_REFLECT);
			pMainStatusBar->push ("extend-mode changed to CAIRO_EXTEND_REFLECT");
		break;
	}

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_filter_mode_changed ()
{
	switch (pFilterModeComboBox->get_active_row_number ())
	{
		case CAIRO_FILTER_FAST :
			m_pCairoSamples->set_filter_mode (CAIRO_FILTER_FAST);
			pMainStatusBar->push ("filter-mode changed to CAIRO_FILTER_FAST");
		break;

		case CAIRO_FILTER_GOOD :
			m_pCairoSamples->set_filter_mode (CAIRO_FILTER_GOOD);
			pMainStatusBar->push ("filter-mode changed to CAIRO_FILTER_GOOD");
		break;

		case CAIRO_FILTER_BEST :
			m_pCairoSamples->set_filter_mode (CAIRO_FILTER_BEST);
			pMainStatusBar->push ("filter-mode changed to CAIRO_FILTER_BEST");
		break;

		case CAIRO_FILTER_NEAREST :
			m_pCairoSamples->set_filter_mode (CAIRO_FILTER_NEAREST);
			pMainStatusBar->push ("filter-mode changed to CAIRO_FILTER_NEAREST");
		break;

		case CAIRO_FILTER_BILINEAR :
			m_pCairoSamples->set_filter_mode (CAIRO_FILTER_BILINEAR);
			pMainStatusBar->push ("filter-mode changed to CAIRO_FILTER_BILINEAR");
		break;

		case CAIRO_FILTER_GAUSSIAN :
			m_pCairoSamples->set_filter_mode (CAIRO_FILTER_GAUSSIAN);
			pMainStatusBar->push ("filter-mode changed to CAIRO_FILTER_GAUSSIAN");
		break;
	}

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_line_width_changed ()
{
	m_pCairoSamples->set_line_width ((double) pLineWidthHScale->get_value ());

	std::stringstream message;
	message << "line-width changed to " << pLineWidthHScale->get_value ();
	pMainStatusBar->push (message.str ());

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_bg_color_set ()
{
	m_pCairoSamples->set_bg_color (pBGColorColorButton->get_color ());

	std::stringstream message;
	message << "background-color changed to "
			<< pBGColorColorButton->get_color().get_red_p ()
			<< "/"
			<< pBGColorColorButton->get_color().get_green_p ()
			<< "/"
			<< pBGColorColorButton->get_color().get_blue_p ();
	pMainStatusBar->push (message.str ());

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

bool on_timeout ()
{
	m_pCairoSamples->do_animation_step ();

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();

	return true;
}

void on_animate_toggled ()
{
	if (pAnimateToggleButton->get_active ())
	{
		timeoutHandlerConnection = Glib::signal_timeout().connect (sigc::ptr_fun(&on_timeout), 100);
		m_bAnimate = true;
		pMainStatusBar->push ("animation is turned on");
	}
	else
	{
		timeoutHandlerConnection.disconnect ();
		m_bAnimate = false;
		pMainStatusBar->push ("animation is turned off");
	}
}

void on_sample_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column)
{
	// this feels awkward/wrong, isn't there another way to get the
	// integer-values form a Gtk::TreeModel::Path ?
	std::stringstream str2int;
	str2int << path.to_string ();
	str2int >> m_iSample;

	std::stringstream message;
	message << "rendering sample \""
			<< m_pCairoSamples->get_sample_name ((CairoSamples::Sample) m_iSample)
			<< "\"";

	pMainStatusBar->push (message.str ());

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

bool on_expose_event (GdkEventExpose* pEvent)
{
	m_pCairoContext = gdk_cairo_create (pMainDrawingArea->get_window()->gobj ());
	if (m_pCairoContext)
	{
		m_pCairoSamples->set_context (m_pCairoContext);
		m_pCairoSamples->normalize_canvas ((double) pMainDrawingArea->get_allocation().get_width (),
										   (double) pMainDrawingArea->get_allocation().get_height ());
		m_pCairoSamples->do_sample ((CairoSamples::Sample) m_iSample);
		cairo_destroy (m_pCairoContext);
	}

	return true;
}

// this doesn't catch every slant- and weight-attribute-names there are, but it
// covers most of the usual "Regular", "Bold", "Italic", "Oblique" bits... this
// is only a testbed after all and no full-blown application that needs to be
// bullet-proof... aside from that, I'm always happy to receive patches :)
void on_font_set ()
{
	std::string strFontName = pFontFontButton->get_font_name ();
	std::string strToken;
	std::string::size_type start;
	std::string::size_type length;

	std::stringstream message;
	message << "font changed to "
			<< strFontName;
	pMainStatusBar->push (message.str ());

	// set default slant and weight
	m_pCairoSamples->set_font_slant (CAIRO_FONT_SLANT_NORMAL);
	m_pCairoSamples->set_font_weight (CAIRO_FONT_WEIGHT_NORMAL);

	// just find one occurance of "Regular" and eat it
	strToken = "Regular";
	start = strFontName.find (strToken);
	length = strToken.length ();
	if (start != std::string::npos)
		strFontName.erase (start, length);

	// find one occurance of "Roman" and eat it 
	// *sigh* this bites with "Times New Roman"
	strToken = "Roman";
	start = strFontName.find (strToken);
	length = strToken.length ();
	if (start != std::string::npos)
		strFontName.erase (start, length);

	// find one occurance of "Bold"
	strToken = "Bold";
	start = strFontName.find (strToken);
	length = strToken.length ();
	if (start != std::string::npos)
	{
		m_pCairoSamples->set_font_weight (CAIRO_FONT_WEIGHT_BOLD);
		strFontName.erase (start, length);
	}

	// find one occurance of "Italic"
	strToken = "Italic";
	start = strFontName.find (strToken);
	length = strToken.length ();
	if (start != std::string::npos)
	{
		m_pCairoSamples->set_font_slant (CAIRO_FONT_SLANT_ITALIC);
		strFontName.erase (start, length);
	}

	// find one occurance of "Oblique"
	strToken = "Oblique";
	start = strFontName.find (strToken);
	length = strToken.length ();
	if (start != std::string::npos)
	{
		m_pCairoSamples->set_font_slant (CAIRO_FONT_SLANT_OBLIQUE);
		strFontName.erase (start, length);
	}

	// just find and cut one occurance of "semicondensed"
	strToken = "semicondensed";
	start = strFontName.find (strToken);
	length = strToken.length ();
	if (start != std::string::npos)
		strFontName.erase (start, length);

	// get font-size
	start = strFontName.find_last_of (" ");
	std::stringstream str2int;
	str2int << strFontName.substr (start);
	str2int >> m_iFontSize;
	m_pCairoSamples->set_font_size (m_iFontSize * 0.01f);

	// cut size from remaining string
	start = strFontName.find_last_of (" ");
	if (start != std::string::npos)
		strFontName.erase (start);

	// cut trailing spaces from remaining string
	start = strFontName.find_last_of (" ");
	if (start != std::string::npos)
		strFontName.erase (start);

	// cut trailing comma from remaining string
	start = strFontName.find_last_of (",");
	if (start != std::string::npos)
		strFontName.erase (start);

	// finally the remaining string only contains the font-family name
	m_pCairoSamples->set_font_family (strFontName);

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_text_entry_activated ()
{
	std::stringstream message;
	message << "some text changed to "
			<< "\""
			<< pTextEntry->get_text ()
			<< "\"";
	pMainStatusBar->push (message.str ());

	m_pCairoSamples->set_some_text ((std::string) pTextEntry->get_text ());

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_image_selection_changed ()
{
	std::stringstream message;
	message << "PNG-file changed to "
			<< "\""
			<< pImageFileFileChooserButton->get_filename ()
			<< "\"";
	pMainStatusBar->push (message.str ());

	m_pCairoSamples->set_image_file_name ((std::string) pImageFileFileChooserButton->get_filename ());

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

void on_svg_selection_changed ()
{
	std::stringstream message;
	message << "SVG-file changed to "
			<< "\""
			<< pSvgFileFileChooserButton->get_filename ()
			<< "\"";
	pMainStatusBar->push (message.str ());

	m_pCairoSamples->set_svg_file_name ((std::string) pSvgFileFileChooserButton->get_filename ());

	// force a redraw of the cairo-context
	pMainDrawingArea->queue_draw ();
}

int main (int argc, char** argv)
{
	Gtk::Main app (argc, argv);

	Glib::RefPtr<Gnome::Glade::Xml> refXml;
	try
	{
		refXml = Gnome::Glade::Xml::create("cairo-in-motion.glade");
	}
	catch (const Gnome::Glade::XmlError& exception)
	{
		std::cerr << exception.what () << std::endl;
		return 1;
	}

	refXml->get_widget ("mainWindow", pMainWindow);
	refXml->get_widget ("aboutDialog", pAboutDialog);
	if (pMainWindow)
	{
		Gtk::ImageMenuItem* pQuitMenuItem = NULL;
		Gtk::MenuItem* pInfoMenuItem = NULL;
		refXml->get_widget ("quitMenuItem", pQuitMenuItem);
		refXml->get_widget ("infoMenuItem", pInfoMenuItem);
		refXml->get_widget ("mainStatusBar", pMainStatusBar);
		if (pQuitMenuItem)
			pQuitMenuItem->signal_activate().connect (sigc::ptr_fun (on_quit_menu_item));
		if (pInfoMenuItem)
			pInfoMenuItem->signal_activate().connect (sigc::ptr_fun (on_info_menu_item));
		if (pMainStatusBar)
			pMainStatusBar->push ("program started");

		pMainWindow->set_icon_from_file ("cairo-in-motion.png");
		pAboutDialog->set_icon_from_file ("cairo-in-motion.png");

		refXml->get_widget ("capStyleComboBox", pCapStyleComboBox);
		refXml->get_widget ("joinStyleComboBox", pJoinStyleComboBox);
		refXml->get_widget ("dashStyleComboBox", pDashStyleComboBox);
		refXml->get_widget ("operatorComboBox", pOperatorComboBox);
		refXml->get_widget ("extendModeComboBox", pExtendModeComboBox);
		refXml->get_widget ("filterModeComboBox", pFilterModeComboBox);
		if (pCapStyleComboBox)
		{
			pCapStyleComboBox->set_active ((int) m_capStyle);
			pCapStyleComboBox->signal_changed().connect (sigc::ptr_fun (on_cap_style_changed));
		}
		if (pJoinStyleComboBox)
		{
			pJoinStyleComboBox->set_active ((int) m_joinStyle);
			pJoinStyleComboBox->signal_changed().connect (sigc::ptr_fun (on_join_style_changed));
		}
		if (pDashStyleComboBox)
		{
			pDashStyleComboBox->set_active ((int) m_dashStyle);
			pDashStyleComboBox->signal_changed().connect (sigc::ptr_fun (on_dash_style_changed));
		}
		if (pOperatorComboBox)
		{
			pOperatorComboBox->set_active ((int) m_operator);
			pOperatorComboBox->signal_changed().connect (sigc::ptr_fun (on_operator_changed));
		}
		if (pExtendModeComboBox)
		{
			pExtendModeComboBox->set_active ((int) m_extendMode);
			pExtendModeComboBox->signal_changed().connect (sigc::ptr_fun (on_extend_mode_changed));
		}
		if (pFilterModeComboBox)
		{
			pFilterModeComboBox->set_active ((int) m_filterMode);
			pFilterModeComboBox->signal_changed().connect (sigc::ptr_fun (on_filter_mode_changed));
		}

		refXml->get_widget ("lineWidthHScale", pLineWidthHScale);
		if (pLineWidthHScale)
		{
			pLineWidthHScale->set_value (m_fLineWidth);
			pLineWidthHScale->signal_value_changed().connect (sigc::ptr_fun (on_line_width_changed));
		}

		refXml->get_widget ("bgColorColorButton", pBGColorColorButton);
		if (pBGColorColorButton)
		{
			pBGColorColorButton->set_color (m_bgColor);
			pBGColorColorButton->signal_color_set().connect (sigc::ptr_fun (on_bg_color_set));
		}

		refXml->get_widget ("animateToggleButton", pAnimateToggleButton);
		if (pAnimateToggleButton)
		{
			timeoutHandlerConnection = Glib::signal_timeout().connect(sigc::ptr_fun (&on_timeout), 100);

			if (!m_bAnimate)
				timeoutHandlerConnection.disconnect ();

			pAnimateToggleButton->set_active (m_bAnimate);
			pAnimateToggleButton->signal_toggled().connect (sigc::ptr_fun (on_animate_toggled));
		}

		refXml->get_widget ("samplesTreeView", pSamplesTreeView);
		if (pSamplesTreeView)
		{
			m_pSampleListStore = new SampleListStore (pSamplesTreeView);

			// I was hoping to figure out how to set/highlight the first
			// row of the treeview... but even with asking on #gtk at
			// irc.gimp.org I'm not able to get this very simple thing done
			pSamplesTreeView->get_selection()->select (Gtk::TreePath ("0"));

			pSamplesTreeView->signal_row_activated().connect (sigc::ptr_fun (on_sample_activated));
		}

		refXml->get_widget ("mainDrawingArea", pMainDrawingArea);
		if (pMainDrawingArea)
		{
			m_pCairoSamples = new CairoSamples ();
			if (m_pCairoSamples)
			{
				m_pCairoSamples->set_cap_style (m_capStyle);
				m_pCairoSamples->set_join_style (m_joinStyle);
				m_pCairoSamples->set_operator (m_operator);
				m_pCairoSamples->set_extend_mode (m_extendMode);
				m_pCairoSamples->set_filter_mode (m_filterMode);
				m_pCairoSamples->set_line_width (m_fLineWidth);
				m_pCairoSamples->set_bg_color (m_bgColor);
				m_pCairoSamples->set_font_family (m_strFontFamily);
				m_pCairoSamples->set_font_size ((double) m_iFontSize * 0.01f);
				m_pCairoSamples->set_font_weight (m_fontWeight);
				m_pCairoSamples->set_font_slant (m_fontSlant);
				m_pCairoSamples->set_some_text (m_strSomeText);
				m_pCairoSamples->set_image_file_name (m_strImageFileName);
				m_pCairoSamples->set_svg_file_name (m_strSvgFileName);
				m_pCairoSamples->add_samples_to_list_store (m_pSampleListStore);
			}

			pMainDrawingArea->signal_expose_event().connect (sigc::ptr_fun (on_expose_event));
		}

		refXml->get_widget ("fontFontButton", pFontFontButton);
		if (pFontFontButton)
		{
			// assemble string describing the initial font
			std::string strFontName;
			strFontName = m_strFontFamily;
			switch (m_fontWeight)
			{
				case CAIRO_FONT_WEIGHT_NORMAL :
					strFontName.append (" Regular");
				break;

				case CAIRO_FONT_WEIGHT_BOLD :
					strFontName.append (" Bold");
				break;
			}
			switch (m_fontSlant)
			{
				case CAIRO_FONT_SLANT_ITALIC :
					strFontName.append (" Italic");
				break;

				case CAIRO_FONT_SLANT_OBLIQUE :
					strFontName.append (" Oblique");
				break;

				default :
				break;
			}
			std::stringstream int2str;
			int2str << m_iFontSize;
			strFontName.append (" ");
			strFontName.append (int2str.str ());

			pFontFontButton->set_font_name (strFontName);
			pFontFontButton->set_show_size (true);
			pFontFontButton->set_use_font (false);
			pFontFontButton->set_use_size (false);
			pFontFontButton->set_show_style (false);
			pFontFontButton->signal_font_set().connect (sigc::ptr_fun (on_font_set));
		}

		refXml->get_widget ("imageFileFileChooserButton", pImageFileFileChooserButton);
		if (pImageFileFileChooserButton)
		{
			pImageFileFileChooserButton->set_filename (m_strImageFileName.c_str ());
			Gtk::FileFilter pngFilter;
			pngFilter.set_name ("PNG Images");
			pngFilter.add_pattern ("*.png");
			pngFilter.add_pattern ("*.PNG");
			pImageFileFileChooserButton->add_filter (pngFilter);
			pImageFileFileChooserButton->set_filter (pngFilter);

			pImageFileFileChooserButton->signal_selection_changed ().connect (sigc::ptr_fun (on_image_selection_changed));
		}

		refXml->get_widget ("svgFileFileChooserButton", pSvgFileFileChooserButton);
		if (pSvgFileFileChooserButton)
		{
			pSvgFileFileChooserButton->set_filename (m_strSvgFileName.c_str ());
			Gtk::FileFilter svgFilter;
			svgFilter.set_name ("SVG Drawings");
			svgFilter.add_pattern ("*.svg");
			svgFilter.add_pattern ("*.SVG");
			pSvgFileFileChooserButton->add_filter (svgFilter);
			pSvgFileFileChooserButton->set_filter (svgFilter);

			pSvgFileFileChooserButton->signal_selection_changed ().connect (sigc::ptr_fun (on_svg_selection_changed));
		}

		refXml->get_widget ("textEntry", pTextEntry);
		if (pTextEntry)
		{
			pTextEntry->set_text (m_strSomeText);
			pTextEntry->signal_activate().connect (sigc::ptr_fun (on_text_entry_activated));
		}

		app.run (*pMainWindow);
	}


	return 0;
}

--- NEW FILE: sample-list-store.cpp ---
// "cairo in motion" is a testbed for animated vector-drawing
// using cairo within a gtk+-environment
//
// Copyright (C) 2005 Mirco Mueller <macslow at bangang.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#include "sample-list-store.h"

SampleListStore::SampleListStore (Gtk::TreeView* pTreeView)
{
	m_pTreeView = pTreeView;
	m_refListStore = Gtk::ListStore::create (m_columns);
	m_pTreeView->set_model (m_refListStore);
	add_columns ();
}

SampleListStore::~SampleListStore ()
{
}

void SampleListStore::add_item (std::string strName)
{
	Gtk::TreeRow entry = *(m_refListStore->append ());
	entry[m_columns.name] = strName;
}

void SampleListStore::add_columns ()
{
	Gtk::CellRendererText* pRenderer = Gtk::manage (new Gtk::CellRendererText ());

	int cols_count = m_pTreeView->append_column ("Sample Name", *pRenderer);
	Gtk::TreeViewColumn* pColumn = m_pTreeView->get_column (cols_count - 1);

	pColumn->add_attribute (pRenderer->property_text (), m_columns.name);
}

--- NEW FILE: sample-list-store.h ---
// "cairo in motion" is a testbed for animated vector-drawing
// using cairo within a gtk+-environment
//
// Copyright (C) 2005 Mirco Mueller <macslow at bangang.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#ifndef _SAMPLELISTSTORE_H_
#define _SAMPLELISTSTORE_H_

#include <string>
#include <vector>
#include <gtkmm.h>

class SampleListStore
{
	public:
		SampleListStore (Gtk::TreeView* pTreeView);
		~SampleListStore ();
		void add_item (std::string strName);

	private:
		void add_columns ();

		struct ModelColumns : public Gtk::TreeModelColumnRecord
		{
			Gtk::TreeModelColumn<std::string> name;

			ModelColumns ()
			{
				add (name);
			}
		};

		Gtk::TreeView* m_pTreeView;
		const ModelColumns m_columns;
		Glib::RefPtr<Gtk::ListStore> m_refListStore;
};

#endif /*_SAMPLELISTSTORE_H_*/



More information about the cairo-commit mailing list