[MonoDevelop] How can I stop this problem with dock items ?

alan battersby alan.battersby at ntlworld.com
Mon Oct 5 16:08:44 EDT 2009


Hi,
My program has six or so Dock items. I have two widgets one contains a
treeview the other contains a drawing area both are in different dock
items. When I select an item in the treeview it is displayed in the
drawing area. This works fine so long as the dock item containing the
display widget with the drawingarea is fully realized and visible. When
dock item containing the display widget is not initially selected it
seems that the drawingarea is not realized (may be wrong because I am
not sure about this at all) and so a null exception occurs when I try to
access the drawingarea  GdkWindow in the display code called as a result
of selecting something in the treeview. This happens when I  start my
program and the display widget dock item (which is in a tabbed group of
three dock items ) is not the selected tab.  (If I manually select the
tab first no problems as the drawing area is realized  and visible).

I want to make the dock item containing the display widget  be the
selected tab automatically if it isn't , when I select an item in the 
treeview but I don't know how to do that.
 
I tried adding code to the display widget to check its GdkWindow and if
this is null to change the dock item status.

if (drawingarea.GdkWindow == null)
            {
                DockItem di = _df.GetItem(Keys.LATTICE_DISPLAY_DOCK_ID);
                di.Status = DockItemStatus.Dockable;
                di.Visible = true;
                di.Behavior = DockItemBehavior.Normal;
                this.ShowAll();
            }

It seems this is not enough as I am still getting the null exception, I
think I need to access the tabbed group in the DockFrame and make the
drawingarea the selected tab and if anyone can tell me how to do this I
would be most grateful.

Thanks
Alan

The layout is

  <layout name="LATTICE" width="1142" height="747" size="1142"
prefSize="1142" defaultHorSize="-1" defaultVerSize="-1" type="Horizontal">
    <group size="275" prefSize="275" defaultHorSize="86.2099490249485"
defaultVerSize="100" type="Tabbed" currentTabPage="3">
      <item size="0" prefSize="0" defaultHorSize="100"
defaultVerSize="135.448671792079" id="CellLib" visible="True"
status="Dockable" autoHideSize="284" />
      <item size="0" prefSize="0" defaultHorSize="100"
defaultVerSize="100" id="PropExplorer" visible="True" status="Dockable" />
      <item size="0" prefSize="0" defaultHorSize="100"
defaultVerSize="100" id="Pathexplorer" visible="True" status="Dockable" />
      <item size="0" prefSize="0" defaultHorSize="100"
defaultVerSize="100" id="LatLib" visible="True" status="Dockable" />
    </group>
    <group size="857" prefSize="857" defaultHorSize="268.468531431888"
defaultVerSize="100" type="Horizontal">
      <group size="857" prefSize="857" defaultHorSize="97.5819993306241"
defaultVerSize="100" type="Vertical">
        <group size="747" prefSize="747"
defaultHorSize="131.275107773287" defaultVerSize="78.1380753138076"
type="Tabbed" currentTabPage="2">
          <item size="0" prefSize="0" defaultHorSize="100"
defaultVerSize="100" id="Celleditor" visible="True" status="Dockable" />
          <item size="0" prefSize="0" defaultHorSize="100"
defaultVerSize="100" id="Surface" visible="True" status="Dockable" />
          <item size="0" prefSize="0" defaultHorSize="100"
defaultVerSize="100" id="Latdisp" visible="True" status="Dockable" />
*** the drawing area
        </group>
      </group>
      <item size="347" prefSize="168.658643326039"
defaultHorSize="34.3090735477622" defaultVerSize="100"
id="Pathgenerator" visible="True" status="AutoHide"
autoHidePosition="Right" autoHideSize="334" />
    </group>
    <group size="257.845296167248" prefSize="233.970731707317"
defaultHorSize="93.1354866005334" defaultVerSize="100" type="Tabbed"
currentTabPage="0">
      <item size="0" prefSize="0" defaultHorSize="114.584377122372"
defaultVerSize="100" id="Headstock" visible="True" status="AutoHide"
autoHidePosition="Right" autoHideSize="294" />
      <item size="0" prefSize="0" defaultHorSize="100"
defaultVerSize="100" id="Gcodegenerator" visible="True"
status="AutoHide" autoHidePosition="Right" autoHideSize="294"
floatX="448" floatY="85" floatWidth="437" floatHeight="952" />
    </group>
  </layout>


More information about the Monodevelop-list mailing list