[Gtk-sharp-list] Help with widget not displaying in dialog

alan battersby alan.battersby at ntlworld.com
Sun Apr 19 15:55:54 EDT 2009


Hi,
I have a problem, I have a dialog containing a widget I wrote to display
axis information. In turn this widget contains another widget to draw
the axes concerned in a drawingarea. When I run the dialog, the drawing
initially appears but then is cleared. When I click on a button to
rotate the axes then drawing appears again and stays visible. So could
someone suggest what I am doing wrong or how I can stop the drawingarea
from being cleared initially.  Is it being cleared when I run the Dialog?

Thanks any help would be appreciated as Ive spent all afternoon trying
to solve this,
Alan

Code fragments are

public partial class AxismapDialog : Gtk.Dialog
{
         public AxisMap AxisMap {
            get {
                return axismapdisplay.AxisMap;
            }
            set {
                axismapdisplay.AxisMap = value;
            }
 }   

public partial class AxismapDisplay : Gtk.Bin
 {  
        AxisMap _map;

        public AxisMap AxisMap {
            get {
                return _map;
            }
            set {
                _map = value;
               // code to set UI textfields etc
                ...
                // SHOULD DRAW HERE
                framedisplay1.Frame = _map.Frame;
                framedisplay1.DrawAxes();     // put this in out of
desperation shouldn't need it
            }

            // in widget I have a buttons to rotate the axes
          protected virtual void OnXrotBTNClicked (object sender,
System.EventArgs e)
            {
                _map.Frame.Rotate90(AXIS.X);
                framedisplay1.DrawAxes();      // this works ok
            }
 }

public partial class FrameDisplay : Gtk.Bin
 {
             Frame _frame;
       
        public Frame Frame {
            get {
                    return _frame;
                }
            set {
                    _frame = value;
                    DrawAxes();
            }

          public void DrawAxes()
        {
            if (_frame == null) return;
            drawingarea.GdkWindow.Clear();
            using (Context ct =
Gdk.CairoHelper.Create(drawingarea.GdkWindow))
            {
                // now scale window and centre to origin
                int height = 0,width = 0;
               
                drawingarea.GdkWindow.GetSize(out width, out height);
                l = (float)Math.Min(width/2,height/2);
                ct.Translate(width/2,height/2);
                // should be centred now
                // first x axis
                ct.Color = new Cairo.Color(1,0,0); 
                drawline(_frame.X,ct,l,AXIS.X.ToString());
                // now y axis
                ct.Color = new Cairo.Color(0,1,0); 
                drawline(_frame.Y,ct,l,AXIS.Y.ToString());
                // now z axis
                ct.Color = new Cairo.Color(0,0,1);
                drawline(_frame.Z,ct,l,AXIS.Z.ToString());
            }
        }
}

//in main user window have a button to create and display the dialog.
protected virtual void OnAxismapbtnClicked (object sender,
System.EventArgs e)
        {
            AxismapDialog amd = new AxismapDialog();
            amd.AxisMap = _codegen.AxisMap;
            if (amd.Run() == (int)ResponseType.Ok)
            {
                _codegen.AxisMap = amd.AxisMap;   
            }
            amd.Destroy();
            axismaplabel.Text = _codegen.AxisMap.ShortString;
        }

Dont know if this enough information to help.


More information about the Gtk-sharp-list mailing list