Added three more examples over the past few days:
shows how to set column headers and row labels in a GtkSheet. Key methods used: GtkSheet::column_button_add_label(), GtkSheet::row_button_add_label(), GtkSheet::column_button_justify().
shows how to set a GtkSheet in browser mode i.e. user can only browse but not edit the cell contents - similar to a standard GtkTreeView. Key method used: GtkSheet::new_browser().
- http://www.kksou.com/php-gtk2/articles/use-GtkSheet—Part-7—tab-to-move-to-next-row.php. By default, when you press the Tab key and it reaches the last column, it will stay at that cell. Suppose you would like the Tab key to move the active cell automatically to the first column of the next row. A GtkSheet is just like any other standard Gtk widget. As such, you can have precise control of the behavior of keys through the GtkWidget::key-press-event(). Key method used: GtkSheet::get_active_cell(), GtkSheet::set_active_cell().
I’ve actually tried a lot more stuff on GtkSheet. If you’re interested, below are some of the more interesting (or frustrating) ones…
Have wanted to show an example that illustrates alternate color rows. However, the method GtkSheet::range_set_background() is not imported into php-gtk2 yet. Please see http://www.kksou.com/php-gtk2/forum/viewtopic.php?p=152#152 for details. It’s still possible to display alternate color rows without using this method. Will try to come out with a sample code for this later.
Have also tried GtkSheet::new_with_custom_entry(). By default, a GtkSheet uses GtkItemEntry for the cell entry. with this method, you can change it to use a standard GtkEntry or any GtkEntry subclass. Looks easy, but took me two days to figure out how what’s that last parameter GtkType!!! It always makes me wonder why do they want to make it so difficult, when it’s so straightforward and powerful!
I’ll definitely come out with the sample code to show you how to use GtkSheet::new_with_custom_entry(). But before that, I’m still trying to understand what’s the key difference between using a GtkItemEntry for the cell, compared with using a standard GtkEntry. I think GtkItemEntry is a subclass of GtkEntry. So is there any advantage to use a GtkEntry? Anybody got any clue?
I also got stuck for three days trying to understand the method GtkSheet::attach(). This is an extremely powerful method! With this method, you can attach almost any standard widget to a cell, similar to GtkTable::attach(). However, what puzzled me is that while you will find no problem attaching a widget to a cell, it seems that the underlying GtkItemEntry is active too! So when you use a mouse, you activate the attached widget. But when you use the keyboard, you will see the underlying GtkItemEntry. It’s confusing and messy. I still don’t know whether this is a bug or a feature, and how to “deactivate” the underlying GtkItemEntry.
Any expert out there who can give me some pointers?
The place for php-gtk2 sample codes