Exemplo n.º 1
0
AntialiasingSettingsView::AntialiasingSettingsView(const char* name)
	: BView(name, 0)
{
	// collect the current system settings
	if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK)
		fCurrentSubpixelAntialiasing = false;
	fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing;

	if (get_hinting_mode(&fCurrentHinting) != B_OK)
		fCurrentHinting = HINTING_MODE_ON;
	fSavedHinting = fCurrentHinting;

	if (get_average_weight(&fCurrentAverageWeight) != B_OK)
		fCurrentAverageWeight = 100;
	fSavedAverageWeight = fCurrentAverageWeight;

	// create the controls

	// antialiasing menu
	_BuildAntialiasingMenu();
	fAntialiasingMenuField = new BMenuField("antialiasing",
		B_TRANSLATE("Antialiasing type:"), fAntialiasingMenu, NULL);

	// "average weight" in subpixel filtering
	fAverageWeightControl = new BSlider("averageWeightControl",
		B_TRANSLATE("Reduce colored edges filter strength:"),
		new BMessage(kMsgSetAverageWeight), 0, 255, B_HORIZONTAL);
	fAverageWeightControl->SetLimitLabels(B_TRANSLATE("Off"),
		B_TRANSLATE("Strong"));
	fAverageWeightControl->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fAverageWeightControl->SetHashMarkCount(255 / 15);
	fAverageWeightControl->SetEnabled(false);

	// hinting menu
	_BuildHintingMenu();
	fHintingMenuField = new BMenuField("hinting", B_TRANSLATE("Glyph hinting:"),
		fHintingMenu, NULL);

#ifdef DISABLE_HINTING_CONTROL
	fHintingMenuField->SetEnabled(false);
#endif

#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
	// subpixelAntialiasingDisabledLabel
	BFont infoFont(*be_plain_font);
	infoFont.SetFace(B_ITALIC_FACE);
	rgb_color infoColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
		B_DARKEN_4_TINT);
	// TODO: Replace with layout friendly constructor once available.
	BRect textBounds = Bounds();
	BTextView* subpixelAntialiasingDisabledLabel = new BTextView(
		textBounds, "unavailable label", textBounds, &infoFont, &infoColor,
		B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT);
	subpixelAntialiasingDisabledLabel->SetText(B_TRANSLATE(
		"Subpixel based anti-aliasing in combination with glyph hinting is not "
		"available in this build of Haiku to avoid possible patent issues. To "
		"enable this feature, you have to build Haiku yourself and enable "
		"certain options in the libfreetype configuration header."));
	subpixelAntialiasingDisabledLabel->SetViewColor(
		ui_color(B_PANEL_BACKGROUND_COLOR));
	subpixelAntialiasingDisabledLabel->MakeEditable(false);
	subpixelAntialiasingDisabledLabel->MakeSelectable(false);
#endif // !FT_CONFIG_OPTION_SUBPIXEL_RENDERING

	SetLayout(new BGroupLayout(B_VERTICAL));

	// controls pane
	AddChild(BGridLayoutBuilder(10, 10)
		.Add(fHintingMenuField->CreateLabelLayoutItem(), 0, 0)
		.Add(fHintingMenuField->CreateMenuBarLayoutItem(), 1, 0)

		.Add(fAntialiasingMenuField->CreateLabelLayoutItem(), 0, 1)
		.Add(fAntialiasingMenuField->CreateMenuBarLayoutItem(), 1, 1)

		.Add(fAverageWeightControl, 0, 2, 2)

#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
		// hinting+subpixel unavailable info
		.Add(subpixelAntialiasingDisabledLabel, 0, 3, 2)
#else
		.Add(BSpaceLayoutItem::CreateGlue(), 0, 3, 2)
#endif

		.SetInsets(10, 10, 10, 10)
	);

	_SetCurrentAntialiasing();
	_SetCurrentHinting();
	_SetCurrentAverageWeight();
}
Exemplo n.º 2
0
void DisView::OnPaint(wxPaintEvent &evt)
{
	wxPaintDC dc(this);
	// Initialize tools
	wxBrush infoBrush(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_INACTIVECAPTION), wxBRUSHSTYLE_SOLID);
	wxBrush arrowBrush(wxColour(0xF7, 0xEA, 0x59));
	wxBrush breakBrush(wxColour(0xFC, 0x0D, 0x00));
	wxFont infoFont(wxSystemSettings::GetFont(wxSystemFont::wxSYS_SYSTEM_FONT));
	wxFont codeFont(wxSystemSettings::GetFont(wxSystemFont::wxSYS_ANSI_FIXED_FONT));
	wxPen transparentPen(wxColour(), 0, wxPenStyle::wxPENSTYLE_TRANSPARENT);
	wxPen infoTextPen(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_INFOTEXT));
	wxPen codeTextPen = infoTextPen;
	dc.SetFont(infoFont);
	dc.SetPen(infoTextPen);

	// Initialize sizes
	wxRect clientRect(dc.GetSize());
	wxRect codeRect = clientRect;
	wxPoint infoCorner(20, dc.GetCharHeight() + 10);
	wxRect addressLabelRect(infoCorner.x, 0, 0, infoCorner.y);
	wxRect rawLabelRect = addressLabelRect;
	wxRect instrLabelRect = rawLabelRect;

	codeRect.SetTopLeft(infoCorner);
	addressLabelRect.SetWidth(dc.GetFontMetrics().averageWidth*16);
	rawLabelRect.Offset(addressLabelRect.GetWidth(), 0);
	rawLabelRect.SetWidth(dc.GetFontMetrics().averageWidth * 18);
	instrLabelRect.SetLeft(rawLabelRect.GetRight());
	instrLabelRect.SetRight(codeRect.GetRight());
	wxRect addressRect = addressLabelRect;
	wxRect rawRect = rawLabelRect;
	wxRect instrRect = instrLabelRect;
	addressRect.Offset(0, addressLabelRect.GetHeight());
	rawRect.Offset(0, rawRect.GetHeight());
	instrRect.Offset(0, instrRect.GetHeight());
	dc.SetFont(codeFont);
	_startingY = infoCorner.y;
	_lineHeight = dc.GetCharHeight();
	addressRect.SetHeight(_lineHeight);
	rawRect.SetHeight(_lineHeight);
	instrRect.SetHeight(_lineHeight);

	// Clear background
	//ClearBackground();

	// Paint info bars
	dc.SetBrush(infoBrush);
	dc.SetFont(infoFont);
	dc.SetPen(transparentPen);
	dc.DrawRectangle(0,0, dc.GetSize().GetWidth(), infoCorner.y);
	dc.DrawRectangle(0, infoCorner.y, infoCorner.x, clientRect.GetHeight()-infoCorner.y);
	dc.SetPen(infoTextPen);
	wxPoint labelVertCenterOffset(0,(addressLabelRect.GetHeight() - dc.GetCharHeight())/2);
	dc.DrawText(_("Address:"), addressLabelRect.GetLeftTop() + labelVertCenterOffset);
	dc.DrawText(_("Raw:"), rawLabelRect.GetLeftTop() + labelVertCenterOffset);
	dc.DrawText(_("Instruction:"), instrLabelRect.GetLeftTop() + labelVertCenterOffset);

	// Paint code section
	dc.SetFont(codeFont);
	dc.SetPen(codeTextPen);
	if (_emu->emu != NULL && _numberOfLines > 0)
	{

		unsigned int address = _startingLine;
		while (addressRect.GetBottom() < codeRect.GetBottom())
		{
			// Draw a line
			const char *raw;
			const char *instr;
			char size = _emu->emu->Disassemble(_emu->handle, address, &raw, &instr);

			if (address == _currentLine) // Draw currentLine icon
			{
				dc.SetBrush(arrowBrush);
				dc.SetPen(transparentPen);
				wxPoint arrowPoint(0, addressRect.GetTop()+2);
				dc.DrawRoundedRectangle(arrowPoint, wxSize(infoCorner.x, _lineHeight-4), 3);
				dc.DrawRectangle(addressRect);
				dc.DrawRectangle(rawRect);
				dc.DrawRectangle(instrRect);
				dc.SetPen(codeTextPen);
			}
			if (_emu->emu->IsBreakpoint(_emu->handle, address))
			{
				// Breakpoint
				wxPoint breakPoint(infoCorner.x / 2, addressRect.GetTop() + _lineHeight / 2);
				dc.SetBrush(breakBrush);
				dc.SetPen(transparentPen);
				dc.DrawCircle(breakPoint, _lineHeight / 2);
				dc.SetPen(codeTextPen);
			}

			dc.DrawText(wxString::Format("0x%08X", address), addressRect.GetLeftTop());
			dc.DrawText(raw, rawRect.GetLeftTop());
			dc.DrawText(instr, instrRect.GetLeftTop());

			address += size;
			address %= _numberOfLines;
			addressRect.Offset(0, addressRect.GetHeight());
			rawRect.Offset(0, rawRect.GetHeight());
			instrRect.Offset(0, instrRect.GetHeight());
		}
		_endingLine = address;
	}
	else {
		// Draw no emulator loaded text
		wxPoint centerCode(codeRect.GetBottomLeft());
		centerCode.y -= codeRect.GetHeight()/2;
		dc.DrawText(_("There is no emulator loaded"),centerCode);
	}
}