1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
28 #include "ctrl_generic.hpp"
29 #include "../utils/observer.hpp"
30 #include "../utils/var_list.hpp"
37 /// Class for control list
38 class CtrlList: public CtrlGeneric, public Observer<VarList, void*>,
39 public Observer<VarPercent, void *>
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 );
49 /// Handle an event on the control.
50 virtual void handleEvent( EvtGeneric &rEvent );
52 /// Check whether coordinates are inside the control.
53 virtual bool mouseOver( int x, int y ) const;
55 /// Draw the control on the given graphics
56 virtual void draw( OSGraphics &rImage, int xDest, int yDest );
58 /// Called when the layout is resized
59 virtual void onResize();
61 /// Return true if the control can gain the focus
62 virtual bool isFocusable() const { return true; }
64 /// Get the type of control (custom RTTI)
65 virtual string getType() const { return "list"; }
68 /// List associated to the control
71 const GenericFont &m_rFont;
73 /** If NULL, the 2 background colors defined below will be used */
74 const GenericBitmap *m_pBitmap;
75 /// Color of normal text
77 /// Color of the playing item
79 /// Background colors, used when no background bitmap is given
80 uint32_t m_bgColor1, m_bgColor2;
81 /// Background of selected items
83 /// Pointer on the last selected item in the list
84 VarList::Elem_t *m_pLastSelected;
85 /// Image of the control
90 /// Method called when the list variable is modified
91 virtual void onUpdate( Subject<VarList, void*> &rList, void* );
93 /// Method called when the position variable of the list is modified
94 virtual void onUpdate( Subject<VarPercent, void*> &rPercent, void* );
96 /// Called when the position is set
97 virtual void onPositionChange();
99 /// Check if the list must be scrolled
102 /// Draw the image of the control