Re: How to create the particular area in this window?



I'm sorry I can't see your picture or other attachment,

but you're welcome to send them to me directly. However, I'll try to help w/ my recent knowledge of gtkmm's TreeViews.

They're cool but HARD to figure out. Here are some docs on TreeViews that I found: (more stars, better info)
1. http://scentric.net/temp/tutorial/ **
2. http://www.gtk.org/tutorial/index.html ***
3. http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch08.html ***
4. http://liw.iki.fi/liw/texts/gtktreeview-tutorial.html   ****

I use them and it took a while for me to understand the use of "list stores/tree stores" and their relationship to the actual view. However, they are quite powerful.

The "Combo" boxes you wish to mimic can be done in an actual tree view column! But you've got to understand how to write a cell renderer.

So, here's the connection between the TreeView, the "Store", and the Renderer in a nutshell - anyone's WELCOME To correct me too! I'm no expert @ TreeViews.

1. Must construct a "Store" first that is composed of the "columns" you wish or MIGHT wish to display. Example

#ifndef H_CALLTREEMODELCOLUMNS_H
#define H_CALLTREEMODELCOLUMNS_H

#include <gtkmm.h>
#include <string>

/**
* *****************************************************************************
* \class CModelColumns
*
*    \brief Creates a model for the columns of a list box
*
* Detailed Description:
* All list boxes must have a model for their columns. All columns do not * have to be used, so as many columns may be added to accomodate any special
*    situation.
*
* The Mortar Filename can also be a RAM file name.
* *****************************************************************************
*/
class CAllTreeModelColumns : public Gtk::TreeModel::ColumnRecord
{
        // //////////////////////////////////////
public:// Instance Methods
       // //////////////////////////////////////

   // add all columns to the model
   CAllTreeModelColumns(void)
   {
     add(m_colRowNumber);
     add(m_colRowColor);
    }; ///< ctor

// //////////////////////////////////////
public:// Instance Attributes
       // //////////////////////////////////////
// Columns Available
   //
Gtk::TreeModelColumn<std::string> m_colRowNumber; ///< Row Number Gtk::TreeModelColumn<std::string> m_colSensorName; ///< Name of Sensor Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf>> m_colThreat1Color; ///< the color of a legend object Gtk::TreeModelColumn<bool> m_colEventOnOff; ///< Event On or Off
};


Notice that 2 of the 4 columns are NOT added to the Constructor of this class which holds ALL of the columns I might wish to use. That is on purpose to show you that if you DO NOT add these columns in the constructor with the ADD command, they really are NOT part of the column class OBJECT when it is instantiated.

Also, the types are very important. string is easy. bool I've not learned how to use yet but it's for toggle buttons. the pixubuf is really cool! You can put a picture in a Gtk TreeView Cell! awesome & it works I do that.


OK, we have the "columns" class, now you've got to have the actual "list or tree" store. TreeStores are used if you have a tree type structure to your data. Lists are lists - a tree with only 1 level.

Glib::RefPtr<Gtk::ListStore> m_lststorSensors; ///< list store for Sensors Glib::RefPtr<Gtk::ListStore> m_lststorGuns; ///< list store for Guns


Now you need the actual TREEVIEW that is composed of the "store"

Gtk::TreeView *m_tvpSensorTreeView; ///< Sensors Tree View Gtk::TreeView *m_tvpGunTreeView; ///< Guns/Defending Weapons Tree view

  m_lststorSensors = Gtk::ListStore::create( m_atmcAllTreeModelColumns );
  m_lststorGuns    = Gtk::ListStore::create( m_atmcAllTreeModelColumns );
m_tvpSensorTreeView->set_model(m_lststorSensors);
  m_tvpSensorTreeView->property_enable_grid_lines();
  m_tvpSensorTreeView->set_rules_hint();
m_tvpGunTreeView->set_model(m_lststorGuns);
  m_tvpGunTreeView->property_enable_grid_lines();
  m_tvpGunTreeView->set_rules_hint();


Ok, show instantiating the stores using an OBJECT!!! named m_atmcAllTreeModelColumns; Its declaration is: CAllTreeModelColumns m_atmcAllTreeModelColumns; ///< All Tree Model Columns Available to all Tree Views

Why? Because it makes accessing the Column easier later on, which is covered w/in the tutorials I've referred to.

They I assign the "stores" to their rightful TreeViews. However, you'll also see the use of enable_grid_lines & rules_hint. They, they don't work for me and I don't know why. But they're supposed to draw grid lines and hi-lite every other line in the row. From here, it's best to read the tutorials to learn how to use Treeviews in general. They're very helpful and I'd just be repeating what they say.

I hope all goes very well & for the combo boxes within a TreeView Cell, it can be done!!! Buuuuut I'm not exactly sure how. Sorry. :-(

Hope this info helps.... :-)

--
Sincerely, Allen

Gene Allen Saucier, Jr
Senior Software Engineer
CAS, Inc
100 Quality Circle
Huntsville, AL  35806
or
PO Box 11190
Huntsville, AL  35814
(256) 922-6453 (w)
"...As for I and my house, we shall follow the Lord"  Joshua 24:15




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