示例#1
0
void ListCtrlLogger::UpdateSettings()
{
    if (!control)
        return;

    ConfigManager* cfgman = Manager::Get()->GetConfigManager(_T("message_manager"));
    int size = cfgman->ReadInt(_T("/log_font_size"), platform::macosx ? 10 : 8);
    wxFont default_font(size, fixed ? wxFONTFAMILY_MODERN : wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
    wxFont bold_font(default_font);
    wxFont italic_font(default_font);

    bold_font.SetWeight(wxFONTWEIGHT_BOLD);

    wxFont bigger_font(bold_font);
    bigger_font.SetPointSize(size + 2);

    wxFont small_font(default_font);
    small_font.SetPointSize(size - 4);

    italic_font.SetStyle(wxFONTSTYLE_ITALIC);

    wxColour default_text_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    for(unsigned int i = 0; i < num_levels; ++i)
    {
        style[i].font = default_font;
        style[i].colour = default_text_colour;
    }

    ColourManager *colours = Manager::Get()->GetColourManager();

    style[caption].font = bigger_font;
    style[success].colour = colours->GetColour(wxT("logs_success_text"));
    style[failure].colour = colours->GetColour(wxT("logs_failure_text"));

    style[warning].font = italic_font;
    style[warning].colour = colours->GetColour(wxT("logs_warning_text"));

    style[error].colour = colours->GetColour(wxT("logs_error_text"));

    style[critical].font = bold_font;
    style[critical].colour = colours->GetColour(wxT("logs_critical_text_listctrl"));

    style[spacer].font = small_font;
    style[pagetitle] = style[caption];

    // Tell control and items about the font change
    control->SetFont(default_font);
    for (int i = 0; i < control->GetItemCount(); ++i)
    {
        wxFont font = control->GetItemFont(i);
        font.SetPointSize(size);
        control->SetItemFont( i, font );
    }//for
} // end of UpdateSettings
示例#2
0
void RheiaTextLogger::UpdateSettings()
{
    RheiaConfigurationManager* cfg = RheiaManager::Get()->GetConfigurationManager( wxT("RheiaTextLogger") );
    bool isFirstTime = true;

    isFirstTime = (bool) cfg->ReadInt( wxT("/first_time") , (int) true );

    if( isFirstTime )
    {
        int size = 10;
        wxFont default_font(size, wxFONTFAMILY_SWISS , wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
        wxFont bold_font(size, wxFONTFAMILY_SWISS , wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
        wxFont italic_font(size, wxFONTFAMILY_SWISS , wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL);

        bold_font.SetWeight(wxFONTWEIGHT_BOLD);

        wxFont bigger_font(bold_font);
        bigger_font.SetPointSize(size + 1);

        wxFont small_font(default_font);
        small_font.SetPointSize(size - 4);

        for(unsigned int i = 0; i < (unsigned int) RheiaLogging::RheiaLogLevelNumber ; ++i)
        {
            m_textattr[i].SetFlags( wxTEXT_ATTR_FONT | wxTEXT_ATTR_ALIGNMENT );
            m_textattr[i].SetFont(default_font);
            m_textattr[i].SetAlignment(wxTEXT_ALIGNMENT_LEFT);
            m_textattr[i].SetTextColour(*wxBLACK);
            m_textattr[i].SetBackgroundColour(*wxWHITE);
        }

        m_textattr[RheiaLogging::warning].SetFont(italic_font);
        m_textattr[RheiaLogging::warning].SetTextColour(*wxBLUE);

        m_textattr[RheiaLogging::success].SetAlignment(wxTEXT_ALIGNMENT_CENTRE);
        bigger_font.SetUnderlined(true);
        m_textattr[RheiaLogging::success].SetFont(bigger_font);
        m_textattr[RheiaLogging::success].SetTextColour(*wxBLUE);

        m_textattr[RheiaLogging::error].SetFont(bold_font);
        m_textattr[RheiaLogging::error].SetTextColour(*wxRED);

        m_textattr[RheiaLogging::fatalerror].SetFont(bold_font);
        m_textattr[RheiaLogging::fatalerror].SetTextColour(*wxWHITE);
        m_textattr[RheiaLogging::fatalerror].SetBackgroundColour(*wxRED);

        m_textattr[RheiaLogging::syserror].SetFont(bold_font);
        m_textattr[RheiaLogging::syserror].SetTextColour(*wxWHITE);
        m_textattr[RheiaLogging::syserror].SetBackgroundColour(*wxBLUE);

        m_textattr[RheiaLogging::info].SetFont(italic_font);

        m_textattr[RheiaLogging::status].SetFont(bold_font);
        m_textattr[RheiaLogging::status].SetTextColour(*wxGREEN);

        m_textattr[RheiaLogging::debug].SetFont(italic_font);
        m_textattr[RheiaLogging::debug].SetTextColour(*wxGREEN);

        m_textattr[RheiaLogging::trace].SetFont(italic_font);
        m_textattr[RheiaLogging::trace].SetTextColour(*wxGREEN);

        if( cfg != NULL )
        {
            cfg->Write( wxT("/message") , m_textattr[RheiaLogging::message] );
            cfg->Write( wxT("/warning") , m_textattr[RheiaLogging::warning] );
            cfg->Write( wxT("/success") , m_textattr[RheiaLogging::success] );
            cfg->Write( wxT("/error") , m_textattr[RheiaLogging::error] );
            cfg->Write( wxT("/fatalerror") , m_textattr[RheiaLogging::fatalerror] );
            cfg->Write( wxT("/info") , m_textattr[RheiaLogging::info] );
            cfg->Write( wxT("/status") , m_textattr[RheiaLogging::status] );
            cfg->Write( wxT("/syserror") , m_textattr[RheiaLogging::syserror] );
            cfg->Write( wxT("/debug") , m_textattr[RheiaLogging::debug] );
            cfg->Write( wxT("/trace") , m_textattr[RheiaLogging::trace] );
            cfg->Write( wxT("/first_time") , (int) false );
        }

        return;
    }

    m_textattr[RheiaLogging::message] = cfg->ReadTextAttr( wxT("/message") );
    m_textattr[RheiaLogging::warning] = cfg->ReadTextAttr( wxT("/warning") );
    m_textattr[RheiaLogging::success] = cfg->ReadTextAttr( wxT("/success") );
    m_textattr[RheiaLogging::error] = cfg->ReadTextAttr( wxT("/error") );
    m_textattr[RheiaLogging::fatalerror] = cfg->ReadTextAttr( wxT("/fatalerror") );
    m_textattr[RheiaLogging::info] = cfg->ReadTextAttr( wxT("/info") );
    m_textattr[RheiaLogging::status] = cfg->ReadTextAttr( wxT("/status") );
    m_textattr[RheiaLogging::syserror] = cfg->ReadTextAttr( wxT("/syserror") );
    m_textattr[RheiaLogging::debug] = cfg->ReadTextAttr( wxT("/debug") );
    m_textattr[RheiaLogging::trace] = cfg->ReadTextAttr( wxT("/trace") );
}
示例#3
0
void TextCtrlLogger::UpdateSettings()
{
    if (!control)
        return;

    control->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));

    ConfigManager* cfgman = Manager::Get()->GetConfigManager(_T("message_manager"));
    int size = cfgman->ReadInt(_T("/log_font_size"), platform::macosx ? 10 : 8);

    wxFont default_font(size, fixed ? wxFONTFAMILY_MODERN : wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
    wxFont bold_font(default_font);
    wxFont italic_font(default_font);

    bold_font.SetWeight(wxFONTWEIGHT_BOLD);

    wxFont bigger_font(bold_font);
    bigger_font.SetPointSize(size + 2);

    wxFont small_font(default_font);
    small_font.SetPointSize(size - 4);

    italic_font.SetStyle(wxFONTSTYLE_ITALIC);

    // might try alternatively
    //italic_font.SetStyle(wxFONTSTYLE_SLANT);

    wxColour default_text_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    for(unsigned int i = 0; i < num_levels; ++i)
    {
        style[i].SetFont(default_font);
        style[i].SetAlignment(wxTEXT_ALIGNMENT_DEFAULT);
        style[i].SetTextColour(default_text_colour);
        style[i].SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));

        // is it necessary to do that?
        //style[i].SetFlags(...);
    }

    style[caption].SetAlignment(wxTEXT_ALIGNMENT_CENTRE);
    bigger_font.SetUnderlined(true);
    style[caption].SetFont(bigger_font);

    ColourManager *colours = Manager::Get()->GetColourManager();

    style[success].SetTextColour(colours->GetColour(wxT("logs_success_text")));

    style[warning].SetFont(italic_font);
    style[warning].SetTextColour(colours->GetColour(wxT("logs_warning_text")));

    style[error].SetFont(bold_font);
    style[error].SetTextColour(colours->GetColour(wxT("logs_error_text")));

    style[critical].SetFont(bold_font);
    style[critical].SetTextColour(colours->GetColour(wxT("logs_critical_text")));     // we're setting both fore and background colors here
    style[critical].SetBackgroundColour(colours->GetColour(wxT("logs_critical_back"))); // so we don't have to mix in default colors
    style[spacer].SetFont(small_font);

    // Tell control about the font change
    control->SetFont(default_font);
} // end of UpdateSettings