Commit f3bcd927 authored by Cyril Deguet's avatar Cyril Deguet

* at last made the skin module compile under linux !

  It does absolutely nothing, but it compiles ;)
parent 84b3b12b
......@@ -15,7 +15,7 @@ bool 'GTK+ support' CONFIG_GTK
dep_bool ' Gnome interface support' CONFIG_GNOME $CONFIG_GTK
bool 'GTK2 support' CONFIG_GTK2
dep_bool ' Gnome2 support' CONFIG_GNOME2 $CONFIG_GTK2
bool 'Win32 skins module' CONFIG_SKINS
bool 'Skins module' CONFIG_SKINS
bool 'Familiar GTK+ support' CONFIG_FAMILIAR
bool 'wxWindows support' CONFIG_WXWINDOWS
bool 'Qt interface support' CONFIG_QT
......
......@@ -2305,6 +2305,11 @@ if test "x${enable_skins}" != "xno"; then
PLUGINS="${PLUGINS} skins"
CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins -Imodules/gui/skins/src -Imodules/gui/skins/win32 -Imodules/gui/skins/controls"
LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32 -lmsimg32"
else
PKG_CHECK_MODULES(GTK2, [gtk+-2.0 >= 2.0.0, gthread-2.0])
PLUGINS="${PLUGINS} skins"
CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins -Imodules/gui/skins/src -Imodules/gui/skins/gtk2 -Imodules/gui/skins/controls -Imodules/gui/skins/parser ${GTK2_CFLAGS}"
LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ ${GTK2_LIBS}"
fi
fi
......
......@@ -77,6 +77,25 @@ SOURCES_skins = \
modules/gui/skins/win32/win32_theme.h \
modules/gui/skins/win32/win32_window.cpp \
modules/gui/skins/win32/win32_window.h \
\
modules/gui/skins/gtk2/gtk2_api.cpp \
modules/gui/skins/gtk2/gtk2_bitmap.cpp \
modules/gui/skins/gtk2/gtk2_bitmap.h \
modules/gui/skins/gtk2/gtk2_dialog.cpp \
modules/gui/skins/gtk2/gtk2_dialog.h \
modules/gui/skins/gtk2/gtk2_dragdrop.cpp \
modules/gui/skins/gtk2/gtk2_dragdrop.h \
modules/gui/skins/gtk2/gtk2_event.cpp \
modules/gui/skins/gtk2/gtk2_event.h \
modules/gui/skins/gtk2/gtk2_font.cpp \
modules/gui/skins/gtk2/gtk2_font.h \
modules/gui/skins/gtk2/gtk2_graphics.cpp \
modules/gui/skins/gtk2/gtk2_graphics.h \
modules/gui/skins/gtk2/gtk2_run.cpp \
modules/gui/skins/gtk2/gtk2_theme.cpp \
modules/gui/skins/gtk2/gtk2_theme.h \
modules/gui/skins/gtk2/gtk2_window.cpp \
modules/gui/skins/gtk2/gtk2_window.h \
$(NULL)
EXTRA_DIST += \
......
......@@ -2,7 +2,7 @@
* slider.cpp: Slider control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: slider.cpp,v 1.2 2003/03/21 00:17:00 karibu Exp $
* $Id: slider.cpp,v 1.3 2003/04/12 21:43:27 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -78,7 +78,12 @@ ControlSlider::~ControlSlider()
{
delete[] CursorX;
delete[] CursorY;
/* FIXME: kludge */
#ifdef WIN32
DeleteObject( HitRgn );
#else
fprintf(stderr, "WARNING: fixme in slider.cpp!!!!!");
#endif
}
//---------------------------------------------------------------------------
void ControlSlider::Init()
......
/*****************************************************************************
* gtk2_api.cpp: Various gtk2-specific functions
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_api.cpp,v 1.1 2003/04/12 21:43:27 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.
*****************************************************************************/
//--- GTK2 ------------------------------------------------------------------
#include <gtk/gtk.h>
//--- SKIN ------------------------------------------------------------------
#include "window.h"
#include "os_window.h"
#include "os_api.h"
#include "event.h" // for MAX_PARAM_SIZE
/*
//---------------------------------------------------------------------------
// Event API
//---------------------------------------------------------------------------
void OSAPI_SendMessage( Window *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( Window *win, unsigned int message, unsigned int param1,
long param2 )
{
if( win == NULL )
PostMessage( NULL, message, param1, param2 );
else
PostMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
param2 );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 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()
{
return GetTickCount();
}
//---------------------------------------------------------------------------
void OSAPI_GetScreenSize( int &w, int &h )
{
w = GetSystemMetrics(SM_CXSCREEN);
h = GetSystemMetrics(SM_CYSCREEN);
}
//---------------------------------------------------------------------------
void OSAPI_GetMousePos( int &x, int &y )
{
LPPOINT MousePos = new POINT;
GetCursorPos( MousePos );
x = MousePos->x;
y = MousePos->y;
delete MousePos;
}
//---------------------------------------------------------------------------
string OSAPI_GetWindowTitle( Window *win )
{
char *buffer = new char[MAX_PARAM_SIZE];
GetWindowText( ((Win32Window *)win)->GetHandle(), buffer, MAX_PARAM_SIZE );
string Title = buffer;
delete buffer;
return Title;
}
//---------------------------------------------------------------------------
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;
}
//---------------------------------------------------------------------------
*/
/*****************************************************************************
* gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.cpp,v 1.1 2003/04/12 21:43:27 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.
*****************************************************************************/
//--- GTK2 -----------------------------------------------------------------
//#define WINVER 0x0500
//#include <windows.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "graphics.h"
#include "gtk2_graphics.h"
#include "bitmap.h"
#include "gtk2_bitmap.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// GTK2Bitmap
//---------------------------------------------------------------------------
GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
: Bitmap( p_intf, FileName, AColor )
{
/* HBITMAP HBitmap;
HBITMAP HBuf;
BITMAP Bmp;
HDC bufDC;
AlphaColor = AColor;
// 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 );*/
}
//---------------------------------------------------------------------------
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()
{
/* DeleteDC( bmpDC );*/
}
//---------------------------------------------------------------------------
void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest )
{
/* HDC destDC = ( (GTK2Graphics *)dest )->GetImageHandle();
// New method, not available in win95
TransparentBlt( destDC, xRef, yRef, w, h, bmpDC, x, y, w, h, AlphaColor );
*/
}
//---------------------------------------------------------------------------
bool GTK2Bitmap::Hit( int x, int y)
{
/* unsigned int c = GetPixel( bmpDC, x, y );
if( c == AlphaColor || c == CLR_INVALID )
return false;
else
return true;
*/
}
//---------------------------------------------------------------------------
int GTK2Bitmap::GetBmpPixel( int x, int y )
{
// return GetPixel( bmpDC, x, y );
}
//---------------------------------------------------------------------------
void GTK2Bitmap::SetBmpPixel( int x, int y, int color )
{
// SetPixelV( bmpDC, x, y, color );
}
//---------------------------------------------------------------------------
/*****************************************************************************
* gtk2_bitmap.h: GTK2 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.h,v 1.1 2003/04/12 21:43:27 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 <windows.h>
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Bitmap;
class Graphics;
//---------------------------------------------------------------------------
class GTK2Bitmap : public Bitmap
{
private:
// HDC bmpDC;
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 );
// HDC GetBmpDC() { return bmpDC; }
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* gtk2_dialog.cpp: GTK2 implementation of some dialog boxes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_dialog.cpp,v 1.1 2003/04/12 21:43:27 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.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
extern intf_thread_t *g_pIntf;
//--- GTK2 -----------------------------------------------------------------
#define _GTK2_IE 0x0400 // Yes, i think it's a fucking kludge !
//#include <windows.h>
//#include <commdlg.h>
//#include <commctrl.h>
//#include <richedit.h>
//--- SKIN ------------------------------------------------------------------
#include "banks.h"
#include "dialog.h"
#include "os_dialog.h"
#include "skin_common.h"
#include "window.h"
#include "os_window.h"
#include "theme.h"
#include "os_theme.h"
#include "event.h"
#include "os_api.h"
/*
//---------------------------------------------------------------------------
// Open file dialog box
//---------------------------------------------------------------------------
GTK2OpenFileDialog::GTK2OpenFileDialog( intf_thread_t *_p_intf, string title,
bool multiselect ) : OpenFileDialog( _p_intf, title, multiselect )
{
}
//---------------------------------------------------------------------------
GTK2OpenFileDialog::~GTK2OpenFileDialog()
{
}
//---------------------------------------------------------------------------
void GTK2OpenFileDialog::AddFilter( string name, string type )
{
unsigned int i;
for( i = 0; i < name.length(); i++ )
Filter[FilterLength++] = name[i];
Filter[FilterLength++] = ' ';
Filter[FilterLength++] = '(';
for( i = 0; i < type.length(); i++ )
Filter[FilterLength++] = type[i];
Filter[FilterLength++] = ')';
Filter[FilterLength++] = '\0';
for( i = 0; i < type.length(); i++ )
Filter[FilterLength++] = type[i];
Filter[FilterLength++] = '\0';
// Ending null character if this filter is the last
Filter[FilterLength] = '\0';
}
//---------------------------------------------------------------------------
bool GTK2OpenFileDialog::Open()
{
// Initailize dialog box
OPENFILENAME OpenFile;
memset( &OpenFile, 0, sizeof( OpenFile ) );
OpenFile.lStructSize = sizeof( OPENFILENAME );
OpenFile.hwndOwner = NULL;
OpenFile.lpstrFile = new char[MAX_PATH];
OpenFile.lpstrFile[0] = '\0';
OpenFile.nMaxFile = MAX_PATH;
if( MultiSelect )
{
OpenFile.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER;
}
else
{
OpenFile.Flags = OFN_EXPLORER;
}
OpenFile.lpstrTitle = Title.c_str();
OpenFile.lpstrFilter = Filter;
// Remove mouse tracking event to avoid non process due to modal open box
if( p_intf != NULL && p_intf->p_sys->p_theme != NULL )
{
TRACKMOUSEEVENT TrackEvent;
TrackEvent.cbSize = sizeof( TRACKMOUSEEVENT );
TrackEvent.dwFlags = TME_LEAVE|TME_CANCEL;
TrackEvent.dwHoverTime = 1;
list<Window *>::const_iterator win;
for( win = g_pIntf->p_sys->p_theme->WindowList.begin();
win != g_pIntf->p_sys->p_theme->WindowList.end(); win++ )
{
TrackEvent.hwndTrack = ( (GTK2Window *)(*win) )->GetHandle();
TrackMouseEvent( &TrackEvent );
}
}
// Show dialog box
if( !GetOpenFileName( &OpenFile ) )
{
OSAPI_PostMessage( NULL, WINDOW_LEAVE, 0, 0 );
return false;
}
// Tell windows that mouse cursor has left window because it has been
// unactivated
OSAPI_PostMessage( NULL, WINDOW_LEAVE, 0, 0 );
// Find files in string result
char * File = OpenFile.lpstrFile;
int i = OpenFile.nFileOffset;
int last = OpenFile.nFileOffset;
string path;
string tmpFile;
// If only one file has been selected
if( File[OpenFile.nFileOffset - 1] != '\0' )
{
FileList.push_back( (string)File );
}
// If multiple files have been selected
else
{
// Add \ if not present at end of path
if( File[OpenFile.nFileOffset - 2] != '\\' )
{
path = (string)File + '\\';
}
else
{
path = (string)File;
}
// Search filenames
while( true )
{
if( File[i] == '\0' )