Re: [gtkmm] some easy questions from a beginner



I can't help with problem 1 but with problem 2 try using menu->show(); instead of menu.show();

Jacob Lambrecht


On Thu, 2002-07-11 at 09:42, Daniel Perez Alcazar wrote:
Hello,

I've recently begin to work with Gtkmm, and I've had some problems.
Sure you have solved these problems before. I've read the examples 
of gtkmm and I've not found anything related, so I'm asking you now.

I have 2 main problems :

	1- I can't do a "pack_start" with any thing different to a Widget object.
	I want to do a pack_start(menu,false,false,0), where "menu" is an
	object derived from the MenuBar class.

	2- The first times I wrote  gtkmm code, I always wrote 
	derived classes from Gtkmm classes and I declared an instance of
	them and after this, I always did a "menu.show()", being "menu" the
	derived class. I do that because "menu" has inherited all the methods
	of the mother class (which is intended to be a gtkmm widget). But 
	the compiler gives me an error: <<request for member "show" in
 	"menu"	, which is of non-aggregate type "nsMenu ()()">>. After some
	investigation, I saw that all of the examples call the "show" method 
	inside the class itself, but I don't understand why my approach is not
	correct.

Here you have all the code. Ah! I'm sorry if sometimes it's difficult to
understand my written English!

Thank you very much,

Dani P.

////////////////////// nsMain.cpp ////////////////////////////////
#include <gtk--/main.h>
#include <gtk--/window.h>
#include <gtk--/box.h>
#include "nsMenu.h"

int main (int argc, char *argv[])
{
	Gtk::Main start(argc,argv);
	Gtk::Window window(GTK_WINDOW_TOPLEVEL);
	
	nsMenu menu();
	//menu.show(); <----- This is what I meant in 2nd problem
	
	Gtk::VBox main_packing_box(FALSE,0);
	main_packing_box.pack_start(menu,false,0);
	main_packing_box.show();
	
	
	window.set_title("NetScout");
	window.set_policy(false,false,true);
	window.add(main_packing_box);
	window.show();

	
	start.run();

	return(0);
}
/////////////////////// End nsMain ///////////////////////////

--------------------------------

/////////////////////// nsMenu.cpp //////////////////////////
#include "nsMenu.h"

nsMenu::nsMenu()
{
	
	Gtk::Menu file_menu();
		MenuList& file_menu_list=file_menu.items();
		file_menu_list.push_back("Open");
		file_menu_list.push_back("Save");
		file_menu.show();
		
	MenuList& menu_bar_list=items();
	menu_bar_list.push_back(MenuElem("File",NULL,file_menu));
	show(); <--- This is what I did to solve the 2nd  issue.
}

////////////////////////// End nsMenu /////////////////////////

---------------------------------

/////////////////////////// nsMenu.h ////////////////////////////

#include <gtk--/menubar.h>
#include <gtk--/menu.h>

class nsMenu : public Gtk::MenuBar
{
	nsMenu::nsMenu();
};


//////////////////////// End nsMenu.h ///////////////////////

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

    


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