1693
|
1
|
|
2 unsigned char * mplMenuDrawBuffer = NULL;
|
|
3 int mplMenuRender = 1;
|
|
4 int mplMenuItem = -1;
|
|
5 int mplOldMenuItem = -1;
|
|
6 int mplMenuX,mplMenuY;
|
|
7
|
|
8 void mplHideMenu( int mx,int my );
|
|
9
|
|
10 void mplMenuDraw( wsParamDisplay )
|
|
11 {
|
|
12 unsigned long * buf = NULL;
|
|
13 unsigned long * drw = NULL;
|
|
14 unsigned long x,y,tmp;
|
|
15
|
|
16 if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
3476
|
17 if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return;
|
1693
|
18
|
|
19 if ( mplMenuRender || mplMenuItem != mplOldMenuItem )
|
|
20 {
|
|
21 memcpy( mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Image,appMPlayer.menuBase.Bitmap.ImageSize );
|
|
22 // ---
|
|
23 if ( mplMenuItem != -1 )
|
|
24 {
|
|
25 buf=(unsigned long *)mplMenuDrawBuffer;
|
|
26 drw=(unsigned long *)appMPlayer.menuSelected.Bitmap.Image;
|
|
27 for ( y=appMPlayer.MenuItems[ mplMenuItem ].y; y < appMPlayer.MenuItems[ mplMenuItem ].y + appMPlayer.MenuItems[ mplMenuItem ].height; y++ )
|
|
28 for ( x=appMPlayer.MenuItems[ mplMenuItem ].x; x < appMPlayer.MenuItems[ mplMenuItem ].x + appMPlayer.MenuItems[ mplMenuItem ].width; x++ )
|
|
29 {
|
|
30 tmp=drw[ y * appMPlayer.menuSelected.width + x ];
|
|
31 if ( tmp != 0x00ff00ff ) buf[ y * appMPlayer.menuBase.width + x ]=tmp;
|
|
32 }
|
|
33 }
|
|
34 mplOldMenuItem=mplMenuItem;
|
|
35 // ---
|
|
36 wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.ImageSize );
|
|
37 mplMenuRender=0;
|
|
38 }
|
|
39 wsPutImage( &appMPlayer.menuWindow );
|
|
40 }
|
|
41
|
|
42 void mplMenuMouseHandle( int X,int Y,int RX,int RY )
|
|
43 {
|
|
44 int x,y,i;
|
|
45
|
|
46 if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
|
47
|
|
48 mplMenuItem=-1;
|
|
49 x=RX - appMPlayer.menuWindow.X;
|
|
50 y=RY - appMPlayer.menuWindow.Y;
|
|
51 if ( ( x < 0 ) || ( y < 0 ) || ( x > appMPlayer.menuBase.width ) || ( y > appMPlayer.menuBase.height ) )
|
|
52 {
|
|
53 wsPostRedisplay( &appMPlayer.menuWindow );
|
|
54 return;
|
|
55 }
|
|
56
|
1823
|
57 for( i=0;i<=appMPlayer.NumberOfMenuItems;i++ )
|
1693
|
58 {
|
|
59 if ( wgIsRect( x,y,
|
|
60 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
|
1823
|
61 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) { mplMenuItem=i; break; }
|
1693
|
62 }
|
|
63 wsPostRedisplay( &appMPlayer.menuWindow );
|
|
64 }
|
|
65
|
|
66 void mplShowMenu( int mx,int my )
|
|
67 {
|
|
68 int x,y;
|
|
69
|
|
70 if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
|
71
|
|
72 x=mx;
|
|
73 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1;
|
|
74 y=my;
|
|
75 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1;
|
|
76
|
|
77 mplMenuX=x; mplMenuY=y;
|
|
78
|
|
79 mplMenuItem = 0;
|
|
80
|
2854
|
81 wsMoveWindow( &appMPlayer.menuWindow,False,x,y );
|
3476
|
82 wsMoveTopWindow( &appMPlayer.menuWindow );
|
|
83 mplMenuRender=1;
|
1693
|
84 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow );
|
3476
|
85 wsPostRedisplay( &appMPlayer.menuWindow );
|
1693
|
86 }
|
|
87
|
|
88 void mplHideMenu( int mx,int my )
|
|
89 {
|
|
90 int x,y,i=mplMenuItem;
|
|
91
|
|
92 if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
|
93
|
|
94 x=mx-mplMenuX;
|
|
95 y=my-mplMenuY;
|
1823
|
96 // x=RX - appMPlayer.menuWindow.X;
|
|
97 // y=RY - appMPlayer.menuWindow.Y;
|
1693
|
98
|
|
99 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow );
|
|
100
|
|
101 if ( ( x < 0 ) || ( y < 0 ) ) return;
|
|
102
|
3476
|
103 // printf( "---------> %d %d,%d\n",i,x,y );
|
|
104 // printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].height );
|
1693
|
105 if ( wgIsRect( x,y,
|
|
106 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
|
|
107 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,
|
|
108 appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) )
|
|
109 {
|
|
110 mplMsgHandle( appMPlayer.MenuItems[i].msg,0 );
|
|
111 }
|
|
112 }
|
|
113
|
|
114 void mplMenuInit( void )
|
|
115 {
|
|
116
|
|
117 if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
|
118
|
|
119 appMPlayer.menuBase.x=0;
|
|
120 appMPlayer.menuBase.y=0;
|
|
121
|
|
122 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
|
|
123 {
|
|
124 #ifdef DEBUG
|
1884
|
125 dbprintf( 1,MSGTR_NEMFMR );
|
1693
|
126 #endif
|
1907
|
127 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR );
|
1693
|
128 return;
|
|
129 }
|
|
130
|
|
131 wsCreateWindow( &appMPlayer.menuWindow,
|
|
132 appMPlayer.menuBase.x,appMPlayer.menuBase.y,appMPlayer.menuBase.width,appMPlayer.menuBase.height,
|
|
133 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" );
|
|
134
|
|
135 #ifdef DEBUG
|
|
136 dbprintf( 1,"[menu.h] menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID );
|
|
137 #endif
|
|
138
|
|
139 appMPlayer.menuWindow.ReDraw=mplMenuDraw;
|
|
140 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle;
|
|
141 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle;
|
3476
|
142 mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow );
|
1693
|
143 }
|