Exemple #1
0
void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{
  wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
  const wxColour font_color{0xB8B8B8};

  g_controller_interface.UpdateInput();

  GamepadPage* const current_page =
      static_cast<GamepadPage*>(m_pad_notebook->GetPage(m_pad_notebook->GetSelection()));

  wxMemoryDC dc;
  auto lock = ControllerEmu::GetStateLock();
  for (ControlGroupBox* g : current_page->control_groups)
  {
    // Only if this control group has a bitmap
    if (!g->static_bitmap)
      continue;

    wxBitmap bitmap(g->static_bitmap->GetBitmap());
    // NOTE: Selecting the bitmap inherits the bitmap's ScaleFactor onto the DC as well.
    dc.SelectObjectAsSource(bitmap);
    dc.SetBackground(*wxWHITE_BRUSH);
    dc.Clear();

#ifdef __WXGTK20__
    int dc_height = 0;
    dc.SetFont(small_font);
    dc.GetTextExtent(g->control_group->name, nullptr, &dc_height);
#endif

    std::unique_ptr<wxGraphicsContext> gc{wxGraphicsContext::Create(dc)};
    gc->DisableOffset();
    gc->SetFont(small_font, font_color);

#ifdef __WXGTK20__
    double gc_height = 0;
    gc->GetTextExtent(g->control_group->name, nullptr, &gc_height);
    // On GTK2, wx creates a new empty Cairo/Pango context for the graphics context instead
    // of reusing the wxMemoryDC one, this causes it to forget the screen DPI so fonts stop
    // scaling, we need to scale it manually instead.
    if (std::ceil(gc_height) < dc_height)
    {
      wxFont fixed_font(small_font);
      fixed_font.SetPointSize(static_cast<int>(fixed_font.GetPointSize() * g->m_scale));
      gc->SetFont(fixed_font, font_color);
    }
#endif

    DrawControlGroupBox(gc.get(), g);
    DrawBorder(gc.get(), g->m_scale);

    // label for sticks and stuff
    if (g->HasBitmapHeading())
      gc->DrawText(StrToWxStr(g->control_group->name).Upper(), 4 * g->m_scale, 2 * g->m_scale);

    gc.reset();
    dc.SelectObject(wxNullBitmap);
    g->static_bitmap->SetBitmap(bitmap);
  }
}
/* Personalize class */
PersonalizePageComponent::PersonalizePageComponent():
background("lab_back","Background"), icons("lab_icons","Icons management"), opt_back("opt_back",""),
opt_name("opt_name", "Name:"), opt_img("opt_img", "Icon path:"), opt_shell("opt_shell", "Command:"),
add_btn("Add"), apply("Apply"), choose_back("back_box"), edit_back("back_field"),
edit_name("name"), edit_icn("icn"), edit_shell("shell"), config(assetConfigFile("config.json")),
json(JSON::parse(config)), success("suc", "Success !")
{
  bgColor = Colour(0xffd23c6d);
  bgImage = createImageFromFile(assetFile("settingsBackground.png"));
  Font big_font(Font::getDefaultMonospacedFontName(), 25.f, 0);
  background.setFont(big_font);
  icons.setFont(big_font);
  
  Font small_font(Font::getDefaultMonospacedFontName(), 17.5f, 0);
  opt_back.setFont(small_font);
  opt_name.setFont(small_font);
  opt_img.setFont(small_font);
  opt_shell.setFont(small_font);
  success.setFont(big_font);
  
  addAndMakeVisible(background);
  addAndMakeVisible(icons);
  addAndMakeVisible(add_btn);
  addAndMakeVisible(apply);
  addAndMakeVisible(success);
  apply.addListener(this);
  add_btn.addListener(this);
  /* ComboBox */
  choose_back.addItem("Default",1);
  choose_back.addItem("Color",2);
  choose_back.addItem("Image",3);
  choose_back.setSelectedId(1);
  choose_back.addListener(this);
  addAndMakeVisible(choose_back);
  //////////////
  /* + */
  edit_back.setColour(TextEditor::ColourIds::textColourId, Colour::greyLevel(0.f));
  addAndMakeVisible(edit_back);
  addAndMakeVisible(opt_back);
  addAndMakeVisible(opt_name);
  addAndMakeVisible(opt_img);
  addAndMakeVisible(opt_shell);
  addAndMakeVisible(edit_name);
  addAndMakeVisible(edit_icn);
  addAndMakeVisible(edit_shell);
  
  showAddComponents(false);
  success.setVisible(false);
  
  // create back button
  backButton = createImageButton("Back", createImageFromFile(assetFile("backIcon.png")));
  backButton->addListener(this);
  backButton->setAlwaysOnTop(true);
  addAndMakeVisible(backButton);
}
Exemple #3
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
void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{
    wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);

    g_controller_interface.UpdateInput();

    // don't want game thread updating input when we are using it here
    std::unique_lock<std::recursive_mutex> lk(g_controller_interface.update_lock, std::try_to_lock);
    if (!lk.owns_lock())
        return;

    GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection());

    for (ControlGroupBox* g : current_page->control_groups)
    {
        // if this control group has a bitmap
        if (g->static_bitmap)
        {
            wxMemoryDC dc;
            wxBitmap bitmap(g->static_bitmap->GetBitmap());
            dc.SelectObject(bitmap);
            dc.Clear();

            dc.SetFont(small_font);
            dc.SetTextForeground(0xC0C0C0);

            // label for sticks and stuff
            if (64 == bitmap.GetHeight())
                dc.DrawText(StrToWxStr(g->control_group->name).Upper(), 4, 2);

            DrawControlGroupBox(dc, g);

            // box outline
            // Windows XP color
            dc.SetPen(wxPen("#7f9db9"));
            dc.SetBrush(*wxTRANSPARENT_BRUSH);
            dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());

            dc.SelectObject(wxNullBitmap);
            g->static_bitmap->SetBitmap(bitmap);
        }
    }
}
Exemple #5
0
void FreeSpaceBar::DrawText(QPainter* p, const QRect& r) {
  QFont small_font(font());
  small_font.setPointSize(small_font.pointSize() - 1);
  small_font.setBold(true);
  QFontMetrics small_metrics(small_font);
  p->setFont(small_font);

  // Work out the geometry for the text
  QList<Label> labels;
  labels << Label(TextForSize(used_text_, total_ - free_), kColorBar1);
  if (additional_)
    labels << Label(TextForSize(additional_text_, additional_), kColorAdd1);
  labels << Label(TextForSize(free_text_, free_ - additional_), kColorBg2);

  int text_width = 0;
  for (const Label& label : labels) {
    text_width += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing +
                  small_metrics.width(label.text);
  }

  // Draw the text
  int x = (r.width() - text_width) / 2;

  p->setRenderHint(QPainter::Antialiasing, false);
  for (const Label& label : labels) {
    const bool light = palette().color(QPalette::Base).value() > 128;

    QRect box(x, r.top() + (r.height() - kLabelBoxSize) / 2, kLabelBoxSize,
              kLabelBoxSize);
    p->setPen(label.color.darker());
    p->setBrush(label.color);
    p->drawRect(box);

    QRect text(x + kLabelBoxSize + kLabelBoxPadding, r.top(),
               small_metrics.width(label.text), r.height());
    p->setPen(light ? label.color.darker() : label.color);
    p->drawText(text, Qt::AlignCenter, label.text);

    x += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing +
         small_metrics.width(label.text);
  }
}
Exemple #6
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") );
}
void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{
	wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);

	g_controller_interface.UpdateInput();

	// don't want game thread updating input when we are using it here
	std::unique_lock<std::recursive_mutex> lk(g_controller_interface.update_lock, std::try_to_lock);
	if (!lk.owns_lock())
		return;

	GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection());

	std::vector< ControlGroupBox* >::iterator
		g = current_page->control_groups.begin(),
		ge = current_page->control_groups.end();
	for ( ; g != ge; ++g  )
	{
		// if this control group has a bitmap
		if ( (*g)->static_bitmap )
		{
			wxMemoryDC dc;
			wxBitmap bitmap((*g)->static_bitmap->GetBitmap());
			dc.SelectObject(bitmap);
			dc.Clear();

			dc.SetFont(small_font);
			dc.SetTextForeground(0xC0C0C0);

			// label for sticks and stuff
			if (64 == bitmap.GetHeight())
				dc.DrawText(wxString::FromAscii((*g)->control_group->name).Upper(), 4, 2);

			switch ( (*g)->control_group->type )
			{
			case GROUP_TYPE_TILT :
			case GROUP_TYPE_STICK :
			case GROUP_TYPE_CURSOR :
				{
					// this is starting to be a mess combining all these in one case

					float x = 0, y = 0, z = 0;
					float xx, yy;

					switch ((*g)->control_group->type)
					{
					case GROUP_TYPE_STICK :
						((ControllerEmu::AnalogStick*)(*g)->control_group)->GetState( &x, &y, 32.0, 32-1.5 );
						break;
					case GROUP_TYPE_TILT :
						((ControllerEmu::Tilt*)(*g)->control_group)->GetState( &x, &y, 32.0, 32-1.5 );
						break;
					case GROUP_TYPE_CURSOR :
						((ControllerEmu::Cursor*)(*g)->control_group)->GetState( &x, &y, &z );
						x *= (32-1.5); x+= 32;
						y *= (32-1.5); y+= 32;
						break;
					}

					xx = (*g)->control_group->controls[3]->control_ref->State();
					xx -= (*g)->control_group->controls[2]->control_ref->State();
					yy = (*g)->control_group->controls[1]->control_ref->State();
					yy -= (*g)->control_group->controls[0]->control_ref->State();
					xx *= 32 - 1; xx += 32;
					yy *= 32 - 1; yy += 32;

					// draw the shit

					// ir cursor forward movement
					if (GROUP_TYPE_CURSOR == (*g)->control_group->type)
					{
						if (z)
						{
							dc.SetPen(*wxRED_PEN);
							dc.SetBrush(*wxRED_BRUSH);
						}
						else
						{
							dc.SetPen(*wxGREY_PEN);
							dc.SetBrush(*wxGREY_BRUSH);
						}
						dc.DrawRectangle( 0, 31 - z*31, 64, 2);
					}

					// circle for visual aid for diagonal adjustment
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.SetBrush(*wxWHITE_BRUSH);
					if ( GROUP_TYPE_STICK == (*g)->control_group->type )
					{
						dc.SetBrush(*wxTRANSPARENT_BRUSH);
						dc.DrawCircle( 32, 32, 32);
					}
					else
						dc.DrawRectangle( 16, 16, 32, 32 );

					if ( GROUP_TYPE_CURSOR != (*g)->control_group->type )
					{
						// deadzone circle
						dc.SetBrush(*wxLIGHT_GREY_BRUSH);
						dc.DrawCircle( 32, 32, ((*g)->control_group)->settings[0]->value * 32 );
					}

					// raw dot
					dc.SetPen(*wxGREY_PEN);
					dc.SetBrush(*wxGREY_BRUSH);
					// i like the dot better than the cross i think
					dc.DrawRectangle( xx - 2, yy - 2, 4, 4 );
					//dc.DrawRectangle( xx-1, 64-yy-4, 2, 8 );
					//dc.DrawRectangle( xx-4, 64-yy-1, 8, 2 );

					// adjusted dot
					if (x!=32 || y!=32)
					{
						dc.SetPen(*wxRED_PEN);
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle( x-2, 64-y-2, 4, 4 );
						// i like the dot better than the cross i think
						//dc.DrawRectangle( x-1, 64-y-4, 2, 8 );
						//dc.DrawRectangle( x-4, 64-y-1, 8, 2 );
					}

				}
				break;
			case GROUP_TYPE_FORCE :
				{
					float raw_dot[3];
					float adj_dot[3];
					const float deadzone = 32 * ((*g)->control_group)->settings[0]->value;

					// adjusted
					((ControllerEmu::Force*)(*g)->control_group)->GetState( adj_dot, 32.0, 32-1.5 );

					// raw
					for ( unsigned int i=0; i<3; ++i )
					{
						raw_dot[i] = (*g)->control_group->controls[i*2 + 1]->control_ref->State()
							- (*g)->control_group->controls[i*2]->control_ref->State();
						raw_dot[i] *= 32 - 1; raw_dot[i] += 32;
					}

					// deadzone rect for forward/backward visual
					dc.SetBrush(*wxLIGHT_GREY_BRUSH);
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.DrawRectangle( 0, 32 - deadzone, 64, deadzone * 2 );

					// raw forward/background line
					dc.SetPen(*wxGREY_PEN);
					dc.SetBrush(*wxGREY_BRUSH);
					dc.DrawRectangle( 0, raw_dot[2] - 1, 64, 2 );

					// adjusted forward/background line
					if ( adj_dot[2]!=32 )
					{
						dc.SetPen(*wxRED_PEN);
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle( 0, adj_dot[2] - 1, 64, 2 );
					}

					// a rectangle, for looks i guess
					dc.SetBrush(*wxWHITE_BRUSH);
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.DrawRectangle( 16, 16, 32, 32 );

					// deadzone square
					dc.SetBrush(*wxLIGHT_GREY_BRUSH);
					dc.DrawRectangle( 32 - deadzone, 32 - deadzone, deadzone * 2, deadzone * 2 );

					// raw dot
					dc.SetPen(*wxGREY_PEN);
					dc.SetBrush(*wxGREY_BRUSH);
					dc.DrawRectangle( raw_dot[1] - 2, raw_dot[0] - 2, 4, 4 );

					// adjusted dot
					if ( adj_dot[1]!=32 || adj_dot[0]!=32 )
					{
						dc.SetPen(*wxRED_PEN);
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle( adj_dot[1]-2, adj_dot[0]-2, 4, 4 );
					}

				}
				break;
			case GROUP_TYPE_BUTTONS :
				{
					const unsigned int button_count = ((unsigned int)(*g)->control_group->controls.size());

					// draw the shit
					dc.SetPen(*wxGREY_PEN);

					unsigned int * const bitmasks = new unsigned int[ button_count ];
					for (unsigned int n = 0; n<button_count; ++n)
						bitmasks[n] = (1 << n);

					unsigned int buttons = 0;
					((ControllerEmu::Buttons*)(*g)->control_group)->GetState( &buttons, bitmasks );

					for (unsigned int n = 0; n<button_count; ++n)
					{
						if ( buttons & bitmasks[n] )
							dc.SetBrush( *wxRED_BRUSH );
						else
						{
							unsigned char amt = 255 - (*g)->control_group->controls[n]->control_ref->State() * 128;
							dc.SetBrush(wxBrush(wxColor(amt, amt, amt)));
						}
						dc.DrawRectangle(n * 12, 0, 14, 12);

						// text
						const char* const name = (*g)->control_group->controls[n]->name;
						// bit of hax so ZL, ZR show up as L, R
						dc.DrawText(wxString::FromAscii((name[1] && name[1] < 'a') ? name[1] : name[0]), n*12 + 2, 1);
					}

					delete[] bitmasks;
					
				}
				break;
			case GROUP_TYPE_TRIGGERS :
				{
					const unsigned int trigger_count = ((unsigned int)((*g)->control_group->controls.size()));

					// draw the shit
					dc.SetPen(*wxGREY_PEN);
					ControlState deadzone =  (*g)->control_group->settings[0]->value;

					unsigned int* const trigs = new unsigned int[trigger_count];
					((ControllerEmu::Triggers*)(*g)->control_group)->GetState( trigs, 64 );

					for ( unsigned int n = 0; n < trigger_count; ++n )
					{
						ControlState trig_r = (*g)->control_group->controls[n]->control_ref->State();

						// outline
						dc.SetPen(*wxGREY_PEN);
						dc.SetBrush(*wxWHITE_BRUSH);
						dc.DrawRectangle(0, n*12, 64, 14);

						// raw
						dc.SetBrush(*wxGREY_BRUSH);
						dc.DrawRectangle(0, n*12, trig_r*64, 14);

						// deadzone affected
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle(0, n*12, trigs[n], 14);

						// text
						dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n]->name), 3, n*12 + 1);
					}

					delete[] trigs;

					// deadzone box
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.SetBrush(*wxTRANSPARENT_BRUSH);
					dc.DrawRectangle(0, 0, deadzone*64, trigger_count*14);

				}
				break;
			case GROUP_TYPE_MIXED_TRIGGERS :
				{
					const unsigned int trigger_count = ((unsigned int)((*g)->control_group->controls.size() / 2));

					// draw the shit
					dc.SetPen(*wxGREY_PEN);
					ControlState thresh =  (*g)->control_group->settings[0]->value;

					for ( unsigned int n = 0; n < trigger_count; ++n )
					{
						dc.SetBrush(*wxRED_BRUSH);
						ControlState trig_d = (*g)->control_group->controls[n]->control_ref->State();

						ControlState trig_a = trig_d > thresh ? 1
							: (*g)->control_group->controls[n+trigger_count]->control_ref->State();

						dc.DrawRectangle(0, n*12, 64+20, 14);
						if ( trig_d <= thresh )
							dc.SetBrush(*wxWHITE_BRUSH);
						dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
						dc.DrawRectangle(64, n*12, 32, 14);

						// text
						dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
						dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n]->name[0]), 64 + 3, n*12 + 1);
					}

					// threshold box
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.SetBrush(*wxTRANSPARENT_BRUSH);
					dc.DrawRectangle(thresh*64, 0, 128, trigger_count*14);

				}
				break;
			case GROUP_TYPE_SLIDER:
				{
					const ControlState deadzone =  (*g)->control_group->settings[0]->value;

					ControlState state = (*g)->control_group->controls[1]->control_ref->State() - (*g)->control_group->controls[0]->control_ref->State();
					dc.SetPen(*wxGREY_PEN);
					dc.SetBrush(*wxGREY_BRUSH);
					dc.DrawRectangle(31 + state * 30, 0, 2, 14);

					((ControllerEmu::Slider*)(*g)->control_group)->GetState(&state, 1);
					if (state)
					{
						dc.SetPen(*wxRED_PEN);
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle(31 + state * 30, 0, 2, 14);
					}

					// deadzone box
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.SetBrush(*wxTRANSPARENT_BRUSH);
					dc.DrawRectangle(32 - deadzone * 32, 0, deadzone * 64, 14);
				}
				break;
			default :
				break;
			}

			// box outline
			// Windows XP color
			dc.SetPen(wxPen(_T("#7f9db9")));
			dc.SetBrush(*wxTRANSPARENT_BRUSH);
			dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());

			dc.SelectObject(wxNullBitmap);
			(*g)->static_bitmap->SetBitmap(bitmap);
		}
	}
}
Exemple #8
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