HexEditorWidget.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "HexEditor.h"
  8. #include <AK/Function.h>
  9. #include <AK/LexicalPath.h>
  10. #include <LibGUI/ActionGroup.h>
  11. #include <LibGUI/Application.h>
  12. #include <LibGUI/TextEditor.h>
  13. #include <LibGUI/Widget.h>
  14. #include <LibGUI/Window.h>
  15. class HexEditor;
  16. class HexEditorWidget final : public GUI::Widget {
  17. C_OBJECT(HexEditorWidget)
  18. public:
  19. virtual ~HexEditorWidget() override;
  20. void open_file(const String& path);
  21. void initialize_menubar(GUI::Window&);
  22. bool request_close();
  23. private:
  24. HexEditorWidget();
  25. void set_path(StringView const&);
  26. void update_title();
  27. void set_search_results_visible(bool visible);
  28. virtual void drop_event(GUI::DropEvent&) override;
  29. RefPtr<HexEditor> m_editor;
  30. String m_path;
  31. String m_name;
  32. String m_extension;
  33. int m_goto_history { 0 };
  34. String m_search_text;
  35. ByteBuffer m_search_buffer;
  36. int last_found_index() const { return m_last_found_index == -1 ? 0 : m_last_found_index; }
  37. int m_last_found_index { -1 };
  38. RefPtr<GUI::Action> m_new_action;
  39. RefPtr<GUI::Action> m_open_action;
  40. RefPtr<GUI::Action> m_save_action;
  41. RefPtr<GUI::Action> m_save_as_action;
  42. RefPtr<GUI::Action> m_find_action;
  43. RefPtr<GUI::Action> m_goto_offset_action;
  44. RefPtr<GUI::Action> m_layout_toolbar_action;
  45. RefPtr<GUI::Action> m_layout_search_results_action;
  46. GUI::ActionGroup m_bytes_per_row_actions;
  47. RefPtr<GUI::Statusbar> m_statusbar;
  48. RefPtr<GUI::Toolbar> m_toolbar;
  49. RefPtr<GUI::ToolbarContainer> m_toolbar_container;
  50. RefPtr<GUI::TableView> m_search_results;
  51. RefPtr<GUI::Widget> m_search_results_container;
  52. bool m_document_dirty { false };
  53. };