Re: [Win32] Layout and look&feel




jalqadir netscape net wrote:

Hey folks!
OK, huff, I hit a wall people. I just can't get this program to display the ComboBox within an acceptable size! I can manipulate the width of the widget, but getting the height to a more suitable size has proven to be a real challenge. Below is the code for the program and if you have to look at the window I can send you a 'GNP' file that will show you what I mean. Please note that I am using the Win32 version of Gtkmm and that many times I have had gone a great length to fix a problem, just to realize that the problem lies within the Win32 port of the toolkit. Thanks in advance.
----- h file ---
namespace jme{
//! \brief This class is thrown in the case of an exception
class BoxEntryEx : public virtual jme::Exception {
public:
    BoxEntryEx( jme::error_t ec, const std::string& f,
                const std::string& m, size_t l ) {
        setException( ec, f, m, l );
    }
    virtual ~BoxEntryEx()throw(){}
};//Class
class IOBoxBase : public Gtk::VBox{
protected:
    virtual void Init() throw(jme::BoxEntryEx );
    void setTitle(const char*) throw(jme::BoxEntryEx);
    int max_len;
    int height;
    int width;
    Glib::ustring title;
    Glib::ustring text;
    Gtk::Label* label;
public:
    IOBoxBase(){Init();}
    virtual ~IOBoxBase(){};
}; //class
class ComboBox : virtual public jme::IOBoxBase{
private:
protected:
    virtual void Init() throw(jme::BoxEntryEx );
    Gtk::ComboBoxEntryText* combo_box;
public:
    ComboBox(){Init();}
    ComboBox(const gchar*,              //Title
             gint)                      //Vertical padding
             throw(jme::BoxEntryEx );   //Exception
    virtual ~ComboBox(){}
    Gtk::ComboBoxEntryText* getHandle() {return combo_box;}
}; //class
}  // namespace
--- cpp file ---
void jme::IOBoxBase::Init()
throw(jme::BoxEntryEx ){
    try{
        label = Gtk::manage(new Gtk::Label());
    }catch(...){
        jme::BoxEntryEx e( mem_alloc, FILE, METHOD, LINE );
        e.record("error_log.txt");
        throw e;
    }
    text = "unknown";
    height = 20;
    width  = 20;
    label->set_label(text);
    label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_BOTTOM);
}
void jme::IOBoxBase::setTitle(const char* c)
throw(jme::BoxEntryEx ){
    title.assign(c);
    if(title.empty()){
        title.clear();
        jme::BoxEntryEx e( str_empty, FILE, METHOD, LINE );
        throw e;
    }
    label->set_label(title);
}
void jme::TextEntry::Init()
    throw(jme::BoxEntryEx ){
    try{
        entry = Gtk::manage(new Gtk::Entry());
    }catch(...){
        jme::BoxEntryEx e( mem_alloc, FILE, METHOD, LINE );
        e.record("error_log.txt");
        throw e;
    }
    // this->set_spacing(0);
    // Display the box with a frame
    entry->set_has_frame( true );
    entry->set_visibility( true );
    // This value is overridden by the user
    entry->set_max_length(30);

    // The size of the widget
    this->ensure_style();
}
/////////////////////// ComboBox ///////////////////////////
void jme::ComboBox::Init()
throw(jme::BoxEntryEx ){
    try{
        combo_box = Gtk::manage(new Gtk::ComboBoxEntryText());
    }catch(...){
        jme::BoxEntryEx e( mem_alloc, FILE, METHOD, LINE );
        e.record("error_log.txt");
        throw e;
    }
  this->add(*label);
  this->add(*combo_box);
}
jme::ComboBox::ComboBox(const gchar* title, gint pad)
throw(jme::BoxEntryEx ){
   Init();
   setTitle(title);
// === <> ===
//   this->set_size_request (10,    //width_pixels
//                           10);  //height_pixels);
   combo_box->set_size_request(10,1); //<< this does not work either
}
* You cannot exercise your power to a point of humiliation.
- Jean Chretien

* It's amazing how the small seeds of distrust and misunderstanding
can yield a crop of hate and death...

* If that document has fine printing anywhere, just chuck it in the garbage
- Jorge Escalante
Ma'assalama! Adiós! bye!
------------------------------------------------------------------------
*Try the New Netscape Mail Today!*
Virtually Spam-Free | More Storage | Import Your Contact List
http://mail.netscape.com

------------------------------------------------------------------------

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Your problem comes in "void jme::ComboBox::Init()" where you are using Gtk::Container::add to insert your label and combobox into "class IOBoxBase". Try using "Gtk::Box::pack_start" instead. This method gives you much more control over the combobox widget's display behavior at run time. See http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Box.html#e1a2ca6c5de8ad4442ed93c2c20eec87 for more information.

Hope this helps.

Bob Caryl
begin:vcard
fn:Robert Caryl
n:Caryl;Robert
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758;USA
email;internet:bob fis-cal com
title:Senior Software Design Engineer
tel;work:356-772-8920 X108
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard



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