/* * GuiLoader/C++ examples * Copyright (c) 2006 Maxim Udushlivy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef _WIN32 #include #endif #include namespace GuiExample { class Application : public sigc::trackable { public: Application() { loader= Gui::Loader::create(); GUIXML_DECL #include "simple.gui.h" GUIXML_LOAD_CPP(loader) loader->bind_object("window1", &window); loader->bind_object("button1", &button); loader->connect_signals("onDeleteEvent", sigc::mem_fun(*this, &Application::onDeleteEvent)); loader->connect_signals("onButtonClicked", sigc::mem_fun(*this, &Application::onButtonClicked)); loader->connect_signals_s("onCheckToggled", sigc::mem_fun(*this, &Application::onCheckToggled)); } Gtk::Window * getWindow() { return window; } protected: bool onDeleteEvent(GdkEventAny *) { return true; } void onButtonClicked() { window->hide(); } void onCheckToggled(Glib::Object * source) { Gtk::CheckButton * check= dynamic_cast(source); button->set_sensitive(check->get_active()); } private: Gui::PLoader loader; Gtk::Window * window; Gtk::Button * button; }; int Main(int argc, char ** argv) { Gtk::Main gtkmain(&argc, &argv); Gui::Enter enter; Application application; Gtk::Main::run(*application.getWindow()); return 0; } } #ifdef _WIN32 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { return GuiExample::Main(__argc, __argv); } #else int main(int argc, char ** argv) { return GuiExample::Main(argc, argv); } #endif