Re: [gtkmm] some easy questions from a beginner
- From: Carl Nygard <cjnygard fast net>
- To: danielpa wanadoo es
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] some easy questions from a beginner
- Date: 11 Jul 2002 11:09:56 -0400
On Thu, 2002-07-11 at 11: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();
You're declaring a function named menu taking no arguments and returning
an object of type nsMenu. Drop the () and you should be good. Compiler
is expecting use of 'menu' to be a function.
> //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]