Example #1
0
wxFont NewBuildTab::DoGetFont() const
{
    wxFont font = wxNullFont;
    LexerConfPtr lexerConf = EditorConfigST::Get()->GetLexer("C++");
    if ( lexerConf ) {
        font = lexerConf->GetFontForSyle(wxSTC_C_DEFAULT);
    }

    if ( font.IsOk() == false ) {
        font = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
    }
    return font;
}
Example #2
0
void CCBoxTipWindow::DoInitialize(const wxString& tip, size_t numOfTips, bool simpleTip)
{
    m_tip = tip;
    m_numOfTips = numOfTips;
    
    //Invalidate the rectangles
    m_leftTipRect = wxRect();
    m_rightTipRect = wxRect();

    if ( !simpleTip && m_numOfTips > 1 )
        m_tip.Prepend(wxT("\n\n")); // Make room for the arrows

    Hide();

    wxBitmap bmp(1, 1);
    wxMemoryDC dc(bmp);

    wxSize size;
    
    LexerConfPtr cppLex = EditorConfigST::Get()->GetLexer("C++");
    if ( cppLex ) {
        // use the lexer default font
        m_codeFont = cppLex->GetFontForSyle(0);
        
    } else {
        m_codeFont    = wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
        
    }
    
    m_commentFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);

    wxString codePart, commentPart;
    wxString strippedTip = DoStripMarkups();
    
    size_t from = 0;
    int hr_count = 0;
    size_t hrPos = strippedTip.find("<hr>");
    while ( hrPos != wxString::npos ) {
        ++hr_count;
        from = hrPos + 4;
        hrPos = strippedTip.find("<hr>", from);
    }
    
    int where= strippedTip.Find("<hr>");
    if ( where != wxNOT_FOUND ) {
        codePart    = strippedTip.Mid(0, where);
        commentPart = strippedTip.Mid(where + 5);

    } else {
        codePart = strippedTip;
    }

    int commentWidth  = 0;
    int codeWidth     = 0;

    // Use bold font for measurements
    m_codeFont.SetWeight(wxFONTWEIGHT_BOLD);
    m_commentFont.SetWeight(wxFONTWEIGHT_BOLD);
    
    if ( !simpleTip ) {
        dc.GetMultiLineTextExtent(codePart,    &codeWidth,    NULL, NULL, &m_codeFont);
        dc.GetMultiLineTextExtent(commentPart, &commentWidth, NULL, NULL, &m_commentFont);
        
    } else {
        dc.GetMultiLineTextExtent(strippedTip, &codeWidth,    NULL, NULL, &m_commentFont);

    }
    
    m_codeFont.SetWeight(wxFONTWEIGHT_NORMAL);
    m_commentFont.SetWeight(wxFONTWEIGHT_NORMAL);

    // Set the width
    commentWidth > codeWidth ? size.x = commentWidth : size.x = codeWidth;

    dc.GetTextExtent(wxT("Tp"), NULL, &m_lineHeight, NULL, NULL, &m_codeFont);
    int nLineCount = ::wxStringTokenize(m_tip, wxT("\r\n"), wxTOKEN_RET_EMPTY_ALL).GetCount();
    
    size.y = nLineCount * m_lineHeight;
    size.y += (hr_count * 10) + 10; // each <hr> uses 10 pixels height
    size.x += 40;
    SetSize(size);

    Connect(wxEVT_PAINT, wxPaintEventHandler(CCBoxTipWindow::OnPaint), NULL, this);
    Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(CCBoxTipWindow::OnEraseBG), NULL, this);
    Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CCBoxTipWindow::OnMouseLeft), NULL, this);
}