Re: ComboBox(), again!

Jamiil Abduqadir wrote:
It has been my intention to create a class that will simplify the inclusion of combo widgets in my programs, the class derives from 'Gtk::VBox' and then add to it a 'Gtk::ComboBoxEntryText', like this:

------ HPP FILE
namespace jme{
class Combo : virtual public Gtk::VBox{
    virtual void Init();
    void Pack();
    Glib::ustring str;
    Gtk::Label* label;
    Gtk::ComboBoxEntryText* text_box;

    virtual ~Combo();
};// Class
}// Namespace
----- CPP FILE
void jme::Combo::Init() {
    // Instantiate object widgets
    label     = Gtk::manage(new Gtk::Label(, Gtk::ALIGN_LEFT ));
    if(label == NULL) {
    text_box  = Gtk::manage(new Gtk::ComboBoxEntryText());
    if(text_box == NULL) {

:ustring& s) {
    str = s;
jme::Combo::~Combo() { }

Later on another class I declare my hand dandy class (jme::Combo* entryboxFirstName;) , then I instantiate it like this 'entryboxFirstName = Gtk::manage(new jme::Combo("sometext"));' to add it to a 'Gtk::Frame' (someFrame->pack_start(*entryboxFirstName);

This works just fine, however, the size of the combo box is too high, high enough to fit two lines of text. Is this a normal behaviour in GTKmm?

Please advice, thanks in advance.

I would only say two things: First, did you know that if you declare your class members (for example your "label" above) as regular class types instead of pointer types (in other words, "Gtk::Label label" instead of "Gtk::Label* label") they are created and destroyed when the class is also instantiated and then destroyed (you wouldn't need to use manage)? In the same way, if you declare your entryboxFirstName as jme::Combo instead of jme::Combo* that class will disappear automatically when the parent class disappears (if it's member of a parent class). You would need to use manage, however, when the widget you're creating is not a member of a class.

Second, I think you have to look into the different packing options that containers have. See for example the VBox docs, specially pack_start() <> and pack_end() <>.

Happiness has many doors, and when one of them closes another opens, yet we spent so much time looking at the one that is shut that we don't see the one that just opened.

gtkmm-list mailing list
gtkmm-list gnome org

José Alburquerque
jaalburquerque cox net

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]