PageRenderTime 158ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llsearcheditor.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 96 lines | 47 code | 14 blank | 35 comment | 1 complexity | 1e2ee0a47a2052498bea8ad8541a9ecc MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llsearcheditor.h
  3. * @brief Text editor widget that represents a search operation
  4. *
  5. * Features:
  6. * Text entry of a single line (text, delete, left and right arrow, insert, return).
  7. * Callbacks either on every keystroke or just on the return key.
  8. * Focus (allow multiple text entry widgets)
  9. * Clipboard (cut, copy, and paste)
  10. * Horizontal scrolling to allow strings longer than widget size allows
  11. * Pre-validation (limit which keys can be used)
  12. * Optional line history so previous entries can be recalled by CTRL UP/DOWN
  13. *
  14. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  15. * Second Life Viewer Source Code
  16. * Copyright (C) 2010, Linden Research, Inc.
  17. *
  18. * This library is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU Lesser General Public
  20. * License as published by the Free Software Foundation;
  21. * version 2.1 of the License only.
  22. *
  23. * This library is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. * Lesser General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU Lesser General Public
  29. * License along with this library; if not, write to the Free Software
  30. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  31. *
  32. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  33. * $/LicenseInfo$
  34. */
  35. #ifndef LL_SEARCHEDITOR_H
  36. #define LL_SEARCHEDITOR_H
  37. #include "lllineeditor.h"
  38. #include "llbutton.h"
  39. class LLSearchEditor : public LLUICtrl
  40. {
  41. public:
  42. struct Params : public LLInitParam::Block<Params, LLLineEditor::Params>
  43. {
  44. Optional<LLButton::Params> search_button,
  45. clear_button;
  46. Optional<bool> search_button_visible,
  47. clear_button_visible;
  48. Optional<commit_callback_t> keystroke_callback;
  49. Params()
  50. : search_button("search_button"),
  51. search_button_visible("search_button_visible"),
  52. clear_button("clear_button"),
  53. clear_button_visible("clear_button_visible")
  54. {}
  55. };
  56. void setCommitOnFocusLost(BOOL b) { if (mSearchEditor) mSearchEditor->setCommitOnFocusLost(b); }
  57. protected:
  58. LLSearchEditor(const Params&);
  59. friend class LLUICtrlFactory;
  60. public:
  61. virtual ~LLSearchEditor() {}
  62. /*virtual*/ void draw();
  63. void setText(const LLStringExplicit &new_text) { mSearchEditor->setText(new_text); }
  64. const std::string& getText() const { return mSearchEditor->getText(); }
  65. // LLUICtrl interface
  66. virtual void setValue(const LLSD& value );
  67. virtual LLSD getValue() const;
  68. virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text );
  69. virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
  70. virtual void setLabel( const LLStringExplicit &new_label );
  71. virtual void clear();
  72. virtual void setFocus( BOOL b );
  73. void setKeystrokeCallback( commit_callback_t cb ) { mKeystrokeCallback = cb; }
  74. protected:
  75. void onClearButtonClick(const LLSD& data);
  76. virtual void handleKeystroke();
  77. commit_callback_t mKeystrokeCallback;
  78. LLLineEditor* mSearchEditor;
  79. LLButton* mSearchButton;
  80. LLButton* mClearButton;
  81. };
  82. #endif // LL_SEARCHEDITOR_H