An alternate approach would be to not try to create the pens, but just update an existing pen's color and width from a lookup table. This might be more efficient use of resources as well ... but I would really like to understand this a little better.
Both of the class predicate declarations for paintPen/1 below cause c504 errors:
Code: Select all
class predicates % for the lookup table
p : ( integer PenNum, unsigned Color, real Width ) determ (i,o,o).
clauses
p( 0, color::darkred, 1 ).
p( 1, color::darkblue, 1 ).
class predicates
% paintPen : ( integer PenNum ) -> gdiplus_native::gpPen.
% error c504 : The expression has type 'pen', which is incompatible with the type 'gdiplus_native::gpPen'
paintPen : ( integer PenNum ) -> pen.
% error c504 : The expression has type 'pen', which is incompatible with the type 'vpiDomains::
clauses
paintPen( PNO ) = P :-
p(PNO,C,Width),
!,
PColor = color::create(C),
P = pen::createColor( PColor, Width, unitPixel ).
paintPen( _ ) = pen::createColor( color::create( color::black ), 1, unitPixel ).
