예제 #1
0
int main(int argc, char *argv[])
{

    // make window
    Glib::RefPtr<Gtk::Application> app =
        Gtk::Application::create(argc, argv,
                                 "tutorial2");

    Gtk::Window window;

    window.set_default_size(400,200);
    window.set_title("Tutorial 2");

    // This creates a vertical box container with 0 padding
    Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));
    window.add(*vbox);

    // creates menu bar
    Gtk::MenuBar *menubar = Gtk::manage(new Gtk::MenuBar());
    vbox->pack_start(*menubar, Gtk::PACK_SHRINK, 0);

    // create menu items
    Gtk::MenuItem *menuitem_file = Gtk::manage(new Gtk::MenuItem("_File", true));
    menubar->append(*menuitem_file);
    Gtk::Menu *filemenu = Gtk::manage(new Gtk::Menu());
    menuitem_file->set_submenu(*filemenu);
    Gtk::MenuItem *menuitem_quit = Gtk::manage(new Gtk::MenuItem("_Quit", true));
    filemenu->append(*menuitem_quit);

    // create grid container with border width 10
    // and add it to the new cell of the vertical box
    Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
    grid->set_border_width(10);
    vbox->add(*grid);

    // create button
    Gtk::Button *b1 = Gtk::manage(new Gtk::Button("Button 1"));
    b1->set_hexpand(true);		//  take up all unused space horizontally
    b1->set_vexpand(true);		//  take up all unused space vertically
    // possition 0(x), 0(y), span 1 cell wide and 2 cells down
    grid->attach(*b1, 0, 0, 1, 2);

    Gtk::Button *b2 = Gtk::manage(new Gtk::Button("Button 2"));
    grid->attach(*b2, 1, 0, 1, 1);

    Gtk::Button *b3 = Gtk::manage(new Gtk::Button("Button 3"));
    grid->attach(*b3, 1, 1, 1, 1);

    vbox->show_all();

    return app->run(window);
}
예제 #2
0
SendMsgDlg::SendMsgDlg(const char *name, time_t when, const char *text)
: LinqWindow(WIN_SEND_MESSAGE)
{
	signal_delete_event().connect(SigC::slot(*this, &SendMsgDlg::on_window_delete_event));
	set_title (_("LinQ - Send message"));

	m_notebook.set_scrollable(true);
	m_notebook.popup_enable();

	Gtk::VBox *vbox;
	vbox = Gtk::manage(new Gtk::VBox(false, 0));
	
	Gtk::MenuBar *menubar;
	menubar = Gtk::manage(new Gtk::MenuBar());

	Gtk::Menu *menu;
	menu = Gtk::manage(new Gtk::Menu());	
	Gtk::Menu::MenuList& menulist = menu->items();
	menulist.push_back(Gtk::Menu_Helpers::MenuElem(_("View _histroy")));
	menulist.push_back(Gtk::Menu_Helpers::MenuElem(_("_Close")));	
	menubar->items().push_back( Gtk::Menu_Helpers::MenuElem("_Conservation", *menu) );
	
	menu = Gtk::manage(new Gtk::Menu());	
	menulist = menu->items();
	menulist.push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Enabel _sound")));
	menubar->items().push_back( Gtk::Menu_Helpers::MenuElem("_Conservation", *menu) );

	vbox->pack_start(*menubar, false, true, 0);
	vbox->pack_start(m_notebook, true, true, 0);

	add(*vbox);

	SendMsgDlgTab *tab;
	tab = new SendMsgDlgTab(this, name);
	if (text)
		tab->onRecvMessage(when, text);
	tab->doPresent();

	show_all();
}
예제 #3
0
myWindow::myWindow()
{
	set_default_size(400, 200);
	set_title("Tutorial 3");

	Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));
	add(*vbox);

	Gtk::MenuBar *menubar = Gtk::manage(new Gtk::MenuBar());
	vbox->pack_start(*menubar, Gtk::PACK_SHRINK, 0);

	Gtk::MenuItem *menuitem_file = Gtk::manage(new Gtk::MenuItem("_File", true));
	menubar->append(*menuitem_file);
	Gtk::Menu *filemenu = Gtk::manage(new Gtk::Menu());
	menuitem_file->set_submenu(*filemenu);
	Gtk::MenuItem *menuitem_quit = Gtk::manage(new Gtk::MenuItem("_Quit", true));
	menuitem_quit->signal_activate().connect(sigc::mem_fun(*this, &myWindow::on_quit_click));
	filemenu->append(*menuitem_quit);

	Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
	grid->set_border_width(10);
	vbox->add(*grid);

	Gtk::Button *b1 = Gtk::manage(new Gtk::Button("Big Button 1"));
    b1->set_hexpand(true);
    b1->set_vexpand(true);
    b1->signal_clicked().connect(sigc::mem_fun(*this, &myWindow::on_big_button1_click));
    grid->attach(*b1, 0, 0, 1, 2);

    Gtk::Button *b2 = Gtk::manage(new Gtk::Button("Button 2"));
    b2->signal_clicked().connect(sigc::mem_fun(*this, &myWindow::on_button2_click));
    grid->attach(*b2, 1, 0, 1, 1);

    Gtk::Button *b3 = Gtk::manage(new Gtk::Button("Button 3"));
    b3->signal_clicked().connect(sigc::mem_fun(*this, &myWindow::on_button3_click));
    grid->attach(*b3, 1, 1, 1, 1);

    vbox->show_all();
}
예제 #4
0
MainWindow::MainWindow () :
	Gtk::Window(),
	m_events(m_window.GetWindow()),
	m_mainimage(PREFIX_SHARE "/meteor.png"),
	m_padConfigDialog(*this, m_config),
	m_running(false)
{
	this->set_title("Meteor");
	this->set_resizable(false);

	Gtk::Menu* menu_file = manage(new Gtk::Menu);
	menu_file->items().push_back(Gtk::Menu_Helpers::StockMenuElem(
				Gtk::Stock::OPEN, sigc::mem_fun(*this,
					&MainWindow::on_open)));
	Gtk::Image* img = manage(new Gtk::Image(Gtk::Stock::OPEN,
				Gtk::ICON_SIZE_MENU));
	menu_file->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(
				"Open _BIOS", *img, sigc::mem_fun(*this, &MainWindow::on_open_bios)));
	menu_file->items().push_back(Gtk::Menu_Helpers::StockMenuElem(
				Gtk::Stock::CLOSE, sigc::mem_fun(*this,
					&MainWindow::on_close)));
	img = manage(new Gtk::Image(Gtk::Stock::CLOSE,
				Gtk::ICON_SIZE_MENU));
	menu_file->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(
				"Close B_IOS", *img, sigc::mem_fun(*this,
					&MainWindow::on_close_bios)));
	menu_file->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
	menu_file->items().push_back(Gtk::Menu_Helpers::StockMenuElem(
				Gtk::Stock::QUIT, sigc::mem_fun(*this,
					&MainWindow::on_quit)));

	Gtk::Menu* menu_emulator = manage(new Gtk::Menu);
	img = manage(new Gtk::Image(Gtk::Stock::MEDIA_PLAY,
				Gtk::ICON_SIZE_MENU));
	menu_emulator->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(
				"R_un", Gtk::AccelKey('u', Gdk::CONTROL_MASK), *img,
				sigc::mem_fun(*this, &MainWindow::on_run)));
	img = manage(new Gtk::Image(Gtk::Stock::MEDIA_STOP,
				Gtk::ICON_SIZE_MENU));
	menu_emulator->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(
				"_Stop", Gtk::AccelKey('s', Gdk::CONTROL_MASK), *img,
				sigc::mem_fun(*this, &MainWindow::on_stop)));
	img = manage(new Gtk::Image(Gtk::Stock::MEDIA_REWIND,
				Gtk::ICON_SIZE_MENU));
	menu_emulator->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(
				"_Reset", Gtk::AccelKey('r', Gdk::CONTROL_MASK), *img,
				sigc::mem_fun(*this, &MainWindow::on_reset)));
	menu_emulator->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
	img = manage(new Gtk::Image(Gtk::Stock::PREFERENCES,
				Gtk::ICON_SIZE_MENU));
	menu_emulator->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(
				"_Configure pad", *img,
				sigc::mem_fun(*this, &MainWindow::on_config_pad)));

	Gtk::Menu* menu_sstate = manage(new Gtk::Menu);
	Gtk::Menu* menu_lstate = manage(new Gtk::Menu);
	{
		char tmp[2];
		tmp[0] = '1';
		tmp[1] = '\0';
		for (char c = 0; c < 9; ++c, ++tmp[0])
			menu_sstate->items().push_back(Gtk::Menu_Helpers::MenuElem(
						tmp, Gtk::AccelKey(GDK_F1 + c, Gdk::CONTROL_MASK),
						sigc::bind<uint8_t>(sigc::mem_fun(
								*this, &MainWindow::on_save_state), c)));

		tmp[0] = '1';
		for (char c = 0; c < 9; ++c, ++tmp[0])
			menu_lstate->items().push_back(Gtk::Menu_Helpers::MenuElem(
						tmp, Gtk::AccelKey(GDK_F1 + c, (Gdk::ModifierType)0),
						sigc::bind<uint8_t>(sigc::mem_fun(
								*this, &MainWindow::on_load_state), c)));
	}

	Gtk::Menu* menu_state = manage(new Gtk::Menu);
	img = manage(new Gtk::Image(Gtk::Stock::SAVE,
				Gtk::ICON_SIZE_MENU));
	menu_state->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(
				"Save", *img, *menu_sstate));
	img = manage(new Gtk::Image(Gtk::Stock::OPEN,
				Gtk::ICON_SIZE_MENU));
	menu_state->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(
				"Load", *img, *menu_lstate));

	Gtk::Menu* menu_debug = manage(new Gtk::Menu);
	Gtk::Menu_Helpers::CheckMenuElem disassemblercheck(
				"Disassembler", sigc::mem_fun(*this,
					&MainWindow::on_menu_disassembler_toggle));
	m_refDisassemblerCheck =
		Glib::RefPtr<Gtk::CheckMenuItem>::cast_static(
				disassemblercheck.get_child());
	menu_debug->items().push_back(disassemblercheck);
	Gtk::Menu_Helpers::CheckMenuElem palettecheck(
				"Palette", sigc::mem_fun(*this,
					&MainWindow::on_menu_palette_toggle));
	m_refPaletteCheck =
		Glib::RefPtr<Gtk::CheckMenuItem>::cast_static(
				palettecheck.get_child());
	menu_debug->items().push_back(palettecheck);
	Gtk::Menu_Helpers::CheckMenuElem vramcheck(
				"Vram viewer", sigc::mem_fun(*this,
					&MainWindow::on_menu_vram_toggle));
	m_refVramCheck =
		Glib::RefPtr<Gtk::CheckMenuItem>::cast_static(
				vramcheck.get_child());
	menu_debug->items().push_back(vramcheck);

	Gtk::Menu* menu_help = manage(new Gtk::Menu);
	menu_help->items().push_back(Gtk::Menu_Helpers::StockMenuElem(
				Gtk::Stock::ABOUT, sigc::mem_fun(*this,
					&MainWindow::on_menu_about)));

	Gtk::MenuBar* menubar = manage(new Gtk::MenuBar);
	menubar->items().push_back(Gtk::Menu_Helpers::MenuElem("_File", *menu_file));
	menubar->items().push_back(
			Gtk::Menu_Helpers::MenuElem("_Emulator", *menu_emulator));
	menubar->items().push_back(
			Gtk::Menu_Helpers::MenuElem("_State", *menu_state));
	menubar->items().push_back(
			Gtk::Menu_Helpers::MenuElem("_Debug", *menu_debug));
	menubar->items().push_back(
			Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::HELP, *menu_help));

	m_viewport.set_double_buffered(false);
	m_viewport.set_size_request(4*240, 4*160);

	m_statusbar.set_has_resize_grip(false);

	m_mainvbox.pack_start(*menubar);
	m_mainvbox.pack_start(m_mainimage);
	m_mainvbox.pack_start(m_viewport);
	m_mainvbox.pack_start(m_statusbar);

	this->add(m_mainvbox);

	menubar->show_all();
	m_mainimage.show_all();
	m_statusbar.show_all();
	m_mainvbox.show();
	this->show();

	m_disassemblerWindow.signal_hide().connect(sigc::mem_fun(*this,
				&MainWindow::on_disassembler_hide));
	m_paletteWindow.signal_hide().connect(sigc::mem_fun(*this,
				&MainWindow::on_palette_hide));
	m_vramWindow.signal_hide().connect(sigc::mem_fun(*this,
				&MainWindow::on_vram_hide));

	m_config.Load();
	m_config.Init();
	m_batteryPath = m_config.GetBatteryPath();
	m_sstatePath = m_config.GetSStatePath();
	m_romPath = m_config.GetRomPath();

	m_window.InitAMeteor();
	m_audio.InitAMeteor();

	//m_refDisassemblerCheck->set_active(true);
	//m_refPaletteCheck->set_active(true);
	m_aboutDialog.set_logo(m_mainimage.get_pixbuf());
}