bool Clock::on_timeout()
{
// force our program to redraw the entire clock.
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);
}
return true;
}
"bool Clock::on_timeout() { // force our program to redraw the entire clock. 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); } return true; }"
struct GdkEventButton
struct GdkEventButton {
GdkEventType type;
GdkWindow *window;
gint8 send_event;
guint32 time;
gdouble x;
gdouble y;
gdouble *axes;
guint state;
guint button;
GdkDevice *device;
gdouble x_root, y_root;
};
struct GdkEventButton { GdkEventType type; GdkWindow *window; gint8 send_event; guint32 time; gdouble x; gdouble y; gdouble *axes; guint state; guint button; GdkDevice *device; gdouble x_root, y_root; };
* amigadave has quit (leaving)
* JanC has quit (Read error: 145 (Connection timed out))
* timebomb has quit (Remote closed the connection)
* emmanuel (~emmanuel@host155.201-253-134.telecom.net.ar) has joined #gtk+
* audifahrer_ (~andreas@p5B281D37.dip.t-dialin.net) has joined #gtk+
* gusnan has quit (Lämnar)
* JanC (~janc@ip-213-49-118-197.dsl.scarlet.be) has joined #gtk+
* paulk (~paulk@lib33-1-82-233-88-171.fbx.proxad.net) has joined #gtk+
* audifahrer__ has quit (Ping timeout: 600 seconds)
* elima has quit (Remote closed the connection)
* timebomb (~timebomb@ip-109-40-82-172.web.vodafone.de) has joined #gtk+
* wyuka has quit (Remote closed the connection)
* nekohayo (~jeff@206-248-171-113.dsl.teksavvy.com) has joined #gtk+
* wyuka (~tirtha@111.93.171.226) has joined #gtk+
* Notify: desrt is online (irc.gnome.org).
* zelvosaur has quit (Ping timeout: 600 seconds)
* desrt goes to do his 'real work' now :)
* Bitruder has quit (Read error: 104 (Connection reset by peer))
* jmd has quit (Remote closed the connection)
* Bitruder (~Bitruder@69-165-159-105.dsl.teksavvy.com) has joined #gtk+
Dynamic allocation with manage() and add()
gtkmm provides the manage() function and add() methods to create and destroy widgets. Every widget except a top-level window must be added or packed into a container in order to be displayed. The manage() function marks a packed widget so that when the widget is added to a container, the container becomes responsible for deleting the widget.
MyWidget::MyWidget()
{
Gtk::Button* pButton = manage(new Gtk::Button("Test"));
add(*pButton); //add aButton to MyWidget
}
Now, when objects of type MyWidget are destroyed, the button will also be deleted. It is no longer necessary to delete pButton to free the button's memory; its deletion has been delegated to the MyWidget object.
gtkmm also provides the set_manage() method for all widgets. This can be used to generate the same result as manage(), but is more tedious:
foo.add( (w=new Gtk::Label("Hello"), w->set_manage(), &w) );
is the same as
foo.add( manage(new Gtk::Label("Hello")) );
Of course, a top level container will not be added to another container. The programmer is responsible for destroying the top level container using one of the traditional C++ techniques. For instance, your top-level Window might just be an instance in your main() function..
gtkmm provides the manage() function and add() methods to create and destroy widgets. Every widget except a top-level window must be added or packed into a container in order to be displayed. The manage() function marks a packed widget so that when the widget is added to a container, the container becomes responsible for deleting the widget.
MyWidget::MyWidget() { Gtk::Button* pButton = manage(new Gtk::Button("Test")); add(*pButton); //add aButton to MyWidget } gtkmm also provides the set_manage() method for all widgets. This can be used to generate the same result as manage(), but is more tedious:
foo.add( (w=new Gtk::Label("Hello"), w->set_manage(), &w) );
is the same as
foo.add( manage(new Gtk::Label("Hello")) );
Of course, a top level container will not be added to another container. The programmer is responsible for destroying the top level container using one of the traditional C++ techniques. For instance, your top-level Window might just be an instance in your main() function..
Note that we don't pass a pointer to on_button_clicked() directly to the signal's connect() method. Instead, we call sigc::ptr_fun(), and pass the result to connect().
sigc::ptr_fun() generates a sigc::slot. A slot is an object which looks and feels like a function, but is actually an object. These are also known as function objects, or functors. sigc::ptr_fun() generates a slot for a standalone function or static method. sigc::mem_fun() generates a slot for a member method of a particular instance.
Note that we don't pass a pointer to on_button_clicked() directly to the signal's connect() method. Instead, we call sigc::ptr_fun(), and pass the result to connect().
sigc::ptr_fun() generates a sigc::slot. A slot is an object which looks and feels like a function, but is actually an object. These are also known as function objects, or functors. sigc::ptr_fun() generates a slot for a standalone function or static method. sigc::mem_fun() generates a slot for a member method of a particular instance.
Legend: all the funky keys in here (like right arrow, left arrow, tab, etc.) are represented by their entries in the gdk/gdkkeysyms.h file
OOOOTIMO
http://www.optionexplicit.be/projects/gnome-windows/GTK 3/
std::ostringstream output; output.imbue(std::locale("")); // use the user's locale for this stream output << percentage << " % done"; label->set_text(Glib::locale_to_utf8(output.str()));
| std::string Glib::locale_from_utf8 | ( | const Glib::ustring& | utf8_string | ) |
Convert from UTF-8 to the current locale's encoding.
Convenience wrapper around Glib::convert().
| utf8_string | The UTF-8 string to convert. |
| Glib::ConvertError |
| Glib::ustring Glib::locale_to_utf8 | ( | const std::string & | opsys_string | ) |
Convert from the current locale's encoding to UTF-8.
Convenience wrapper around Glib::convert().
| opsys_string | The string to convert. Must be encoded in the charset used by the operating system's current locale. |
| Glib::ConvertError |