phpgtk__legacy/wiki1/wiki.d/Code.GtkContainer

30 lines
6.8 KiB
Text

version=pmwiki-1.0.5
newline=²
text=[[include:CodeHintsInc#TopBar#TopBarEnd]]²²!! [[#empty]] Empty {{GtkContainer}}s [---({{GtkBox}}es are {{GtkContainer}}s)---]²²!!!!!a simple function to empty widgets can be²[[include:Main/CodeTable]]²function empty_widget($widget){² if(count($widget->children())!=0){² while(($child=$widget->children[0]->widget)!=NULL){² $widget->remove($child);² }² }²}²[[include:Main/CodeTableEnd]]²!!!!!a more flexible but more complex solution²the next function allow you to use it as a callback function and allow you to preserve the childs widget by passing FALSE as the last parameter.²²[[include:Main/CodeTable]]²<?php²/**² remove and optionnally destroy all child from a widget² @param GtkWidget &$call_widget is the calling widget ² or if is the only Gtkcontainer is the one to empty² @param GtkContainer [&$target_widget] is the gtkcontainer to empty ² if only one Gtkwidget is passed and is a Gtkcontainer ² it would be this one by default² @param bool $destroy_childs default is TRUE ² so the childs widget will be destroy by default,² pass FALSE as last argument to preserve childs widgets² @licence LGPL²**/²function empty_widget(&$call_widget){² # If we receive only one arguments it must be the target widget² $n = func_num_args();² if($n>1){² if(! is_bool($destroy_childs = func_get_arg($n-1)))² unset($destroy_childs);² }² switch($n){² case 1:² if(! is_a($call_widget,"GtkContainer"))² return FALSE;² $widget = &$call_widget;² $destroy_childs = TRUE;² break;² case 2:² if( is_bool($destroy_childs = func_get_arg(1))){² if(! is_a($widget = func_get_arg(0),"GtkContainer"))² return FALSE;² }elseif(is_a($destroy_childs,"GtkContainer")){² $widget = &$destroy_childs;² $destroy_childs = TRUE;² }else{² return FALSE;² }² break;² case 3:² if( is_bool($destroy_childs = func_get_arg(2)))² if(! is_a($widget = func_get_arg(1),"GtkContainer"))² return FALSE;² else² return FALSE;² break;² default:² return FALSE;² }² if(count($widget->children())!=0){² while(is_a(($child=$widget->children[0]->widget),"GtkWidget")){² $widget->remove($child);² if($destroy_childs)² $child->destroy();² }² return TRUE;² }else{² return FALSE;² }²}²?>[[include:Main/CodeTableEnd]]²[[include:CodeHintsInc#BottomBar#BottomBarEnd]]
time=1090874634
diff:1090777242:1090777242:=1,83c1²< [[include:CodeHintsNav]]²< ²< *[[#empty how to empty containers?]]²< ----²< ²< !! [[#empty]]To empty GtkHBox?, GTKVBox, ...²< ²< !!!!!a simple function to empty widgets can be²< %codelines%[=²< function empty_widget($widget){²< if(count($widget->children())!=0){²< while(($child=$widget->children[0]->widget)!=NULL){²< $widget->remove($child);²< }²< }²< }²< =]²< !!!!!a more flexible but more complex solution²< the next function allow you to use it as a callback function and allow you to preserve the childs widget by passing FALSE as the last parameter.²< ²< %codelines%[=²< <?php²< /**²< remove and optionnally destroy all child from a widget²< @param GtkWidget &$call_widget is the calling widget ²< or if is the only Gtkcontainer is the one to empty²< @param GtkContainer [&$target_widget] is the gtkcontainer to empty ²< if only one Gtkwidget is passed and is a Gtkcontainer ²< it would be this one by default²< @param bool $destroy_childs default is TRUE ²< so the childs widget will be destroy by default,²< pass FALSE as last argument to preserve childs widgets²< @licence LGPL²< **/²< function empty_widget(&$call_widget){²< # If we receive only one arguments it must be the target widget²< $n = func_num_args();²< if($n>1){²< if(! is_bool($destroy_childs = func_get_arg($n-1)))²< unset($destroy_childs);²< }²< switch($n){²< case 1:²< if(! is_a($call_widget,"GtkContainer"))²< return FALSE;²< $widget = &$call_widget;²< $destroy_childs = TRUE;²< break;²< case 2:²< if( is_bool($destroy_childs = func_get_arg(1))){²< if(! is_a($widget = func_get_arg(0),"GtkContainer"))²< return FALSE;²< }elseif(is_a($destroy_childs,"GtkContainer")){²< $widget = &$destroy_childs;²< $destroy_childs = TRUE;²< }else{²< return FALSE;²< }²< break;²< case 3:²< if( is_bool($destroy_childs = func_get_arg(2)))²< if(! is_a($widget = func_get_arg(1),"GtkContainer"))²< return FALSE;²< else²< return FALSE;²< break;²< default:²< return FALSE;²< }²< if(count($widget->children())!=0){²< while(is_a(($child=$widget->children[0]->widget),"GtkWidget")){²< $widget->remove($child);²< if($destroy_childs)²< $child->destroy();²< }²< return TRUE;²< }else{²< return FALSE;²< }²< }²< ?>=]²< [[#top top]]²< ----²---²> Describe GtkContainer here.²\ No newline at end of file²
author=nathan
author:1090777242=nathan
host:1090777242=82.124.244.245
name=Code.GtkContainer
host=82.120.149.253
agent=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040615 Firefox/0.8 StumbleUpon/1.908
rev=7
diff:1090777523:1090777242:minor=6c6²< !! [[#empty]] Empty {{GtkContainer}}s [---({{GtkBox}}es are {{GtkContainer}}s)---]²---²> !! [[#empty]]To empty GtkHBox?, GTKVBox, ...²
author:1090777523=nathan
host:1090777523=82.124.244.245
diff:1090801461:1090777523:minor=1c1,2²< [[include:CodeHintsInc#Topbar#TopBarEnd]]²---²> [[include:CodeHintsNav]]²> ²81c82,83²< [[include:CodeHintsInc#BottomBar#BottomBarEnd]]²\ No newline at end of file²---²> [[#top top]]²> ----²
author:1090801461=nathan
host:1090801461=82.124.244.245
diff:1090801502:1090801461:minor=1c1²< [[include:CodeHintsInc#TopBar#TopBarEnd]]²---²> [[include:CodeHintsInc#Topbar#TopBarEnd]]²81c81²< [[include:CodeHintsInc#Bottombar#BottomBarEnd]]²\ No newline at end of file²---²> [[include:CodeHintsInc#BottomBar#BottomBarEnd]]²\ No newline at end of file²
author:1090801502=nathan
host:1090801502=82.124.244.245
diff:1090801534:1090801502:minor=81c81²< [[include:CodeHintsInc#BottomBar#BottomBarEnd]]²\ No newline at end of file²---²> [[include:CodeHintsInc#Bottombar#BottomBarEnd]]²\ No newline at end of file²
author:1090801534=nathan
host:1090801534=82.124.244.245
diff:1090801660:1090801534:minor=1a2,3²> *[[#empty how to empty containers?]]²> ----²
author:1090801660=nathan
host:1090801660=82.124.244.245
diff:1090874634:1090801660:minor=6c6²< [[include:Main/CodeTable]]²---²> %codelines%[=²14c14²< [[include:Main/CodeTableEnd]]²---²> =]²18c18²< [[include:Main/CodeTable]]²---²> %codelines%[=²78c78²< ?>[[include:Main/CodeTableEnd]]²---²> ?>=]²
author:1090874634=nathan
host:1090874634=82.120.149.253