gltk 0.3
a C++ widget library built on GLUT
entry.cc
entry.png

Simple use of the Entry widget.

#include <gltk.hh>
using namespace gltk;

class ExampleWindow : public Window
{
protected:
        void on_checkbox_editable_toggled()
        {
                ety.set_editable(cb_e.get_active());
        }

        void on_checkbox_visibility_toggled()
        {
                ety.set_visibility(cb_v.get_active());
        }

        void on_button_close()
        {
                hide();
        }
        
        //Child widgets:
        Box hbx;
        Box vbx;
        Entry ety;
        Button bt_c;
        CheckButton cb_e, cb_v;
public:
        ExampleWindow() :
                hbx(ORIENTATION_HORIZONTAL),
                vbx(ORIENTATION_VERTICAL),
                bt_c("Close"),
                cb_e("Editable"),
                cb_v("Visible")
        {
                set_default_size(200, 100);
                set_title("Gtk::Entry");

                add(vbx);

                ety.set_max_length(50);
                ety.set_text("hello");
                ety.set_text(ety.get_text() + " world");
                ety.select_all();
                vbx.pack_start(ety);

                vbx.add(hbx);

                hbx.pack_start(cb_e);
                cb_e.signal_toggled()
                        .connect(sigc::mem_fun(this, & ExampleWindow::on_checkbox_editable_toggled));
                cb_e.set_active(true);

                hbx.pack_start(& cb_v);
                cb_v.signal_toggled()
                        .connect(sigc::mem_fun(this, & ExampleWindow::on_checkbox_visibility_toggled));
                cb_v.set_active(true);

                bt_c.signal_clicked()
                        .connect(sigc::mem_fun(this, & ExampleWindow::on_button_close));
                vbx.pack_start(bt_c);

                bt_c.make_focus();

                show_all_children();
        }

        virtual ~ExampleWindow() {}
};

int main(int argc, char *argv[])
{
        Main kit(argc, argv);
        ExampleWindow window;
        Main::run(window);
        return 0;
}
 All Classes Namespaces Files Functions Variables Enumerations Enumerator