Editor.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "Editor.h"
  2. #include "EditorWrapper.h"
  3. #include <LibGUI/GPainter.h>
  4. #include <LibGUI/GScrollBar.h>
  5. EditorWrapper& Editor::wrapper()
  6. {
  7. return static_cast<EditorWrapper&>(*parent());
  8. }
  9. const EditorWrapper& Editor::wrapper() const
  10. {
  11. return static_cast<const EditorWrapper&>(*parent());
  12. }
  13. void Editor::focusin_event(CEvent& event)
  14. {
  15. wrapper().set_editor_has_focus({}, true);
  16. if (on_focus)
  17. on_focus();
  18. GTextEditor::focusin_event(event);
  19. }
  20. void Editor::focusout_event(CEvent & event)
  21. {
  22. wrapper().set_editor_has_focus({}, false);
  23. GTextEditor::focusout_event(event);
  24. }
  25. void Editor::paint_event(GPaintEvent& event)
  26. {
  27. GTextEditor::paint_event(event);
  28. if (is_focused()) {
  29. GPainter painter(*this);
  30. painter.add_clip_rect(event.rect());
  31. auto rect = frame_inner_rect();
  32. if (vertical_scrollbar().is_visible())
  33. rect.set_width(rect.width() - vertical_scrollbar().width());
  34. if (horizontal_scrollbar().is_visible())
  35. rect.set_height(rect.height() - horizontal_scrollbar().height());
  36. painter.draw_rect(rect, Color::from_rgb(0x955233));
  37. }
  38. }