On Tuesday 04 September 2001 06:30, you wrote:
> Hello
>
> I am new to FOX and I wonder if anyone can help me?
> To pratice my skills I have implemented both a parent and a child window,
> each window consists of a single spinner.
> Can anyone tell me how I can continuously update the spinner in the child
> window to
> match the value shown by the spinner in the parent window.
> At present both spinners consist of independant FXDataTarget's that are
> public: data
> memebers of each class.
> Where do I start?
>
> Thanks Roger
>
> FXIMPLEMENT(FXChildWindow,FXTopWindow,NULL,0)
>
> FXChildWindow::FXChildWindow(FXWindow* owner):FXTopWindow(owner,"Child
> Window",NULL,NULL,DECOR_ALL,0,0,0,0,0,0)
> {
> child_int = 0;
> new FXLabel(this,"Child Window",NULL,LAYOUT_TOP|JUSTIFY_LEFT);
> child_target = new FXDataTarget(child_int);
> FXMatrix* matrix=new
> FXMatrix(this,2,FRAME_RAISED|LAYOUT_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
> child_spinner = new
> FXSpinner(matrix,5,child_target,FXDataTarget::ID_VALUE,FRAME_SUNKEN|FRAME_T
>H ICK|LAYOUT_CENTER_Y|LAYOUT_FILL_ROW);
> child_spinner->setMinMax(0,35);
> }
>
>
> FXDEFMAP(FXParentWindow) FXParentWindowMap[]=
> {
> FXMAPFUNC(SEL_COMMAND, FXParentWindow::ID_SHOWCHILD,
> FXParentWindow::onCmdShowDialog),
> };
>
> FXIMPLEMENT(FXParentWindow,FXMainWindow,FXParentWindowMap,ARRAYNUMBER(FXPar
>e ntWindowMap))
>
> FXParentWindow::FXParentWindow(FXApp* a):FXMainWindow(a,"Parent
> Window",NULL,NULL,DECOR_ALL,0,0,0,0)
> {
> parent_int = 0;
> child=new FXChildWindow(this);
> parent_target = new FXDataTarget(parent_int);
> FXMatrix* matrix=new
> FXMatrix(this,3,FRAME_RAISED|LAYOUT_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
> new FXLabel(matrix,"Parent Window",NULL,LAYOUT_TOP|JUSTIFY_LEFT);
> new FXButton(matrix,"Child
> Window",NULL,this,ID_SHOWCHILD,FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAY
>O UT_CENTER_Y);
> parent_spinner = new
> FXSpinner(matrix,5,parent_target,FXDataTarget::ID_VALUE,FRAME_SUNKEN|FRAME_
>T HICK|LAYOUT_CENTER_Y|LAYOUT_FILL_ROW);
> parent_spinner->setMinMax(0,35);
> }
>
Just make BOTH windows connect to the same data target!
Regards,
- Jeroen
P.S.
You could simplify your code a bit:
class SomeWindow : public ... {
...
FXint myint;
FXDataTarget myint_target;
...
};
SomeWindow::SomeWindow(FXComposite* parent,...):myint_target(mymint){
...
new FXSpinner(matrix,5,&myint_target,FXDataTarget::ID_VALUE,...);
...
}
or alternatively:
SomeWindow::SomeWindow(FXComposite* parent,...){
myint_target.connect(myint);
...
new FXSpinner(matrix,5,&myint_target,FXDataTarget::ID_VALUE,...);
...
}
The advantage of this is that you don't have to worry about deleting all the
data targets (because they're not dynamically allocated).
|