1 /*****************************************************************************
2 * gtk2_api.cpp: Various gtk2-specific functions
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: gtk2_api.cpp,v 1.11 2003/04/16 21:40:07 ipkiss Exp $
7 * Authors: Cyril Deguet <asmax@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
23 *****************************************************************************/
27 //--- GTK2 ------------------------------------------------------------------
31 //--- SKIN ------------------------------------------------------------------
32 #include "../src/window.h"
33 #include "../os_window.h"
34 #include "../os_api.h"
35 #include "../src/event.h" // for MAX_PARAM_SIZE
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
42 void OSAPI_SendMessage( Window *win, unsigned int message, unsigned int param1,
46 SendMessage( NULL, message, param1, param2 );
48 SendMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
51 //---------------------------------------------------------------------------
52 void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
55 GdkEventClient *event = new GdkEventClient;
56 event->type = GDK_CLIENT_EVENT;
60 event->window = ((GTK2Window *)win)->GetHandle();
61 event->send_event = 0;
62 event->message_type = NULL;
63 event->data_format = 32;
64 event->data.l[0] = message;
65 event->data.l[1] = param1;
66 event->data.l[2] = param2;
68 gdk_event_put( (GdkEvent *)event );
72 //---------------------------------------------------------------------------
77 //---------------------------------------------------------------------------
79 //---------------------------------------------------------------------------
80 int OSAPI_GetNonTransparentColor( int c )
82 /* // Get desktop device context
83 HDC DeskDC = GetWindowDC( GetDesktopWindow() );
85 // If color is black or color is same as black wether pixel color depth
86 if( c == 0 || SetPixel( DeskDC, 0, 0, c ) == 0 )
88 if( GetDeviceCaps( DeskDC, BITSPIXEL ) < 24 )
93 ReleaseDC( GetDesktopWindow(), DeskDC );
96 //---------------------------------------------------------------------------
101 //---------------------------------------------------------------------------
103 //---------------------------------------------------------------------------
107 g_get_current_time( &time );
108 return ( time.tv_sec * 1000 + time.tv_usec / 1000 );
110 //---------------------------------------------------------------------------
111 void OSAPI_GetScreenSize( int &w, int &h )
113 /* w = GetSystemMetrics(SM_CXSCREEN);
114 h = GetSystemMetrics(SM_CYSCREEN);*/
116 //---------------------------------------------------------------------------
117 void OSAPI_GetMousePos( int &x, int &y )
119 gdk_window_get_pointer( gdk_get_default_root_window(), &x, &y, NULL );
121 //---------------------------------------------------------------------------
122 string OSAPI_GetWindowTitle( Window *win )
124 return ( (GTK2Window *)win )->GetName();
126 //---------------------------------------------------------------------------
127 bool OSAPI_RmDir( string path )
129 /* WIN32_FIND_DATA find;
131 string FindFiles = path + "\\*.*";
132 HANDLE handle = FindFirstFile( (char *)FindFiles.c_str(), &find );
134 while( handle != INVALID_HANDLE_VALUE )
136 // If file is neither "." nor ".."
137 if( strcmp( find.cFileName, "." ) && strcmp( find.cFileName, ".." ) )
140 File = path + "\\" + (string)find.cFileName;
142 // If file is a directory, delete it recursively
143 if( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
147 // Else, it is a file so simply delete it
150 DeleteFile( (char *)File.c_str() );
154 // If no more file in directory, exit while
155 if( !FindNextFile( handle, &find ) )
159 // Now directory is empty so can be removed
161 RemoveDirectory( (char *)path.c_str() );
165 //---------------------------------------------------------------------------