]> git.sesse.net Git - vlc/blob - modules/gui/skins2/controls/ctrl_list.hpp
d2b6b5996252ca09d98874ed089343a291313f53
[vlc] / modules / gui / skins2 / controls / ctrl_list.hpp
1 /*****************************************************************************
2  * ctrl_list.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifndef CTRL_LIST_HPP
26 #define CTRL_LIST_HPP
27
28 #include "ctrl_generic.hpp"
29 #include "../utils/observer.hpp"
30 #include "../utils/var_list.hpp"
31
32 class OSGraphics;
33 class GenericFont;
34
35
36 /// Class for control list
37 class CtrlList: public CtrlGeneric, public Observer<VarList>,
38     public Observer<VarPercent>
39 {
40     public:
41         CtrlList( intf_thread_t *pIntf, VarList &rList, GenericFont &rFont,
42                   uint32_t fgcolor, uint32_t playcolor, uint32_t bgcolor1,
43                   uint32_t bgcolor2, uint32_t selColor,
44                   const UString &rHelp, VarBool *pVisible );
45         virtual ~CtrlList();
46
47         /// Handle an event on the control.
48         virtual void handleEvent( EvtGeneric &rEvent );
49
50         /// Check whether coordinates are inside the control.
51         virtual bool mouseOver( int x, int y ) const;
52
53         /// Draw the control on the given graphics
54         virtual void draw( OSGraphics &rImage, int xDest, int yDest );
55
56         /// Called when the layout is resized
57         virtual void onResize();
58
59         /// Return true if the control can gain the focus
60         virtual bool isFocusable() const { return true; }
61
62         /// Get the type of control (custom RTTI)
63         virtual string getType() const { return "list"; }
64
65     private:
66         /// List associated to the control
67         VarList &m_rList;
68         /// Font
69         GenericFont &m_rFont;
70         /// Color of normal text
71         uint32_t m_fgColor;
72         /// Color of the playing item
73         uint32_t m_playColor;
74         /// Background colors
75         uint32_t m_bgColor1, m_bgColor2;
76         /// Background of selected items
77         uint32_t m_selColor;
78         /// Pointer on the last selected item in the list
79         VarList::Elem_t *m_pLastSelected;
80         /// Image of the control
81         OSGraphics *m_pImage;
82         /// Last position
83         int m_lastPos;
84
85         /// Method called when the list variable is modified
86         virtual void onUpdate( Subject<VarList> &rList );
87
88         /// Method called when the position variable of the list is modified
89         virtual void onUpdate( Subject<VarPercent> &rPercent );
90
91         /// Called when the position is set
92         virtual void onPositionChange();
93
94         /// Check if the list must be scrolled
95         void autoScroll();
96
97         /// Draw the image of the control
98         void makeImage();
99 };
100
101 #endif