//-----------------------------------------------------------------------------
// wx.NET/Utils - WxTopLevelScrolledWindow.cs
//
// wx.NET "WxTopLevelScrolledWindow".
//
// Written by Alexander Olk (xenomorph2@onlinehome.de)
// (C) 2004 Alexander Olk
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: WxTopLevelScrolledWindow.cs,v 1.5 2004/06/14 19:56:36 t9mike Exp $
//-----------------------------------------------------------------------------
using System;
using System.Xml;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
namespace wx.ToWxNet{
public class WxTopLevelScrolledWindow : WxRootObjectBase
{
public override void GenerateCSharpCode()
{
string baseclass = "Panel";
linesout.Add( BetweenLine( 1 ) );
linesout.Add( " " );
// fix for XRC
if ( WxObjectBase.generateFromSource == 2 )
{
classname = name;
}
linesout.Add( "\tpublic class " + classname + " : " + baseclass );
linesout.Add( "\t{" );
// add IDs
if ( allIDs.Count > 0 )
{
regionIDS.Add( "\t\tpublic enum Cmd {" );
for ( int i = 0; i < allIDs.Count; i++ )
{
if ( i < ( allIDs.Count - 1 ) )
regionIDS.Add( "\t\t\t" + allIDs[i] + "," );
else
regionIDS.Add( "\t\t\t" + allIDs[i] );
}
regionIDS.Add( "\t\t}" );
}
// now add it to linesout...
linesout.Add( "\t\t" + doNotChangeCode );
linesout.Add( "\t\t#region \"TowxNET IDS: " + classname +"\"" );
foreach( string str in regionIDS )
{
linesout.Add( str );
}
linesout.Add( "\t\t#endregion" );
linesout.Add( " ");
linesout.Add( BetweenLine( 2 ) );
linesout.Add( " " );
// add wxObjects
if ( allObjs.Count > 0 )
{
for ( int i = 0; i < allObjs.Count; i++ )
{
regionObjects.Add( "\t\tprotected " + allObjs[i] + ";" );
}
}
// now add it to linesout...
linesout.Add( "\t\t" + doNotChangeCode );
linesout.Add( "\t\t#region \"TowxNET Objects: " + classname +"\"" );
foreach( string str in regionObjects )
{
linesout.Add( str );
}
linesout.Add( "\t\t#endregion" );
linesout.Add( " " );
linesout.Add( BetweenLine( 2 ) );
linesout.Add( " " );
// ctor
linesout.Add( "\t\tpublic " + classname + "( Window parent, int id, string title )" );
StringBuilder basestring = new StringBuilder();
basestring.Append( "\t\t\t: base( parent, id , wxDefaultPosition, " );
basestring.Append( size.Length > 0 ? "new Size( " + size + " )" : "wxDefaultSize" );
basestring.Append( ", " );
basestring.Append( style.Length > 0 ? style : "wxDEFAULT_DIALOG_STYLE" );
basestring.Append( ", \"" + title + "\" )" );
linesout.Add( basestring.ToString() );
linesout.Add( "\t\t{" );
linesout.Add( "\t\t\tInitializeComponent();" );
linesout.Add( "\t\t}" );
linesout.Add( " " );
linesout.Add( BetweenLine( 2 ) );
linesout.Add( " " );
linesout.Add( "\t\t" + doNotChangeCode );
linesout.Add( "\t\t#region \"TowxNET CTOR: " + classname +"\"" );
// InitializeComponent()
regionCTOR.Add( "\t\tpublic void InitializeComponent()" );
regionCTOR.Add( "\t\t{" );
regionCTOR.Add( "\t\t\t//common" );
// add code from all objects to the common
AddCtorLines( objects, regionCTOR );
regionCTOR.Add( " " );
regionCTOR.Add( "\t\t\t//Properties" );
AddPropertiesSelf( regionCTOR );
AddPropertyLinesSelf( regionCTOR );
AddPropertyLines( objects, regionCTOR );
regionCTOR.Add( " " );
regionCTOR.Add( "\t\t\t//Layout" );
AddLayoutLines( objects, regionCTOR );
// normally there should be at least one sizer
if ( WxObjectBase.topsizer != null )
{
regionCTOR.Add( "\t\t\tAutoLayout = true;" );
regionCTOR.Add( "\t\t\tSetSizer( " + WxObjectBase.topsizer.name + " );" );
regionCTOR.Add( "\t\t\tLayout();" );
}
if ( centered.Length > 0 )
{
regionCTOR.Add( "\t\t\tCentre();" );
}
regionCTOR.Add( "\t\t}" );
// now add it to linesout...
foreach ( string str in regionCTOR )
{
linesout.Add( str );
}
linesout.Add( "\t\t#endregion" );
linesout.Add( "\t}" );
linesout.Add( " " );
}
//---------------------------------------------------------------------
public override void GenerateBasicCode()
{
string baseclass = "Panel";
linesout.Add( BetweenLine( 1 ) );
linesout.Add( " " );
// fix for XRC
if ( WxObjectBase.generateFromSource == 2 )
{
classname = name;
}
linesout.Add( "\tPublic Class " + classname );
linesout.Add( "\t\tInherits" + baseclass );
linesout.Add( " " );
// add IDs
if ( allIDs.Count > 0 )
{
regionIDS.Add( "\t\tPublic Enum Cmd" );
for ( int i = 0; i < allIDs.Count; i++ )
{
regionIDS.Add( "\t\t\t" + allIDs[i] );
}
regionIDS.Add( "\t\tEnd Enum" );
}
// now add it to linesout...
linesout.Add( "\t\t" + doNotChangeCode );
linesout.Add( "\t\t#region \"TowxNET IDS: " + classname + "\"");
foreach( string str in regionIDS )
{
linesout.Add( str );
}
linesout.Add( "\t\t#end region" );
linesout.Add( " ");
linesout.Add( BetweenLine( 2 ) );
linesout.Add( " " );
// add wxObjects
if ( allObjsBasic.Count > 0 )
{
for ( int i = 0; i < allObjsBasic.Count; i++ )
{
regionObjects.Add( "\t\tProtected WithEvents " + allObjsBasic[i] );
}
}
// now add it to linesout...
linesout.Add( "\t\t" + doNotChangeCode );
linesout.Add( "\t\t#region \"TowxNET Objects: " + classname + "\"");
foreach( string str in regionObjects )
{
linesout.Add( str );
}
linesout.Add( "\t\t#end region" );
linesout.Add( " " );
linesout.Add( BetweenLine( 2 ) );
linesout.Add( " " );
// ctor
linesout.Add( "\t\tPublic Sub New( ByVal parent As Window, ByVal id As Integer, ByVal title As String )" );
StringBuilder basestring = new StringBuilder();
basestring.Append( "\t\t\tMyBase.New( parent, id , \"" + title + "\", wxDefaultPosition, " );
basestring.Append( size.Length > 0 ? "new Size( " + size + " )" : "wxDefaultSize" );
basestring.Append( ", " );
basestring.Append( style.Length > 0 ? VBCorrectStyle(style) : "wxDEFAULT_DIALOG_STYLE" );
basestring.Append( ", \"" + title + "\" )" );
linesout.Add( basestring.ToString() );
linesout.Add( " " );
linesout.Add( "\t\t\tInitializeComponent" );
linesout.Add( "\t\tEnd Sub" );
linesout.Add( " " );
linesout.Add( BetweenLine( 2 ) );
linesout.Add( " " );
linesout.Add( "\t\t" + doNotChangeCode );
linesout.Add( "\t\t#region \"TowxNET CTOR: " + classname + "\"");
regionCTOR.Add( "\t\tPublic Sub InitializeComponent()" );
regionCTOR.Add( " " );
regionCTOR.Add( "\t\t\t'common" );
// add code from all objects to the ctor
AddCtorLines( objects, regionCTOR );
regionCTOR.Add( " " );
regionCTOR.Add( "\t\t\t'Properties" );
AddPropertiesSelf( regionCTOR );
AddPropertyLinesSelf( regionCTOR );
AddPropertyLines( objects, regionCTOR );
regionCTOR.Add( " " );
regionCTOR.Add( "\t\t\t'Layout" );
AddLayoutLines( objects, regionCTOR );
// normally there should be at least one sizer
if ( WxObjectBase.topsizer != null )
{
regionCTOR.Add( "\t\t\tAutoLayout = True" );
regionCTOR.Add( "\t\t\tSetSizer( " + WxObjectBase.topsizer.name + " )" );
regionCTOR.Add( "\t\t\tLayout()" );
}
if ( centered.Length > 0 )
{
regionCTOR.Add( "\t\t\tCentre()" );
}
regionCTOR.Add( "\t\tEnd Sub" );
// now add it to linesout...
foreach ( string str in regionCTOR )
{
linesout.Add( str );
}
linesout.Add( "\t\t#end region" );
linesout.Add( " " );
linesout.Add( "\tEnd Class" );
linesout.Add( " " );
}
}
}
|