/xbmc/guilib/GUISelectButtonControl.h

http://github.com/xbmc/xbmc · C++ Header · 134 lines · 49 code · 8 blank · 77 comment · 0 complexity · 4e4f5631e2466efebf910f0d011b51ce MD5 · raw file

  1. /*!
  2. \file GUISelectButtonControl.h
  3. \brief
  4. */
  5. #ifndef GUILIB_GUIWINDOWSELECTCONTROL_H
  6. #define GUILIB_GUIWINDOWSELECTCONTROL_H
  7. #pragma once
  8. /*
  9. * Copyright (C) 2005-2013 Team XBMC
  10. * http://xbmc.org
  11. *
  12. * This Program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2, or (at your option)
  15. * any later version.
  16. *
  17. * This Program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with XBMC; see the file COPYING. If not, see
  24. * <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. #include "GUIButtonControl.h"
  28. /*!
  29. \ingroup controls
  30. \brief Button with multi selection choice.
  31. Behaves like a normal button control, but when pressing,
  32. it can show multiple strings. The user can choose one by
  33. moving left or right. \n
  34. \n
  35. Messages the button reactes on: \n
  36. - GUI_MSG_LABEL_ADD \n
  37. Add a label to the control. Use CGUIMessage::SetLabel
  38. to set the label text.
  39. - GUI_MSG_LABEL_RESET \n
  40. Remove all labels from the control.
  41. - GUI_MSG_ITEM_SELECTED \n
  42. After sending this message the CGUIMessage::GetParam1
  43. contains the selected label as an integer.
  44. \note The order of the items depends on the order they have been added to
  45. the control using GUI_MSG_LABEL_ADD.
  46. - GUI_MSG_ITEM_SELECT \n
  47. Send this message with CGUIMessage::SetParam1() set to the label
  48. to be selected. \n
  49. \n
  50. Example entry to define a select button in a window or as reference control: \n
  51. \verbatim
  52. <control>
  53. <description>default select button</description
  54. <type>selectbutton</type>
  55. <id>6</id>
  56. <posX>60</posX>
  57. <posY>192</posY>
  58. <width>130</width>
  59. <height>32</height>
  60. <label>132</label>
  61. <font>font13</font>
  62. <textureFocus>button-focus.png</textureFocus>
  63. <textureNoFocus>button-nofocus.jpg</textureNoFocus>
  64. <texturebg>button-focus.png</texturebg>
  65. <textureLeft>scroll-left.png</textureLeft>
  66. <textureRight>scroll-right.png</textureRight>
  67. <font>font13</font>
  68. <textcolor>ffffffff</textcolor>
  69. <colordiffuse>ffffffff</colordiffuse>
  70. <disabledcolor>60ffffff</disabledcolor>
  71. <onleft>50</onleft>
  72. <onright>50</onright>
  73. <onup>3</onup>
  74. <ondown>7</ondown>
  75. </control>
  76. \endverbatim
  77. \sa CGUIMessage
  78. */
  79. class CGUISelectButtonControl : public CGUIButtonControl
  80. {
  81. public:
  82. CGUISelectButtonControl(int parentID, int controlID,
  83. float posX, float posY,
  84. float width, float height,
  85. const CTextureInfo& buttonFocus, const CTextureInfo& button,
  86. const CLabelInfo& labelInfo,
  87. const CTextureInfo& selectBackground,
  88. const CTextureInfo& selectArrowLeft, const CTextureInfo& selectArrowLeftFocus,
  89. const CTextureInfo& selectArrowRight, const CTextureInfo& selectArrowRightFocus);
  90. virtual ~CGUISelectButtonControl(void);
  91. virtual CGUISelectButtonControl *Clone() const { return new CGUISelectButtonControl(*this); };
  92. virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
  93. virtual void Render();
  94. virtual bool OnAction(const CAction &action) ;
  95. virtual void OnLeft();
  96. virtual void OnRight();
  97. virtual bool OnMessage(CGUIMessage& message);
  98. virtual bool OnMouseOver(const CPoint &point);
  99. virtual void AllocResources();
  100. virtual void FreeResources(bool immediately = false);
  101. virtual void DynamicResourceAlloc(bool bOnOff);
  102. virtual void SetInvalid();
  103. virtual void SetPosition(float posX, float posY);
  104. protected:
  105. virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
  106. virtual bool UpdateColors();
  107. bool m_bShowSelect;
  108. CGUITexture m_imgBackground;
  109. CGUITexture m_imgLeft;
  110. CGUITexture m_imgLeftFocus;
  111. CGUITexture m_imgRight;
  112. CGUITexture m_imgRightFocus;
  113. std::vector<std::string> m_vecItems;
  114. int m_iCurrentItem;
  115. int m_iDefaultItem;
  116. int m_iStartFrame;
  117. bool m_bLeftSelected;
  118. bool m_bRightSelected;
  119. bool m_bMovedLeft;
  120. bool m_bMovedRight;
  121. unsigned int m_ticks;
  122. };
  123. #endif