TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

factory.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* This file is part of the KDE project
  2. Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
  3. (C) 1999 David Faure <faure@kde.org>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef __tdeparts_factory_h__
  18. #define __tdeparts_factory_h__
  19. #include <klibloader.h>
  20. class TQWidget;
  21. namespace KParts
  22. {
  23. class Part;
  24. /**
  25. * A generic factory object to create a Part.
  26. *
  27. * Factory is an abstract class. Reimplement the
  28. * createPartObject() method to give it functionality.
  29. *
  30. * @see KLibFactory.
  31. */
  32. class TDEPARTS_EXPORT Factory : public KLibFactory
  33. {
  34. Q_OBJECT
  35. public:
  36. Factory( TQObject *parent = 0, const char *name = 0 );
  37. virtual ~Factory();
  38. /**
  39. * Creates a part.
  40. *
  41. * The TQStringList can be used to pass additional arguments to the part.
  42. * If the part needs additional arguments, it should take them as
  43. * name="value" pairs. This is the way additional arguments will get passed
  44. * to the part from eg. tdehtml. You can for example embed the part into HTML
  45. * by using the following code:
  46. * \code
  47. * <object type="my_mimetype" data="url_to_my_data">
  48. * <param name="name1" value="value1">
  49. * <param name="name2" value="value2">
  50. * </object>
  51. * \endcode
  52. * This could result in a call to
  53. * \code
  54. * createPart( parentWidget, name, parentObject, parentName, "KParts::Part",
  55. * TQStringList("name1="value1"", "name2="value2") );
  56. * \endcode
  57. *
  58. * @returns the newly created part.
  59. *
  60. * createPart() automatically emits a signal KLibFactory::objectCreated to tell
  61. * the library about its newly created object. This is very
  62. * important for reference counting, and allows unloading the
  63. * library automatically once all its objects have been destroyed.
  64. */
  65. Part *createPart( TQWidget *parentWidget = 0, const char *widgetName = 0, TQObject *parent = 0, const char *name = 0, const char *classname = "KParts::Part", const TQStringList &args = TQStringList() );
  66. /**
  67. * If you have a part contained in a shared library you might want to query
  68. * for meta-information like the about-data, or the TDEInstance in general.
  69. * If the part is exported using KParts::GenericFactory then this method will
  70. * return the instance that belongs to the part without the need to instantiate
  71. * the part component.
  72. */
  73. const TDEInstance *partInstance();
  74. /**
  75. * A convenience method for partInstance() that takes care of retrieving
  76. * the factory for a given library name and calling partInstance() on it.
  77. *
  78. * @param libraryName name of the library to query the instance from
  79. */
  80. static const TDEInstance *partInstanceFromLibrary( const TQCString &libraryName );
  81. protected:
  82. /**
  83. * Reimplement this method in your implementation to create the Part.
  84. *
  85. * The TQStringList can be used to pass additional arguments to the part.
  86. * If the part needs additional arguments, it should take them as
  87. * name="value" pairs. This is the way additional arguments will get passed
  88. * to the part from eg. tdehtml. You can for example emebed the part into HTML
  89. * by using the following code:
  90. * \code
  91. * <object type="my_mimetype" data="url_to_my_data">
  92. * <param name="name1" value="value1">
  93. * <param name="name2" value="value2">
  94. * </object>
  95. * \endcode
  96. * This could result in a call to
  97. * \code
  98. * createPart( parentWidget, name, parentObject, parentName, "Kparts::Part",
  99. * TQStringList("name1="value1"", "name2="value2") );
  100. * \endcode
  101. *
  102. * @returns the newly created part.
  103. */
  104. virtual Part *createPartObject( TQWidget *parentWidget = 0, const char *widgetName = 0, TQObject *parent = 0, const char *name = 0, const char *classname = "KParts::Part", const TQStringList &args = TQStringList() ) = 0;
  105. /**
  106. * Reimplemented from KLibFactory. Calls createPart()
  107. */
  108. virtual TQObject *createObject( TQObject *parent = 0, const char *name = 0, const char *classname = TQOBJECT_OBJECT_NAME_STRING, const TQStringList &args = TQStringList() );
  109. /** This 'enum' along with the structure below is NOT part of the public API.
  110. * It's going to disappear in KDE 4.0 and is likely to change inbetween.
  111. *
  112. * @internal
  113. */
  114. enum { VIRTUAL_QUERY_INSTANCE_PARAMS = 0x10 };
  115. struct QueryInstanceParams
  116. {
  117. const TDEInstance *instance;
  118. };
  119. };
  120. }
  121. /*
  122. * vim: et sw=4
  123. */
  124. #endif