]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/pluginmanager.cpp
Prevent implicit Widget construction
[xonotic/netradiant.git] / radiant / pluginmanager.cpp
index 35933014641d472b6641173165870b277a4c9ba7..91e9f9ae184f9af759c36e4e75d894c2de222c70 100644 (file)
@@ -1,23 +1,23 @@
 /*
-Copyright (C) 1999-2006 Id Software, Inc. and contributors.
-For a list of contributors, see the accompanying CONTRIBUTORS file.
+   Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
 
-This file is part of GtkRadiant.
+   This file is part of GtkRadiant.
 
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-GtkRadiant is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
 // PlugInManager.cpp: implementation of the CPlugInManager class.
 //
@@ -43,184 +43,168 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 /* plugin manager --------------------------------------- */
 class CPluginSlot : public IPlugIn
 {
-  CopiedString m_menu_name;
-  const _QERPluginTable *mpTable;
-  std::list<CopiedString> m_CommandStrings;
-  std::list<CopiedString> m_CommandTitleStrings;
-  std::list<std::size_t> m_CommandIDs;
-  
+CopiedString m_menu_name;
+const _QERPluginTable *mpTable;
+std::list<CopiedString> m_CommandStrings;
+std::list<CopiedString> m_CommandTitleStrings;
+std::list<std::size_t> m_CommandIDs;
+
 public:
-  /*!
-  build directly from a SYN_PROVIDE interface
 */
-  CPluginSlot(GtkWidget* main_window, const char* name, const _QERPluginTable& table);
-  /*!
-  dispatching a command by name to the plugin
 */
-  void Dispatch(const char *p);
-
-  // IPlugIn ------------------------------------------------------------
-  const char* getMenuName();
-  std::size_t getCommandCount();
-  const char* getCommand(std::size_t n);  
-  const char* getCommandTitle(std::size_t n);
-  void addMenuID(std::size_t n);
-  bool ownsCommandID(std::size_t n);
-  
+/*!
+   build directly from a SYN_PROVIDE interface
+ */
+CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table );
+/*!
+   dispatching a command by name to the plugin
+ */
+void Dispatch( const char *p );
+
+// IPlugIn ------------------------------------------------------------
+const char* getMenuName();
+std::size_t getCommandCount();
+const char* getCommand( std::size_t n );
+const char* getCommandTitle( std::size_t n );
+void addMenuID( std::size_t n );
+bool ownsCommandID( std::size_t n );
+
 };
 
-CPluginSlot::CPluginSlot(GtkWidget* main_window, const char* name, const _QERPluginTable& table)
-{
-  mpTable = &table;
-  m_menu_name = name;
-
-  const char* commands = mpTable->m_pfnQERPlug_GetCommandList();
-  const char* titles = mpTable->m_pfnQERPlug_GetCommandTitleList();
-
-  StringTokeniser commandTokeniser(commands, ",;");
-  StringTokeniser titleTokeniser(titles, ",;");
-  
-  const char* cmdToken = commandTokeniser.getToken();
-  const char *titleToken = titleTokeniser.getToken();
-  while (!string_empty(cmdToken))
-  {
-    if(string_empty(titleToken))
-    {
-      m_CommandStrings.push_back(cmdToken);
-      m_CommandTitleStrings.push_back(cmdToken);
-      cmdToken = commandTokeniser.getToken();
-      titleToken = "";
-    }
-    else
-    {
-      m_CommandStrings.push_back(cmdToken);
-      m_CommandTitleStrings.push_back(titleToken);
-      cmdToken = commandTokeniser.getToken();
-      titleToken = titleTokeniser.getToken();
-    }
-  }
-  mpTable->m_pfnQERPlug_Init(0, (void*)main_window);
-}
-
-const char* CPluginSlot::getMenuName()
-{
-  return m_menu_name.c_str();
+CPluginSlot::CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){
+       mpTable = &table;
+       m_menu_name = name;
+
+       const char* commands = mpTable->m_pfnQERPlug_GetCommandList();
+       const char* titles = mpTable->m_pfnQERPlug_GetCommandTitleList();
+
+       StringTokeniser commandTokeniser( commands, ",;" );
+       StringTokeniser titleTokeniser( titles, ",;" );
+
+       const char* cmdToken = commandTokeniser.getToken();
+       const char *titleToken = titleTokeniser.getToken();
+       while ( !string_empty( cmdToken ) )
+       {
+               if ( string_empty( titleToken ) ) {
+                       m_CommandStrings.push_back( cmdToken );
+                       m_CommandTitleStrings.push_back( cmdToken );
+                       cmdToken = commandTokeniser.getToken();
+                       titleToken = "";
+               }
+               else
+               {
+                       m_CommandStrings.push_back( cmdToken );
+                       m_CommandTitleStrings.push_back( titleToken );
+                       cmdToken = commandTokeniser.getToken();
+                       titleToken = titleTokeniser.getToken();
+               }
+       }
+       mpTable->m_pfnQERPlug_Init( 0, (void*)main_window );
 }
 
-std::size_t CPluginSlot::getCommandCount()
-{
-  return m_CommandStrings.size();  
+const char* CPluginSlot::getMenuName(){
+       return m_menu_name.c_str();
 }
-  
-const char* CPluginSlot::getCommand(std::size_t n)
-{
-  std::list<CopiedString>::iterator i = m_CommandStrings.begin();
-  while(n-- != 0)
-    ++i;
-  return (*i).c_str();  
+
+std::size_t CPluginSlot::getCommandCount(){
+       return m_CommandStrings.size();
 }
 
-const char* CPluginSlot::getCommandTitle(std::size_t n)
-{
-  std::list<CopiedString>::iterator i = m_CommandTitleStrings.begin();
-  while(n-- != 0)
-    ++i;
-  return (*i).c_str();  
+const char* CPluginSlot::getCommand( std::size_t n ){
+       std::list<CopiedString>::iterator i = m_CommandStrings.begin();
+       while ( n-- != 0 )
+               ++i;
+       return ( *i ).c_str();
 }
 
-void CPluginSlot::addMenuID(std::size_t n)
-{
-  m_CommandIDs.push_back(n);
+const char* CPluginSlot::getCommandTitle( std::size_t n ){
+       std::list<CopiedString>::iterator i = m_CommandTitleStrings.begin();
+       while ( n-- != 0 )
+               ++i;
+       return ( *i ).c_str();
 }
 
-bool CPluginSlot::ownsCommandID(std::size_t n)
-{
-  for(std::list<std::size_t>::iterator i = m_CommandIDs.begin(); i != m_CommandIDs.end(); ++i)
-  {
-    if (*i == n)
-      return true;
-  }
-  return false;
+void CPluginSlot::addMenuID( std::size_t n ){
+       m_CommandIDs.push_back( n );
 }
 
-void CPluginSlot::Dispatch(const char *p)
-{
-  Vector3 vMin, vMax;
-  Select_GetBounds (vMin, vMax);
-  mpTable->m_pfnQERPlug_Dispatch(p, reinterpret_cast<float*>(&vMin), reinterpret_cast<float*>(&vMax), true);//QE_SingleBrush(true));
+bool CPluginSlot::ownsCommandID( std::size_t n ){
+       for ( std::list<std::size_t>::iterator i = m_CommandIDs.begin(); i != m_CommandIDs.end(); ++i )
+       {
+               if ( *i == n ) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+void CPluginSlot::Dispatch( const char *p ){
+       Vector3 vMin, vMax;
+       Select_GetBounds( vMin, vMax );
+       mpTable->m_pfnQERPlug_Dispatch( p, reinterpret_cast<float*>( &vMin ), reinterpret_cast<float*>( &vMax ), true ); //QE_SingleBrush(true));
 }
 
 
 class CPluginSlots
 {
-  std::list<CPluginSlot *> mSlots;
+std::list<CPluginSlot *> mSlots;
 public:
-  virtual ~CPluginSlots();
-
-  void AddPluginSlot(GtkWidget* main_window, const char* name, const _QERPluginTable& table)
-  {
-    mSlots.push_back(new CPluginSlot(main_window, name, table));
-  }
-  
-  void PopulateMenu(PluginsVisitor& menu);
-  bool Dispatch(std::size_t n, const char* p);
+virtual ~CPluginSlots();
+
+void AddPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){
+       mSlots.push_back( new CPluginSlot( main_window, name, table ) );
+}
+
+void PopulateMenu( PluginsVisitor& menu );
+bool Dispatch( std::size_t n, const char* p );
 };
 
-CPluginSlots::~CPluginSlots()
-{
-  std::list<CPluginSlot *>::iterator iSlot;
-  for(iSlot=mSlots.begin(); iSlot!=mSlots.end(); ++iSlot)
-  {
-    delete *iSlot;
-    *iSlot = 0;
-  }
+CPluginSlots::~CPluginSlots(){
+       std::list<CPluginSlot *>::iterator iSlot;
+       for ( iSlot = mSlots.begin(); iSlot != mSlots.end(); ++iSlot )
+       {
+               delete *iSlot;
+               *iSlot = 0;
+       }
 }
 
-void CPluginSlots::PopulateMenu(PluginsVisitor& menu)
-{
-  std::list<CPluginSlot *>::iterator iPlug;
-  for(iPlug=mSlots.begin(); iPlug != mSlots.end(); ++iPlug)
-  {
-    menu.visit(*(*iPlug));
-  }
+void CPluginSlots::PopulateMenu( PluginsVisitor& menu ){
+       std::list<CPluginSlot *>::iterator iPlug;
+       for ( iPlug = mSlots.begin(); iPlug != mSlots.end(); ++iPlug )
+       {
+               menu.visit( *( *iPlug ) );
+       }
 }
 
-bool CPluginSlots::Dispatch(std::size_t n, const char* p)
-{
-  std::list<CPluginSlot *>::iterator iPlug;
-  for(iPlug=mSlots.begin(); iPlug!=mSlots.end(); ++iPlug)
-  {
-    CPluginSlot *pPlug = *iPlug;
-    if (pPlug->ownsCommandID(n))
-    {
-      pPlug->Dispatch(p);
-      return true;
-    }
-  }
-  return false;
+bool CPluginSlots::Dispatch( std::size_t n, const char* p ){
+       std::list<CPluginSlot *>::iterator iPlug;
+       for ( iPlug = mSlots.begin(); iPlug != mSlots.end(); ++iPlug )
+       {
+               CPluginSlot *pPlug = *iPlug;
+               if ( pPlug->ownsCommandID( n ) ) {
+                       pPlug->Dispatch( p );
+                       return true;
+               }
+       }
+       return false;
 }
 
 CPluginSlots g_plugin_slots;
 
 
-void FillPluginSlots(CPluginSlots& slots, GtkWidget* main_window)
-{
-  class AddPluginVisitor : public PluginModules::Visitor
-  {
-    CPluginSlots& m_slots;
-    GtkWidget* m_main_window;
-  public:
-    AddPluginVisitor(CPluginSlots& slots, GtkWidget* main_window)
-      : m_slots(slots), m_main_window(main_window)
-    {
-    }
-    void visit(const char* name, const _QERPluginTable& table) const
-    {
-      m_slots.AddPluginSlot(m_main_window, name, table);
-    }
-  } visitor(slots, main_window);
+void FillPluginSlots( CPluginSlots& slots, ui::Widget main_window ){
+       class AddPluginVisitor : public PluginModules::Visitor
+       {
+       CPluginSlots& m_slots;
+       ui::Widget m_main_window;
+public:
+       AddPluginVisitor( CPluginSlots& slots, ui::Widget main_window )
+               : m_slots( slots ), m_main_window( main_window ){
+       }
+       void visit( const char* name, const _QERPluginTable& table ) const {
+               m_slots.AddPluginSlot( m_main_window, name, table );
+       }
+       } visitor( slots, main_window );
 
-  Radiant_getPluginModules().foreachModule(visitor);
+       Radiant_getPluginModules().foreachModule( visitor );
 }
 
 
@@ -228,26 +212,21 @@ void FillPluginSlots(CPluginSlots& slots, GtkWidget* main_window)
 
 CPlugInManager g_PlugInMgr;
 
-CPlugInManager& GetPlugInMgr()
-{
-  return g_PlugInMgr;
+CPlugInManager& GetPlugInMgr(){
+       return g_PlugInMgr;
 }
 
-void CPlugInManager::Dispatch(std::size_t n, const char * p)
-{
-  g_plugin_slots.Dispatch(n, p);
+void CPlugInManager::Dispatch( std::size_t n, const char * p ){
+       g_plugin_slots.Dispatch( n, p );
 }
 
-void CPlugInManager::Init(GtkWidget* main_window)
-{
-  FillPluginSlots(g_plugin_slots, main_window);
+void CPlugInManager::Init( ui::Widget main_window ){
+       FillPluginSlots( g_plugin_slots, main_window );
 }
 
-void CPlugInManager::constructMenu(PluginsVisitor& menu)
-{
-  g_plugin_slots.PopulateMenu(menu);
+void CPlugInManager::constructMenu( PluginsVisitor& menu ){
+       g_plugin_slots.PopulateMenu( menu );
 }
 
-void CPlugInManager::Shutdown()
-{
+void CPlugInManager::Shutdown(){
 }