Program: bbtk
Module: $RCSfile: bbtkWxGUITextEditor.cxx,v $
Language: C++
- Date: $Date: 2008/03/25 15:47:54 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/24 12:56:40 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "bbtkWxGUITextEditor.h"
#include "bbtkWxBlackBox.h"
#include "bbtkConfigurationFile.h"
+#include "bbtkUtilities.h"
#include "icons/cc_new.xpm"
#include "icons/cc_open.xpm"
//================================================================
void WxGUITextEditorPage::Load(const std::string& filename)
{
- std::cout << "-------------- LOAD ---------------"<<std::endl;
- std::cout << "'" << filename << "'"<<std::endl;
+ // std::cout << "-------------- LOAD ---------------"<<std::endl;
+ // std::cout << "'" << filename << "'"<<std::endl;
//std::string oldFilename = mFilename;
mName = filename;
mAskFilename = false;
//================================================================
void WxGUITextEditorPage::Save(const std::string& filter)
{
- std::cout << "-------------- SAVE ---------------"<<std::endl;
+ // std::cout << "-------------- SAVE ---------------"<<std::endl;
if (mAskFilename)
{
wxFileDialog* fd = new wxFileDialog(this,_T("Save file"),_T(""),
}
else
{
- std::cout << "-------------- CANCELLED ---------------"
- <<std::endl;
+ // std::cout << "-------------- CANCELLED ---------------"
+ // <<std::endl;
return;
}
}
- std::cout << "file [" << mName << "]" <<std::endl;
- mwxInputText->SaveFile(mName);
+ // std::cout << "file [" << mName << "]" <<std::endl;
+ mwxInputText->SaveFile(std2wx(mName));
mwxInputText->SetModified(false);
}
//================================================================
mUser(user),
mFileNameFilter("*.*")
{
- std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
+ // std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
// mInterpreter = new bbtk::Interpreter();
//mInterpreter->SetWxGUITextEditor(this);
// mInterpreter->SetCommandLine(true);
| wxNO_BORDER);
sizer->Add(mwxNotebook,1,wxGROW);
-
+
+
// BUTTONS
wxPanel *btnsCtrlPanel = new wxPanel(this,-1);
wxBoxSizer *btnsSizer = new wxBoxSizer(wxHORIZONTAL);
btnsSizer->Add( mwxPosition );
btnsCtrlPanel->SetSizer(btnsSizer);
+ btnsCtrlPanel->SetAutoLayout(true);
+ btnsCtrlPanel->Layout();
+
sizer->Add ( btnsCtrlPanel, 0, wxLEFT | wxRIGHT | wxBOTTOM //| wxGROW
, 10 );
page->Load(name);
}
page->SetPageName(name);
- mwxNotebook->AddPage(page,name,true);
+ std::string fname = Utilities::get_file_name(name);
+ mwxNotebook->AddPage(page,std2wx(fname),true);
FocusOnCurrentPage();
}
//================================================================
}
void WxGUITextEditor::Open()
{
- std::cout << "-------------- OPEN ---------------"<<std::endl;
+ // std::cout << "-------------- OPEN ---------------"<<std::endl;
wxFileDialog* fd = new wxFileDialog(this,_T("Open file"),_T(""),
_T(""),std2wx(mFileNameFilter),
}
else
{
- std::cout << "-------------- CANCELLED ---------------"<<std::endl;
+ // std::cout << "-------------- CANCELLED ---------------"<<std::endl;
}
}
//================================================================
//================================================================
bool WxGUITextEditor::CloseCurrentPage()
{
- std::cout << "-------------- CLOSE ---------------"<<std::endl;
+ // std::cout << "-------------- CLOSE ---------------"<<std::endl;
if (mwxNotebook->GetPageCount()==0) return true;
if (GetCurrentPage()->IsModified())
{
if (mwxNotebook->GetPageCount()==0) return;
GetCurrentPage()->Save(mFileNameFilter);
mwxNotebook->SetPageText(mwxNotebook->GetSelection(),
- GetCurrentPage()->GetPageName());
+ std2wx(GetCurrentPage()->GetPageName()));
}
//================================================================
//================================================================
void WxGUITextEditor::OnPageClose(wxAuiNotebookEvent& evt)
{
- std::cout << "-------------- CLOSE ---------------"<<std::endl;
+ // std::cout << "-------------- CLOSE ---------------"<<std::endl;
if (!CloseCurrentPage()) evt.Veto();
/*
}
void WxGUITextEditor::New()
{
- std::cout << "-------------- NEW ---------------" << std::endl;
+ /// std::cout << "-------------- NEW ---------------" << std::endl;
NewPage("");
UpdateInfo();
}
// pos+1,
// (long)mwxInputText->GetValue().length())+1;
- mwxPosition->SetLabel(wxString(mess));
+ // mwxPosition->SetLabel(wxString(mess));
+ mwxPosition->SetLabel(std2wx(mess));
mwxPosition->Show();
if (text->IsModified())
{
std::string title("*");
title += GetCurrentPage()->GetPageName();
- mwxNotebook->SetPageText(mwxNotebook->GetSelection(),title);
+ mwxNotebook->SetPageText(mwxNotebook->GetSelection(),std2wx(title));
}
}
//================================================================
SetSizer(sizer);
- // Creates and sets the parent window of all bbtk windows
- wxWindow* top = new wxPanel(this,-1);
- top->Hide();
+ // Creates the parent window of all bbtk windows as a child of this
+ Wx::CreateTopWindow(this);
+ // Add the method OnWxSignal as a Wx::Signal observer
+ //bbtkAddWxSignalObserver(WxGUITextEditorWindow::OnWxSignal);
- Wx::SetTopWindow(top);
SetAutoLayout(true);
Layout();