WizardPage.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2021, Nick Vella <nick@nxk.io>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGUI/BoxLayout.h>
  7. #include <LibGUI/Label.h>
  8. #include <LibGUI/SeparatorWidget.h>
  9. #include <LibGUI/Widget.h>
  10. #include <LibGUI/Wizards/WizardPage.h>
  11. #include <LibGfx/Font/FontDatabase.h>
  12. #include <LibGfx/SystemTheme.h>
  13. namespace GUI {
  14. WizardPage::WizardPage(DeprecatedString const& title_text, DeprecatedString const& subtitle_text)
  15. : AbstractWizardPage()
  16. {
  17. set_layout<VerticalBoxLayout>(GUI::Margins {}, 0);
  18. auto& header_widget = add<Widget>();
  19. header_widget.set_fill_with_background_color(true);
  20. header_widget.set_background_role(Gfx::ColorRole::Base);
  21. header_widget.set_fixed_height(58);
  22. header_widget.set_layout<VerticalBoxLayout>(GUI::Margins { 15, 30, 0 });
  23. m_title_label = header_widget.add<Label>(title_text);
  24. m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant());
  25. m_title_label->set_fixed_height(m_title_label->font().glyph_height() + 2);
  26. m_title_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
  27. m_subtitle_label = header_widget.add<Label>(subtitle_text);
  28. m_subtitle_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
  29. m_subtitle_label->set_fixed_height(m_subtitle_label->font().glyph_height());
  30. header_widget.add_spacer().release_value_but_fixme_should_propagate_errors();
  31. auto& separator = add<SeparatorWidget>(Gfx::Orientation::Horizontal);
  32. separator.set_fixed_height(2);
  33. m_body_widget = add<Widget>();
  34. m_body_widget->set_layout<VerticalBoxLayout>(20);
  35. }
  36. void WizardPage::set_page_title(DeprecatedString const& text)
  37. {
  38. m_title_label->set_text(text);
  39. }
  40. void WizardPage::set_page_subtitle(DeprecatedString const& text)
  41. {
  42. m_subtitle_label->set_text(text);
  43. }
  44. }