/*=========================================================================
- Program: bbtk
- Module: $RCSfile$
- Language: C++
- Date: $Date$
- Version: $Revision$
+Program: bbtk
+Module: $RCSfile$
+Language: C++
+Date: $Date$
+Version: $Revision$
=========================================================================*/
/* ---------------------------------------------------------------------
* ------------------------------------------------------------------------ */
/**
- * \file
- * \brief Class bbtk::WxInterfaceEditorGraphicBBS .
- */
-
-
+* \file
+* \brief Class bbtk::WxInterfaceEditorGraphicBBS .
+*/
#include "bbtkwxGUIEditorGraphicBBS.h"
-#include "bbtkwxGUIEditorGraphicContainer.h"
-
-#include <bbtkWxGUIPackageBrowser2.h>
-
namespace bbtk
{
- //=========================================================================
+ //=========================================================================
wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent)
- : wxFrame(parent, -1, _T("bbEditor"),wxDefaultPosition, wxSize(1200,800))
- {
- m_mgr.SetManagedWindow(this);
- editorgraphiccontainer = new wxGUIEditorGraphicContainer(this);
-
- wxPanel *mWxGUIGrapphicEditorPanel = new wxPanel(this,-1);
- wxPanel *mWxGUIBoxBrowserPanel = new wxPanel(this,-1);
- wxPanel *mWxGUIConfigurationGraphicEditorPanel = new wxPanel(this,-1);
-
- mWxGUIGrapphicEditorPanel->SetBackgroundColour( wxColor(255,0,0) );
- mWxGUIBoxBrowserPanel->SetBackgroundColour( wxColor(0,255,0) );
- mWxGUIConfigurationGraphicEditorPanel->SetBackgroundColour( wxColor(255,0,255) );
-
- //
- m_mgr.AddPane(mWxGUIGrapphicEditorPanel,
- wxAuiPaneInfo().Name(wxT("graphic_editor_content"))
- .Caption(wxT("Graphic editor"))
- .MinimizeButton(true)
- .MaximizeButton(true)
- .Center()
- .MinSize(wxSize(100,100))
- );
-
- m_mgr.AddPane(mWxGUIBoxBrowserPanel,
- wxAuiPaneInfo().Name(wxT("box_browser_content"))
- .Caption(wxT("Box browser"))
- .MinimizeButton(true)
- .MaximizeButton(true)
- .Right()
- .Layer(2)
- .MinSize(wxSize(400,100))
- );
-
- m_mgr.AddPane(mWxGUIConfigurationGraphicEditorPanel,
- wxAuiPaneInfo().Name(wxT("configuration_graphic_editor_content"))
- .Caption(wxT("Messages"))
- .MinimizeButton(true)
- .MaximizeButton(true)
- .Bottom()
- .MinSize(wxSize(100,100))
- );
-
- SetAutoLayout(true);
- Layout();
- m_mgr.Update();
-
- WxGUIPackageBrowser2 *bb= new WxGUIPackageBrowser2(this);
+ : wxFrame(parent, -1, _T("bbtkGEditor"),wxDefaultPosition, wxSize(1200,800))
+ {
+ _frameAUIMgr = new wxAuiManager(this);
+
+
+ //std::string datadir( crea::System::GetExecutablePath() );
+ std::string datadir (".");
+ cout<<"RaC //------------------"<<endl;
+ cout<<"RaC //TODO wxGUIEditorGraphicBBS constructor.Initialize datadir with crea::System::GetExecutablePath() ."<<endl;
+ cout<<"RaC //------------------"<<endl;
+
+ #ifdef LINUX /* assume this is OSX */
+ datadir=datadir+"/../share/creaContours";
+ #endif // MACOSX
- }
+ #ifdef MACOSX /* assume this is OSX */
+ datadir=datadir+"/../../../../share/creaContours";
+ #endif // MACOSX
+
+ _dataDir = datadir;
+
+ initMenu();
+ initToolbar();
+ initPackageBrowser();
+ initTabPanelsManager();
+
+ CreateStatusBar();
+ _frameAUIMgr->Update();
+ }
+
+
+ //=========================================================================
+ wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS()
+ {
+ _frameAUIMgr->UnInit();
+ }
+
+ //=========================================================================
+ void wxGUIEditorGraphicBBS::initToolbar()
+ {
+ //std::string filename= _dataDir + "/data/icons/wxart_new.xpm";
+ wxBitmap bmp_new(new_xpm);
+
+ wxToolBar *_toolbar = new wxToolBar(this, wxID_ANY);
+
+ //Adds a tool btn to the toolbar
+ _toolbar->AddTool(wxID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
- //=========================================================================
- wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS()
- {
- delete editorgraphiccontainer;
- m_mgr.UnInit();
- }
- //=========================================================================
+ ////////////////////
+ // TEMP to avoid drag and drop
+
+ _toolbar->AddTool(wxID_NEW+1,_T("New Box"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New Box"), _T("Create a new Box"));
+
+
+ //
+ ////////////////////
+
+ _toolbar->SetMargins( 2, 2 );
+ _toolbar->Realize();
+ SetToolBar(_toolbar);
+
+ // connect command event handlers
+ Connect(wxID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
+
+ }
+
+ //=========================================================================
+ void wxGUIEditorGraphicBBS::initMenu()
+ {
+ // create a menu bar
+ wxMenu *fileMenu = new wxMenu;
+
+ // the "About" item should be in the help menu
+ wxMenu *helpMenu = new wxMenu;
+ helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
+ fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
+
+ // now append the freshly created menu to the menu bar...
+ wxMenuBar *menuBar = new wxMenuBar();
+ menuBar->Append(fileMenu, _T("&File"));
+ menuBar->Append(helpMenu, _T("&Help"));
+
+ // attach this menu bar to the frame
+ SetMenuBar(menuBar);
+ }
+
+ //=========================================================================
+ void wxGUIEditorGraphicBBS::initTabPanelsManager()
+ {
+ wxAuiNotebook *notebook = new wxAuiNotebook(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP|wxAUI_NB_TAB_MOVE|wxAUI_NB_CLOSE_ON_ACTIVE_TAB|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON);
+ _tabsMgr = new wxTabPanelsManager(notebook);
+ _frameAUIMgr->AddPane(notebook,wxAuiPaneInfo().CenterPane());
+
+ }
+
+ //=========================================================================
+ void wxGUIEditorGraphicBBS::initPackageBrowser()
+ {
+ _pkgBrowser = new WxGUIPackageBrowser2(this);
+ _pkgBrowser->IncludeAll();
+ _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));
+
+ //FIXME - Just the first tab with drop target event
+ //_pkgBrowser->SetBoxListDropTarget((wxDropTarget*)_tabsMgr->getActualTabPanel());
+ }
+
+ /*****************************************************
+ /* HANDLERS
+ /*****************************************************/
+
+ void wxGUIEditorGraphicBBS::OnToolLeftClick(wxCommandEvent& event)
+ {
+ switch (event.GetId())
+ {
+ case wxID_NEW :
+ std::cout<<"RaC New"<<std::endl;
+ _tabsMgr->addNewTab();
+ break;
+ case wxID_NEW+1 :
+ //BlackBoxDescriptor* desc = _pkgBrowser->GetActualSelected();
+ //cout<<"RaC GetActualSelected desc:"<<desc->GetAuthor()<<endl;
+ }
+ }
} // EO namespace bbtk