Kendall Russell
|
Blocking and Unblocking Widgets
|
Kendall Russell
05/05/2011 12:40 PM
post85447
|
Blocking and Unblocking Widgets
How do you block and unblock individual widgets?
I am attempting to block and unblock (disable and enable) individual widgets depending upon the state of the overall
program and what the user is trying to do.
PtSetResource() is not working for this or I am not calling it correctly. I can successfully get the resource with
PtGetResource().
Right now I am just trying to do this with PtText widgets, but I will soon need to do this with other types as well.
Basically, my code is currently doing the following:
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
nSetFlags = *pnGetFlags | Pt_BLOCKED;
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 0);
//I have also tried the following modifications to PtSetResource
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, sizeof(long));
The code for the full functions are included below:
#include <Pt.h>
int WdgtDisable(PtWidget_t* pWidget)
{
int nError = 0;
if(PtWidgetClass(pWidget) == PtText)
{
unsigned long* pnGetFlags = 0;
unsigned long nSetFlags = 0;
/* GET WIDGET FLAGS */
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
/* SET BLOCK FLAG */
nSetFlags = *pnGetFlags | Pt_BLOCKED;
nError = PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
/* SET COLOR TO INDICATE WIDGET IS BLOCKED */
PtSetResource(pWidget, Pt_ARG_FILL_COLOR, PgGray(217), 0);
}
return nError;
}
int WdgtEnable(PtWidget_t* pWidget)
{
int nError = 0;
if(PtWidgetClass(pWidget) == PtText)
{
unsigned long* pnGetFlags = 0;
unsigned long nSetFlags = 0;
/* GET WIDGET FLAGS */
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
/* UNSET BLOCK FLAG */
nSetFlags = *pnGetFlags & ~Pt_BLOCKED;
nError = PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
/*SET COLOR TO INDICATE WIDGET IS UNBLOCKED*/
PtSetResource(pWidget, Pt_ARG_FILL_COLOR, PgGray(254), 0);
}
return nError;
}
-------
Kendall
|
|
|
Thomas Haupt
|
AW: Blocking and Unblocking Widgets
|
Thomas Haupt
05/05/2011 1:10 PM
post85449
|
AW: Blocking and Unblocking Widgets
The 4th argument is a bit-mask determining which bits from the 3rd argument shall be applied.
----- Originalnachricht -----
Von: Kendall Russell [mailto:community-noreply@qnx.com]
Gesendet: Thursday, May 05, 2011 12:40 PM
An: photon-graphics <post85447@community.qnx.com>
Betreff: Blocking and Unblocking Widgets
How do you block and unblock individual widgets?
I am attempting to block and unblock (disable and enable) individual widgets depending upon the state of the overall
program and what the user is trying to do.
PtSetResource() is not working for this or I am not calling it correctly. I can successfully get the resource with
PtGetResource().
Right now I am just trying to do this with PtText widgets, but I will soon need to do this with other types as well.
Basically, my code is currently doing the following:
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
nSetFlags = *pnGetFlags | Pt_BLOCKED;
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 0);
//I have also tried the following modifications to PtSetResource
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, sizeof(long));
The code for the full functions are included below:
#include <Pt.h>
int WdgtDisable(PtWidget_t* pWidget)
{
int nError = 0;
if(PtWidgetClass(pWidget) == PtText)
{
unsigned long* pnGetFlags = 0;
unsigned long nSetFlags = 0;
/* GET WIDGET FLAGS */
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
/* SET BLOCK FLAG */
nSetFlags = *pnGetFlags | Pt_BLOCKED;
nError = PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
/* SET COLOR TO INDICATE WIDGET IS BLOCKED */
PtSetResource(pWidget, Pt_ARG_FILL_COLOR, PgGray(217), 0);
}
return nError;
}
int WdgtEnable(PtWidget_t* pWidget)
{
int nError = 0;
if(PtWidgetClass(pWidget) == PtText)
{
unsigned long* pnGetFlags = 0;
unsigned long nSetFlags = 0;
/* GET WIDGET FLAGS */
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
/* UNSET BLOCK FLAG */
nSetFlags = *pnGetFlags & ~Pt_BLOCKED;
nError = PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
/*SET COLOR TO INDICATE WIDGET IS UNBLOCKED*/
PtSetResource(pWidget, Pt_ARG_FILL_COLOR, PgGray(254), 0);
}
return nError;
}
-------
Kendall
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post85447
|
|
|
Kendall Russell
|
Re: AW: Blocking and Unblocking Widgets
|
Kendall Russell
05/05/2011 2:11 PM
post85452
|
Re: AW: Blocking and Unblocking Widgets
So, instead of getting the resource, modifying it and then setting it again all I have to do is:
PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_TRUE, Pt_BLOCKED);
PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_FALSE, Pt_BLOCKED);
I guess I just assumed that the 4th argument was a length value since it is named "len"
Thomas - Thank you!
Follow up question:
Where is the documentation that spells out how to call PtSetResource depending upon which resource is being set?
|
|
|
Steve Reid
|
RE: AW: Blocking and Unblocking Widgets
|
Steve Reid
05/05/2011 2:15 PM
post85453
|
RE: AW: Blocking and Unblocking Widgets
Here's a link to the section in the Photon Programmer's Guide:
http://www.qnx.com/developers/docs/6.5.0/topic/com.qnx.doc.photon_prog_g
uide/res_code.html#SettingResources
Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems
> -----Original Message-----
> From: Kendall Russell [mailto:community-noreply@qnx.com]
> Sent: Thursday, May 05, 2011 2:12 PM
> To: photon-graphics
> Subject: Re: AW: Blocking and Unblocking Widgets
>
>
> So, instead of getting the resource, modifying it and then setting it
> again all I have to do is:
>
> PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_TRUE, Pt_BLOCKED);
> PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_FALSE, Pt_BLOCKED);
>
> I guess I just assumed that the 4th argument was a length value since
> it is named "len"
>
> Thomas - Thank you!
>
> Follow up question:
> Where is the documentation that spells out how to call PtSetResource
> depending upon which resource is being set?
>
>
>
> _______________________________________________
>
> Photon microGUI
> http://community.qnx.com/sf/go/post85452
|
|
|
Kendall Russell
|
Re: RE: AW: Blocking and Unblocking Widgets
|
Kendall Russell
05/05/2011 2:51 PM
post85454
|
Re: RE: AW: Blocking and Unblocking Widgets
Thank you.
I had actually read that before, but I must have just skipped over the link describing the argument list.
Kendall
> Here's a link to the section in the Photon Programmer's Guide:
>
> http://www.qnx.com/developers/docs/6.5.0/topic/com.qnx.doc.photon_prog_g
> uide/res_code.html#SettingResources
>
>
>
> Steve Reid (stever@qnx.com)
> Technical Editor
> QNX Software Systems
>
>
> > -----Original Message-----
> > From: Kendall Russell [mailto:community-noreply@qnx.com]
> > Sent: Thursday, May 05, 2011 2:12 PM
> > To: photon-graphics
> > Subject: Re: AW: Blocking and Unblocking Widgets
> >
> >
> > So, instead of getting the resource, modifying it and then setting it
> > again all I have to do is:
> >
> > PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_TRUE, Pt_BLOCKED);
> > PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_FALSE, Pt_BLOCKED);
> >
> > I guess I just assumed that the 4th argument was a length value since
> > it is named "len"
> >
> > Thomas - Thank you!
> >
> > Follow up question:
> > Where is the documentation that spells out how to call PtSetResource
> > depending upon which resource is being set?
> >
> >
> >
> > _______________________________________________
> >
> > Photon microGUI
> > http://community.qnx.com/sf/go/post85452
|
|
|
|