mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
feat: add clear button to console panel
This commit is contained in:
@@ -79,6 +79,14 @@ public:
|
||||
}
|
||||
void add_message(MessageType type, String const& text, bool joined_to_previous = false) {
|
||||
add_message(make_intrusive<ConsoleMessage>(type,text,joined_to_previous));
|
||||
}
|
||||
|
||||
void clear_console() {
|
||||
messages.clear();
|
||||
layout_all();
|
||||
selection = messages.size();
|
||||
update_scrollbar();
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
bool have_selection() const {
|
||||
@@ -455,6 +463,7 @@ END_EVENT_TABLE()
|
||||
|
||||
ConsolePanel::ConsolePanel(Window* parent, int id)
|
||||
: SetWindowPanel(parent, id)
|
||||
, menuConsole(nullptr)
|
||||
, messages(nullptr)
|
||||
, entry(nullptr)
|
||||
, is_active_window(false)
|
||||
@@ -466,11 +475,13 @@ ConsolePanel::ConsolePanel(Window* parent, int id)
|
||||
messages = new MessageCtrl(splitter, ID_MESSAGE_LIST);
|
||||
entry_panel = new wxPanel(splitter, wxID_ANY);
|
||||
entry = new HistoryTextCtrl(entry_panel, wxID_ANY);
|
||||
wxButton* evaluate = new wxButton(entry_panel, ID_EVALUATE, _BUTTON_("evaluate"));
|
||||
wxButton* evaluate = new wxButton(entry_panel, ID_EVALUATE, _BUTTON_("evaluate"));
|
||||
wxButton* clear = new wxButton(entry_panel, ID_CLEAR_CONSOLE, _BUTTON_("clear"));
|
||||
// init sizer for entry_panel
|
||||
wxSizer* se = new wxBoxSizer(wxHORIZONTAL);
|
||||
se->Add(entry, 1, wxEXPAND, 2);
|
||||
se->Add(evaluate, 0, wxEXPAND | wxLEFT, 2);
|
||||
se->Add(evaluate, 0, wxEXPAND | wxLEFT, 2);
|
||||
se->Add(clear, 0, wxEXPAND | wxLEFT, 2);
|
||||
entry_panel->SetSizer(se);
|
||||
// init splitter
|
||||
splitter->SetMinimumPaneSize(40);
|
||||
@@ -480,7 +491,15 @@ ConsolePanel::ConsolePanel(Window* parent, int id)
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(splitter, 1, wxEXPAND);
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
SetSizer(s);
|
||||
|
||||
// init menus
|
||||
menuConsole = new wxMenu();
|
||||
add_menu_item_tr(menuConsole, ID_CLEAR_CONSOLE, "clear_console", "clear console");
|
||||
}
|
||||
|
||||
ConsolePanel::~ConsolePanel() {
|
||||
delete menuConsole;
|
||||
}
|
||||
|
||||
void ConsolePanel::onChangeSet() {
|
||||
@@ -500,13 +519,20 @@ void ConsolePanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
|
||||
// stop blinker
|
||||
is_active_window = true;
|
||||
stop_blinker();
|
||||
stop_blinker();
|
||||
|
||||
add_tool_tr(tb, ID_CLEAR_CONSOLE, "clear_console", "clear console");
|
||||
tb->Realize();
|
||||
|
||||
mb->Insert(2, menuConsole, _MENU_("console"));
|
||||
}
|
||||
|
||||
void ConsolePanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
// Menus
|
||||
|
||||
// Toolbar
|
||||
tb->DeleteTool(ID_CLEAR_CONSOLE);
|
||||
// Menus
|
||||
mb->Remove(2);
|
||||
|
||||
// we are no longer active, allow blinker
|
||||
is_active_window = false;
|
||||
}
|
||||
@@ -524,6 +550,9 @@ void ConsolePanel::onCommand(int id) {
|
||||
if (id == ID_EVALUATE) {
|
||||
exec(entry->get_command_and_clear());
|
||||
}
|
||||
else if (id == ID_CLEAR_CONSOLE) {
|
||||
messages->clear_console();
|
||||
}
|
||||
}
|
||||
|
||||
void ConsolePanel::onIdle(wxIdleEvent&) {
|
||||
|
||||
Reference in New Issue
Block a user