PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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