当前位置: 首页>>代码示例>>C++>>正文


C++ Global类代码示例

本文整理汇总了C++中Global的典型用法代码示例。如果您正苦于以下问题:C++ Global类的具体用法?C++ Global怎么用?C++ Global使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Global类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create_sk_window

SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
    printf("Started\n");

    SkCommandLineFlags::Parse(argc, argv);

    // Get the default Isolate created at startup.
    Isolate* isolate = Isolate::GetCurrent();
    Global* global = new Global(isolate);


    // Set up things to look like a browser by creating
    // a console object that invokes our print function.
    const char* startupScript =
            "function Console() {};                   \n"
            "Console.prototype.log = function() {     \n"
            "  var args = Array.prototype.slice.call(arguments).join(' '); \n"
            "  print(args);                      \n"
            "};                                       \n"
            "console = new Console();                 \n";

    if (!global->parseScript(startupScript)) {
        printf("Failed to parse startup script: %s.\n", FLAGS_infile[0]);
        exit(1);
    }

    const char* script =
            "function onDraw(canvas) {              \n"
            "    canvas.fillStyle = '#00FF00';      \n"
            "    canvas.fillRect(20, 20, 100, 100); \n"
            "    canvas.inval();                    \n"
            "}                                      \n";

    SkAutoTUnref<SkData> data;
    if (FLAGS_infile.count()) {
        data.reset(SkData::NewFromFileName(FLAGS_infile[0]));
        script = static_cast<const char*>(data->data());
    }
    if (NULL == script) {
        printf("Could not load file: %s.\n", FLAGS_infile[0]);
        exit(1);
    }
    Path2D::AddToGlobal(global);

    if (!global->parseScript(script)) {
        printf("Failed to parse file: %s.\n", FLAGS_infile[0]);
        exit(1);
    }


    JsContext* jsContext = new JsContext(global);

    if (!jsContext->initialize()) {
        printf("Failed to initialize.\n");
        exit(1);
    }
    SkV8ExampleWindow* win = new SkV8ExampleWindow(hwnd, jsContext);
    global->setWindow(win);

    return win;
}
开发者ID:Adenilson,项目名称:skia,代码行数:60,代码来源:SkV8Example.cpp

示例2: tolua_LuaAPI_Global_setDataRootDirectory00

/* method: setDataRootDirectory of class  Global */
static int tolua_LuaAPI_Global_setDataRootDirectory00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
 !tolua_isusertype(tolua_S,1,"Global",0,&tolua_err) || 
 !tolua_isstring(tolua_S,2,0,&tolua_err) || 
 !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
 goto tolua_lerror;
 else
#endif
 {
  Global* self = (Global*)  tolua_tousertype(tolua_S,1,0);
  const char* s = ((const char*)  tolua_tostring(tolua_S,2,0));
#ifndef TOLUA_RELEASE
 if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDataRootDirectory'",NULL);
#endif
 {
  self->setDataRootDirectory(s);
 }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'setDataRootDirectory'.",&tolua_err);
 return 0;
#endif
}
开发者ID:cpzhang,项目名称:zen,代码行数:30,代码来源:LuaAPI.cpp

示例3: QWidget

ScatterPlotWidget::ScatterPlotWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ScatterPlotWidget),
    selectedTrips(NULL),
    selectionGraph(NULL)
{
    ui->setupUi(this);

    attrib1 = getAttrib(ui->comboBox->currentText());
    attrib2 = getAttrib(ui->comboBox_2->currentText());

    //
    Global* global = Global::getInstance();
    int numExtraFields = global->numExtraFields();
    for(int i = 0 ; i < numExtraFields ; ++i){
        ExtraField field = global->getExtraField(i);
        if(field.active){
            ui->comboBox->addItem(field.screenName);
            ui->comboBox_2->addItem(field.screenName);
        }
    }

    // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
    connect(ui->customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
    connect(ui->customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

    //
    updatePlot();
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:29,代码来源:scatterplotwidget.cpp

示例4: getScore

int Player::getScore() {
    Global *g = Global::get();
    int computedScore = 0;
    for (Item &item : items) {
        computedScore += item.getValue();
    }
    return (computedScore * g->getDifficulty() + getSteps());
}
开发者ID:jm-janzen,项目名称:termq,代码行数:8,代码来源:Player.cpp

示例5: main

int main(int argc, char **argv)
{
    // expecting a filename
    if (argc < 2) {
        fprintf(stderr, "You have to specify at least one filename\n");
        return -1;
    }

    bool ret = true;
    {
        JSLock lock;

        // create interpreter w/ global object
        Global* global = new Global();
        RefPtr<Interpreter> interp = new Interpreter(global);
        ExecState *exec = interp->globalExec();

        MyObject *myObject = new MyObject();
        RefPtr<RootObject> root = RootObject::create(0, interp);
        global->put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::BalLanguage, (void *)myObject, root));

        for (int i = 1; i < argc; i++) {
            const char *code = readJavaScriptFromFile(argv[i]);

            if (code) {
                // run
                Completion comp(interp->evaluate("", 0, code));

                /*if (comp.complType() == Throw) {
                    JSValue *exVal = comp.value();
                    char *msg = exVal->toString(exec).ascii();
                    int lineno = -1;
                    if (exVal->type() == ObjectType) {
                        JSValue *lineVal = exVal->getObject()->get(exec, Identifier("line"));
                        if (lineVal->type() == NumberType)
                            lineno = int(lineVal->toNumber(exec));
                    }
                    if (lineno != -1)
                        fprintf(stderr,"Exception, line %d: %s\n",lineno,msg);
                    else
                        fprintf(stderr,"Exception: %s\n",msg);
                    ret = false;
                }
                else if (comp.complType() == ReturnValue) {
                    char *msg = comp.value()->toString(interp->globalExec()).ascii();
                    fprintf(stderr,"Return value: %s\n",msg);
                }*/
            }
        }

        delete myObject;

    } // end block, so that Interpreter and global get deleted

    return ret ? 0 : 3;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:56,代码来源:testbalbindings.cpp

示例6: env

QSObject QuickInterpreter::object(const QString &name) const
{
    QSObject g = env()->globalObject();
    Global *global = (Global*)&g; // ### ugly
    QSObject obj;
    if (name.isEmpty()) {
	obj = g;
    } else {
	int p = name.lastIndexOf('.');
	if (p == -1)
	    obj = global->get(name);
	else
	    obj = global->getQualified(name);
    }
    return obj;
}
开发者ID:aschet,项目名称:qsaqt5,代码行数:16,代码来源:quickinterpreter.cpp

示例7: preGameTracker

void preGameTracker(int x, int y) {
	globe.getGlobal()->mX = x;
	globe.getGlobal()->mY = y;
	if (x > 1.5) {
		menu = ( y / 150);		
	}
}
开发者ID:JUSTIVE,项目名称:ballRollPool,代码行数:7,代码来源:pregame.cpp

示例8: QDialog

// Constructor. Thys happens when the class is declared.
NotebookProperties::NotebookProperties(QWidget *parent) :
    QDialog(parent)
{
    okPressed = false;
    setWindowTitle(tr("Notebook"));
    setWindowIcon(global.getIconResource(":notebookSmallIcon"));
    setLayout(&grid);

    syncBox.setText(tr("Synchronized"));
    syncBox.setChecked(true);
    syncBox.setEnabled(false);

    defaultNotebook.setText(tr("Default"));
    defaultNotebook.setChecked(false);
    defaultNotebook.setEnabled(true);

    connect(&name, SIGNAL(textChanged(const QString&)), this, SLOT(validateInput()));

    nameLabel.setText(tr("Name"));
    queryGrid.addWidget(&nameLabel, 1,1);
    queryGrid.addWidget(&name, 1, 2);
    queryGrid.addWidget(&syncBox, 2,2);
    queryGrid.addWidget(&defaultNotebook, 3,2);
//    queryGrid.setContentsMargins(10, 10,  -10, -10);
    grid.addLayout(&queryGrid,1,1);

    ok.setText(tr("OK"));
    connect(&ok, SIGNAL(clicked()), this, SLOT(okButtonPressed()));
    cancel.setText(tr("Cancel"));
    connect(&cancel, SIGNAL(clicked()), this, SLOT(cancelButtonPressed()));
    buttonGrid.addWidget(&ok, 1, 1);
    buttonGrid.addWidget(&cancel, 1,2);
    grid.addLayout(&buttonGrid,2,1);
    this->setFont(global.getGuiFont(font()));
}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:36,代码来源:notebookproperties.cpp

示例9: QDialog

LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent)
{
    okPressed = false;
    setWindowTitle(tr("NixNote Login"));
    setWindowIcon(global.getIconResource(":passwordIcon"));
    setLayout(&grid);

    password.setEchoMode(QLineEdit::Password);

    connect(&userid, SIGNAL(textChanged(const QString&)), this, SLOT(validateInput()));
    connect(&password, SIGNAL(textChanged(const QString&)), this, SLOT(validateInput()));

    useridLabel.setText(tr("Userid"));
    passwordLabel.setText(tr("Password"));
    passwordGrid.addWidget(&useridLabel, 1,1);
    passwordGrid.addWidget(&userid, 1, 2);
    passwordGrid.addWidget(&passwordLabel, 2,1);
    passwordGrid.addWidget(&password, 2, 2);
    passwordGrid.setContentsMargins(10, 10,  -10, -10);
    grid.addLayout(&passwordGrid,1,1);

    ok.setText(tr("OK"));
    if (global.password == "" and global.username == "")
        ok.setEnabled(false);
    connect(&ok, SIGNAL(clicked()), this, SLOT(okButtonPressed()));
    cancel.setText(tr("Cancel"));
    connect(&cancel, SIGNAL(clicked()), this, SLOT(cancelButtonPressed()));
    buttonGrid.addWidget(&ok, 1, 1);
    buttonGrid.addWidget(&cancel, 1,2);
    grid.addLayout(&buttonGrid,2,1);
    grid.setSizeConstraint( QLayout::SetFixedSize );
    this->setFont(global.getGuiFont(font()));
}
开发者ID:AustinPowered,项目名称:Nixnote2,代码行数:34,代码来源:logindialog.cpp

示例10: createThemeMenu

void NMainMenuBar::createThemeMenu(QMenu *parentMenu) {
    QMenu *menu = parentMenu->addMenu(tr("Theme"));
    QStringList list = global.getThemeNames();
    QFont f = global.getGuiFont(QFont());

    global.settings->beginGroup(INI_GROUP_APPEARANCE);
    QString userTheme = global.settings->value("themeName", DEFAULT_THEME_NAME).toString();
    global.settings->endGroup();


    // Setup themes (we expect to find the DEFAULT_THEME_NAME theme as first one)
    for (int i = 0; i < list.size(); i++) {
        QString themeName(list[i]);
        if ((i == 0) && (QString::compare(themeName, DEFAULT_THEME_NAME, Qt::CaseInsensitive) != 0)) {
            QLOG_ERROR() << "First theme is expected to be " << DEFAULT_THEME_NAME;
        }


        QAction *themeAction = new QAction(themeName, this);
        themeAction->setData(themeName);
        themeAction->setCheckable(true);
        themeAction->setFont(f);
        connect(themeAction, SIGNAL(triggered()), parent, SLOT(reloadIcons()));
        if (themeName == userTheme) {
            themeAction->setChecked(true);
        }
        themeActions.append(themeAction);
    }
    menu->addActions(themeActions);
    menu->setFont(f);
}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:31,代码来源:nmainmenubar.cpp

示例11: tempTable

//*****************************************
//* This class is used to connect to the
//* database.
//*****************************************
DatabaseConnection::DatabaseConnection(QString connection)
{
    dbLocked = Unlocked;
    this->connection = connection;
    QLOG_DEBUG() << "SQL drivers available: " << QSqlDatabase::drivers();
    QLOG_TRACE() << "Adding database SQLITE";
    conn = QSqlDatabase::addDatabase("QSQLITE", connection);
    QLOG_TRACE() << "Setting DB name";
    conn.setDatabaseName(global.fileManager.getDbDirPath("nixnote.db"));
    QLOG_TRACE() << "Opening database";
    if (!conn.open()) {
        QLOG_ERROR() << "Error opening database: " << conn.lastError();
        exit(16);
    }

    if (connection == "nixnote")
        global.db = this;
    QLOG_TRACE() << "Preparing tables";
    // Start preparing the tables
    configStore = new ConfigStore(this);
    dataStore = new DataStore(this);

    NSqlQuery tempTable(this);
//    tempTable.exec("pragma cache_size=8096");
//    tempTable.exec("pragma page_size=8096");
    tempTable.exec("pragma busy_timeout=50000");
    tempTable.exec("pragma journal_mode=wal");

//    tempTable.exec("pragma SQLITE_THREADSAFE=2");
    if (connection == "nixnote") {
        tempTable.exec("pragma COMPILE_OPTIONS");
        QLOG_DEBUG() << "*** SQLITE COMPILE OPTIONS ***";
        while (tempTable.next()) {
            QLOG_DEBUG() << tempTable.value(0).toString();
        }

        int value = global.getDatabaseVersion();
        if (value < 2) {
            QLOG_DEBUG() << "*****************";
            QLOG_DEBUG() << "Upgrading Database";
            DatabaseUpgrade dbu;
            dbu.fixSql();
        }
        global.setDatabaseVersion(2);
    }

    QLOG_TRACE() << "Creating filter table";
    tempTable.exec("Create table if not exists filter (lid integer)");
    tempTable.exec("delete from filter");
    QLOG_TRACE() << "Adding to filter table";
    tempTable.exec("insert into filter select distinct lid from NoteTable;");
    QLOG_TRACE() << "Addition complete";
    tempTable.finish();


}
开发者ID:artmg,项目名称:Nixnote2,代码行数:60,代码来源:databaseconnection.cpp

示例12: QLineEdit

TreeWidgetEditor::TreeWidgetEditor(QTreeWidget *parent) :
    QLineEdit(parent)
{
    this->parent = parent;
    this->setFont(global.getGuiFont(font()));
    lid = 0;
    stackName = "";
    connect(this, SIGNAL(returnPressed()), SLOT(textChanged()));

    QString css = global.getThemeCss("treeWidgetEditorCss");
    if (css!="")
        this->setStyleSheet(css);

}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:14,代码来源:treewidgeteditor.cpp

示例13: saveValues

void LocalePreferences::saveValues() {
    int dateFormat = getDateFormatNo();
    int timeFormat = getTimeFormatNo();
    QString translation = getTranslation();

    global.settings->beginGroup(INI_GROUP_LOCALE);
    global.settings->setValue("translation", translation);
    global.settings->setValue("dateFormat", dateFormat);
    global.settings->setValue("timeFormat", timeFormat);
    global.settings->endGroup();


    global.setDateFormat(dateFormat);
    global.setTimeFormat(timeFormat);
}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:15,代码来源:localepreferences.cpp

示例14: QWidget

PopplerViewer::PopplerViewer(const QString &mimeType, const QString &reslid, QWidget *parent) :
    QWidget(parent)
{
    this->mimeType = mimeType;
    this->lid = reslid.toInt();
    printImageFile = global.fileManager.getTmpDirPath() + QString::number(lid) +QString("-print.png");
    QString file = global.fileManager.getDbaDirPath() + reslid +".pdf";
    doc = Poppler::Document::load(file);
    if (doc == NULL || doc->isLocked())
        return;

    currentPage = 0;

    totalPages = doc->numPages();

    image = new QImage(doc->page(currentPage)->renderToImage());
    scene = new QGraphicsScene();
    view = new PopplerGraphicsView(scene);
    view->filename = file;
    item = new QGraphicsPixmapItem(QPixmap::fromImage(*image));
    image->save(printImageFile);   // This is in case we want to print a note.  Otherwise it isn't used.
    scene->addItem(item);
    view->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

    QHBoxLayout *buttonLayout = new QHBoxLayout();
    pageLabel = new QLabel(tr("Page ") +QString::number(currentPage+1) + QString(tr(" of ") +QString::number(totalPages)), this);
    pageLeft = new QPushButton();
    pageRight = new QPushButton();
    pageRight->setMaximumWidth(30);
    pageLeft->setMaximumWidth(30);
    pageLeft->setIcon(global.getIconResource(":leftArrowIcon"));
    pageRight->setIcon(global.getIconResource(":rightArrowIcon"));
    buttonLayout->addStretch(100);
    buttonLayout->addWidget(pageLeft);
    buttonLayout->addWidget(pageLabel);
    buttonLayout->addWidget(pageRight);
    buttonLayout->addStretch(100);
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addLayout(buttonLayout);
    layout->addWidget(view);
    this->setLayout(layout);
    connect(pageRight, SIGNAL(clicked()), this, SLOT(pageRightPressed()));
    connect(pageLeft, SIGNAL(clicked()), this, SLOT(pageLeftPressed()));
    if (totalPages == 1) {
        pageRight->setEnabled(false);
    }
    pageLeft->setEnabled(false);
}
开发者ID:KlemensWinter,项目名称:Nixnote2,代码行数:48,代码来源:popplerviewer.cpp

示例15: loadFontNames

// Load the list of font names
void EditorButtonBar::loadFontNames() {
    if (global.forceWebFonts){
        QStringList fontFamilies;
        fontFamilies.append("Gotham");
        fontFamilies.append("Georgia");
        fontFamilies.append("Helvetica");
        fontFamilies.append("Courier New");
        fontFamilies.append("Times New Roman");
        fontFamilies.append("Times");
        fontFamilies.append("Trebuchet");
        fontFamilies.append("Verdana");
        fontFamilies.sort();
        bool first = true;

        for (int i = 0; i < fontFamilies.size(); i++) {
            fontNames->addItem(fontFamilies[i], fontFamilies[i].toLower());
            QFont f;
            global.getGuiFont(f);
            f.setFamily(fontFamilies[i]);
            fontNames->setItemData(i, QVariant(f), Qt::FontRole);
            if (first) {
                loadFontSizeComboBox(fontFamilies[i]);
                first=false;
            }
        }
        return;
    }

    // Load up the list of font names
    QFontDatabase fonts;
    QStringList fontFamilies = fonts.families();
    fontFamilies.append(tr("Times"));
    fontFamilies.sort();
    bool first = true;

    for (int i = 0; i < fontFamilies.size(); i++) {
        fontNames->addItem(fontFamilies[i], fontFamilies[i].toLower());
        QFont f;
        global.getGuiFont(f);
        f.setFamily(fontFamilies[i]);
        if (global.previewFontsInDialog())
           fontNames->setItemData(i, QVariant(f), Qt::FontRole);
        if (first) {
            loadFontSizeComboBox(fontFamilies[i]);
            first=false;
        }
    }
}
开发者ID:hosiet,项目名称:nixnote2,代码行数:49,代码来源:editorbuttonbar.cpp


注:本文中的Global类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。