* 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 $
+ * $Id: gtk2_api.cpp,v 1.16 2003/04/28 12:00:13 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* USA.
*****************************************************************************/
+#ifdef GTK2_SKINS
//--- GTK2 ------------------------------------------------------------------
-#include <gtk/gtk.h>
+#include <glib.h>
+#include <gdk/gdk.h>
//--- SKIN ------------------------------------------------------------------
-#include "window.h"
-#include "os_window.h"
-#include "os_api.h"
-#include "event.h" // for MAX_PARAM_SIZE
+#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( Window *win, unsigned int message, unsigned int param1,
+void OSAPI_SendMessage( SkinWindow *win, unsigned int message, unsigned int param1,
long param2 )
{
- if( win == NULL )
+/* if( win == NULL )
SendMessage( NULL, message, param1, param2 );
else
SendMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
- param2 );
+ param2 );*/
}
//---------------------------------------------------------------------------
-void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
+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 )
- PostMessage( NULL, message, param1, param2 );
+ {
+ event->window = NULL;
+ }
else
- PostMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
- param2 );
+ {
+ 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;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int OSAPI_GetNonTransparentColor( int c )
{
- // Get desktop device context
+/* // Get desktop device context
HDC DeskDC = GetWindowDC( GetDesktopWindow() );
// If color is black or color is same as black wether pixel color depth
c = RGB(1, 0, 0);
}
ReleaseDC( GetDesktopWindow(), DeskDC );
- return c;
+ return c;*/
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int OSAPI_GetTime()
{
- return GetTickCount();
+ GTimeVal time;
+ g_get_current_time( &time );
+ return ( time.tv_sec * 1000 + time.tv_usec / 1000 );
}
//---------------------------------------------------------------------------
void OSAPI_GetScreenSize( int &w, int &h )
{
- w = GetSystemMetrics(SM_CXSCREEN);
- h = GetSystemMetrics(SM_CYSCREEN);
+ w = gdk_screen_width();
+ h = gdk_screen_height();
}
//---------------------------------------------------------------------------
void OSAPI_GetMousePos( int &x, int &y )
{
- LPPOINT MousePos = new POINT;
- GetCursorPos( MousePos );
- x = MousePos->x;
- y = MousePos->y;
- delete MousePos;
+ gdk_window_get_pointer( gdk_get_default_root_window(), &x, &y, NULL );
}
//---------------------------------------------------------------------------
-string OSAPI_GetWindowTitle( Window *win )
+string OSAPI_GetWindowTitle( SkinWindow *win )
{
- char *buffer = new char[MAX_PARAM_SIZE];
- GetWindowText( ((Win32Window *)win)->GetHandle(), buffer, MAX_PARAM_SIZE );
- string Title = buffer;
- delete buffer;
-
- return Title;
+ return ( (GTK2Window *)win )->GetName();
}
//---------------------------------------------------------------------------
bool OSAPI_RmDir( string path )
{
- WIN32_FIND_DATA find;
+/* WIN32_FIND_DATA find;
string File;
string FindFiles = path + "\\*.*";
HANDLE handle = FindFirstFile( (char *)FindFiles.c_str(), &find );
FindClose( handle );
RemoveDirectory( (char *)path.c_str() );
- return true;
+ return true;*/
}
//---------------------------------------------------------------------------
-*/
+
+#endif