2015-04-02 18:00:50 -04:00
|
|
|
/**
|
|
|
|
* Wrapper around wxAuiNotebook
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "TabContainer.h"
|
|
|
|
|
|
|
|
static unsigned long untitled_document_count = 0;
|
2015-04-13 09:30:56 -04:00
|
|
|
static unsigned long open_document_count = 0;
|
2015-04-02 18:00:50 -04:00
|
|
|
|
|
|
|
TabContainer::TabContainer(
|
|
|
|
wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style
|
|
|
|
) : wxAuiNotebook(parent, id, pos, size, style)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TabContainer::~TabContainer() {}
|
|
|
|
|
|
|
|
void TabContainer::AddTab()
|
|
|
|
{
|
|
|
|
untitled_document_count++;
|
2015-04-13 09:30:56 -04:00
|
|
|
open_document_count++;
|
|
|
|
|
2015-04-02 18:00:50 -04:00
|
|
|
wxString caption;
|
2015-04-10 15:11:15 -04:00
|
|
|
|
2015-04-02 18:00:50 -04:00
|
|
|
caption.Printf("Untitled %lu", untitled_document_count);
|
2015-04-10 15:11:15 -04:00
|
|
|
|
2015-04-09 11:45:19 -04:00
|
|
|
EditPane *editor = new EditPane(this, wxID_ANY);
|
2015-04-10 15:11:15 -04:00
|
|
|
|
2015-04-15 12:17:25 -04:00
|
|
|
this->AddPage(editor, caption, true);
|
2015-04-02 18:00:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void TabContainer::AddTab(wxString filePath)
|
|
|
|
{
|
2015-04-13 09:30:56 -04:00
|
|
|
open_document_count++;
|
|
|
|
|
2015-04-10 15:11:15 -04:00
|
|
|
wxFileName fileName(filePath);
|
|
|
|
|
|
|
|
wxString caption= fileName.GetFullName();
|
2015-04-09 11:45:19 -04:00
|
|
|
EditPane *editor = new EditPane(this, wxID_ANY);
|
2015-04-02 18:00:50 -04:00
|
|
|
|
2015-04-10 15:11:15 -04:00
|
|
|
bool loaded_file = editor->LoadAndHighlight(filePath);
|
2015-04-09 17:16:28 -04:00
|
|
|
|
2015-04-10 15:11:15 -04:00
|
|
|
if (loaded_file)
|
|
|
|
{
|
2015-04-15 12:17:25 -04:00
|
|
|
this->AddPage(editor, caption, true);
|
2015-04-10 15:11:15 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-15 12:17:25 -04:00
|
|
|
wxMessageDialog err(
|
|
|
|
this,
|
|
|
|
_T("Failed to open the specified file. Do you have permission to open it?"),
|
|
|
|
_T("Could not open file."),
|
|
|
|
wxOK|wxCENTER|wxICON_WARNING
|
|
|
|
);
|
|
|
|
err.ShowModal();
|
2015-04-10 15:11:15 -04:00
|
|
|
}
|
2015-04-09 11:45:19 -04:00
|
|
|
}
|
|
|
|
|
2015-04-09 13:27:30 -04:00
|
|
|
EditPane *TabContainer::GetCurrentEditor()
|
2015-04-09 11:45:19 -04:00
|
|
|
{
|
2015-04-09 13:27:30 -04:00
|
|
|
return (EditPane *) this->GetCurrentPage();
|
2015-04-09 11:45:19 -04:00
|
|
|
}
|