KOffice – TDE office suite
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.

kis_tool_dummy.cc 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #include <tqwidget.h>
  19. #include <tqstring.h>
  20. #include <kaction.h>
  21. #include <tqlabel.h>
  22. #include <kaction.h>
  23. #include <klocale.h>
  24. #include "kis_canvas_controller.h"
  25. #include "kis_canvas_subject.h"
  26. #include "kis_cursor.h"
  27. #include "kis_tool_dummy.h"
  28. #include "kis_button_press_event.h"
  29. #include "kis_button_release_event.h"
  30. #include "kis_move_event.h"
  31. KisToolDummy::KisToolDummy()
  32. : super(i18n("No Active Tool"))
  33. {
  34. setName("tool_dummy");
  35. m_subject = 0;
  36. m_dragging = false;
  37. m_optionWidget = 0;
  38. setCursor(TQCursor::forbiddenCursor);
  39. }
  40. KisToolDummy::~KisToolDummy()
  41. {
  42. }
  43. void KisToolDummy::update(KisCanvasSubject *subject)
  44. {
  45. m_subject = subject;
  46. super::update(m_subject);
  47. }
  48. void KisToolDummy::buttonPress(KisButtonPressEvent *e)
  49. {
  50. if (m_subject && !m_dragging && e->button() == Qt::LeftButton) {
  51. KisCanvasController *controller = m_subject->canvasController();
  52. m_origScrollX = controller->horzValue();
  53. m_origScrollY = controller->vertValue();
  54. m_dragPos = controller->windowToView(e->pos());
  55. m_dragging = true;
  56. }
  57. }
  58. void KisToolDummy::move(KisMoveEvent *e)
  59. {
  60. if (m_subject && m_dragging) {
  61. KisCanvasController *controller = m_subject->canvasController();
  62. KisPoint currPos = controller->windowToView(e->pos());
  63. KisPoint delta = currPos - m_dragPos;
  64. controller->scrollTo(m_origScrollX - delta.floorX(), m_origScrollY - delta.floorY());
  65. }
  66. }
  67. void KisToolDummy::buttonRelease(KisButtonReleaseEvent *e)
  68. {
  69. if (m_subject && m_dragging && e->button() == Qt::LeftButton) {
  70. m_dragging = false;
  71. }
  72. }
  73. void KisToolDummy::setup(KActionCollection *collection)
  74. {
  75. m_action = static_cast<KRadioAction *>(collection->action(name()));
  76. if (m_action == 0) {
  77. m_action = new KRadioAction(i18n("&Dummy"), "tool_dummy", TQt::SHIFT+TQt::Key_H, this, TQT_SLOT(activate()), collection, name());
  78. m_action->setExclusiveGroup("tools");
  79. m_ownAction = true;
  80. }
  81. }
  82. TQWidget* KisToolDummy::createOptionWidget(TQWidget* parent)
  83. {
  84. m_optionWidget = new TQLabel(i18n("Layer is locked or invisible."), parent);
  85. m_optionWidget->setCaption(i18n("No Active Tool"));
  86. m_optionWidget->setAlignment(TQt::AlignCenter);
  87. return m_optionWidget;
  88. }
  89. TQWidget* KisToolDummy::optionWidget()
  90. {
  91. return m_optionWidget;
  92. }
  93. #include "kis_tool_dummy.moc"