aboutsummaryrefslogtreecommitdiff
path: root/guilib/GUISelectButtonControl.h
blob: 519b0af26560c93a7e3c169eb00512ea0de74655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*!
\file GUISelectButtonControl.h
\brief
*/

#ifndef GUILIB_GUIWINDOWSELECTCONTROL_H
#define GUILIB_GUIWINDOWSELECTCONTROL_H

#pragma once

/*
 *      Copyright (C) 2005-2008 Team XBMC
 *      http://www.xbmc.org
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with XBMC; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */

#include "GUIButtonControl.h"

/*!
 \ingroup controls
 \brief Button with multi selection choice.

 Behaves like a normal button control, but when pressing,
 it can show multiple strings. The user can choose one by
 moving left or right. \n
 \n
 Messages the button reactes on: \n

 - GUI_MSG_LABEL_ADD \n
 Add a label to the control. Use CGUIMessage::SetLabel
 to set the label text.
 - GUI_MSG_LABEL_RESET \n
 Remove all labels from the control.
 - GUI_MSG_ITEM_SELECTED \n
 After sending this message the CGUIMessage::GetParam1
 contains the selected label as an integer.
 \note The order of the items depends on the order they have been added to
 the control using GUI_MSG_LABEL_ADD.
 - GUI_MSG_ITEM_SELECT \n
 Send this message with CGUIMessage::SetParam1() set to the label
 to be selected. \n
 \n
 Example entry to define a select button in a window or as reference control: \n
 \verbatim
    <control>
      <description>default select button</description
      <type>selectbutton</type>
      <id>6</id>
      <posX>60</posX>
      <posY>192</posY>
      <width>130</width>
      <height>32</height>
      <label>132</label>
      <font>font13</font>
      <textureFocus>button-focus.png</textureFocus>
      <textureNoFocus>button-nofocus.jpg</textureNoFocus>
      <texturebg>button-focus.png</texturebg>
      <textureLeft>scroll-left.png</textureLeft>
      <textureRight>scroll-right.png</textureRight>
      <font>font13</font>
      <textcolor>ffffffff</textcolor>
      <colordiffuse>ffffffff</colordiffuse>
      <disabledcolor>60ffffff</disabledcolor>
      <onleft>50</onleft>
      <onright>50</onright>
      <onup>3</onup>
      <ondown>7</ondown>
    </control>
  \endverbatim

 \sa CGUIMessage
 */
class CGUISelectButtonControl : public CGUIButtonControl
{
public:
  CGUISelectButtonControl(int parentID, int controlID,
                          float posX, float posY,
                          float width, float height,
                          const CTextureInfo& buttonFocus, const CTextureInfo& button,
                          const CLabelInfo& labelInfo,
                          const CTextureInfo& selectBackground,
                          const CTextureInfo& selectArrowLeft, const CTextureInfo& selectArrowLeftFocus,
                          const CTextureInfo& selectArrowRight, const CTextureInfo& selectArrowRightFocus);
  virtual ~CGUISelectButtonControl(void);
  virtual CGUISelectButtonControl *Clone() const { return new CGUISelectButtonControl(*this); };

  virtual void Render();
  virtual bool OnAction(const CAction &action) ;
  virtual void OnLeft();
  virtual void OnRight();
  virtual bool OnMessage(CGUIMessage& message);
  virtual bool OnMouseOver(const CPoint &point);

  virtual void AllocResources();
  virtual void FreeResources(bool immediately = false);
  virtual void DynamicResourceAlloc(bool bOnOff);
  virtual void SetInvalid();
  virtual void SetPosition(float posX, float posY);

protected:
  virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
  virtual void UpdateColors();
  bool m_bShowSelect;
  CGUITexture m_imgBackground;
  CGUITexture m_imgLeft;
  CGUITexture m_imgLeftFocus;
  CGUITexture m_imgRight;
  CGUITexture m_imgRightFocus;
  std::vector<std::string> m_vecItems;
  int m_iCurrentItem;
  int m_iDefaultItem;
  int m_iStartFrame;
  bool m_bLeftSelected;
  bool m_bRightSelected;
  bool m_bMovedLeft;
  bool m_bMovedRight;
  unsigned int m_ticks;
};
#endif