void ScrollbarThemeGtk::paintButton(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect, ScrollbarPart part) { GtkStyleContext* styleContext = gtkScrollbarStyleContext(); gtk_style_context_save(styleContext); ScrollbarOrientation orientation = scrollbar->orientation(); applyScrollbarStyleContextClasses(styleContext, orientation); guint flags = 0; if ((BackButtonStartPart == part && scrollbar->currentPos()) || (BackButtonEndPart == part && scrollbar->currentPos()) || (ForwardButtonEndPart == part && scrollbar->currentPos() != scrollbar->maximum()) || (ForwardButtonStartPart == part && scrollbar->currentPos() != scrollbar->maximum())) { if (part == scrollbar->pressedPart()) flags |= GTK_STATE_FLAG_ACTIVE; if (part == scrollbar->hoveredPart()) flags |= GTK_STATE_FLAG_PRELIGHT; } else flags |= GTK_STATE_FLAG_INSENSITIVE; gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags)); gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_BUTTON); gtk_render_background(styleContext, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); gtk_render_frame(styleContext, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); gfloat arrowScaling; gtk_style_context_get_style(styleContext, "arrow-scaling", &arrowScaling, nullptr); double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling; FloatPoint arrowPoint( rect.x() + (rect.width() - arrowSize) / 2, rect.y() + (rect.height() - arrowSize) / 2); if (flags & GTK_STATE_FLAG_ACTIVE) { gint arrowDisplacementX, arrowDisplacementY; gtk_style_context_get_style(styleContext, "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr); arrowPoint.move(arrowDisplacementX, arrowDisplacementY); } gdouble angle; if (orientation == VerticalScrollbar) angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI : 0; else angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2); gtk_render_arrow(styleContext, context->platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize); gtk_style_context_restore(styleContext); }
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); } }