PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lldndbutton.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 80 lines | 24 code | 12 blank | 44 comment | 0 complexity | 4695b8fa3d671cffdba70e3314999a7c MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lldndbutton.h
  3. * @brief Declaration of the drag-n-drop button.
  4. *
  5. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLDNDBUTTON_H
  27. #define LL_LLDNDBUTTON_H
  28. #include "llbutton.h"
  29. /**
  30. * Class representing a button which can handle Drag-And-Drop event.
  31. *
  32. * LLDragAndDropButton does not contain any logic to handle Drag-And-Drop itself.
  33. * Instead it provides drag_drop_handler_t which can be set to the button.
  34. * Then each Drag-And-Drop will be delegated to this handler without any pre/post processing.
  35. *
  36. * All xml parameters are the same as LLButton has.
  37. *
  38. * @see LLLandmarksPanel for example of usage of this class.
  39. */
  40. class LLDragAndDropButton : public LLButton
  41. {
  42. public:
  43. struct Params : public LLInitParam::Block<Params, LLButton::Params> {};
  44. LLDragAndDropButton(const Params& params);
  45. typedef boost::function<bool (
  46. S32 /*x*/, S32 /*y*/, MASK /*mask*/, BOOL /*drop*/,
  47. EDragAndDropType /*cargo_type*/,
  48. void* /*cargo_data*/,
  49. EAcceptance* /*accept*/,
  50. std::string& /*tooltip_msg*/)> drag_drop_handler_t;
  51. /**
  52. * Sets a handler which should process Drag-And-Drop.
  53. */
  54. void setDragAndDropHandler(drag_drop_handler_t handler) { mDragDropHandler = handler; }
  55. /**
  56. * Process Drag-And-Drop by delegating the event to drag_drop_handler_t.
  57. *
  58. * @return BOOL - value returned by drag_drop_handler_t if it is set, FALSE otherwise.
  59. */
  60. /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
  61. EDragAndDropType cargo_type,
  62. void* cargo_data,
  63. EAcceptance* accept,
  64. std::string& tooltip_msg);
  65. private:
  66. drag_drop_handler_t mDragDropHandler;
  67. };
  68. #endif // LL_LLDNDBUTTON_H