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.

statusbarextension.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* This file is part of the KDE project
  2. Copyright (C) 2003 Daniel Molkentin <molkentin@kde.org>
  3. Copyright (C) 2003 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_STATUSBAREXTENSION_H
  18. #define TDEPARTS_STATUSBAREXTENSION_H
  19. #include <tqwidget.h>
  20. #include <tqvaluelist.h>
  21. #include <tdelibs_export.h>
  22. class KStatusBar;
  23. class TDEMainWindow;
  24. class TQEvent;
  25. namespace KParts
  26. {
  27. class ReadOnlyPart;
  28. // Defined in impl
  29. class StatusBarItem;
  30. /**
  31. * @short An extension for KParts that allows more sophisticated statusbar handling
  32. *
  33. * Every part can use this class to customize the statusbar as long as it is active.
  34. * Add items via addStatusBarItem() and remove an item with removeStatusBarItem().
  35. *
  36. * IMPORTANT: do NOT add any items immediately after constructing the extension.
  37. * Give the application time to set the statusbar in the extension if necessary.
  38. *
  39. * @since 3.2
  40. */
  41. class TDEPARTS_EXPORT StatusBarExtension : public TQObject
  42. {
  43. Q_OBJECT
  44. public:
  45. StatusBarExtension( KParts::ReadOnlyPart *parent, const char *name=0L );
  46. ~StatusBarExtension();
  47. /**
  48. * This adds a widget to the statusbar for this part.
  49. * If you use this method instead of using statusBar() directly,
  50. * this extension will take care of removing the items when the parts GUI
  51. * is deactivated and will re-add them when it is reactivated.
  52. * The parameters are the same as TQStatusBar::addWidget().
  53. *
  54. * Note that you can't use KStatusBar methods (inserting text items by id)
  55. * but you can create a KStatusBarLabel with a dummy id instead, and use
  56. * it directly in order to get the same look and feel.
  57. *
  58. * @param widget the widget to add
  59. * @param stretch the stretch factor. 0 for a minimum size.
  60. * @param permanent passed to TQStatusBar::addWidget as the "permanent" bool.
  61. * Note that the item isn't really permanent though, it goes away when
  62. * the part is unactivated. This simply controls where temporary messages
  63. * hide the @p widget, and whether it's added to the left or to the right side.
  64. *
  65. * IMPORTANT: do NOT add any items immediately after constructing the extension.
  66. * Give the application time to set the statusbar in the extension if necessary.
  67. */
  68. void addStatusBarItem( TQWidget * widget, int stretch, bool permanent );
  69. /**
  70. * Remove a @p widget from the statusbar for this part.
  71. */
  72. void removeStatusBarItem( TQWidget * widget );
  73. /**
  74. * @return the statusbar of the TDEMainWindow in which this part is currently embedded.
  75. * WARNING: this could return 0L
  76. */
  77. KStatusBar* statusBar() const;
  78. /**
  79. * This allows the hosting application to set a particular KStatusBar
  80. * for this part. If it doesn't do this, the statusbar used will be
  81. * the one of the TDEMainWindow in which the part is embedded.
  82. * Konqueror uses this to assign a view-statusbar to the part.
  83. * The part should never call this method!
  84. */
  85. void setStatusBar( KStatusBar* status );
  86. /**
  87. * Queries @p obj for a child object which inherits from this
  88. * BrowserExtension class. Convenience method.
  89. */
  90. static StatusBarExtension *childObject( TQObject *obj );
  91. /** @internal */
  92. virtual bool eventFilter( TQObject *watched, TQEvent* ev );
  93. private:
  94. TQValueList<StatusBarItem> m_statusBarItems; // Our statusbar items
  95. mutable KStatusBar* m_statusBar;
  96. // for future extensions
  97. class StatusBarExtensionPrivate;
  98. StatusBarExtensionPrivate *d;
  99. };
  100. }
  101. #endif // TDEPARTS_STATUSBAREXTENSION_H
  102. // vim: ts=2 sw=2 et