PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llsplitbutton.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 106 lines | 54 code | 23 blank | 29 comment | 0 complexity | 969eed03e1709e58cd01973b307dff07 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llsplitbutton.h
  3. * @brief LLSplitButton base class
  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. // A control that displays the name of the chosen item, which when clicked
  27. // shows a scrolling box of choices.
  28. #include "llbutton.h"
  29. #include "llpanel.h"
  30. #include "lluictrl.h"
  31. #ifndef LL_LLSPLITBUTTON_H
  32. #define LL_LLSPLITBUTTON_H
  33. class LLSplitButton
  34. : public LLUICtrl
  35. {
  36. public:
  37. typedef enum e_arrow_position
  38. {
  39. LEFT,
  40. RIGHT
  41. } EArrowPosition;
  42. struct ArrowPositionValues : public LLInitParam::TypeValuesHelper<EArrowPosition, ArrowPositionValues>
  43. {
  44. static void declareValues();
  45. };
  46. struct ItemParams : public LLInitParam::Block<ItemParams, LLButton::Params>
  47. {
  48. ItemParams();
  49. };
  50. struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
  51. {
  52. Optional<EArrowPosition, ArrowPositionValues> arrow_position;
  53. Optional<LLButton::Params> arrow_button;
  54. Optional<LLPanel::Params> items_panel;
  55. Multiple<ItemParams> items;
  56. Params();
  57. };
  58. virtual ~LLSplitButton() {};
  59. //Overridden
  60. virtual void onFocusLost();
  61. virtual void setFocus(BOOL b);
  62. virtual void setEnabled(BOOL enabled);
  63. //Callbacks
  64. void onArrowBtnDown();
  65. void onHeldDownShownButton();
  66. void onItemSelected(LLUICtrl* ctrl);
  67. void setSelectionCallback(commit_callback_t cb) { mSelectionCallback = cb; }
  68. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  69. virtual void showButtons();
  70. virtual void hideButtons();
  71. protected:
  72. friend class LLUICtrlFactory;
  73. LLSplitButton(const LLSplitButton::Params& p);
  74. LLButton* prepareItemButton(LLButton::Params params);
  75. LLPanel* prepareItemsPanel(LLPanel::Params params, S32 items_count);
  76. LLPanel* mItemsPanel;
  77. std::list<LLButton*> mHidenItems;
  78. LLButton* mArrowBtn;
  79. LLButton* mShownItem;
  80. EArrowPosition mArrowPosition;
  81. commit_callback_t mSelectionCallback;
  82. };
  83. #endif