[Gtk-sharp-list] Forcing a resize in nested widgets

Adam Tauno Williams adam at morrison-ind.com
Mon Mar 24 16:34:20 EDT 2008


I have a widget (TaskAnnotationForm : Gtk.Bin) designed in Stetic in a
MonoDevelop project.   Another widget (TaskHistoryForm : Gtk.Bin)
basically contains a ScrolledWindow whose Viewport contains a Gtk.VBox
of TaskAnnotationForm widgets.  Basically it is given a task objects and
displays all the annotations made upon the task,  there can be many
annotations
<http://docs.opengroupware.org/Members/whitemice/consonance/ConsonanceTaskNotations/image_view>.

That works,  but I have one problem.  The comment field (Gtk.TextView)
of the TaskAnnotationForm widgets does not expand.  It displays one line
of text, or even a partial line of text, and the scroll area does not
expand UNTIL you click anywhere in the window - then the widgets size
themselves correctly.  Once you click inside the window everything is
sized correctly.

I've set "comment.ResizeMode = ResizeMode.Immediate;" in
TaskAnnotationForm and I invoke "viewport.ResizeChildren();" after
adding all TaskAnnotationForm to the viewport's VBox.  But I can't get
the widgets to resize.

Method to fill the TaskHistoryForm looks like -

public void Fill(Entity _entity)
{
  VBox                  history;
  Whitemice.ZOGI.Task   task;

  if (_entity is Whitemice.ZOGI.Task)
    task = (_entity as Whitemice.ZOGI.Task);
    else throw new Exception("Inappropriate entity provided to form");

  history = new VBox();
  history.Spacing = 2;
  task.Notations.Sort();
  foreach(TaskNotation a in task.Notations)
    history.PackStart(new TaskAnnotationForm(a), true, true, 2);
  if (!(viewport.Child == null))
    viewport.Remove(viewport.Child);
  viewport.Child = history;
  viewport.ShowAll();
  viewport.ResizeChildren();
}

The constructor of TaskAnnotationForm is -

public TaskAnnotationForm(TaskNotation _annotation)
{
  this.Build();
  id.Text = "Annotation#" + _annotation.ObjectId.ToString();
  action.Text = _annotation.Action.ToString();
  actor.Text = _annotation.ActorName;
  date.Text = _annotation.Date.ToString("yyyy-MM-dd HH:mm");
  comment.Buffer.Text = _annotation.Comment;
  comment.ResizeMode = ResizeMode.Immediate;
}




More information about the Gtk-sharp-list mailing list