/* * entry.cpp * mar sep 24 09:56:05 EDT 2002 * * ---------------------------------------------------------------------- * * display an entry text * When enter is pressed in the entry text, the text is printed on stdout * * ---------------------------------------------------------------------- * * Compile with g++ `gtkfc-config --cflags` entry.cpp -o entry `gtkfc-config --libs` */ #define APPNAME "Entry text" #include <gtkfc.h> #include <Gapplication.h> #include <GentryText.h> class MyWindow : public Gwindow { private: GentryText* the_text; public: MyWindow(Gstring s):Gwindow(s) { SetLayout(new GboxLayout(Gcontainers::VERTICAL)); the_text = new GentryText(); } ~MyWindow() { Gapplication::Exit(); } bool OnInit() { Insert(the_text); return true; } void OnAction(Gwidget* w, GdkEvent* e) { if(w == the_text) { printf("%s\n", the_text->GetText().c_str()); the_text->SetText(Gstring("")); } } protected: bool OnDestroy(){ return true; } }; int main(int argc, char **argv) { Gapplication app(APPNAME, argc, argv); Gwindow *w = new MyWindow(app.GetAppName()); app.Add(w); w->Show(); app.Run(); return EXIT_SUCCESS; }