Пример #1
0
// Return the text between two offsets.
QString QsciAccessibleScintillaBase::text(int startOffset, int endOffset) const
{
    QsciScintillaBase *sb = sciWidget();

    return textRange(sb, offsetAsPosition(sb, startOffset),
            offsetAsPosition(sb, endOffset));
}
Пример #2
0
// Return the fragment of text after an offset.
QString QsciAccessibleScintillaBase::textAfterOffset(int offset,
        QAccessible::TextBoundaryType boundaryType, int *startOffset,
        int *endOffset) const
{
    QsciScintillaBase *sb = sciWidget();

    // Initialise in case of errors.
    *startOffset = *endOffset = -1;

    int position = validPosition(offset);

    if (position < 0)
        return QString();

    int start_position, end_position;

    if (!boundaries(sb, position, boundaryType, &start_position, &end_position))
        return QString();

    if (end_position >= sb->SendScintilla(QsciScintillaBase::SCI_GETTEXTLENGTH))
        return QString();

    if (!boundaries(sb, end_position, boundaryType, &start_position, &end_position))
        return QString();

    positionRangeAsOffsetRange(sb, start_position, end_position, startOffset,
            endOffset);

    return textRange(sb, start_position, end_position);
}
Пример #3
0
// Start a drag.
void QsciScintillaQt::StartDrag()
{
    inDragDrop = ddDragging;

    QDragObject *dobj = new QTextDrag(textRange(&drag), qsb->viewport());

    // Remove the dragged text if it was a move to another widget or
    // application.
    if (dobj->drag() && dobj->target() != qsb->viewport())
        ClearSelection();

    SetDragPosition(QSCI_SCI_NAMESPACE(SelectionPosition)());
    inDragDrop = ddNone;
}
Пример #4
0
AIArtHandle ListFonts::WriteVectorOfFontsToArtboard()
{
    ai::ArtboardList abList;
    sAIArtboard->GetArtboardList(abList);
    ai::ArtboardProperties props;
    sAIArtboard->GetArtboardProperties(abList, 0, props);
    AIRealRect rect;
    props.GetPosition(rect);
    
    AIRealPoint anchor = {.h = rect.left, .v = rect.bottom - 52};
    AIArtHandle textFrame;
    sAITextFrame->NewPointText(kPlaceAboveAll, NULL, kHorizontalTextOrientation, anchor, &textFrame);
    
    //Create the ATE range
    ATE::TextRangeRef textRangeRef;
    sAITextFrame->GetATETextRange(textFrame, &textRangeRef);
    ATE::ITextRange textRange(textRangeRef);
    textRange.Remove();

    for (auto& feature : featuresList)
    {
        string infoString;
        bool isAssigned = false;
        BtAteTextFeatures adjustedFeatures;
        
        auto it = henceFonts.find(GetPostscriptFontNameFromFeatures(feature));
        if (it != henceFonts.end())
        {
            infoString = it->second;
        }
        else
        {
            infoString = "NONE";
        }
        
        infoString += "\t";
        adjustedFeatures.SetFont("Helvetica-Bold");
        adjustedFeatures.SetFontSize(8);
        adjustedFeatures.AddTextToRangeWithFeatures(infoString, textRange);
        
        infoString = GetFontNameFromFeatures(feature);
        
        ASReal fontSize = feature.GetFontSize(&isAssigned);
        if (isAssigned)
        {
            infoString += ", Sz: " + to_string(fontSize);
        }
        
        ASReal leading = feature.GetLeading(&isAssigned);
        if (isAssigned)
        {
            infoString += ", Ld: " + to_string(leading);
        }
        
        //Make sure the lines stay spaced apart enough to read
        adjustedFeatures = feature;
        adjustedFeatures.SetLeading(fontSize + 2);
        
        infoString += "\n";
        adjustedFeatures.AddTextToRangeWithFeatures(infoString, textRange);
    }
    
    return textFrame;
}

void ListFonts::RemoveDuplicatesFromFeaturesList()
{
    for(auto feature = featuresList.begin(); feature != featuresList.end(); feature++)
    {
        bool found1 = false;
        featuresList.erase(
                           std::remove_if(featuresList.begin(), featuresList.end(), [feature, &found1](ATE::ICharFeatures f)
                           {
                               bool isAAssigned = false;
                               bool isBAssigned = false;
                               
                               string fontNameA = GetFontNameFromFeatures(*feature);
                               string fontNameB = GetFontNameFromFeatures(f);
                               
                               if (fontNameA == fontNameB)
                               {
                                   ASReal fontSizeA = feature->GetFontSize(&isAAssigned);
                                   ASReal fontSizeB = f.GetFontSize(&isBAssigned);
                                   if (isAAssigned && isBAssigned && fontSizeA == fontSizeB)
                                   {
                                       ASReal leadingA = feature->GetLeading(&isAAssigned);
                                       ASReal leadingB = f.GetLeading(&isBAssigned);
                                       if (isAAssigned && isBAssigned && leadingA == leadingB)
                                       {
                                           if (!found1)
                                           {
                                               found1 = true;
                                               return false;
                                           }
                                           else
                                           {
                                               return true;
                                           }
                                       }
                                   }
                               }
                               return false;
                           }
                                          ),
                           featuresList.end()
        );
    }
}

void ListFonts::FillJobPostscriptFontList()
{
    for (auto& feature : featuresList)
    {
        postscriptFontNamesOnJob.insert(GetPostscriptFontNameFromFeatures(feature));
    }
}

bool ListFonts::LoadFontListFromFile()
{
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
    char path[PATH_MAX];
    if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
    {
        // error!
    }
    CFRelease(resourcesURL);
    
    chdir(path);
    
//    char buf[2048];
//    getcwd(buf, sizeof(buf));
//    printf("%s", buf);
//    sAIUser->ErrorAlert(ai::UnicodeString(buf));

    ifstream in(PATH_TO_FONTLIST);
    
    if (in.is_open())
    {
        //string contents((istreambuf_iterator<char>(in)), istreambuf_iterator<char>());
        string postscriptName, henceCode;
        while ( getline(in, henceCode, ',') )
        {
            getline(in, postscriptName);
            henceFonts.insert(pair<string,string>(postscriptName, henceCode));
        }
        in.close();
        return true;
    }
    else
    {
        return false;
    }
}