Commit 5e0f6df7 authored by Emmanuel Puig's avatar Emmanuel Puig

* gtk2_bitmap.cpp: fixed constructor bug

* Events work better: controls are working, not still perfectly...
parent 88e6ced2
......@@ -2,7 +2,7 @@
* button.cpp: Button control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: button.cpp,v 1.6 2003/04/15 20:33:58 karibu Exp $
* $Id: button.cpp,v 1.7 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -137,6 +137,7 @@ bool ControlButton::MouseUp( int x, int y, int button )
// If hit in the button
if( Img[1]->Hit( x - Left, y - Top ) )
{
fprintf( stderr, " Button up ! (%i;%i)\n", button, (int)Selected );
if( !Enabled )
return true;
......@@ -160,17 +161,20 @@ bool ControlButton::MouseDown( int x, int y, int button )
{
if( Img[0]->Hit( x - Left, y - Top ) )
{
fprintf( stderr, " Button down ! (%i)\n", button );
if( !Enabled )
return true;
fprintf( stderr, " Button down ! (%i)\n", button );
if( button == 1 )
{
State = 0;
Selected = true;
fprintf( stderr, " Button down ! (%i)\n", (int)Selected );
ParentWindow->Refresh( Left, Top, Width, Height );
fprintf( stderr, " Button down ! (%i)\n", (int)Selected );
return true;
}
fprintf( stderr, "button\n" );
}
return false;
......
......@@ -2,7 +2,7 @@
* gtk2_api.cpp: Various gtk2-specific functions
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_api.cpp,v 1.9 2003/04/16 14:38:04 asmax Exp $
* $Id: gtk2_api.cpp,v 1.10 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -65,11 +65,6 @@ void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
event->data.l[1] = param1;
event->data.l[2] = param2;
if( message == VLC_HIDE )
{
fprintf( stderr, "======= message %i %x\n", message, event );
}
gdk_event_put( (GdkEvent *)event );
delete event;
......
......@@ -2,7 +2,7 @@
* gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.cpp,v 1.11 2003/04/16 14:38:04 asmax Exp $
* $Id: gtk2_bitmap.cpp,v 1.12 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -50,7 +50,6 @@ GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
HBITMAP HBuf;
BITMAP Bmp;
HDC bufDC;
AlphaColor = AColor;
// Create image from file if it exists
HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP,
......@@ -169,36 +168,34 @@ void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
//---------------------------------------------------------------------------
bool GTK2Bitmap::Hit( int x, int y)
{
if( x < 0 || x >= Width || y < 0 || y >= Height )
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( x < 0 || x >= Width || y < 0 || y >= Height )
return -1;
/* FIXME */
guchar *pixels;
int rowstride, offset;
gboolean has_alpha;
rowstride = gdk_pixbuf_get_rowstride( Bmp );
pixels = gdk_pixbuf_get_pixels( 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];
int b = pixels [offset + 2];
unsigned int c = r + g * 256 + b * 65536;
/* If has_alpha == TRUE, then the alpha component is in
pixels [offset + 3] */
int g = pixels [offset + 1] << 8;
int b = pixels [offset + 2] << 16;
if( c == AlphaColor )
return false;
else
return true;
}
//---------------------------------------------------------------------------
int GTK2Bitmap::GetBmpPixel( int x, int y )
{
// return GetPixel( bmpDC, x, y );
return r + g + b;
}
//---------------------------------------------------------------------------
void GTK2Bitmap::SetBmpPixel( int x, int y, int color )
......
......@@ -2,7 +2,7 @@
* gtk2_event.cpp: GTK2 implementation of the Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_event.cpp,v 1.7 2003/04/15 20:54:58 karibu Exp $
* $Id: gtk2_event.cpp,v 1.8 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -92,9 +92,9 @@ bool GTK2Event::SendEvent()
//---------------------------------------------------------------------------
bool GTK2Event::IsEqual( Event *evt )
{
/* GTK2Event *WinEvt = (GTK2Event *)evt;
return( WinEvt->GetWindow() == hWnd && WinEvt->GetMessage() == Message &&
WinEvt->GetParam1() == Param1 && WinEvt->GetParam2() == Param2 );*/
GTK2Event *GTKEvt = (GTK2Event *)evt;
return( GTKEvt->GetWindow() == gWnd && GTKEvt->GetMessage() == Message &&
GTKEvt->GetParam1() == Param1 && GTKEvt->GetParam2() == Param2 );
}
//---------------------------------------------------------------------------
void GTK2Event::CreateOSEvent( string para1, string para2, string para3 )
......
......@@ -2,7 +2,7 @@
* gtk2_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_run.cpp,v 1.8 2003/04/15 20:42:04 karibu Exp $
* $Id: gtk2_run.cpp,v 1.9 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -95,10 +95,15 @@ void GTK2Proc( GdkEvent *event, gpointer data )
((GdkEventAny *)event)->window, msg, 0, (long)event );
}
// Send event
if( IsVLCEvent( msg ) )
{
if( !proc->EventProc( evt ) )
{
fprintf( stderr, "Quit\n" );
g_main_context_unref( g_main_context_default() );
return; // Exit VLC !
}
}
else if( gwnd == NULL )
{
......@@ -131,8 +136,12 @@ void GTK2Proc( GdkEvent *event, gpointer data )
}
}
evt->DestructParameters();
delete (OSEvent *)evt;
// Check if vlc is closing
proc->IsClosing();
#if 0
// If Window is parent window
if( hwnd == ( (GTK2Theme *)p_intf->p_sys->p_theme )->GetParentWindow() )
......
......@@ -2,7 +2,7 @@
* bitmap.cpp: Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: bitmap.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
* $Id: bitmap.cpp,v 1.2 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -37,13 +37,15 @@
//---------------------------------------------------------------------------
Bitmap::Bitmap( intf_thread_t *_p_intf, string FileName, int AColor )
{
p_intf = _p_intf;
p_intf = _p_intf;
AlphaColor = AColor;
}
//---------------------------------------------------------------------------
Bitmap::Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y,
int w, int h, int AColor )
{
p_intf = _p_intf;
p_intf = _p_intf;
AlphaColor = AColor;
}
//---------------------------------------------------------------------------
Bitmap::Bitmap( intf_thread_t *_p_intf, Bitmap *c )
......
......@@ -2,7 +2,7 @@
* event.cpp: Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: event.cpp,v 1.9 2003/04/16 14:38:04 asmax Exp $
* $Id: event.cpp,v 1.10 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -103,9 +103,7 @@ void Event::PostTextMessage( string text )
{
char *txt = new char[text.size()+1];
strcpy( txt, text.c_str() );
// OSAPI_PostMessage( NULL, CTRL_SET_TEXT, (unsigned int)this, (long)txt );
/* FIXME */
fprintf(stderr, "posttext %s\n", text.c_str());
OSAPI_PostMessage( NULL, CTRL_SET_TEXT, (unsigned int)this, (long)txt );
}
//---------------------------------------------------------------------------
unsigned int Event::GetMessageType( string Desc )
......
......@@ -2,7 +2,7 @@
* window.cpp: Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: window.cpp,v 1.13 2003/04/16 15:34:36 asmax Exp $
* $Id: window.cpp,v 1.14 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -297,6 +297,8 @@ void Window::Refresh( int x, int y, int w, int h )
if( Hidden )
return;
fprintf( stderr, "Refresh: %i %i %i %i\n", x, y, w, h );
// And copy buffer to window
RefreshFromImage( x, y, w, h );
......@@ -386,8 +388,16 @@ void Window::MouseUp( int x, int y, int button )
// Checking event in controls
for( i = ControlList.size() - 1; i >= 0 ; i-- )
{
fprintf( stderr, " -> Control\n" );
if( ControlList[i]->MouseUp( x, y, button ) )
{
int x, y;
//ControlList[i]->GetSize( x, y );
fprintf( stderr, " x: %i\n y: %i\n",
ControlList[i]->Left, ControlList[i]->Top );
return;
}
}
}
//---------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* win32_bitmap.cpp: Win32 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_bitmap.cpp,v 1.2 2003/04/12 21:43:27 asmax Exp $
* $Id: win32_bitmap.cpp,v 1.3 2003/04/16 19:22:53 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -52,7 +52,6 @@ Win32Bitmap::Win32Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
HBITMAP HBuf;
BITMAP Bmp;
HDC bufDC;
AlphaColor = AColor;
// Create image from file if it exists
HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP,
......
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