GDI+ pen domain question
Posted: 19 Apr 2017 15:52
I am trying to create pens having colors and widths defined in a lookup table so that I can create a pen by an index number. Obviously, I don't understand the return domain for PEN. The debugger shows that a gdiplus_native::gpPen is created when I successfully create pens within the display code for a form.
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:
ADDENDUM: However, if I put the paintPen/1 declaration in the .cl file instead of the .pro file, everything compiles nicely.
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 ).