FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


GDI+ pen domain question

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog
View previous topic :: View next topic  
Author Message
Harrison Pratt



Des Moines, Iowa USA
Joined: 05 Nov 2000
Posts: 290

PostPosted: 19 Apr 2017 15:52    Post subject: GDI+ pen domain question Reply with quote

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:

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. Surprised
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3077

PostPosted: 25 Apr 2017 16:44    Post subject: Reply with quote

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 '::':

class predicates
    paintPen : ( integer PenNum ) -> ::pen.


_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Harrison Pratt



Des Moines, Iowa USA
Joined: 05 Nov 2000
Posts: 290

PostPosted: 26 Apr 2017 13:18    Post subject: Reply with quote

Thank you, Thomas!

I did not remember Global Entities Access in the Wiki: http://wiki.visual-prolog.com/index.php?title=Language_Reference/Terms#Global_Entities_Access.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum