2002-01-27 05:56:45 +03:00
|
|
|
/* -*- Mode: C#; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Manticore.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Silverstone Interactive. Portions created by Silverstone Interactive are
|
|
|
|
* Copyright (C) 2001 Silverstone Interactive.
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the
|
|
|
|
* terms of the GNU Public License (the "GPL"), in which case the
|
|
|
|
* provisions of the GPL are applicable instead of those above.
|
|
|
|
* If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of the GPL and not to allow others to use your
|
|
|
|
* version of this file under the MPL, indicate your decision by
|
|
|
|
* deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this
|
|
|
|
* file under either the MPL or the GPL.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Ben Goodger <ben@netscape.com>
|
|
|
|
*
|
|
|
|
*/
|
2002-01-27 01:25:43 +03:00
|
|
|
|
|
|
|
namespace Silverstone.Manticore.Toolkit
|
|
|
|
{
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Drawing;
|
2002-01-27 05:55:43 +03:00
|
|
|
using System.Drawing.Drawing2D;
|
2002-01-27 01:25:43 +03:00
|
|
|
using System.Windows.Forms;
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
|
2002-01-27 01:25:43 +03:00
|
|
|
/// <summary>
|
2002-01-29 11:21:06 +03:00
|
|
|
/// Summary description for StripBar.
|
|
|
|
/// </summary>
|
|
|
|
public class StripBar : UserControl
|
|
|
|
{
|
|
|
|
public StripBar()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayList Rows = new ArrayList();
|
|
|
|
public ArrayList Bands = new ArrayList();
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IStripBar Implementation
|
|
|
|
public void AddBand (StripBand aBand)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
Bands.Add(aBand);
|
|
|
|
aBand.Bar = this;
|
2002-01-27 01:25:43 +03:00
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
if (aBand.NewRow)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
StripRow row = new StripRow(this);
|
|
|
|
Rows.Add(row);
|
|
|
|
aBand.Row = row;
|
2002-01-27 01:25:43 +03:00
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
row.Bands.Add(aBand);
|
2002-01-27 05:55:43 +03:00
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
// TODO: Trigger Height-Changed Event
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
2002-01-29 11:21:06 +03:00
|
|
|
else
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
StripRow row;
|
|
|
|
if (Rows.Count >= 1)
|
|
|
|
row = Rows[Rows.Count-1] as StripRow;
|
|
|
|
else
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
row = new StripRow(this);
|
|
|
|
Rows.Add(row);
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
2002-01-29 11:21:06 +03:00
|
|
|
row.Bands.Add(aBand);
|
|
|
|
aBand.Row = row;
|
|
|
|
|
|
|
|
// Invalidate Row
|
|
|
|
Invalidate(row.Bounds);
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
public void RemoveBand(StripBand aStripBand)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Overriden Methods
|
|
|
|
protected override void OnPaint(PaintEventArgs aPea)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
int rowCount = Rows.Count;
|
|
|
|
for (int i = 0; i < rowCount; ++i)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
StripRow currRow = Rows[i] as StripRow;
|
|
|
|
if (currRow.Bounds.IntersectsWith(aPea.ClipRectangle))
|
|
|
|
currRow.PaintRow(aPea);
|
|
|
|
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
2002-01-29 11:21:06 +03:00
|
|
|
}
|
2002-01-27 01:25:43 +03:00
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
public class StripBand
|
|
|
|
{
|
|
|
|
public StripBand()
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// IStripBand Implementation
|
|
|
|
protected StripRow mRow;
|
|
|
|
public StripRow Row
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
return mRow;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
if (value != mRow)
|
|
|
|
mRow = value;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
|
|
|
|
protected StripBar mBar;
|
|
|
|
public StripBar Bar
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
return mBar;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
if (value != mBar)
|
|
|
|
mBar = value;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
protected int mWidth;
|
|
|
|
public int Width
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
get
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
return mWidth;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
2002-01-29 11:21:06 +03:00
|
|
|
set
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
if (value != mWidth)
|
|
|
|
mWidth = value;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
protected int mHeight = 24;
|
|
|
|
public int Height
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
// Compute height:
|
|
|
|
// height = the larger of - decoration area (icon/text)
|
|
|
|
// - client area (control)
|
|
|
|
// + nonclient, nondecoration area (borders)
|
|
|
|
//
|
|
|
|
return mHeight;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
protected bool mNewRow = false;
|
|
|
|
public bool NewRow
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
return mNewRow;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
if (value != mNewRow)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
mNewRow = value;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
protected Control mControl = null;
|
|
|
|
public Control Child
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
return mControl;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
if (value != mControl)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
mControl = value;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-01-29 11:21:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
protected Color mBackColor = Color.Red;
|
2002-01-27 01:25:43 +03:00
|
|
|
public Color BackColor
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return mBackColor;
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value != mBackColor)
|
|
|
|
{
|
|
|
|
mBackColor = value;
|
2002-01-29 11:21:06 +03:00
|
|
|
StripBar bar = mBar as StripBar;
|
|
|
|
bar.Invalidate(Bounds);
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
public Rectangle Bounds
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
int x, y, w, h, i;
|
|
|
|
|
|
|
|
int bandCount = mRow.Bands.Count;
|
|
|
|
for (i = 0, x = 0; i < bandCount; ++i)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
StripBand currBand = mRow.Bands[i] as StripBand;
|
|
|
|
x += currBand.Bounds.Width;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
2002-01-29 11:21:06 +03:00
|
|
|
y = mRow.Bounds.Y;
|
|
|
|
|
|
|
|
h = Height;
|
|
|
|
|
|
|
|
w = mBar.Width;
|
|
|
|
int bandIndex = mRow.Bands.IndexOf(this);
|
|
|
|
if (bandIndex == (mRow.Bands.Count - 1))
|
|
|
|
w = mBar.ClientRectangle.Width - x;
|
|
|
|
|
|
|
|
return new Rectangle(x, y, w, h);
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
public void PaintBand(PaintEventArgs aPea)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
SolidBrush sbr = new SolidBrush(BackColor);
|
|
|
|
aPea.Graphics.FillRectangle(sbr, Bounds);
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
2002-01-29 11:21:06 +03:00
|
|
|
}
|
2002-01-27 01:25:43 +03:00
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
public class StripRow
|
|
|
|
{
|
|
|
|
public StripRow(StripBar aStripBar)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
mStripBar = aStripBar;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
protected StripBar mStripBar;
|
|
|
|
|
|
|
|
public ArrayList Bands = new ArrayList();
|
|
|
|
|
|
|
|
public Rectangle Bounds
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
int x, y, w, h;
|
|
|
|
w = mStripBar.ClientRectangle.Width;
|
|
|
|
h = Height;
|
|
|
|
|
|
|
|
x = mStripBar.ClientRectangle.Left;
|
|
|
|
|
|
|
|
int rowCount = mStripBar.Rows.Count;
|
|
|
|
StripRow currRow = mStripBar.Rows[0] as StripRow;
|
|
|
|
int i = 0;
|
|
|
|
for (y = 0; currRow != this; ++i)
|
|
|
|
y += currRow.Height;
|
|
|
|
|
|
|
|
return new Rectangle(x, y, w, h);
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
protected int mHeight = 24;
|
|
|
|
public int Height
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
return mHeight;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
if (value != mHeight)
|
|
|
|
mHeight = value;
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
public void AddBand(StripBand aBand)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
if (aBand.Height > mHeight)
|
|
|
|
mHeight = aBand.Height;
|
|
|
|
|
|
|
|
Bands.Add(aBand);
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
|
2002-01-29 11:21:06 +03:00
|
|
|
public void PaintRow(PaintEventArgs aPea)
|
2002-01-27 01:25:43 +03:00
|
|
|
{
|
2002-01-29 11:21:06 +03:00
|
|
|
int bandCount = Bands.Count;
|
|
|
|
for (int i = 0; i < bandCount; ++i)
|
|
|
|
{
|
|
|
|
StripBand currBand = Bands[i] as StripBand;
|
|
|
|
currBand.PaintBand(aPea);
|
|
|
|
}
|
2002-01-27 01:25:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|