[gtkmm] demos: Fix the build.



commit f998df5c0b1c2ea797ff14e43dc8e756d6a73bbc
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Sep 15 10:32:59 2010 +0200

    demos: Fix the build.
    
    * demos/pixbuf-demo.cc:
    * demos/gtk-demo/example_change_display.cc:
    * demos/gtk-demo/example_drawingarea.cc:
    * demos/gtk-demo/example_menus.cc:
    * demos/gtk-demo/example_pixbufs.cc:
    * demos/gtk-demo/example_textview.cc: Adapt to use cairomm instead of
      gdkmm draw_*() and Gdk::GC.
      Remove use of Dialog::set_has_separator().
      Replace use of MenuHelpers.
    
    * gdk/gdkmm/general.h: set_source_pixmap(): Add default parameter values
      for pixmap_x and pixmap_y.

 ChangeLog                                |   17 +++++-
 demos/gtk-demo/example_change_display.cc |   38 +++++------
 demos/gtk-demo/example_drawingarea.cc    |  104 +++++++++++-------------------
 demos/gtk-demo/example_menus.cc          |   73 +++++++++++----------
 demos/gtk-demo/example_pixbufs.cc        |   19 ++----
 demos/gtk-demo/example_textview.cc       |   23 +------
 demos/pixbuf-demo.cc                     |   16 ++---
 gdk/gdkmm/general.h                      |    5 +-
 gdk/src/window.ccg                       |    7 +-
 9 files changed, 131 insertions(+), 171 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fa20fcd..0c139f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,19 @@
-2.90.7:
+2010-09-15  Murray Cumming  <murrayc murrayc com>
+
+	demos: Fix the build.
+
+	* demos/pixbuf-demo.cc:
+	* demos/gtk-demo/example_change_display.cc:
+	* demos/gtk-demo/example_drawingarea.cc:
+	* demos/gtk-demo/example_menus.cc:
+	* demos/gtk-demo/example_pixbufs.cc:
+	* demos/gtk-demo/example_textview.cc: Adapt to use cairomm instead of
+  gdkmm draw_*() and Gdk::GC.
+  Remove use of Dialog::set_has_separator().
+  Replace use of MenuHelpers.
+
+	* gdk/gdkmm/general.h: set_source_pixmap(): Add default parameter values
+  for pixmap_x and pixmap_y.
 
 2010-09-14  Murray Cumming  <murrayc murrayc com>
 
diff --git a/demos/gtk-demo/example_change_display.cc b/demos/gtk-demo/example_change_display.cc
index a3361a5..8a29ef9 100644
--- a/demos/gtk-demo/example_change_display.cc
+++ b/demos/gtk-demo/example_change_display.cc
@@ -55,7 +55,7 @@ protected:
   virtual void query_change_display();
   virtual Gtk::Widget* find_toplevel_at_pointer(const Glib::RefPtr<Gdk::Display>& display);
   virtual Gtk::Window* query_for_toplevel(const Glib::RefPtr<Gdk::Screen>& screen, const Glib::ustring& prompt);
-  
+
   //signal handlers:
   virtual void on_button_display_open();
   virtual void on_button_display_close();
@@ -66,7 +66,7 @@ protected:
   virtual void on_display_closed(bool is_error, Glib::RefPtr<Gdk::Display> display);
 
   virtual bool on_popup_button_release_event(GdkEventButton* event);
-        
+
   virtual void on_response(int response_id);
 
 
@@ -89,7 +89,7 @@ protected:
     ModelColumns_Screen() { add(m_number); add(m_screen); }
   };
   ModelColumns_Screen m_columns_screen;
-  
+
   Gtk::VBox m_VBox;
   Gtk::Frame m_Frame_Display, m_Frame_Screen;
   Gtk::TreeView m_TreeView_Display, m_TreeView_Screen;
@@ -100,13 +100,13 @@ protected:
 
   Glib::RefPtr<Gtk::SizeGroup> m_refSizeGroup_Display, m_refSizeGroup_Screen;
 
-  
+
   Glib::RefPtr<Gdk::Display> m_refCurrentDisplay;
   Glib::RefPtr<Gdk::Screen> m_refCurrentScreen;
 
   Popup* m_pPopup;
 
-  bool m_popup_clicked;                                                                                       
+  bool m_popup_clicked;
 };
 
 
@@ -122,13 +122,11 @@ Example_ChangeDisplay::Example_ChangeDisplay()
   m_pPopup(0),
   m_popup_clicked(false)
 {
-  set_has_separator(false);
-  
   add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
   add_button("Change", Gtk::RESPONSE_OK);
 
   set_default_size(300, 400);
-  
+
   m_VBox.set_border_width(8);
   get_vbox()->pack_start(m_VBox);
 
@@ -155,7 +153,7 @@ Example_ChangeDisplay::Example_ChangeDisplay()
     m_refSizeGroup_Display = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_HORIZONTAL);
     m_refSizeGroup_Display->add_widget(m_ButtonBox_Display);
   }
-  
+
   //Screen:
   {
     setup_frame(m_Frame_Screen, m_TreeView_Screen, m_ButtonBox_Screen);
@@ -221,7 +219,7 @@ void Example_ChangeDisplay::initialize_displays()
   for(type_listDisplays::iterator iter = listDisplays.begin(); iter != listDisplays.end(); ++iter)
   {
     Glib::RefPtr<Gdk::Display> refDisplay = *iter;
-      
+
     Gtk::TreeRow row = *(m_refListStore_Display->append());
     row[m_columns_display.m_name] = refDisplay->get_name();;
     row[m_columns_display.m_display] = refDisplay;
@@ -230,7 +228,7 @@ void Example_ChangeDisplay::initialize_displays()
       sigc::bind<-1>( sigc::mem_fun(*this, &Example_ChangeDisplay::on_display_closed), refDisplay) );
   }
 
-#endif   
+#endif
 }
 
 void Example_ChangeDisplay::on_display_closed(bool /* is_error */, Glib::RefPtr<Gdk::Display> display)
@@ -273,7 +271,7 @@ void Example_ChangeDisplay::on_button_display_open()
     if (response_id != Gtk::RESPONSE_OK)
       break;
 
-    Glib::ustring new_screen_name = entry.get_text(); 
+    Glib::ustring new_screen_name = entry.get_text();
 
     if( !new_screen_name.empty() )
     {
@@ -301,7 +299,7 @@ void Example_ChangeDisplay::on_treeview_display_selection_changed()
   else
     m_refCurrentDisplay.clear();
 
-  fill_screens();  
+  fill_screens();
 }
 
 void Example_ChangeDisplay::on_treeview_screen_selection_changed()
@@ -323,11 +321,11 @@ void Example_ChangeDisplay::fill_screens()
   if(m_refCurrentScreen)
   {
     int n_screens = m_refCurrentDisplay->get_n_screens();
-   
+
     for (int i = 0; i < n_screens; i++)
     {
       Glib::RefPtr<Gdk::Screen> refScreen = m_refCurrentDisplay->get_screen(i);
-      
+
       Gtk::TreeModel::Row row = *(m_refListStore_Screen->append());
       row[m_columns_screen.m_number] = i;
       row[m_columns_screen.m_screen] = refScreen;
@@ -381,7 +379,7 @@ Gtk::Window* Example_ChangeDisplay::query_for_toplevel(const Glib::RefPtr<Gdk::S
     delete m_pPopup;
     m_pPopup = 0;
   }
-   
+
   m_pPopup = new Popup(screen, prompt);
 
   m_pPopup->show();
@@ -389,13 +387,13 @@ Gtk::Window* Example_ChangeDisplay::query_for_toplevel(const Glib::RefPtr<Gdk::S
   Gdk::Cursor cursor(refDisplay, Gdk::CROSSHAIR);
 
   Gtk::Window* toplevel = 0;
-  
+
   if( m_pPopup->get_window()->pointer_grab(false, Gdk::BUTTON_RELEASE_MASK, cursor, GDK_CURRENT_TIME)
      == Gdk::GRAB_SUCCESS )
   {
     m_popup_clicked = false;
     m_pPopup->signal_button_release_event().connect( sigc::mem_fun(*this, &Example_ChangeDisplay::on_popup_button_release_event) );
-    
+
 
     // Process events until clicked is set by button_release_event_cb.
     // We pass in may_block=true since we want to wait if there
@@ -462,12 +460,10 @@ Popup::Popup(const Glib::RefPtr<Gdk::Screen> screen, const Glib::ustring& prompt
 Popup::~Popup()
 {
 }
- 
+
 
 // called by DemoWindow
 Gtk::Window* do_change_display()
 {
   return new Example_ChangeDisplay();
 }
-
-
diff --git a/demos/gtk-demo/example_drawingarea.cc b/demos/gtk-demo/example_drawingarea.cc
index a79707b..1393278 100644
--- a/demos/gtk-demo/example_drawingarea.cc
+++ b/demos/gtk-demo/example_drawingarea.cc
@@ -37,7 +37,7 @@ protected:
   Gtk::Label m_Label_Checkerboard, m_Label_Scribble;
   Gtk::DrawingArea m_DrawingArea_Checkerboard, m_DrawingArea_Scribble;
 
-  Glib::RefPtr<Gdk::Pixmap> m_refPixmap_Scribble;
+  Cairo::RefPtr<Cairo::Surface> m_surface;
 };
 
 //Called by DemoWindow;
@@ -111,7 +111,7 @@ Example_DrawingArea::~Example_DrawingArea()
 {
 }
 
-bool Example_DrawingArea::on_drawingarea_checkerboard_expose_event(GdkEventExpose*)
+bool Example_DrawingArea::on_drawingarea_checkerboard_expose_event(GdkEventExpose* event)
 {
   enum { CHECK_SIZE = 10, SPACING = 2 };
 
@@ -122,46 +122,33 @@ bool Example_DrawingArea::on_drawingarea_checkerboard_expose_event(GdkEventExpos
    * works.
    */
 
-  /* It would be a bit more efficient to keep these
-   * GC's around instead of recreating on each expose, but
-   * this is the lazy/slow way.
-   */
-  Glib::RefPtr<Gdk::GC> refGC1 = Gdk::GC::create(m_DrawingArea_Checkerboard.get_window());
-  Gdk::Color color;
-  color.set_red(30000);
-  color.set_green(0);
-  color.set_blue(30000);
-  refGC1->set_rgb_fg_color(color);
-
-  Glib::RefPtr<Gdk::GC> refGC2 = Gdk::GC::create(m_DrawingArea_Checkerboard.get_window());
-  color.set_red(65535);
-  color.set_green(65535);
-  color.set_blue(65535);
-  refGC2->set_rgb_fg_color(color);
-
-  gint xcount = 0;
-  gint i = SPACING;
-  while (i < m_DrawingArea_Checkerboard.get_allocation().get_width())
+  Glib::RefPtr<Gdk::Window> window = get_window();
+  Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+
+  const Gdk::Rectangle rectangle(&(event->area));
+  Gdk::Cairo::add_rectangle_to_path(cr, rectangle);
+  cr->clip();
+
+  int xcount = 0;
+  int i = SPACING;
+  const int width = m_DrawingArea_Checkerboard.get_allocation().get_width();
+  while (i < width)
   {
-    gint j = SPACING;
-    gint ycount = xcount % 2; /* start with even/odd depending on row */
+    int j = SPACING;
+    int ycount = xcount % 2; /* start with even/odd depending on row */
     while (j < m_DrawingArea_Checkerboard.get_allocation().get_height())
     {
-      Glib::RefPtr<Gdk::GC> refGC;
-    	
       if (ycount % 2)
-        refGC = refGC1;
+        cr->set_source_rgb(0.45777, 0, 0.45777);
       else
-        refGC = refGC2;
+        cr->set_source_rgb(1, 1, 1);
 
       /* If we're outside event->area, this will do nothing.
        * It might be mildly more efficient if we handled
        * the clipping ourselves, but again we're feeling lazy.
        */
-      m_DrawingArea_Checkerboard.get_window()->draw_rectangle(refGC,
-    		      true,
-    		      i, j,
-    		      CHECK_SIZE, CHECK_SIZE);
+      cr->rectangle(i, j, CHECK_SIZE, CHECK_SIZE);
+      cr->fill();
 
       j += CHECK_SIZE + SPACING;
       ++ycount;
@@ -179,36 +166,26 @@ bool Example_DrawingArea::on_drawingarea_checkerboard_expose_event(GdkEventExpos
 
 bool Example_DrawingArea::on_drawingarea_scribble_expose_event(GdkEventExpose* event)
 {
-  /* We use the "foreground GC" for the widget since it already exists,
-   * but honestly any GC would work. The only thing to worry about
-   * is whether the GC has an inappropriate clip region set.
-   */
-  m_DrawingArea_Scribble.get_window()->draw_drawable(
-      m_DrawingArea_Scribble.get_style()->get_fg_gc(m_DrawingArea_Scribble.get_state()),
-      m_refPixmap_Scribble,
-      // Only copy the area that was exposed:
-      event->area.x, event->area.y,
-      event->area.x, event->area.y,
-      event->area.width, event->area.height);
+  Glib::RefPtr<Gdk::Window> window = get_window();
+  Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+  cr->set_source(m_surface, 0, 0); //TODO: Add =0 default parameters to cairomm.
+
+  const Gdk::Rectangle rectangle(&(event->area));
+  Gdk::Cairo::add_rectangle_to_path(cr, rectangle);
+  cr->clip();
 
   return false;
 }
 
 bool Example_DrawingArea::on_drawingarea_scribble_configure_event(GdkEventConfigure*)
 {
-  m_refPixmap_Scribble = Gdk::Pixmap::create(
-      m_DrawingArea_Scribble.get_window(),
-      m_DrawingArea_Scribble.get_allocation().get_width(),
-      m_DrawingArea_Scribble.get_allocation().get_height(),
-      -1);
-
-  /* Initialize the pixmap to white */
-  m_refPixmap_Scribble->draw_rectangle(
-      m_DrawingArea_Scribble.get_style()->get_white_gc(),
-      true,
-      0, 0,
-      m_DrawingArea_Scribble.get_allocation().get_width(),
-      m_DrawingArea_Scribble.get_allocation().get_height());
+  const Gtk::Allocation allocation = m_DrawingArea_Scribble.get_allocation();
+  m_surface =
+    m_DrawingArea_Scribble.get_window()->create_similar_surface(
+      Cairo::CONTENT_COLOR, allocation.get_width(), allocation.get_height());
+  Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(m_surface);
+  cr->set_source_rgb(1, 1, 1);
+  cr->paint();
 
   /* We've handled the configure event, no need for further processing. */
   return true;
@@ -216,7 +193,7 @@ bool Example_DrawingArea::on_drawingarea_scribble_configure_event(GdkEventConfig
 
 bool Example_DrawingArea::on_drawingarea_scribble_motion_notify_event(GdkEventMotion* event)
 {
-  if(!m_refPixmap_Scribble)
+  if(!m_surface)
     return false; // paranoia check, in case we haven't gotten a configure event
 
   /* This call is very important; it requests the next motion event.  If you
@@ -250,7 +227,7 @@ bool Example_DrawingArea::on_drawingarea_scribble_motion_notify_event(GdkEventMo
 
 bool Example_DrawingArea::on_drawingarea_scribble_button_press_event(GdkEventButton* event)
 {
-  if(!m_refPixmap_Scribble)
+  if(!m_surface)
     return false; // paranoia check, in case we haven't gotten a configure event
 
   if(event->button == 1)
@@ -266,15 +243,10 @@ void Example_DrawingArea::scribble_draw_brush(int x, int y)
 {
   const Gdk::Rectangle update_rect (x - 3, y - 3, 6, 6);
 
-  // Paint to the pixmap, where we store our state.
-  //
-  m_refPixmap_Scribble->draw_rectangle(
-      m_DrawingArea_Scribble.get_style()->get_black_gc(),
-      true,
-      update_rect.get_x(), update_rect.get_y(),
-      update_rect.get_width(), update_rect.get_height());
+  Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(m_surface);
+  Gdk::Cairo::add_rectangle_to_path(cr, update_rect);
+  cr->fill();
 
   // Now invalidate the affected region of the drawing area.
   m_DrawingArea_Scribble.get_window()->invalidate_rect(update_rect, false);
 }
-
diff --git a/demos/gtk-demo/example_menus.cc b/demos/gtk-demo/example_menus.cc
index a286c53..770de86 100644
--- a/demos/gtk-demo/example_menus.cc
+++ b/demos/gtk-demo/example_menus.cc
@@ -67,21 +67,22 @@ Example_Menus::Example_Menus()
   m_VBox1.pack_start(m_MenuBar, Gtk::PACK_SHRINK);
 
   {
-    using namespace Gtk::Menu_Helpers;
-    MenuList items = m_MenuBar.items();
-
-    items.push_back(MenuElem("test\nline2"));
-    Gtk::MenuItem* pMenuItem = &items.back();
+    //Note:: It's generally easier to use the Gtk::UIManager API.
+    Gtk::MenuItem* pMenuItem = Gtk::manage(new Gtk::MenuItem("test\nline2"));
     pMenuItem->set_submenu( *(create_menu(2, true)) );
+    m_MenuBar.append(*pMenuItem);
+    pMenuItem->show();
 
-    items.push_back(MenuElem("foo"));
-    pMenuItem = &items.back();
+    pMenuItem = Gtk::manage(new Gtk::MenuItem("foo"));
     pMenuItem->set_submenu( *(create_menu(3, true)) );
+    m_MenuBar.append(*pMenuItem);
+    pMenuItem->show();
 
-    items.push_back(MenuElem("bar"));
-    pMenuItem = &items.back();
+    pMenuItem = Gtk::manage(new Gtk::MenuItem("bar"));
     pMenuItem->set_submenu( *(create_menu(4, true)) );
     pMenuItem->set_right_justified();
+    m_MenuBar.append(*pMenuItem);
+    pMenuItem->show();
   }
 
 
@@ -92,16 +93,24 @@ Example_Menus::Example_Menus()
     Gtk::Menu* pMenu = create_menu(1, false);
     pMenu->set_accel_group(get_accel_group());
 
-    using namespace Gtk::Menu_Helpers;
-    MenuList items = pMenu->items();
+    Gtk::MenuItem* pMenuItem = Gtk::manage(new Gtk::SeparatorMenuItem());
+    pMenu->append(*pMenuItem);
+    pMenuItem->show();
+
+    pMenuItem = Gtk::manage(new Gtk::CheckMenuItem("Accelerate Me"));
+    pMenuItem->add_accelerator("activate", get_accel_group(), GDK_KEY_F1, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE );
+    pMenu->append(*pMenuItem);
+    pMenuItem->show();
 
-    items.push_back(SeparatorElem());
-    items.push_back( CheckMenuElem("Accelerate Me", Gtk::AccelKey(GDK_F1, Gdk::ModifierType(0))) );
-    items.push_back( CheckMenuElem("Accelerator Locked") );
-    items.back().add_accelerator("activate", get_accel_group(), GDK_F2, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE | Gtk::ACCEL_LOCKED);
-    items.push_back( CheckMenuElem("Accelerator Frozen") );
-    items.back().add_accelerator("activate", get_accel_group(), GDK_F2, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE);
-    items.back().add_accelerator("activate", get_accel_group(), GDK_F3, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE);
+    pMenuItem = Gtk::manage(new Gtk::CheckMenuItem("Accelerator Locked"));
+    pMenu->append(*pMenuItem);
+    pMenuItem->add_accelerator("activate", get_accel_group(), GDK_KEY_F2, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE | Gtk::ACCEL_LOCKED);
+    pMenuItem->show();
+
+    pMenuItem = Gtk::manage(new Gtk::CheckMenuItem("Accelerator Frozen"));
+    pMenu->append(*pMenuItem);
+    pMenuItem->add_accelerator("activate", get_accel_group(), GDK_KEY_F2, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE);
+    pMenuItem->show();
   }
 
   m_VBox1.pack_start(m_Separator, Gtk::PACK_SHRINK);
@@ -131,13 +140,11 @@ Gtk::Menu* Example_Menus::create_menu(gint depth, bool tearoff)
   Gtk::Menu* pMenu = Gtk::manage(new Gtk::Menu());
 
   {
-    using namespace Gtk::Menu_Helpers;
-
-    MenuList items = pMenu->items();
-
     if(tearoff)
     {
-      items.push_back(TearoffMenuElem());
+      Gtk::MenuItem* menu_item = Gtk::manage(new Gtk::TearoffMenuItem());
+      pMenu->append(*menu_item);
+      menu_item->show();
     }
 
     Gtk::RadioMenuItem::Group radiogroup;
@@ -147,18 +154,16 @@ Gtk::Menu* Example_Menus::create_menu(gint depth, bool tearoff)
       char buf[32];
       sprintf(buf, "item %2d - %d", depth, j);
 
-      items.push_back(RadioMenuElem(radiogroup, buf));
+      Gtk::MenuItem* pMenuItem = Gtk::manage(new Gtk::RadioMenuItem(radiogroup, buf));
+      pMenu->append(*pMenuItem);
+      pMenuItem->show();
 
-      Gtk::MenuItem* pMenuItem = &items.back();
-      if(pMenuItem)
-      {
-        if(i == 3)
-          pMenuItem->set_sensitive(false);
+      if(i == 3)
+        pMenuItem->set_sensitive(false);
 
-        Gtk::Menu* pSubMenu = create_menu(depth - 1, true);
-        if(pSubMenu)
-         pMenuItem->set_submenu(*pSubMenu);
-      }
+      Gtk::Menu* pSubMenu = create_menu(depth - 1, true);
+      if(pSubMenu)
+        pMenuItem->set_submenu(*pSubMenu);
     }
   }
 
@@ -169,5 +174,3 @@ void Example_Menus::on_button_clicked()
 {
   hide();
 }
-
-
diff --git a/demos/gtk-demo/example_pixbufs.cc b/demos/gtk-demo/example_pixbufs.cc
index d6af32f..1106f67 100644
--- a/demos/gtk-demo/example_pixbufs.cc
+++ b/demos/gtk-demo/example_pixbufs.cc
@@ -126,19 +126,13 @@ void Example_Pixbufs::load_pixbufs()
 /* Expose callback for the drawing area */
 bool Example_Pixbufs::on_drawingarea_expose(GdkEventExpose *event)
 {
-  gint rowstride = m_refPixbuf->get_rowstride();
+  Glib::RefPtr<Gdk::Window> window = get_window();
+  Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+  Gdk::Cairo::set_source_pixbuf(cr, m_refPixbuf_Background);
 
-  const guchar* pixels = m_refPixbuf->get_pixels() + (rowstride * event->area.y) + (event->area.x * 3);
-
-  Glib::RefPtr<Gdk::Window> refWindow = m_DrawingArea.get_window();
-  Glib::RefPtr<Gdk::GC> refGC = m_DrawingArea.get_style()->get_black_gc();
-
-  refWindow->draw_rgb_image_dithalign(refGC,
-				event->area.x, event->area.y,
-				event->area.width, event->area.height,
-				Gdk::RGB_DITHER_NORMAL,
-				pixels, rowstride,
-				event->area.x, event->area.y);
+  const Gdk::Rectangle rectangle(&(event->area));
+  Gdk::Cairo::add_rectangle_to_path(cr, rectangle);
+  cr->fill();
 
   return true;
 }
@@ -204,4 +198,3 @@ bool Example_Pixbufs::on_timeout()
   m_frame_num++;
   return true;
 }
-
diff --git a/demos/gtk-demo/example_textview.cc b/demos/gtk-demo/example_textview.cc
index 73549a6..8f36868 100644
--- a/demos/gtk-demo/example_textview.cc
+++ b/demos/gtk-demo/example_textview.cc
@@ -136,14 +136,6 @@ void Example_TextView::create_tags(Glib::RefPtr<Gtk::TextBuffer>& refBuffer)
   refBuffer->create_tag("blue_foreground")->property_foreground() = "blue";
   refBuffer->create_tag("red_background")->property_background() = "red";
 
-  enum { gray50_width = 2, gray50_height = 2 };
-  static const char gray50_bits[] = { 0x02, 0x01 };
-
-  Glib::RefPtr<Gdk::Bitmap> refStipple = Gdk::Bitmap::create(gray50_bits, gray50_width, gray50_height);
-
-  refBuffer->create_tag("background_stipple")->property_background_stipple() = refStipple;
-  refBuffer->create_tag("foreground_stipple")->property_foreground_stipple() = refStipple;
-
   refBuffer->create_tag("big_gap_before_line")->property_pixels_above_lines() = 30;
   refBuffer->create_tag("big_gap_after_line")->property_pixels_below_lines() = 30;
   refBuffer->create_tag("double_spaced_line")->property_pixels_inside_wrap() = 10;
@@ -224,18 +216,10 @@ void Example_TextView::insert_text(Glib::RefPtr<Gtk::TextBuffer>& refBuffer)
   iter = refBuffer->insert_with_tag(iter, "a red background", "red_background");
   iter = refBuffer->insert(iter, " or even ");
 
-
   typedef const char* type_constpch;
   {
-    type_constpch tag_names[] = {"red_background", "background_stipple", 0};
-    iter = refBuffer->insert_with_tags_by_name(iter, "a stippled red background", tag_names);
-  }
-
-  iter = refBuffer->insert(iter, " or ");
-
-  {
-    type_constpch tag_names[] = {"blue_foreground", "red_background", "foreground_stipple", 0};
-    iter = refBuffer->insert_with_tags_by_name(iter, "a stippled blue foreground on solid red background", tag_names);
+    type_constpch tag_names[] = {"blue_foreground", "red_background", 0};
+    iter = refBuffer->insert_with_tags_by_name(iter, "a blue foreground on red background", tag_names);
   }
 
   iter = refBuffer->insert(iter, " (select that to read it) can be used.\n\n");
@@ -312,7 +296,7 @@ void Example_TextView::insert_text(Glib::RefPtr<Gtk::TextBuffer>& refBuffer)
 					    "wide_margins");
 
   iter = refBuffer->insert_with_tag(iter, "Internationalization. ", "heading");
-	
+
   iter = refBuffer->insert(iter,
       "You can put all sorts of Unicode text in the buffer.\n\nGerman (Deutsch S\xC3\xBC""d) "
       "Gr\xC3\xBC\xC3\x9F Gott\nGreek (\xCE\x95\xCE\xBB\xCE\xBB\xCE\xB7\xCE\xBD\xCE\xB9\xCE\xBA"
@@ -485,4 +469,3 @@ void Window_EasterEgg::recursive_attach_view(int depth, Gtk::TextView& view, Gli
   view.add_child_at_anchor(*pEventBox, refAnchor);
   recursive_attach_view (depth + 1, *pChildView, refAnchor);
 }
-
diff --git a/demos/pixbuf-demo.cc b/demos/pixbuf-demo.cc
index 5db9244..ae21484 100644
--- a/demos/pixbuf-demo.cc
+++ b/demos/pixbuf-demo.cc
@@ -36,6 +36,7 @@
 #include <gtkmm/main.h>
 #include <gtkmm/style.h>
 #include <gtkmm/window.h>
+#include <gdkmm/general.h>
 
 namespace
 {
@@ -127,15 +128,13 @@ DemoRenderArea::~DemoRenderArea()
  */
 bool DemoRenderArea::on_expose_event(GdkEventExpose* event)
 {
-  const int rowstride = current_frame_->get_rowstride();
-  const size_t offset = rowstride * event->area.y + 3 * event->area.x;
+  Glib::RefPtr<Gdk::Window> window = get_window();
+  Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+  Gdk::Cairo::set_source_pixbuf(cr, current_frame_);
 
-  get_window()->draw_rgb_image_dithalign(
-      get_style()->get_black_gc(),
-      event->area.x, event->area.y, event->area.width, event->area.height,
-      Gdk::RGB_DITHER_NORMAL,
-      &current_frame_->get_pixels()[offset], rowstride,
-      event->area.x, event->area.y);
+  const Gdk::Rectangle rectangle(&(event->area));
+  Gdk::Cairo::add_rectangle_to_path(cr, rectangle);
+  cr->fill();
 
   return true; // stop signal emission
 }
@@ -217,4 +216,3 @@ int main(int argc, char** argv)
   }
   return EXIT_SUCCESS;
 }
-
diff --git a/gdk/gdkmm/general.h b/gdk/gdkmm/general.h
index ba92936..e8ea691 100644
--- a/gdk/gdkmm/general.h
+++ b/gdk/gdkmm/general.h
@@ -45,6 +45,7 @@ namespace Cairo
  * @newin{2,10}
  */
 void set_source_color(const ::Cairo::RefPtr< ::Cairo::Context >& context, const Gdk::Color& color);
+
 /** Sets the given pixbuf as the source pattern for the Cairo context. The pattern has an extend mode of CAIRO_EXTEND_NONE and is aligned so that the origin of pixbuf is pixbuf_x, pixbuf_y.
  * @param @context The cairo context.
  * @param pixbuf A Gdk::Pixbuf
@@ -53,7 +54,7 @@ void set_source_color(const ::Cairo::RefPtr< ::Cairo::Context >& context, const
  *
  * @newin{2,10}
  */
-void set_source_pixbuf(const ::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double pixbuf_x, double pixbuf_y);
+void set_source_pixbuf(const ::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double pixbuf_x = 0, double pixbuf_y = 0);
 
 /** Sets the given pixbuf as the source pattern for the Cairo context. The pattern has an extend mode of CAIRO_EXTEND_NONE and is aligned so that the origin of pixbuf is pixmap_x, pixmap_y.
  * @param @context The cairo context.
@@ -64,7 +65,7 @@ void set_source_pixbuf(const ::Cairo::RefPtr< ::Cairo::Context >& context, const
  *
  * @newin{2,10}
  */
-void set_source_pixmap(const ::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr<Gdk::Pixmap>& pixmap, double pixmap_x, double pixmap_y);
+void set_source_pixmap(const ::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr<Gdk::Pixmap>& pixmap, double pixmap_x = 0, double pixmap_y = 0);
 
 /** Adds the given rectangle to the current path of the context.
  *
diff --git a/gdk/src/window.ccg b/gdk/src/window.ccg
index c0109cb..55ca8d9 100644
--- a/gdk/src/window.ccg
+++ b/gdk/src/window.ccg
@@ -63,9 +63,9 @@ void Window::unset_sm_client_id()
 
 void Window::set_icon(const Glib::RefPtr<Window>& icon_window, const Glib::RefPtr<Pixmap>& pixmap)
 {
-  gdk_window_set_icon(gobj(), icon_window->gobj(), pixmap->gobj(), 0); /* See GDK docs */  
+  gdk_window_set_icon(gobj(), icon_window->gobj(), pixmap->gobj(), 0); /* See GDK docs */
 }
-  
+
 void Window::unset_icon()
 {
   gdk_window_set_icon(gobj(), 0, 0, 0); /* See GDK docs */
@@ -74,7 +74,7 @@ void Window::unset_icon()
 void Window::unset_shape_combine_mask()
 {
   gdk_window_shape_combine_mask(gobj(), 0, 0, 0); //See GDK docs.
-} 
+}
 
 void Window::get_internal_paint_info(Glib::RefPtr<Drawable>& real_drawable, int& x_offset, int& y_offset) const
 {
@@ -99,4 +99,3 @@ void Window::restack(bool above)
 }
 
 } // namespace Gdk
-



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