On 12/03/2015 at 21:37, xxxxxxxx wrote:
Hi Andreas,
sure. Bare with me on this one, the setup is a little in-depth, but I think it's important to paint a picture as you (or anyone else) might spot something that I can't see, or am unaware of! The short of it is this - I've inherited from a dialog class, and in that class I house a spline gui variable. I then use this dialog class as a variable in another main dialog class, which looks a bit like this:
class MyCustomSplineClass : public GeDialog
{
private:
SplineCustomGui *Spline_Gui;
SplineData *Spline_Data;
CustomSplineKnot *Knot;
GeDialog *Dialog;
int Initial_Enum;
public:
// the basic GeDialog overrides here, including:
virtual bool Command(..);
virtual LONG Message(...);
// then I have some custom spline based functions
// here, including the following two:
Draw_Spline(LONG flags,int Size_x,int size_y)
{
// Note the use of the Dialog reference
// instead of the inherited dialog link
Dialog->GroupBegin(Initial_Enum,...);
Spline_Gui = (SplineCustomGui* )Dialog->AddCustomGui(Gui_Enum_Id + 1,CUSTOMGUI_SPLINE,...etc...);
Dialog->AddEditNumberArrows(Gui_Enum_Id + 2,...etc...);
Dialog->GroupEnd();
// the edit number field is used for example,
// to change a selected points X position
// these elements draw/update and send
// commands fine.
}
Set_Dialog_Reference(GeDialog* dlg)
{
Dialog = dlg;
}
void Set_Initial_Enum_id(int e)
{
Initial_Enum = e;
}
}
class MainDialog : public GeDialog
{
private:
MyCustomSplineClass MySpline;
public:
Bool CreateLayout(void)
{
...Make dialog layout etc here, including:
MySpline.Set_Initial_Enum_id(ENUM_ID_HERE);
MySpline.Set_Dialog_Reference(this);
MySpline.Draw_Spline(BFH_SCALEFIT|BFV_SCALEFIT,NULL,NULL);
... finish off dialog layout here
}
}
I've set it up like this for three reasons: first it means I only have to edit the one class object in order to update many spline gui objects. Second, it means I can use the custom spline header files in other plugins. And thirdly - I can use the GeDialog's Message() and Command() functions in my custom spline object to catch messages/commands etc.
The messaging works a little like this: enum id's are tested for inside the main dialog's Command(), and if they meet the various enum id criteria, the command id is passed onto the custom spline object's Command(). I know that it works - the messages etc are all receieved in the custom spline class, I can print things and change other gui elements like the AddEditNumberArrows() fields.
The way I call the redraw is simple - I use a function called RedrawCurve() in the custom spline object class, which can be triggered from anywhere, such as from inside the custom spline object's Command(). It looks like this:
class MyCustomSplineClass : public GeDialog
{
SplineCustomGui *Spline_Gui;
...
void RedrawCurve(void)
{
if(Spline_Gui != NULL)
{
Spline_Gui->Redraw(); // doesn't work
Spline_Gui->LayoutChanged() // doesn't work
// mousing over the gui however, does work!
}
}
}
Let me know if you need more. Otherwise, that's the bare bones of it and pretty much it. Everything in the custom spline object works - I can edit real fields, get their values and change spline point positions etc. I'm also using it in two separate plugins. Everything works, everything except for the updating of the spline gui draw itself!
Cheers,
WP.