Commit 5ee03109 authored by Emmanuel Puig's avatar Emmanuel Puig

* Fixed wrapping for texts

* Filling GTK2Graphics and GTK2Region destructors
parent 25ebbc9d
......@@ -2,7 +2,7 @@
* gtk2_font.cpp: GTK2 implementation of the Font class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_font.cpp,v 1.9 2003/04/17 17:45:38 asmax Exp $
* $Id: gtk2_font.cpp,v 1.10 2003/04/19 02:34:47 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -92,7 +92,30 @@ void GTK2Font::GenericPrint( Graphics *dest, string text, int x, int y,
// Set text
pango_layout_set_text( Layout, text.c_str(), text.length() );
pango_layout_set_width( Layout, w * PANGO_SCALE );
// Set size
int real_w, real_h;
GetSize( text, real_w, real_h );
if( real_w > w )
{
// Change clipping region
Region *TextClipRgn = (Region *)new OSRegion( x, y, w, h );
dest->SetClipRegion( TextClipRgn );
delete TextClipRgn;
w = real_w;
if( align == VLC_FONT_ALIGN_RIGHT )
x += w - real_w;
else if( align == VLC_FONT_ALIGN_CENTER )
x += ( w - real_w ) / 2;
// Put old clip region
dest->ResetClipRegion();
}
else
{
pango_layout_set_width( Layout, w * PANGO_SCALE );
}
// Set attributes
pango_layout_set_alignment( Layout, (PangoAlignment)align );
......
......@@ -2,7 +2,7 @@
* gtk2_graphics.cpp: GTK2 implementation of the Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_graphics.cpp,v 1.12 2003/04/17 17:45:38 asmax Exp $
* $Id: gtk2_graphics.cpp,v 1.13 2003/04/19 02:34:47 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -42,21 +42,6 @@
//---------------------------------------------------------------------------
GTK2Graphics::GTK2Graphics( int w, int h, Window *from ) : Graphics( w, h )
{
/* HBITMAP HImage ;
Image = CreateCompatibleDC( NULL );
if( from != NULL )
{
HDC DC = GetWindowDC( ( (GTK2Window *)from )->GetHandle() );
HImage = CreateCompatibleBitmap( DC, w, h );
ReleaseDC( ( (GTK2Window *)from )->GetHandle(), DC );
}
else
{
HImage = CreateCompatibleBitmap( Image, w, h );
}
SelectObject( Image, HImage );
DeleteObject( HImage );*/
if( from != NULL )
{
GdkWindow *fromWnd = ( (GTK2Window *)from )->GetHandle();
......@@ -69,32 +54,23 @@ GTK2Graphics::GTK2Graphics( int w, int h, Window *from ) : Graphics( w, h )
gdk_drawable_set_colormap( Image, gdk_colormap_get_system() );
Gc = gdk_gc_new( Image );
}
// Set the background color to black
gdk_draw_rectangle( Image, Gc, TRUE, 0, 0, w, h );
}
//---------------------------------------------------------------------------
GTK2Graphics::~GTK2Graphics()
{
/* DeleteDC( Image );*/
g_object_unref( Gc );
g_object_unref( Image );
}
//---------------------------------------------------------------------------
void GTK2Graphics::CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src,
int sx, int sy, int Flag )
{
/* BitBlt( Image, dx, dy, dw, dh, ( (GTK2Graphics *)Src )->GetImageHandle(),
sx, sy, Flag );*/
gdk_draw_drawable( Image, Gc, (( GTK2Graphics* )Src )->GetImage(),
sx, sy, dx, dy, dw, dh );
}
//---------------------------------------------------------------------------
/*void GTK2Graphics::CopyTo( Graphics *Dest, int dx, int dy, int dw, int dh,
int sx, int sy, int Flag )
{
BitBlt( ( (GTK2Graphics *)Dest )->GetImageHandle(), dx, dy, dw, dh, Image,
sx, sy, Flag );
}*/
//---------------------------------------------------------------------------
void GTK2Graphics::DrawRect( int x, int y, int w, int h, int color )
{
......@@ -106,7 +82,18 @@ void GTK2Graphics::SetClipRegion( Region *rgn )
gdk_gc_set_clip_region( Gc, ( (GTK2Region *)rgn )->GetHandle() );
}
//---------------------------------------------------------------------------
void GTK2Graphics::ResetClipRegion()
{
GdkRectangle rect;
rect.x = 0;
rect.y = 0;
rect.width = Width;
rect.height = Height;
GdkRegion *rgn = gdk_region_rectangle( &rect );
gdk_gc_set_clip_region( Gc, rgn );
gdk_region_destroy( rgn );
}
//---------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* gtk2_graphics.h: GTK2 implementation of the Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_graphics.h,v 1.3 2003/04/14 20:07:49 asmax Exp $
* $Id: gtk2_graphics.h,v 1.4 2003/04/19 02:34:47 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -37,11 +37,10 @@ class Window;
//---------------------------------------------------------------------------
class GTK2Graphics : public Graphics
{
private:
int Width;
int Height;
protected:
GdkDrawable *Image;
GdkGC *Gc;
public:
// Constructor
GTK2Graphics( int w, int h, Window *from = NULL );
......@@ -56,6 +55,7 @@ class GTK2Graphics : public Graphics
// Clipping methods
virtual void SetClipRegion( Region *rgn );
virtual void ResetClipRegion();
// Specific GTK2 methods
GdkDrawable *GetImage() { return Image; };
......
......@@ -2,7 +2,7 @@
* graphics.h: Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: graphics.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
* $Id: graphics.h,v 1.2 2003/04/19 02:34:47 karibu Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -33,9 +33,10 @@ class Region;
//---------------------------------------------------------------------------
class Graphics
{
private:
protected:
int Width;
int Height;
public:
// Constructor
Graphics( int w, int h );
......@@ -50,6 +51,8 @@ class Graphics
// Clipping methods
virtual void SetClipRegion( Region *rgn ) = 0;
virtual void ResetClipRegion() = 0;
};
//---------------------------------------------------------------------------
class Region
......
......@@ -2,7 +2,7 @@
* win32_graphics.cpp: Win32 implementation of the Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_graphics.cpp,v 1.3 2003/04/16 21:40:07 ipkiss Exp $
* $Id: win32_graphics.cpp,v 1.4 2003/04/19 02:34:47 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -69,13 +69,6 @@ void Win32Graphics::CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src,
sx, sy, Flag );
}
//---------------------------------------------------------------------------
/*void Win32Graphics::CopyTo( Graphics *Dest, int dx, int dy, int dw, int dh,
int sx, int sy, int Flag )
{
BitBlt( ( (Win32Graphics *)Dest )->GetImageHandle(), dx, dy, dw, dh, Image,
sx, sy, Flag );
}*/
//---------------------------------------------------------------------------
void Win32Graphics::DrawRect( int x, int y, int w, int h, int color )
{
LPRECT r = new RECT;
......@@ -94,7 +87,13 @@ void Win32Graphics::SetClipRegion( Region *rgn )
SelectClipRgn( Image, ( (Win32Region *)rgn )->GetHandle() );
}
//---------------------------------------------------------------------------
void Win32Graphics::ResetClipRegion()
{
HRGN rgn = CreateRectRgn( 0, 0, Width, Height );
SelectClipRgn( Image, rgn );
DeleteObject( rgn );
}
//---------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* win32_graphics.h: Win32 implementation of the Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_graphics.h,v 1.2 2003/04/12 21:43:27 asmax Exp $
* $Id: win32_graphics.h,v 1.3 2003/04/19 02:34:47 karibu Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -35,10 +35,9 @@ class Window;
//---------------------------------------------------------------------------
class Win32Graphics : public Graphics
{
private:
int Width;
int Height;
protected:
HDC Image;
public:
// Constructor
Win32Graphics( int w, int h, Window *from = NULL );
......@@ -53,6 +52,7 @@ class Win32Graphics : public Graphics
// Clipping methods
virtual void SetClipRegion( Region *rgn );
virtual void ResetClipRegion();
// Specific win32 methods
HDC GetImageHandle() { return Image; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment