Commit 1decbca7 authored by Cyril Deguet's avatar Cyril Deguet

* src/theme.cpp, src/event.* : no more VLC_SHOW event

* src/window.* : replaced p_intf->p_sys->WindowList by a singleton
  class SkinWindowList (to be tested under windows)
* removed useless gtk2 files
parent 8ecc9407
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
/*****************************************************************************
* gtk2_api.cpp: Various gtk2-specific functions
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_api.cpp,v 1.16 2003/04/28 12:00:13 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifdef GTK2_SKINS
//--- GTK2 ------------------------------------------------------------------
#include <glib.h>
#include <gdk/gdk.h>
//--- SKIN ------------------------------------------------------------------
#include "../src/window.h"
#include "../os_window.h"
#include "../os_api.h"
#include "../src/event.h" // for MAX_PARAM_SIZE
#include <stdio.h>
//---------------------------------------------------------------------------
// Event API
//---------------------------------------------------------------------------
void OSAPI_SendMessage( SkinWindow *win, unsigned int message, unsigned int param1,
long param2 )
{
/* if( win == NULL )
SendMessage( NULL, message, param1, param2 );
else
SendMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
param2 );*/
}
//---------------------------------------------------------------------------
void OSAPI_PostMessage( SkinWindow *win, unsigned int message, unsigned int param1,
long param2 )
{
GdkEventClient *event = (GdkEventClient *) new GdkEvent;
event->type = GDK_CLIENT_EVENT;
if( win == NULL )
{
event->window = NULL;
}
else
{
event->window = ((GTK2Window *)win)->GetHandle();
}
event->send_event = 0;
event->message_type = NULL;
event->data_format = 32;
event->data.l[0] = message;
event->data.l[1] = param1;
event->data.l[2] = param2;
event->data.l[3] = 0;
event->data.l[4] = 0;
gdk_event_put( (GdkEvent *)event );
delete event;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Graphic API
//---------------------------------------------------------------------------
int OSAPI_GetNonTransparentColor( int c )
{
/* // Get desktop device context
HDC DeskDC = GetWindowDC( GetDesktopWindow() );
// If color is black or color is same as black wether pixel color depth
if( c == 0 || SetPixel( DeskDC, 0, 0, c ) == 0 )
{
if( GetDeviceCaps( DeskDC, BITSPIXEL ) < 24 )
c = RGB(8, 0, 0);
else
c = RGB(1, 0, 0);
}
ReleaseDC( GetDesktopWindow(), DeskDC );
return c;*/
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// General
//---------------------------------------------------------------------------
int OSAPI_GetTime()
{
GTimeVal time;
g_get_current_time( &time );
return ( time.tv_sec * 1000 + time.tv_usec / 1000 );
}
//---------------------------------------------------------------------------
void OSAPI_GetScreenSize( int &w, int &h )
{
w = gdk_screen_width();
h = gdk_screen_height();
}
//---------------------------------------------------------------------------
void OSAPI_GetMousePos( int &x, int &y )
{
gdk_window_get_pointer( gdk_get_default_root_window(), &x, &y, NULL );
}
//---------------------------------------------------------------------------
string OSAPI_GetWindowTitle( SkinWindow *win )
{
return ( (GTK2Window *)win )->GetName();
}
//---------------------------------------------------------------------------
bool OSAPI_RmDir( string path )
{
/* WIN32_FIND_DATA find;
string File;
string FindFiles = path + "\\*.*";
HANDLE handle = FindFirstFile( (char *)FindFiles.c_str(), &find );
while( handle != INVALID_HANDLE_VALUE )
{
// If file is neither "." nor ".."
if( strcmp( find.cFileName, "." ) && strcmp( find.cFileName, ".." ) )
{
// Set file name
File = path + "\\" + (string)find.cFileName;
// If file is a directory, delete it recursively
if( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
OSAPI_RmDir( File );
}
// Else, it is a file so simply delete it
else
{
DeleteFile( (char *)File.c_str() );
}
}
// If no more file in directory, exit while
if( !FindNextFile( handle, &find ) )
break;
}
// Now directory is empty so can be removed
FindClose( handle );
RemoveDirectory( (char *)path.c_str() );
return true;*/
}
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.cpp,v 1.17 2003/04/28 12:00:13 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifdef GTK2_SKINS
//--- GTK2 -----------------------------------------------------------------
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "../os_api.h"
#include "../src/graphics.h"
#include "gtk2_graphics.h"
#include "../src/bitmap.h"
#include "gtk2_bitmap.h"
#include "../src/skin_common.h"
//---------------------------------------------------------------------------
// GTK2Bitmap
//---------------------------------------------------------------------------
GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
: Bitmap( p_intf, FileName, AColor )
{
AlphaColor = AColor;
// Load the bitmap image
Bmp = gdk_pixbuf_new_from_file( FileName.c_str(), NULL );
if( Bmp == NULL )
{
if( FileName != "" )
msg_Warn( p_intf, "Couldn't load bitmap: %s", FileName.c_str() );
Width = 0;
Height = 0;
}
else
{
Width = gdk_pixbuf_get_width( Bmp );
Height = gdk_pixbuf_get_height( Bmp );
if( AColor != 0 )
{
// Change black pixels to another color to avoid transparency
int rowstride = gdk_pixbuf_get_rowstride( Bmp );
guchar *pixel = gdk_pixbuf_get_pixels( Bmp );
int pix_size = ( gdk_pixbuf_get_has_alpha( Bmp ) ? 4 : 3 );
for( int y = 0; y < Height; y++ )
{
for( int x = 0; x < Width; x++ )
{
guint32 r = pixel[0];
guint32 g = pixel[1]<<8;
guint32 b = pixel[2]<<16;
if( r+g+b == 0 )
{
pixel[2] = 10; // slight blue
}
pixel += pix_size;
}
}
}
Bmp = gdk_pixbuf_add_alpha( Bmp, TRUE, AColor & 0xff, (AColor>>8) & 0xff,
(AColor>>16) & 0xff );
}
}
//---------------------------------------------------------------------------
GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, Graphics *from, int x, int y,
int w, int h, int AColor ) : Bitmap( p_intf, from, x, y, w, h, AColor )
{
/* Width = w;
Height = h;
AlphaColor = AColor;
HBITMAP HBmp;
HDC fromDC = ( (GTK2Graphics *)from )->GetImageHandle();
// Create image
bmpDC = CreateCompatibleDC( fromDC );
HBmp = CreateCompatibleBitmap( fromDC, Width, Height );
SelectObject( bmpDC, HBmp );
DeleteObject( HBmp );
BitBlt( bmpDC, 0, 0, Width, Height, fromDC, x, y, SRCCOPY );*/
}
//---------------------------------------------------------------------------
GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, Bitmap *c )
: Bitmap( p_intf, c )
{
/* HBITMAP HBuf;
// Copy attibutes
c->GetSize( Width, Height );
AlphaColor = c->GetAlphaColor();
// Copy bmpDC
bmpDC = CreateCompatibleDC( NULL );
HBuf = CreateCompatibleBitmap( bmpDC, Width, Height );
SelectObject( bmpDC, HBuf );
BitBlt( bmpDC, 0, 0, Width, Height, ( (GTK2Bitmap *)c )->GetBmpDC(),
0, 0, SRCCOPY );
DeleteObject( HBuf );*/
}
//---------------------------------------------------------------------------
GTK2Bitmap::~GTK2Bitmap()
{
if( Bmp )
g_object_unref( G_OBJECT( Bmp) );
}
//---------------------------------------------------------------------------
void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest )
{
if( Bmp )
{
GdkDrawable *destImg = ( (GTK2Graphics *)dest )->GetImage();
GdkGC *destGC = ( (GTK2Graphics *)dest )->GetGC();
gdk_pixbuf_render_to_drawable( Bmp, destImg, destGC, x, y, xRef, yRef,
w, h, GDK_RGB_DITHER_NORMAL, 0, 0);
}
}
//---------------------------------------------------------------------------
bool GTK2Bitmap::Hit( int x, int y)
{
unsigned int c = (unsigned int)GetBmpPixel( x, y );
if( c == -1 || c == AlphaColor )
return false;
else
return true;
}
//---------------------------------------------------------------------------
int GTK2Bitmap::GetBmpPixel( int x, int y )
{
if( !Bmp || x < 0 || x >= Width || y < 0 || y >= Height )
return -1;
guchar *pixels;
int rowstride, offset;
gboolean has_alpha;
rowstride = gdk_pixbuf_get_rowstride( Bmp );
pixels = gdk_pixbuf_get_pixels( Bmp );
has_alpha = gdk_pixbuf_get_has_alpha( Bmp );
offset = y * rowstride + ( x * (has_alpha ? 4 : 3) );
int r = pixels [offset];
int g = pixels [offset + 1] << 8;
int b = pixels [offset + 2] << 16;
return r + g + b;
}
//---------------------------------------------------------------------------
void GTK2Bitmap::SetBmpPixel( int x, int y, int color )
{
// SetPixelV( bmpDC, x, y, color );
}
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* gtk2_bitmap.h: GTK2 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.h,v 1.3 2003/04/13 22:55:15 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_GTK2_BITMAP
#define VLC_GTK2_BITMAP
//--- GTK2 -----------------------------------------------------------------
#include <gdk/gdk.h>
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Bitmap;
class Graphics;
//---------------------------------------------------------------------------
class GTK2Bitmap : public Bitmap
{
private:
GdkPixbuf *Bmp;
public:
// Constructors
GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor );
GTK2Bitmap( intf_thread_t *p_intf, Graphics *from, int x, int y,
int w, int h, int AColor );
GTK2Bitmap( intf_thread_t *p_intf, Bitmap *c );
// Destructor
virtual ~GTK2Bitmap();
virtual void DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest );
virtual bool Hit( int x, int y );
virtual int GetBmpPixel( int x, int y );
virtual void SetBmpPixel( int x, int y, int color );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* gtk2_dragdrop.cpp: GTK2 implementation of the drag & drop
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_dragdrop.cpp,v 1.6 2003/04/28 12:00:13 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifdef GTK2_SKINS
//--- GTK2 -----------------------------------------------------------------
#include <gdk/gdk.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "../src/event.h"
#include "../os_api.h"
#include "gtk2_dragdrop.h"
//---------------------------------------------------------------------------
GTK2DropObject::GTK2DropObject( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
}
//---------------------------------------------------------------------------
GTK2DropObject::~GTK2DropObject()
{
}
//---------------------------------------------------------------------------
void GTK2DropObject::HandleDropStart( GdkDragContext *context )
{
GdkAtom atom = gdk_drag_get_selection( context );
guchar *buffer;
GdkAtom prop_type;
gint prop_format;
// Get the owner of the selection
GdkWindow *owner = gdk_selection_owner_get( atom );
// Find the possible targets for the selection
string target = "";
gdk_selection_convert( owner, atom, gdk_atom_intern("TARGETS", FALSE),
OSAPI_GetTime() );
int len = gdk_selection_property_get( owner, &buffer, &prop_type,
&prop_format );
for( int i = 0; i < len / sizeof(GdkAtom); i++ )
{
GdkAtom atom = ( (GdkAtom*)buffer )[i];
gchar *name = gdk_atom_name( atom );
if( name )
{
string curTarget = name;
if( (curTarget == "text/plain" || curTarget == "STRING") )
{
target = curTarget;
break;
}
}
}
if( target == "" )
{
msg_Warn( p_intf, "Drag&Drop: target not found\n" );
}
else
{
gdk_selection_convert( owner, atom, gdk_atom_intern(target.c_str(),
FALSE), OSAPI_GetTime() );
len = gdk_selection_property_get( owner, &buffer, &prop_type,
&prop_format);
OSAPI_PostMessage( NULL, VLC_DROP, (unsigned int)buffer, 0 );
}
/* // Get number of files that are dropped into vlc
int NbFiles = DragQueryFile( (HDROP)HDrop, 0xFFFFFFFF, NULL, 0 );
// For each dropped files
for( int i = 0; i < NbFiles; i++ )
{
// Get the name of the file
int NameLength = DragQueryFile( (HDROP)HDrop, i, NULL, 0 ) + 1;
char *FileName = new char[NameLength];
DragQueryFile( (HDROP)HDrop, i, FileName, NameLength );
// The pointer must not be deleted here because it will be deleted
// in the VLC specific messages processing function
PostMessage( NULL, VLC_DROP, (WPARAM)FileName, 0 );
}
DragFinish( (HDROP)HDrop );
*/
gdk_drop_finish( context, TRUE,OSAPI_GetTime() );
}
#endif
/*****************************************************************************
* gtk2_dragdrop.h: GTK2 implementation of the drag & drop
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_dragdrop.h,v 1.3 2003/04/19 11:46:11 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_GTK2_DRAGDROP
#define VLC_SKIN_GTK2_DRAGDROP
//--- GTK2 -----------------------------------------------------------------
#include <gdk/gdk.h>
#include <stdio.h>
//---------------------------------------------------------------------------
class GTK2DropObject
{
private:
intf_thread_t *p_intf;
public:
GTK2DropObject( intf_thread_t *_p_intf );
virtual ~GTK2DropObject();
void HandleDropStart( GdkDragContext *context );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* gtk2_event.cpp: GTK2 implementation of the Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_event.cpp,v 1.12 2003/04/28 12:00:13 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifdef GTK2_SKINS
//--- GTK2 -----------------------------------------------------------------
#include <gdk/gdk.h>
//--- VLC -------------------------------------------------------------------