1 #############################################################################
3 ## Purpose: XS for Wx::DC and derived classes
4 ## Author: Mattia Barbon
7 ## RCS-ID: $Id: DC.xs 2561 2009-05-17 08:49:49Z mbarbon $
8 ## Copyright: (c) 2000-2007, 2009 Mattia Barbon
9 ## Licence: This program is free software; you can redistribute it and/or
10 ## modify it under the same terms as Perl itself
11 #############################################################################
15 #include <wx/dcmemory.h>
16 #include <wx/dcclient.h>
17 #include <wx/dcscreen.h>
18 #include <wx/window.h>
19 #include <wx/dcbuffer.h>
21 #define wxNullBitmapPtr (wxBitmap*) &wxNullBitmap
23 MODULE=Wx PACKAGE=Wx::DC
28 wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
34 wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ),
36 if( wxPli_object_is_deleteable( aTHX_ ST(0) ) )
39 #if WXPERL_W_VERSION_LT( 2, 7, 0 ) || WXWIN_COMPATIBILITY_2_6
47 wxDC::Blit( xdest, ydest, width, height, source, xsrc, ysrc, logicalFunc = wxCOPY, useMask = false )
55 wxRasterOperationMode logicalFunc
58 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
61 wxDC::StretchBlit( xdest, ydest, wdest, hdest, source, xsrc, ysrc, wsrc, hsrc, logicalFunc = wxCOPY, useMask = false, xsrcmask = -1, ysrcmask = -1 )
71 wxRasterOperationMode logicalFunc
79 wxDC::CalcBoundingBox( x, y )
87 wxDC::CrossHair( x, y )
92 wxDC::DestroyClippingRegion()
95 wxDC::DeviceToLogicalX( x )
99 wxDC::DeviceToLogicalXRel( x )
103 wxDC::DeviceToLogicalY( y )
107 wxDC::DeviceToLogicalYRel( y )
111 wxDC::DrawArc( x1, y1, x2, y2, xc, yc )
120 wxDC::DrawBitmap( bitmap, x, y, transparent )
126 THIS->DrawBitmap( *bitmap, x, y, transparent );
129 wxDC::DrawCheckMark( ... )
132 MATCH_REDISP( wxPliOvl_n_n_n_n, DrawCheckMarkXYWH )
133 MATCH_REDISP( wxPliOvl_wrec, DrawCheckMarkRect )
134 END_OVERLOAD( Wx::DC::DrawCheckMark )
137 wxDC::DrawCheckMarkXYWH( x, y, width, height )
143 THIS->DrawCheckMark( x, y, width, height );
146 wxDC::DrawCheckMarkRect( rect )
149 THIS->DrawCheckMark( *rect );
152 wxDC::DrawCircle( x, y, radius )
158 wxDC::DrawEllipse( x, y, width, height )
165 wxDC::DrawEllipticArc( x, y, width, height, start, end )
174 wxDC::DrawIcon( icon, x, y )
179 THIS->DrawIcon( *icon, x, y );
182 wxDC::DrawLine( x1, y1, x2, y2 )
189 wxDC::DrawLines( list, xoffset = 0, yoffset = 0 )
194 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
199 wxPliArrayGuard<wxPoint> pts;
201 wxPli_av_2_pointlist( aTHX_ list, &points, pts.lvalue() );
202 THIS->DrawLines( &points, xoffset, yoffset );
205 wxDC::DrawPoint( x, y )
210 wxDC::DrawPolygon( list, xoffset, yoffset, fill_style = wxODDEVEN_RULE )
214 wxPolygonFillMode fill_style
216 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
221 wxPliArrayGuard<wxPoint> pts;
223 wxPli_av_2_pointlist( aTHX_ list, &points, pts.lvalue() );
224 THIS->DrawPolygon( &points, xoffset, yoffset, fill_style );
227 wxDC::DrawRectangle( x, y, width, height )
234 wxDC::DrawRotatedText( text, x, y, angle )
241 wxDC::DrawRoundedRectangle( x, y, width, height, radius = 20 )
249 wxDC::DrawSpline( list )
252 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
257 wxPliArrayGuard<wxPoint> pts;
259 wxPli_av_2_pointlist( aTHX_ list, &points, pts.lvalue() );
260 THIS->DrawSpline( &points );
263 wxDC::DrawText( text, x, y )
271 #if WXPERL_W_VERSION_LT( 2, 7, 0 ) || WXWIN_COMPATIBILITY_2_6
282 wxDC::FloodFill( x, y, colour, style = wxFLOOD_SURFACE )
286 wxFloodFillStyle style
288 THIS->FloodFill( x, y, *colour, style );
290 #if WXPERL_W_VERSION_GE( 2, 7, 2 )
293 wxDC::GetAsBitmap( wxRect* subrect = NULL )
295 RETVAL = new wxBitmap( THIS->GetAsBitmap( subrect ) );
301 wxDC::GetBackground()
303 RETVAL = new wxBrush( THIS->GetBackground() );
308 wxDC::GetBackgroundMode()
313 RETVAL = new wxBrush( THIS->GetBrush() );
318 wxDC::GetCharHeight()
324 wxDC::GetClippingBox()
326 wxCoord x, y, width, height;
328 THIS->GetClippingBox( &x, &y, &width, &height );
330 PUSHs( sv_2mortal( newSViv( x ) ) );
331 PUSHs( sv_2mortal( newSViv( y ) ) );
332 PUSHs( sv_2mortal( newSViv( width ) ) );
333 PUSHs( sv_2mortal( newSViv( height ) ) );
338 RETVAL = new wxFont( THIS->GetFont() );
342 wxRasterOperationMode
343 wxDC::GetLogicalFunction()
348 #if !defined( __WXMAC__ ) && WXPERL_W_VERSION_LE( 2, 5, 3 )
351 wxDC::GetOptimization()
358 RETVAL = new wxPen( THIS->GetPen() );
363 wxDC::GetPixel( x, y )
369 THIS->GetPixel( x, y, &c );
370 RETVAL = new wxColour( c );
377 RETVAL = new wxSize( THIS->GetSize() );
386 THIS->GetSize( &x, &y );
388 PUSHs( sv_2mortal( newSViv( x ) ) );
389 PUSHs( sv_2mortal( newSViv( y ) ) );
394 RETVAL = new wxSize( THIS->GetSizeMM() );
403 THIS->GetSizeMM( &x, &y );
405 PUSHs( sv_2mortal( newSViv( x ) ) );
406 PUSHs( sv_2mortal( newSViv( y ) ) );
411 RETVAL = new wxSize( THIS->GetPPI() );
416 wxDC::GetTextBackground()
418 RETVAL = new wxColour( THIS->GetTextBackground() );
423 wxDC::GetTextExtent( string, font = NULL )
427 wxCoord x, y, descent, externalLeading;
429 THIS->GetTextExtent( string, &x, &y, &descent, &externalLeading,
432 PUSHs( sv_2mortal( newSViv( x ) ) );
433 PUSHs( sv_2mortal( newSViv( y ) ) );
434 PUSHs( sv_2mortal( newSViv( descent ) ) );
435 PUSHs( sv_2mortal( newSViv( externalLeading ) ) );
438 wxDC::GetPartialTextExtents( string )
443 bool ok = THIS->GetPartialTextExtents( string, widths );
446 wxPli_intarray_push( aTHX_ widths );
452 wxDC::GetMultiLineTextExtent( string, font = NULL )
458 THIS->GetMultiLineTextExtent( string, &w, &h, &hLine, font );
460 PUSHs( sv_2mortal( newSViv( w ) ) );
461 PUSHs( sv_2mortal( newSViv( h ) ) );
462 PUSHs( sv_2mortal( newSViv( hLine ) ) );
465 wxDC::GetTextForeground()
467 RETVAL = new wxColour( THIS->GetTextForeground() );
476 THIS->GetUserScale( &x, &y );
478 PUSHs( sv_2mortal( newSVnv( x ) ) );
479 PUSHs( sv_2mortal( newSVnv( y ) ) );
481 #if WXPERL_W_VERSION_GE( 2, 7, 2 )
484 wxDC::GradientFillLinear( rect, initialColour, destColour, direction = wxEAST )
486 wxColour initialColour
488 wxDirection direction
489 C_ARGS: *rect, initialColour, destColour, direction
494 wxDC::LogicalToDeviceX( x )
498 wxDC::LogicalToDeviceXRel( x )
502 wxDC::LogicalToDeviceY( y )
506 wxDC::LogicalToDeviceYRel( y )
521 #if WXPERL_W_VERSION_GE( 2, 8, 0 )
529 RETVAL = THIS->IsOk();
540 wxDC::ResetBoundingBox()
543 wxDC::SetAxisOrientation( xLeftRight, yBottomUp )
551 wxDC::GetDeviceOrigin()
553 RETVAL = new wxPoint( THIS->GetDeviceOrigin() );
557 wxDC::SetDeviceOrigin( x, y )
562 wxDC::SetBackground( brush )
565 THIS->SetBackground( *brush );
568 wxDC::SetBackgroundMode( mode )
572 wxDC::SetBrush( brush )
575 THIS->SetBrush( *brush );
578 wxDC::SetClippingRegion( ... )
581 MATCH_REDISP( wxPliOvl_n_n_n_n, SetClippingRegionXYWH )
582 MATCH_REDISP( wxPliOvl_wreg, SetClippingRegionRegion )
583 END_OVERLOAD( Wx::DC::SetClippingRegion )
586 wxDC::SetClippingRegionXYWH( x, y, w, h )
592 THIS->SetClippingRegion( x, y, w, h );
595 wxDC::SetClippingRegionRegion( region )
598 THIS->SetClippingRegion( *region );
601 wxDC::SetFont( font )
604 THIS->SetFont( *font );
607 wxDC::SetLogicalFunction( function )
608 wxRasterOperationMode function
611 wxDC::SetMapMode( mode )
614 #if !defined( __WXMAC__ ) && WXPERL_W_VERSION_LE( 2, 5, 3 )
617 wxDC::SetOptimization( optimize )
623 wxDC::SetPalette( palette )
626 THIS->SetPalette( *palette );
632 THIS->SetPen( *pen );
635 wxDC::SetTextBackground( colour )
638 THIS->SetTextBackground( *colour );
641 wxDC::SetTextForeground( colour )
644 THIS->SetTextForeground( *colour );
647 wxDC::SetUserScale( xScale, yScale )
652 wxDC::StartDoc( message )
659 wxDC::GetLogicalScale()
663 THIS->GetLogicalScale( &x, &y );
665 PUSHs( sv_2mortal( newSVnv( x ) ) );
666 PUSHs( sv_2mortal( newSVnv( y ) ) );
669 wxDC::SetLogicalScale( double x, double y );
671 #if WXPERL_W_VERSION_GE( 2, 7, 1 )
674 wxDC::GetLayoutDirection()
677 wxDC::SetLayoutDirection( wxLayoutDirection dir )
681 MODULE=Wx PACKAGE=Wx::ScreenDC
687 wxScreenDC::EndDrawingOnTop()
690 wxScreenDC::StartDrawingOnTop( ... )
693 MATCH_REDISP( wxPliOvl_wwin, StartDrawingOnTopWindow )
694 MATCH_REDISP( wxPliOvl_wrec, StartDrawingOnTopRect )
695 END_OVERLOAD( Wx::ScreenDC::StartDrawingOnTop )
698 wxScreenDC::StartDrawingOnTopWindow( window )
701 RETVAL = THIS->StartDrawingOnTop( window );
706 wxScreenDC::StartDrawingOnTopRect( rect )
709 RETVAL = THIS->StartDrawingOnTop( rect );
713 MODULE=Wx PACKAGE=Wx::WindowDC
716 wxWindowDC::new( window )
719 MODULE=Wx PACKAGE=Wx::PaintDC
722 wxPaintDC::new( window )
725 MODULE=Wx PACKAGE=Wx::MemoryDC
731 wxMemoryDC::SelectObject( bitmap )
735 #if WXPERL_W_VERSION_GE( 2, 7, 2 )
738 wxMemoryDC::SelectObjectAsSource( bitmap )
744 MODULE=Wx PACKAGE=Wx::ClientDC
747 wxClientDC::new( window )
754 %typemap{wxBufferedDC*}{simple};
755 %typemap{wxBufferedPaintDC*}{simple};
756 %typemap{wxAutoBufferedPaintDC*}{simple};
757 %typemap{wxMirrorDC*}{simple};
758 %typemap{wxDCClipper*}{simple};
760 %name{Wx::BufferedDC} class wxBufferedDC
762 %name{newDefault} wxBufferedDC();
763 #if WXPERL_W_VERSION_GE( 2, 6, 0 )
764 %name{newBitmap} wxBufferedDC( wxDC *dc,
765 const wxBitmap &buffer = wxNullBitmapPtr,
766 int style = wxBUFFER_CLIENT_AREA );
767 %name{newSize} wxBufferedDC( wxDC *dc, const wxSize &area,
768 int style = wxBUFFER_CLIENT_AREA );
769 %name{InitBitmap} void Init( wxDC *dc,
770 const wxBitmap &buffer = wxNullBitmapPtr,
771 int style = wxBUFFER_CLIENT_AREA );
772 %name{InitSize} void Init( wxDC *dc, const wxSize &area,
773 int style = wxBUFFER_CLIENT_AREA );
775 %name{newBitmap} wxBufferedDC( wxDC *dc,
776 const wxBitmap &buffer = wxNullBitmapPtr );
777 %name{newSize} wxBufferedDC( wxDC *dc, const wxSize &area );
778 %name{InitBitmap} void Init( wxDC *dc,
779 const wxBitmap &buffer = wxNullBitmapPtr );
780 %name{InitSize} void Init( wxDC *dc, const wxSize &area );
788 MATCH_VOIDM_REDISP( newDefault )
789 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wdc_wsiz_n, newSize, 2 )
790 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wdc_wbmp_n, newBitmap, 1 )
791 END_OVERLOAD( "Wx::BufferedDC::new" )
797 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wdc_wsiz_n, InitSize, 2 )
798 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wdc_wbmp_n, InitBitmap, 1 )
799 END_OVERLOAD( "Wx::BufferedDC::Init" )
803 #if WXPERL_W_VERSION_GE( 2, 6, 0 )
804 void SetStyle( int style );
809 %name{Wx::BufferedPaintDC} class wxBufferedPaintDC
811 #if WXPERL_W_VERSION_GE( 2, 5, 5 )
812 %name{newBitmap} wxBufferedPaintDC( wxWindow* window,
813 const wxBitmap& buffer,
814 int style = wxBUFFER_CLIENT_AREA );
815 %name{newWindow} wxBufferedPaintDC( wxWindow* window,
816 int style = wxBUFFER_CLIENT_AREA );
818 %name{newBitmap} wxBufferedPaintDC( wxWindow* window,
819 const wxBitmap& buffer );
820 %name{newWindow} wxBufferedPaintDC( wxWindow* window );
827 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wdc_wbmp_n, newBitmap, 2 )
828 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wdc_n, newBitmap, 1 )
829 END_OVERLOAD( "Wx::BufferedPaintDC::new" )
833 #if WXPERL_W_VERSION_GE( 2, 7, 2 )
835 %name{Wx::AutoBufferedPaintDC} class wxAutoBufferedPaintDC
837 wxAutoBufferedPaintDC( wxWindow* win );
841 MODULE=Wx PACKAGE=Wx PREFIX=wx
844 wxDC* wxAutoBufferedPaintDCFactory( wxWindow* window );
846 #include <wx/dcmirror.h>
848 %name{Wx::MirrorDC} class wxMirrorDC
850 wxMirrorDCC( wxDC& dc, bool mirror );
853 # DECLARE_OVERLOAD( wrgn, Wx::Region )
855 %name{Wx::DCClipper} class wxDCClipper
862 MATCH_REDISP( wxPliOvl_wdc_wrgn, newRegion )
863 MATCH_REDISP( wxPliOvl_wdc_wrec, newRect )
864 MATCH_REDISP( wxPliOvl_wdc_n_n_n_n, newXYWH )
865 END_OVERLOAD( Wx::DCClipper::new )
868 %name{newRegion} wxDCClipper( wxDC& dc, const wxRegion& region );
869 %name{newRect} wxDCClipper( wxDC& dc, const wxRect& rect );
870 %name{newXYWH} wxDCClipper( wxDC& dc, int x, int y, int w, int h );
876 wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
880 %code{% wxPli_thread_sv_unregister( aTHX_ "Wx::DCClipper", THIS, ST(0) );