PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
The opposite to GtkTable::attach() (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: The opposite to GtkTable::attach()
#1000
sutterp (User)
Fresh Boarder
Posts: 19
graphgraph
User Offline Click here to see the profile of this user
The opposite to GtkTable::attach() 2 Months, 3 Weeks ago Karma: 0  
I added a widget to a GtkTable using attach. The widget may span several rows and/or columns.

I now need to remove the widget from the table such that I can attach one or more new widgets in the space the original occupied. I.e. the original widget spanned columns 14 to 20, I have to replace this widget with one that spans columns 15 and 16 and a second one that spans columns 18-20, column 17 is to remain empty.

The widget itself is a class and 'knows' which cells it occupies within the table.

How do I do that? There is no GtkTable::unattach();

widget::destroy() will get rid of the widget, but what about the cells within the table, how do I clear these?

Peter
 
  The administrator has disabled public write access.
#1002
kksou (Admin)
Admin
Posts: 443
graph
User Online Now Click here to see the profile of this user
Re:The opposite to GtkTable::attach() 2 Months, 3 Weeks ago Karma: 8  
Hi Peter,

I've just written a sample code for you, but I don't have time to write the full article yet.

Please take a look at the sample code first:
sample code 0525

I think you should have no problem understanding the code.

Regards,
/kksou
 
  The administrator has disabled public write access.
#1006
sutterp (User)
Fresh Boarder
Posts: 19
graphgraph
User Offline Click here to see the profile of this user
Re:The opposite to GtkTable::attach() 2 Months, 3 Weeks ago Karma: 0  
Many many thanks, kksou

This will get me going. Just one question remains in regard to the following piece of code.
Code:
function remove_widgets($container) {
	foreach($container->get_children() as $widget) {
		$container->remove($widget);
	}
}
Although this function appears not to be used in your example, is this a hint that if the widget is a container widget, the container's children have to be removed before the container widget is removed? Peter
 
 
Last Edit: 2008/10/15 10:36 By sutterp.
  The administrator has disabled public write access.
#1015
kksou (Admin)
Admin
Posts: 443
graph
User Online Now Click here to see the profile of this user
Re:The opposite to GtkTable::attach() 2 Months, 2 Weeks ago Karma: 8  
sutterp wrote:

Although this function appears not to be used in your example, is this a hint that if the widget is a container widget, the container's children have to be removed before the container widget is removed?


Have just finished writing the complete article.

I actually came out with two sample codes - Part 1 and Part 2 - each using a slightly different techniques.

Sample Code 524: How to unattach a widget from GtkTable or replace a GtkTable cell with another widget - Part 1?

Sample Code 525: How to unattach a widget from GtkTable or replace a GtkTable cell with another widget - Part 2?

The function you mentioned is used in Part 1. The solution you wanted is in Part 2. But try to understand Part 1. It allow allow you understand more about GtkTable.

By the way, to answer your question, GtkTable is a subclass of GtkContainer. However, interestingly, you do not have to remove a widget attached to a cell before attaching another one. What this means is that you can actually attach more than one widgets into the same cell! Try it. You will be amazed! For example, you can have a GtkLabel that spans from col 1 to 3, and another GtkLabel that spans from col 1 to 6, yet another from col 2 to 10. That is, you can have both overlapping and multiple widgets in and across different cells. Just remember to keep track of the pointer to each attached widget, and you will be able to remove them one by one and replace them with other widgets.

Regards,
/kksou
 
 
Last Edit: 2008/10/17 00:40 By kksou.
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved