void MainWindow::initMenuEdit() { //connect menu "Edit" Action connect(actionCut, SIGNAL(triggered()), _documentManager, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), _documentManager, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), _documentManager, SLOT(paste())); connect(actionUndo, SIGNAL(triggered()), _documentManager, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), _documentManager, SLOT(redo())); connect(actionSelectAll, SIGNAL(triggered()), _documentManager, SLOT(selectAll())); connect(actionIndent, SIGNAL(triggered()), this, SLOT(increaseIndentation())); connect(actionUnindent, SIGNAL(triggered()), this, SLOT(decreaseIndentation())); connect(actionAutoIndentation, SIGNAL(toggled(bool)), _documentManager, SLOT(setAutoIndentation(bool))); connect(actionIndentationGuides, SIGNAL(toggled(bool)), _documentManager, SLOT(showIndentationGuides(bool))); connect(actionTabsToSpaces, SIGNAL(triggered()), _documentManager, SLOT(tabsToSpaces())); connect(actionSpacesToTabs, SIGNAL(triggered()), _documentManager, SLOT(spacesToTabs())); connect(actionTrimTrailingSpaces, SIGNAL(triggered()), _documentManager, SLOT(trimTrailingSpaces())); connect(actionCompressSpaces, SIGNAL(triggered()), _documentManager, SLOT(compressSpaces())); connect(actionUpperCase, SIGNAL(triggered()), _documentManager, SLOT(convertSelectedTextToUpperCase())); connect(actionLowerCase, SIGNAL(triggered()), _documentManager, SLOT(convertSelectedTextToLowerCase())); connect(actionDuplicateLine, SIGNAL(triggered()), _documentManager, SLOT(duplicateCurrentLine())); connect(actionCopyLine, SIGNAL(triggered()), _documentManager, SLOT(copyCurrentLine())); connect(actionCutLine, SIGNAL(triggered()), _documentManager, SLOT(cutCurrentLine())); connect(actionDeleteLine, SIGNAL(triggered()), _documentManager, SLOT(deleteCurrentLine())); connect(actionMoveLineUp, SIGNAL(triggered()), _documentManager, SLOT(moveCurrentLineUp())); connect(actionMoveLineDown, SIGNAL(triggered()), _documentManager, SLOT(moveCurrentLineDown())); connect(actionDeleteWord, SIGNAL(triggered()), _documentManager, SLOT(deleteCurrentWord())); connect(actionGotoLine, SIGNAL(triggered()), this, SLOT(gotoLine())); connect(actionReadOnly, SIGNAL(triggered(bool)), _documentManager, SLOT(setReadOnly(bool))); connect(actionReindentFile, SIGNAL(triggered()), _documentManager, SLOT(reindentDocument())); connect(actionReindentOpenFiles, SIGNAL(triggered()), _documentManager, SLOT(reindentOpenDocuments())); connect(actionToggleComment, SIGNAL(triggered()), _documentManager, SLOT(toggleComment())); connect(actionToggleBlockComment, SIGNAL(triggered()), _documentManager, SLOT(toggleBlockComment())); connect(actionSwitchSrc, SIGNAL(triggered()), _documentManager, SLOT(switchDocumentSrc())); connect(actionSwitchFile, SIGNAL(triggered()), _documentManager, SLOT(switchFile())); connect(actionSwitchSymbol, SIGNAL(triggered()), this, SLOT(switchSymbol())); connect(menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu())); connect(menuIndentation, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditIndentationMenu())); }
/*================================================================================== pstext - subroutine to output text strings. x, y - coordinates of the label's reference point, in real coordinates (but see valign and halign, below) text - character string to be output jchar - length of meaningful character string, 0 if unknown. textlen - automatic argument supplied by fortran, gives allocated length of string valign: integer alignment code for vertical (from possibly rotated character standpoint) alignment. 0 = top-aligned 1 = middle-aligned 2 = bottom-aligned 10-12 = y should be considered a number of lines from top margin of page, then alignment=valign-10 100-902 = valign is given by the final digit. The y-coordinate should be calculated based upon the given y, but then add a number of lines to move down the page from there given by this code/100 (e.g., 1-9 lines) 1000-9002 = valign is given by the final digit. The y-coordinate should be calculated based upon the given y, but then add a number of lines to move up the page from there given by this code/1000 (e.g., 1-9 lines) (e.g., 202 would mean that the text should be bottom-aligned to the reference point, and the y coordinate is two lines below the supplied y coordinate halign: integer alignment code for horizontal (from possibly rotated character standpoint) alignment. 0 = left-aligned 1 = center-aligned 2 = right-aligned 10-12 = x should be considered a number of lines from left margin of page, then alignment=halign-10 100-9002 = halign is given by the final digit. The x coordinate should be calculated based upon the given x, but add a number of points given by this code / 100 (e.g., 1-90). REFERENCE_TO_TRACKED_MIN_X - REFERENCE_TO_TRACKED_MIN_X+2 = halign is given by the final digit. The x coordinate to be used is the tracked minimum x. ==================================================================================*/ void pstext_ (double *x, double *y, char *text, int *jchar, int *valign, int *halign, int textlen) { cairo_text_extents_t te; cairo_font_extents_t fe; cairo_matrix_t curMatrix; double userX, userY; double tempX, tempY; int valignCode, halignCode; int linesToMove = 0; double pointsToMove = 0; double xOffset = 0; double yOffset = 0; char *temptext=malloc(255 * sizeof(char)); char *mytext; strncpy(temptext, text, 254); /* copy only as many characters as will fit in value */ if (*jchar == 0) { temptext[textlen]='\0'; } else { temptext[*jchar]='\0'; } mytext = trim(temptext); compressSpaces(mytext); completeRelativeOperation(); DEBUGPRINT(("In pstext. Pt=(%f, %f), DevPoint=(%f, %f), Text=%s, jchar=%i, textlen=%i, valign=%i, halign=%i.\n", *x, *y, deviceX(*x), deviceY(*y), mytext, *jchar, textlen, *valign, *halign)); cairo_text_extents(dmh_cr,mytext,&te); cairo_font_extents (dmh_cr, &fe); cairo_set_source_rgb (dmh_cr, 0, 0, 0); /* black */ userX = deviceX(*x); /* change coordinates from real to device */ userY = deviceY(*y); if (dmh_debug) { tempX = userX; tempY = userY; cairo_device_to_user(dmh_cr, &tempX, &tempY); /* need this to deal with possibly rotated transform */ cairo_rectangle(dmh_cr, tempX-4, tempY-4, 8, 8); cairo_set_source_rgb (dmh_cr, 1, 0.5, 0); cairo_fill(dmh_cr); cairo_set_source_rgb (dmh_cr, 0, 0, 0); cairo_move_to(dmh_cr, tempX, tempY); } DEBUGPRINT(("In pstext. UserPt=(%f, %f) tempPt=(%f, %f).\n", userX, userY, tempX, tempY)); if (*valign > 9 && *valign < 100) { /* y should be considered a number of lines from top of page. Note that cairo thinks the origin is at top-left */ userY = TOPMARGIN + ((int)*y * fe.height); } else if (*valign > 99 && *valign < 1000) { linesToMove = *valign / 100; } else if (*valign > 990 && *valign < 10000) { linesToMove = -(*valign / 1000); } DEBUGPRINT(("In pstext. LinesToMove=%i.\n", linesToMove)); if (*halign > 9 && *halign < 100) { /* x should be considered a number of lines from top of page. Note that cairo thinks the origin is at top-left */ userX = LEFTMARGIN + ((int)*x * fe.height); } else if (*halign > 99 && *halign < 10000) { pointsToMove = (*halign)/100; } else if (*halign >= REFERENCE_TO_TRACKED_MIN_X && *halign <= REFERENCE_TO_TRACKED_MIN_X+2) { userX = dmh_min_tracked_x; dmh_min_tracked_x = DBL_MAX; /* Now turn off tracking */ dmh_track_min_x = 0; } DEBUGPRINT(("In pstext. UserPt=(%f, %f).\n", userX, userY)); cairo_device_to_user(dmh_cr, &userX, &userY); /* need this to deal with possibly rotated transform */ cairo_move_to(dmh_cr, userX, userY); if (linesToMove != 0) { cairo_rel_move_to(dmh_cr, 0, linesToMove * fe.height); } if (pointsToMove != 0) { cairo_rel_move_to(dmh_cr, pointsToMove, 0); } if (dmh_debug) { cairo_get_current_point(dmh_cr, &tempX, &tempY); cairo_rectangle(dmh_cr, tempX-2, tempY-2, 4, 4); cairo_set_source_rgb (dmh_cr, 0, 0.5, 1); cairo_fill(dmh_cr); cairo_set_source_rgb (dmh_cr, 0, 0, 0); cairo_move_to(dmh_cr, tempX, tempY); } valignCode = *valign % 10; halignCode = *halign % 10; switch (valignCode) { case 0: /* Top-aligned */ yOffset = te.height + EXTRASPACEPTS; break; case 1: /* Middle-aligned */ yOffset = te.height * 0.5; break; case 2: /* Bottom-aligned */ yOffset = -EXTRASPACEPTS; break; } switch (halignCode) { case 0: /* Left-aligned */ xOffset = EXTRASPACEPTS; break; case 1: /* Center-aligned */ xOffset = -te.width * 0.5; break; case 2: /* Right-aligned */ xOffset = -te.width - EXTRASPACEPTS; break; } DEBUGPRINT(("In pstext. Offset=(%f, %f).\n", xOffset, yOffset)); cairo_rel_move_to(dmh_cr, xOffset, yOffset); if (dmh_debug) { cairo_get_current_point(dmh_cr, &tempX, &tempY); cairo_rectangle(dmh_cr, tempX-2, tempY-2, 4, 4); cairo_set_source_rgb (dmh_cr, 1, 0, 0.5); cairo_fill(dmh_cr); cairo_set_source_rgb (dmh_cr, 0, 0, 0); cairo_move_to(dmh_cr, tempX, tempY); } cairo_get_matrix(dmh_cr, &curMatrix); DEBUGPRINT(("Current matrix: %f, %f, %f, %f, %f, %f.\n", curMatrix.xx, curMatrix.yx, curMatrix.xy, curMatrix.yy, curMatrix.x0, curMatrix.y0)); if (dmh_track_min_x) { cairo_get_current_point(dmh_cr, &tempX, &tempY); if (tempX < dmh_min_tracked_x) { dmh_min_tracked_x = tempX; } } cairo_show_text (dmh_cr, mytext); DEBUGPRINT(("Status:%s\n",cairo_status_to_string(cairo_status(dmh_cr)))); free(temptext); }