[gtkmm-documentation] Modify the custom_container and custom_widget examples.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Modify the custom_container and custom_widget examples.
- Date: Sat, 12 Feb 2011 13:32:54 +0000 (UTC)
commit ea06e47e1908d282ee74e62ab58baa91f3e08927
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sun Jan 30 15:50:06 2011 +0100
Modify the custom_container and custom_widget examples.
* .gitignore: Add *~ (gedit's backup files).
* autogen.sh: Add test that mm-common is installed.
* examples/book/custom/custom_widget/mycontainer.[h|cc]:
* examples/book/custom/custom_container/mywidget.[h|cc]: Change int* to
int& in get_preferred_xxx_vfunc().
* examples/book/custom/custom_widget/custom_gtk.css: Minor change in comment.
Bug 639073, comment 19. Bug 628713 (autogen.sh).
.gitignore | 2 +
ChangeLog | 14 ++++++-
.../book/custom/custom_container/mycontainer.cc | 44 +++++++------------
.../book/custom/custom_container/mycontainer.h | 8 ++--
examples/book/custom/custom_widget/custom_gtk.css | 3 +-
examples/book/custom/custom_widget/mywidget.cc | 38 ++++++-----------
examples/book/custom/custom_widget/mywidget.h | 8 ++--
7 files changed, 54 insertions(+), 63 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index a8088f8..6262d1f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,8 @@
Makefile
Makefile.in
stamp-h?
+*~
+
/INSTALL
/aclocal.m4
/autom4te.cache/
diff --git a/ChangeLog b/ChangeLog
index 8a867c5..05a1f8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-02-12 Kjell Ahlstedt <kjell ahlstedt bredband net>
+
+ Modify the custom_container and custom_widget examples.
+
+ * .gitignore: Add *~ (gedit's backup files).
+ * autogen.sh: Add test that mm-common is installed.
+ * examples/book/custom/custom_widget/mycontainer.[h|cc]:
+ * examples/book/custom/custom_container/mywidget.[h|cc]: Change int* to
+ int& in get_preferred_xxx_vfunc().
+ * examples/book/custom/custom_widget/custom_gtk.css: Minor change in comment.
+ Bug 639073, comment 19. Bug 628713 (autogen.sh).
+
2.99.3:
2011-02-02 Murray Cumming <murrayc murrayc com>
@@ -66,7 +78,7 @@
2011-01-23 Kjell Ahlstedt <kjell ahlstedt bredband net>
Modified the custom_container and custom_widget examples.
-
+
* docs/tutorial/C/gtkmm-tutorial-in.xml: Updated the Custom Widgets chapter.
* examples/book/custom/custom_container/examplewindow.[h|cc]: Renamed
m_Button_Two to m_Label_Two. Removed some calls to show().
diff --git a/examples/book/custom/custom_container/mycontainer.cc b/examples/book/custom/custom_container/mycontainer.cc
index 4039a3e..85d58cb 100644
--- a/examples/book/custom/custom_container/mycontainer.cc
+++ b/examples/book/custom/custom_container/mycontainer.cc
@@ -49,7 +49,7 @@ Gtk::SizeRequestMode MyContainer::get_request_mode_vfunc() const
//Discover the total amount of minimum space and natural space needed by
//this container and its children.
-void MyContainer::get_preferred_width_vfunc(int* minimum_width, int* natural_width) const
+void MyContainer::get_preferred_width_vfunc(int& minimum_width, int& natural_width) const
{
int child_minimum_width[2] = {0, 0};
int child_natural_width[2] = {0, 0};
@@ -61,15 +61,12 @@ void MyContainer::get_preferred_width_vfunc(int* minimum_width, int* natural_wid
m_child_two->get_preferred_width(child_minimum_width[1], child_natural_width[1]);
//Request a width equal to the width of the widest visible child.
- if(minimum_width)
- *minimum_width = std::max(child_minimum_width[0], child_minimum_width[1]);
-
- if(natural_width)
- *natural_width = std::max(child_natural_width[0], child_natural_width[1]);
+ minimum_width = std::max(child_minimum_width[0], child_minimum_width[1]);
+ natural_width = std::max(child_natural_width[0], child_natural_width[1]);
}
void MyContainer::get_preferred_height_for_width_vfunc(int width,
- int* minimum_height, int* natural_height) const
+ int& minimum_height, int& natural_height) const
{
int child_minimum_height[2] = {0, 0};
int child_natural_height[2] = {0, 0};
@@ -92,16 +89,13 @@ void MyContainer::get_preferred_height_for_width_vfunc(int width,
//The allocated height will be divided equally among the visible children.
//Request a height equal to the number of visible children times the height
//of the highest child.
- if(minimum_height)
- *minimum_height = nvis_children * std::max(child_minimum_height[0],
- child_minimum_height[1]);
-
- if(natural_height)
- *natural_height = nvis_children * std::max(child_natural_height[0],
- child_natural_height[1]);
+ minimum_height = nvis_children * std::max(child_minimum_height[0],
+ child_minimum_height[1]);
+ natural_height = nvis_children * std::max(child_natural_height[0],
+ child_natural_height[1]);
}
-void MyContainer::get_preferred_height_vfunc(int* minimum_height, int* natural_height) const
+void MyContainer::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const
{
int child_minimum_height[2] = {0, 0};
int child_natural_height[2] = {0, 0};
@@ -122,17 +116,14 @@ void MyContainer::get_preferred_height_vfunc(int* minimum_height, int* natural_h
//The allocated height will be divided equally among the visible children.
//Request a height equal to the number of visible children times the height
//of the highest child.
- if(minimum_height)
- *minimum_height = nvis_children * std::max(child_minimum_height[0],
- child_minimum_height[1]);
-
- if(natural_height)
- *natural_height = nvis_children * std::max(child_natural_height[0],
- child_natural_height[1]);
+ minimum_height = nvis_children * std::max(child_minimum_height[0],
+ child_minimum_height[1]);
+ natural_height = nvis_children * std::max(child_natural_height[0],
+ child_natural_height[1]);
}
void MyContainer::get_preferred_width_for_height_vfunc(int height,
- int* minimum_width, int* natural_width) const
+ int& minimum_width, int& natural_width) const
{
int child_minimum_width[2] = {0, 0};
int child_natural_width[2] = {0, 0};
@@ -159,11 +150,8 @@ void MyContainer::get_preferred_width_for_height_vfunc(int height,
}
//Request a width equal to the width of the widest child.
- if(minimum_width)
- *minimum_width = std::max(child_minimum_width[0], child_minimum_width[1]);
-
- if(natural_width)
- *natural_width = std::max(child_natural_width[0], child_natural_width[1]);
+ minimum_width = std::max(child_minimum_width[0], child_minimum_width[1]);
+ natural_width = std::max(child_natural_width[0], child_natural_width[1]);
}
void MyContainer::on_size_allocate(Gtk::Allocation& allocation)
diff --git a/examples/book/custom/custom_container/mycontainer.h b/examples/book/custom/custom_container/mycontainer.h
index eac4caa..acc9b31 100644
--- a/examples/book/custom/custom_container/mycontainer.h
+++ b/examples/book/custom/custom_container/mycontainer.h
@@ -33,10 +33,10 @@ protected:
//Overrides:
virtual Gtk::SizeRequestMode get_request_mode_vfunc() const;
- virtual void get_preferred_width_vfunc(int* minimum_width, int* natural_width) const;
- virtual void get_preferred_height_for_width_vfunc(int width, int* minimum_height, int* natural_height) const;
- virtual void get_preferred_height_vfunc(int* minimum_height, int* natural_height) const;
- virtual void get_preferred_width_for_height_vfunc(int height, int* minimum_width, int* natural_width) const;
+ virtual void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const;
+ virtual void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const;
+ virtual void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const;
+ virtual void get_preferred_width_for_height_vfunc(int height, int& minimum_width, int& natural_width) const;
virtual void on_size_allocate(Gtk::Allocation& allocation);
virtual void forall_vfunc(gboolean include_internals, GtkCallback callback, gpointer callback_data);
diff --git a/examples/book/custom/custom_widget/custom_gtk.css b/examples/book/custom/custom_widget/custom_gtk.css
index 4e098f6..2354d0b 100644
--- a/examples/book/custom/custom_widget/custom_gtk.css
+++ b/examples/book/custom/custom_widget/custom_gtk.css
@@ -3,8 +3,9 @@
* The name of the style property must have its canonical form, i.e. characters
* other than ASCII letters, digits, and hyphens must be replaced by hyphens.
*/
+
* {
- /* -<widget class name>-<style property canonical name>: <value>;*/
+ /* -<widget class name>-<style property canonical name>: <value>; */
-gtkmm__CustomObject_mywidget-example-scale: 920;
}
diff --git a/examples/book/custom/custom_widget/mywidget.cc b/examples/book/custom/custom_widget/mywidget.cc
index 294cf25..57a0fe4 100644
--- a/examples/book/custom/custom_widget/mywidget.cc
+++ b/examples/book/custom/custom_widget/mywidget.cc
@@ -46,7 +46,7 @@ MyWidget::MyWidget() :
"The scale to use when drawing. This is just a silly example.",
G_MININT,
G_MAXINT,
- 0,
+ 500,
G_PARAM_READABLE) );
m_refStyleProvider = Gtk::CssProvider::create();
@@ -78,42 +78,30 @@ Gtk::SizeRequestMode MyWidget::get_request_mode_vfunc() const
//this widget.
//Let's make this simple example widget always need minimum 60 by 50 and
//natural 100 by 70.
-void MyWidget::get_preferred_width_vfunc(int* minimum_width, int* natural_width) const
+void MyWidget::get_preferred_width_vfunc(int& minimum_width, int& natural_width) const
{
- if (minimum_width)
- *minimum_width = 60;
-
- if (natural_width)
- *natural_width = 100;
+ minimum_width = 60;
+ natural_width = 100;
}
void MyWidget::get_preferred_height_for_width_vfunc(int /* width */,
- int* minimum_height, int* natural_height) const
+ int& minimum_height, int& natural_height) const
{
- if (minimum_height)
- *minimum_height = 50;
-
- if (natural_height)
- *natural_height = 70;
+ minimum_height = 50;
+ natural_height = 70;
}
-void MyWidget::get_preferred_height_vfunc(int* minimum_height, int* natural_height) const
+void MyWidget::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const
{
- if (minimum_height)
- *minimum_height = 50;
-
- if (natural_height)
- *natural_height = 70;
+ minimum_height = 50;
+ natural_height = 70;
}
void MyWidget::get_preferred_width_for_height_vfunc(int /* height */,
- int* minimum_width, int* natural_width) const
+ int& minimum_width, int& natural_width) const
{
- if (minimum_width)
- *minimum_width = 60;
-
- if (natural_width)
- *natural_width = 100;
+ minimum_width = 60;
+ natural_width = 100;
}
void MyWidget::on_size_allocate(Gtk::Allocation& allocation)
diff --git a/examples/book/custom/custom_widget/mywidget.h b/examples/book/custom/custom_widget/mywidget.h
index edf3e4f..ed78dc1 100644
--- a/examples/book/custom/custom_widget/mywidget.h
+++ b/examples/book/custom/custom_widget/mywidget.h
@@ -32,10 +32,10 @@ protected:
//Overrides:
virtual Gtk::SizeRequestMode get_request_mode_vfunc() const;
- virtual void get_preferred_width_vfunc(int* minimum_width, int* natural_width) const;
- virtual void get_preferred_height_for_width_vfunc(int width, int* minimum_height, int* natural_height) const;
- virtual void get_preferred_height_vfunc(int* minimum_height, int* natural_height) const;
- virtual void get_preferred_width_for_height_vfunc(int height, int* minimum_width, int* natural_width) const;
+ virtual void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const;
+ virtual void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const;
+ virtual void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const;
+ virtual void get_preferred_width_for_height_vfunc(int height, int& minimum_width, int& natural_width) const;
virtual void on_size_allocate(Gtk::Allocation& allocation);
virtual void on_map();
virtual void on_unmap();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]