2009-12-01 16:56 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* harbour/contrib/hbcairo/context.c
* harbour/contrib/hbcairo/paths.c
* harbour/contrib/hbcairo/text.c
* harbour/contrib/hbcairo/tests/table.prg
* added some error check. If function parameters are invalid C level
functions is not called with invalid (NULL) pointers.
* changed cairo_text_extent() to return an array of .c structure
members instead of returning multiple values using parameters
passed by reference. In the future I'll try to follow this way
to return structures.
This commit is contained in:
@@ -17,6 +17,18 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-12-01 16:56 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
|
||||
* harbour/contrib/hbcairo/context.c
|
||||
* harbour/contrib/hbcairo/paths.c
|
||||
* harbour/contrib/hbcairo/text.c
|
||||
* harbour/contrib/hbcairo/tests/table.prg
|
||||
* added some error check. If function parameters are invalid C level
|
||||
functions is not called with invalid (NULL) pointers.
|
||||
* changed cairo_text_extent() to return an array of .c structure
|
||||
members instead of returning multiple values using parameters
|
||||
passed by reference. In the future I'll try to follow this way
|
||||
to return structures.
|
||||
|
||||
2009-12-01 16:39 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
|
||||
* harbour/contrib/hbwin/olecore.c
|
||||
* harbour/contrib/hbwin/axcore.c
|
||||
|
||||
@@ -56,71 +56,95 @@
|
||||
|
||||
HB_FUNC( CAIRO_CREATE )
|
||||
{
|
||||
hb_cairo_ret( cairo_create( hb_cairo_surface_param( 1 ) ) );
|
||||
cairo_surface_t * pSurface = hb_cairo_surface_param( 1 );
|
||||
if( pSurface )
|
||||
hb_cairo_ret( cairo_create( pSurface ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_FILL )
|
||||
{
|
||||
cairo_fill( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_fill( pCairo );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_FILL_PRESERVE )
|
||||
{
|
||||
cairo_fill_preserve( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_fill_preserve( pCairo );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_RESTORE )
|
||||
{
|
||||
cairo_restore( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_restore( pCairo );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_SAVE )
|
||||
{
|
||||
cairo_save( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_save( pCairo );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_SET_LINE_CAP )
|
||||
{
|
||||
cairo_set_line_cap( hb_cairo_param( 1 ), hb_parni( 2 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_set_line_cap( pCairo, hb_parni( 2 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_SET_LINE_WIDTH )
|
||||
{
|
||||
cairo_set_line_width( hb_cairo_param( 1 ), hb_parnd( 2 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_set_line_width( pCairo, hb_parnd( 2 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_SET_SOURCE_RGB )
|
||||
{
|
||||
cairo_set_source_rgb( hb_cairo_param( 1 ), hb_parnd( 2 ), hb_parnd( 3 ), hb_parnd( 4 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_set_source_rgb( pCairo, hb_parnd( 2 ), hb_parnd( 3 ), hb_parnd( 4 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_SET_TOLERANCE )
|
||||
{
|
||||
cairo_set_tolerance( hb_cairo_param( 1 ), hb_parnd( 2 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_set_tolerance( pCairo, hb_parnd( 2 ) );
|
||||
}
|
||||
|
||||
HB_FUNC( CAIRO_SHOW_PAGE )
|
||||
{
|
||||
cairo_show_page( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_show_page( pCairo );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_STROKE )
|
||||
{
|
||||
cairo_stroke( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_stroke( pCairo );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_STROKE_PRESERVE )
|
||||
{
|
||||
cairo_stroke_preserve( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_stroke_preserve( pCairo );
|
||||
}
|
||||
|
||||
|
||||
@@ -57,80 +57,109 @@
|
||||
|
||||
HB_FUNC( CAIRO_APPEND_PATH )
|
||||
{
|
||||
cairo_append_path( hb_cairo_param( 1 ), hb_cairo_path_param( 2 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
cairo_path_t * pPath = hb_cairo_path_param( 2 );
|
||||
if( pCairo && pPath )
|
||||
cairo_append_path( pCairo, pPath );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_CLOSE_PATH )
|
||||
{
|
||||
cairo_close_path( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_close_path( pCairo );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_COPY_PATH )
|
||||
{
|
||||
hb_cairo_path_ret( cairo_copy_path( hb_cairo_param( 1 ) ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
hb_cairo_path_ret( cairo_copy_path( pCairo ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_COPY_PATH_FLAT )
|
||||
{
|
||||
hb_cairo_path_ret( cairo_copy_path_flat( hb_cairo_param( 1 ) ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
hb_cairo_path_ret( cairo_copy_path_flat( pCairo ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_CURVE_TO )
|
||||
{
|
||||
cairo_curve_to( hb_cairo_param( 1 ), hb_parnd( 2 ), hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ), hb_parnd( 6 ), hb_parnd( 7 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_curve_to( pCairo, hb_parnd( 2 ), hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ), hb_parnd( 6 ), hb_parnd( 7 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_LINE_TO )
|
||||
{
|
||||
cairo_line_to( hb_cairo_param( 1 ), hb_parnd( 2 ), hb_parnd( 3 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_line_to( pCairo, hb_parnd( 2 ), hb_parnd( 3 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_MOVE_TO )
|
||||
{
|
||||
cairo_move_to( hb_cairo_param( 1 ), hb_parnd( 2 ), hb_parnd( 3 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_move_to( pCairo, hb_parnd( 2 ), hb_parnd( 3 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_NEW_PATH )
|
||||
{
|
||||
cairo_new_path( hb_cairo_param( 1 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_new_path( pCairo );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_RECTANGLE )
|
||||
{
|
||||
cairo_rectangle( hb_cairo_param( 1 ), hb_parnd( 2 ), hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_rectangle( pCairo, hb_parnd( 2 ), hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_REL_CURVE_TO )
|
||||
{
|
||||
cairo_rel_curve_to( hb_cairo_param( 1 ), hb_parnd( 2 ), hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ), hb_parnd( 6 ), hb_parnd( 7 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_rel_curve_to( pCairo, hb_parnd( 2 ), hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ), hb_parnd( 6 ), hb_parnd( 7 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_REL_LINE_TO )
|
||||
{
|
||||
cairo_rel_line_to( hb_cairo_param( 1 ), hb_parnd( 2 ), hb_parnd( 3 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_rel_line_to( pCairo, hb_parnd( 2 ), hb_parnd( 3 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_REL_MOVE_TO )
|
||||
{
|
||||
cairo_rel_move_to( hb_cairo_param( 1 ), hb_parnd( 2 ), hb_parnd( 3 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_rel_move_to( pCairo, hb_parnd( 2 ), hb_parnd( 3 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_TEXT_PATH )
|
||||
{
|
||||
void * hText;
|
||||
cairo_text_path( hb_cairo_param( 1 ), hb_parstr_utf8( 2, &hText, NULL ) );
|
||||
hb_strfree( hText );
|
||||
void * hText;
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
{
|
||||
cairo_text_path( pCairo, hb_parstr_utf8( 2, &hText, NULL ) );
|
||||
hb_strfree( hText );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,10 +52,8 @@ STATIC PROC draw_table( hCairo, nX, nY, aCol )
|
||||
DBGOTOP()
|
||||
aWidth := ARRAY( LEN( aCol ) )
|
||||
FOR nI := 1 TO LEN( aCol )
|
||||
cairo_text_extents( hCairo, REPLICATE( "9", FIELDLEN( FIELDPOS( aCol[ nI, 2 ] ) ) ),,,,, @nDX )
|
||||
aWidth[ nI ] := nDX
|
||||
cairo_text_extents( hCairo, aCol[ nI, 1 ],,,,, @nDX )
|
||||
aWidth[ nI ] := MAX( aWidth[ nI ], nDX ) + 20
|
||||
aWidth[ nI ] := cairo_text_extents( hCairo, REPLICATE( "9", FIELDLEN( FIELDPOS( aCol[ nI, 2 ] ) ) ) )[ 5 ]
|
||||
aWidth[ nI ] := MAX( aWidth[ nI ], cairo_text_extents( hCairo, aCol[ nI, 1 ] )[ 5 ] ) + 20
|
||||
NEXT
|
||||
nW := 0
|
||||
AEVAL( aWidth, {|X| nW += X} )
|
||||
@@ -123,7 +121,6 @@ RETURN
|
||||
STATIC PROC show_text_center( hCairo, cText )
|
||||
LOCAL nDX
|
||||
cairo_text_extents( hCairo, cText,,,,, @nDX )
|
||||
? nDX
|
||||
cairo_rel_move_to( hCairo, -nDX/2, 0 )
|
||||
cairo_show_text( hCairo, cText )
|
||||
RETURN
|
||||
|
||||
@@ -57,37 +57,54 @@
|
||||
|
||||
HB_FUNC( CAIRO_SELECT_FONT_FACE )
|
||||
{
|
||||
void * hFamily;
|
||||
cairo_select_font_face( hb_cairo_param( 1 ), hb_parstr_utf8( 2, &hFamily, NULL ), ( cairo_font_slant_t ) hb_parni( 3 ), ( cairo_font_weight_t ) hb_parni( 4 ) );
|
||||
hb_strfree( hFamily );
|
||||
void * hFamily;
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
{
|
||||
cairo_select_font_face( pCairo, hb_parstr_utf8( 2, &hFamily, NULL ), ( cairo_font_slant_t ) hb_parni( 3 ), ( cairo_font_weight_t ) hb_parni( 4 ) );
|
||||
hb_strfree( hFamily );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_SET_FONT_SIZE )
|
||||
{
|
||||
cairo_set_font_size( hb_cairo_param( 1 ), hb_parnd( 2 ) );
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
cairo_set_font_size( pCairo, hb_parnd( 2 ) );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_SHOW_TEXT )
|
||||
{
|
||||
void * hText;
|
||||
cairo_show_text( hb_cairo_param( 1 ), hb_parstr_utf8( 2, &hText, NULL ) );
|
||||
hb_strfree( hText );
|
||||
void * hText;
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
if( pCairo )
|
||||
{
|
||||
cairo_show_text( pCairo, hb_parstr_utf8( 2, &hText, NULL ) );
|
||||
hb_strfree( hText );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( CAIRO_TEXT_EXTENTS )
|
||||
{
|
||||
void * hText;
|
||||
void * hText;
|
||||
cairo_t * pCairo = hb_cairo_param( 1 );
|
||||
cairo_text_extents_t te;
|
||||
cairo_text_extents( hb_cairo_param( 1 ), hb_parstr_utf8( 2, &hText, NULL ), &te );
|
||||
hb_strfree( hText );
|
||||
hb_stornd( te.x_bearing, 3 );
|
||||
hb_stornd( te.y_bearing, 4 );
|
||||
hb_stornd( te.width, 5 );
|
||||
hb_stornd( te.height, 6 );
|
||||
hb_stornd( te.x_advance, 7 );
|
||||
hb_stornd( te.y_advance, 8 );
|
||||
if( pCairo )
|
||||
{
|
||||
PHB_ITEM pItem = hb_stackReturnItem();
|
||||
|
||||
cairo_text_extents( pCairo, hb_parstr_utf8( 2, &hText, NULL ), &te );
|
||||
hb_strfree( hText );
|
||||
hb_arrayNew( pItem, 6 )
|
||||
hb_arraySetND( pItem, 1, te.x_bearing );
|
||||
hb_arraySetND( pItem, 2, te.y_bearing );
|
||||
hb_arraySetND( pItem, 3, te.width );
|
||||
hb_arraySetND( pItem, 4, te.height );
|
||||
hb_arraySetND( pItem, 5, te.x_advance );
|
||||
hb_arraySetND( pItem, 6, te.y_advance );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user