* gtk2_window.cpp: GTK2 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: gtk2_window.cpp,v 1.2 2003/04/12 22:50:42 asmax Exp $
+ * $Id: gtk2_window.cpp,v 1.15 2003/04/15 20:33:58 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* USA.
*****************************************************************************/
+#if !defined WIN32
//--- GENERAL ---------------------------------------------------------------
//#include <math.h>
#include <vlc/intf.h>
//--- GTK2 ------------------------------------------------------------------
-//#include <windows.h>
+#include <gdk/gdk.h>
+#include <glib.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "theme.h"
-
//---------------------------------------------------------------------------
// Fading API
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
GTK2Window::GTK2Window( intf_thread_t *p_intf, GdkWindow *gwnd, int x, int y,
bool visible, int transition, int normalalpha, int movealpha,
- bool dragdrop )
+ bool dragdrop, string name )
: Window( p_intf, x, y, visible, transition, normalalpha, movealpha,
dragdrop )
{
// Set handles
-/* hWnd = hwnd;
+ gWnd = gwnd;
+ gc = gdk_gc_new( gwnd );
+
+ Name = name;
+ LButtonDown = false;
+ RButtonDown = false;
+/*
// Set position parameters
CursorPos = new POINT;
WindowPos = new POINT;
RegisterDragDrop( hWnd, DropTarget );
}
*/
+ // Create Tool Tip window
+/* GdkWindowAttr attr;
+ attr.event_mask = GDK_ALL_EVENTS_MASK;
+ attr.width = 100;
+ attr.height = 100;
+ attr.window_type = GDK_WINDOW_CHILD;
+ attr.wclass = GDK_INPUT_OUTPUT;
+ gint mask = 0;
+ ToolTipWindow = gdk_window_new( gwnd, &attr, mask);*/
+
}
//---------------------------------------------------------------------------
GTK2Window::~GTK2Window()
//---------------------------------------------------------------------------
void GTK2Window::OSShow( bool show )
{
-/* if( show )
+ if( show )
{
- ShowWindow( hWnd, SW_SHOW );
+ gdk_window_show( gWnd );
}
else
{
- ShowWindow( hWnd, SW_HIDE );
- }*/
+ gdk_window_hide( gWnd );
+ }
}
//---------------------------------------------------------------------------
bool GTK2Window::ProcessOSEvent( Event *evt )
{
-/* unsigned int msg = evt->GetMessage();
+ unsigned int msg = evt->GetMessage();
unsigned int p1 = evt->GetParam1();
int p2 = evt->GetParam2();
switch( msg )
{
- case WM_PAINT:
- HDC DC;
- PAINTSTRUCT Infos;
- DC = BeginPaint( hWnd , &Infos );
- EndPaint( hWnd , &Infos );
+ case GDK_EXPOSE:
RefreshFromImage( 0, 0, Width, Height );
return true;
- case WM_MOUSEMOVE:
- TRACKMOUSEEVENT TrackEvent;
- TrackEvent.cbSize = sizeof( TRACKMOUSEEVENT );\r
- TrackEvent.dwFlags = TME_LEAVE;\r
- TrackEvent.hwndTrack = hWnd;\r
- TrackEvent.dwHoverTime = 1;
- TrackMouseEvent( &TrackEvent );
- if( p1 == MK_LBUTTON )
- MouseMove( LOWORD( p2 ), HIWORD( p2 ), 1 );
- else if( p1 == MK_RBUTTON )
- MouseMove( LOWORD( p2 ), HIWORD( p2 ), 2 );
+ case GDK_MOTION_NOTIFY:
+ if( LButtonDown )
+ MouseMove( (int)( (GdkEventButton *)p2 )->x,
+ (int)( (GdkEventButton *)p2 )->y, 1 );
+ else if( RButtonDown )
+ MouseMove( (int)( (GdkEventButton *)p2 )->x,
+ (int)( (GdkEventButton *)p2 )->y, 2 );
else
- MouseMove( LOWORD( p2 ), HIWORD( p2 ), 0 );
-
+ MouseMove( (int)( (GdkEventButton *)p2 )->x,
+ (int)( (GdkEventButton *)p2 )->y, 0 );
+ gdk_window_get_pointer( gWnd, 0, 0, 0 );
return true;
- case WM_LBUTTONDOWN:
- SetCapture( hWnd );
- MouseDown( LOWORD( p2 ), HIWORD( p2 ), 1 );
- return true;
- case WM_LBUTTONUP:
- ReleaseCapture();
- MouseUp( LOWORD( p2 ), HIWORD( p2 ), 1 );
- return true;
+ case GDK_BUTTON_PRESS:
+ switch( ( (GdkEventButton *)p2 )->button )
+ {
+ case 1:
+ // Left button
+ LButtonDown = true;
+ MouseDown( (int)( (GdkEventButton *)p2 )->x,
+ (int)( (GdkEventButton *)p2 )->y, 1 );
+ break;
- case WM_RBUTTONDOWN:
- MouseDown( LOWORD( p2 ), HIWORD( p2 ), 2 );
- return true;
+ case 3:
+ // Right button
+ RButtonDown = true;
+ MouseDown( (int)( (GdkEventButton *)p2 )->x,
+ (int)( (GdkEventButton *)p2 )->y, 2 );
+ break;
- case WM_RBUTTONUP:
- MouseUp( LOWORD( p2 ), HIWORD( p2 ), 2 );
+ default:
+ break;
+ }
return true;
- case WM_LBUTTONDBLCLK:
- MouseDblClick( LOWORD( p2 ), HIWORD( p2 ), 1 );
+ case GDK_BUTTON_RELEASE:
+ switch( ( (GdkEventButton *)p2 )->button )
+ {
+ case 1:
+ // Left button
+ LButtonDown = false;
+ MouseUp( (int)( (GdkEventButton *)p2 )->x,
+ (int)( (GdkEventButton *)p2 )->y, 1 );
+ break;
+
+ case 3:
+ // Right button
+ RButtonDown = false;
+ MouseUp( (int)( (GdkEventButton *)p2 )->x,
+ (int)( (GdkEventButton *)p2 )->y, 2 );
+ break;
+
+ default:
+ break;
+ }
return true;
- case WM_MOUSELEAVE:
+ case GDK_LEAVE_NOTIFY:
OSAPI_PostMessage( this, WINDOW_LEAVE, 0, 0 );
return true;
+/*
+ case WM_LBUTTONDBLCLK:
+ MouseDblClick( LOWORD( p2 ), HIWORD( p2 ), 1 );
+ return true;
+*/
default:
return false;
- }*/
+ }
}
//---------------------------------------------------------------------------
void GTK2Window::SetTransparency( int Value )
// Release window device context
ReleaseDC( hWnd, DC );
+
*/
+
+ gdk_draw_drawable( gWnd, gc, (( GTK2Graphics* )Image )->GetImage(),
+ x, y, x, y, w, h );
}
//---------------------------------------------------------------------------
void GTK2Window::WindowManualMove()
{
-/* // Get mouse cursor position
- LPPOINT NewPos = new POINT;
- GetCursorPos( NewPos );
+ // Get mouse cursor position
+ int x, y;
+ gdk_window_get_pointer( gdk_get_default_root_window(), &x, &y, NULL );
// Move window and chek for magnetism
p_intf->p_sys->p_theme->MoveSkinMagnet( this,
- WindowPos->x + NewPos->x - CursorPos->x,
- WindowPos->y + NewPos->y - CursorPos->y );
+ WindowX + x - CursorX, WindowY + y - CursorY );
- // Free memory
- delete[] NewPos;
-*/
}
//---------------------------------------------------------------------------
void GTK2Window::WindowManualMoveInit()
{
-/* GetCursorPos( CursorPos );
- WindowPos->x = Left;
- WindowPos->y = Top;*/
+ gdk_window_get_pointer( gdk_get_default_root_window(), &CursorX, &CursorY,
+ NULL );
+ WindowX = Left;
+ WindowY = Top;
}
//---------------------------------------------------------------------------
void GTK2Window::Move( int left, int top )
{
-/* Left = left;
+ Left = left;
Top = top;
- //SetWindowPos( hWnd, HWND_TOP, Left, Top, Width, Height,
- // SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER );
- MoveWindow( hWnd, Left, Top, Width, Height, false );*/
+ gdk_window_move( gWnd, left, top );
}
//---------------------------------------------------------------------------
void GTK2Window::Size( int width, int height )
{
-/* Width = width;
+ Width = width;
Height = height;
- SetWindowPos( hWnd, HWND_TOP, Left, Top, Width, Height,
- SWP_NOMOVE|SWP_NOREDRAW|SWP_NOZORDER );*/
+ gdk_window_resize( gWnd, width, height );
}
//---------------------------------------------------------------------------
void GTK2Window::ChangeToolTipText( string text )
}
//---------------------------------------------------------------------------
+#endif