Re: Gtk::Fixed or Gtk::DrawingArea(Porting DBDesigner to c++ & gtkmm)



I made a sample prog with a widget on the canvas: Hopefull this is helpfulll for others
// --main.cc--
/* Created by Anjuta version 1.2.2 */
/*    This file will not be overwritten */
#include <libgnomecanvasmm/init.h>
#include <gtkmm/main.h>
#include <iostream>

#include "WndMain.h"

int main(int argc, char* argv[])
{
 Gnome::Canvas::init();
 Gtk::Main app(argc, argv);

 WndMain mainwin;
 app.run(mainwin);

 return 0;
}

// --WndMain.h--

/*
* File: WndMain.h
* Created by: Bart <bartverstraete77 hotmail com>
* Created on: Sat Feb 19 21:13:47 2005
*/

#ifndef _WNDMAIN_H_
#define _WNDMAIN_H_

#include <gtkmm.h>
#include <libgnomecanvasmm/canvas.h>
#include <libgnomecanvasmm/widget.h>
#include <libgnomecanvasmm/group.h>

class WndMain : public Gtk::Window
{
public:
   WndMain();
   virtual ~WndMain();
protected:
   Gtk::ScrolledWindow m_scrolledwindow;
   Gnome::Canvas::Canvas m_canvas;
   Gtk::Button* m_ptrButton;
};
#endif /*_WNDMAIN_H_*/

// --WndMain.cc--

/*
* File: WndMain.h
* Created by: Bart <bartverstraete77 hotmail com>
* Created on: Sat Feb 19 21:13:47 2005
*/

#include "WndMain.h"

WndMain::WndMain()
{
   set_title("gnomecanvas");
   set_border_width(0);
   set_size_request(640, 480);
m_canvas.set_size_request(1280, 960);
   m_canvas.set_scroll_region(0, 0, 1280, 960);
   //m_canvas.set_center_scroll_region(true);
m_scrolledwindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
   m_scrolledwindow.add(m_canvas);
add(m_scrolledwindow);

   Gnome::Canvas::Group* root = m_canvas.root();
   m_ptrButton = Gtk::manage(new Gtk::Button("Hello World!"));
Gnome::Canvas::Widget* widget = Gtk::manage(new Gnome::Canvas::Widget(*root, 50.0, 50.0, *m_ptrButton));
   widget->property_width() = 300;
   widget->property_height() = 300;
   widget->property_anchor() = Gtk::ANCHOR_NW;
   widget->property_size_pixels() = false;
show_all_children();
}

WndMain::~WndMain()
{
}




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