gtk2_api.cpp 5.43 KB
Newer Older
1
2
3
4
/*****************************************************************************
 * gtk2_api.cpp: Various gtk2-specific functions
 *****************************************************************************
 * Copyright (C) 2003 VideoLAN
5
 * $Id: gtk2_api.cpp,v 1.12 2003/04/21 00:18:37 asmax Exp $
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 *
 * 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.
 *****************************************************************************/

25
#if !defined WIN32
26
27

//--- GTK2 ------------------------------------------------------------------
28
#include <glib.h>
29
#include <gdk/gdk.h>
30
31

//--- SKIN ------------------------------------------------------------------
32
33
34
35
#include "../src/window.h"
#include "../os_window.h"
#include "../os_api.h"
#include "../src/event.h"       // for MAX_PARAM_SIZE
36

ipkiss's avatar
ipkiss committed
37
#include <stdio.h>
38
39
40
41
42
43
44

//---------------------------------------------------------------------------
// Event API
//---------------------------------------------------------------------------
void OSAPI_SendMessage( Window *win, unsigned int message, unsigned int param1,
                        long param2 )
{
45
/*    if( win == NULL )
46
47
48
        SendMessage( NULL, message, param1, param2 );
    else
        SendMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
49
                     param2 );*/
50
51
52
53
54
}
//---------------------------------------------------------------------------
void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
                        long param2 )
{
ipkiss's avatar
ipkiss committed
55
    GdkEventClient *event = new GdkEventClient;
56
    
ipkiss's avatar
ipkiss committed
57
58
59
    event->type = GDK_CLIENT_EVENT;
    if( win == NULL )
        event->window = NULL;
60
    else
ipkiss's avatar
ipkiss committed
61
62
63
64
65
66
67
68
69
70
71
        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;

    gdk_event_put( (GdkEvent *)event );

    delete event;
72
73
74
75
76
77
78
79
80
81
82
}
//---------------------------------------------------------------------------




//---------------------------------------------------------------------------
// Graphic API
//---------------------------------------------------------------------------
int OSAPI_GetNonTransparentColor( int c )
{
83
/*    // Get desktop device context
84
85
86
87
88
89
90
91
92
93
94
    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 );
95
    return c;*/
96
97
98
99
100
101
102
103
104
105
106
}
//---------------------------------------------------------------------------




//---------------------------------------------------------------------------
// General
//---------------------------------------------------------------------------
int OSAPI_GetTime()
{
107
108
109
    GTimeVal time;
    g_get_current_time( &time );
    return ( time.tv_sec * 1000 + time.tv_usec / 1000 );
110
111
112
113
}
//---------------------------------------------------------------------------
void OSAPI_GetScreenSize( int &w, int &h )
{
114
115
/*    w = GetSystemMetrics(SM_CXSCREEN);
    h = GetSystemMetrics(SM_CYSCREEN);*/
116
117
118
119
}
//---------------------------------------------------------------------------
void OSAPI_GetMousePos( int &x, int &y )
{
Emmanuel Puig's avatar
Emmanuel Puig committed
120
    gdk_window_get_pointer( gdk_get_default_root_window(), &x, &y, NULL );
121
122
123
124
}
//---------------------------------------------------------------------------
string OSAPI_GetWindowTitle( Window *win )
{
125
    return ( (GTK2Window *)win )->GetName();
126
127
128
129
}
//---------------------------------------------------------------------------
bool OSAPI_RmDir( string path )
{
130
/*    WIN32_FIND_DATA find;
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    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() );

164
    return true;*/
165
166
}
//---------------------------------------------------------------------------
167

168
#endif