PageRenderTime 28ms CodeModel.GetById 14ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llviewertexteditor.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 133 lines | 65 code | 25 blank | 43 comment | 0 complexity | 8be27c9aec6c65eca314cccbcc3341dc MD5 | raw file
  1/** 
  2 * @file llviewertexteditor.h
  3 * @brief Text editor widget to let users enter a multi-line document//
  4 *
  5 * $LicenseInfo:firstyear=2001&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_VIEWERTEXTEDITOR_H
 28#define LL_VIEWERTEXTEDITOR_H
 29
 30#include "lltexteditor.h"
 31
 32//
 33// Classes
 34//
 35class LLViewerTextEditor : public LLTextEditor
 36{
 37public:
 38	struct Params : public LLInitParam::Block<Params, LLTextEditor::Params>
 39	{};
 40
 41protected:
 42	LLViewerTextEditor(const Params&);
 43	friend class LLUICtrlFactory;
 44
 45public:
 46	virtual ~LLViewerTextEditor();
 47
 48	virtual void makePristine();
 49	
 50	// mousehandler overrides
 51	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 52	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 53	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
 54	virtual BOOL	handleDoubleClick(S32 x, S32 y, MASK mask );
 55
 56	virtual BOOL	handleDragAndDrop(S32 x, S32 y, MASK mask,
 57										BOOL drop, EDragAndDropType cargo_type, 
 58										void *cargo_data, EAcceptance *accept, std::string& tooltip_msg);
 59
 60  	const class LLInventoryItem* getDragItem() const { return mDragItem; }
 61	virtual BOOL 	importBuffer(const char* buffer, S32 length);
 62	virtual bool	importStream(std::istream& str);
 63	virtual BOOL 	exportBuffer(std::string& buffer);
 64	virtual void	onValueChange(S32 start, S32 end);
 65
 66	void setNotecardInfo(const LLUUID& notecard_item_id, const LLUUID& object_id, const LLUUID& preview_id)
 67	{
 68		mNotecardInventoryID = notecard_item_id;
 69		mObjectID = object_id;
 70		mPreviewID = preview_id;
 71	}
 72	
 73	void setASCIIEmbeddedText(const std::string& instr);
 74	void setEmbeddedText(const std::string& instr);
 75	std::string getEmbeddedText();
 76	
 77	// Appends Second Life time, small font, grey.
 78	// If this starts a line, you need to prepend a newline.
 79	std::string appendTime(bool prepend_newline);
 80
 81	void copyInventory(const LLInventoryItem* item, U32 callback_id = 0);
 82
 83	// returns true if there is embedded inventory.
 84	// *HACK: This is only useful because the notecard verifier may
 85	// change the asset if there is embedded inventory. This mechanism
 86	// should be changed to get a different asset id from the verifier
 87	// rather than checking if a re-load is necessary. Phoenix 2007-02-27
 88	bool hasEmbeddedInventory();
 89
 90private:
 91	// Embedded object operations
 92	void findEmbeddedItemSegments(S32 start, S32 end);
 93	virtual llwchar	pasteEmbeddedItem(llwchar ext_char);
 94
 95	BOOL			openEmbeddedItemAtPos( S32 pos );
 96	BOOL			openEmbeddedItem(LLPointer<LLInventoryItem> item, llwchar wc);
 97
 98	S32				insertEmbeddedItem(S32 pos, LLInventoryItem* item);
 99
100	// *NOTE: most of openEmbeddedXXX methods except openEmbeddedLandmark take pointer to LLInventoryItem.
101	// Be sure they don't bind it to callback function to avoid situation when it gets invalid when
102	// callback is trigged after text editor is closed. See EXT-8459.
103	void			openEmbeddedTexture( LLInventoryItem* item, llwchar wc );
104	void			openEmbeddedSound( LLInventoryItem* item, llwchar wc );
105	void			openEmbeddedLandmark( LLPointer<LLInventoryItem> item_ptr, llwchar wc );
106	void			openEmbeddedNotecard( LLInventoryItem* item, llwchar wc);
107	void			openEmbeddedCallingcard( LLInventoryItem* item, llwchar wc);
108	void			showCopyToInvDialog( LLInventoryItem* item, llwchar wc );
109	void			showUnsavedAlertDialog( LLInventoryItem* item );
110
111	bool			onCopyToInvDialog(const LLSD& notification, const LLSD& response );
112	static bool		onNotecardDialog(const LLSD& notification, const LLSD& response );
113	
114	LLPointer<LLInventoryItem> mDragItem;
115	LLTextSegment* mDragSegment;
116	llwchar mDragItemChar;
117	BOOL mDragItemSaved;
118	class LLEmbeddedItems* mEmbeddedItemList;
119
120	LLUUID mObjectID;
121	LLUUID mNotecardInventoryID;
122	LLUUID mPreviewID;
123
124	LLPointer<class LLEmbeddedNotecardOpener> mInventoryCallback;
125
126	//
127	// Inner classes
128	//
129
130	class TextCmdInsertEmbeddedItem;
131};
132
133#endif  // LL_VIEWERTEXTEDITOR_H