[gtkmm] Adding more C++ power to Gtkmm
- From: "r ve" <kaas_10 hotmail com>
- To: gtkmm-list gnome org
- Subject: [gtkmm] Adding more C++ power to Gtkmm
- Date: Sun, 06 Apr 2003 00:37:24 +0200
Some time ago, I've been complaining that Gtkmm does things too much C-like.
Because things won't change when keeping my mouth shut, here's a few
suggestions that I would really like to see added in Gtkmm.
One example of something 'C-like' in Gtkmm is that some methods contain far
too many arguments.
Here's a method with 16 (!!) arguments:
- Gdk::Pixbuf::composite_color(const Glib::RefPtr<Gdk::Pixbuf>& dest, int
dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double
offset_y, double scale_x, double scale_y, InterpType interp_type, int
overall_alpha, int check_x, int check_y, int check_size, guint32 color1,
guint32 color2)
These arguments could be reduced to 13 arguments by rewriting it to this:
- Gdk::Pixbuf::composite_color(const Glib::RefPtr<Gdk::Pixbuf& dest,
Gdk::Rectangle& dest_rect, double offset_x, double offset_y, double scale_x,
double scale_y, InterpType interp_type, int overall_alpha, int check_x, int
check_y, int check_size, guint32 color1, guint32 color2)
It could be reduced to 10 arguments by modifying the Gdk::Point class to
become a template (would be useful for a few other classes as well):
- Gdk::Pixbuf::composite_color(const Glib::RefPtr<Gdk::Pixbuf& dest,
Gdk::Rectangle& dest_rect, Gdk::Point<double>& offset, Gdk::Point<double>&
scale, InterpType interp_type, int overall_alpha, Gdk::Point<int>&
check_offset, int check_size, guint32 color1, guint32 color2)
Well, I think you get the point :)
10 arguments is still quite a lot imho, but it's much better than 16 (!)
arguments.
Other things that could be done to improve Gtkmm is to add more overloaded
operators.
The Gdk::Point class, for example, does only overload the == and !=
operators, but this class could be much more useful if it had operators for
adding, subtracting and multiplying Gdk::Points.
On top of that, the Gdk::Point class doesn't have a Point(const Point& rhs)
constructor, which can also prove to be useful at some times.
The Gdk::Rectangle class doesn't overload _any_ operator, that's bad because
it's a pain to write something like this:
if ((rect1->get_x() != rect2->get_x()) && (rect1->get_y() != rect2->get_y())
&& (rect1->get_width() != rect2->get_width() && (rect1->get_height() !=
rect2->get_height()) bleh;
Instead of:
if (rect1 != rect2) bleh;
Which is not only much easier on the eyes, but faster to type as well.
Also, it would be really nice if virtual methods (signals) wouldn't be like
this (the C way):
virtual void on_set_focus(Widget* focus); // set_focus signal for
Gtk::Window
But rather like this (the C++ way):
virtual void on_set_focus(Gtk::Widget* focus); (or const Gtk::Widget&
focus.. whatever)
And same goes for all other signals.
Any thoughs?
Rich
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]