Scrollable DrawingArea?
- From: "Johan Winge" <johan winge telia com>
- To: gtkmm-list gnome org
- Subject: Scrollable DrawingArea?
- Date: Sat, 05 Dec 2009 22:15:35 +0100
I have problems understanding how I can get a DrawingArea scrollable. I
have written a small program which loads an image and shows it in a
DrawingArea, placed inside a ScrolledWindow. This works great, except for
the scrollbars, which are unusable. Am I supposed to update them manually,
and how in that case? Or is there another way to do what I want to achieve
(load a picture, display it with scrollbars, and also analyse and modify
individual pixels.)
Just for your information, I'm a newbie when it comes to gtkmm, nor am I
that familiar with the C++ language. I'm learning by doing.
This is the complete program (the file "test.tiff" is a relatively large
image):
#include <gtkmm.h>
class MyArea : public Gtk::DrawingArea
{
public:
MyArea()
{
image = Gdk::Pixbuf::create_from_file("test.tiff");
}
virtual ~MyArea();
protected:
Glib::RefPtr<Gdk::Pixbuf> image;
bool on_expose_event(GdkEventExpose* event)
{
Glib::RefPtr<Gdk::Window> window = get_window();
if(window && image)
{
image->render_to_drawable(window, get_style()->get_black_gc(),
0, 0, 0, 0, image->get_width(), image->get_height(),
Gdk::RGB_DITHER_NONE, 0, 0);
}
return true;
}
};
int main(int argc, char* argv[])
{
Gtk::Main kit(argc, argv);
Gtk::Window window;
Gtk::ScrolledWindow scrolledwindow;
window.add(scrolledwindow);
MyArea drawingarea;
scrolledwindow.add(drawingarea);
window.show_all_children();
Gtk::Main::run(window);
return 0;
}
Thanks,
Johan Winge
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]