PageRenderTime 14ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/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
 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
27#ifndef LL_LLDNDBUTTON_H
28#define LL_LLDNDBUTTON_H
29
30#include "llbutton.h"
31
32/**
33 * Class representing a button which can handle Drag-And-Drop event.
34 *
35 * LLDragAndDropButton does not contain any logic to handle Drag-And-Drop itself.
36 * Instead it provides drag_drop_handler_t which can be set to the button.
37 * Then each Drag-And-Drop will be delegated to this handler without any pre/post processing.
38 *
39 * All xml parameters are the same as LLButton has.
40 *
41 * @see LLLandmarksPanel for example of usage of this class.
42 */
43class LLDragAndDropButton : public LLButton
44{
45public:
46	struct Params : public LLInitParam::Block<Params, LLButton::Params> {};
47
48	LLDragAndDropButton(const Params& params);
49
50	typedef boost::function<bool (
51		S32 /*x*/, S32 /*y*/, MASK /*mask*/, BOOL /*drop*/,
52		EDragAndDropType /*cargo_type*/,
53		void* /*cargo_data*/,
54		EAcceptance* /*accept*/,
55		std::string& /*tooltip_msg*/)> drag_drop_handler_t;
56
57
58	/**
59	 * Sets a handler which should process Drag-And-Drop.
60	 */
61	void setDragAndDropHandler(drag_drop_handler_t handler) { mDragDropHandler = handler; }
62
63
64	/**
65	 * Process Drag-And-Drop by delegating the event to drag_drop_handler_t.
66	 * 
67	 * @return BOOL - value returned by drag_drop_handler_t if it is set, FALSE otherwise.
68	 */
69	/*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
70		EDragAndDropType cargo_type,
71		void* cargo_data,
72		EAcceptance* accept,
73		std::string& tooltip_msg);
74
75private:
76	drag_drop_handler_t mDragDropHandler;
77};
78
79
80#endif // LL_LLDNDBUTTON_H