1 /* -*- Mode: C#; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Manticore.
18 * The Initial Developer of the Original Code is
19 * Silverstone Interactive.
20 * Portions created by the Initial Developer are Copyright (C) 2001
21 * the Initial Developer. All Rights Reserved.
24 * Ben Goodger <ben@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 namespace Silverstone
.Manticore
.Toolkit
43 using System
.Collections
;
44 using System
.ComponentModel
;
46 using System
.Drawing
.Drawing2D
;
47 using System
.Windows
.Forms
;
51 /// Summary description for StripBar.
53 public class StripBar
: UserControl
59 public ArrayList Rows
= new ArrayList();
60 public ArrayList Bands
= new ArrayList();
62 ///////////////////////////////////////////////////////////////////////////
63 // IStripBar Implementation
64 public void AddBand (StripBand aBand
)
71 StripRow row
= new StripRow(this);
77 // TODO: Trigger Height-Changed Event
83 row
= Rows
[Rows
.Count
-1] as StripRow
;
86 row
= new StripRow(this);
93 Invalidate(row
.Bounds
);
97 public void RemoveBand(StripBand aStripBand
)
102 ///////////////////////////////////////////////////////////////////////////
104 protected override void OnPaint(PaintEventArgs aPea
)
106 int rowCount
= Rows
.Count
;
107 for (int i
= 0; i
< rowCount
; ++i
)
109 StripRow currRow
= Rows
[i
] as StripRow
;
110 if (currRow
.Bounds
.IntersectsWith(aPea
.ClipRectangle
))
111 currRow
.PaintRow(aPea
);
117 public class StripBand
123 ///////////////////////////////////////////////////////////////////////////
124 // IStripBand Implementation
125 protected StripRow mRow
;
140 protected StripBar mBar
;
155 protected int mWidth
;
170 protected int mHeight
= 24;
176 // height = the larger of - decoration area (icon/text)
177 // - client area (control)
178 // + nonclient, nondecoration area (borders)
185 protected bool mNewRow
= false;
194 if (value != mNewRow
)
202 protected Control mControl
= null;
211 if (value != mControl
)
219 protected Color mBackColor
= Color
.Red
;
220 public Color BackColor
228 if (value != mBackColor
)
231 StripBar bar
= mBar
as StripBar
;
232 bar
.Invalidate(Bounds
);
237 public Rectangle Bounds
243 int bandCount
= mRow
.Bands
.Count
;
244 for (i
= 0, x
= 0; i
< bandCount
; ++i
)
246 StripBand currBand
= mRow
.Bands
[i
] as StripBand
;
247 x
+= currBand
.Bounds
.Width
;
254 int bandIndex
= mRow
.Bands
.IndexOf(this);
255 if (bandIndex
== (mRow
.Bands
.Count
- 1))
256 w
= mBar
.ClientRectangle
.Width
- x
;
258 return new Rectangle(x
, y
, w
, h
);
262 ///////////////////////////////////////////////////////////////////////////
264 public void PaintBand(PaintEventArgs aPea
)
266 SolidBrush sbr
= new SolidBrush(BackColor
);
267 aPea
.Graphics
.FillRectangle(sbr
, Bounds
);
271 public class StripRow
273 public StripRow(StripBar aStripBar
)
275 mStripBar
= aStripBar
;
278 protected StripBar mStripBar
;
280 public ArrayList Bands
= new ArrayList();
282 public Rectangle Bounds
287 w
= mStripBar
.ClientRectangle
.Width
;
290 x
= mStripBar
.ClientRectangle
.Left
;
292 int rowCount
= mStripBar
.Rows
.Count
;
293 StripRow currRow
= mStripBar
.Rows
[0] as StripRow
;
295 for (y
= 0; currRow
!= this; ++i
)
298 return new Rectangle(x
, y
, w
, h
);
302 protected int mHeight
= 24;
311 if (value != mHeight
)
316 public void AddBand(StripBand aBand
)
318 if (aBand
.Height
> mHeight
)
319 mHeight
= aBand
.Height
;
324 public void PaintRow(PaintEventArgs aPea
)
326 int bandCount
= Bands
.Count
;
327 for (int i
= 0; i
< bandCount
; ++i
)
329 StripBand currBand
= Bands
[i
] as StripBand
;
330 currBand
.PaintBand(aPea
);