Commit 0d15ca7b authored by Cyril Deguet's avatar Cyril Deguet

* raise the skin window on top when clicked

* a bit of code cleaning
parent c8e01ad8
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* playlist.cpp: Playlist control * playlist.cpp: Playlist control
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: playlist.cpp,v 1.6 2003/04/21 00:18:37 asmax Exp $ * $Id: playlist.cpp,v 1.7 2003/04/21 14:26:59 asmax Exp $
* *
* Authors: Olivier Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -465,9 +465,7 @@ bool ControlPlayList::MouseScroll( int x, int y, int direction ) ...@@ -465,9 +465,7 @@ bool ControlPlayList::MouseScroll( int x, int y, int direction )
if( !TextClipRgn->Hit( x - Left, y - Top ) && !Slider->MouseOver( x, y ) ) if( !TextClipRgn->Hit( x - Left, y - Top ) && !Slider->MouseOver( x, y ) )
return false; return false;
//long pos = Slider->GetCursorPosition();
long pos = StartIndex; long pos = StartIndex;
fprintf(stderr," scroll %d %d\n", pos, StartIndex);
switch( direction ) switch( direction )
{ {
case MOUSE_SCROLL_UP: case MOUSE_SCROLL_UP:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class * gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.cpp,v 1.14 2003/04/17 17:45:38 asmax Exp $ * $Id: gtk2_bitmap.cpp,v 1.15 2003/04/21 14:26:59 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -47,73 +47,22 @@ ...@@ -47,73 +47,22 @@
GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor ) GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
: Bitmap( p_intf, FileName, AColor ) : Bitmap( p_intf, FileName, AColor )
{ {
/* HBITMAP HBitmap;
HBITMAP HBuf;
BITMAP Bmp;
HDC bufDC;
// Create image from file if it exists
HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE );
if( HBitmap == NULL )
{
if( FileName != "" )
msg_Warn( p_intf, "Couldn't load bitmap: %s", FileName.c_str() );
HBitmap = CreateBitmap( 0, 0, 1, 32, NULL );
}
// Create device context
bmpDC = CreateCompatibleDC( NULL );
SelectObject( bmpDC, HBitmap );
// Get size of image
GetObject( HBitmap, sizeof( Bmp ), &Bmp );
Width = Bmp.bmWidth;
Height = Bmp.bmHeight;
// If alpha color is not 0, then change 0 colors to non black color to avoid
// window transparency
if( (int)AlphaColor != OSAPI_GetNonTransparentColor( 0 ) )
{
bufDC = CreateCompatibleDC( bmpDC );
HBuf = CreateCompatibleBitmap( bmpDC, Width, Height );
SelectObject( bufDC, HBuf );
LPRECT r = new RECT;
HBRUSH Brush = CreateSolidBrush( OSAPI_GetNonTransparentColor( 0 ) );
r->left = 0;
r->top = 0;
r->right = Width;
r->bottom = Height;
FillRect( bufDC, r, Brush );
DeleteObject( Brush );
delete r;
TransparentBlt( bufDC, 0, 0, Width, Height, bmpDC, 0, 0, Width, Height, 0 );
BitBlt( bmpDC, 0, 0, Width, Height, bufDC, 0, 0, SRCCOPY );
DeleteDC( bufDC );
DeleteObject( HBuf );
}
// Delete objects
DeleteObject( HBitmap );*/
// Load the bitmap image // Load the bitmap image
Bmp = gdk_pixbuf_new_from_file( FileName.c_str(), NULL ); Bmp = gdk_pixbuf_new_from_file( FileName.c_str(), NULL );
if( Bmp == NULL ) if( Bmp == NULL )
{ {
if( FileName != "" ) if( FileName != "" )
msg_Warn( p_intf, "Couldn't load bitmap: %s", FileName.c_str() ); msg_Warn( p_intf, "Couldn't load bitmap: %s", FileName.c_str() );
Width = 0;
// Bmp = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); Height = 0;
Bmp = NULL;
} }
else
{
Bmp = gdk_pixbuf_add_alpha( Bmp, TRUE, AColor & 0xff, (AColor>>8) & 0xff, Bmp = gdk_pixbuf_add_alpha( Bmp, TRUE, AColor & 0xff, (AColor>>8) & 0xff,
(AColor>>16) & 0xff ); (AColor>>16) & 0xff );
Width = gdk_pixbuf_get_width( Bmp ); Width = gdk_pixbuf_get_width( Bmp );
Height = gdk_pixbuf_get_height( Bmp ); Height = gdk_pixbuf_get_height( Bmp );
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, Graphics *from, int x, int y, GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, Graphics *from, int x, int y,
...@@ -154,17 +103,21 @@ GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, Bitmap *c ) ...@@ -154,17 +103,21 @@ GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, Bitmap *c )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
GTK2Bitmap::~GTK2Bitmap() GTK2Bitmap::~GTK2Bitmap()
{ {
/* DeleteDC( bmpDC );*/ if( Bmp )
g_object_unref( G_OBJECT( Bmp) );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef, void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest ) Graphics *dest )
{ {
if( Bmp )
{
GdkDrawable *destImg = ( (GTK2Graphics *)dest )->GetImage(); GdkDrawable *destImg = ( (GTK2Graphics *)dest )->GetImage();
GdkGC *destGC = ( (GTK2Graphics *)dest )->GetGC(); GdkGC *destGC = ( (GTK2Graphics *)dest )->GetGC();
gdk_pixbuf_render_to_drawable( Bmp, destImg, destGC, x, y, xRef, yRef, gdk_pixbuf_render_to_drawable( Bmp, destImg, destGC, x, y, xRef, yRef,
w, h, GDK_RGB_DITHER_NORMAL, 0, 0); w, h, GDK_RGB_DITHER_NORMAL, 0, 0);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool GTK2Bitmap::Hit( int x, int y) bool GTK2Bitmap::Hit( int x, int y)
...@@ -179,7 +132,7 @@ bool GTK2Bitmap::Hit( int x, int y) ...@@ -179,7 +132,7 @@ bool GTK2Bitmap::Hit( int x, int y)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int GTK2Bitmap::GetBmpPixel( int x, int y ) int GTK2Bitmap::GetBmpPixel( int x, int y )
{ {
if( x < 0 || x >= Width || y < 0 || y >= Height ) if( !Bmp || x < 0 || x >= Width || y < 0 || y >= Height )
return -1; return -1;
guchar *pixels; guchar *pixels;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_run.cpp: * gtk2_run.cpp:
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_run.cpp,v 1.18 2003/04/21 03:37:40 asmax Exp $ * $Id: gtk2_run.cpp,v 1.19 2003/04/21 14:26:59 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -150,7 +150,6 @@ void GTK2Proc( GdkEvent *event, gpointer data ) ...@@ -150,7 +150,6 @@ void GTK2Proc( GdkEvent *event, gpointer data )
{ {
if( !proc->EventProc( evt ) ) if( !proc->EventProc( evt ) )
{ {
fprintf( stderr, "Quit\n" );
wxExit(); wxExit();
return; // Exit VLC ! return; // Exit VLC !
} }
...@@ -258,11 +257,6 @@ void OSRun( intf_thread_t *p_intf ) ...@@ -258,11 +257,6 @@ void OSRun( intf_thread_t *p_intf )
wxTheApp = new Instance( p_intf, callbackobj ); wxTheApp = new Instance( p_intf, callbackobj );
/* vlc_mutex_lock( &p_intf->p_sys->init_lock );
vlc_cond_wait( &p_intf->p_sys->init_cond, &p_intf->p_sys->init_lock );
vlc_mutex_unlock( &p_intf->p_sys->init_lock );*/
wxEntry( 1, p_args ); wxEntry( 1, p_args );
delete callbackobj; delete callbackobj;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_theme.cpp: GTK2 implementation of the Theme class * gtk2_theme.cpp: GTK2 implementation of the Theme class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_theme.cpp,v 1.21 2003/04/21 02:12:06 ipkiss Exp $ * $Id: gtk2_theme.cpp,v 1.22 2003/04/21 14:26:59 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -53,40 +53,8 @@ void SkinManage( intf_thread_t *p_intf ); ...@@ -53,40 +53,8 @@ void SkinManage( intf_thread_t *p_intf );
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
GTK2Theme::GTK2Theme( intf_thread_t *_p_intf ) : Theme( _p_intf ) GTK2Theme::GTK2Theme( intf_thread_t *_p_intf ) : Theme( _p_intf )
{ {
/*
// Get instance handle
hinst = GetModuleHandle( NULL );
// Create window class
WNDCLASS SkinWindow;
SkinWindow.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
SkinWindow.lpfnWndProc = (WNDPROC) GTK2Proc;
SkinWindow.lpszClassName = "SkinWindow";
SkinWindow.lpszMenuName = NULL;
SkinWindow.cbClsExtra = 0;
SkinWindow.cbWndExtra = 0;
SkinWindow.hbrBackground = HBRUSH (COLOR_WINDOW);
SkinWindow.hCursor = LoadCursor( NULL , IDC_ARROW );
SkinWindow.hIcon = LoadIcon( hinst, "VLC_ICON" );
SkinWindow.hInstance = hinst;
if( !RegisterClass( &SkinWindow ) )
{
WNDCLASS wndclass;
// Check why it failed. If it's because the class already exists
// then fine, otherwise return with an error.
if( !GetClassInfo( hinst, "SkinWindow", &wndclass ) )
{
msg_Err( p_intf, "Cannot register window class" );
return;
}
}
*/
//Initialize value //Initialize value
ParentWindow = NULL; ParentWindow = NULL;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -108,73 +76,17 @@ GTK2Theme::~GTK2Theme() ...@@ -108,73 +76,17 @@ GTK2Theme::~GTK2Theme()
{ {
Shell_NotifyIcon( NIM_DELETE, &TrayIcon ); Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
} }
*/
// Destroy parent window // Destroy parent window
if( ParentWindow ) if( ParentWindow )
{ {
DestroyWindow( ParentWindow ); gdk_window_destroy( ParentWindow );
}*/ }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Theme::OnLoadTheme() void GTK2Theme::OnLoadTheme()
{/* {
// Create window class /* // The create menu
WNDCLASS ParentClass;
ParentClass.style = CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS;
ParentClass.lpfnWndProc = (WNDPROC) GTK2Proc;
ParentClass.lpszClassName = "ParentWindow";
ParentClass.lpszMenuName = NULL;
ParentClass.cbClsExtra = 0;
ParentClass.cbWndExtra = 0;
ParentClass.hbrBackground = HBRUSH (COLOR_WINDOW);
ParentClass.hCursor = LoadCursor( NULL , IDC_ARROW );
ParentClass.hIcon = LoadIcon( hinst, "VLC_ICON" );
ParentClass.hInstance = hinst;
// register class and check it
if( !RegisterClass( &ParentClass ) )
{
WNDCLASS wndclass;
// Check why it failed. If it's because the class already exists
// then fine, otherwise return with an error.
if( !GetClassInfo( hinst, "ParentWindow", &wndclass ) )
{
msg_Err( p_intf, "Cannot register window class" );
return;
}
}
// Create Window
ParentWindow = CreateWindowEx( WS_EX_LAYERED|WS_EX_TOOLWINDOW,
"ParentWindow", "VLC Media Player",
WS_SYSMENU,
0, 0, 0, 0, 0, 0, hinst, NULL );
// Store with it a pointer to the interface thread
SetWindowLongPtr( ParentWindow, GWLP_USERDATA, (LONG_PTR)p_intf );
ShowWindow( ParentWindow, SW_SHOW );
// System tray icon
TrayIcon.cbSize = sizeof( PNOTIFYICONDATA );
TrayIcon.hWnd = ParentWindow;
TrayIcon.uID = 42;
TrayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE;
TrayIcon.uCallbackMessage = WM_RBUTTONDOWN;
TrayIcon.hIcon = LoadIcon( hinst, "VLC_ICON" );
strcpy( TrayIcon.szTip, "VLC Media Player" );
// Remove default entries from system menu popup
SysMenu = GetSystemMenu( ParentWindow, false );
RemoveMenu( SysMenu, SC_RESTORE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_MOVE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_SIZE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_MINIMIZE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_MAXIMIZE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_CLOSE, MF_BYCOMMAND );
RemoveMenu( SysMenu, 0, MF_BYPOSITION );
// The create menu
CreateSystemMenu(); CreateSystemMenu();
*/ */
// Set the parent window attributes // Set the parent window attributes
...@@ -193,8 +105,11 @@ void GTK2Theme::OnLoadTheme() ...@@ -193,8 +105,11 @@ void GTK2Theme::OnLoadTheme()
// Create the parent window // Create the parent window
ParentWindow = gdk_window_new( NULL, &attr, mask); ParentWindow = gdk_window_new( NULL, &attr, mask);
if( !ParentWindow )
// gdk_window_show( ParentWindow ); {
msg_Err( p_intf, "gdk_window_new failed" );
return;
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Theme::AddSystemMenu( string name, Event *event ) void GTK2Theme::AddSystemMenu( string name, Event *event )
...@@ -217,24 +132,7 @@ void GTK2Theme::ChangeClientWindowName( string name ) ...@@ -217,24 +132,7 @@ void GTK2Theme::ChangeClientWindowName( string name )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Theme::AddWindow( string name, int x, int y, bool visible, void GTK2Theme::AddWindow( string name, int x, int y, bool visible,
int fadetime, int alpha, int movealpha, bool dragdrop ) int fadetime, int alpha, int movealpha, bool dragdrop )
{/* {
HWND hwnd;
hwnd = CreateWindowEx( WS_EX_LAYERED|WS_EX_TOOLWINDOW,
"SkinWindow", name.c_str(), WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, ParentWindow, 0, hinst, NULL );
if( !hwnd )
{
msg_Err( p_intf, "CreateWindow failed" );
return;
}
SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)p_intf );
WindowList.push_back( (Window *)new OSWindow( p_intf, hwnd, x, y, visible,
fadetime, alpha, movealpha, dragdrop ) ) ;*/
GdkWindowAttr attr; GdkWindowAttr attr;
attr.title = (gchar *)name.c_str(); attr.title = (gchar *)name.c_str();
attr.event_mask = GDK_ALL_EVENTS_MASK; attr.event_mask = GDK_ALL_EVENTS_MASK;
...@@ -250,7 +148,7 @@ void GTK2Theme::AddWindow( string name, int x, int y, bool visible, ...@@ -250,7 +148,7 @@ void GTK2Theme::AddWindow( string name, int x, int y, bool visible,
GdkWindow *gwnd = gdk_window_new( NULL, &attr, mask ); GdkWindow *gwnd = gdk_window_new( NULL, &attr, mask );
if( !gwnd ) if( !gwnd )
{ {
msg_Err( p_intf, "CreateWindow failed" ); msg_Err( p_intf, "gdk_window_new failed" );
return; return;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_window.cpp: GTK2 implementation of the Window class * gtk2_window.cpp: GTK2 implementation of the Window class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_window.cpp,v 1.24 2003/04/20 15:00:19 karibu Exp $ * $Id: gtk2_window.cpp,v 1.25 2003/04/21 14:26:59 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -48,17 +48,6 @@ ...@@ -48,17 +48,6 @@
#include "../src/theme.h" #include "../src/theme.h"
//---------------------------------------------------------------------------
// Fading API
//---------------------------------------------------------------------------
/*#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002
typedef BOOL (WINAPI *SLWA)(HWND, COLORREF, BYTE, DWORD);
HMODULE hModule = LoadLibrary( "user32.dll" );
SLWA SetLayeredWindowAttributes =
(SLWA)GetProcAddress( hModule, "SetLayeredWindowAttributes" );
*/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Skinable Window // Skinable Window
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -185,6 +174,14 @@ bool GTK2Window::ProcessOSEvent( Event *evt ) ...@@ -185,6 +174,14 @@ bool GTK2Window::ProcessOSEvent( Event *evt )
case GDK_BUTTON_PRESS: case GDK_BUTTON_PRESS:
// Raise all the windows
for( list<Window *>::const_iterator win =
p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
gdk_window_raise( ( (GTK2Window *)(*win) )->GetHandle() );
}
switch( ( (GdkEventButton *)p2 )->button ) switch( ( (GdkEventButton *)p2 )->button )
{ {
case 1: case 1:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment