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);
}