[gnomemm] Some questions about the Gnome::Canvas::Canvas



Hi,

I am new to the List and would like to know some things about the
Canvas.
I´m currently working on a little game.
Just to know if things right, here is what i did so far:

I have a kind of gamehandler class witch does all the game stuff and
creates the gui like this:

#include <libgnomecanvasmm/init.h>
#include <gtkmm/main.h>
#include "MainFrame.h"

int main (int argc, char ** argv)
{
  Gnome::Canvas::init();
  Gtk::Main main(0, NULL);
  MainFrame *gui = new class MainFrame(this, field, width, height);

  main.run(*gui);
  return 0;
}

The MainFrame is the main part of the gui witch is derived from
Gtk::Window
In the Constructor it creates a class witch is derived from Canvas, adds
it to itself and shows it.
the mainframe has a method to update the canvas witch is called from the
gamehandler if something has to change to the canvas.

MainFrame::redraw()
{
   canvas->drawField();
   canvas->update_now();
}

the drawField method is part of the MyCanvas class witch adds some
Canvas::Item s like Rect to the rootGroup like this:

    r = manage(new Rect(rootGroup, 
                        0,
                        0,
                        width,
                        height));

   *r << Properties::width_pixels(0)
      << Properties::fill_color("white");

r is a pointer of class Rect, rootGroup is a Canvas::Group Object witch
has been initialized in the Constructor of MyCanvas like this:

MyCanvas::MyCanvas(MainFrame *p, short int** f, int w, int h
                                              , int f_w, int f_h)
                  : Canvas(GNOME_CANVAS(g_object_new(get_type(),0)))
                    ,rootGroup(*(root()), 0, 0)
{
...
}

I hope its correct so far. It seams to work not that bad, bud sometimes
changes to the Canvas, like adding some additional items, are not
updated immediately. Where could be the problem?
Then i have some questions about the virtual methods of the Canvas
class. When is each of them called and if I implement my own ones, do i
have to call the original ownes too?

Thanks

Klaus




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