Discussions related to Visual Prolog
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

GDI+ pen domain question

Unread post by Harrison Pratt »

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:

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 ).
ADDENDUM: However, if I put the paintPen/1 declaration in the .cl file instead of the .pro file, everything compiles nicely. :o
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

You have opened vpiDomains in the top of your implementation, therefore pen is vpiDomains::pen.

The gdi+ pen is a global interface, which is shadowed by vpiDomains::pen (due to the open).

You can however reference the global pen by prefixing it with '::':
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Unread post by Harrison Pratt »

Thank you, Thomas!

I did not remember Global Entities Access in the Wiki: http://wiki.visual-prolog.com/index.php ... ies_Access.
Post Reply