TDE graphics utilities
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.

77 lines
2.3KB

  1. /*
  2. Copyright (c) 2003,2004,2005 Clarence Dang <dang@kde.org>
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  13. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #include <kpwidgetmapper.h>
  24. #include <tqpoint.h>
  25. #include <tqrect.h>
  26. #include <tqwidget.h>
  27. namespace kpWidgetMapper
  28. {
  29. TQPoint fromGlobal (const TQWidget *widget, const TQPoint &point)
  30. {
  31. if (!widget)
  32. return point;
  33. return widget->mapFromGlobal (point);
  34. }
  35. TQRect fromGlobal (const TQWidget *widget, const TQRect &rect)
  36. {
  37. if (!widget || !rect.isValid ())
  38. return rect;
  39. TQPoint topLeft = fromGlobal (widget, rect.topLeft ());
  40. return TQRect (topLeft.x (), topLeft.y (), rect.width (), rect.height ());
  41. }
  42. TQPoint toGlobal (const TQWidget *widget, const TQPoint &point)
  43. {
  44. if (!widget)
  45. return point;
  46. return widget->mapToGlobal (point);
  47. }
  48. TQRect toGlobal (const TQWidget *widget, const TQRect &rect)
  49. {
  50. if (!widget || !rect.isValid ())
  51. return rect;
  52. TQPoint topLeft = toGlobal (widget, rect.topLeft ());
  53. return TQRect (topLeft.x (), topLeft.y (), rect.width (), rect.height ());
  54. }
  55. } // namespace kpWidgetMapper {