Manuel PHP-GTK

GtkText Constructor

GtkText ([ GtkAdjustment hadj = NULL , [ GtkAdjustment vadj = NULL ]]);

Creates a text widget that is by default scrollable up and down using the bound keys given below, when there is enough text present. The horizontal adjustment, and therefore the horizontal scrolling, do not work; the horizontal adjustment parameter in the constructor should always be declared as null (the default setting) for that reason.

Tableau 7. Key bindings for scrolling GtkText

Key combination Scroll function
Control + Home Move to the top of the text
Control + End Move to the end of the text
Page Up Move up one page increment
Page Down Move down one page increment
Up arrow Move up one line
Down arrow Move down one line

Exemple 42. Adding a scrollbar to a GtkText widget

  1. <?php
  2.  
  3. dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));  
  4.  
  5. $window = &new GtkWindow();  
  6. $window->set_position(GTK_WIN_POS_CENTER);  
  7. $window->connect_object('destroy', array('gtk', 'main_quit'));  
  8.  
  9. $box = &new GtkHBox();  
  10. $window->add($box);  
  11.  
  12. $text = &new GtkText();  
  13. $text->set_word_wrap(true);  
  14. $string = "This is a string of text which will be displayed in the
  15. GtkText widget.\n\nIt isn't long enough to allow scrolling, so you will
  16. probably need to extend it.\n\nOn the other hand, the box isn't sized, so
  17. it may just creep over that limit and be a useful demonstration after
  18. all.";  
  19. if(strstr(PHP_OS, 'WIN')) $string = wordwrap($string, 26);  
  20. $text->insert_text($string, 0);  
  21. $box->pack_start($text);  
  22.  
  23. $adj = $text->vadj;  
  24. $scrollbar = &new GtkVScrollbar($adj);  
  25. $box->pack_end($scrollbar, false);  
  26.  
  27. $window->show_all();  
  28.  
  29. gtk::main();  
  30.  
  31.  
  32. ?> 

Remonter Remonter
L'éditeur javascript - CSS - Gentoo - Tutoriaux PHP - Tutoriels PHP - Bretagne - php - Moto - Kit graphique