How do you use region and PtRaw?

How do you use region and PtRaw?
Can illustrate them?

A good place to start would be knowing what they are for.

Regions are fundamental to Photon. Oversimplifying what the Photon kernel does is manage events moving in the Z axis (in or out) of the 3D Photon space. Regions are rectangles that are in an X/Y plane.

Regions can emit, absorb, or just detect events as they pass by. Events going in are things like mouse clicks and moves, and keyboard presses, so they are usually detected and absorbed by the first region they intersect. Events moving out are typically draw events, that are detected by a video driver region.

When writing a photon program, you usually do not have to handle regions directly very much, but you do have to understand where they fit in. Widgets are implemented as a set of library routines that run as part of the user application. They interact with the photon kernel by detecting and emitting various events.

The PtRaw Widget is a widget that specifically has its own region. Not all, and in fact most widgets do not. The PtRaw widget is usually used to detect specific “raw” input events using its region. These are typically mouse or keyboard events.

You could write code to create a region directly, place in the correct Z location, and cause it to detect and/or absorb specific events. This would involve using the lower level Photon routines, and is not advised unless you are avoiding using the widget libraries entirely.

A good easy place to start conceptualizing all this is to bring up one of the region display utilities, and compare what you see to what is on the screen.

As a final note, its good to know how the window manager fits into all of this. When you write a Photon Widget program, you typically build your application into one or more window widgets. These widgets know how to interact directly with the window manager. I believe that it is the window manager that actually renders the window frame, buttons, and title. The window manager also mediates using the mouse to move, resize, and minimize windows.

It is at least theoretically possible to build your own window manager. There are a few different reasons you might want to do this. For example, you might want a window manager for your embedded system that restricts the user in ways that the default manager does not. You could even write a system that does not use the manager at all.

An interesting way to learn what exactly the window manager does for you is to kill it, and see what is left. Of course you will probably need to reboot, or at least turn off Photon after trying this.

Setting up a PtRaw widget the way you want is fairly straight forward using the application builder. Like any widget, you can place it in your window, and set its size. You also can choose which events you want your callback to hear about. The callback gets called with structures that give you detailed information about the event that has occured.

Using regions directly would be a little complicated to describe here in detail.
Now with some basics down, do you want to refine your question?

Thank you for your explain!!!

As I know, PtRaw don’t have its own region( try to do PtGetRid(PtRaw_wgt) - return 0 so i think he has main region with cliping events)

Well I got curious, and I took a look and found that I am completely wrong about the PtRaw widget. It’s purpose is to give you a place to draw so that if your drawing is damaged, by for example being put behind another window, a callback is called to repair the damage.

It seems like most if not all widgets can get raw events, and since there is no special region created, qnxloader must be right about the clipping.