]> git.sesse.net Git - vlc/blob - modules/gui/skins2/controls/ctrl_list.hpp
skins2: improve refresh of layouts
[vlc] / modules / gui / skins2 / controls / ctrl_list.hpp
1 /*****************************************************************************
2  * ctrl_list.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
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 along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 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 class GenericBitmap;
35
36
37 /// Class for control list
38 class CtrlList: public CtrlGeneric, public Observer<VarList>,
39     public Observer<VarPercent>
40 {
41 public:
42     CtrlList( intf_thread_t *pIntf, VarList &rList,
43               const GenericFont &rFont, const GenericBitmap *pBitmap,
44               uint32_t fgcolor, uint32_t playcolor, uint32_t bgcolor1,
45               uint32_t bgcolor2, uint32_t selColor,
46               const UString &rHelp, VarBool *pVisible );
47     virtual ~CtrlList();
48
49     /// Handle an event on the control.
50     virtual void handleEvent( EvtGeneric &rEvent );
51
52     /// Check whether coordinates are inside the control.
53     virtual bool mouseOver( int x, int y ) const;
54
55     /// Draw the control on the given graphics
56     virtual void draw( OSGraphics &rImage, int xDest, int yDest, int w, int h );
57
58     /// Called when the layout is resized
59     virtual void onResize();
60
61     /// Return true if the control can gain the focus
62     virtual bool isFocusable() const { return true; }
63
64     /// Get the type of control (custom RTTI)
65     virtual string getType() const { return "list"; }
66
67 private:
68     /// List associated to the control
69     VarList &m_rList;
70     /// Font
71     const GenericFont &m_rFont;
72     /// Background bitmap
73     /** If NULL, the 2 background colors defined below will be used */
74     const GenericBitmap *m_pBitmap;
75     /// Color of normal text
76     uint32_t m_fgColor;
77     /// Color of the playing item
78     uint32_t m_playColor;
79     /// Background colors, used when no background bitmap is given
80     uint32_t m_bgColor1, m_bgColor2;
81     /// Background of selected items
82     uint32_t m_selColor;
83     /// Pointer on the last selected item in the list
84     VarList::Elem_t *m_pLastSelected;
85     /// Image of the control
86     OSGraphics *m_pImage;
87     /// Last position
88     int m_lastPos;
89
90     /// Method called when the list variable is modified
91     virtual void onUpdate( Subject<VarList> &rList, void* );
92
93     /// Method called when the position variable of the list is modified
94     virtual void onUpdate( Subject<VarPercent> &rPercent, void*  );
95
96     /// Called when the position is set
97     virtual void onPositionChange();
98
99     /// Check if the list must be scrolled
100     void autoScroll();
101
102     /// Draw the image of the control
103     void makeImage();
104 };
105
106 #endif