PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llurllineeditorctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 92 lines | 50 code | 13 blank | 29 comment | 0 complexity | 1933c70dd34902108b5408d555c502f3 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llurllineeditorctrl.h
  3. * @brief Combobox-like location input control
  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 LLURLLINEEDITOR_H_
  27. #define LLURLLINEEDITOR_H_
  28. #include "linden_common.h"
  29. #include "lllineeditor.h"
  30. #include "lluictrl.h"
  31. // LLURLLineEditor class performing escaping of an URL while copying or cutting the target text
  32. class LLURLLineEditor: public LLLineEditor {
  33. LOG_CLASS( LLURLLineEditor);
  34. public:
  35. // LLLineEditor overrides to do necessary escaping
  36. /*virtual*/ void copy();
  37. /*virtual*/ void cut();
  38. protected:
  39. LLURLLineEditor(const Params&);
  40. friend class LLUICtrlFactory;
  41. friend class LLFloaterEditUI;
  42. private:
  43. // util function to escape selected text and copy it to clipboard
  44. void copyEscapedURLToClipboard();
  45. // Helper class to do rollback if needed
  46. class LLURLLineEditorRollback
  47. {
  48. public:
  49. LLURLLineEditorRollback( LLURLLineEditor* ed )
  50. :
  51. mCursorPos( ed->mCursorPos ),
  52. mScrollHPos( ed->mScrollHPos ),
  53. mIsSelecting( ed->mIsSelecting ),
  54. mSelectionStart( ed->mSelectionStart ),
  55. mSelectionEnd( ed->mSelectionEnd )
  56. {
  57. mText = ed->getText();
  58. }
  59. void doRollback( LLURLLineEditor* ed )
  60. {
  61. ed->mCursorPos = mCursorPos;
  62. ed->mScrollHPos = mScrollHPos;
  63. ed->mIsSelecting = mIsSelecting;
  64. ed->mSelectionStart = mSelectionStart;
  65. ed->mSelectionEnd = mSelectionEnd;
  66. ed->mText = mText;
  67. ed->mPrevText = mText;
  68. }
  69. std::string getText() { return mText; }
  70. private:
  71. std::string mText;
  72. S32 mCursorPos;
  73. S32 mScrollHPos;
  74. BOOL mIsSelecting;
  75. S32 mSelectionStart;
  76. S32 mSelectionEnd;
  77. }; // end class LLURLLineEditorRollback
  78. };
  79. #endif /* LLURLLINEEDITOR_H_ */