dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] pnetlib/samples XClockEmbed.cs, NONE, 1.1 samples.


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] pnetlib/samples XClockEmbed.cs, NONE, 1.1 samples.build, 1.18, 1.19
Date: Fri, 31 Oct 2003 06:52:58 +0000

Update of /cvsroot/dotgnu-pnet/pnetlib/samples
In directory subversions:/tmp/cvs-serv18499/samples

Modified Files:
        samples.build 
Added Files:
        XClockEmbed.cs 
Log Message:


Check in a sample application that demonstrates how to use 
"EmbeddedApplication".


Index: samples.build
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/samples/samples.build,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** samples.build       11 Oct 2003 05:55:59 -0000      1.18
--- samples.build       31 Oct 2003 06:52:56 -0000      1.19
***************
*** 197,200 ****
--- 197,232 ----
                        <references>
                                <includes if="${CONFIG_REFLECTION}" 
name="../Xsharp/Xsharp.dll"/>
+                               <includes if="${CONFIG_REFLECTION}" 
name="../System/System.dll"/>
+                               <includes if="${CONFIG_REFLECTION}" 
name="../DotGNU.SSL/DotGNU.SSL.dll"/>
+                               <includes if="${CONFIG_REFLECTION}" 
name="../DotGNU.Images/DotGNU.Images.dll"/>
+                               <file name="../runtime/mscorlib.dll"/>
+                       </references>
+ 
+                       <arg compiler="cscc" value="-Wno-empty-input"/>
+                       <arg compiler="cscc" value="-flatin1-charset"/>
+                       <arg compiler="csc" value="/nowarn:626"/>
+                       <arg compiler="csc" value="/nowarn:649"/>
+                       <arg compiler="csc" value="/nowarn:168"/>
+                       <arg compiler="csc" value="/nowarn:67"/>
+                       <arg compiler="csc" value="/nowarn:169"/>
+               </compile>
+ 
+               <!-- Build the XClockEmbed.exe program -->
+               <compile output="XClockEmbed.exe"
+                                target="exe"
+                                unsafe="true"
+                                nostdlib="true"
+                                optimize="true"
+                                debug="true">
+ 
+                       <sources>
+                               <includes if="${CONFIG_REFLECTION}" 
name="XClockEmbed.cs"/>
+                               <file name="dummy.cs"/>
+                       </sources>
+ 
+                       <references>
+                               <includes if="${CONFIG_REFLECTION}" 
name="../Xsharp/Xsharp.dll"/>
+                               <includes if="${CONFIG_REFLECTION}" 
name="../System/System.dll"/>
+                               <includes if="${CONFIG_REFLECTION}" 
name="../DotGNU.SSL/DotGNU.SSL.dll"/>
                                <includes if="${CONFIG_REFLECTION}" 
name="../DotGNU.Images/DotGNU.Images.dll"/>
                                <file name="../runtime/mscorlib.dll"/>

--- NEW FILE: XClockEmbed.cs ---
/*
 * XClockEmbed.cs - Embed "xclock" in an Xsharp app using XC-APPGROUP.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software, you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY, without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program, if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

using System;
using Xsharp;

public class XClockEmbed : TopLevelWindow
{
        // Main entry point.
        public static void Main(String[] args)
        {
                Application app = new Application("XClockEmbed", args);
                XClockEmbed topLevel = new XClockEmbed("Embedded Clock", 200, 
200);
                topLevel.Map();
                app.Run();
                app.Close();
        }

        // Internal state.
        private EmbeddedApplication embed;
        private bool allowClose;

        // Constructor.
        public XClockEmbed(String title, int width, int height)
                : base(title, width, height)
        {
                embed = new Embedder(this, 0, 0, width, height);
                embed.Program = "xclock";
                embed.Launch();
        }

        // Handle resizes of the main application window.
        protected override void OnResize(int width, int height)
        {
                embed.Resize(width, height);
        }

        // Handle close events on the main application window.
        // We pass the close down to the embedded application.
        protected override bool OnClose()
        {
                if(allowClose)
                {
                        return true;
                }
                else
                {
                        embed.Close();
                        return false;
                }
        }

        // Embed window, overriding the "OnClose()" notification.
        private class Embedder : EmbeddedApplication
        {
                // Constructor.
                public Embedder(Widget parent, int x, int y, int width, int 
height)
                        : base(parent, x, y, width, height) {}

                // Receive notification of application closure.
                protected override void OnClose()
                {
                        ((XClockEmbed)Parent).allowClose = true;
                        ((XClockEmbed)Parent).Close();
                }

        }; // class Embedder

}; // class XClockEmbed





reply via email to

[Prev in Thread] Current Thread [Next in Thread]