|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.Text; |
|
19 using System.Collections.Generic; |
|
20 using System.Drawing; |
|
21 |
|
22 namespace CrashItemLib.Crash.Base.DataBinding |
|
23 { |
|
24 public class CIDBCell |
|
25 { |
|
26 #region Constructors |
|
27 public CIDBCell() |
|
28 { |
|
29 iColors.Add( System.Drawing.Color.Black ); |
|
30 iColors.Add( System.Drawing.Color.Transparent ); |
|
31 } |
|
32 |
|
33 public CIDBCell( string aCaption ) |
|
34 : this() |
|
35 { |
|
36 iCaption = aCaption; |
|
37 } |
|
38 |
|
39 public CIDBCell( string aCaption, Color aForeColor ) |
|
40 : this() |
|
41 { |
|
42 iCaption = aCaption; |
|
43 ForeColor = aForeColor; |
|
44 } |
|
45 |
|
46 public CIDBCell( Color aForeColor, Color aBackColor ) |
|
47 : this( string.Empty, aForeColor, aBackColor ) |
|
48 { |
|
49 } |
|
50 |
|
51 public CIDBCell( string aCaption, Color aForeColor, Color aBackColor ) |
|
52 : this( aCaption, aForeColor, aBackColor, string.Empty ) |
|
53 { |
|
54 } |
|
55 |
|
56 public CIDBCell( string aCaption, Color aForeColor, Color aBackColor, string aFormat ) |
|
57 : this() |
|
58 { |
|
59 Caption = aCaption; |
|
60 ForeColor = aForeColor; |
|
61 BackColor = aBackColor; |
|
62 Format = aFormat; |
|
63 } |
|
64 #endregion |
|
65 |
|
66 #region API |
|
67 #endregion |
|
68 |
|
69 #region Properties |
|
70 public string Caption |
|
71 { |
|
72 get { return iCaption; } |
|
73 set { iCaption = value; } |
|
74 } |
|
75 |
|
76 public string Format |
|
77 { |
|
78 get { return iFormat; } |
|
79 set { iFormat = value; } |
|
80 } |
|
81 |
|
82 public Color ForeColor |
|
83 { |
|
84 get |
|
85 { |
|
86 bool set = IsSet( KColIndexFore ); |
|
87 Color ret = Color( KColIndexFore ); |
|
88 |
|
89 // Get color from row if we've not been explicitly set |
|
90 if ( !set && Row != null ) |
|
91 { |
|
92 ret = Row.ForeColor; |
|
93 } |
|
94 // |
|
95 return ret; |
|
96 } |
|
97 set |
|
98 { |
|
99 SetColor( value, KColIndexFore ); |
|
100 } |
|
101 } |
|
102 |
|
103 public Color BackColor |
|
104 { |
|
105 get |
|
106 { |
|
107 bool set = IsSet( KColIndexBack ); |
|
108 Color ret = Color( KColIndexBack ); |
|
109 |
|
110 // Get color from row if we've not been explicitly set |
|
111 if ( !set && Row != null ) |
|
112 { |
|
113 ret = Row.BackColor; |
|
114 } |
|
115 // |
|
116 return ret; |
|
117 } |
|
118 set |
|
119 { |
|
120 SetColor( value, KColIndexBack ); |
|
121 } |
|
122 } |
|
123 |
|
124 public CIDBRow Row |
|
125 { |
|
126 get { return iRow; } |
|
127 internal set { iRow = value; } |
|
128 } |
|
129 |
|
130 public CIElement Element |
|
131 { |
|
132 get { return Row.Element; } |
|
133 } |
|
134 #endregion |
|
135 |
|
136 #region From System.Object |
|
137 public override string ToString() |
|
138 { |
|
139 return Caption; |
|
140 } |
|
141 #endregion |
|
142 |
|
143 #region Internal constants |
|
144 private const int KColIndexFore = 0; |
|
145 private const int KColIndexBack = 1; |
|
146 #endregion |
|
147 |
|
148 #region Internal methods |
|
149 private bool IsSet( int aIndex ) |
|
150 { |
|
151 return iColorsSet[ aIndex ]; |
|
152 } |
|
153 |
|
154 private Color Color( int aIndex ) |
|
155 { |
|
156 return iColors[ aIndex ]; |
|
157 } |
|
158 |
|
159 private void SetColor( Color aColor, int aIndex ) |
|
160 { |
|
161 iColors[ aIndex ] = aColor; |
|
162 iColorsSet[ aIndex ] = true; |
|
163 } |
|
164 #endregion |
|
165 |
|
166 #region Data members |
|
167 private CIDBRow iRow = null; |
|
168 private string iCaption = string.Empty; |
|
169 private string iFormat = string.Empty; |
|
170 private bool[] iColorsSet = new bool[ 2 ] { false, false }; |
|
171 private List<Color> iColors = new List<Color>( 2 ); |
|
172 #endregion |
|
173 } |
|
174 } |