FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rect, Point, Color, FontData, etc

 
Post new topic   Reply to topic     Forum Index -> MinWin
View previous topic :: View next topic  
Author Message
BenHinkle



Joined: 27 Mar 2004
Posts: 76

PostPosted: Tue Mar 01, 2005 9:20 pm    Post subject: Rect, Point, Color, FontData, etc Reply with quote

I think I'm going to experiment a bit with the API to see how a different style feels. Currently the types Rect, Point, etc are all aliases for the native corresponding type. This means, though, that most uses will be through top-level functions since different systems have different names for the fields of the native types. For example
Code:

alias RECT Rect;
int rectL(inout Rect r){ return r.left; }

This can get verbose and the code ends up looking worse than the native equivalent. The upside is that passing these types to native functions is transparent.
What I want to try is a more standard set of definitions like
Code:

struct Rect {
  RECT native;
  int left(){ return native.left; }
}

This means if r is a Rect you can't use r.left as an l-value and you have to use r.native when calling native functions. The upside is that the generic code ends up looking nicer.

Anyhow, I'm going to spend a little time to try out the other style. It would apply to Rect, Point, Color, FontData, FontMetrics, PenData, Event(s). Note that this is different than the "peer" property since a peer is managed by the OS and this "native" property is just a native type without any system resource attached to it.

Any preference?
Back to top
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Wed Mar 02, 2005 7:52 am    Post subject: Reply with quote

I think the new way would be the right way.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
BenHinkle



Joined: 27 Mar 2004
Posts: 76

PostPosted: Thu Mar 03, 2005 7:39 am    Post subject: Reply with quote

Carlos wrote:
I think the new way would be the right way.


I've done the windows code and it does look better so I'll go ahead and convert the Unix versions, too.

One other difference is that a static array of Points now needs to be wrapped in two brackets:
Code:
Point[] pts = [{{0,0}},{{10,20}},{{30,40}}];

and generally more ".native" references have to be added.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MinWin All times are GMT - 6 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group