llviewertexteditor.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * @file llviewertexteditor.h
  3. * @brief Text editor widget to let users enter a multi-line document//
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_VIEWERTEXTEDITOR_H
  33. #define LL_VIEWERTEXTEDITOR_H
  34. #include "lltexteditor.h"
  35. class LLViewerTextEditor final : public LLTextEditor
  36. {
  37. public:
  38. LLViewerTextEditor(const std::string& name, const LLRect& rect,
  39. S32 max_length,
  40. const std::string& default_text = std::string(),
  41. LLFontGL* glfont = NULL,
  42. bool allow_embedded_items = false);
  43. ~LLViewerTextEditor() override;
  44. LL_INLINE void setSourceID(const LLUUID& id) { mSourceID = id; }
  45. void makePristine() override;
  46. const std::string& getTag() const override;
  47. LLXMLNodePtr getXML(bool save_children = true) const override;
  48. static LLView* fromXML(LLXMLNodePtr nodep, LLView* parentp,
  49. LLUICtrlFactory*);
  50. // Mouse handler overrides
  51. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  52. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  53. bool handleMiddleMouseDown(S32 x, S32 y, MASK mask) override;
  54. bool handleMiddleMouseUp(S32 x, S32 y, MASK mask) override;
  55. bool handleRightMouseDown(S32 x, S32 y, MASK mask) override;
  56. bool handleHover(S32 x, S32 y, MASK mask) override;
  57. bool handleDoubleClick(S32 x, S32 y, MASK mask) override;
  58. bool handleToolTip(S32 x, S32 y, std::string& msg, LLRect* rect) override;
  59. bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
  60. EDragAndDropType cargo_type, void* cargo_data,
  61. EAcceptance* accept, std::string& tooltip) override;
  62. LL_INLINE const class LLInventoryItem* getDragItem() const
  63. {
  64. return mDragItem;
  65. }
  66. virtual bool importStream(std::istream& str);
  67. bool importBuffer(const char* buffer, S32 length) override;
  68. bool exportBuffer(std::string& buffer) override;
  69. LL_INLINE void setNotecardObjectID(const LLUUID& object_id)
  70. {
  71. mObjectID = object_id;
  72. }
  73. LL_INLINE void setNotecardInfo(const LLUUID& notecard_item_id,
  74. const LLUUID& object_id)
  75. {
  76. mNotecardInventoryID = notecard_item_id;
  77. mObjectID = object_id;
  78. }
  79. void setASCIIEmbeddedText(const std::string& instr);
  80. void setEmbeddedText(const std::string& instr);
  81. std::string getEmbeddedText();
  82. // Appends Second Life time, small font, grey.
  83. // If this starts a line, you need to prepend a newline.
  84. std::string appendTime(bool prepend_newline);
  85. void copyInventory(const LLInventoryItem* item, U32 callback_id = 0);
  86. // Returns true if there is embedded inventory.
  87. // *HACK: This is only useful because the notecard verifier may
  88. // change the asset if there is embedded inventory. This mechanism
  89. // should be changed to get a different asset id from the verifier
  90. // rather than checking if a re-load is necessary. Phoenix 2007-02-27
  91. bool hasEmbeddedInventory();
  92. private:
  93. // Embedded object operations
  94. llwchar pasteEmbeddedItem(llwchar ext_char) override;
  95. void bindEmbeddedChars(LLFontGL* font) const override;
  96. void unbindEmbeddedChars(LLFontGL* font) const override;
  97. bool getEmbeddedItemToolTipAtPos(S32 pos, LLWString& wmsg) const;
  98. bool openEmbeddedItemAtPos(S32 pos);
  99. bool openEmbeddedItem(LLInventoryItem* item, llwchar wc);
  100. S32 insertEmbeddedItem(S32 pos, LLInventoryItem* item);
  101. void openEmbeddedTexture(LLInventoryItem* item, llwchar wc);
  102. void openEmbeddedSound(LLInventoryItem* item, llwchar wc);
  103. void openEmbeddedLandmark(LLInventoryItem* item, llwchar wc);
  104. void openEmbeddedNotecard(LLInventoryItem* item, llwchar wc);
  105. void openEmbeddedCallingcard(LLInventoryItem* item, llwchar);
  106. void showCopyToInvDialog(LLInventoryItem* item, llwchar wc);
  107. void showUnsavedAlertDialog(LLInventoryItem* item);
  108. bool onCopyToInvDialog(const LLSD& notification, const LLSD& response);
  109. static bool onNotecardDialog(const LLSD& notif, const LLSD& response);
  110. private:
  111. LLPointer<class LLEmbeddedNotecardOpener> mInventoryCallback;
  112. LLPointer<LLInventoryItem> mDragItem;
  113. class LLEmbeddedItems* mEmbeddedItemList;
  114. LLUUID mSourceID;
  115. LLUUID mObjectID;
  116. LLUUID mNotecardInventoryID;
  117. llwchar mDragItemChar;
  118. bool mDragItemSaved;
  119. // Inner class
  120. class LLTextCmdInsertEmbeddedItem;
  121. };
  122. #endif // LL_VIEWERTEXTEDITOR_H