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