Splitter.cs :  » GUI » wx-NET » wx » SampleSplitter » 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 » SampleSplitter » Splitter.cs
//-----------------------------------------------------------------------------
// wx.NET/Samples - Splitter.cs
//
// A wx.NET version of the wxWidgets "splitter" sample.
//
// Written by Jason Perkins (jason@379.com)
// (C) 2003 by 379, Inc.
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: Splitter.cs,v 1.12 2007/10/21 15:30:42 harald_meyer Exp $
//-----------------------------------------------------------------------------

using System;
using System.Drawing;

namespace wx.SampleSplitter{
  enum Cmd
  {
    Quit,
    SplitHorizontal,
    SplitVertical,
    Unsplit,
    SplitLive,
    SetPosition,
    SetMinSize
  }


  public class SplitterApp : wx.App
  {
    //---------------------------------------------------------------------

    public override bool OnInit()
    {
      MyFrame frame = new MyFrame();
      frame.Show(true);
      return true;
    }

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

    [STAThread]
    static void Main()
    {
      SplitterApp app = new SplitterApp();
      app.Run();
    }

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


  public class MyFrame : wx.Frame
  {
    private MySplitterWindow splitter;
    private MyCanvas         left, right;

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

    public MyFrame()
      : base("wxSplitterWindow Sample",
             wxDefaultPosition, new Size(420,300),
             wxDEFAULT_FRAME | wxNO_FULL_REPAINT_ON_RESIZE)
    {
      wx.Menu splitMenu = new wx.Menu();
      splitMenu.Append((int)Cmd.SplitVertical, "Split &Vertically\tCtrl-V", "Split vertically");
      splitMenu.Append((int)Cmd.SplitHorizontal, "Split &Horizontally\tCtrl-H", "Split horizontally");
      splitMenu.Append((int)Cmd.Unsplit, "&Unsplit\tCtrl-U", "Unsplit");
      splitMenu.AppendSeparator();
      splitMenu.AppendCheckItem((int)Cmd.SplitLive, "&Live Update\tCtrl-L", "Toggle live update mode");
      splitMenu.Append((int)Cmd.SetPosition, "Set &Position\tCtrl-P", "Set the splitter position");
      splitMenu.Append((int)Cmd.SetMinSize, "Set &Minimum Size\tCtrl-M", "Set the minimum pane size");
      splitMenu.AppendSeparator();
      splitMenu.Append((int)Cmd.Quit, "E&xit\tAlt-X", "Exit");

      wx.MenuBar menuBar = new wx.MenuBar();
      menuBar.Append(splitMenu, "&Splitter");
      MenuBar = menuBar;

      menuBar.Check((int)Cmd.SplitLive, true);

      CreateStatusBar(2);
      SetStatusText("Min pane size = 0", 1);

      splitter = new MySplitterWindow(this);

      left = new MyCanvas(splitter);
      left.BackgroundColour = new wx.Colour("RED");
      left.SetScrollbars(20, 20, 50, 50);
      left.Cursor = new Cursor(StockCursor.wxCURSOR_MAGNIFIER);

      right = new MyCanvas(splitter);
      right.BackgroundColour = new wx.Colour("CYAN");
      right.SetScrollbars(20, 20, 50, 50);

      splitter.SplitVertically(left, right, 100);

      // Set up the event table

      EVT_MENU((int)Cmd.SplitVertical,    new EventListener(SplitVertical));
      EVT_MENU((int)Cmd.SplitHorizontal,  new EventListener(SplitHorizontal));
      EVT_MENU((int)Cmd.Unsplit,          new EventListener(Unsplit));
      EVT_MENU((int)Cmd.SplitLive,        new EventListener(ToggleLive));
      EVT_MENU((int)Cmd.SetPosition,      new EventListener(SetPosition));
      EVT_MENU((int)Cmd.SetMinSize,       new EventListener(SetMinSize));

      EVT_MENU((int)Cmd.Quit,             new EventListener(OnQuit));

      EVT_UPDATE_UI((int)Cmd.SplitVertical,   new EventListener(UpdateUIVertical));
      EVT_UPDATE_UI((int)Cmd.SplitHorizontal, new EventListener(UpdateUIHorizontal));
      EVT_UPDATE_UI((int)Cmd.Unsplit,         new EventListener(UpdateUIUnsplit));
    }

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

    public void SplitHorizontal(object sender, wx.Event e)
    {
      if (splitter.IsSplit)
        splitter.Unsplit();

      left.Show(true);
      right.Show(true);

      splitter.SplitHorizontally(left, right);

      SetStatusText("Splitter split horizontally", 1);
    }

    public void SplitVertical(object sender, wx.Event e)
    {
      if (splitter.IsSplit)
        splitter.Unsplit();

      left.Show(true);
      right.Show(true);

      splitter.SplitVertically(left, right);

      SetStatusText("Splitter split vertically", 1);
    }

    public void Unsplit(object sender, wx.Event e)
    {
      if (splitter.IsSplit)
        splitter.Unsplit();
      SetStatusText("No splitter", 1);
    }

    public void ToggleLive(object sender, wx.Event e)
    {
      CommandEvent ce = (CommandEvent)e;
      if (ce.IsChecked)
        splitter.StyleFlags |= SplitterWindow.wxSP_LIVE_UPDATE;
      else
                splitter.StyleFlags &= ~(uint)SplitterWindow.wxSP_LIVE_UPDATE;
    }

    public void SetPosition(object sender, wx.Event e)
    {
    }

    public void SetMinSize(object sender, wx.Event e)
    {
    }

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

    public void OnQuit(object sender, wx.Event e)
    {
      Close(true);
    }

    public void UpdateUIHorizontal(object sender, wx.Event e)
    {
      UpdateUIEvent ue = (UpdateUIEvent)e;
      ue.Enabled = (!splitter.IsSplit || splitter.SplitMode != SplitMode.wxSPLIT_HORIZONTAL);
    }

    public void UpdateUIVertical(object sender, wx.Event e)
    {
      UpdateUIEvent ue = (UpdateUIEvent)e;
      ue.Enabled = (!splitter.IsSplit || splitter.SplitMode != SplitMode.wxSPLIT_VERTICAL);
    }

    public void UpdateUIUnsplit(object sender, wx.Event e)
    {
      UpdateUIEvent ue = (UpdateUIEvent)e;
      ue.Enabled = splitter.IsSplit;
    }

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



  public class MySplitterWindow : wx.SplitterWindow
  {
    private Frame parent;

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

    public MySplitterWindow(wx.Frame parent)
      : base(parent, -1,
             wxDefaultPosition, wxDefaultSize,
             wxSP_3D | wxSP_LIVE_UPDATE | wxCLIP_CHILDREN)
    {
      this.parent = parent;
    }

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

    public void OnPositionChanged(object sender, wx.Event e)
    {
    }

    public void OnPositionChanging(object sender, wx.Event e)
    {
    }

    public void OnDoubleClick(object sender, wx.Event e)
    {
    }

    public void OnUnsplit(object sender, wx.Event e)
    {
    }

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


  public class MyCanvas : wx.ScrolledWindow
  {
    //---------------------------------------------------------------------

    public MyCanvas(Window parent)
      : base(parent)
    {
    }

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

    public override void OnDraw(wx.DC dc)
    {
      dc.Pen = new Pen("BLACK", 1, FillStyle.wxSOLID);
      dc.DrawLine(0, 0, 100, 100);

      dc.BackgroundMode = FillStyle.wxTRANSPARENT;
      dc.DrawText("Testing", 50, 50);

      dc.Pen = new Pen("RED", 1, FillStyle.wxSOLID);
      dc.Brush = new Brush("GREEN", FillStyle.wxSOLID);
      dc.DrawRectangle(120, 120, 100, 80);
    }

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