OxyScripts.com
Menu spacer Home Tutorials Articles Code Forums irc.freenode.net #oxyscripts
Main (PHP)
Home Forums PHP News PHP Tutorials Articles PHP Code Snippets Contact Us Sysadmin Resources Books Template Shop
3rd Party Streams
SlashDot PHPDeveloper.org PHP.Net
Resources
PHP Manual MySQL Manual Smarty Manual PEAR Manual PHP-GTK Manual Symfony Manual
Code Snippets
Authentication Database Graphics HTTP Miscellaneous Time/Date
Affiliates
Scripts TutorialMan TutorialGuide CodingForums.com PHP Scripts Cheap Web Hosting Affordable Web Hosting Dreamweaver Templates

Search This Site :     PHP Function Reference :
 
GtkSpinButton Constructor

GtkSpinButton Constructor

GtkSpinButton ([ GtkAdjustment adjustment = NULL , [double climb_rate = 0.0 , [int digits = 0 ]]]);

Although the first parameter adjustment is optional, you will find it impossible to create a working GtkSpinButton without harnessing it to an appropriately defined GtkAdjustment, as the first five parameters of the adjustment need to be set for the spinbutton widget to operate. You may either associate the adjustment at this point, or use the set_adjustment() or configure() method at a later point in your script.

climb_rate refers to the speed of the spin, rather than its incremental value. Its default setting is 0.0, which runs the internal timer at 20ms per increment (following a 200ms start from the button press). If you intend using this parameter, the value given needs to be fairly high in order for it to make an appreciable difference.

The digits parameter controls the number of decimal places displayed.

Example 40. Creating a GtkSpinButton calendar.

<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function collect($d, $m, $y) {
  echo $d->get_value_as_int(). "-" .$m->get_value_as_int(). 
"-" .$y->get_value_as_int()."\n";
  flush();
}

$window = &new GtkWindow();
$window->set_position(GTK_WIN_POS_CENTER);
$window->connect_object('destroy', array('gtk', 'main_quit'));

$vbox = &new GtkVBox(false, 5);
$window->add($vbox);

$hbox = &new GtkHBox(false, 5);
$hbox->set_border_width(5);
$vbox->add($hbox);

$daylabel = &new GtkLabel("Day:");
$hbox->pack_start($daylabel, false);

$day = date("d");
$dayadj = &new GtkAdjustment($day, 1.0, 31.0, 1.0, 7.0, 0.0);
$dayspin = &new GtkSpinButton($dayadj);
$dayspin->set_wrap(true);
$hbox->pack_start($dayspin, false);

$monthlabel = &new GtkLabel("Month:");
$hbox->pack_start($monthlabel, false);

$month = date("m");
$monthadj = &new GtkAdjustment($month, 1.0, 12.0, 1.0, 3.0, 0.0);
$monthspin = &new GtkSpinButton($monthadj);
$monthspin->set_wrap(true);
$hbox->pack_start($monthspin, false);

$yearlabel = &new GtkLabel("Year:");
$hbox->pack_start($yearlabel, false);

$year = date("Y");
$yearadj = &new GtkAdjustment($year, $year-90, $year+10, 1.0, 5.0, 0.0);
$yearspin = &new GtkSpinButton($yearadj);
$yearspin->set_usize(55, 0);
$hbox->pack_start($yearspin, false);

$button = &new GtkButton("Collect data");
$button->connect_object('clicked', 'collect', $dayspin, $monthspin, 
$yearspin);
$vbox->add($button);

$vbox->show_all();
$hbox->show_all();
$window->show_all();

gtk::main();

?>
See also: GtkAdjustment's "value-changed" signal.

 
   Print this page

Top Sponsor
Symantec\'s Norton SystemWorks 2006
Sponsors
CA
Sponsors
AdWords Dominator 125*125
Advertisting

Affiliates
VertexTemplates PHPFreaks CodeWalkers StarGeek DevScripts CGI & PHP Scripts PHP CMS

Shopping Rebates   Sell It 4 You   Flash Page Counters   Get Insured
GPS Tracking Service   Charity Donate Info   Web Site Hosting   VOIP Service

Privacy Policy | Links | Site Map | Advertising

All content on OxyScripts.com is (©)2002-2007

 
Powered by Adrastea - Version 1.0.0. Copyright © Rune Solutions, 2004-2005