/* * layout.cpp * dim sep 22 22:20:19 EDT 2002 * * ---------------------------------------------------------------------- * * display a simple window with 3 layouts. * * 1 hoziwontal * 2 vertical * 3 fixed * * Each layout contains 2 labels * ---------------------------------------------------------------------- * * Compile with g++ `gtkfc-config --cflags` layout.cpp -o layout `gtkfc-config --libs` */ #define APPNAME "Layout" #include <gtkfc.h> #include <Gapplication.h> #include <Glabel.h> class MyWindow : public Gwindow { public: MyWindow(Gstring s):Gwindow(s) { // the main layout of the window is vertical SetLayout(new GboxLayout(Gcontainers::VERTICAL)); } ~MyWindow() { // DO NOT delete the_button. it was deleted in the widget tree !!! Gapplication::Exit(); } bool OnInit() { // create the vertical layout Gcontainers* vertical = new GboxLayout(Gcontainers::VERTICAL); Insert(vertical); vertical->Add(new Glabel("first")); vertical->Add(new Glabel("second")); Gcontainers* horizontal = new GboxLayout(Gcontainers::HORIZONTAL); Insert(horizontal); horizontal->Add(new Glabel("first")); horizontal->Add(new Glabel("second")); Gcontainers* fixed = new GfixedLayout(); Insert(fixed); Glabel* label; label = new Glabel("first"); label->SetPosition(10, 10, 0, 0); fixed->Add(label); label = new Glabel("second"); label->SetPosition(100, 100, 0, 0); fixed->Add(label); return true; } 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; }