// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Copyright (c) 2004 Novell, Inc.
+// Copyright (c) 2004-2005 Novell, Inc.
//
// Authors:
// Jordi Mas i Hernandez, jordi@ximian.com
//
//
-// INCOMPLETE
+// COMPLETE
using System.ComponentModel;
using System.ComponentModel.Design;
SetStyle (ControlStyles.ResizeRedraw, true);
SetStyle (ControlStyles.Selectable, false);
-
- Resize += new EventHandler (OnResizeLB);
+
HandleCreated += new EventHandler (OnHandleCreatedLB);
}
[Localizable(true)]
public Image Image {
get {
- return image;
+ if (image != null) {
+ return image;
+ }
+
+ if (image_list != null && ImageIndex >= 0) {
+ return image_list.Images[ImageIndex];
+ }
+
+ return null;
}
set {
if (image == value)
[Localizable (true)]
[TypeConverter (typeof (ImageIndexConverter))]
public int ImageIndex {
- get { return image_index;}
+ get {
+ if (ImageList == null) {
+ return -1;
+ }
+
+ if (image_index >= image_list.Images.Count) {
+ return image_list.Images.Count - 1;
+ }
+
+ return image_index;
+ }
set {
- if (value < 0 || value>= image_list.Images.Count)
- throw new ArgumentException();
+ if (value < -1)
+ throw new ArgumentException ();
if (image_index == value)
return;
set {
if (image_list == value)
return;
+
+ image_list = value;
- if (ImageList != null && image_index !=-1)
+ if (image_list != null && image_index !=-1)
Image = null;
Refresh ();
Refresh ();
}
-
protected override void OnPaint (PaintEventArgs pevent)
{
if (Width <= 0 || Height <= 0 || Visible == false)
return;
- Draw ();
- // TODO: Imagelist
+ Draw ();
pevent.Graphics.DrawImage (ImageBuffer, 0, 0);
-
}
protected override void OnParentChanged (EventArgs e)
public override string ToString()
{
- return base.ToString();
+ return base.ToString () + "Text: " + Text;
}
protected override void WndProc(ref Message m)
internal void Draw ()
{
ThemeEngine.Current.DrawLabel(DeviceContext, ClientRectangle, this);
-
- DrawImage (DeviceContext, Image, ClientRectangle, image_align);
+ DrawImage (DeviceContext, Image, ClientRectangle, image_align);
}
private void OnHandleCreatedLB (Object o, EventArgs e)
CalcAutoSize ();
}
- private void OnResizeLB (object o, EventArgs e)
- {
- if (Width <= 0 || Height <= 0)
- return;
- }
-
-
private void SetUseMnemonic (bool use)
{
if (use)
public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
- StringFormat format) {
- SolidBrush brush;
-
- brush=new SolidBrush(ControlPaint.Light(color, 95));
+ StringFormat format) {
layoutRectangle.Offset(1.0f, 1.0f);
- graphics.DrawString(s, font, brush, layoutRectangle, format);
-
- brush.Color=ControlPaint.Light(color, 50);
+ graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 95)), layoutRectangle, format);
layoutRectangle.Offset(-1.0f, -1.0f);
- graphics.DrawString(s, font, brush, layoutRectangle, format);
-
- brush.Dispose();
+ graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 50)), layoutRectangle, format);
+
}
private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,