void buildSymbolTable(TreeNode *syntaxTree) { /* Format headings */ if (TraceAnalyse) { drawRuler(listing, ""); fprintf(listing, "Scope Identifier Line Is a Symbol type\n"); fprintf(listing, "depth Decl. parm?\n"); } declarePredefines(); /* make input() and output() visible in globals */ buildSymbolTable2(syntaxTree); /* set the isGlobal field in appropriate nodes: needed in code generator */ markGlobals(syntaxTree); /* Dump the global scope, if it's asked for */ if (TraceAnalyse) { drawRuler(listing, "GLOBALS"); dumpCurrentScope(); drawRuler(listing, ""); fprintf(listing, "*** Symbol table dump complete\n"); } }
void Prefs_Display::restoreDisScale() { disconnect(adjustDisplaySlider, SIGNAL(valueChanged(int)), this, SLOT(setDisScale())); int dpi = qApp->desktop()->logicalDpiX(); if ((dpi < 60) || (dpi > 250)) dpi = 72; displayScale = dpi / 72.0; adjustDisplaySlider->setValue(qRound(100 * displayScale) - 150); drawRuler(); displayDPI->setText(QString::number(qRound(displayScale*72.0))+ tr(" dpi")); connect(adjustDisplaySlider, SIGNAL(valueChanged(int)), this, SLOT(setDisScale())); }
void DemoQPItem::paint(QPainter *painter) { m_painter = painter; qreal w = boundingRect().width(); qreal h = boundingRect().height(); qreal t = m_animationTime; // These painting commands are identical with both renderers for (int i=0 ; i < m_testCount ; i++) { // Paint ruler if (m_enabledTests & 1) { drawRuler(0, h*0.02, w, h*0.05, t); } // Paint circles if (m_enabledTests & 2) { drawGraphCircles(w*0.15, h*0.1, w*0.7, w*0.7, 10, t*2); drawGraphCircles(w*0.05, h*0.55, w*0.25, w*0.25, 8, t*3); drawGraphCircles(w*0.70, h*0.55, w*0.25, w*0.25, 3, t); } // Paint lines if (m_enabledTests & 4) { drawGraphLine(0, h, w, -h, 4, t); drawGraphLine(0, h, w, -h*0.8, 6, t+10); drawGraphLine(0, h, w, -h*0.6, 12, t/2); } // Paint bars if (m_enabledTests & 8) { drawGraphBars(0, h, w, -h*0.8, 6, t*3); drawGraphBars(0, h, w, -h*0.4, 10, t+2); drawGraphBars(0, h, w, -h*0.3, 20, t*2+2); drawGraphBars(0, h, w, -h*0.2, 40, t*3+2); } // Paint icons int icons = 50; if (m_enabledTests & 16) { drawIcons(0, h*0.2, w, h*0.2, icons, t); } // Increase animation time when m_testCount > 1 t += 0.3; } }
void ScheduleDialog::initCanvas() { DrawProperties p; p.canvas = canvas; p.nameWidth = 0; // name labels are on other canvas p.x = WIDGET_SPACING; p.y = 0; p.width = canvas->width(); p.height = canvas->height(); // calculate pix per ns (find block with highest clock to draw it // BLOCKS_PER_CANVAS times. unsigned int max_clock = 0; QValueList<BlockNode*>::Iterator it; for (it = blocks_.begin(); it != blocks_.end(); ++it) { max_clock = QMAX(max_clock, (*it)->clock()); } p.pixPerNs = (max_clock > 0) ? (double)p.width / (max_clock * BLOCKS_PER_CANVAS) : 1.0; drawRuler(&p); for (it = blocks_.begin(); it != blocks_.end(); ++it) { drawTimings(&p, *it); } // create highlighter highlightCanvasRectangle = new QCanvasRectangle(canvas); highlightCanvasRectangle->setSize(canvas->width(), BOX_HEIGHT + BOX_YSPACING); highlightCanvasRectangle->setBrush(QBrush(qApp->palette().active().highlight())); highlightCanvasRectangle->setPen(QPen(white)); highlightCanvasRectangle->move(0, RULER_HEIGHT - BOX_YSPACING / 2); highlightCanvasRectangle->setZ(0); highlightCanvasRectangle->show(); connect(timingTable, SIGNAL(currentChanged(int, int)), this, SLOT(updateHighlighter(int, int))); canvas->update(); labelCanvas->update(); }
void ScheduleDialog::print() { PrintManager printer(project_->name()); if (!printer.setup()) return; QPaintDeviceMetrics *metrics = printer.getMetrics(); int printCanvasWidth = metrics->width(); delete metrics; int tableHeight = (blocks_.count() + 1) * PRINT_ITEM_HEIGHT; QCanvas *printCanvas = new QCanvas(printCanvasWidth, tableHeight + PRINT_ITEM_HEIGHT + canvas->height()); // first draw timing table int y = 0; Q_ASSERT(timingTable->numCols() == 4); int xOfs[6] = {0, // x offsets of the columns printCanvasWidth * 1/20, printCanvasWidth * 4/10, printCanvasWidth * 6/10, printCanvasWidth * 8/10, printCanvasWidth - 1}; QCanvasLine *line = new QCanvasLine(printCanvas); line->setPoints(xOfs[0], y, xOfs[5], y); line->setPen(gray); line->show(); // print header and vertical lines for (int i = 0; i <= 5; i++) { if ((i > 0) && (i < 5)) { QCanvasText* text = new QCanvasText( timingTable->horizontalHeader()->label(i - 1), printCanvas); text->move(xOfs[i] + PRINT_SPACING, y + PRINT_SPACING); text->show(); } line = new QCanvasLine(printCanvas); line->setPoints(xOfs[i], y, xOfs[i], y + tableHeight); line->setPen(gray); line->show(); } y += PRINT_ITEM_HEIGHT; // now print contents int row = 0; QValueList<BlockNode*>::Iterator it; for (it = blocks_.begin(); it != blocks_.end(); ++it) { // number QCanvasText* text; text = new QCanvasText(QString::number(row + 1), printCanvas); text->move(xOfs[0] + PRINT_SPACING, y + PRINT_SPACING); text->show(); // other contents for (int i = 1; i <= 4; i++) { text = new QCanvasText(timingTable->text(row, i - 1), printCanvas); text->move(xOfs[i] + PRINT_SPACING, y + PRINT_SPACING); text->show(); } // horizontal line line = new QCanvasLine(printCanvas); line->setPoints(xOfs[0], y, xOfs[5], y); line->setPen(gray); line->show(); y += PRINT_ITEM_HEIGHT; row++; } line = new QCanvasLine(printCanvas); line->setPoints(xOfs[0], y, xOfs[5], y); line->setPen(gray); line->show(); y += PRINT_ITEM_HEIGHT; // properties for the graph DrawProperties p; p.nameWidth = PRINT_NAME_WIDTH; p.x = 0; p.y = y; p.width = printCanvasWidth; p.height = canvas->height(); p.canvas = printCanvas; // now draw graph unsigned int max_clock = 0; for (it = blocks_.begin(); it != blocks_.end(); ++it) { max_clock = QMAX(max_clock, (*it)->clock()); } p.pixPerNs = (max_clock > 0) ? (double)canvas->width() / (max_clock * BLOCKS_PER_CANVAS) : 1.0; drawRuler(&p); for (it = blocks_.begin(); it != blocks_.end(); ++it) { drawTimings(&p, *it); } // finally print canvas printer.print(printCanvas); }
static void buildSymbolTable2(TreeNode *syntaxTree) { int i; /* iterate over node children */ HashNodePtr luSymbol; /* symbol being looked up */ char errorMessage[80]; /* used to decorate RETURN nodes with enclosing procedure */ static TreeNode *enclosingFunction = NULL; while (syntaxTree != NULL) { /* * Examine current symbol: if it's a declaration, insert into * symbol table. */ if (syntaxTree->nodekind == DecK) insertSymbol(syntaxTree->name, syntaxTree, syntaxTree->lineno); /* If entering a new function, tell the symbol table */ if ((syntaxTree->nodekind == DecK) && (syntaxTree->kind.dec == FuncDecK)) { /* record the enclosing procedure declaration */ enclosingFunction = syntaxTree; if (TraceAnalyse) /* * For functions at least, it's nice to tell the user * whereabouts in the program the variable comes into * scope. We don't bother printing out compound-stmt * scopes */ drawRuler(listing, syntaxTree->name); newScope(); ++scopeDepth; } /* If entering a compound-statement, create a new scope as well */ if ((syntaxTree->nodekind == StmtK) && (syntaxTree->kind.stmt == CompoundK)) { newScope(); ++scopeDepth; } /* * If the current node is an identifier, it needs to be checked * against the symbol table, and annotated with a pointer back to * it's declaration. */ if (((syntaxTree->nodekind == ExpK) /* identifier reference... */ && (syntaxTree->kind.exp == IdK)) || ((syntaxTree->nodekind == StmtK) /* function call... */ && (syntaxTree->kind.stmt == CallK))) { DEBUG_ONLY( fprintf(listing, "*** Annotating identifier \"%s\" on line %d\n", syntaxTree->name, syntaxTree->lineno); ); luSymbol = lookupSymbol(syntaxTree->name); if (luSymbol == NULL) { /* operation failed; say so to user */ sprintf(errorMessage, "identifier \"%s\" unknown or out of scope\n", syntaxTree->name); flagSemanticError(errorMessage); } else { /* * Annotate identifier tree-node with a pointer to it's * declaration. */ syntaxTree->declaration = luSymbol->declaration; } }
void Prefs_Display::restoreDefaults(struct ApplicationPrefs *prefsData) { docUnitIndex = prefsData->docSetupPrefs.docUnitIndex; double unitRatio = unitGetRatioFromIndex(docUnitIndex); QString unitSuffix = unitGetSuffixFromIndex(docUnitIndex); showImagesCheckBox->setChecked(prefsData->guidesPrefs.showPic); showControlCharsCheckBox->setChecked(prefsData->guidesPrefs.showControls); showRulersCheckBox->setChecked(prefsData->guidesPrefs.rulersShown); showRulersRelativeToPageCheckBox->setChecked(prefsData->guidesPrefs.rulerMode); showTextChainsCheckBox->setChecked(prefsData->guidesPrefs.linkShown); showFramesCheckBox->setChecked(prefsData->guidesPrefs.framesShown); showLayerIndicatorsCheckBox->setChecked(prefsData->guidesPrefs.layerMarkersShown); showUnprintableAreaInMarginColorCheckBox->setChecked(prefsData->displayPrefs.marginColored); showBleedAreaCheckBox->setChecked(prefsData->guidesPrefs.showBleed); showPageShadowCheckBox->setChecked(prefsData->displayPrefs.showPageShadow); showVerifierWarningsOnCanvasCheckBox->setChecked(prefsData->displayPrefs.showVerifierWarningsOnCanvas); scratchSpaceLeftSpinBox->setMaximum(1000); scratchSpaceRightSpinBox->setMaximum(1000); scratchSpaceTopSpinBox->setMaximum(1000); scratchSpaceBottomSpinBox->setMaximum(1000); pageGapHorizontalSpinBox->setMaximum(1000); pageGapVerticalSpinBox->setMaximum(1000); scratchSpaceLeftSpinBox->setNewUnit(docUnitIndex); scratchSpaceRightSpinBox->setNewUnit(docUnitIndex); scratchSpaceTopSpinBox->setNewUnit(docUnitIndex); scratchSpaceBottomSpinBox->setNewUnit(docUnitIndex); pageGapHorizontalSpinBox->setNewUnit(docUnitIndex); pageGapVerticalSpinBox->setNewUnit(docUnitIndex); scratchSpaceLeftSpinBox->setValue(prefsData->displayPrefs.scratch.Left * unitRatio); scratchSpaceRightSpinBox->setValue(prefsData->displayPrefs.scratch.Right * unitRatio); scratchSpaceTopSpinBox->setValue(prefsData->displayPrefs.scratch.Top * unitRatio); scratchSpaceBottomSpinBox->setValue(prefsData->displayPrefs.scratch.Bottom * unitRatio); pageGapHorizontalSpinBox->setValue(prefsData->displayPrefs.pageGapHorizontal); pageGapVerticalSpinBox->setValue(prefsData->displayPrefs.pageGapVertical); QPixmap pm(100, 30); pm.fill(prefsData->displayPrefs.paperColor); colorPaper = prefsData->displayPrefs.paperColor; pageFillColorButton->setText( QString::null ); pageFillColorButton->setIcon(pm); pm.fill(prefsData->displayPrefs.frameColor); colorFrame = prefsData->displayPrefs.frameColor; frameSelectedColorButton->setText( QString::null ); frameSelectedColorButton->setIcon(pm); pm.fill(prefsData->displayPrefs.frameNormColor); colorFrameNorm = prefsData->displayPrefs.frameNormColor; frameColorButton->setText( QString::null ); frameColorButton->setIcon(pm); pm.fill(prefsData->displayPrefs.frameGroupColor); colorFrameGroup = prefsData->displayPrefs.frameGroupColor; frameGroupedColorButton->setText( QString::null ); frameGroupedColorButton->setIcon(pm); pm.fill(prefsData->displayPrefs.frameLinkColor); colorFrameLinked = prefsData->displayPrefs.frameLinkColor; frameLinkedColorButton->setText( QString::null ); frameLinkedColorButton->setIcon(pm); pm.fill(prefsData->displayPrefs.frameLockColor); colorFrameLocked = prefsData->displayPrefs.frameLockColor; frameLockedColorButton->setText( QString::null ); frameLockedColorButton->setIcon(pm); pm.fill(prefsData->displayPrefs.frameAnnotationColor); colorFrameAnnotation = prefsData->displayPrefs.frameAnnotationColor; frameAnnotationColorButton->setText( QString::null ); frameAnnotationColorButton->setIcon(pm); pm.fill(prefsData->displayPrefs.pageBorderColor); colorPageBorder = prefsData->displayPrefs.pageBorderColor; selectedPageBorderButton->setText( QString::null ); selectedPageBorderButton->setIcon(pm); pm.fill(prefsData->displayPrefs.controlCharColor); colorControlChars = prefsData->displayPrefs.controlCharColor; textControlCharsButton->setText( QString::null ); textControlCharsButton->setIcon(pm); displayScale=prefsData->displayPrefs.displayScale; adjustDisplaySlider->setValue(qRound(100 * displayScale) - 150); displayDPI->setText(QString::number(qRound(displayScale*72.0))+ tr(" dpi")); rulerUnitComboBox->clear(); rulerUnitComboBox->addItems(unitGetTextUnitList()); rulerUnitComboBox->setCurrentIndex(docUnitIndex); drawRuler(); }
void Prefs_Display::setDisScale() { displayScale = qMax((150.0 + adjustDisplaySlider->value()) / 100.0, 0.01); drawRuler(); displayDPI->setText(QString::number(qRound(displayScale*72.0))+ tr(" dpi")); }