SpectralLibraryMatchResults::~SpectralLibraryMatchResults()
{
   Service<DesktopServices> pDesktop;

   // remove toolbar button and menu item
   QAction* pAction = getAction();
   if (pAction != NULL)
   {
      ToolBar* pToolBar = static_cast<ToolBar*>(pDesktop->getWindow("Spectral", TOOLBAR));
      if (pToolBar != NULL)
      {
         pToolBar->removeItem(pAction);
         MenuBar* pMenuBar = pToolBar->getMenuBar();
         if (pMenuBar != NULL)
         {
            pMenuBar->removeMenuItem(pAction);
         }
      }
   }

   // dockwindow should still exist so detach from it
   DockWindow* pWindow = getDockWindow();
   if (pWindow != NULL)
   {
      pWindow->detach(SIGNAL_NAME(DockWindow, AboutToShowContextMenu),
         Slot(this, &SpectralLibraryMatchResults::updateContextMenu));
   }
}
Exemplo n.º 2
0
/// This will make the floating ToolBarFrame appear at the specified location
void ToolBarStub::ShowWindowedToolBar(wxPoint * where /* = NULL */ ) 
{
   if (!mWindowedStatus) {
      
      if (!mToolBarFrame) {
         //Create a frame with a toolbar of type tbt inside it
         if (mType == MeterToolBarID)
            mToolBarFrame = new ToolBarFullFrame(mFrameParent, mType);
         else
            mToolBarFrame = new ToolBarMiniFrame(mFrameParent, mType);
         
         //Get the newly-created toolbar to get some info from it.
         ToolBar * tempTB = mToolBarFrame->GetToolBar();
         
         mTitle = tempTB->GetTitle();
         mSize = tempTB->GetSize();
      }

      //Move the frame to the mouse position
      if (where) {
         mToolBarFrame->DoMove(*where);
      }
      
      //Show the new window
      mToolBarFrame->DoShow();
   }

   mWindowedStatus = true;
}
Exemplo n.º 3
0
ToolBar* MainWindow::get_toolbar(Properties& prop)
{
    // use the main toolbar by default
    ToolBar* toolbar = toolbar_;

    const char* tool = prop.get_string("tool");
    if (tool && *tool)
    {
        ToolMap::iterator i = toolMap_.find(tool);
        if (i == toolMap_.end())
        {
            toolbar = manage(new ToolBar);
            add_toolbar(tool, *toolbar);
            toolMap_.insert(i, make_pair(tool, toolbar));
        }
        else
        {
            toolbar = i->second;
            if (prop.get_word("separator", 0))
            {
                toolbar->add_separator();
            }
        }
    }
    return toolbar;
}
Exemplo n.º 4
0
//
// Set the visible/hidden state of a toolbar
//
void ToolDock::Expose( int type, bool show )
{
   ToolBar *t = mBars[ type ];

   // Maintain the docked array
   if( show )
   {
      if( mDockedBars.Index( t ) == wxNOT_FOUND )
      {
         mDockedBars.Add( t );
      }
   }
   else
   {
      if( mDockedBars.Index( t ) != wxNOT_FOUND )
      {
         mDockedBars.Remove( t );
      }
   }

   // Make it (dis)appear
   t->Expose( show );

   // Update the layout
   LayoutToolBars();
   Updated();
}
QAction* SpectralLibraryMatchResults::createAction()
{
   // Add toolbar button and menu item to invoke the window
   QAction* pShowAction(NULL);
   ToolBar* pToolBar = static_cast<ToolBar*>(Service<DesktopServices>()->getWindow("Spectral", TOOLBAR));
   if (pToolBar != NULL)
   {
      MenuBar* pMenuBar = pToolBar->getMenuBar();
      if (pMenuBar != NULL)
      {
         QAction* pMenuAction = pMenuBar->getMenuItem("/Spectral/Support Tools");
         if (pMenuAction != NULL)
         {
            QMenu* pMenu = pMenuBar->getMenu(pMenuAction);
            if (pMenu != NULL)
            {
               pShowAction = pMenu->addAction("Spectral Library Match Results Window");
               if (pShowAction != NULL)
               {
                  QPixmap pixShowResults(ShowResultsIcon);
                  pShowAction->setIcon(QIcon(pixShowResults));
                  pShowAction->setCheckable(true);
                  pShowAction->setAutoRepeat(false);
                  pShowAction->setStatusTip("Toggles the display of the Spectral Library Match Results Window");
                  pToolBar->addSeparator();
                  pToolBar->addButton(pShowAction);
               }
            }
         }
      }
   }

   return pShowAction;
}
bool SpectralLibraryManager::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
    mpProgress = Service<PlugInManagerServices>()->getProgress(this);
    if (mpProgress != NULL)
    {
        Service<DesktopServices>()->createProgressDialog(getName(), mpProgress);
    }

    // Create edit library action
    if (isBatch() == false)
    {
        QPixmap pixEditLib(EditSpectralLibraryIcon);
        mpEditSpectralLibraryAction = new QAction(QIcon(pixEditLib),
                "&Edit Spectral Library", this);
        mpEditSpectralLibraryAction->setAutoRepeat(false);
        mpEditSpectralLibraryAction->setStatusTip("Display the editor for adding and removing "
                "signatures used by the Spectral Library Match algorithm plug-ins.");
        VERIFYNR(connect(mpEditSpectralLibraryAction, SIGNAL(triggered()), this, SLOT(editSpectralLibrary())));

        ToolBar* pToolBar = static_cast<ToolBar*>(Service<DesktopServices>()->getWindow("Spectral", TOOLBAR));
        if (pToolBar != NULL)
        {
            pToolBar->addSeparator();
            pToolBar->addButton(mpEditSpectralLibraryAction);
        }
    }

    return true;
}
Exemplo n.º 7
0
void Theme::ApplyUpdatedImages()
{
   AudacityProject *p = GetActiveProject();
   for( int ii = 0; ii < ToolBarCount; ++ii )
   {
      ToolBar *pToolBar = p->mToolManager->GetToolBar(ii);
      if( pToolBar )
         pToolBar->ReCreateButtons();
   }
}
Exemplo n.º 8
0
void ToolManager::Reset()
{
   int ndx;

   // Disconnect all docked bars
   for( ndx = 0; ndx < ToolBarCount; ndx++ )
   {
      wxWindow *parent;
      ToolDock *dock;
      ToolBar *bar = mBars[ ndx ];

      // Disconnect the bar
      if( bar->IsDocked() )
      {
         bar->GetDock()->Undock( bar );
         parent = NULL;
      }
      else
      {
         parent = bar->GetParent();
      }

      if( ndx == SelectionBarID )
      {
         dock = mBotDock;

         wxCommandEvent e;
         bar->GetEventHandler()->ProcessEvent(e);
      }
      else
      {
         dock = mTopDock;
         bar->ReCreateButtons();
      }

      bar->EnableDisableButtons();
#if 0
      if( bar->IsResizable() )
      {
         bar->SetSize(bar->GetBestFittingSize());
      }
#endif
      dock->Dock( bar );

      Expose( ndx, ndx ==  DeviceBarID ? false : true );

      if( parent )
      {
         parent->Destroy();
      }
   }

   LayoutToolBars();
   Updated();
} 
Exemplo n.º 9
0
//
// Tell the toolbars that preferences have been updated
//
void ToolManager::UpdatePrefs()
{
   for( int ndx = 0; ndx < ToolBarCount; ndx++ )
   {
      ToolBar *bar = mBars[ ndx ];
      if( bar )
      {
         bar->UpdatePrefs();
      }
   }
}
Exemplo n.º 10
0
void buildGui() {
	// status bar
	new StatusBar(0,0,CON_WIDTH,1);

	VBox *vbox=new VBox(0,2,1);
	// stats
	ToolBar *stats = new ToolBar(0,0,21,"Stats","Statistics about the current dungeon");
	stats->addWidget(new Label(0,0,wallRatioTxt,"Ratio of wall cells / total number of cells"));
	stats->addWidget(new Label(0,0,seedTxt,"Current random seed used to build the map"));
	vbox->addWidget(stats);
}
Exemplo n.º 11
0
//This creates a toolbar of type t in the ToolBars array
void AudacityProject::LoadToolBar(enum ToolBarType t)
{

   //First, go through ToolBarArray and determine the current 
   //combined height of all toolbars.
   int tbheight = 0;
   int len = mToolBarArray.GetCount();
   for (int i = 0; i < len; i++)
      tbheight += mToolBarArray[i]->GetHeight();


   //Get the size of the current project window
   int width, height;
   GetSize(&width, &height);

   //Create a toolbar of the proper type
   ToolBar *toolbar;
   int h;
   switch (t) {
   case ControlToolBarID:
      h = gControlToolBarStub->GetHeight();
      toolbar = new ControlToolBar(this, -1, wxPoint(10, tbheight), wxSize(width - 10, h));
      ((wxMenuItemBase *)mViewMenu->FindItem(FloatControlToolBarID))->SetName(_("Float Control Toolbar"));
      mToolBarArray.Insert(toolbar, 0);
      break;

   case EditToolBarID:

      if (!gEditToolBarStub){
         gEditToolBarStub = new ToolBarStub(gParentWindow, EditToolBarID);
      }
      
      h = gEditToolBarStub->GetHeight();
      toolbar = new EditToolBar(this, -1, wxPoint(10, tbheight), wxSize(width - 10, h));
      
      
      mToolBarArray.Add(toolbar);
      break;

   case NoneID:
   default:
      toolbar = NULL;
      break;
   }

   //Add the new toolbar to the ToolBarArray and redraw screen
   mTotalToolBarHeight += toolbar->GetHeight() + 1;

   HandleResize();
}
Exemplo n.º 12
0
//
// Toggles the visible/hidden state of a toolbar
//
void ToolManager::ShowHide( int type )
{
   ToolBar *t = mBars[ type ];

   // Handle docked and floaters differently
   if( t->IsDocked() )
   {
      t->GetDock()->ShowHide( type );
   }
   else
   {
      t->Expose( !t->IsVisible() );
   }
}
Exemplo n.º 13
0
// ToolBarStub Constructer. Requires a ToolBarType.
// Whenever a ToolBarStub is around, there will be a floating
// ToolBarFrame.  It may be hidden or unhidden.
ToolBarStub::ToolBarStub(wxWindow * Parent, enum ToolBarType tbt) 
{
   //Create a frame with a toolbar of type tbt inside it
   mToolBarFrame = new ToolBarFrame(Parent, tbt);

   //Get the newly-created toolbar to get some info from it.
   ToolBar * tempTB = mToolBarFrame->GetToolBar();

   mType = tbt;
   mTitle = tempTB->GetTitle();
   mSize = tempTB->GetSize();
   mWindowedStatus = false;
   mLoadedStatus = true;
} 
Exemplo n.º 14
0
//
// Set the visible/hidden state of a toolbar
//
void ToolManager::Expose( int type, bool show )
{
   ToolBar *t = mBars[ type ];

   // Handle docked and floaters differently
   if( t->IsDocked() )
   {
      t->GetDock()->Expose( type, show );
   }
   else
   {
      t->Expose( show );
   }
}
Exemplo n.º 15
0
void ToolBarAreaImpl::expandStrechableBars
(ToolBarRowPtr& row, int portion, int shift, int barIndex, int numStrechables, int lastSpace)
{
    ToolBar* bar = row->toolBars[barIndex];
    bar->desiredX += shift;
    if(bar->isStretchable()){
        int addition = (numStrechables > 1) ? portion : lastSpace;
        shift += addition;
        lastSpace -= addition;
        --numStrechables;
    }
    ++barIndex;
    if(barIndex < (int)row->toolBars.size()){
        expandStrechableBars(row, portion, shift, barIndex,  numStrechables, lastSpace);
    }
}
SpectralLibraryManager::~SpectralLibraryManager()
{
    clearLibrary();

    // Remove the toolbar button
    Service<DesktopServices> pDesktop;
    ToolBar* pToolBar = static_cast<ToolBar*>(pDesktop->getWindow("Spectral", TOOLBAR));
    if (pToolBar != NULL)
    {
        if (mpEditSpectralLibraryAction != NULL)
        {
            VERIFYNR(disconnect(mpEditSpectralLibraryAction, SIGNAL(triggered()), this, SLOT(editSpectralLibrary())));
            pToolBar->removeItem(mpEditSpectralLibraryAction);
        }
    }
}
Exemplo n.º 17
0
//
// Returns the visibility of the specified toolbar
//
bool ToolManager::IsVisible( int type )
{
   ToolBar *t = mBars[ type ];

   return t->IsVisible();

   // If toolbar is floating
   if( !t->IsDocked() )
   {
      // Must return state of floater window
      return t->GetParent()->IsShown();
   }

   // Return state of docked toolbar
   return t->IsShown();
}
Exemplo n.º 18
0
bool
MainWindow::add_toolbar(const char* name, ToolBar& toolbar, bool defaultVisibility)
{
    assert(name);

    if (toolMap_.insert(make_pair(name, &toolbar)).second)
    {
        CHKPTR(toolbox_)->pack_start(toolbar, false, false);

        string toolName(name);
        MenuList& items = CHKPTR(toolMenu_)->items();

        items.push_back(Gtk::Menu_Helpers::CheckMenuElem(
            toolName,
            Gtk_BIND(Gtk_SLOT(this, &MainWindow::on_menu_toggle_toolbar),
                     &toolbar)));
        toolName = "toolbar." + toolName;

        if (debugger().properties()->get_word(toolName.c_str(), defaultVisibility))
        {
            Gtk_MENU_ITEM(items.back()).activate();
            toolbar.show_all();
        }
        return true;
    }
    return false;
}
Exemplo n.º 19
0
void ToolBarAreaImpl::setNewToolBar(ToolBar* toolBar, vector<int>& numStrechablesOfRow)
{
    if(DEBUG_MODE){
        cout << "ToolBarAreaImpl::setNewToolBar()" << endl;
    }
    
    if(toolBar){

        ToolBarRowPtr toolBarRow;
        int rowIndex = -1;
        int width = toolBar->minimumSizeHint().width();

        for(size_t i=0; i < toolBarRows.size(); ++i){
            ToolBarRowPtr existingRow = toolBarRows[i];
            ToolBar* lastToolBar = existingRow->toolBars.back();
            if(lastToolBar){
                QRect r = lastToolBar->geometry();
                int lastX = r.x() + r.width();
                int lastSpace = self->width() - lastX;
                if(width <= lastSpace){
                    toolBar->desiredX = lastX + 1;
                    if(toolBar->isStretchable()){
                        width = std::min(toolBar->sizeHint().width(), lastSpace);
                    }
                    toolBarRow = existingRow;
                    rowIndex = i;
                    break;
                }
            }
        }
        if(!toolBarRow){
            toolBar->desiredX = 0;
            rowIndex = toolBarRows.size();
            toolBarRow.reset(new ToolBarRow(self));
            toolBarRows.push_back(toolBarRow);
            numStrechablesOfRow.push_back(0);
        }
        
        toolBarRow->toolBars.push_back(toolBar);
        if(toolBar->isStretchable()){
            numStrechablesOfRow[rowIndex]++;
        }
        toolBar->setParent(self);
        toolBar->setGeometry(toolBar->desiredX, 0, width, toolBar->sizeHint().height());
        toolBar->show();
    }
}
Exemplo n.º 20
0
void ToolBarMiniFrame::OnMouseEvent(wxMouseEvent& evt)
{

   //The following is prototype code for allowing a double-click
   //close the toolbar.  Commented out in lieu of a close button
   //that is being tested.

#if 0
     if(evt.ButtonDClick(1))
      {
         AudacityProject * p  = GetActiveProject();
         ToolBar* tb = ToolBarFrame::GetToolBar();
         ToolBarStub *tbs= tb->GetToolBarStub();
         p->FloatToolBar(tbs);
      }
#endif
}
Exemplo n.º 21
0
	void Menu::openMenu()
	{
		// Close all SubMenus
		for(std::vector<Menu*>::iterator it = mSubMenus.begin(); it != mSubMenus.end(); ++it)
			(*it)->closeMenu();

		Point p = getScreenPosition();

		if(mParentWidget->getClass() == "ToolBar")
		{
			ToolBar* tb = mDesc->toolBar;
			if(tb == NULL)
				throw Exception(Exception::ERR_INVALID_STATE,"Parent ToolBar reference is NULL!","Menu::openMenu");

			if(tb->getOrientation() == TOOLBAR_ORIENTATION_HORIZONTAL)
			{
				// Position the MenuList above or below the MenuTextItem - below is desired
				if((getScreenPosition().y + mDesc->widget_dimensions.size.height + mMenuPanel->getSize().height) > mDesc->guiManager->getViewport()->getActualHeight())
					p.y = mParentWidget->getScreenPosition().y - mMenuPanel->getSize().height;
				else
					p.y = mParentWidget->getScreenPosition().y + mParentWidget->getSize().height;
			}
			else // orientation is TOOLBAR_ORIENTATION_VERTICAL
			{
				// Position the MenuList to the left or right of the MenuTextItem - right is desired
				if((getScreenPosition().x + mDesc->widget_dimensions.size.width + mMenuPanel->getSize().width) > mDesc->guiManager->getViewport()->getActualWidth())
					p.x = mParentWidget->getScreenPosition().x - mMenuPanel->getSize().width;
				else
					p.x = mParentWidget->getScreenPosition().x + mParentWidget->getSize().width;
			}
		}
		else // parent class is "MenuPanel", which means this menu is a SubMenu of another Menu, or menu of a ContextMenu
		{
			// Position the MenuList to the left or right of the MenuTextItem - right is desired
			if((getScreenPosition().x + getSize().width + mMenuPanel->getSize().width) > mDesc->guiManager->getViewport()->getActualWidth())
				p.x = mParentWidget->getScreenPosition().x - mMenuPanel->getSize().width + mDesc->menu_subMenuOverlap;
			else
				p.x = mParentWidget->getScreenPosition().x + mParentWidget->getSize().width - mDesc->menu_subMenuOverlap;

			p.y = getScreenPosition().y - mMenuPanel->mSkinElement->getBorderThickness(BORDER_TOP);
		}

		mMenuPanel->setPosition(p);
		mMenuPanel->setVisible(true);
	}
Exemplo n.º 22
0
////////////////////////////////////////////////////////////
//  This fetches a pointer to the control toolbar.  It may
//  either be embedded in the current window or floating out
//  in the open.
////////////////////////////////////////////////////////////
ControlToolBar *AudacityProject::GetControlToolBar()
{
   ToolBar *tb = NULL;
   bool GetToolBarFromFrame = false;

   if (mToolBarArray.GetCount() != 0) {
      tb = mToolBarArray[0];
      if ((tb->GetType()) != ControlToolBarID)
         GetToolBarFromFrame = true;
   } else {
      GetToolBarFromFrame = true;
   }

   if (GetToolBarFromFrame && gControlToolBarStub)
      tb = gControlToolBarStub->GetToolBar();

   return wxDynamicCast(tb, ControlToolBar);
}
Exemplo n.º 23
0
/*
 *  Constructs a TextViewer which is a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'
 */
    TextViewer::TextViewer( QWidget *parent, Qt::WFlags f )
: QMainWindow( parent, f )
{
    textArea = new QTextEdit(this);
    textArea->setReadOnly(true);
    setCentralWidget(textArea);
    docSelector = new QDocumentSelector();

    QAction *actionOpen = new QAction(tr("Open Document"), this );
    connect(actionOpen, SIGNAL(triggered()), this, SLOT(openDocument()));
#ifdef QTOPIA_PHONE
    QMenu* menu = QSoftMenuBar::menuFor(textArea);
    menu->addAction(actionOpen);
#else
    ToolBar *toolbar = new QToolBar(this);
    toolbar->setMovable(false);
    addToolBar(toolbar);
    toolbar->addAction(actionOpen);
#endif
    connect(docSelector, SIGNAL(documentSelected(QContent)), this, SLOT(documentSelected(QContent)));
}
Exemplo n.º 24
0
//
// Toggles the visible/hidden state of a toolbar
//
void ToolDock::ShowHide( int type )
{
   ToolBar *t = mBars[ type ];

   // Maintain the docked array
   if( t->IsVisible() )
   {
      mDockedBars.Remove( t );
   }
   else
   {
      mDockedBars.Add( t );
   }

   // Make it (dis)appear
   t->Expose( !t->IsVisible() );

   // Update the layout
   LayoutToolBars();
   Updated();
}
Exemplo n.º 25
0
	virtual bool eventFilter(QObject *o, QEvent *e)
	{
		QToolButton *button = qobject_cast<QToolButton *>(o);
		if (!button)
			return false;
		if (button->isEnabled())
			return false;
		ToolBar *toolbar = qobject_cast<ToolBar *>(button->parentWidget());
		if (!toolbar)
			return false;

		switch (e->type())
		{
			case QEvent::MouseButtonPress:
				toolbar->widgetPressed();
				return true;
			case QEvent::MouseMove:
			{
				QMouseEvent event(QEvent::MouseMove, toolbar->mapFromGlobal(QCursor::pos()), Qt::NoButton, ((QMouseEvent *)e)->buttons(), ((QMouseEvent *)e)->modifiers());
				toolbar->mouseMoveEvent(&event);
				return event.isAccepted();
			}
			case QEvent::ContextMenu:
			{
				QContextMenuEvent event(QContextMenuEvent::Mouse, toolbar->mapFromGlobal(QCursor::pos()));
				toolbar->contextMenuEvent(&event);
				return event.isAccepted();
			}
			default:
				return false;
		}
	}
Exemplo n.º 26
0
ICSPlayersView::ICSPlayersView(void)
    :
    BGroupView("icstxtcontrol_view", B_VERTICAL, 0)
{
    fListView = new PlayersListView();
    fListView->AddColumn(new BTitledColumn("Name", 100, 0, 10000), 0);
    fListView->AddColumn(new BTitledColumn("Blitz", 50, 0, 10000), 1);
    fListView->AddColumn(new BTitledColumn("Bullet", 50, 0, 10000), 2);
    fListView->AddColumn(new BTitledColumn("Title", 50, 0, 10000), 3);
    fListView->AddColumn(new BTitledColumn("Status", 60, 0, 10000), 4);
    fListView->AddColumn(new BTitledColumn("Rank", 50, 0, 10000), 5);
    fListView->AddColumn(new BTitledColumn("Slow", 50, 0, 10000), 6);
    fListView->AddColumn(new BTitledColumn("Internet", 70, 0, 10000), 7);
    fListView->AddColumn(new BTitledColumn("Engine", 60, 0, 10000), 7);

    ToolBar* toolBar = new ToolBar();
    toolBar->AddButton("Challenge", "star_green");
    toolBar->AddButton("Follow", "star_green");
    toolBar->AddButton("Picture", "star_green");
    toolBar->AddButton("Rating", "star_green");
    toolBar->AddButton("Ping", "star_green");

    BLayoutBuilder::Group<>(this)
        .Add(fListView)
        .Add(toolBar)
    ;
}
Exemplo n.º 27
0
void ToolBarAreaImpl::setNewToolBars()
{
    vector<int> numStrechablesOfRow;

    for(size_t i=0; i < newToolBars.size(); ++i){
        setNewToolBar(newToolBars[i], numStrechablesOfRow);
    }
    newToolBars.clear();

    for(size_t i=0; i < numStrechablesOfRow.size(); ++i){
        int numStrechables = numStrechablesOfRow[i];
        if(numStrechables > 0){
            ToolBarRowPtr& row = toolBarRows[i];
            ToolBar* lastToolBar = row->toolBars.back();
            QRect r = lastToolBar->geometry();
            int space = self->width() - (r.x() + r.width());
            if(space > 0){
                expandStrechableBars(row, (space / numStrechables), 0, 0, numStrechables, space);
            }
        }
    }
}
Exemplo n.º 28
0
void ToolBarAreaImpl::storeLayout(YamlMappingPtr layout)
{
    YamlMapping* layoutOfToolBars = layout->createMapping("layoutOfToolBars");
    YamlSequence* rows = layoutOfToolBars->createSequence("rows");
    
    for(size_t i=0; i < toolBarRows.size(); ++i){
        ToolBarList& toolBars = toolBarRows[i]->toolBars;
        if(!toolBars.empty()){
            YamlSequence* bars = new YamlSequence();
            for(ToolBarList::iterator p = toolBars.begin(); p != toolBars.end(); ++p){
                ToolBar* toolBar = *p;
                YamlMapping* state = new YamlMapping();
                state->setFlowStyle(true);
                state->write("name", toolBar->objectName().toStdString(), YAML_DOUBLE_QUOTED);
                state->write("x", toolBar->desiredX);
                state->write("priority", toolBar->layoutPriority);
                bars->append(state);
            }
            rows->append(bars);
        }
    }
}
Exemplo n.º 29
0
//
// Save the toolbar states
//
void ToolManager::WriteConfig()
{
   if( !gPrefs )
   {
      return;
   }

   wxString oldpath = gPrefs->GetPath();
   int ndx;

   // Change to the bar root
   gPrefs->SetPath( wxT("/GUI/ToolBars") );

   // Save state of each bar
   for( ndx = 0; ndx < ToolBarCount; ndx++ )
   {
      ToolBar *bar = mBars[ ndx ];

      // Change to the bar subkey
      gPrefs->SetPath( bar->GetSection() );

      // Search both docks for toolbar order
      int to = mTopDock->GetOrder( bar );
      int bo = mBotDock->GetOrder( bar );

      // Save
      gPrefs->Write( wxT("Dock"), to ? TopDockID : bo ? BotDockID : NoDockID );
      gPrefs->Write( wxT("Order"), to + bo );
      gPrefs->Write( wxT("Show"), IsVisible( ndx ) );

      wxPoint pos( -1, -1 );
      wxSize sz = bar->GetSize();
      if( !bar->IsDocked() )
      {
         pos = bar->GetParent()->GetPosition();
         sz = bar->GetParent()->GetSize();
      }
      gPrefs->Write( wxT("X"), pos.x );
      gPrefs->Write( wxT("Y"), pos.y );
      gPrefs->Write( wxT("W"), sz.x );
      gPrefs->Write( wxT("H"), sz.y );

      // Kill the bar
      bar->Destroy();

      // Change back to the bar root
      gPrefs->SetPath( wxT("..") );
   }

   // Restore original config path
   gPrefs->SetPath( oldpath );
   gPrefs->Flush();
}
	void MenuPanel::onLoseFocus(const EventArgs& args)
	{
		if(mDesc->menupanel_owner != NULL)
		{
			Ogre::String ownerClass = mDesc->menupanel_owner->getClass();
			if(ownerClass == "Menu")
			{
				ToolBar* tb = dynamic_cast<Menu*>(mDesc->menupanel_owner)->getToolBar();
				if(tb != NULL)
				{
					if(mDesc->guiManager->getLastClickedWidget() == NULL)
						tb->closeMenus();
					else if(!mDesc->guiManager->getLastClickedWidget()->isComponentOf(tb) && 
							!mDesc->guiManager->getLastClickedWidget()->isChildOf(tb))
						tb->closeMenus();
				}
				else
				{
					ContextMenu* cm = dynamic_cast<Menu*>(mDesc->menupanel_owner)->getContextMenu();
					if((cm != NULL) && (cm->findWidget(mDesc->sheet->getWindowInFocus()->getName()) == NULL))
						cm->hide();
				}
			}
			else if(ownerClass == "ComboBox")
			{
				ComboBox* cb = dynamic_cast<ComboBox*>(mDesc->menupanel_owner);

				// If we click a widget other than the combobox, hide the list.
				// If we did click the combobox, the combobox will hide the list automatically.
				if(mDesc->guiManager->getLastClickedWidget() == NULL)
					cb->hideDropDownList();
				else if(!mDesc->guiManager->getLastClickedWidget()->isComponentOf(cb))
					cb->hideDropDownList();
			}
		}
	}