KJS::Value KstBindEllipse::borderColor(KJS::ExecState *exec) const {
  KstViewEllipsePtr d = makeEllipse(_d);
  if (d) {
    KstReadLocker rl(d);
    return KJSEmbed::convertToValue(exec, d->borderColor());
  }
  return KJSEmbed::convertToValue(exec, QColor());
}
KJS::Value KstBindEllipse::borderWidth(KJS::ExecState *exec) const {
  Q_UNUSED(exec)
  KstViewEllipsePtr d = makeEllipse(_d);
  if (d) {
    KstReadLocker rl(d);
    return KJS::Number(d->borderWidth());
  }
  return KJS::Number(0);
}
void KstBindEllipse::setBorderWidth(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned w = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(w)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstViewEllipsePtr d = makeEllipse(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setBorderWidth(w);
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
void KstBindEllipse::setBorderColor(KJS::ExecState *exec, const KJS::Value& value) {
  QVariant cv = KJSEmbed::convertToVariant(exec, value);
  if (!cv.canCast(QVariant::Color)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstViewEllipsePtr d = makeEllipse(_d);
  if (d) {
    KstWriteLocker rl(d);
    d->setBorderColor(cv.toColor());
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
Esempio n. 5
0
int main(int argc, char** argv)
{
    bool timeit = FALSE;
    QApplication app(argc,argv);

    bool scrollbars=FALSE;

    for (int arg=1; arg<argc; arg++) {
	if (0==strcmp(argv[arg],"-bounce")) {
	    bouncers=atoi(argv[++arg]);
	} else if (0==strcmp(argv[arg],"-help") ||
		   0==strcmp(argv[arg],"--help")) {
	    showtext=FALSE;
	} else if (0==strcmp(argv[arg],"-redraws")) {
	    showredraws=TRUE;
	} else if (0==strcmp(argv[arg],"-lines")) {
	    showlines=TRUE;
	} else if (0==strcmp(argv[arg],"-btext")) {
	    btext=FALSE;
	} else if (0==strcmp(argv[arg],"-dsprite")) {
	    dsprite=FALSE;
	} else if (0==strcmp(argv[arg],"-dpoly")) {
	    dpoly=!dpoly;
	} else if (0==strcmp(argv[arg],"-delay")) {
	    refresh_delay=atoi(argv[++arg]);
	} else if (0==strcmp(argv[arg],"-sb")) {
	    scrollbars=TRUE;
	} else if (0==strcmp(argv[arg],"-noopt")) {
	    QPixmap::setDefaultOptimization( QPixmap::NoOptim );
	} else if (0==strcmp(argv[arg],"-bestopt")) {
	    QPixmap::setDefaultOptimization( QPixmap::BestOptim );
#ifdef _WS_WIN_
	} else if (0==strcmp(argv[arg],"-bsm")) {
	    extern bool qt_bitblt_bsm;
	    qt_bitblt_bsm=TRUE;
#endif
	} else if (0==strcmp(argv[arg],"-iter")) {
	    iterations=atoi(argv[++arg]);
	    timeit = TRUE;
	} else {
	    warning("Bad param %s", argv[arg]);
	}
    }

    QMainWindow m;
    MySpriteField field(IMG_BACKGROUND,scrollbars ? WIDTH*3 : WIDTH,
		scrollbars ? HEIGHT*3 : HEIGHT);
    Example example(scrollbars,field,&m);

    QMenuBar* menu = m.menuBar();

    QPopupMenu* file = new QPopupMenu;
    file->insertItem("New view", &example, SLOT(makeSlave()), CTRL+Key_N);
    file->insertSeparator();
    file->insertItem("Quit", qApp, SLOT(quit()), CTRL+Key_Q);
    menu->insertItem("&File", file);

    QPopupMenu* edit = new QPopupMenu;
    edit->insertItem("New polygon", &example, SLOT(makePolygon()));
    edit->insertItem("New ellipse", &example, SLOT(makeEllipse()));
    edit->insertItem("New rectangle", &example, SLOT(makeRectangle()));
    menu->insertItem("&Edit", edit);

    MyPopupMenu* options = new MyPopupMenu;
    options->insertCheckItem("Show help text", &showtext, CTRL+Key_H);
    options->insertCheckItem("Show bouncing text", &btext, CTRL+Key_T);
    options->insertCheckItem("Show polygon", &dpoly, CTRL+Key_P);
    options->insertCheckItem("Show drawn sprite", &dsprite, CTRL+Key_D);
    options->insertCheckItem("Show redraw areas", &showredraws, CTRL+Key_A);
    options->insertCheckItem("Show foreground lines", &showlines, CTRL+Key_L);
    options->insertSeparator();
    options->insertRadioItem("1 bouncer", &bouncers, 1);
    options->insertRadioItem("3 bouncers", &bouncers, 3);
    options->insertRadioItem("10 bouncers", &bouncers, 10);
    options->insertRadioItem("30 bouncers", &bouncers, 30);
    options->insertRadioItem("100 bouncers", &bouncers, 100);
    options->insertRadioItem("1000 bouncers", &bouncers, 1000);
    options->insertSeparator();
    options->insertRadioItem("No delay", &refresh_delay, 0);
    options->insertRadioItem("500 fps", &refresh_delay, 2);
    options->insertRadioItem("100 fps", &refresh_delay, 10);
    options->insertRadioItem("72 fps", &refresh_delay, 14);
    options->insertRadioItem("30 fps", &refresh_delay, 33);
    options->insertRadioItem("10 fps", &refresh_delay, 100);
    options->insertRadioItem("5 fps", &refresh_delay, 200);
    options->insertSeparator();
    options->insertRadioItem("1/10 speed", &speed, 2);
    options->insertRadioItem("1/2 speed", &speed, 10);
    options->insertRadioItem("1x speed", &speed, 20);
    options->insertRadioItem("2x speed", &speed, 40);
    options->insertRadioItem("5x speed", &speed, 100);
    menu->insertItem("&Options",options);
    m.statusBar();

    QObject::connect(options, SIGNAL(variableChanged(bool*)), &example, SLOT(refresh()));
    QObject::connect(options, SIGNAL(variableChanged(int*)), &example, SLOT(refresh()));
    QObject::connect(&example, SIGNAL(status(const char*)), m.statusBar(), SLOT(message(const char*)));
    m.setCentralWidget(&example);
    app.setMainWidget(&m);
    m.show();

    QTime t;
    t.start();
    app.exec();
    if ( timeit )
	debug("%dms",t.elapsed());
    return 0;
}