//-----------------------------------------------------------------------------
// wx.NET/Utils - WxRootObjectBase.cs
//
// wx.NET "WxRootObjectBase".
//
// Written by Alexander Olk (xenomorph2@onlinehome.de)
// (C) 2004 Alexander Olk
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: WxRootObjectBase.cs,v 1.2 2004/06/08 05:10:01 t9mike Exp $
//-----------------------------------------------------------------------------
using System;
using System.Xml;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
namespace wx.ToWxNet{
public class WxRootObjectBase : WxObjectBase
{
public StringCollection linesout = new StringCollection();
public StringCollection regionIDS = new StringCollection();
public StringCollection regionObjects = new StringCollection();
public StringCollection regionCTOR = new StringCollection();
public StringCollection regionPROPERTIES = new StringCollection();
public StringCollection regionLAYOUT = new StringCollection();
public WxStatusBarObject wxStatusBarObject = null;
public WxToolBarObject wxToolBarObject = null;
public WxMenuBarObject wxMenuBarObject = null;
public string stringDoNotChangeCode = "Do not change the code between region and endregion ( incl. region and endregion )...";
//---------------------------------------------------------------------
public override void Start()
{
XmlTextReader xtr = WxObjectBase.xtr;
WxObjectBase.baseptr = this;
topsizer = null;
while ( xtr.Read() )
{
switch ( xtr.NodeType )
{
case XmlNodeType.Element:
switch ( xtr.Name )
{
case "object":
ReadObjectAttributes();
if ( !CheckCommonObjects() )
{
switch ( objectBase )
{
case "EditMenuBar":
wxMenuBarObject = new WxMenuBarObject();
wxMenuBarObject.parent = this;
wxMenuBarObject.name = objectName;
wxMenuBarObject.classname = objectClassName;
wxMenuBarObject.basename = objectBase;
wxMenuBarObject.id = AddObj( objectClassName, objectName );
wxMenuBarObject.Start();
break;
case "EditStatusBar":
wxStatusBarObject = new WxStatusBarObject();
wxStatusBarObject.parent = this;
wxStatusBarObject.name = objectName;
wxStatusBarObject.classname = objectClassName;
wxStatusBarObject.basename = objectBase;
wxStatusBarObject.id = AddObj( objectClassName, objectName );
wxStatusBarObject.Start();
break;
case "EditToolBar":
wxToolBarObject = new WxToolBarObject();
wxToolBarObject.parent = this;
wxToolBarObject.name = objectName;
wxToolBarObject.classname = objectClassName;
wxToolBarObject.basename = objectBase;
wxToolBarObject.id = AddObj( objectClassName, objectName );
wxToolBarObject.Start();
break;
}
}
break;
case "style":
style = Next;
break;
case "title":
title = Next;
break;
case "menubar":
menubar = Next;
break;
case "statusbar":
statusbar = Next;
break;
case "toolbar":
toolbar = Next;
break;
case "size":
AddSize( Next );
break;
case "tooltip":
tooltip = Next;
break;
case "foreground":
foreground = Next;
break;
case "background":
background = Next;
break;
case "id":
AddID( Next );
break;
case "focused":
focused = Next;
break;
case "font":
fontObject = new WxFontObject();
fontObject.parent = this;
fontObject.Start();
break;
case "hidden":
hidden = Next;
break;
case "disabled":
disabled = Next;
break;
case "default":
sdefault = Next;
break;
case "icon":
icon = Next;
break;
case "centered":
centered = Next;
break;
}
break;
case XmlNodeType.EndElement:
if ( xtr.Name == "object" )
{
GenerateCode();
return;
}
break;
}
}
}
//---------------------------------------------------------------------
// recursive method, adds ctorlines of all child objects
public void AddCtorLines( ArrayList objects, StringCollection alinesout )
{
foreach( WxObjectBase wob in objects )
{
if ( wob.ctorlines.Count > 0 )
{
for ( int i = 0; i < wob.ctorlines.Count; i++ )
alinesout.Add( wob.ctorlines[i] );
}
AddCtorLines( wob.objects, alinesout );
}
}
//---------------------------------------------------------------------
// recursive method, adds propertylines of all child objects
public void AddPropertyLines( ArrayList objects, StringCollection alinesout )
{
foreach( WxObjectBase wob in objects )
{
if ( wob.propertylines.Count > 0 )
{
for ( int i = 0; i < wob.propertylines.Count; i++ )
alinesout.Add( wob.propertylines[i] );
}
AddPropertyLines( wob.objects, alinesout );
}
}
//---------------------------------------------------------------------
// only for the four main objects, adds properties
public void AddPropertyLinesSelf( StringCollection alinesout )
{
if ( propertylines.Count > 0 )
{
for ( int i = 0; i < propertylines.Count; i++ )
{
alinesout.Add( propertylines[i] );
}
}
}
//---------------------------------------------------------------------
// recursive method, adds layoutlines of all child objects
public void AddLayoutLines( ArrayList objects, StringCollection alinesout )
{
foreach( WxObjectBase wob in objects )
{
AddLayoutLines( wob.objects, alinesout );
if ( wob.layoutlines.Count > 0 )
{
for ( int i = 0; i < wob.layoutlines.Count; i++ )
{
alinesout.Add( wob.layoutlines[i] );
}
}
}
}
//---------------------------------------------------------------------
// returns stringDoNotChangeCode
public string doNotChangeCode
{
get {
string retval = "";
switch ( outputCodeType )
{
case 1:
retval = "// " + stringDoNotChangeCode;
break;
case 2:
retval = "' " + stringDoNotChangeCode;
break;
}
return retval;
}
}
//---------------------------------------------------------------------
public string BetweenLine( int numberTabs )
{
StringBuilder sb = new StringBuilder();
for ( int i = 0; i < numberTabs; ++i )
sb.Append( "\t" );
switch ( outputCodeType )
{
case 1:
sb.Append( "//" );
break;
case 2:
sb.Append( "'" );
break;
}
sb.Append( "---------------------------------------------------------------------" );
return sb.ToString();
}
}
}
|