01 May 2013 - After the site upgrade, all passwords were reset and you will need to ask the site for a login reset on your first connection.
The Dial widget is a graphical object which displays
an analog value. This is a direct port of the Gtk
tutorial about creating
graphical
widgets
The Dial widget can display a value from
-120 to 120. This could be changed, just write the right
mathematical operations (I'm a bit lazy, guys). This widget can
draw directly into a Window (direct drawing) or draw into a
pixmap, which we can then refresh as needed ; just look at
the class source code to see how it is done.
Direct draw is much faster for large windows ; I can't see differences for small ones. The actual graphical part (drawing the dial) is a php-gtk port from the Gtk tutorial. This widget is a good start when you need to build dynamic graphical widgets like this one.
<?php
$dial = new Dial(); # (1)
$dial->set_size_request(80, 80);
$dial->set_value(0);
$window = new GtkWindow();
$window->connect_simple('destroy', array('gtk', 'main_quit'));
$window->set_title('Dial demo');
$window->set_position(Gtk::WIN_POS_CENTER);
$window->set_border_width(8);
$window->add($dial); # (2)
$window->show_all();
Gtk::timeout_add(100, 'dial_timeout', $dial); # (3)
Gtk::main();
/**
* a timeout function to change the dial value from -120 to 120
* giving an animation to the widget.
*/
function dial_timeout($dial)
{
static $value = 0;
static $increment = 4;
if ($value < -120)
$increment *= -1 ;
if ($value > 120)
$increment *= -1;
$value += $increment;
# $dial->set_value($value / 180*PI);
$dial->set_value($value); # (4)
Gtk::timeout_add(20, 'dial_timeout', $dial);
return FALSE;
}
?>$dial->set_value($val)
See the attached sources file below
| Allegato | Dimensione |
|---|---|
| gtk-drawing-area-dial.php_.txt | 6.31 KB |
Commenti recenti
43 settimane 4 giorni fa
44 settimane 3 giorni fa
45 settimane 16 ore fa
47 settimane 3 giorni fa
1 anno 15 settimane fa
1 anno 19 settimane fa
1 anno 23 settimane fa
1 anno 23 settimane fa
1 anno 23 settimane fa
1 anno 40 settimane fa