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