|
//
// ___ _____ ___ ___ __ __
// / __|_ _/ _ \| _ \ \/ |
// \__ \ | || (_) | / |\/| |
// |___/ |_| \___/|_|_\_| |_|
//
// Storm.TextEditor.dll
// ��������������������
// Storm.TabControl.dll was created under the LGPL
// license. Some of the code was created from scratch,
// some was not. Code not created from scratch was
// based on the DotNetFireball framework and evolved
// from that.
//
// What I mostly did in this library was that I
// cleaned up the code, structured it, documentated
// it and added new features.
//
// Although it might not sound like it, it was very
// hard and took a long (pretty much a shitload)
// time. Why? Well, this was* some of the crappiest,
// most unstructured, undocumentated, ugly code I've
// ever seen. It would actually have taken me less
// time to create it from scratch, but I figured that
// out too late. Figuring out what the code actually
// did and then documentating it was (mostly) a
// day-long process. Well, I hope you enjoy some of
// my hard work. /rant
//
// Of course some/most of it is made from scratch by me.
// *Yes, was. It isn't now. :) Some of the naming
// conventions might still seem a little bit off though.
//
// What is Storm?
// ��������������
// Storm is a set of dynamic link libraries used in
// Theodor "Vestras" Storm Kristensen's application
// "Moonlite".
//
//
// Thanks:
// �������
// - The DotNetFireball team for creating and publishing
// DotNetFireball which I based some of my code on.
//
//
// Copyright (c) Theodor "Vestras" Storm Kristensen 2009
// �����������������������������������������������������
//
namespace Storm.TextEditor.Controls
{
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Design;
using System.Diagnostics.SymbolStore;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Windows.Forms;
using Storm.TextEditor;
using Storm.TextEditor.Controls;
using Storm.TextEditor.Controls.Core;
using Storm.TextEditor.Controls.Core.Globalization;
using Storm.TextEditor.Controls.Core.Timers;
using Storm.TextEditor.Controls.IntelliMouse;
using Storm.TextEditor.Document;
using Storm.TextEditor.Document.Exporters;
using Storm.TextEditor.Forms;
using Storm.TextEditor.Interacting;
using Storm.TextEditor.Painting;
using Storm.TextEditor.Parsing;
using Storm.TextEditor.Parsing.Base;
using Storm.TextEditor.Parsing.Classes;
using Storm.TextEditor.Parsing.Language;
using Storm.TextEditor.Preset;
using Storm.TextEditor.Preset.Painting;
using Storm.TextEditor.Preset.TextDraw;
using Storm.TextEditor.Printing;
using Storm.TextEditor.Utilities;
using Storm.TextEditor.Win32;
[ToolboxItem(false)]
public class SplitViewChildControl : Widget
{
public SplitViewThumbControl LeftThumb;
public SplitViewThumbControl TopThumb;
protected HScrollBar hScroll;
protected VScrollBar vScroll;
private Panel Filler;
private Container components = null;
public SplitViewChildControl()
{
InitializeComponent();
hScroll.VisibleChanged += new EventHandler(Scroll_VisibleChanged);
vScroll.VisibleChanged += new EventHandler(Scroll_VisibleChanged);
// Puzzle.Windows.NativeMethods.OpenThemeData (Handle,"EDIT");
// Puzzle.Windows.NativeMethods.OpenThemeData (vScroll.Handle,"SCROLLBAR");
// Puzzle.Windows.NativeMethods.OpenThemeData (hScroll.Handle,"SCROLLBAR");
}
void Scroll_VisibleChanged(object sender, EventArgs e)
{
Filler.Visible = hScroll.Visible || vScroll.Visible;
LeftThumb.Visible = LeftThumbVisible && hScroll.Visible;
TopThumb.Visible = TopThumbVisible && vScroll.Visible;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Component Designer generated code
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof (SplitViewChildControl));
hScroll = new System.Windows.Forms.HScrollBar();
vScroll = new System.Windows.Forms.VScrollBar();
Filler = new System.Windows.Forms.Panel();
TopThumb = new SplitViewThumbControl();
LeftThumb = new SplitViewThumbControl();
SuspendLayout();
//
// hScroll
//
hScroll.Location = new System.Drawing.Point(-4, 292);
hScroll.Name = "hScroll";
hScroll.Size = new System.Drawing.Size(440, 16);
hScroll.TabIndex = 0;
//
// vScroll
//
vScroll.Location = new System.Drawing.Point(440, 0);
vScroll.Maximum = 300;
vScroll.Minimum = 0;
vScroll.Name = "vScroll";
vScroll.Size = new System.Drawing.Size(16, 360);
vScroll.TabIndex = 1;
//
// Filler
//
Filler.BackColor = System.Drawing.SystemColors.Control;
Filler.Location = new System.Drawing.Point(64, 260);
Filler.Name = "Filler";
Filler.Size = new System.Drawing.Size(20, 20);
Filler.TabIndex = 3;
//
// TopThumb
//
TopThumb.BackColor = System.Drawing.SystemColors.Control;
TopThumb.Cursor = System.Windows.Forms.Cursors.HSplit;
TopThumb.Location = new System.Drawing.Point(101, 17);
TopThumb.Name = "TopThumb";
TopThumb.Size = new System.Drawing.Size(16, 8);
TopThumb.TabIndex = 3;
TopThumb.Visible = false;
//
// LeftThumb
//
LeftThumb.BackColor = System.Drawing.SystemColors.Control;
LeftThumb.Cursor = System.Windows.Forms.Cursors.VSplit;
LeftThumb.Location = new System.Drawing.Point(423, 17);
LeftThumb.Name = "LeftThumb";
LeftThumb.Size = new System.Drawing.Size(8, 16);
LeftThumb.TabIndex = 3;
LeftThumb.Visible = false;
//
// SplitViewChildControl
//
Controls.AddRange(new System.Windows.Forms.Control[]
{
TopThumb,
LeftThumb,
Filler,
vScroll,
hScroll
});
Name = "SplitViewChildControl";
Size = new System.Drawing.Size(456, 376);
ResumeLayout(false);
}
#endregion
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
DoResize();
}
protected Rectangle ClientArea
{
get
{
Rectangle r = ClientRectangle;
r.Width -= vScroll.Width;
r.Height -= hScroll.Height;
return r;
}
}
private void DoResize()
{
/*try
{*/
SuspendLayout();
if (TopThumb == null)
return;
TopThumb.Width = SystemInformation.VerticalScrollBarWidth;
LeftThumb.Height = SystemInformation.HorizontalScrollBarHeight;
vScroll.Width = SystemInformation.VerticalScrollBarWidth;
hScroll.Height = SystemInformation.HorizontalScrollBarHeight;
if (TopThumbVisible)
{
vScroll.Top = TopThumb.Height;
if (hScroll.Visible)
vScroll.Height = ClientHeight - hScroll.Height - TopThumb.Height;
else
vScroll.Height = ClientHeight - TopThumb.Height;
}
else
{
if (hScroll.Visible)
vScroll.Height = ClientHeight - hScroll.Height;
else
vScroll.Height = ClientHeight;
vScroll.Top = 0;
}
if (LeftThumbVisible)
{
hScroll.Left = LeftThumb.Width;
if (vScroll.Visible)
hScroll.Width = ClientWidth - vScroll.Width - LeftThumb.Width;
else
hScroll.Width = ClientWidth - LeftThumb.Width;
}
else
{
if (vScroll.Visible)
hScroll.Width = ClientWidth - vScroll.Width;
else
hScroll.Width = ClientWidth;
hScroll.Left = 0;
}
vScroll.Left = ClientWidth - vScroll.Width;
hScroll.Top = ClientHeight - hScroll.Height;
LeftThumb.Left = 0;
LeftThumb.Top = hScroll.Top;
TopThumb.Left = vScroll.Left;
TopThumb.Top = 0;
Filler.Left = vScroll.Left;
Filler.Top = hScroll.Top;
Filler.Width = vScroll.Width;
Filler.Height = hScroll.Height;
/*}
catch
{
}*/
ResumeLayout(false);
}
/// <summary>
/// Gets or Sets if the Left side thumb control is visible or not.
/// </summary>
public bool LeftThumbVisible
{
get { return LeftThumb.Visible; }
set
{
LeftThumb.Visible = value;
DoResize();
}
}
/// <summary>
/// Getd ot Sets if the Top thumb control is visible or not.
/// </summary>
public bool TopThumbVisible
{
get { return TopThumb.Visible; }
set
{
TopThumb.Visible = value;
DoResize();
}
}
[Browsable(false)]
public int VisibleClientHeight
{
get
{
if (hScroll.Visible)
return ClientHeight - hScroll.Height;
else
return ClientHeight;
}
}
[Browsable(false)]
public int VisibleClientWidth
{
get
{
if (hScroll.Visible)
return ClientWidth - vScroll.Width;
else
return ClientWidth;
}
}
#region public property ScrollBars
private ScrollBars _ScrollBars;
public ScrollBars ScrollBars
{
get { return _ScrollBars; }
set
{
_ScrollBars = value;
if (ScrollBars == ScrollBars.Both)
{
hScroll.Visible = true;
vScroll.Visible = true;
}
if (ScrollBars == ScrollBars.None)
{
hScroll.Visible = false;
vScroll.Visible = false;
}
if (ScrollBars == ScrollBars.Horizontal)
{
hScroll.Visible = true;
vScroll.Visible = false;
}
if (ScrollBars == ScrollBars.Vertical)
{
hScroll.Visible = false;
vScroll.Visible = true;
}
Filler.Visible = hScroll.Visible & vScroll.Visible;
if (vScroll.Visible && HasThumbs)
{
TopThumb.Height = 8;
}
else
{
TopThumb.Height = 0;
}
if (hScroll.Visible && HasThumbs)
{
LeftThumb.Width = 8;
}
else
{
LeftThumb.Width = 0;
}
DoResize();
Refresh();
}
}
private bool HasThumbs;
public void HideThumbs()
{
TopThumb.Height = 0;
LeftThumb.Width = 0;
HasThumbs = false;
DoResize();
}
public void ShowThumbs()
{
TopThumb.Height = 8;
LeftThumb.Width = 8;
HasThumbs = true;
DoResize();
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.