Code Coverage Statistics for Source File
c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Util\TipSplitter.cs
|
Sequence Point Coverage
N/A
0 of 0
|
Branch Coverage
N/A
0 of 0
|
Lines
99
|
Highlight:
Uncovered Code
Covered Code
| L | V | Source |
|---|---|---|
1 |
// <file> |
|
2 |
// <copyright see="prj:///doc/copyright.txt"/> |
|
3 |
// <license see="prj:///doc/license.txt"/> |
|
4 |
// <owner name="none" email=""/> |
|
5 |
// <version>$Revision: 915 $</version> |
|
6 |
// </file> |
|
7 |
||
8 |
using System; |
|
9 |
using System.Diagnostics; |
|
10 |
using System.Drawing; |
|
11 |
||
12 |
namespace ICSharpCode.TextEditor.Util |
|
13 |
{ |
|
14 |
class TipSplitter: TipSection |
|
15 |
{ |
|
16 |
bool isHorizontal; |
|
17 |
float [] offsets; |
|
18 |
TipSection[] tipSections; |
|
19 |
||
20 |
public TipSplitter(Graphics graphics, bool horizontal, params TipSection[] sections): base(graphics) |
|
21 |
{ |
|
22 |
Debug.Assert(sections != null); |
|
23 |
||
24 |
isHorizontal = horizontal; |
|
25 |
offsets = new float[sections.Length]; |
|
26 |
tipSections = (TipSection[])sections.Clone(); |
|
27 |
} |
|
28 |
||
29 |
public override void Draw(PointF location) |
|
30 |
{ |
|
31 |
if (isHorizontal) { |
|
32 |
for (int i = 0; i < tipSections.Length; i ++) { |
|
33 |
tipSections[i].Draw |
|
34 |
(new PointF(location.X + offsets[i], location.Y)); |
|
35 |
} |
|
36 |
} else { |
|
37 |
for (int i = 0; i < tipSections.Length; i ++) { |
|
38 |
tipSections[i].Draw |
|
39 |
(new PointF(location.X, location.Y + offsets[i])); |
|
40 |
} |
|
41 |
} |
|
42 |
} |
|
43 |
||
44 |
protected override void OnMaximumSizeChanged() |
|
45 |
{ |
|
46 |
base.OnMaximumSizeChanged(); |
|
47 |
||
48 |
float currentDim = 0; |
|
49 |
float otherDim = 0; |
|
50 |
SizeF availableArea = MaximumSize; |
|
51 |
||
52 |
for (int i = 0; i < tipSections.Length; i ++) { |
|
53 |
TipSection section = (TipSection)tipSections[i]; |
|
54 |
||
55 |
section.SetMaximumSize(availableArea); |
|
56 |
||
57 |
SizeF requiredArea = section.GetRequiredSize(); |
|
58 |
offsets[i] = currentDim; |
|
59 |
||
60 |
// It's best to start on pixel borders, so this will |
|
61 |
// round up to the nearest pixel. Otherwise there are |
|
62 |
// weird cutoff artifacts. |
|
63 |
float pixelsUsed; |
|
64 |
||
65 |
if (isHorizontal) { |
|
66 |
pixelsUsed = (float)Math.Ceiling(requiredArea.Width); |
|
67 |
currentDim += pixelsUsed; |
|
68 |
||
69 |
availableArea.Width = Math.Max |
|
70 |
(0, availableArea.Width - pixelsUsed); |
|
71 |
||
72 |
otherDim = Math.Max(otherDim, requiredArea.Height); |
|
73 |
} else { |
|
74 |
pixelsUsed = (float)Math.Ceiling(requiredArea.Height); |
|
75 |
currentDim += pixelsUsed; |
|
76 |
||
77 |
availableArea.Height = Math.Max |
|
78 |
(0, availableArea.Height - pixelsUsed); |
|
79 |
||
80 |
otherDim = Math.Max(otherDim, requiredArea.Width); |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
foreach (TipSection section in tipSections) { |
|
85 |
if (isHorizontal) { |
|
86 |
section.SetAllocatedSize(new SizeF(section.GetRequiredSize().Width, otherDim)); |
|
87 |
} else { |
|
88 |
section.SetAllocatedSize(new SizeF(otherDim, section.GetRequiredSize().Height)); |
|
89 |
} |
|
90 |
} |
|
91 |
||
92 |
if (isHorizontal) { |
|
93 |
SetRequiredSize(new SizeF(currentDim, otherDim)); |
|
94 |
} else { |
|
95 |
SetRequiredSize(new SizeF(otherDim, currentDim)); |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
} |