]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins/gtk2/gtk2_graphics.cpp
* small fix
[vlc] / modules / gui / skins / gtk2 / gtk2_graphics.cpp
index 03a169d43f1a3b116f3eddd80d24d7b7ed227837..31663344e5be8bd9375b0119107999e2af9011a0 100644 (file)
@@ -2,9 +2,10 @@
  * gtk2_graphics.cpp: GTK2 implementation of the Graphics and Region classes
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: gtk2_graphics.cpp,v 1.9 2003/04/16 21:40:07 ipkiss Exp $
+ * $Id: gtk2_graphics.cpp,v 1.12 2003/04/17 17:45:38 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
+ *          Emmanuel Puig    <karibu@via.ecp.fr>
  *
  * 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
@@ -34,6 +35,7 @@
 #include "gtk2_graphics.h"
 
 #include <stdio.h>
+#include <math.h>
 
 //---------------------------------------------------------------------------
 // GTK2 GRAPHICS
@@ -101,7 +103,7 @@ void GTK2Graphics::DrawRect( int x, int y, int w, int h, int color )
 //---------------------------------------------------------------------------
 void GTK2Graphics::SetClipRegion( Region *rgn )
 {
-/*    SelectClipRgn( Image, ( (GTK2Region *)rgn )->GetHandle() );*/
+    gdk_gc_set_clip_region( Gc, ( (GTK2Region *)rgn )->GetHandle() );
 }
 //---------------------------------------------------------------------------
 
@@ -128,12 +130,12 @@ GTK2Region::GTK2Region( int x, int y, int w, int h )
 //---------------------------------------------------------------------------
 GTK2Region::~GTK2Region()
 {
-/*    DeleteObject( Rgn );*/
+    gdk_region_destroy( Rgn );
 }
 //---------------------------------------------------------------------------
 void GTK2Region::AddPoint( int x, int y )
 {
-/*    AddRectangle( x, y, x + 1, y + 1 );*/
+    AddRectangle( x, y, 1, 1 );
 }
 //---------------------------------------------------------------------------
 void GTK2Region::AddRectangle( int x, int y, int w, int h )
@@ -149,16 +151,41 @@ void GTK2Region::AddRectangle( int x, int y, int w, int h )
 //---------------------------------------------------------------------------
 void GTK2Region::AddElipse( int x, int y, int w, int h )
 {
-/*    HRGN Buffer;
-    Buffer = CreateEllipticRgn( x, y, x + w, y + h );
-    CombineRgn( Rgn, Buffer, Rgn, 0x2 );
-    DeleteObject( Buffer );*/
-    /*FIXME*/
+    GdkRegion *Buffer;
+    GdkRectangle rect;
+    rect.height = 1;
+
+    double ex, ey;
+    double a = w / 2;
+    double b = h / 2;
+
+    if( !a || !b )
+        return;
+
+    for( ey = 0; ey < h; ey++ )
+    {
+        // Calculate coords
+        ex = a * sqrt( 1 - ey * ey / ( b * b ) );
+
+        // Upper line
+        rect.x     = (gint)( x + a - ex );
+        rect.y     = (gint)( y + b - ey );
+        rect.width = (gint)( 2 * ex );
+        Buffer = gdk_region_rectangle( &rect );
+        gdk_region_union( Rgn, Buffer );
+        gdk_region_destroy( Buffer );
+
+        // Lower line
+        rect.y = (gint)( y + b + ey );
+        Buffer = gdk_region_rectangle( &rect );
+        gdk_region_union( Rgn, Buffer );
+        gdk_region_destroy( Buffer );
+    }
 }
 //---------------------------------------------------------------------------
 void GTK2Region::Move( int x, int y )
 {
-/*    OffsetRgn( Rgn, x, y );*/
+    gdk_region_offset( Rgn, x, y );
 }
 //---------------------------------------------------------------------------
 bool GTK2Region::Hit( int x, int y )