Caret.cs :  » GUI » wx-NET » wx » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GUI » wx NET 
wx NET » wx » Caret.cs
//-----------------------------------------------------------------------------
// wx.NET - Caret.cs
//
// The wxCaret wrapper class.
//
// Written by Bryan Bulten (bryan@bulten.ca)
// (C) 2003 by Bryan Bulten
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: Caret.cs,v 1.8 2007/07/02 20:52:56 harald_meyer Exp $
//-----------------------------------------------------------------------------

using System;
using System.Drawing;
using System.Runtime.InteropServices;

namespace wx{
  public class Caret : Object
  {
    [DllImport("wx-c")] static extern IntPtr wxCaret_ctor();
    [DllImport("wx-c")] static extern void wxCaret_dtor(IntPtr self);
    [DllImport("wx-c")] static extern bool wxCaret_Create(IntPtr self, IntPtr window, int width, int height);
    [DllImport("wx-c")] static extern bool wxCaret_IsOk(IntPtr self);
    [DllImport("wx-c")] static extern bool wxCaret_IsVisible(IntPtr self);
    [DllImport("wx-c")] static extern void wxCaret_GetPosition(IntPtr self, out int x, out int y);
    [DllImport("wx-c")] static extern void wxCaret_GetSize(IntPtr self, out int width, out int height);
    [DllImport("wx-c")] static extern IntPtr wxCaret_GetWindow(IntPtr self);
    [DllImport("wx-c")] static extern void wxCaret_SetSize(IntPtr self, int width, int height);
    [DllImport("wx-c")] static extern void wxCaret_Move(IntPtr self, int x, int y);
    [DllImport("wx-c")] static extern void wxCaret_Show(IntPtr self, bool show);
    [DllImport("wx-c")] static extern void wxCaret_Hide(IntPtr self);
    [DllImport("wx-c")] static extern int wxCaret_GetBlinkTime();
    [DllImport("wx-c")] static extern void wxCaret_SetBlinkTime(int milliseconds);
    
    //---------------------------------------------------------------------

    public Caret()
      : this(wxCaret_ctor(), true) {}

    public Caret(IntPtr wxObject)
      : base(wxObject)
    {
      this.wxObject = wxObject;
    }
    
    internal Caret(IntPtr wxObject, bool memOwn)
      : base(wxObject)
    { 
      this.memOwn = memOwn;
      this.wxObject = wxObject;
    }

    public Caret(Window window, Size size)
      : this(window, size.Width, size.Height) {}

    public Caret(Window window, int width, int height)
      : this(wxCaret_ctor(), true)
    {
      if (!wxCaret_Create(wxObject, Object.SafePtr(window), width, height))
      {
        throw new InvalidOperationException("Failed to create Caret");
      }
    }
    
    //---------------------------------------------------------------------
        
    public override void Dispose()
    {
      if (!disposed)
      {
                if (wxObject != IntPtr.Zero)
        {
          if (memOwn)
          {
            wxCaret_dtor(wxObject);
            memOwn = false;
          }
        }
        RemoveObject(wxObject);
        wxObject = IntPtr.Zero;
                --validInstancesCount;
                disposed = true;
      }
      
      base.Dispose();
      GC.SuppressFinalize(this);
    }
    
    //---------------------------------------------------------------------
    
    ~Caret() 
    {
      Dispose();
    }
    
    //---------------------------------------------------------------------

    public bool Create(Window window, int width, int height)
    {
      return wxCaret_Create(wxObject, Object.SafePtr(window), width, height);
    }

    //---------------------------------------------------------------------

    public bool IsOk
    {
      get { return wxCaret_IsOk(wxObject); }
    }

    public bool IsVisible
    {
      get { return wxCaret_IsVisible(wxObject); }
    }

    //---------------------------------------------------------------------

    public Point Position
    {
      get
      {
        int x, y;
        wxCaret_GetPosition(wxObject, out x, out y);
        return new Point(x, y);
      }
      set
      {
        wxCaret_Move(wxObject, value.X, value.Y);
      }
    }

    //---------------------------------------------------------------------

    public Size Size
    {
      get
      {
        int w, h;
        wxCaret_GetSize(wxObject, out w, out h);
        return new Size(w, h);
      }
      set
      {
        wxCaret_SetSize(wxObject, value.Width, value.Height);
      }
    }

    //---------------------------------------------------------------------

    public Window Window
    {
      get
      {
        return (Window)Object.FindObject(wxCaret_GetWindow(wxObject));
      }
    }

    //---------------------------------------------------------------------

    public void Show(bool show)
    {
      wxCaret_Show(wxObject, show);
    }

    public void Hide()
    {
      wxCaret_Hide(wxObject);
    }

    //---------------------------------------------------------------------

    public static int BlinkTime
    {
      get
      {
        return wxCaret_GetBlinkTime();
      }
      set
      {
        wxCaret_SetBlinkTime(value);
      }
    }

    //---------------------------------------------------------------------
  }

  public class CaretSuspend : Object
  {
    [DllImport("wx-c")] static extern IntPtr wxCaretSuspend_ctor(IntPtr win);
    [DllImport("wx-c")] static extern void wxCaretSuspend_dtor(IntPtr self);
    
    //---------------------------------------------------------------------

    public CaretSuspend(Window win)
      : this(wxCaretSuspend_ctor(Object.SafePtr(win)), true) {}
    
    public CaretSuspend(IntPtr wxObject)
      : base(wxObject)
    { 
      this.wxObject = wxObject;
    }
    
    internal CaretSuspend(IntPtr wxObject, bool memOwn)
      : base(wxObject)
    { 
      this.memOwn = memOwn;
      this.wxObject = wxObject;
    }
    
    //---------------------------------------------------------------------
        
    public override void Dispose()
    {
      if (!disposed)
      {
                if (wxObject != IntPtr.Zero)
        {
          if (memOwn)
          {
            wxCaretSuspend_dtor(wxObject);
            memOwn = false;
          }
        }
        RemoveObject(wxObject);
        wxObject = IntPtr.Zero;
                --validInstancesCount;
                disposed = true;
      }
      
      base.Dispose();
      GC.SuppressFinalize(this);
    }
    
    //---------------------------------------------------------------------
    
    ~CaretSuspend() 
    {
      Dispose();
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.