How to get client rect of a component

Hello, everyone. As a newbie of JUCE, I might pop up a simple question. But I cannot find a proper way to get client rect in JUCE. On Windows, there’s a system API GetClientRect() to use. But in JUCE, I only found a couple of similar methods (e.g. getLocalArea(), which I don’t know how to utilize.

Could anyone kindly give me some tips? Thanks in advance!

You can use getBounds(), which returns a Rectangle with the Component’s bounds (x, y, width and height).
Anyway, there’s plenty of ways to know a Component’s coordinate, just take a look in juce_Component.h from line 265.

Thanks for your quick response, masshacker!

As far as I understand, getBounds() will return the bounding box, which includes the border of the window. What I expect is the area inside the border. Of course, normally the border will only take 1 or 2 pixels. But if the border is thicker, then what getBounds() returns might be quite different from what I want.

Why exactly do you want to know about the size of the window border?

Yes, the juce classes do provide a way to get the border size, but I suspect that you’re probably asking the wrong question. There are very very few situations where you doing maths involving the window frame is the best solution, so the chances are that there’s a more appropriate way of doing whatever it is that you’re actually trying to do?

I don’t think flower4wine really cares about the nature of the border, but instead the client rectangle inside the borders of a top level window. (?)

Yes, but my point is why does he want to know that?

I’ve seen so many forum conversations like this over the years:

A: “How do I do [low level platform-specific obscure thing]?”
B: “Why do you actually want to do that?”
A: “Oh, I need it so I can do [high level behaviour]”
B: “Then you should just use the doHighLevelThing() function.”
A: “Thanks, I didn’t know that existed!”

To Mike: yeah, that’s what I want. Thanks :smiley:

To Jules: The hearsay is true. You really reply all questions here :smiley:

Well, I guess my work is different from most of other JUCE users. I’m working on an existing application, and now I want to port it to JUCE, as JUCE provides so great platforms compatibility. The porting work needs to implement some virtual methods of the application and one of them is to return client area. It’s difficult to change the existing application itself.

Anyway, I think I got the answer from all you guys’ kindly replies. I’ll combine high level materials to achieve my low level stuff, which is fortunately not so much.