FormEditorWidget.cpp 1000 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "FormEditorWidget.h"
  2. #include "CursorTool.h"
  3. #include "FormWidget.h"
  4. #include "WidgetTreeModel.h"
  5. #include <LibGUI/GPainter.h>
  6. FormEditorWidget::FormEditorWidget(GWidget* parent)
  7. : GScrollableWidget(parent)
  8. , m_tool(make<CursorTool>(*this))
  9. {
  10. set_fill_with_background_color(true);
  11. set_background_color(Color::MidGray);
  12. set_frame_shape(FrameShape::Container);
  13. set_frame_shadow(FrameShadow::Sunken);
  14. set_frame_thickness(2);
  15. m_form_widget = FormWidget::construct(*this);
  16. m_widget_tree_model = WidgetTreeModel::create(*m_form_widget);
  17. }
  18. FormEditorWidget::~FormEditorWidget()
  19. {
  20. }
  21. void FormEditorWidget::paint_event(GPaintEvent& event)
  22. {
  23. GFrame::paint_event(event);
  24. GPainter painter(*this);
  25. painter.add_clip_rect(event.rect());
  26. }
  27. void FormEditorWidget::set_tool(NonnullOwnPtr<Tool> tool)
  28. {
  29. m_tool->detach();
  30. m_tool = move(tool);
  31. m_tool->attach();
  32. }
  33. WidgetTreeModel& FormEditorWidget::model()
  34. {
  35. return *m_widget_tree_model;
  36. }