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.

event.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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_event_h__
  18. #define __tdeparts_event_h__
  19. #include <tqevent.h>
  20. #include <tdelibs_export.h>
  21. class TQWidget;
  22. namespace KParts
  23. {
  24. class Part;
  25. /**
  26. * Base class for all KParts events.
  27. */
  28. class TDEPARTS_EXPORT Event : public TQCustomEvent
  29. {
  30. public:
  31. Event( const char *eventName );
  32. virtual const char *eventName() const;
  33. static bool test( const TQEvent *event );
  34. static bool test( const TQEvent *event, const char *name );
  35. };
  36. /**
  37. * This event is sent to a Part when its GUI has been activated or deactivated.
  38. * This is related to PartActivateEvent, but the difference is that
  39. * GUIActivateEvent happens later (when the GUI is actually built),
  40. * only for parts that have GUI elements, and only if using KParts::MainWindow.
  41. * @see KParts::Part::guiActivateEvent()
  42. */
  43. class TDEPARTS_EXPORT GUIActivateEvent : public Event
  44. {
  45. public:
  46. GUIActivateEvent( bool activated ) : Event( s_strGUIActivateEvent ), m_bActivated( activated ) {}
  47. bool activated() const { return m_bActivated; }
  48. static bool test( const TQEvent *event ) { return Event::test( event, s_strGUIActivateEvent ); }
  49. private:
  50. static const char *s_strGUIActivateEvent;
  51. bool m_bActivated;
  52. };
  53. /**
  54. * This event is sent by the part manager when the active part changes.
  55. * Each time the active part changes, it will send first a PartActivateEvent
  56. * with activated=false, part=oldActivePart, widget=oldActiveWidget
  57. * and then another PartActivateEvent
  58. * with activated=true, part=newPart, widget=newWidget.
  59. * @see KParts::Part::partActivateEvent
  60. */
  61. class TDEPARTS_EXPORT PartActivateEvent : public Event
  62. {
  63. public:
  64. PartActivateEvent( bool activated, Part *part, TQWidget *widget ) : Event( s_strPartActivateEvent ), m_bActivated( activated ), m_part( part ), m_widget( widget ) {}
  65. bool activated() const { return m_bActivated; }
  66. Part *part() const { return m_part; }
  67. TQWidget *widget() const { return m_widget; }
  68. static bool test( const TQEvent *event ) { return Event::test( event, s_strPartActivateEvent ); }
  69. private:
  70. static const char *s_strPartActivateEvent;
  71. bool m_bActivated;
  72. Part *m_part;
  73. TQWidget *m_widget;
  74. };
  75. /**
  76. * This event is sent when a part is selected or deselected.
  77. * @see KParts::PartManager::setSelectionPolicy
  78. */
  79. class TDEPARTS_EXPORT PartSelectEvent : public Event
  80. {
  81. public:
  82. PartSelectEvent( bool selected, Part *part, TQWidget *widget ) : Event( s_strPartSelectEvent ), m_bSelected( selected ), m_part( part ), m_widget( widget ) {}
  83. bool selected() const { return m_bSelected; }
  84. Part *part() const { return m_part; }
  85. TQWidget *widget() const { return m_widget; }
  86. static bool test( const TQEvent *event ) { return Event::test( event, s_strPartSelectEvent ); }
  87. private:
  88. static const char *s_strPartSelectEvent;
  89. bool m_bSelected;
  90. Part *m_part;
  91. TQWidget *m_widget;
  92. };
  93. } // namespace
  94. #endif