function testVirtualMethod()
 {
     echo "\ntesting calling a virtual method";
     $argc = 1;
     $argv = array("argv");
     $app = new MyApplication($argc, $argv);
     $myWidget = new MyWidget();
     $myWidget->show();
     $app->exec();
     echo " passed";
 }
Example #2
0
$t->diag('::escapeOnce()');
$t->is(sfWidget::escapeOnce('This a > text to "escape"'), 'This a > text to "escape"', '::escapeOnce() escapes an HTML strings');
$t->is(sfWidget::escapeOnce(sfWidget::escapeOnce('This a > text to "escape"')), 'This a > text to "escape"', '::escapeOnce() does not escape an already escaped string');
$t->is(sfWidget::escapeOnce('This a > text to "escape"'), 'This a > text to "escape"', '::escapeOnce() does not escape an already escaped string');
class MyClass
{
    public function __toString()
    {
        return 'mycontent';
    }
}
$t->is(sfWidget::escapeOnce(new MyClass()), 'mycontent', '::escapeOnce() converts objects to string');
// ::fixDoubleEscape()
$t->diag('::fixDoubleEscape()');
$t->is(sfWidget::fixDoubleEscape(htmlspecialchars(htmlspecialchars('This a > text to "escape"'), ENT_QUOTES, sfWidget::getCharset()), ENT_QUOTES, sfWidget::getCharset()), 'This a > text to "escape"', '::fixDoubleEscape() fixes double escaped strings');
// ::getCharset() ::setCharset()
$t->diag('::getCharset() ::setCharset()');
$t->is(sfWidget::getCharset(), 'UTF-8', '::getCharset() returns the charset to use for widgets');
sfWidget::setCharset('ISO-8859-1');
$t->is(sfWidget::getCharset(), 'ISO-8859-1', '::setCharset() changes the charset to use for widgets');
// ::setXhtml() ::isXhtml()
$t->diag('::setXhtml() ::isXhtml()');
$w = new MyWidget();
$t->is(sfWidget::isXhtml(), true, '::isXhtml() return true if the widget must returns XHTML tags');
sfWidget::setXhtml(false);
$t->is($w->renderTag('input', array('value' => 'Test')), '<input value="Test">', '::setXhtml() changes the value of the XHTML tag');
// ->getJavaScripts() ->getStylesheets()
$t->diag('->getJavaScripts() ->getStylesheets()');
$w = new MyWidget();
$t->is($w->getJavaScripts(), array(), '->getJavaScripts() returns an array of stylesheets');
$t->is($w->getStylesheets(), array(), '->getStylesheets() returns an array of JavaScripts');
Example #3
0
 function GamePage()
 {
     parent::MyWidget();
     $this->layoutViewFile = 'layout' . DIRECTORY_SEPARATOR . 'form.phtml';
     $this->globalModel = new GlobalModel();
 }
Example #4
0
}
require_once 'cannonfield.php';
require_once 'lcdrange.php';
class MyWidget extends QWidget
{
    public function __construct()
    {
        parent::__construct();
        $quit = new QPushButton(tr("Quit"));
        $quit->setFont(new QFont("Times", 18, QFont::Bold));
        QObject::connect($quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()'));
        $angle = new LCDRange();
        $angle->setRange(5, 70);
        $cannonField = new CannonField();
        QObject::connect($angle, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setAngle(int)'));
        QObject::connect($cannonField, SIGNAL('angleChanged(int)'), $angle, SLOT('setValue(int)'));
        $gridLayout = new QGridLayout();
        $gridLayout->addWidget($quit, 0, 0);
        $gridLayout->addWidget($angle, 1, 0);
        $gridLayout->addWidget($cannonField, 1, 1, 2, 1);
        $gridLayout->setColumnStretch(1, 10);
        $this->setLayout($gridLayout);
        $angle->setValue(60);
        $angle->setFocus();
    }
}
$app = new QApplication($argc, $argv);
$widget = new MyWidget();
$widget->setGeometry(100, 100, 500, 355);
$widget->show();
$app->exec();
Example #5
0
    dl('php_qt.' . PHP_SHLIB_SUFFIX);
}
class MyWidget extends QWidget
{
    private $quit;
    private $slider;
    private $layout;
    private $lcd;
    function __construct()
    {
        parent::__construct();
        $this->quit = new QPushButton(tr("Quit"));
        $this->quit->setFont(new QFont("Times", 18, QFont::Bold));
        $this->lcd = new QLCDNumber(2);
        $this->lcd->setSegmentStyle(QLCDNumber::Filled);
        $this->slider = new QSlider(Qt::Horizontal);
        $this->slider->setRange(0, 99);
        $this->slider->setValue(0);
        $this->connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()'));
        $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this->lcd, SLOT('display(int)'));
        $this->layout = new QVBoxLayout();
        $this->layout->addWidget($this->quit);
        $this->layout->addWidget($this->lcd);
        $this->layout->addWidget($this->slider);
        $this->setLayout($this->layout);
    }
}
$app = new QApplication($argc, $argv);
$widget = new MyWidget();
$widget->show();
$app->exec();