]> git.sesse.net Git - vlc/blob - modules/gui/skins/controls/generic.h
* changed Region into SkinRegion to prepare the X11 port
[vlc] / modules / gui / skins / controls / generic.h
1 /*****************************************************************************
2  * generic.h: Generic control, parent of the others
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: generic.h,v 1.4 2003/04/28 12:25:34 asmax Exp $
6  *
7  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
8  *          Emmanuel Puig    <karibu@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,
23  * USA.
24  *****************************************************************************/
25
26
27 #ifndef VLC_SKIN_CONTROL_GENERIC
28 #define VLC_SKIN_CONTROL_GENERIC
29
30 //--- GENERAL ---------------------------------------------------------------
31 #include <string>
32 using namespace std;
33
34 //---------------------------------------------------------------------------
35 struct intf_thread_t;
36 class SkinWindow;
37 class Bitmap;
38 class Graphics;
39 class SkinRegion;
40 class Event;
41
42 //---------------------------------------------------------------------------
43 // Generic control class
44 //---------------------------------------------------------------------------
45 class GenericControl               // This is the generic control class
46 {
47     protected:
48         SkinWindow * ParentWindow;
49         bool     Visible;
50         string   ID;
51         string   Help;
52         intf_thread_t *p_intf;
53
54     private:
55     public:
56         // Constructor
57         GenericControl( string id, bool visible, string help, SkinWindow *Parent );
58
59         // Destructor
60         virtual ~GenericControl();
61
62         // initializations
63         virtual void Init();
64         bool GenericProcessEvent( Event *evt );
65         virtual bool ProcessEvent( Event *evt );
66
67         // Draw the control into the destination DC
68         virtual void Draw( int x, int y, int w, int h, Graphics *dest ) = 0;
69
70         // Simulate a mouse action on control at coordinates x/y
71         virtual bool MouseUp( int x, int y, int button );
72         virtual bool MouseDown( int x, int y, int button );
73         virtual bool MouseMove( int x, int y, int button );
74         virtual bool MouseOver( int x, int y );
75         virtual bool MouseDblClick( int x, int y, int button );
76         virtual bool MouseScroll( int x, int y, int direction );
77         virtual bool ToolTipTest( int x, int y );
78         virtual bool SendNewHelpText();
79
80         // Move control
81         void Move( int left, int top );
82         virtual void MoveRelative( int xOff, int yOff );
83
84         // Get two rectangle regions and return intersection
85         bool GetIntersectRgn( int x1, int y1, int w1, int h1, int x2,
86             int y2, int w2, int h2, int &x, int &y, int &w, int &h );
87
88         // Create a region from a bitmap with transcolor as empty region
89         SkinRegion *CreateRegionFromBmp( Bitmap *bmp, int MoveX, int MoveY );
90         int Left;               // Left offset of the control
91         int Top;                // Top offset of the control
92         int Width;              // Width of the control
93         int Height;             // Height of the control
94         int State;              // Used to special state of the control
95                                 // (for button, sets whether down or up)
96         Bitmap **Img;           // Array of bitmap used to draw control
97
98         // Enabling control
99         virtual void Enable( Event *event, bool enabled );
100
101         // Found if ID matches
102         bool IsID( string id );
103 };
104 //---------------------------------------------------------------------------
105
106
107 #endif