[gtkmm-documentation] New example programs in the DrawingArea chapter.



commit bdefcfa4c0824deecd8d1c925e44d067f2b82b63
Author: Pedro Ferreira <darkiiiiii gmail com>
Date:   Mon Jan 30 16:57:49 2012 +0100

    New example programs in the DrawingArea chapter.
    
    * docs/tutorial/C/gtkmm-tutorial-in.xml: Add a section on drawing thin lines.
    Add an example program that draws text.
    * docs/tutorial/C/figures/drawingarea_thin_lines.png:
    * docs/tutorial/C/figures/drawingarea_pango_text.png: New screenshots.
    * docs/tutorial/Makefile.am: Add the new files.
    * examples/book/drawingarea/thin_lines/main.cc:
    * examples/book/drawingarea/thin_lines/examplewindow.[h|cc]:
    * examples/book/drawingarea/thin_lines/myarea.[h|cc]:
    * examples/book/drawingarea/pango_text/main.cc:
    * examples/book/drawingarea/pango_text/myarea.[h|cc]: New example programs.
    * examples/Makefile.am: Add the new files.
    Bug #666885.

 ChangeLog                                          |   17 ++++
 docs/tutorial/C/figures/drawingarea_pango_text.png |  Bin 0 -> 5412 bytes
 docs/tutorial/C/figures/drawingarea_thin_lines.png |  Bin 0 -> 4998 bytes
 docs/tutorial/C/gtkmm-tutorial-in.xml              |   50 +++++++++-
 docs/tutorial/Makefile.am                          |    2 +
 examples/Makefile.am                               |   14 +++
 examples/book/drawingarea/pango_text/main.cc       |   35 +++++++
 examples/book/drawingarea/pango_text/myarea.cc     |   97 ++++++++++++++++++++
 examples/book/drawingarea/pango_text/myarea.h      |   38 ++++++++
 .../book/drawingarea/thin_lines/examplewindow.cc   |   47 ++++++++++
 .../book/drawingarea/thin_lines/examplewindow.h    |   41 ++++++++
 examples/book/drawingarea/thin_lines/main.cc       |   29 ++++++
 examples/book/drawingarea/thin_lines/myarea.cc     |   69 ++++++++++++++
 examples/book/drawingarea/thin_lines/myarea.h      |   39 ++++++++
 14 files changed, 473 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8d7be6d..8ee63c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2012-01-30  Pedro Ferreira <darkiiiiii gmail com>
+
+	New example programs in the DrawingArea chapter.
+
+	* docs/tutorial/C/gtkmm-tutorial-in.xml: Add a section on drawing thin lines.
+	Add an example program that draws text.
+	* docs/tutorial/C/figures/drawingarea_thin_lines.png:
+	* docs/tutorial/C/figures/drawingarea_pango_text.png: New screenshots.
+	* docs/tutorial/Makefile.am: Add the new files.
+	* examples/book/drawingarea/thin_lines/main.cc:
+	* examples/book/drawingarea/thin_lines/examplewindow.[h|cc]:
+	* examples/book/drawingarea/thin_lines/myarea.[h|cc]:
+	* examples/book/drawingarea/pango_text/main.cc:
+	* examples/book/drawingarea/pango_text/myarea.[h|cc]: New example programs.
+	* examples/Makefile.am: Add the new files.
+	Bug #666885.
+
 2012-01-26  Kjell Ahlstedt <kjell ahlstedt bredband net>
 
 	Remove Table and other deprecated classes.
diff --git a/docs/tutorial/C/figures/drawingarea_pango_text.png b/docs/tutorial/C/figures/drawingarea_pango_text.png
new file mode 100644
index 0000000..a81a661
Binary files /dev/null and b/docs/tutorial/C/figures/drawingarea_pango_text.png differ
diff --git a/docs/tutorial/C/figures/drawingarea_thin_lines.png b/docs/tutorial/C/figures/drawingarea_thin_lines.png
new file mode 100644
index 0000000..45c1200
Binary files /dev/null and b/docs/tutorial/C/figures/drawingarea_thin_lines.png differ
diff --git a/docs/tutorial/C/gtkmm-tutorial-in.xml b/docs/tutorial/C/gtkmm-tutorial-in.xml
index 00216a9..30490bf 100644
--- a/docs/tutorial/C/gtkmm-tutorial-in.xml
+++ b/docs/tutorial/C/gtkmm-tutorial-in.xml
@@ -4213,7 +4213,35 @@ myContext->set_line_width(2.0);</programlisting>
             the Cairo API documentation.
         </para>
     </sect2>
-</sect1>
+    <sect2 id="sec-cairo-thin-lines">
+      <title>Drawing thin lines</title>
+      <para>
+        If you try to draw one pixel wide lines, you may notice that the line
+        sometimes comes up blurred and wider than it ought to be.
+        This happens because Cairo will try to draw from the selected position,
+        to both sides (half to each), so if you're positioned right on the
+        intersection of the pixels, and want a one pixel wide line, Cairo will try
+        to use half of each adjacent pixel, which isn't possible (a pixel is the
+        smallest unit possible). This happens when the width of the line is an
+        odd number of pixels (not just one pixel).
+      </para>
+      <para>
+        The trick is to position in the middle of the pixel where you want the
+        line to be drawn, and thus guaranteeing you get the desired results.
+        See <ulink url="http://cairographics.org/FAQ/#sharp_lines";>Cairo FAQ</ulink>.
+      </para>
+
+      <figure id="figure-drawingarea-thin-lines">
+        <title>Drawing Area - Thin Lines</title>
+        <screenshot>
+          <graphic format="PNG" fileref="&url_figures_base;drawingarea_thin_lines.png"/>
+        </screenshot>
+      </figure>
+
+      <para><ulink url="&url_examples_base;drawingarea/thin_lines">Source Code</ulink></para>
+    </sect2>
+  </sect1>
+
     <sect1 id="sec-cairo-curved-lines">
         <title>Drawing Curved Lines</title>
         <para>
@@ -4371,10 +4399,22 @@ context->restore();</programlisting>
               be rendered using the
               <methodname>Pango::Layout::show_in_cairo_context()</methodname> method.
           </para>
-          <para>
-              The Printing chapter contains an
-              <link linkend="sec-printing-example">example</link> of drawing text.
-          </para>
+      </sect2>
+      <sect2 id="pango-text-example">
+        <title>Example</title>
+        <para>
+           Here is an example of a program that draws some text, some of it
+           upside-down. The Printing chapter contains another
+           <link linkend="sec-printing-example">example</link> of drawing text.
+        </para>
+        <figure id="figure-drawingarea-pango-text">
+            <title>Drawing Area - Text</title>
+            <screenshot>
+                <graphic format="PNG" fileref="&url_figures_base;drawingarea_pango_text.png"/>
+            </screenshot>
+        </figure>
+
+        <para><ulink url="&url_examples_base;drawingarea/pango_text">Source Code</ulink></para>
       </sect2>
 
       <!--
diff --git a/docs/tutorial/Makefile.am b/docs/tutorial/Makefile.am
index 814c9ab..19395c8 100644
--- a/docs/tutorial/Makefile.am
+++ b/docs/tutorial/Makefile.am
@@ -50,7 +50,9 @@ DOC_FIGURES =					\
 	figures/drawingarea_curve.png		\
 	figures/drawingarea_image.png		\
 	figures/drawingarea_lines.png		\
+	figures/drawingarea_pango_text.png		\
 	figures/drawingarea_text.png		\
+	figures/drawingarea_thin_lines.png		\
 	figures/entry.png			\
 	figures/entry_completion.png		\
 	figures/eventbox.png			\
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 4649746..148a82f 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -42,7 +42,9 @@ check_PROGRAMS =					\
 	book/drawingarea/curve/drawingareacurve		\
 	book/drawingarea/image/drawingareaimage		\
 	book/drawingarea/joins/cairojoins		\
+	book/drawingarea/pango_text/example		\
 	book/drawingarea/simple/drawingarea		\
+	book/drawingarea/thin_lines/example		\
 	book/entry/completion/example			\
 	book/entry/icon/example				\
 	book/entry/progress/example			\
@@ -319,11 +321,23 @@ book_drawingarea_joins_cairojoins_SOURCES =	\
 	book/drawingarea/joins/myarea.cc	\
 	book/drawingarea/joins/myarea.h
 
+book_drawingarea_pango_text_example_SOURCES =	\
+	book/drawingarea/pango_text/main.cc		\
+	book/drawingarea/pango_text/myarea.cc	\
+	book/drawingarea/pango_text/myarea.h
+
 book_drawingarea_simple_drawingarea_SOURCES =	\
 	book/drawingarea/simple/main.cc		\
 	book/drawingarea/simple/myarea.cc	\
 	book/drawingarea/simple/myarea.h
 
+book_drawingarea_thin_lines_example_SOURCES =	\
+	book/drawingarea/thin_lines/main.cc		\
+	book/drawingarea/thin_lines/examplewindow.cc	\
+	book/drawingarea/thin_lines/examplewindow.h  \
+	book/drawingarea/thin_lines/myarea.cc	\
+	book/drawingarea/thin_lines/myarea.h
+
 book_entry_completion_example_SOURCES =		\
 	book/entry/completion/examplewindow.cc	\
 	book/entry/completion/examplewindow.h	\
diff --git a/examples/book/drawingarea/pango_text/main.cc b/examples/book/drawingarea/pango_text/main.cc
new file mode 100644
index 0000000..f775cb6
--- /dev/null
+++ b/examples/book/drawingarea/pango_text/main.cc
@@ -0,0 +1,35 @@
+/* gtkmm example Copyright (C) 2012 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "myarea.h"
+#include <gtkmm/main.h>
+#include <gtkmm/window.h>
+
+int main(int argc, char* argv[])
+{
+  Gtk::Main kit(argc, argv);
+
+  Gtk::Window window;
+  window.set_title("Drawing text example");
+
+  MyArea area;
+  window.add(area);
+  area.show();
+
+  Gtk::Main::run(window);
+
+  return 0;
+}
diff --git a/examples/book/drawingarea/pango_text/myarea.cc b/examples/book/drawingarea/pango_text/myarea.cc
new file mode 100644
index 0000000..4685f61
--- /dev/null
+++ b/examples/book/drawingarea/pango_text/myarea.cc
@@ -0,0 +1,97 @@
+/* gtkmm example Copyright (C) 2012 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "myarea.h"
+
+MyArea::MyArea()
+{
+}
+
+MyArea::~MyArea()
+{
+}
+
+bool MyArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
+{
+  Gtk::Allocation allocation = get_allocation();
+  const int width = allocation.get_width();
+  const int height = allocation.get_height();
+
+  const int rectangle_width = width;
+  const int rectangle_height = height / 2;
+
+  // Draw a black rectangle
+  cr->set_source_rgb(0.0, 0.0, 0.0);
+  draw_rectangle(cr, rectangle_width, rectangle_height);
+
+  // and some white text
+  cr->set_source_rgb(1.0, 1.0, 1.0);
+  draw_text(cr, rectangle_width, rectangle_height);
+
+  // flip the image vertically
+  // see http://www.cairographics.org/documentation/cairomm/reference/classCairo_1_1Matrix.html
+  // the -1 corresponds to the yy part (the flipping part)
+  // the height part is a translation (we could have just called cr->translate(0, height) instead)
+  // it's height and not height / 2, since we want this to be on the second part of our drawing
+  // (otherwise, it would draw over the previous part)
+  Cairo::Matrix matrix(1.0, 0.0, 0.0, -1.0, 0.0, height);
+
+  // apply the matrix
+  cr->transform(matrix);
+
+  // white rectangle
+  cr->set_source_rgb(1.0, 1.0, 1.0);
+  draw_rectangle(cr, rectangle_width, rectangle_height);
+
+  // black text
+  cr->set_source_rgb(0.0, 0.0, 0.0);
+  draw_text(cr, rectangle_width, rectangle_height);
+
+  return true;
+}
+
+void MyArea::draw_rectangle(const Cairo::RefPtr<Cairo::Context>& cr,
+                            int width, int height)
+{
+  cr->rectangle(0, 0, width, height);
+  cr->fill();
+}
+
+void MyArea::draw_text(const Cairo::RefPtr<Cairo::Context>& cr,
+                       int rectangle_width, int rectangle_height)
+{
+  // http://developer.gnome.org/pangomm/unstable/classPango_1_1FontDescription.html
+  Pango::FontDescription font;
+
+  font.set_family("Monospace");
+  font.set_weight(Pango::WEIGHT_BOLD);
+
+  // http://developer.gnome.org/pangomm/unstable/classPango_1_1Layout.html
+  Glib::RefPtr<Pango::Layout> layout = create_pango_layout("Hi there!");
+
+  layout->set_font_description(font);
+
+  int text_width;
+  int text_height;
+
+  //get the text dimensions (it updates the variables -- by reference)
+  layout->get_pixel_size(text_width, text_height);
+
+  // Position the text in the middle
+  cr->move_to((rectangle_width-text_width)/2, (rectangle_height-text_height)/2);
+
+  layout->show_in_cairo_context(cr);
+}
diff --git a/examples/book/drawingarea/pango_text/myarea.h b/examples/book/drawingarea/pango_text/myarea.h
new file mode 100644
index 0000000..5ff2a01
--- /dev/null
+++ b/examples/book/drawingarea/pango_text/myarea.h
@@ -0,0 +1,38 @@
+/* gtkmm example Copyright (C) 2012 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GTKMM_EXAMPLE_MYAREA_H
+#define GTKMM_EXAMPLE_MYAREA_H
+
+#include <gtkmm/drawingarea.h>
+
+class MyArea : public Gtk::DrawingArea
+{
+public:
+  MyArea();
+  virtual ~MyArea();
+
+protected:
+  //Override default signal handler:
+  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
+
+private:
+  void draw_rectangle(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
+  void draw_text(const Cairo::RefPtr<Cairo::Context>& cr, int rectangle_width, int rectangle_height);
+
+};
+
+#endif // GTKMM_EXAMPLE_MYAREA_H
diff --git a/examples/book/drawingarea/thin_lines/examplewindow.cc b/examples/book/drawingarea/thin_lines/examplewindow.cc
new file mode 100644
index 0000000..6827aea
--- /dev/null
+++ b/examples/book/drawingarea/thin_lines/examplewindow.cc
@@ -0,0 +1,47 @@
+/* gtkmm example Copyright (C) 2012 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "examplewindow.h"
+
+ExampleWindow::ExampleWindow()
+: m_Button_FixLines("Fix lines")
+{
+  set_title("Thin lines example");
+
+  m_Container.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
+
+  m_Container.add(m_Area_Lines);
+  m_Container.add(m_Button_FixLines);
+
+  add(m_Container);
+
+  m_Button_FixLines.signal_toggled().connect(
+    sigc::mem_fun(*this, &ExampleWindow::on_button_toggled));
+
+  // Synchonize the drawing in m_Area_Lines with the state of the toggle button.
+  on_button_toggled();
+
+  show_all_children();
+}
+
+ExampleWindow::~ExampleWindow()
+{
+}
+
+void ExampleWindow::on_button_toggled()
+{
+  m_Area_Lines.fix_lines(m_Button_FixLines.get_active());
+}
diff --git a/examples/book/drawingarea/thin_lines/examplewindow.h b/examples/book/drawingarea/thin_lines/examplewindow.h
new file mode 100644
index 0000000..dc2996b
--- /dev/null
+++ b/examples/book/drawingarea/thin_lines/examplewindow.h
@@ -0,0 +1,41 @@
+/* gtkmm example Copyright (C) 2012 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GTKMM_EXAMPLEWINDOW_H
+#define GTKMM_EXAMPLEWINDOW_H
+
+#include <gtkmm/window.h>
+#include <gtkmm/grid.h>
+#include <gtkmm/checkbutton.h>
+#include "myarea.h"
+
+class ExampleWindow : public Gtk::Window
+{
+public:
+  ExampleWindow();
+  virtual ~ExampleWindow();
+
+protected:
+  //Signal handlers:
+  void on_button_toggled();
+
+private:
+  Gtk::Grid m_Container;
+  MyArea m_Area_Lines;
+  Gtk::CheckButton m_Button_FixLines;
+};
+
+#endif //GTKMM_EXAMPLEWINDOW_H
diff --git a/examples/book/drawingarea/thin_lines/main.cc b/examples/book/drawingarea/thin_lines/main.cc
new file mode 100644
index 0000000..f8a538c
--- /dev/null
+++ b/examples/book/drawingarea/thin_lines/main.cc
@@ -0,0 +1,29 @@
+/* gtkmm example Copyright (C) 2012 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "examplewindow.h"
+#include <gtkmm/main.h>
+
+int main(int argc, char* argv[])
+{
+  Gtk::Main kit(argc, argv);
+
+  ExampleWindow window;
+  //Shows the window and returns when it is closed.
+  Gtk::Main::run(window);
+
+  return 0;
+}
diff --git a/examples/book/drawingarea/thin_lines/myarea.cc b/examples/book/drawingarea/thin_lines/myarea.cc
new file mode 100644
index 0000000..3a8b475
--- /dev/null
+++ b/examples/book/drawingarea/thin_lines/myarea.cc
@@ -0,0 +1,69 @@
+/* gtkmm example Copyright (C) 2012 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "myarea.h"
+
+MyArea::MyArea()
+: m_fix (0)
+{
+  set_size_request (200, 100);
+}
+
+MyArea::~MyArea()
+{
+}
+
+bool MyArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
+{
+  Gtk::Allocation allocation = get_allocation();
+  const int width = allocation.get_width();
+  const int height = allocation.get_height();
+
+  cr->set_line_width(1.0);
+
+  // draw one line, every two pixels
+  // without the 'fix', you won't notice any space between the lines,
+  // since each one will occupy two pixels (width)
+  for (int i = 0; i < width; i += 2)
+  {
+    cr->move_to(i + m_fix, 0);
+    cr->line_to(i + m_fix, height);
+  }
+
+  cr->stroke();
+
+  return true;
+}
+
+// Toogle between both values (0 or 0.5)
+void MyArea::fix_lines(bool fix)
+{
+  // to get the width right, we have to draw in the middle of the pixel
+  m_fix = fix ? 0.5 : 0.0;
+
+  force_redraw();
+}
+
+// force the redraw of the image
+void MyArea::force_redraw()
+{
+  Glib::RefPtr<Gdk::Window> win = get_window();
+  if (win)
+  {
+    Gdk::Rectangle r(0, 0, get_allocation().get_width(), get_allocation().get_height());
+    win->invalidate_rect(r, false);
+  }
+}
diff --git a/examples/book/drawingarea/thin_lines/myarea.h b/examples/book/drawingarea/thin_lines/myarea.h
new file mode 100644
index 0000000..7b16991
--- /dev/null
+++ b/examples/book/drawingarea/thin_lines/myarea.h
@@ -0,0 +1,39 @@
+/* gtkmm example Copyright (C) 2012 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GTKMM_EXAMPLE_MYAREA_H
+#define GTKMM_EXAMPLE_MYAREA_H
+
+#include <gtkmm/drawingarea.h>
+
+class MyArea : public Gtk::DrawingArea
+{
+public:
+  MyArea();
+  virtual ~MyArea();
+
+  void fix_lines(bool fix = true);
+  void force_redraw();
+
+protected:
+  //Override default signal handler:
+  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
+
+private:
+  double m_fix;
+};
+
+#endif // GTKMM_EXAMPLE_MYAREA_H



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]