gtk-- newbie question





Hello!

I'm a rank newbie to Gnome, and I have a really dumb question about how
to use gtk--. I am having trouble with figuring out how drawing primitives
work. 


 Here's my pathetic attempt at drawing a rectangle in a window:


#include <gtk--.h>

//
// Attempt to draw a rectangle - this doesn't work because I'm
// doing something hideously boneheaded
//

class HexWindow : public Gtk_Window {
   Gtk_DrawingArea *d_area;

public:
   HexWindow() : d_area( new Gtk_DrawingArea() ){
       set_title("Here is a rectangle");
       set_usize(400,400);
       d_area->size(400,400);
       d_area->draw_rectangle(this,TRUE,10,20,30,40);
       add(d_area);
       d_area->show();
   }
};


int main( int argc, char **argv )

   Gtk_Main m( &argc, &argv );
   HexWindow w;

   w.show();

   m.run();
   return 0;

}

I compile with:

$ g++ `gtkmm-config --cflags` -o hello hello.C `gtkmm-config --libs`

and get this compiler error:

hello.C: In method `HexWindow::HexWindow()':
hello.C:15: no matching function for call to
`Gtk_DrawingArea::draw_rectangle (HexWindow *, bool, int, int, int,
int)'


 Perhaps someone could fix my rotten code and demonstrate the correct
way to draw the rectangle in a window? I know I am missing something
obvious but this is the best I could do with my poor understanding of
the gtk-- source code.

 Many thanks for any hints. If this is the wrong forum for gtk-- questions,
please let me know where I should go.

 -Derrick



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