An application window that's managed by the Photon Window Manager
PtWidget → PtBasic → PtContainer → PtDisjoint → PtWindow
For more information, see the diagram of the widget hierarchy.
None — use PhAB's Window or Dialog module.
<photon/PtWindow.h>
The PtWindow class provides a top-level container for your applications' widgets. It also provides a standard appearance for all windows. Windows are managed by the Photon Window Manager if it's present (PtForwardWindowEvent() sends window events to the Window Manager — see the Photon Library Reference).
The frame and title bar aren't part of the PtWindow widget; the window manager adds them. The value of the widget's Pt_ARG_DIM resource doesn't include the frame, but you can call PtWindowGetFrameSize() to determine the size of the frame.
|
The PtWindow class handles the details of opening a Photon window and displaying the widget hierarchy in it. It also tells the Window Manager what controls to place in the frame around the application window. This gives a standard appearance to the windows of all applications using the Photon widget library.
Using resources, you can choose which elements of the window frame will be displayed. You can control which window management functions the Window Manager will perform, and whether they're invoked from the window menu or from one of the window controls. You can also have your application notified when the user has requested a window management function, regardless of whether or not the Window Manager will perform that function.
You can specify the string displayed in the window's title bar by setting the Pt_ARG_WINDOW_TITLE resource.
You control the elements displayed in the window frame using the Pt_ARG_WINDOW_RENDER_FLAGS resource. Enable or disable a window-frame element by setting or clearing the appropriate bit.
The Pt_ARG_WINDOW_RENDER_FLAGS resource also has one of the following bits set to specify how the window and its frame are displayed and behave:
If you need to control the maximum and minimum possible sizes for the window, use the Pt_ARG_MAXIMUM_DIM and Pt_ARG_MINIMUM_DIM resources defined by PtWidget.
The following resources also control the window's size:
You can control how the Window Manager operates on your window by setting Pt_ARG_WINDOW_MANAGED_FLAGS.
Every flag in the resource corresponds to an operation the Window Manager can perform on the window. If the flag is set, the Window Manager lets you perform that operation. If a flag isn't set, the Window Manager disables the operation.
Each operation is identified by the name of the flag that enables/disables it. Here are the operations the Window Manager lets you perform on a window:
You may also tell the Window Manager to notify the application after it has done a Window Manager operation. This behavior is controlled by the Pt_ARG_WINDOW_NOTIFY_FLAGS resource. This resource consists of the same set of flags as the Pt_ARG_WINDOW_MANAGED_FLAGS resource.
Setting a flag in this resource tells the Window Manager that it should send an event to the application whenever the corresponding operation is performed on the window widget. The event sent to the application is handled by the window's Pt_CB_WINDOW callbacks.
The callback data for these callbacks consists of a pointer to a window event structure, PhWindowEvent_t (described in the Photon Library Reference).
Some parts of the UI, such as toolbars, palettes, or dialogs, may reside outside the main application window in windows of their own. These windows are usually subwindows of the main application window.
A subwindow is obtained by creating a window widget as the child of another window widget. A subwindow can't be placed behind its parent. The subwindows associated with a window are also iconified as a group whenever the window itself is iconified.
Resource | C type | Pt type | Default |
---|---|---|---|
Pt_ARG_MAX_HEIGHT | short | Scalar | 0 (See below) |
Pt_ARG_MAX_WIDTH | short | Scalar | 0 (See below) |
Pt_ARG_MIN_HEIGHT | short | Scalar | 0 (See below) |
Pt_ARG_MIN_WIDTH | short | Scalar | 0 (See below) |
Pt_ARG_WINDOW_ACTIVE_COLOR | PgColor_t | Scalar | See below |
Pt_ARG_WINDOW_FLAGS | unsigned short | Flag | See below |
Pt_ARG_WINDOW_FRONT_WINDOW | PhRid_t | Scalar | 0 |
Pt_ARG_WINDOW_HELP_ROOT | char * | String | NULL |
Pt_ARG_WINDOW_INACTIVE_COLOR | PgColor_t | Scalar | See below |
Pt_ARG_WINDOW_MANAGED_FLAGS | unsigned long | Flag | See below |
Pt_ARG_WINDOW_NOTIFY_FLAGS | unsigned long | Flag | See below |
Pt_ARG_WINDOW_RENDER_FLAGS | unsigned long | Flag | See below |
Pt_ARG_WINDOW_STATE | unsigned long | Flag | See below |
Pt_ARG_WINDOW_TITLE | char * | String | "Untitled" |
Pt_ARG_WINDOW_TITLE_COLOR | PgColor_t | Scalar | See below |
Pt_CB_WINDOW | PtCallback_t * | Link | NULL |
Pt_CB_WINDOW_CLOSING | PtCallback_t * | Link | NULL |
Pt_CB_WINDOW_OPENING | PtCallback_t * | Link | NULL |
Pt_CB_WINDOW_TRANSPORT | PtCallback_t * | Link | NULL |
C type | Pt type | Default |
---|---|---|
short | Scalar | 0 (See below) |
The maximum height of the window. If you set this resource to 0, the default value specified by the window manager is used.
C type | Pt type | Default |
---|---|---|
short | Scalar | 0 (see below) |
The maximum width of the widget. If you set this resource to 0, the default value specified by the window manager is used.
C type | Pt type | Default |
---|---|---|
short | Scalar | 0 (See below) |
The minimum height of the widget. If you set this resource to 0, the default value specified by the window manager is used.
C type | Pt type | Default |
---|---|---|
short | Scalar | 0 (See below) |
The minimum width of the widget. If you set this resource to 0, the default value specified by the window manager is used.
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Pg_DEFAULT_WM_COLOR |
The color of the window's frame when the window has focus. This overrides the color specified by the window manager.
C type | Pt type | Default |
---|---|---|
unsigned short | Flag | Pt_WINDOW_FRAME_BLOCKABLE |
This resource has a single bit, Pt_WINDOW_FRAME_BLOCKABLE. It controls whether the Window Manager knows that the window widget is blocked with the Pt_BLOCKED flag in Pt_ARG_FLAGS. If this bit is not set, a user can give the window focus and resize it, even if it's blocked.
C type | Pt type | Default |
---|---|---|
PhRid_t | Scalar | 0 |
Specifies the region ID of the window that this window is to be positioned behind.
C type | Pt type | Default |
---|---|---|
char * | String | NULL |
Defines the root topic path for the window. For more information, see the PtHelp*() functions in the Photon Library Reference and the Context-Sensitive Help chapter of the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Pg_DEFAULT_WM_COLOR |
The color of the window's frame when the window doesn't have focus. This overrides the color specified by the window manager.
C type | Pt type | Default |
---|---|---|
unsigned long | Flag | Ph_WM_APP_DEF_MANAGED |
Controls which actions the Window Manager performs for the application, but doesn't affect whether or not the Window Manager notifies the application of those actions (for that, use Pt_ARG_WINDOW_NOTIFY_FLAGS). You can set the following bits:
If you set this bit: | the Window Manager: |
---|---|
Ph_WM_BACKDROP | Allows the window to be the workspace backdrop |
Ph_WM_CLOSE | Closes the application |
Ph_WM_COLLAPSE | Collapses the window to just the title bar |
Ph_WM_CONSWITCH | Moves the window to keep it on the visible display whenever the virtual Photon console is switched |
Ph_WM_FFRONT | Allows the window to become force front. To make the base window force front, set Ph_WM_STATE_ISFRONT in the Pt_ARG_WINDOW_STATE resource. |
Ph_WM_FOCUS | Handles gaining and losing focus for this window |
Ph_WM_HELP | Provides context-sensitive help |
Ph_WM_MAX | Maximizes the window |
Ph_WM_MENU | Pops up the window menu |
Ph_WM_MOVE | Moves the window |
Ph_WM_NO_FOCUS_LIST | Doesn't let you cycle focus to the window when you press Alt-Esc, Alt-Shift-Esc, or Alt-Tab |
Ph_WM_RESIZE | Resizes the application |
Ph_WM_RESTORE | Restores the window after it has been iconified, maximized, or hidden |
Ph_WM_TASKBAR | Includes the window in its taskbar |
Ph_WM_TOBACK | Sends the window to the back |
Ph_WM_TOFRONT | Sends the window to the front |
Ph_WM_HIDE | Hides the window |
The default is Ph_WM_APP_DEF_MANAGED, a convenience manifest that's defined in <PhWm.h> as:
#define Ph_WM_APP_DEF_MANAGED ( Ph_WM_CLOSE | \ Ph_WM_FOCUS | \ Ph_WM_MENU | \ Ph_WM_TOFRONT | \ Ph_WM_TOBACK | \ Ph_WM_RESIZE | \ Ph_WM_MOVE | \ Ph_WM_HIDE | \ Ph_WM_MAX | \ Ph_WM_RESTORE | \ Ph_WM_TASKBAR | \ Ph_WM_COLLAPSE)
C type | Pt type | Default |
---|---|---|
unsigned long | Flag | Ph_WM_RESIZE|Ph_WM_CLOSE| Ph_WM_HELP |
This resource controls which events the Pt_CB_WINDOW callbacks are invoked for. This resource doesn't cause the window manager to perform actions (for that, use Pt_ARG_WINDOW_MANAGED_FLAGS). Pt_ARG_WINDOW_NOTIFY_FLAGS uses the same set of bits as Pt_ARG_WINDOW_MANAGED_FLAGS, but the following bits have no notification associated with them:
C type | Pt type | Default |
---|---|---|
unsigned long | Flag | Ph_WM_APP_DEF_RENDER |
Controls how the Window Manager renders components of the window. The value of this resource is one of the following bits, which determine how the window and its frame look and feel:
as well as any combination of the following bits:
The default value is Ph_WM_APP_DEF_RENDER, a convenience manifest that's defined in <PhWm.h> as:
#define Ph_WM_APP_DEF_RENDER ( Ph_WM_RENDER_ASAPP | \ Ph_WM_RENDER_BORDER | \ Ph_WM_RENDER_RESIZE | \ Ph_WM_RENDER_MOVE | \ Ph_WM_RENDER_CLOSE | \ Ph_WM_RENDER_TITLE | \ Ph_WM_RENDER_MENU | \ Ph_WM_RENDER_MIN | \ Ph_WM_RENDER_MAX | \ Ph_WM_RENDER_COLLAPSE)
C type | Pt type | Default |
---|---|---|
unsigned long | Flag | Ph_WM_STATE_ISFOCUS |
This resource controls the window's state. You can set one of the following:
You can get and set the state of the window at any time by using this resource, but you might get unexpected results if the user is changing the window state at the same time. |
The safest time to use this resource to set the window state is before the window is realized. For example, you could set it when creating the PtWindow widget or in the window's Pt_CB_WINDOW_OPENING callback. The setting will be in effect when the window is realized.
You can set Pt_ARG_WINDOW_STATE after the window has been realized, basing your changes on what you think the current window state is, but it's safer to tell the window manager how you want to change the state, by calling:
C type | Pt type | Default |
---|---|---|
char * | String | "Untitled" |
The string that the Window Manager displays in the title bar.
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Pg_DEFAULT_WM_COLOR |
The color of the window's title (i.e. the text). This overrides the color specified by the window manager.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks that the widget invokes when it receives an event from the Window Manager. See Pt_ARG_WINDOW_NOTIFY_FLAGS.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
For an example of using this callback to verify that the user really wants to exit the application, see “Notification callback” in the Window Management chapter of the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks that the widget invokes when the window is being closed. It's invoked before the window's region is removed. These callbacks are invoked when the window is about to unrealize for any reason. This includes transporting to another Photon and explicit calls to PtDestroyWidget() or PtUnrealizeWidget(). If you want to make sure in a Window Closing callback that the window is actually being destroyed, check the Pt_DESTROYED flag in Pt_ARG_FLAGS. You can also use the Pt_CB_DESTROYED callback to know when a window is marked for destruction, or Pt_CB_IS_DESTROYED to know when it is being destroyed.
The Pt_CB_WINDOW_CLOSING callbacks are invoked when the window is already closing. To be notified before the window is closed, use the Ph_WM_CLOSE bit in Pt_ARG_WINDOW_NOTIFY_FLAGS and the Pt_CB_WINDOW callback. |
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks that the widget invokes when the window is being opened. If you want to resize the window and want anchoring to be in effect, do it in this type of callback.
The window hasn't been completely realized when the Pt_CB_WINDOW_OPENING callbacks are invoked; don't change the window's widget family hierarchy in these callbacks. If you need to adjust the widgets' stacking order, do it in the Pt_CB_REALIZED callbacks. |
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks that the widget invokes when the window is being transported through a Jump Gate.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
If the widget modifies an inherited resource, the “Default override” column indicates the new value. This modification affects any subclasses of the widget.
The PtWindow widget defines the following convenience functions: