TabCtrl.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 » TabCtrl.cs
//-----------------------------------------------------------------------------
// wx.NET - TabCtrl.cs
//
// The wxTabCtrl wrapper class.
//
// Written by Alexander Olk (xenomorph2@onlinehome.de)
// (C) 2004 by Alexander Olk
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: TabCtrl.cs,v 1.11 2007/11/25 18:32:34 harald_meyer Exp $
//-----------------------------------------------------------------------------

#if ! __WXMSW__ || ! wxUSE_TAB_DIALOG
#if !wxUSE_TAB_DIALOG
#warning TabCtrl will not be available since this is not configured
#else
#warning TabCtrl will not be available since wx.NET is not compiled for exclusive use under Windows
#endif
#else

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

namespace wx{
  public class TabEvent : Event
  {
    [DllImport("wx-c")] static extern IntPtr wxTabEvent_ctor(int commandType, int id, int nSel, int nOldSel);
    [DllImport("wx-c")] static extern int    wxTabEvent_GetSelection(IntPtr self);
    [DllImport("wx-c")] static extern void   wxTabEvent_SetSelection(IntPtr self, int nSel);
    [DllImport("wx-c")] static extern int    wxTabEvent_GetOldSelection(IntPtr self);
    [DllImport("wx-c")] static extern void   wxTabEvent_SetOldSelection(IntPtr self, int nOldSel);
    [DllImport("wx-c")] static extern void wxTabEvent_Veto(IntPtr self);
    [DllImport("wx-c")] static extern void wxTabEvent_Allow(IntPtr self);
    [DllImport("wx-c")] static extern bool wxTabEvent_IsAllowed(IntPtr self);    

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

    public TabEvent(IntPtr wxObject)
      : base(wxObject) { }

    public TabEvent(int commandType, int id, int nSel, int nOldSel)
      : base(wxTabEvent_ctor(commandType, id, nSel, nOldSel)) { }

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

    public int Selection
    {
      get { return wxTabEvent_GetSelection(wxObject); }
      set { wxTabEvent_SetSelection(wxObject, value); }
    }

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

    public int OldSelection
    {
      get { return wxTabEvent_GetOldSelection(wxObject); }
      set { wxTabEvent_SetOldSelection(wxObject, value); }
    }
    
    //-----------------------------------------------------------------------------    
    
    public void Veto()
    {
      wxTabEvent_Veto(wxObject);
    }
    
    //-----------------------------------------------------------------------------
    
    public void Allow()
    {
      wxTabEvent_Allow(wxObject);
    }
    
    //-----------------------------------------------------------------------------
    
    public bool Allowed
    {
      get { return wxTabEvent_IsAllowed(wxObject); }
    }    
  }

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

  public class TabCtrl : Control
  {
    [DllImport("wx-c")] static extern IntPtr wxTabCtrl_ctor();
    [DllImport("wx-c")] static extern IntPtr wxTabCtrl_ctor2(IntPtr parent, int id, int posX, int posY, int width, int height, uint style, IntPtr name);
    [DllImport("wx-c")] static extern int wxTabCtrl_GetSelection(IntPtr self);
    [DllImport("wx-c")] static extern int wxTabCtrl_GetCurFocus(IntPtr self);
    [DllImport("wx-c")] static extern IntPtr wxTabCtrl_GetImageList(IntPtr self);
    [DllImport("wx-c")] static extern int wxTabCtrl_GetItemCount(IntPtr self);
    [DllImport("wx-c")] static extern bool wxTabCtrl_GetItemRect(IntPtr self, int item, out Rectangle rect);
    [DllImport("wx-c")] static extern int wxTabCtrl_GetRowCount(IntPtr self);
    [DllImport("wx-c")] static extern IntPtr wxTabCtrl_GetItemText(IntPtr self, int item);
    [DllImport("wx-c")] static extern int wxTabCtrl_GetItemImage(IntPtr self, int item);
    [DllImport("wx-c")] static extern IntPtr wxTabCtrl_GetItemData(IntPtr self, int item);
    [DllImport("wx-c")] static extern int wxTabCtrl_SetSelection(IntPtr self, int item);
    [DllImport("wx-c")] static extern void wxTabCtrl_SetImageList(IntPtr self, IntPtr imageList);
    [DllImport("wx-c")] static extern bool wxTabCtrl_SetItemText(IntPtr self, int item, IntPtr text);
    [DllImport("wx-c")] static extern bool wxTabCtrl_SetItemImage(IntPtr self, int item, int image);
    [DllImport("wx-c")] static extern bool wxTabCtrl_SetItemData(IntPtr self, int item, IntPtr data);
    [DllImport("wx-c")] static extern void wxTabCtrl_SetItemSize(IntPtr self, ref Size size);
    [DllImport("wx-c")] static extern bool wxTabCtrl_Create(IntPtr self, IntPtr parent, int id, int posX, int posY, int width, int height, uint style, IntPtr name);
    [DllImport("wx-c")] static extern void wxTabCtrl_SetPadding(IntPtr self, ref Size padding);
    [DllImport("wx-c")] static extern bool wxTabCtrl_DeleteAllItems(IntPtr self);
    [DllImport("wx-c")] static extern bool wxTabCtrl_DeleteItem(IntPtr self, int item);
    [DllImport("wx-c")] static extern int wxTabCtrl_HitTest(IntPtr self, ref Point pt, out int flags);
    [DllImport("wx-c")] static extern bool wxTabCtrl_InsertItem(IntPtr self, int item, IntPtr text, int imageId, IntPtr data);

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

    public TabCtrl(IntPtr wxObject) 
      : base(wxObject) { }

    public TabCtrl()
      : base(wxTabCtrl_ctor()) {}

    public TabCtrl(Window parent, int id)
      : this(parent, id, wxDefaultPosition, wxDefaultSize, 0, "tabCtrl") {}

    public TabCtrl(Window parent, int id, Point pos)
      : this(parent, id, pos, wxDefaultSize, 0, "tabCtrl") {}

    public TabCtrl(Window parent, int id, Point pos, Size size)
      : this(parent, id, pos, size, 0, "tabCtrl") {}

    public TabCtrl(Window parent, int id, Point pos, Size size, uint style)
      : this(parent, id, pos, size, style, "tabCtrl") {}

    public TabCtrl(Window parent, int id, Point pos, Size size, uint style, string name)
      : this(parent, id, pos, size, style, wxString.SafeNew(name)) {}

    public TabCtrl(Window parent, int id, Point pos, Size size, uint style, wxString name)
      : base(wxTabCtrl_ctor2(Object.SafePtr(parent), id, pos.X, pos.Y, size.Width, size.Height, (uint)style, Object.SafePtr(name))) {}
      
    //---------------------------------------------------------------------
    // ctors with self created id
    
    public TabCtrl(Window parent)
      : this(parent, Window.UniqueID, wxDefaultPosition, wxDefaultSize, 0, "tabCtrl") {}

    public TabCtrl(Window parent, Point pos)
      : this(parent, Window.UniqueID, pos, wxDefaultSize, 0, "tabCtrl") {}

    public TabCtrl(Window parent, Point pos, Size size)
      : this(parent, Window.UniqueID, pos, size, 0, "tabCtrl") {}

    public TabCtrl(Window parent, Point pos, Size size, uint style)
      : this(parent, Window.UniqueID, pos, size, style, "tabCtrl") {}

    public TabCtrl(Window parent, Point pos, Size size, uint style, string name)
      : this(parent, Window.UniqueID, pos, size, style, name) {}

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

    public bool Create(Window parent, int id)
    {
      return Create(parent, id, wxDefaultPosition, wxDefaultSize, 0, "tabCtrl");
    }

    public bool Create(Window parent, int id, Point pos)
    {
      return Create(parent, id, pos, wxDefaultSize, 0, "tabCtrl");
    }

    public bool Create(Window parent, int id, Point pos, Size size)
    {
      return Create(parent, id, pos, size, 0, "tabCtrl");
    }

    public bool Create(Window parent, int id, Point pos, Size size, uint style)
    {
      return Create(parent, id, pos, size, style, "tabCtrl");
    }

    public bool Create(Window parent, int id, Point pos, Size size, uint style, string name)
    {
            return this.Create(parent, id, pos, size, style, wxString.SafeNew(name));
        }
    public bool Create(Window parent, int id, Point pos, Size size, uint style, wxString name)
    {
      return wxTabCtrl_Create(wxObject, Object.SafePtr(parent), id, pos.X, pos.Y, size.Width, size.Height, (uint)style, Object.SafePtr(name));
    }
    
    //-----------------------------------------------------------------------------

    public int Selection
    {
      get { return wxTabCtrl_GetSelection(wxObject); }
      set { wxTabCtrl_SetSelection(wxObject, value); }
    }
    
    //-----------------------------------------------------------------------------

    public int CurFocus
    {
      get { return wxTabCtrl_GetCurFocus(wxObject); }
    }
    
    //-----------------------------------------------------------------------------

    public ImageList ImageList
    {
      get { return (ImageList)FindObject(wxTabCtrl_GetImageList(wxObject), typeof(ImageList)); }
      set { wxTabCtrl_SetImageList(wxObject, Object.SafePtr(value)); }
    }
    
    //-----------------------------------------------------------------------------

    public int ItemCount
    {
      get { return wxTabCtrl_GetItemCount(wxObject); }
    }
    
    //-----------------------------------------------------------------------------

    public bool GetItemRect(int item, out Rectangle rect)
    {
      return wxTabCtrl_GetItemRect(wxObject, item, out rect);
    }
    
    //-----------------------------------------------------------------------------

    public int RowCount
    {
      get { return wxTabCtrl_GetRowCount(wxObject); }
    }
    
    //-----------------------------------------------------------------------------

    public string GetItemText(int item)
    {
      return new wxString(wxTabCtrl_GetItemText(wxObject, item), true);
    }
    
    //-----------------------------------------------------------------------------

    public int GetItemImage(int item)
    {
      return wxTabCtrl_GetItemImage(wxObject, item);
    }
    
    //-----------------------------------------------------------------------------

    public IntPtr GetItemData(int item)
    {
      return wxTabCtrl_GetItemData(wxObject, item);
    }
    
    //-----------------------------------------------------------------------------

    public bool SetItemText(int item, string text)
    {
            wxString wxtext=wxString.SafeNew(text);
      return wxTabCtrl_SetItemText(wxObject, item, Object.SafePtr(wxtext));
    }
    
    //-----------------------------------------------------------------------------

    public bool SetItemImage(int item, int image)
    {
      return wxTabCtrl_SetItemImage(wxObject, item, image);
    }
    
    //-----------------------------------------------------------------------------

    public bool SetItemData(int item, IntPtr data)
    {
      return wxTabCtrl_SetItemData(wxObject, item, data);
    }
    
    //-----------------------------------------------------------------------------

    public Size ItemSize
    {
      set { wxTabCtrl_SetItemSize(wxObject, ref value); }
    }
    
    //-----------------------------------------------------------------------------

    public Size Padding
    {
      set { wxTabCtrl_SetPadding(wxObject, ref value); }
    }
    
    //-----------------------------------------------------------------------------

    public bool DeleteAllItems()
    {
      return wxTabCtrl_DeleteAllItems(wxObject);
    }
    
    //-----------------------------------------------------------------------------

    public bool DeleteItem(int item)
    {
      return wxTabCtrl_DeleteItem(wxObject, item);
    }
    
    //-----------------------------------------------------------------------------

    public int HitTest(Point pt, out int flags)
    {
      return wxTabCtrl_HitTest(wxObject, ref pt, out flags);
    }
    
    //-----------------------------------------------------------------------------

    public bool InsertItem(int item, string text)
    {
      return InsertItem(item, text, -1, IntPtr.Zero);
    }
    
    public bool InsertItem(int item, string text, int imageId)
    {
      return InsertItem(item, text, imageId, IntPtr.Zero);
    }
    
    public bool InsertItem(int item, string text, int imageId, IntPtr data)
    {
            wxString wxtext=wxString.SafeNew(text);
      return wxTabCtrl_InsertItem(wxObject, item, Object.SafePtr(wxtext), imageId, data);
    }

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

    public event EventListener SelectionChange
    {
      add { AddCommandListener(Event.wxEVT_COMMAND_TAB_SEL_CHANGED, ID, value, this); }
      remove { RemoveHandler(value, this); }
    }

    public event EventListener SelectionChanging
    {
      add { AddCommandListener(Event.wxEVT_COMMAND_TAB_SEL_CHANGING, ID, value, this); }
      remove { RemoveHandler(value, this); }
    }
  }
}

#endif
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.