slider and up/down

Does anybody have source that binds sliders with up/downs easily?

Hi David,

For the up/downs do you mean PtUpDown ?? Are you looking to use the up
down button to move the slider ?

If that is what you mean here is a simple function that moves the slider
when the up or down button arrows are used this function is attached to
the activate callback of the PtUpDown widget.

int counter = 0;

int
updown_activate_CB( PtWidget_t *widget, ApInfo_t *apinfo, CallbackInfo_t
*cbinfo )
{
ulong_t ButtonPressed = cbinfo->reason_subtype;

if (ButtonPressed == UPDOWN_TOP)
counter ++;
else if (ButtonPressed == UPDOWN_BOTTOM)
counter --;
PtSetResource(ABW_base_slider, Pt_ARG_GAUGE_VALUE, counter, 0);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}

If this isn’t what you had in mind could you please post a more detailed
explaination of what your trying to do ?

Regards
Brenda

David Hurlburt wrote:

Does anybody have source that binds sliders with up/downs easily?

Hi Brenda,

Thanks for your quick responses. Yes this is what I was shooting for,
except that it doesn’t call the callback hung on the slider.

I also have a SlideMoveCB on the slider which gets cbdata->position and then
writes this to a label widget.

I tried to “activate” the slideMoveCB by doing the following:

PtSliderWidget_t *sliderWidget;
PtCallbackInfo_t fakeCBinfo;

sliderWidget = (PtSliderWidget_t*) AGW_VerticalSliderWidget;

fakCBinfo.reason = Pt_CB_SLIDER_MOVE;

PtInvokeCallbackList(sliderWidget->cb_move,
ABW_VerticalSliderWidget,
&fakeCBinfo);

This does, infact, “activate” the CB_MOVE callback, but the cbdata->position
isn’t right. In the slideMoveCB, I do the following:

PtSetArg(&arg, Pt_ARG_GAUGE_VALUE, 0, 0 );
PtGetResource(ABW_VerticalSliderWidget, 1, &arg);

arg.value does not equal cbdata->position.

Example:

arg.value = 1

cbdata->position = 1006

Do you know what I may be missing from the InvokeCallback functionality?

“GUI Group” <gui@qnx.com> wrote in message news:3C337A1A.7010100@qnx.com

Hi David,

For the up/downs do you mean PtUpDown ?? Are you looking to use the up
down button to move the slider ?

If that is what you mean here is a simple function that moves the slider
when the up or down button arrows are used this function is attached to
the activate callback of the PtUpDown widget.

int counter = 0;

int
updown_activate_CB( PtWidget_t *widget, ApInfo_t *apinfo, CallbackInfo_t
*cbinfo )
{
ulong_t ButtonPressed = cbinfo->reason_subtype;

if (ButtonPressed == UPDOWN_TOP)
counter ++;
else if (ButtonPressed == UPDOWN_BOTTOM)
counter --;
PtSetResource(ABW_base_slider, Pt_ARG_GAUGE_VALUE, counter, 0);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}

If this isn’t what you had in mind could you please post a more detailed
explaination of what your trying to do ?

Regards
Brenda

David Hurlburt wrote:

Does anybody have source that binds sliders with up/downs easily?
\

Hi David,

In order for the Pt_CB_SLIDER_MOVE callback to get invoked when you
change the value using set and get resources in the updown_activate_CB
try setting the Pt_CALLBACKS_ACTIVE flag in Pt_ARG_FLAGS resource for
the Slider widget.

Below is also the function I used to get the position for the slider.

Hope this helps. Let me know if it works for you.
Regards
Brenda

int counter = 0;


int
updown_activate_CB( PtWidget_t *widget, ApInfo_t *apinfo,
PtCallbackInfo_t *cbinfo )

{
ulong_t ButtonPressed = cbinfo->reason_subtype;
int *gauge_value;
PtArg_t args[1];


PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, &gauge_value, 0);
PtGetResources(ABW_base_slider, 1, args);
counter = *gauge_value;

if (ButtonPressed == UPDOWN_TOP)
counter++;
else if (ButtonPressed == UPDOWN_BOTTOM)
counter–;
PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, counter, 0);
PtSetResources(ABW_base_slider, 1, args);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}


int
slider_move_CB( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )

{
PtSliderCallback_t *cbdata = cbinfo->cbdata;
char buffer[20];
PtArg_t args[1];

sprintf(buffer, “%i”, cbdata->position);
PtArgSet(&args[0], Pt_ARG_TEXT_STRING, buffer, 0);
PtSetResources(ABW_base_text, 1, args);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}




David Hurlburt wrote:

Hi Brenda,

Thanks for your quick responses. Yes this is what I was shooting for,
except that it doesn’t call the callback hung on the slider.

I also have a SlideMoveCB on the slider which gets cbdata->position and then
writes this to a label widget.

I tried to “activate” the slideMoveCB by doing the following:

PtSliderWidget_t *sliderWidget;
PtCallbackInfo_t fakeCBinfo;

sliderWidget = (PtSliderWidget_t*) AGW_VerticalSliderWidget;

fakCBinfo.reason = Pt_CB_SLIDER_MOVE;

PtInvokeCallbackList(sliderWidget->cb_move,
ABW_VerticalSliderWidget,
&fakeCBinfo);

This does, infact, “activate” the CB_MOVE callback, but the cbdata->position
isn’t right. In the slideMoveCB, I do the following:

PtSetArg(&arg, Pt_ARG_GAUGE_VALUE, 0, 0 );
PtGetResource(ABW_VerticalSliderWidget, 1, &arg);

arg.value does not equal cbdata->position.

Example:

arg.value = 1

cbdata->position = 1006

Do you know what I may be missing from the InvokeCallback functionality?

“GUI Group” <> gui@qnx.com> > wrote in message news:> 3C337A1A.7010100@qnx.com> …

Hi David,

For the up/downs do you mean PtUpDown ?? Are you looking to use the up
down button to move the slider ?

If that is what you mean here is a simple function that moves the slider
when the up or down button arrows are used this function is attached to
the activate callback of the PtUpDown widget.

int counter = 0;

int
updown_activate_CB( PtWidget_t *widget, ApInfo_t *apinfo, CallbackInfo_t
*cbinfo )
{
ulong_t ButtonPressed = cbinfo->reason_subtype;

if (ButtonPressed == UPDOWN_TOP)
counter ++;
else if (ButtonPressed == UPDOWN_BOTTOM)
counter --;
PtSetResource(ABW_base_slider, Pt_ARG_GAUGE_VALUE, counter, 0);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}

If this isn’t what you had in mind could you please post a more detailed
explaination of what your trying to do ?

Regards
Brenda

David Hurlburt wrote:


Does anybody have source that binds sliders with up/downs easily?


\

Hi Brenda,

Again, thanks. Your assistance has been very helpful through the last few
days. I am new to QNX, Photon, and even Newsgroups so this has been awsome.

Best Regards,

Dave
“GUI Group” <gui@qnx.com> wrote in message news:3C39BFFE.9020506@qnx.com

Hi David,

In order for the Pt_CB_SLIDER_MOVE callback to get invoked when you
change the value using set and get resources in the updown_activate_CB
try setting the Pt_CALLBACKS_ACTIVE flag in Pt_ARG_FLAGS resource for
the Slider widget.

Below is also the function I used to get the position for the slider.

Hope this helps. Let me know if it works for you.
Regards
Brenda

int counter = 0;


int
updown_activate_CB( PtWidget_t *widget, ApInfo_t *apinfo,
PtCallbackInfo_t *cbinfo )

{
ulong_t ButtonPressed = cbinfo->reason_subtype;
int *gauge_value;
PtArg_t args[1];


PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, &gauge_value, 0);
PtGetResources(ABW_base_slider, 1, args);
counter = *gauge_value;

if (ButtonPressed == UPDOWN_TOP)
counter++;
else if (ButtonPressed == UPDOWN_BOTTOM)
counter–;
PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, counter, 0);
PtSetResources(ABW_base_slider, 1, args);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}


int
slider_move_CB( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )

{
PtSliderCallback_t *cbdata = cbinfo->cbdata;
char buffer[20];
PtArg_t args[1];

sprintf(buffer, “%i”, cbdata->position);
PtArgSet(&args[0], Pt_ARG_TEXT_STRING, buffer, 0);
PtSetResources(ABW_base_text, 1, args);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}




David Hurlburt wrote:

Hi Brenda,

Thanks for your quick responses. Yes this is what I was shooting for,
except that it doesn’t call the callback hung on the slider.

I also have a SlideMoveCB on the slider which gets cbdata->position and
then
writes this to a label widget.

I tried to “activate” the slideMoveCB by doing the following:

PtSliderWidget_t *sliderWidget;
PtCallbackInfo_t fakeCBinfo;

sliderWidget = (PtSliderWidget_t*) AGW_VerticalSliderWidget;

fakCBinfo.reason = Pt_CB_SLIDER_MOVE;

PtInvokeCallbackList(sliderWidget->cb_move,
ABW_VerticalSliderWidget,
&fakeCBinfo);

This does, infact, “activate” the CB_MOVE callback, but the
cbdata->position
isn’t right. In the slideMoveCB, I do the following:

PtSetArg(&arg, Pt_ARG_GAUGE_VALUE, 0, 0 );
PtGetResource(ABW_VerticalSliderWidget, 1, &arg);

arg.value does not equal cbdata->position.

Example:

arg.value = 1

cbdata->position = 1006

Do you know what I may be missing from the InvokeCallback functionality?

“GUI Group” <> gui@qnx.com> > wrote in message
news:> 3C337A1A.7010100@qnx.com> …

Hi David,

For the up/downs do you mean PtUpDown ?? Are you looking to use the up
down button to move the slider ?

If that is what you mean here is a simple function that moves the slider
when the up or down button arrows are used this function is attached to
the activate callback of the PtUpDown widget.

int counter = 0;

int
updown_activate_CB( PtWidget_t *widget, ApInfo_t *apinfo, CallbackInfo_t
*cbinfo )
{
ulong_t ButtonPressed = cbinfo->reason_subtype;

if (ButtonPressed == UPDOWN_TOP)
counter ++;
else if (ButtonPressed == UPDOWN_BOTTOM)
counter --;
PtSetResource(ABW_base_slider, Pt_ARG_GAUGE_VALUE, counter, 0);

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

return( Pt_CONTINUE );

}

If this isn’t what you had in mind could you please post a more detailed
explaination of what your trying to do ?

Regards
Brenda

David Hurlburt wrote:


Does anybody have source that binds sliders with up/downs easily?



\