Reputation: 1087
What is the preferred way to get the metric(s) for NSWindow border size? Basically I need to figure out in pixels how thick the window border is.
I've recently found myself needing to do this, but various solutions seem to be considerably outdated (i.e., Carbon and HITheme).
Upvotes: 0
Views: 966
Reputation: 90681
Basically, you use one of these NSWindow
methods to convert from a content rect to a frame rect or vice versa and then compare the two rects:
+contentRectForFrameRect:styleMask:
+frameRectForContentRect:styleMask:
-contentRectForFrameRect:
-frameRectForContentRect:
You use the class methods if you don't have a specific window to measure or if you want to ignore the presence of a toolbar.
For ages now, there is no "border" anywhere on windows other than the top (the title bar).
Upvotes: 2