Resizing a Realized Widget

I’m actually doing this in Photon 1.14 but thought that the same might apply
in Photon 2.0

I’m attempting to create a widget and then change it’s size programatically.
Problem is when I send a PtSetResources(…) Nothing seems to happen.
Actually when I click in the area which is supposed to be the new window
size, the window is selected. But graphically it’s not shown. Can anyone
give me some help? Here is what I’m doing:

// Window Size Change
////////////////////////////////////
int CGraphicsWindow3D::ChangeWindowSize(int nXSize, int nYSize)
{
int rc;
PtArg_t args[2];

PhDim_t *oldDim = NULL;
PhDim_t newDim;

PhPoint_t *oldPos = NULL;
PhPoint_t newPos;

newDim.w = 0; newPos.x = 0;
newDim.h = 0; newPos.y = 0;

PtSetArg(&args[0], Pt_ARG_POS, &oldPos, 0);
PtSetArg(&args[1], Pt_ARG_DIM, &oldDim, 0);
// Get Current Dimensions
/////////////////////////
if(PtGetResources(m_window, 2, args) == -1)
rc = cRESP_FAILURE;
else
rc = cRESP_SUCCESS;

// Alter Dimensions
/////////////////////
if (oldDim && oldPos)
{
fprintf(stderr,“current Window(0x%08x) Pos(%d,%d) Size(%d,%d)”, m_window,
oldPos->x,oldPos->y,oldDim->w,oldDim->h);
newDim = *oldDim;
newDim.w += nXSize;
newDim.h += nYSize;

newPos = *oldPos;
fprintf(stderr," new Window(0x%08x) Pos(%d,%d) Size(%d,%d)", m_window,
oldPos->x,oldPos->y,oldDim->w,oldDim->h);
}

PtSetArg(&args[0], Pt_ARG_DIM, &newDim, 0);
PtSetArg(&args[1], Pt_ARG_POS, &newPos, 0);

// Set New Dimensions
/////////////////////
if(PtSetResources(m_window, 2, args) == -1)
rc = cRESP_FAILURE;
else
rc = cRESP_SUCCESS;

if(-1 == PtRealizeWidget(m_window))
message(“Error realizeing widget\n”);

return rc;
}


// Constructor
//////////////////////
CGraphicsWindow3D::CGraphicsWindow3D(int _id, int _xloc, int _yloc, int
_xsize, int _ysize, PtWidget_t* _parent, bool _concave):
CGraphicsWindow(_id)
{
PhArea_t windowArea;
PtArg_t args[8];
CGraphicsWindow *this_ptr = this;
PgColor_t bottom_color, top_color;

m_concave = _concave;

windowArea.pos.x = _xloc;
windowArea.pos.y = _yloc;
windowArea.size.w = _xsize;
windowArea.size.h = _ysize;

PtSetArg(&args[0], Pt_ARG_AREA, &windowArea, 0);
PtSetArg(&args[1], Pt_ARG_BORDER_WIDTH, 0, 0);
PtSetArg(&args[2], Pt_ARG_WINDOW_RENDER_FLAGS, 0, Ph_WM_APP_DEF_RENDER);
PtSetArg(&args[3], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0);
PtSetArg(&args[4], Pt_ARG_MIN_WIDTH, _xsize, 0);
PtSetArg(&args[5], Pt_ARG_MIN_HEIGHT, _ysize, 0);

m_window = PtCreateWidget(PtWindow, _parent, 6, args);

if(NULL == m_window)
{
fprintf(stderr, “Error creating text window %d, could not create window
widget\n”, _id);
return;
}
else
fprintf(stderr,“3DWindow Created(0x%08x) Pos(%d,%d) Size(%d,%d)”,
m_window, windowArea.pos.x, windowArea.pos.y, windowArea.size.w,
windowArea.size.h);

windowArea.pos.x = 0;
windowArea.pos.y = 0;
windowArea.size.w = _xsize - (2 * sc_border_width);
windowArea.size.h = _ysize - (2 * sc_border_width);

if(m_concave)
{
top_color = Pg_BLACK;
bottom_color = Pg_WHITE;
}
else
{
top_color = Pg_WHITE;
bottom_color = Pg_BLACK;
}

PtSetArg(&args[0], Pt_ARG_AREA, &windowArea, 0);
PtSetArg(&args[1], Pt_ARG_BORDER_WIDTH, sc_border_width, 0);
PtSetArg(&args[2], Pt_ARG_BOT_BORDER_COLOR, bottom_color, 0);
PtSetArg(&args[3], Pt_ARG_TOP_BORDER_COLOR, top_color, 0);
PtSetArg(&args[4], Pt_ARG_FILL_COLOR, Pg_GREY, 0);

m_bevel = PtCreateWidget(PtButton, m_window, 5, args);

if(NULL == m_bevel)
{
fprintf(stderr, “Error creating 3D text window %d, could not create raw
widget\n”, _id);
return;
}

if(-1 == PtRealizeWidget(m_window))
{
fprintf(stderr, “Error creating 3D text window %d, could not realize
window widget\n”, _id);
return;
}

PtWindowFocus(_parent);
}

Jeff Holtz <holtzj@mediaone.net> wrote:

I’m actually doing this in Photon 1.14 but thought that the same might apply
in Photon 2.0

There is a chance that it does; but there also is a chance that it
doesn’t, and that the only person who knows the answer doesn’t read this
newsgroup because he only deals with Photon 1.14… :wink:

I’m attempting to create a widget and then change it’s size programatically.
Problem is when I send a PtSetResources(…) Nothing seems to happen.
Actually when I click in the area which is supposed to be the new window
size, the window is selected. But graphically it’s not shown. Can anyone
give me some help? Here is what I’m doing:

What do you mean by “the window is selected” and “graphically it’s not
shown”? What happens if you switch consoles? What happens if you drag
another window across the screen? Does the window have a frame – if
not, could you enable it temporarily, and see what things look like
then?

Are you calling ChangeWindowSize() right after the constructor runs, or
are you letting the main loop run for a while, and then resizing the
window from a callback?


Wojtek Lerch QNX Software Systems Ltd.

Thanks for the response. Turns out I wasn’t changing all the right
widgets. To create a “3d Window” I create a window and then a Button on
top of that window (See original post for code). After altering my code to
change both widgets, the m_window (PtWindow) and m_bevel (PtButton), I can
get the “3d Window” to change size. Although I can now get this to work
alright. I’m wondering wither there is a simplier way to doing this.
Right now I have to create a huge if…then…else statement to take
care of the 4 possibilities (+,+)(+,-)(-,+)(-,-) Basically if the incoming
demensions shrink then I have to decrease the m_bevel first and then the
window. Otherwise the PtSetResources on the m_window doesn’t shrink because
the child button is bigger than the new m_window dimensions. Likewise if I
grow the “3d Window” I have to increase the m_window first and then the
m_bevel. Again this is due to the PtSetResources on the m_bevel will not
let me grow the button greater than the parent. In the case of a
combination of size, either (+,-) or (-,+), I have to perform 4
(PtGetResource/PtSetResource) pairs. 1 direction first and then the other,
due to the ordering problem.
Although this is working for me, I’m wondering if there is a flag in
the Widget resource that will let me grow/shirk the widget dimensions
greater/less than it’s parent/child.

Thanks for the help.

Jeff

“Wojtek Lerch” <wojtek_l@ottawa.com> wrote in message
news:a5g9eh$ipt$1@nntp.qnx.com

Jeff Holtz <> holtzj@mediaone.net> > wrote:
I’m actually doing this in Photon 1.14 but thought that the same might
apply
in Photon 2.0

There is a chance that it does; but there also is a chance that it
doesn’t, and that the only person who knows the answer doesn’t read this
newsgroup because he only deals with Photon 1.14… > :wink:

I’m attempting to create a widget and then change it’s size
programatically.
Problem is when I send a PtSetResources(…) Nothing seems to happen.
Actually when I click in the area which is supposed to be the new window
size, the window is selected. But graphically it’s not shown. Can
anyone
give me some help? Here is what I’m doing:

What do you mean by “the window is selected” and “graphically it’s not
shown”? What happens if you switch consoles? What happens if you drag
another window across the screen? Does the window have a frame – if
not, could you enable it temporarily, and see what things look like
then?
The underlying PtWindow doesn’t have a frame and thus is essentially

invisible. When I clicked in the area that I grew the PtWindow the button
was became selected.

Are you calling ChangeWindowSize() right after the constructor runs, or
are you letting the main loop run for a while, and then resizing the
window from a callback?
I’m trying to resizing the window from a custom TCP/IP server which I’ve set

up. Thus this can happen after the main loop has been running for a while.


Wojtek Lerch QNX Software Systems Ltd.

PtSetArg (&argt, Pt_ARG_RESIZE_FLAGS, 0, Pt_RESIZE_XY_BITS);
PtSetResources (window, 1, &argt);

In Photon 2.0 you would just anchor the button to the window and only have
to resize the window. The anchors on the button would resize it based on the
windows size.

“Jeff Holtz” <holtzj@mediaone.net> wrote in message
news:a5gghi$at3$1@inn.qnx.com

Thanks for the response. Turns out I wasn’t changing all the right
widgets. To create a “3d Window” I create a window and then a Button on
top of that window (See original post for code). After altering my code
to
change both widgets, the m_window (PtWindow) and m_bevel (PtButton), I can
get the “3d Window” to change size. Although I can now get this to work
alright. I’m wondering wither there is a simplier way to doing this.
Right now I have to create a huge if…then…else statement to take
care of the 4 possibilities (+,+)(+,-)(-,+)(-,-) Basically if the
incoming
demensions shrink then I have to decrease the m_bevel first and then the
window. Otherwise the PtSetResources on the m_window doesn’t shrink
because
the child button is bigger than the new m_window dimensions. Likewise if
I
grow the “3d Window” I have to increase the m_window first and then the
m_bevel. Again this is due to the PtSetResources on the m_bevel will not
let me grow the button greater than the parent. In the case of a
combination of size, either (+,-) or (-,+), I have to perform 4
(PtGetResource/PtSetResource) pairs. 1 direction first and then the
other,
due to the ordering problem.
Although this is working for me, I’m wondering if there is a flag in
the Widget resource that will let me grow/shirk the widget dimensions
greater/less than it’s parent/child.

Thanks for the help.

Jeff

“Wojtek Lerch” <> wojtek_l@ottawa.com> > wrote in message
news:a5g9eh$ipt$> 1@nntp.qnx.com> …
Jeff Holtz <> holtzj@mediaone.net> > wrote:
I’m actually doing this in Photon 1.14 but thought that the same might
apply
in Photon 2.0

There is a chance that it does; but there also is a chance that it
doesn’t, and that the only person who knows the answer doesn’t read this
newsgroup because he only deals with Photon 1.14… > :wink:

I’m attempting to create a widget and then change it’s size
programatically.
Problem is when I send a PtSetResources(…) Nothing seems to happen.
Actually when I click in the area which is supposed to be the new
window
size, the window is selected. But graphically it’s not shown. Can
anyone
give me some help? Here is what I’m doing:

What do you mean by “the window is selected” and “graphically it’s not
shown”? What happens if you switch consoles? What happens if you drag
another window across the screen? Does the window have a frame – if
not, could you enable it temporarily, and see what things look like
then?
The underlying PtWindow doesn’t have a frame and thus is essentially
invisible. When I clicked in the area that I grew the PtWindow the button
was became selected.

Are you calling ChangeWindowSize() right after the constructor runs, or
are you letting the main loop run for a while, and then resizing the
window from a callback?
I’m trying to resizing the window from a custom TCP/IP server which I’ve
set
up. Thus this can happen after the main loop has been running for a
while.


Wojtek Lerch QNX Software Systems Ltd.