зеркало из https://github.com/mono/mail-archives.git
119 строки
10 KiB
HTML
119 строки
10 KiB
HTML
<tt>
|
||
Alan-<br><br>The drawing code (in FrameDisplay.DrawAxes()) should really called on the expose event handler for FrameDisplay. This way, it will get called whenever the control needs to be redrawn. Just put<br><br>ExposeEvent += HandleExposeEvent;<br><br>
|
||
<br>into the FrameDisplay constructor, then put a call to DrawAxes() in the handler:<br><br>void HandleExposeEvent(object o, Gtk.ExposeEventArgs args)<br>{<br> DrawAxes();<br>}<br><br>Hope this helps.<br><br><br><div class="gmail_quote"><br>
|
||
On Sun, Apr 19, 2009 at 2:55 PM, alan battersby <span dir="ltr">&lt;<a href="mailto:alan.battersby@ntlworld.com">alan.battersby@ntlworld.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
|
||
Hi,<br><br>
|
||
I have a problem, I have a dialog containing a widget I wrote to display<br><br>
|
||
axis information. In turn this widget contains another widget to draw<br><br>
|
||
the axes concerned in a drawingarea. When I run the dialog, the drawing<br><br>
|
||
initially appears but then is cleared. When I click on a button to<br><br>
|
||
rotate the axes then drawing appears again and stays visible. So could<br><br>
|
||
someone suggest what I am doing wrong or how I can stop the drawingarea<br><br>
|
||
from being cleared initially. Is it being cleared when I run the Dialog?<br><br>
|
||
<br><br>
|
||
Thanks any help would be appreciated as Ive spent all afternoon trying<br><br>
|
||
to solve this,<br><br>
|
||
Alan<br><br>
|
||
<br><br>
|
||
Code fragments are<br><br>
|
||
<br><br>
|
||
public partial class AxismapDialog : Gtk.Dialog<br><br>
|
||
{<br><br>
|
||
public AxisMap AxisMap {<br><br>
|
||
get {<br><br>
|
||
return axismapdisplay.AxisMap;<br><br>
|
||
}<br><br>
|
||
set {<br><br>
|
||
axismapdisplay.AxisMap = value;<br><br>
|
||
}<br><br>
|
||
}<br><br>
|
||
<br><br>
|
||
public partial class AxismapDisplay : Gtk.Bin<br><br>
|
||
{<br><br>
|
||
AxisMap _map;<br><br>
|
||
<br><br>
|
||
public AxisMap AxisMap {<br><br>
|
||
get {<br><br>
|
||
return _map;<br><br>
|
||
}<br><br>
|
||
set {<br><br>
|
||
_map = value;<br><br>
|
||
// code to set UI textfields etc<br><br>
|
||
...<br><br>
|
||
// SHOULD DRAW HERE<br><br>
|
||
framedisplay1.Frame = _map.Frame;<br><br>
|
||
framedisplay1.DrawAxes(); // put this in out of<br><br>
|
||
desperation shouldn&#39;t need it<br><br>
|
||
}<br><br>
|
||
<br><br>
|
||
// in widget I have a buttons to rotate the axes<br><br>
|
||
protected virtual void OnXrotBTNClicked (object sender,<br><br>
|
||
System.EventArgs e)<br><br>
|
||
{<br><br>
|
||
_map.Frame.Rotate90(AXIS.X);<br><br>
|
||
framedisplay1.DrawAxes(); // this works ok<br><br>
|
||
}<br><br>
|
||
}<br><br>
|
||
<br><br>
|
||
public partial class FrameDisplay : Gtk.Bin<br><br>
|
||
{<br><br>
|
||
Frame _frame;<br><br>
|
||
<br><br>
|
||
public Frame Frame {<br><br>
|
||
get {<br><br>
|
||
return _frame;<br><br>
|
||
}<br><br>
|
||
set {<br><br>
|
||
_frame = value;<br><br>
|
||
DrawAxes();<br><br>
|
||
}<br><br>
|
||
<br><br>
|
||
public void DrawAxes()<br><br>
|
||
{<br><br>
|
||
if (_frame == null) return;<br><br>
|
||
drawingarea.GdkWindow.Clear();<br><br>
|
||
using (Context ct =<br><br>
|
||
Gdk.CairoHelper.Create(drawingarea.GdkWindow))<br><br>
|
||
{<br><br>
|
||
// now scale window and centre to origin<br><br>
|
||
int height = 0,width = 0;<br><br>
|
||
<br><br>
|
||
drawingarea.GdkWindow.GetSize(out width, out height);<br><br>
|
||
l = (float)Math.Min(width/2,height/2);<br><br>
|
||
ct.Translate(width/2,height/2);<br><br>
|
||
// should be centred now<br><br>
|
||
// first x axis<br><br>
|
||
ct.Color = new Cairo.Color(1,0,0);<br><br>
|
||
drawline(_frame.X,ct,l,AXIS.X.ToString());<br><br>
|
||
// now y axis<br><br>
|
||
ct.Color = new Cairo.Color(0,1,0);<br><br>
|
||
drawline(_frame.Y,ct,l,AXIS.Y.ToString());<br><br>
|
||
// now z axis<br><br>
|
||
ct.Color = new Cairo.Color(0,0,1);<br><br>
|
||
drawline(_frame.Z,ct,l,AXIS.Z.ToString());<br><br>
|
||
}<br><br>
|
||
}<br><br>
|
||
}<br><br>
|
||
<br><br>
|
||
//in main user window have a button to create and display the dialog.<br><br>
|
||
protected virtual void OnAxismapbtnClicked (object sender,<br><br>
|
||
System.EventArgs e)<br><br>
|
||
{<br><br>
|
||
AxismapDialog amd = new AxismapDialog();<br><br>
|
||
amd.AxisMap = _codegen.AxisMap;<br><br>
|
||
if (amd.Run() == (int)ResponseType.Ok)<br><br>
|
||
{<br><br>
|
||
_codegen.AxisMap = amd.AxisMap;<br><br>
|
||
}<br><br>
|
||
amd.Destroy();<br><br>
|
||
axismaplabel.Text = _codegen.AxisMap.ShortString;<br><br>
|
||
}<br><br>
|
||
<br><br>
|
||
Dont know if this enough information to help.<br><br>
|
||
_______________________________________________<br><br>
|
||
Gtk-sharp-list maillist - <a href="mailto:Gtk-sharp-list@lists.ximian.com">Gtk-sharp-list@lists.ximian.com</a><br><br>
|
||
<a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list" target="_blank">http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</a><br><br>
|
||
</blockquote></div><br><br>
|
||
|
||
</tt>
|