Example #1
0
 void SetAStyle(int style, ColourDesired fore, ColourDesired back = 0xFFFFFFFF, int size = -1, const char* face = nullptr)
 {
     SendCommand(SCI_STYLESETFORE, uptr_t(style), fore.AsLong());
     SendCommand(SCI_STYLESETBACK, uptr_t(style), back.AsLong());
     if (size >= 1)
         SendCommand(SCI_STYLESETSIZE, uptr_t(style), size);
     if (face)
         SendCommand(SCI_STYLESETFONT, uptr_t(style), reinterpret_cast<sptr_t>(face));
 }
Example #2
0
// Convert a Scintilla colour, and alpha component, to a Qt QColor.
QColor SurfaceImpl::convertQColor(const ColourDesired &col, unsigned alpha)
{
    long c = col.AsLong();

    unsigned r = c & 0xff;
    unsigned g = (c >> 8) & 0xff;
    unsigned b = (c >> 16) & 0xff;

    return QColor(r, g, b, alpha);
}
Example #3
0
void ScEclipseTheme::Apply(struct ScEditor* editor, int fontSize, const char* fontName)
{
    // Set up the global default style. These attributes are used wherever no explicit choices are made.
    editor->SetAStyle(STYLE_DEFAULT, m_foreground, m_background, fontSize, fontName);
    editor->SendCommand(SCI_STYLECLEARALL); // Copies global style to all others
    editor->SetAStyle(STYLE_INDENTGUIDE, 0xFFC0C0C0, m_background, fontSize, fontName);
    editor->SetAStyle(STYLE_BRACELIGHT, m_bracket, m_background, fontSize, fontName);
    editor->SetAStyle(STYLE_BRACEBAD, m_bracket, m_background, fontSize, fontName);
    editor->SetAStyle(STYLE_LINENUMBER, m_lineNumber, 0xD0333333, fontSize, fontName);

    editor->SetAStyle(SCE_C_DEFAULT, m_foreground, m_background, fontSize, fontName);
    editor->SetAStyle(SCE_C_STRING, m_string, m_background);// GW-TODO: Pick a good color
    editor->SetAStyle(SCE_C_IDENTIFIER, m_method, m_background);
    editor->SetAStyle(SCE_C_CHARACTER, m_string, m_background); // GW-TODO: Pick a good color
    editor->SetAStyle(SCE_C_WORD, m_keyword, m_background);
    editor->SetAStyle(SCE_C_WORD2, m_keyword, m_background);
    editor->SetAStyle(SCE_C_GLOBALCLASS, m_class, m_background);
    editor->SetAStyle(SCE_C_PREPROCESSOR, m_annotation, m_background);
    editor->SetAStyle(SCE_C_NUMBER, m_number, m_background);
    editor->SetAStyle(SCE_C_OPERATOR, m_operator, m_background);
    editor->SetAStyle(SCE_C_COMMENT, m_multiLineComment, m_background);
    editor->SetAStyle(SCE_C_COMMENTLINE, m_singleLineComment, m_background);
    editor->SetAStyle(SCE_C_COMMENTDOC, m_multiLineComment, m_background);

    //SCE_C_COMMENTDOCKEYWORD
    //SCE_C_COMMENTDOCKEYWORDERROR

    // text->StyleSetBold(wxSTC_C_WORD, true);
    // text->StyleSetBold(wxSTC_C_WORD2, true);
    //text->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true);

    editor->SendCommand(SCI_SETSELBACK, 1, m_background.AsLong());
    // editor->SendCommand(SCI_SETSELBACK, 1, 0xD0CC9966);
    editor->SendCommand(SCI_SETCARETFORE, 0xFFFFFFFF, 0);
    editor->SendCommand(SCI_SETCARETLINEVISIBLE, 1);
    editor->SendCommand(SCI_SETCARETLINEBACK, 0xFFFFFFFF);
    editor->SendCommand(SCI_SETCARETLINEBACKALPHA, 0x20);

    editor->SendCommand(SCI_SETUSETABS, 1);
    editor->SendCommand(SCI_SETTABWIDTH, 4);
    editor->SendCommand(SCI_SETINDENTATIONGUIDES, SC_IV_REAL);

    editor->SendCommand(SCI_MARKERSETBACK, 0, 0xFF6A6A6A);
    editor->SendCommand(SCI_MARKERSETFORE, 0, 0xFF0000FF);
}
Example #4
0
bool htmlToColour(ColourDesired& colour, const char* html)
{
#if 1 // Built In
    colour.Set(html);
    colour.Set(colour.AsLong() | ((unsigned int)0xFF << 24)); // ColourDesired is lame in that it never sets the alpha channel..
    return true;
#else
    const char* start = html;
    if (*start == '#')
        ++start;

    const size_t size = strlen(start);
    if (size == 6)
    {
        // 8 bits per channel
        char* end;
        char parse[3];
        parse[2] = '\0';

        // Red
        parse[0] = start[0];
        parse[1] = start[1];
        unsigned int r = strtol(parse, &end, 16);

        // Green
        parse[0] = start[2];
        parse[1] = start[3];
        unsigned int g = strtol(parse, &end, 16);

        // Blue
        parse[0] = start[4];
        parse[1] = start[5];
        unsigned int b = strtol(parse, &end, 16);

        // ColourDesired is lame in that it never sets the alpha channel..
        long result = r | (g << 8) | (b << 16) | (0xFF << 24);
        colour.Set(result);
        return true;
    }
    else if (size == 3)
    {
        // 4 bits per channel
        char* end;
        char parse[2];
        parse[2] = '\0';

        // Red
        parse[0] = start[0];

        unsigned int r = strtol(parse, &end, 16);
        r = r * 16 + r;

        // Green
        parse[0] = start[1];
        unsigned int g = strtol(parse, &end, 16);
        g = g * 16 + g;

        // Blue
        parse[0] = start[2];
        unsigned int b = strtol(parse, &end, 16);
        b = b * 16 + b;

        // ColourDesired is lame in that it never sets the alpha channel..
        long result = r | (g << 8) | (b << 16) | (0xFF << 24);
        colour.Set(result);
        return true;
    }

    // Invalid color
    return false;
#endif
}
Example #5
0
wxColour wxColourFromCDandAlpha(ColourDesired& cd, int alpha) {
    return wxColour((unsigned char)cd.GetRed(),
                    (unsigned char)cd.GetGreen(),
                    (unsigned char)cd.GetBlue(),
                    (unsigned char)alpha);
}
Example #6
0
wxColour wxColourFromCD(ColourDesired& cd) {
    return wxColour((unsigned char)cd.GetRed(),
                    (unsigned char)cd.GetGreen(),
                    (unsigned char)cd.GetBlue());
}
Example #7
0
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize,
                                 ColourDesired fill, int alphaFill,
                                 ColourDesired outline, int alphaOutline,
                                 int /*flags*/) {
#if wxUSE_GRAPHICS_CONTEXT
    wxGCDC dc(*(wxMemoryDC*)hdc);
    wxColour penColour(wxColourFromCDandAlpha(outline, alphaOutline));
    wxColour brushColour(wxColourFromCDandAlpha(fill, alphaFill));
    dc.SetPen(wxPen(penColour));
    dc.SetBrush(wxBrush(brushColour));
    dc.DrawRoundedRectangle(wxRectFromPRectangle(rc), cornerSize);
    return;
#else

#ifdef wxHAS_RAW_BITMAP

    // TODO:  do something with cornerSize
    wxUnusedVar(cornerSize);

    int x, y;
    wxRect r = wxRectFromPRectangle(rc);
    wxBitmap bmp(r.width, r.height, 32);

    // This block is needed to ensure that the changes done to the bitmap via
    // pixel data object are committed before the bitmap is drawn.
    {
        wxAlphaPixelData pixData(bmp);

        // Set the fill pixels
        ColourDesired cdf(fill.AsLong());
        int red   = cdf.GetRed();
        int green = cdf.GetGreen();
        int blue  = cdf.GetBlue();

        wxAlphaPixelData::Iterator p(pixData);
        for (y=0; y<r.height; y++) {
            p.MoveTo(pixData, 0, y);
            for (x=0; x<r.width; x++) {
                p.Red()   = wxPy_premultiply(red,   alphaFill);
                p.Green() = wxPy_premultiply(green, alphaFill);
                p.Blue()  = wxPy_premultiply(blue,  alphaFill);
                p.Alpha() = alphaFill;
                ++p;
            }
        }

        // Set the outline pixels
        ColourDesired cdo(outline.AsLong());
        red   = cdo.GetRed();
        green = cdo.GetGreen();
        blue  = cdo.GetBlue();
        for (x=0; x<r.width; x++) {
            p.MoveTo(pixData, x, 0);
            p.Red()   = wxPy_premultiply(red,   alphaOutline);
            p.Green() = wxPy_premultiply(green, alphaOutline);
            p.Blue()  = wxPy_premultiply(blue,  alphaOutline);
            p.Alpha() = alphaOutline;
            p.MoveTo(pixData, x, r.height-1);
            p.Red()   = wxPy_premultiply(red,   alphaOutline);
            p.Green() = wxPy_premultiply(green, alphaOutline);
            p.Blue()  = wxPy_premultiply(blue,  alphaOutline);
            p.Alpha() = alphaOutline;
        }

        for (y=0; y<r.height; y++) {
            p.MoveTo(pixData, 0, y);
            p.Red()   = wxPy_premultiply(red,   alphaOutline);
            p.Green() = wxPy_premultiply(green, alphaOutline);
            p.Blue()  = wxPy_premultiply(blue,  alphaOutline);
            p.Alpha() = alphaOutline;
            p.MoveTo(pixData, r.width-1, y);
            p.Red()   = wxPy_premultiply(red,   alphaOutline);
            p.Green() = wxPy_premultiply(green, alphaOutline);
            p.Blue()  = wxPy_premultiply(blue,  alphaOutline);
            p.Alpha() = alphaOutline;
        }
    }

    // Draw the bitmap
    hdc->DrawBitmap(bmp, r.x, r.y, true);

#else
    wxUnusedVar(cornerSize);
    wxUnusedVar(alphaFill);
    wxUnusedVar(alphaOutline);
    RectangleDraw(rc, outline, fill);
#endif
#endif
}