Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptcalcabsposition.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptcalcabsposition.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptcalcabsposition.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptcalcabsposition.html on line 8

PtCalcAbsPosition()

Calculate the position of a widget based on a position and another widget

Synopsis:

int PtCalcAbsPosition( PtWidget_t *reference, 
                       PhPoint_t const *pos,
                       PhDim_t const *dim, 
                       PhPoint_t *new_pos );

Library:

ph

Description:

This function calculates the position of a new widget with dimensions dim, according to the reference widget and pos values passed.

The reference argument is a pointer to a widget you wish to position the new widget relative to. The pos argument is an offset from the reference widget or from the top left corner of the screen. The dim argument gives the dimensions of the new widget to be positioned and must not be NULL. The new_pos argument must be a pointer to a PhPoint_t structure. The calculated position is stored in it.

The position is calculated as follows:

Reference Position Position returned
NULL NULL center of the screen
NULL non-NULL offset pos from the top left corner of the screen
non-NULL NULL center of reference widget
non-NULL non-NULL offset pos from the reference widget's top left corner

Returns:

0
Success
-1
An error occurred. The dim or new_pos values might have been NULL.

Examples:

If you have a main application window and want to center a dialog on it, you could do the following:

PtWidget_t  *window;            // The main window
PhDim_t     dim = { 100, 100 }; // The size the dialog 
                                // is going to be
PhPoint_t   pos;                // The position of the dialog, 
                                // to be determined
int         err;

...
// make a main window
window = PtCreateWidget(PtWindow, Pt_NO_PARENT,
                        n_args, args);
...
err = PtCalcAbsPosition(window, NULL, &dim, &pos);
...
// Create the dialog and position it at 'pos' --
// it will be centered on the window.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PhDim_t, PhPoint_t


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptcalcabsposition.html on line 185

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptcalcabsposition.html on line 185