|
From: <Pi...@us...> - 2011-01-14 00:38:23
|
Revision: 1643
http://cs-sdl.svn.sourceforge.net/cs-sdl/?rev=1643&view=rev
Author: Pikablu
Date: 2011-01-14 00:38:13 +0000 (Fri, 14 Jan 2011)
Log Message:
-----------
Modified Paths:
--------------
branches/experimental/examples/SdlDotNetExamples/SmallDemos/GuiExample.cs
branches/experimental/src/Graphics/Font.cs
branches/experimental/src/Graphics/Surface.cs
branches/experimental/src/Graphics/Video.cs
branches/experimental/src/Properties/AssemblyInfo.cs
branches/experimental/src/SdlDotNet.csproj
branches/experimental/src/Widgets/AnimatedWidget.cs
branches/experimental/src/Widgets/Button.cs
branches/experimental/src/Widgets/CheckBox.cs
branches/experimental/src/Widgets/ComboBox.cs
branches/experimental/src/Widgets/ContainerWidget.cs
branches/experimental/src/Widgets/FileBrowserDialog.cs
branches/experimental/src/Widgets/FileDialog.cs
branches/experimental/src/Widgets/GroupBox.cs
branches/experimental/src/Widgets/HScrollBar.cs
branches/experimental/src/Widgets/Highlighter.cs
branches/experimental/src/Widgets/IContainer.cs
branches/experimental/src/Widgets/IListBoxItem.cs
branches/experimental/src/Widgets/Label.cs
branches/experimental/src/Widgets/ListBox.cs
branches/experimental/src/Widgets/ListBoxItemCollection.cs
branches/experimental/src/Widgets/ListBoxTextItem.cs
branches/experimental/src/Widgets/NumericUpDown.cs
branches/experimental/src/Widgets/Panel.cs
branches/experimental/src/Widgets/PictureBox.cs
branches/experimental/src/Widgets/ProgressBar.cs
branches/experimental/src/Widgets/RadioButton.cs
branches/experimental/src/Widgets/SaveFileDialog.cs
branches/experimental/src/Widgets/ScrollableWidget.cs
branches/experimental/src/Widgets/TextBox.cs
branches/experimental/src/Widgets/TextRenderer.cs
branches/experimental/src/Widgets/TitleBar.cs
branches/experimental/src/Widgets/ToolTip.cs
branches/experimental/src/Widgets/VScrollBar.cs
branches/experimental/src/Widgets/Widget.cs
branches/experimental/src/Widgets/WidgetCollection.cs
branches/experimental/src/Widgets/WidgetRenderer.cs
branches/experimental/src/Widgets/Widgets.cs
branches/experimental/src/Widgets/Window.cs
branches/experimental/src/Widgets/WindowManager.cs
branches/experimental/src/Widgets/WindowSwitcher.cs
branches/experimental/src/Widgets/WindowSwitcherButton.cs
Added Paths:
-----------
branches/experimental/src/Core/Resolution.cs
branches/experimental/src/Widgets/DragDropDataObject.cs
branches/experimental/src/Widgets/DragDropEvents.cs
branches/experimental/src/Widgets/DragEventArgs.cs
branches/experimental/src/Widgets/IDataObject.cs
branches/experimental/src/Widgets/OpenFileDialog.cs
Modified: branches/experimental/examples/SdlDotNetExamples/SmallDemos/GuiExample.cs
===================================================================
--- branches/experimental/examples/SdlDotNetExamples/SmallDemos/GuiExample.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/examples/SdlDotNetExamples/SmallDemos/GuiExample.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -49,15 +49,18 @@
}
public void Go() {
- if (File.Exists(Path.Combine(dataDirectory,fontName)))
- {
+ if (File.Exists(Path.Combine(dataDirectory, fontName))) {
filePath = "";
- }
+ }
Video.WindowIcon();
Video.WindowCaption = "SDL.NET - Gui Example";
- screen = Video.SetVideoMode(640, 480, 16);
+ Video.UseResolutionScaling = true;
+ Resolution.SetStandardResolution(640, 480);
+ Resolution.SetResolution(1024, 768);
+ screen = Video.SetVideoMode(Resolution.ResolutionWidth, Resolution.ResolutionHeight, 16, true);
+
Widgets.Initialize(screen, Path.Combine(filePath, Path.Combine(dataDirectory, "Widgets")),
Path.Combine(filePath, Path.Combine(dataDirectory, fontName)), 12, true);
@@ -65,6 +68,7 @@
Events.Tick += new EventHandler<TickEventArgs>(this.Tick);
Events.Quit += new EventHandler<QuitEventArgs>(this.Quit);
+ Events.VideoResize += new EventHandler<VideoResizeEventArgs>(Events_VideoResize);
Events.Run();
}
@@ -101,10 +105,14 @@
}
void testButton_Click(object sender, MouseButtonEventArgs e) {
- resultsLabel.Text = "Status:\nWaiting for input...";
- MessageBoxButtons buttons = (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), messageBoxButtonsSelectionListBox.SelectedItem.TextIdentifier, true);
- DialogResult result = MessageBox.Show("Pick a button! Any button!", "Button Selection", buttons);
- resultsLabel.Text = "Status:\n\"" + result.ToString() + "\" selected!";
+ //resultsLabel.Text = "Status:\nWaiting for input...";
+ //MessageBoxButtons buttons = (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), messageBoxButtonsSelectionListBox.SelectedItem.TextIdentifier, true);
+ //DialogResult result = MessageBox.Show("Pick a button! Any button!", "Button Selection", buttons);
+ //resultsLabel.Text = "Status:\n\"" + result.ToString() + "\" selected!";
+
+ FileBrowserDialog fbd = new FileBrowserDialog("fileBrowserDialog");
+ fbd.Filter = "All Files|*.*|Text Files|*.txt;*.dll;*.exe";
+ fbd.ShowDialog();
}
void Tick(object sender, TickEventArgs e) {
@@ -119,6 +127,11 @@
Events.QuitApplication();
}
+ void Events_VideoResize(object sender, VideoResizeEventArgs e) {
+ Resolution.SetResolution(e.Width, e.Height);
+ screen = Video.SetVideoMode(Resolution.ResolutionWidth, Resolution.ResolutionHeight, 16, true);
+ }
+
/// <summary>
/// Lesson Title
/// </summary>
Added: branches/experimental/src/Core/Resolution.cs
===================================================================
--- branches/experimental/src/Core/Resolution.cs (rev 0)
+++ branches/experimental/src/Core/Resolution.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -0,0 +1,119 @@
+#region Header
+
+/*
+ * Copyright (C) 2010 Pikablu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#endregion Header
+
+namespace SdlDotNet.Core
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Drawing;
+ using System.Text;
+
+ using SdlDotNet.Widgets;
+
+ public class Resolution
+ {
+ #region Fields
+
+ public static int StandardResolutionHeight = 600;
+ public static int StandardResolutionWidth = 800;
+
+ static int resolutionHeight = StandardResolutionHeight;
+ static decimal resolutionHeightRatio;
+ static int resolutionWidth = StandardResolutionWidth;
+ static decimal resolutionWidthRatio;
+
+ #endregion Fields
+
+ #region Properties
+
+ public static int ResolutionHeight {
+ get { return resolutionHeight; }
+ }
+
+ public static int ResolutionWidth {
+ get { return resolutionWidth; }
+ }
+
+ #endregion Properties
+
+ #region Methods
+
+ public static int ConvertHeight(int height) {
+ return (int)(height * resolutionHeightRatio);
+ }
+
+ public static int ConvertWidth(int width) {
+ return (int)(width * resolutionWidthRatio);
+ }
+
+ public static Point ConvertPoint(int x, int y) {
+ return new Point((int)(x * resolutionWidthRatio), (int)(y * resolutionHeightRatio));
+ }
+
+ public static Size ConvertSize(int width, int height) {
+ return new Size((int)(width * resolutionWidthRatio), (int)(height * resolutionHeightRatio));
+ }
+
+ public static Size DeconvertSize(int width, int height) {
+ return new Size((int)(width / resolutionWidthRatio), (int)(height / resolutionHeightRatio));
+ }
+
+ public static Point GetCenter(Size childSize) {
+ return GetCenter(childSize, 0, 0);
+ }
+
+ public static Point GetCenter(Size childSize, int xOffset, int yOffset) {
+ return new Point((StandardResolutionWidth / 2) - (childSize.Width / 2) + xOffset, (StandardResolutionHeight / 2) - (childSize.Height / 2) + yOffset);
+ }
+
+ public static Point GetCenter(Widget widget, int xOffset, int yOffset) {
+ return GetCenter(widget.UnscaledSize, xOffset, yOffset);
+ }
+
+ public static Point GetCenter(Widget widget) {
+ return GetCenter(widget.UnscaledSize);
+ }
+
+ public static int GetCenterX(Widget widget) {
+ return (StandardResolutionWidth / 2) - (widget.UnscaledSize.Width / 2);
+ }
+
+ public static void SetStandardResolution(int width, int height) {
+ StandardResolutionWidth = width;
+ StandardResolutionHeight = height;
+ }
+
+ public static void SetResolution(int width, int height) {
+ resolutionWidth = width;
+ resolutionHeight = height;
+
+ resolutionWidthRatio = resolutionWidth / (decimal)StandardResolutionWidth;
+ resolutionHeightRatio = resolutionHeight / (decimal)StandardResolutionHeight;
+
+ foreach (Widget childWidget in Widgets.EnumerateActiveWidgets()) {
+ childWidget.HandleResolutionChanged();
+ }
+ }
+
+ #endregion Methods
+ }
+}
\ No newline at end of file
Modified: branches/experimental/src/Graphics/Font.cs
===================================================================
--- branches/experimental/src/Graphics/Font.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Graphics/Font.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -86,6 +86,7 @@
Font.InitializeFontSystem();
}
+ ProcessPointSize(ref pointSize);
this.Handle = SdlTtf.TTF_OpenFont(fileName, pointSize);
if (this.Handle == IntPtr.Zero) {
throw FontException.Generate();
@@ -103,6 +104,7 @@
Font.InitializeFontSystem();
}
+ ProcessPointSize(ref pointSize);
this.Handle = SdlTtf.TTF_OpenFontIndex(fileName, pointSize, index);
if (this.Handle == IntPtr.Zero) {
throw FontException.Generate();
@@ -122,6 +124,7 @@
Font.InitializeFontSystem();
}
+ ProcessPointSize(ref pointSize);
this.Handle = SdlTtf.TTF_OpenFontRW(Sdl.SDL_RWFromMem(array, array.Length), 0, pointSize);
if (this.Handle == IntPtr.Zero) {
throw FontException.Generate();
@@ -142,6 +145,7 @@
Font.InitializeFontSystem();
}
+ ProcessPointSize(ref pointSize);
this.Handle = SdlTtf.TTF_OpenFontIndexRW(Sdl.SDL_RWFromMem(array, array.Length), 0, pointSize, index);
if (this.Handle == IntPtr.Zero) {
throw FontException.Generate();
@@ -248,9 +252,6 @@
SdlColor.ConvertColor(textColor);
Sdl.SDL_Color backgroundColorSdl =
SdlColor.ConvertColor(backgroundColor);
- if (glyph == null) {
- glyph = ' ';
- }
IntPtr handle = SdlTtf.TTF_RenderGlyph_Shaded(this.Handle, (short)glyph, textColorSdl, backgroundColorSdl);
GC.KeepAlive(this);
return new Surface(handle);
@@ -264,14 +265,17 @@
/// <returns></returns>
private Surface RenderGlyphBlended(char glyph, Color textColor) {
Sdl.SDL_Color colorSdl = SdlColor.ConvertColor(textColor);
- if (glyph == null) {
- glyph = ' ';
- }
IntPtr handle = SdlTtf.TTF_RenderGlyph_Blended(this.Handle, (short)glyph, colorSdl);
GC.KeepAlive(this);
return new Surface(handle);
}
+ private void ProcessPointSize(ref int pointSize) {
+ if (Video.UseResolutionScaling) {
+ pointSize = Resolution.ConvertHeight(pointSize);
+ }
+ }
+
#endregion
#region Public Methods
Modified: branches/experimental/src/Graphics/Surface.cs
===================================================================
--- branches/experimental/src/Graphics/Surface.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Graphics/Surface.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -229,6 +229,7 @@
/// <param name="redMask">Red Mask</param>
public Surface(int width, int height, int bitsPerPixel, int redMask, int greenMask, int blueMask, int alphaMask)
{
+ ProcessSize(ref width, ref height);
this.Handle =
Sdl.SDL_CreateRGBSurface((int)VideoModes.None, width, height, bitsPerPixel, redMask, greenMask, blueMask, alphaMask);
if (this.Handle == IntPtr.Zero)
@@ -359,6 +360,13 @@
destination.isVideoMode = source.isVideoMode;
}
+ private void ProcessSize(ref int width, ref int height) {
+ if (Video.UseResolutionScaling) {
+ width = Resolution.ConvertWidth(width);
+ height = Resolution.ConvertHeight(height);
+ }
+ }
+
#endregion Private Methods
#region Internal Methods
Modified: branches/experimental/src/Graphics/Video.cs
===================================================================
--- branches/experimental/src/Graphics/Video.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Graphics/Video.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -229,11 +229,19 @@
const int USE_CURRENT_BPP = 0;
static bool isInitialized = Initialize();
+ static bool useResolutionScaling = false;
#endregion
#region Public Methods
+ public static bool UseResolutionScaling {
+ get { return useResolutionScaling; }
+ set {
+ useResolutionScaling = value;
+ }
+ }
+
/// <summary>
///
/// </summary>
Modified: branches/experimental/src/Properties/AssemblyInfo.cs
===================================================================
--- branches/experimental/src/Properties/AssemblyInfo.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Properties/AssemblyInfo.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -43,9 +43,9 @@
[assembly: AssemblyTrademark("http://cs-sdl.sourceforge.net")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
-[assembly: AssemblyVersion("6.1.0.0")]
-[assembly: AssemblyFileVersion("6.1.0.0")]
-[assembly: AssemblyInformationalVersion("6.1.0.0")]
+[assembly: AssemblyVersion("6.9.0.0")]
+[assembly: AssemblyFileVersion("6.9.0.0")]
+[assembly: AssemblyInformationalVersion("6.9.0.0")]
//
// Version information for an assembly consists of the following four values:
Modified: branches/experimental/src/SdlDotNet.csproj
===================================================================
--- branches/experimental/src/SdlDotNet.csproj 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/SdlDotNet.csproj 2011-01-14 00:38:13 UTC (rev 1643)
@@ -122,6 +122,7 @@
<DependentUpon>SurfaceControl.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <Compile Include="Core\Resolution.cs" />
<Compile Include="Graphics\GlyphData.cs" />
<Compile Include="Graphics\NativeMethods.cs" />
<Compile Include="Graphics\SurfaceGl.cs" />
@@ -155,6 +156,9 @@
<Compile Include="Widgets\ComponentCollection.cs" />
<Compile Include="Widgets\ContainerWidget.cs" />
<Compile Include="Widgets\DialogResult.cs" />
+ <Compile Include="Widgets\DragDropDataObject.cs" />
+ <Compile Include="Widgets\DragDropEvents.cs" />
+ <Compile Include="Widgets\DragEventArgs.cs" />
<Compile Include="Widgets\DrawingSupport.cs" />
<Compile Include="Widgets\FileBrowserDialog.cs" />
<Compile Include="Widgets\FileDialog.cs" />
@@ -163,6 +167,7 @@
<Compile Include="Widgets\HighlightType.cs" />
<Compile Include="Widgets\HScrollBar.cs" />
<Compile Include="Widgets\IContainer.cs" />
+ <Compile Include="Widgets\IDataObject.cs" />
<Compile Include="Widgets\IListBoxItem.cs" />
<Compile Include="Widgets\ImageSizeMode.cs" />
<Compile Include="Widgets\InvocationItem.cs" />
@@ -175,6 +180,7 @@
<Compile Include="Widgets\MessageBoxButtons.cs" />
<Compile Include="Widgets\MouseButtonEventArgs.cs" />
<Compile Include="Widgets\NumericUpDown.cs" />
+ <Compile Include="Widgets\OpenFileDialog.cs" />
<Compile Include="Widgets\Panel.cs" />
<Compile Include="Widgets\PictureBox.cs" />
<Compile Include="Widgets\ProgressBar.cs" />
Modified: branches/experimental/src/Widgets/AnimatedWidget.cs
===================================================================
--- branches/experimental/src/Widgets/AnimatedWidget.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/AnimatedWidget.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -43,8 +43,12 @@
public AnimatedWidget(string name)
: base(name) {
fps = -1;
+
+ base.Paint += new EventHandler(AnimatedWidget_Paint);
}
+
+
#endregion Constructors
#region Events
@@ -89,9 +93,7 @@
}
}
- protected override void DrawBuffer() {
- base.DrawBuffer();
-
+ void AnimatedWidget_Paint(object sender, EventArgs e) {
if (RenderFrame != null)
RenderFrame(this, EventArgs.Empty);
}
Modified: branches/experimental/src/Widgets/Button.cs
===================================================================
--- branches/experimental/src/Widgets/Button.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/Button.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -40,6 +40,8 @@
bool selected;
bool spaceDown;
string text;
+ bool redrawHighlightSurfaceRequested;
+ bool selectedChanged;
#endregion Fields
@@ -60,8 +62,12 @@
base.MouseEnter += new EventHandler(Button_MouseEnter);
base.MouseLeave += new EventHandler(Button_MouseLeave);
base.Resized += new EventHandler(Button_Resized);
+
+ base.Paint += new EventHandler(Button_Paint);
}
+
+
#endregion Constructors
#region Properties
@@ -88,7 +94,7 @@
set {
if (highlightColor != value) {
highlightColor = value;
- RedrawHighlightSurface();
+ RequestRedrawHighlightSurface();
RequestRedraw();
}
}
@@ -115,7 +121,7 @@
set {
if (highlightType != value) {
highlightType = value;
- RedrawHighlightSurface();
+ RequestRedrawHighlightSurface();
}
}
}
@@ -127,13 +133,9 @@
get { return selected; }
set {
if (selected != value) {
- if (selected) {
- highlightSurface.Alpha = 0;
- }
selected = value;
- if (selected) {
- highlightSurface.Alpha = 150;
- }
+ selectedChanged = true;
+ RequestRedrawHighlightSurface();
RequestRedraw();
}
}
@@ -237,25 +239,20 @@
}
}
- protected override void DrawBuffer() {
- lock (lockObject) {
- if (!base.disposed) {
- CheckHighlightSurface();
- CheckFont();
- base.DrawBuffer();
- if (highlightType == HighlightType.Color) {
- base.Buffer.Blit(highlightSurface, new Point(base.BorderWidth, base.BorderWidth), new Rectangle(base.BorderWidth, base.BorderWidth, base.Width - (base.BorderWidth * 2), base.Height - (base.BorderWidth * 2)));
- } else if (highlightType == HighlightType.Image) {
- base.Buffer.Blit(highlightSurface, DrawingSupport.GetCenter(this.Size, highlightSurface.Size));
- }
- if (!string.IsNullOrEmpty(text) && font != null) {
- SdlDotNet.Graphics.Surface fontSurf = font.Render(text, base.ForeColor);
- base.Buffer.Blit(fontSurf, DrawingSupport.GetCenter(base.Buffer, fontSurf.Size));
- fontSurf.Close();
- }
- DrawBorder();
- }
+ void Button_Paint(object sender, EventArgs e) {
+ CheckHighlightSurface();
+ CheckFont();
+ if (highlightType == HighlightType.Color) {
+ base.Buffer.Blit(highlightSurface, new Point(base.BorderWidth, base.BorderWidth), new Rectangle(base.BorderWidth, base.BorderWidth, base.Width - (base.BorderWidth * 2), base.Height - (base.BorderWidth * 2)));
+ } else if (highlightType == HighlightType.Image) {
+ base.Buffer.Blit(highlightSurface, DrawingSupport.GetCenter(this.Size, highlightSurface.Size));
}
+ if (!string.IsNullOrEmpty(text) && font != null) {
+ SdlDotNet.Graphics.Surface fontSurf = font.Render(text, base.ForeColor);
+ base.Buffer.Blit(fontSurf, DrawingSupport.GetCenter(base.Buffer, fontSurf.Size));
+ fontSurf.Close();
+ }
+ DrawBorder();
}
void Button_KeyDown(object sender, SdlDotNet.Input.KeyboardEventArgs e) {
@@ -290,7 +287,7 @@
void Button_Resized(object sender, EventArgs e) {
lock (lockObject) {
- if (highlightSurface != null) {
+ if (highlightType == SdlDotNet.Widgets.HighlightType.Color && highlightSurface != null) {
highlightSurface.Close();
highlightSurface = null;
}
@@ -306,14 +303,21 @@
private void CheckHighlightSurface() {
if (highlightSurface == null) {
- highlightSurface = new SdlDotNet.Graphics.Surface(base.Size);
+ highlightSurface = new SdlDotNet.Graphics.Surface(base.UnscaledSize);
highlightSurface.Alpha = 0;
highlightSurface.AlphaBlending = true;
+ RequestRedrawHighlightSurface();
+ }
+ if (redrawHighlightSurfaceRequested) {
RedrawHighlightSurface();
}
}
+ private void RequestRedrawHighlightSurface() {
+ redrawHighlightSurfaceRequested = true;
+ }
+
private void RedrawHighlightSurface() {
switch (highlightType) {
case HighlightType.Color: {
@@ -323,6 +327,15 @@
}
break;
}
+
+ if (selectedChanged) {
+ selectedChanged = false;
+ if (selected) {
+ highlightSurface.Alpha = 150;
+ } else {
+ highlightSurface.Alpha = 0;
+ }
+ }
}
#endregion Methods
Modified: branches/experimental/src/Widgets/CheckBox.cs
===================================================================
--- branches/experimental/src/Widgets/CheckBox.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/CheckBox.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -48,17 +48,25 @@
: base(name, true) {
lblText = new Label("lblText");
lblText.AutoSize = true;
+ lblText.BackColor = Color.Transparent;
+ base.InitializeDefaultWidget();
+
+ this.BackColor = Color.Transparent;
+
NotCheckedNotOver = new SdlDotNet.Graphics.Surface(Widgets.ResourceDirectory + "/CheckBox/unchecked.png");
NotCheckedIsOver = new SdlDotNet.Graphics.Surface(Widgets.ResourceDirectory + "/CheckBox/unchecked-hover.png");
IsCheckedNotOver = new SdlDotNet.Graphics.Surface(Widgets.ResourceDirectory + "/CheckBox/checked.png");
IsCheckedIsOver = new SdlDotNet.Graphics.Surface(Widgets.ResourceDirectory + "/CheckBox/checked-hover.png");
- base.InitializeDefaultWidget();
base.MouseEnter += new EventHandler(CheckBox_MouseEnter);
base.MouseLeave += new EventHandler(Checkbox_MouseLeave);
+
+ base.Paint += new EventHandler(CheckBox_Paint);
}
+
+
#endregion Constructors
#region Events
@@ -72,7 +80,6 @@
public new Color BackColor {
get { return base.BackColor; }
set {
- lblText.BackColor = Color.Transparent;
base.BackColor = value;
}
}
@@ -136,11 +143,10 @@
Checked = !@checked;
}
- protected override void DrawBuffer() {
- base.DrawBuffer();
+ void CheckBox_Paint(object sender, EventArgs e) {
Size checkBoxSize = new Size(CHECKBOX_SIZE, CHECKBOX_SIZE);
- SdlDotNet.Graphics.Surface textSurf = lblText.Render();
- Point centerPoint = DrawingSupport.GetCenter(base.Buffer, textSurf.Size);
+ //SdlDotNet.Graphics.Surface textSurf = lblText.Render();
+ //Point centerPoint = DrawingSupport.GetCenter(base.Buffer, textSurf.Size);
if (@checked) {
if (base.MouseInBounds) {
base.Buffer.Blit(IsCheckedIsOver);
@@ -154,7 +160,8 @@
base.Buffer.Blit(NotCheckedNotOver);
}
}
- base.Buffer.Blit(textSurf, new Point(2 + CHECKBOX_SIZE + 10, centerPoint.Y));
+ lblText.BlitToScreen(base.Buffer, new Point(2 + CHECKBOX_SIZE + 10, 0));
+ //base.Buffer.Blit(textSurf, new Point(2 + CHECKBOX_SIZE + 10, centerPoint.Y));
base.DrawBorder();
}
Modified: branches/experimental/src/Widgets/ComboBox.cs
===================================================================
--- branches/experimental/src/Widgets/ComboBox.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/ComboBox.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -52,8 +52,12 @@
base.Click += new EventHandler<MouseButtonEventArgs>(ComboBox_Click);
base.Resized += new EventHandler(ComboBox_Resized);
+
+ base.Paint += new EventHandler(ComboBox_Paint);
}
+
+
#endregion Constructors
#region Events
@@ -109,8 +113,7 @@
itemListBox.SelectItem(index);
}
- protected override void DrawBuffer() {
- base.DrawBuffer();
+ void ComboBox_Paint(object sender, EventArgs e) {
if (itemListBox.SelectedItems.Count == 1) {
base.Buffer.Blit(itemListBox.SelectedItems[0].Buffer, new Point(5, 2), new Rectangle(0, 0, this.Width - 5, this.Height - 2));
}
Modified: branches/experimental/src/Widgets/ContainerWidget.cs
===================================================================
--- branches/experimental/src/Widgets/ContainerWidget.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/ContainerWidget.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -42,6 +42,7 @@
bool updateParentContainer;
VScrollBar vScrollBar;
internal List<ClearRegionRequest> clearRegionRequests;
+ bool inBlitRegion;
#endregion Fields
@@ -109,7 +110,7 @@
}
if (loaded || this.Parent == null) {
widget.RequestRedraw();
- UpdateWidget(widget);
+ //UpdateWidget(widget);
}
}
}
@@ -132,14 +133,28 @@
}
}
- public override void BlitToScreen(SdlDotNet.Graphics.Surface destinationSurface) {
+ public override void BlitToScreen(SdlDotNet.Graphics.Surface destinationSurface, Rectangle sourceRectangle, Point location) {
+ inBlitRegion = true;
+ base.BlitToScreen(destinationSurface, sourceRectangle, location);
for (int i = 0; i < clearRegionRequests.Count; i++) {
ClearRegion(clearRegionRequests[i].Region, clearRegionRequests[i].WidgetToSkip);
//clearRegionRequests.RemoveAt(i);
}
clearRegionRequests.Clear();
CheckWidgets();
+ inBlitRegion = false;
+ }
+
+ public override void BlitToScreen(SdlDotNet.Graphics.Surface destinationSurface) {
+ //inBlitRegion = true;
base.BlitToScreen(destinationSurface);
+ //for (int i = 0; i < clearRegionRequests.Count; i++) {
+ // ClearRegion(clearRegionRequests[i].Region, clearRegionRequests[i].WidgetToSkip);
+ // //clearRegionRequests.RemoveAt(i);
+ //}
+ //clearRegionRequests.Clear();
+ //CheckWidgets();
+ //inBlitRegion = false;
}
public void CheckWidgets() {
@@ -167,30 +182,42 @@
}
public void ClearRegion(Rectangle bounds, Widget widgetToSkip) {
- ClearRegion(bounds, widgetToSkip, true);
+ if (inBlitRegion) {
+ ClearRegion(bounds, widgetToSkip, true);
+ } else {
+#if TEST
+ MessageBox.Show("Blit error! (1)", "Error!");
+#endif
+ }
}
public void ClearRegion(Rectangle bounds, Widget widgetToSkip, bool updateParent) {
- lock (lockObject) {
- DrawBackgroundRegion(bounds);
- base.DrawBackgroundImageRegion(bounds);
+ if (inBlitRegion) {
+ lock (lockObject) {
+ DrawBackgroundRegion(bounds);
+ base.DrawBackgroundImageRegion(bounds);
- for (int i = 0; i < childWidgets.Count; i++) {
- if (childWidgets[i].Visible && (widgetToSkip != null && childWidgets[i] != widgetToSkip)) {
- if (childWidgets[i].Bounds.IntersectsWith(bounds)) {
- Rectangle region = CalculateRegion(bounds, childWidgets[i].Bounds);//new Rectangle(widgetToSkip.X - childWidgets[i].X, widgetToSkip.Y - childWidgets[i].Y, System.Math.Min((childWidgets[i].Width + childWidgets[i].X) - widgetToSkip.X, widgetToSkip.Width), System.Math.Min((childWidgets[i].Height + childWidgets[i].Y) - widgetToSkip.Y, widgetToSkip.Height));
- childWidgets[i].BlitToScreen(base.Buffer, region, new Point(childWidgets[i].X + region.X, childWidgets[i].Y + region.Y));
+ for (int i = 0; i < childWidgets.Count; i++) {
+ if (childWidgets[i].Visible && (widgetToSkip != null && childWidgets[i] != widgetToSkip)) {
+ if (childWidgets[i].Bounds.IntersectsWith(bounds)) {
+ Rectangle region = CalculateRegion(bounds, childWidgets[i].Bounds);//new Rectangle(widgetToSkip.X - childWidgets[i].X, widgetToSkip.Y - childWidgets[i].Y, System.Math.Min((childWidgets[i].Width + childWidgets[i].X) - widgetToSkip.X, widgetToSkip.Width), System.Math.Min((childWidgets[i].Height + childWidgets[i].Y) - widgetToSkip.Y, widgetToSkip.Height));
+ childWidgets[i].BlitToScreen(base.Buffer, region, new Point(childWidgets[i].X + region.X, childWidgets[i].Y + region.Y));
+ }
}
}
- }
- // TriggerRedrawEvent();
- if (updateParentContainer && updateParent) {
- if (ParentContainer != null && ParentContainer != this) {
- base.RequestRedraw();
- //RequestRedraw();
- //ParentContainer.UpdateWidget(this);
+ // TriggerRedrawEvent();
+ if (updateParentContainer && updateParent) {
+ if (ParentContainer != null && ParentContainer != this) {
+ base.RequestRedraw();
+ //RequestRedraw();
+ //ParentContainer.UpdateWidget(this);
+ }
}
}
+ } else {
+#if TEST
+ MessageBox.Show("Blit error! (2)", "Error!");
+#endif
}
}
@@ -249,12 +276,12 @@
public override void OnMouseDown(MouseButtonEventArgs e) {
base.OnMouseDown(e);
- e.Position = new Point(e.Position.X - this.Location.X, e.Position.Y - this.Location.Y);
+ e.Position = new Point(e.Position.X - this.ScaledLocation.X, e.Position.Y - this.ScaledLocation.Y);
//Point location = this.ScreenLocation;
//Point relPoint = new Point(e.Position.X - location.X, e.Position.Y - location.Y);
for (int i = childWidgets.Count - 1; i >= 0; i--) {
if (childWidgets[i].Visible) {
- if (DrawingSupport.PointInBounds(e.Position, childWidgets[i].Bounds)) {
+ if (DrawingSupport.PointInBounds(e.Position, childWidgets[i].ScaledBounds)) {
if (!childWidgets[i].PreventFocus) {
activeWidget = childWidgets[i];
}
@@ -282,12 +309,12 @@
public override void OnMouseUp(MouseButtonEventArgs e) {
base.OnMouseUp(e);
- e.Position = new Point(e.Position.X - this.Location.X, e.Position.Y - this.Location.Y);
+ e.Position = new Point(e.Position.X - this.ScaledLocation.X, e.Position.Y - this.ScaledLocation.Y);
//Point location = this.ScreenLocation;
//Point relPoint = new Point(e.Position.X - location.X, e.Position.Y - location.Y);
for (int i = childWidgets.Count - 1; i >= 0; i--) {
if (childWidgets[i].Visible) {
- if (DrawingSupport.PointInBounds(e.Position, childWidgets[i].Bounds)) {
+ if (DrawingSupport.PointInBounds(e.Position, childWidgets[i].ScaledBounds)) {
childWidgets[i].OnMouseUp(e);
return;
}
@@ -313,7 +340,7 @@
lock (lockObject) {
int index = childWidgets.FindWidget(name);
if (index > -1) {
- ClearRegion(childWidgets[index].Bounds, childWidgets[index]);
+ ClearRegion(childWidgets[index].ScaledBounds, childWidgets[index]);
childWidgets[index].FreeResources();
childWidgets.RemoveWidget(index);
} else {
@@ -342,64 +369,88 @@
}
public void UpdateBuffer() {
- UpdateBuffer(true);
+ if (inBlitRegion) {
+ UpdateBuffer(true);
+ } else {
+#if TEST
+ MessageBox.Show("Blit error! (3)", "Error!");
+#endif
+ }
}
public void UpdateBuffer(bool resetBackground) {
- lock (lockObject) {
- if (!base.Updating) {
- if (resetBackground) {
- base.Buffer.Fill(this.BackColor);
- DrawBackgroundImage();
- }
- if (childWidgets != null) {
- for (int i = 0; i < childWidgets.Count; i++) {
- if (childWidgets[i].Visible) {
- childWidgets[i].BlitToScreen(base.Buffer);
+ if (inBlitRegion) {
+ lock (lockObject) {
+ if (!base.Updating) {
+ if (resetBackground) {
+ base.Buffer.Fill(this.BackColor);
+ DrawBackgroundImage();
+ }
+ if (childWidgets != null) {
+ for (int i = 0; i < childWidgets.Count; i++) {
+ if (childWidgets[i].Visible) {
+ childWidgets[i].BlitToScreen(base.Buffer);
+ }
}
}
+ TriggerRedrawEvent();
}
- TriggerRedrawEvent();
}
+ } else {
+#if TEST
+ MessageBox.Show("Blit error! (4)", "Error!");
+#endif
}
}
public void UpdateWidget(Widget widget) {
- lock (lockObject) {
- if (!base.Updating) {
- if (!string.IsNullOrEmpty(widget.Name)) {
- if (widget.BackColor == Color.Transparent) {
- DrawBackgroundRegion(widget.Bounds);
- base.DrawBackgroundImageRegion(widget.Bounds);
- }
- WidgetRenderer.UpdateWidget(base.Buffer, widget, childWidgets);
- //for (int i = 0; i < childWidgets.Count; i++) {
- // if (childWidgets[i].Visible) {
- // if (childWidgets[i] == widget) {
- // childWidgets[i].BlitToScreen(base.Buffer);
- // } else if (childWidgets[i].Bounds.IntersectsWith(widget.Bounds)) {
- // Rectangle region = CalculateRegion(widget.Bounds, childWidgets[i].Bounds);//new Rectangle(widget.X, widget.Y, System.Math.Min((childWidgets[i].Width + childWidgets[i].X) - widget.X, widget.Width), System.Math.Min((childWidgets[i].Height + childWidgets[i].Y) - widget.Y, widget.Height));
- // childWidgets[i].BlitToScreen(base.Buffer, region, new Point(childWidgets[i].X + region.X, childWidgets[i].Y + region.Y));
- // }
- // }
- //}
- TriggerRedrawEvent();
- if (updateParentContainer) {
- if (ParentContainer != null && ParentContainer != this) {
- base.RequestRedraw();
- //ParentContainer.RequestRedraw();
- //base.RequestRedraw();
- //ParentContainer.UpdateWidget(this);
+ if (inBlitRegion) {
+ lock (lockObject) {
+ if (!base.Updating) {
+ if (!string.IsNullOrEmpty(widget.Name)) {
+ if (widget.BackColor == Color.Transparent) {
+ DrawBackgroundRegion(widget.ScaledBounds);
+ base.DrawBackgroundImageRegion(widget.ScaledBounds);
}
+ WidgetRenderer.UpdateWidget(base.Buffer, widget, childWidgets);
+ //for (int i = 0; i < childWidgets.Count; i++) {
+ // if (childWidgets[i].Visible) {
+ // if (childWidgets[i] == widget) {
+ // childWidgets[i].BlitToScreen(base.Buffer);
+ // } else if (childWidgets[i].Bounds.IntersectsWith(widget.Bounds)) {
+ // Rectangle region = CalculateRegion(widget.Bounds, childWidgets[i].Bounds);//new Rectangle(widget.X, widget.Y, System.Math.Min((childWidgets[i].Width + childWidgets[i].X) - widget.X, widget.Width), System.Math.Min((childWidgets[i].Height + childWidgets[i].Y) - widget.Y, widget.Height));
+ // childWidgets[i].BlitToScreen(base.Buffer, region, new Point(childWidgets[i].X + region.X, childWidgets[i].Y + region.Y));
+ // }
+ // }
+ //}
+ TriggerRedrawEvent();
+ if (updateParentContainer) {
+ if (ParentContainer != null && ParentContainer != this) {
+ base.RequestRedraw();
+ //ParentContainer.RequestRedraw();
+ //base.RequestRedraw();
+ //ParentContainer.UpdateWidget(this);
+ }
+ }
}
}
}
+ } else {
+#if TEST
+ MessageBox.Show("Blit error! (5)", "Error!");
+#endif
}
}
protected virtual void DrawBackgroundRegion(Rectangle region) {
- lock (lockObject) {
- base.Buffer.Fill(region, this.BackColor);
+ if (inBlitRegion) {
+ lock (lockObject) {
+ base.Buffer.Fill(region, this.BackColor);
+ }
+ } else {
+#if TEST
+ MessageBox.Show("Blit error! (6)", "Error!");
+#endif
}
}
Added: branches/experimental/src/Widgets/DragDropDataObject.cs
===================================================================
--- branches/experimental/src/Widgets/DragDropDataObject.cs (rev 0)
+++ branches/experimental/src/Widgets/DragDropDataObject.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SdlDotNet.Widgets
+{
+ class DragDropDataObject : IDataObject
+ {
+ public object GetData(Type format) {
+ return null;
+ }
+
+ public bool GetDataPresent(Type format) {
+ return false;
+ }
+
+ public void SetData(object data) {
+
+ }
+ }
+}
Added: branches/experimental/src/Widgets/DragDropEvents.cs
===================================================================
--- branches/experimental/src/Widgets/DragDropEvents.cs (rev 0)
+++ branches/experimental/src/Widgets/DragDropEvents.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SdlDotNet.Widgets
+{
+ [FlagsAttribute]
+ public enum DragDropEvents
+ {
+ /// <summary>
+ /// The drop target does not accept the data.
+ /// </summary>
+ None,
+ /// <summary>
+ /// The data from the drag source is copied to the drop target.
+ /// </summary>
+ Copy,
+ /// <summary>
+ /// The data from the drag source is moved to the drop target.
+ /// </summary>
+ Move,
+ /// <summary>
+ /// The data from the drag source is linked to the drop target.
+ /// </summary>
+ Link,
+ /// <summary>
+ /// The target can be scrolled while dragging to locate a drop position that is not currently visible in the target.
+ /// </summary>
+ Scroll,
+ /// <summary>
+ /// The combination of the Copy, Move, and Scroll effects.
+ /// </summary>
+ All
+ }
+}
Added: branches/experimental/src/Widgets/DragEventArgs.cs
===================================================================
--- branches/experimental/src/Widgets/DragEventArgs.cs (rev 0)
+++ branches/experimental/src/Widgets/DragEventArgs.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SdlDotNet.Widgets
+{
+ public class DragEventArgs
+ {
+ IDataObject data;
+
+
+ }
+}
Modified: branches/experimental/src/Widgets/FileBrowserDialog.cs
===================================================================
--- branches/experimental/src/Widgets/FileBrowserDialog.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/FileBrowserDialog.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -144,7 +144,7 @@
if (!string.IsNullOrEmpty(filter)) {
string[] filters = filter.Split('|');
for (int i = 0; i < filters.Length; i++) {
- ListBoxTextItem item = new ListBoxTextItem(new Graphics.Font(Widgets.DefaultFontPath, Widgets.DefaultFontSize), filters[i]);
+ ListBoxTextItem item = new ListBoxTextItem(new Graphics.Font(Widgets.DefaultFontPath, Widgets.DefaultFontSize), filters[i] + " (" + filters[i +1].Replace(";", ", ") + ")");
item.Tag = filters[i + 1];
cmbFilter.Items.Add(item);
@@ -155,6 +155,16 @@
}
}
+ public string SelectedFilterType {
+ get {
+ if (cmbFilter.SelectedItem != null) {
+ return cmbFilter.SelectedItem.Tag as string;
+ } else {
+ return null;
+ }
+ }
+ }
+
public new DialogResult ShowDialog() {
if (cmbFilter.Items.Count > filterIndex) {
cmbFilter.SelectItem(filterIndex);
Modified: branches/experimental/src/Widgets/FileDialog.cs
===================================================================
--- branches/experimental/src/Widgets/FileDialog.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/FileDialog.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -93,6 +93,12 @@
}
}
+ public string SelectedFilterType {
+ get {
+ return fileBrowser.SelectedFilterType;
+ }
+ }
+
public FileDialog() {
Initialize();
}
@@ -106,10 +112,12 @@
fileBrowser = new FileBrowserDialog("FileBrowser-FileDialog");
}
- public DialogResult ShowDialog() {
+ public virtual DialogResult ShowDialog() {
DialogResult browserResult = fileBrowser.ShowDialog();
this.fileName = fileBrowser.SelectedFile;
+ this.fileNames = new string[1];
+ this.fileNames[0] = fileBrowser.SelectedFile;
return browserResult;
}
}
Modified: branches/experimental/src/Widgets/GroupBox.cs
===================================================================
--- branches/experimental/src/Widgets/GroupBox.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/GroupBox.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -53,8 +53,11 @@
children.AddWidget(pnlContainer);
base.Resized += new EventHandler(GroupBox_Resized);
+ base.Paint += new EventHandler(GroupBox_Paint);
}
+
+
#endregion Constructors
#region Properties
@@ -69,6 +72,10 @@
set { text = value; }
}
+ public WidgetCollection ChildWidgets {
+ get { return pnlContainer.ChildWidgets; }
+ }
+
#endregion Properties
#region Methods
@@ -132,8 +139,7 @@
base.BlitToScreen(destinationSurface);
}
- protected override void DrawBuffer() {
- base.DrawBuffer();
+ void GroupBox_Paint(object sender, EventArgs e) {
if (!string.IsNullOrEmpty(text) && font != null) {
//TextRenderer.RenderText(base.Buffer, font, text, base.ForeColor, false, this.Width, 0, 5, 0);
}
Modified: branches/experimental/src/Widgets/HScrollBar.cs
===================================================================
--- branches/experimental/src/Widgets/HScrollBar.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/HScrollBar.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -92,8 +92,12 @@
clickTickVal = -1;
scrollDelay = 200;
scrollSpeed = 50;
+
+ base.Paint += new EventHandler(HScrollBar_Paint);
}
+
+
#endregion Constructors
#region Events
@@ -317,8 +321,7 @@
}
}
- protected override void DrawBuffer() {
- base.DrawBuffer();
+ void HScrollBar_Paint(object sender, EventArgs e) {
if (btnLeft != null) {
btnLeft.BlitToScreen(base.Buffer);
}
Modified: branches/experimental/src/Widgets/Highlighter.cs
===================================================================
--- branches/experimental/src/Widgets/Highlighter.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/Highlighter.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -40,19 +40,19 @@
#region Constructors
public Highlighter(string name)
- : base(name)
- {
+ : base(name) {
base.BackColor = Color.Transparent;
this.MouseEnter += new EventHandler(Highlighter_MouseEnter);
this.MouseLeave += new EventHandler(Highlighter_MouseLeave);
+
+ base.Paint += new EventHandler(Highlighter_Paint);
}
#endregion Constructors
#region Properties
- public Surface HighlightImage
- {
+ public Surface HighlightImage {
get { return highlightImage; }
set {
if (highlightImage != null) {
@@ -70,8 +70,7 @@
#region Methods
- public override void FreeResources()
- {
+ public override void FreeResources() {
base.FreeResources();
if (highlightImage != null) {
highlightImage.Close();
@@ -79,22 +78,18 @@
}
}
- protected override void DrawBuffer()
- {
- base.DrawBuffer();
+ void Highlighter_Paint(object sender, EventArgs e) {
if (base.MouseInBounds) {
base.Buffer.Blit(highlightImage, new Point(0, 0));
}
base.DrawBorder();
}
- void Highlighter_MouseEnter(object sender, EventArgs e)
- {
+ void Highlighter_MouseEnter(object sender, EventArgs e) {
RequestRedraw();
}
- void Highlighter_MouseLeave(object sender, EventArgs e)
- {
+ void Highlighter_MouseLeave(object sender, EventArgs e) {
RequestRedraw();
}
Modified: branches/experimental/src/Widgets/IContainer.cs
===================================================================
--- branches/experimental/src/Widgets/IContainer.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/IContainer.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -60,6 +60,10 @@
/// <param name="widget">The widget.</param>
void UpdateWidget(Widget widget);
+ void BlitToScreen(SdlDotNet.Graphics.Surface destinationSurface);
+
+ WidgetCollection ChildWidgets { get; }
+
#endregion Methods
}
}
\ No newline at end of file
Added: branches/experimental/src/Widgets/IDataObject.cs
===================================================================
--- branches/experimental/src/Widgets/IDataObject.cs (rev 0)
+++ branches/experimental/src/Widgets/IDataObject.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SdlDotNet.Widgets
+{
+ interface IDataObject
+ {
+ object GetData(Type format);
+ bool GetDataPresent(Type format);
+ void SetData(object data);
+ }
+}
Modified: branches/experimental/src/Widgets/IListBoxItem.cs
===================================================================
--- branches/experimental/src/Widgets/IListBoxItem.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/IListBoxItem.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -59,6 +59,7 @@
void FreeResources();
bool AttemptRedraw();
+ void SetContainer(ListBox container);
#endregion Methods
}
Modified: branches/experimental/src/Widgets/Label.cs
===================================================================
--- branches/experimental/src/Widgets/Label.cs 2010-12-19 05:10:58 UTC (rev 1642)
+++ branches/experimental/src/Widgets/Label.cs 2011-01-14 00:38:13 UTC (rev 1643)
@@ -46,6 +46,7 @@
bool wordWrap;
bool autoScrollSet = false;
bool scrollToBottom;
+ bool inHover = false;
#endregion Fields
@@ -60,8 +61,11 @@
base.MouseEnter += new EventHandler(Label_MouseEnter);
base.MouseLeave += new EventHandler(Label_MouseLeave);
base.Resized += new EventHandler(Label_Resized);
+ base.Paint += new EventHandler(Label_Paint);
}
+
+
#endregion Constructors
#region Delegates
@@ -140,6 +144,11 @@
get { return base.ForeColor; }
set {
if (base.ForeColor != value) {
+ for (int i = 0; i < charRenderOptions.Count; i++) {
+ if (charRenderOptions[i].ForeColor == base.ForeColor) {
+ charRenderOptions[i].ForeColor = value;
+ }
+ }
base.ForeColor = value;
RequestRedraw();
}
@@ -238,6 +247,7 @@
if (vScroll != null && vScroll.Visible) {
//vScroll.Value = vScroll.Maximum;
scrollToBottom = true;
+ RequestRedraw();
}
}
@@ -266,13 +276,10 @@
SetText(newText);
}
- protected override void DrawBuffer() {
+ void Label_Paint(object sender, EventArgs e) {
lock (lockObject) {
if (this.Updating == false) {
this.Updating = true;
- if (string.IsNullOrEmpty(text)) {
- base.DrawBuffer();
- }
if (!string.IsNullOrEmpty(text)) {
CheckFont();
@@ -282,7 +289,6 @@
// ResizeInternal(new Size(newSize.Width + 10, newSize.Height));
// }
//}
- base.DrawBuffer();
//string escapedText = System.Text.RegularExpressions.Regex.Escape(text);
//if (escapedText.Length != charRenderOptions.Count) {
@@ -296,9 +302,12 @@
if (autoScroll && autoScrollSet) {
int width = this.Width;
//Size textSize1 = TextRenderer.SizeText2(font, text, antiAlias, width);
- Size textSize2 = TextRenderer.SizeText2(font, text, antiAlias, width - 12);//vScroll.Width);
+ Size textSize2 = TextRenderer.SizeText2(font, text, antiAlias, width - 12 - 5);//vScroll.Width);
Size goodSize = new Size();
+ //if (vScroll != null & vScroll.Visible) {
+ // Size testSize = TextRenderer.RenderSizeData(this.font, text, charRenderOptions.ToArray(), Color.Black, false, this.Width - vScroll.Width - 5, this.Height, 0, vScroll.Value);
+ //}
//if (textSize2.Height > this.Height) {
// goodSize = textSize2;
//} else if (textSize1.Height > this.Height) {
@@ -306,13 +315,15 @@
//}
goodSize = textSize2;
+
+
if (goodSize.Height > this.Height) {
CheckVScrollBar();
vScroll.Location = new Point(this.Width - 12, 0);
vScroll.Size = new Size(12, this.Height);
vScroll.Minimum = 0;
//vScroll.Value = 0;
- vScroll.Maximum = RoundToMultiple((goodSize.Height / font.Height), 1) - (this.Height / font.Height) + 1;
+ vScroll.Maximum = ((goodSize.Height + font.Height) / font.Height) - (RoundToMultiple(Height, font.Height) / font.Height);//RoundToMultiple((goodSize.Height / font.LineSize), 1) - (this.Height / font.LineSize) + 1;
vScroll.Visible = true;
if (scrollToBottom) {
vScroll.Value = vScroll.Maximum;
@@ -328,19 +339,31 @@
SdlDotNet.Graphics.Surface textSurface;
Color textColor;
- if (hoverColor != Color.Empty && IsMouseInBounds()) {
+ if (hoverColor != Color.Empty && inHover) {
textColor = hoverColor;
} else {
textColor = this.ForeColor;
}
- if (vScroll != null && vScroll.Visible && hScroll != null && hScroll.Visible) {
- textSurface = TextRenderer.RenderTextBasic2(this.font, text, charRenderOptions.ToArray(), textColor, false, this.Width - vScroll.Width - 5, this.Height - hScroll.Height, 0, 0);
- } else if (vScroll != null && vScroll.Visible) {
- textSurface = TextRenderer.RenderTextBasic2(this.font, text, charRenderOptions.ToArray(), textColor, false, this.Width - vScroll.Width - 5, this.Height, 0, vScroll.Value);
- } else if (hScroll != null && hScroll.Visible) {
- textSurface = TextRenderer.RenderTextBasic2(this.font, text, charRenderOptions.ToArray(), textColor, false, this.Width - 5, this.Height - hScroll.Height, 0, 0);
+ if (inHover) {
+ if (vScroll != null && vScroll.Visible && hScroll != null && hScroll.Visible) {
+ textSurface = TextRenderer.RenderTextBasic2(this.font, text, null, hoverColor, false, this.Width - vScroll.Width - 5, this.Height - hScroll.Height, 0, 0);
+ } else if (vScroll != null && vScroll.Visible) {
+ textSurface = TextRenderer.RenderTextBasic2(this.font, text, null, hoverColor, false, this.Width - vScroll.Width - 5, this.Height, 0, vScroll.Value);
+ } else if (hScroll != null && hScroll.Visible) {
+ textSurface = TextRenderer.RenderTextBasic2(this.font, text, null, hoverColor, false, this.Width - 5, this.Height - hScroll.Height, 0, 0);
+ } else {
+ textSurface = TextRenderer.RenderTextBasic2(this.font, text, null, hoverColor, false, this.Width - 5, this.Height, 0, 0);
+ }
} else {
- textSurface = TextRenderer.RenderTextBasic2(this.font, text, charRenderOptions.ToArray(), textColor, false, this.Width - 5, this.Height, 0, 0);
+ if (...
[truncated message content] |