1 /*****************************************************************************
2 * image.cpp: Image control
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: image.cpp,v 1.5 2003/04/16 21:40:07 ipkiss Exp $
7 * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
8 * Emmanuel Puig <karibu@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., 59 Temple Place - Suite 330, Boston, MA 02111,
24 *****************************************************************************/
27 //--- VLC -------------------------------------------------------------------
30 //--- SKIN ------------------------------------------------------------------
31 #include "../src/bitmap.h"
32 #include "../src/banks.h"
35 #include "../src/event.h"
36 #include "../src/theme.h"
37 #include "../src/window.h"
38 #include "../src/skin_common.h"
42 //---------------------------------------------------------------------------
44 //---------------------------------------------------------------------------
45 ControlImage::ControlImage( string id, bool visible, int x, int y, string img,
46 string event, string help, Window *Parent )
47 : GenericControl( id, visible, help, Parent )
51 MouseDownActionName = event;
55 //---------------------------------------------------------------------------
56 ControlImage::~ControlImage()
59 //---------------------------------------------------------------------------
60 void ControlImage::Init()
62 Img = new (Bitmap*)[1];
63 Img[0] = p_intf->p_sys->p_theme->BmpBank->Get( Bg );
64 Img[0]->GetSize( Width, Height );
67 MouseDownAction = new Action( p_intf, MouseDownActionName );
70 //---------------------------------------------------------------------------
71 bool ControlImage::ProcessEvent( Event *evt )
74 switch( evt->GetMessage() )
77 Enable( (Event*)evt->GetParam1(), (bool)evt->GetParam2() );
82 //---------------------------------------------------------------------------
83 void ControlImage::Draw( int x, int y, int w, int h, Graphics *dest )
89 if( GetIntersectRgn(x, y, w, h, Left, Top, Width, Height, xI, yI, wI, hI ) )
90 Img[0]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
93 //---------------------------------------------------------------------------
94 bool ControlImage::MouseDown( int x, int y, int button )
96 if( !Enabled || !Img[0]->Hit( x - Left, y - Top ) || button != 1 ||
97 !MouseDownAction->SendEvent() )
102 //---------------------------------------------------------------------------
103 bool ControlImage::MouseOver( int x, int y )
105 if( Img[0]->Hit( x - Left, y - Top ) )
110 //---------------------------------------------------------------------------
111 void ControlImage::Enable( Event *event, bool enabled )
113 if( !MouseDownAction->MatchEvent( event, ACTION_MATCH_ONE ) )
116 if( enabled != !Enabled )
119 ParentWindow->Refresh( Left, Top, Width, Height );
123 //---------------------------------------------------------------------------