summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Applications/HexEditor/HexEditor.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/Applications/HexEditor/HexEditor.cpp b/Applications/HexEditor/HexEditor.cpp
index 77c67462d5..f5c96c7c77 100644
--- a/Applications/HexEditor/HexEditor.cpp
+++ b/Applications/HexEditor/HexEditor.cpp
@@ -49,6 +49,8 @@ HexEditor::HexEditor(GUI::Widget* parent)
set_frame_thickness(2);
set_scrollbars_enabled(true);
set_font(GFontDatabase::the().get_by_name("Csilla Thin"));
+ set_background_role(ColorRole::Base);
+ set_foreground_role(ColorRole::BaseText);
vertical_scrollbar().set_step(line_height());
}
@@ -484,7 +486,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
GUI::Painter painter(*this);
painter.add_clip_rect(widget_inner_rect());
painter.add_clip_rect(event.rect());
- painter.fill_rect(event.rect(), Color::White);
+ painter.fill_rect(event.rect(), palette().color(background_role()));
if (m_buffer.is_empty())
return;
@@ -498,13 +500,13 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
85,
height() - height_occupied_by_horizontal_scrollbar() //(total_rows() * line_height()) + 5
};
- painter.fill_rect(offset_clip_rect, Color::WarmGray);
- painter.draw_line(offset_clip_rect.top_right(), offset_clip_rect.bottom_right(), Color::DarkGray);
+ painter.fill_rect(offset_clip_rect, palette().ruler());
+ painter.draw_line(offset_clip_rect.top_right(), offset_clip_rect.bottom_right(), palette().ruler_border());
auto margin_and_hex_width = offset_margin_width() + (m_bytes_per_row * (character_width() * 3)) + 15;
painter.draw_line({ margin_and_hex_width, 0 },
{ margin_and_hex_width, vertical_scrollbar().value() + (height() - height_occupied_by_horizontal_scrollbar()) },
- Color::LightGray);
+ palette().ruler_border());
auto view_height = (height() - height_occupied_by_horizontal_scrollbar());
auto min_row = max(0, vertical_scrollbar().value() / line_height()); // if below 0 then use 0
@@ -519,8 +521,14 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
height() - height_occupied_by_horizontal_scrollbar()
};
+ bool is_current_line = (m_position / bytes_per_row()) == i;
auto line = String::format("0x%08X", i * bytes_per_row());
- painter.draw_text(side_offset_rect, line);
+ painter.draw_text(
+ side_offset_rect,
+ line,
+ is_current_line ? Gfx::Font::default_bold_font() : font(),
+ Gfx::TextAlignment::TopLeft,
+ is_current_line ? palette().ruler_active_text() : palette().ruler_inactive_text());
}
for (int i = min_row; i < max_row; i++) {
@@ -529,12 +537,11 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
if (byte_position >= m_buffer.size())
return;
- Color text_color = Color::Black;
+ Color text_color = palette().color(foreground_role());
if (m_tracked_changes.contains(byte_position)) {
text_color = Color::Red;
}
- Color highlight_color = palette().selection();
auto highlight_flag = false;
if (m_selection_start > -1 && m_selection_end > -1) {
if (byte_position >= m_selection_start && byte_position <= m_selection_end) {
@@ -552,10 +559,11 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
line_height() - m_line_spacing
};
if (highlight_flag) {
- painter.fill_rect(hex_display_rect, highlight_color);
- text_color = text_color == Color::Red ? Color::from_rgb(0xFFC0CB) : Color::White;
+ painter.fill_rect(hex_display_rect, palette().selection());
+ text_color = text_color == Color::Red ? Color::from_rgb(0xFFC0CB) : palette().selection_text();
} else if (byte_position == m_position) {
- painter.fill_rect(hex_display_rect, Color::from_rgb(0xCCCCCC));
+ painter.fill_rect(hex_display_rect, palette().inactive_selection());
+ text_color = palette().inactive_selection_text();
}
auto line = String::format("%02X", m_buffer[byte_position]);
@@ -569,9 +577,9 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
};
// selection highlighting.
if (highlight_flag) {
- painter.fill_rect(text_display_rect, highlight_color);
+ painter.fill_rect(text_display_rect, palette().selection());
} else if (byte_position == m_position) {
- painter.fill_rect(text_display_rect, Color::from_rgb(0xCCCCCC));
+ painter.fill_rect(text_display_rect, palette().inactive_selection());
}
painter.draw_text(text_display_rect, String::format("%c", isprint(m_buffer[byte_position]) ? m_buffer[byte_position] : '.'), Gfx::TextAlignment::TopLeft, text_color);