changeset 26:7f0b7a53a000

FBGUI: Allow derived classes to access some internals
author Ivo Smits <Ivo@UCIS.nl>
date Mon, 15 Apr 2013 20:29:02 +0200
parents 5d8fe6b2189c
children 5bfc6c68591e
files FBGUI.cs
diffstat 1 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/FBGUI.cs	Mon Apr 15 16:50:07 2013 +0200
+++ b/FBGUI.cs	Mon Apr 15 20:29:02 2013 +0200
@@ -118,8 +118,8 @@
 	}
 	public class FBGContainerControl : FBGControl, IFBGContainerControl {
 		protected List<IFBGControl> controls = new List<IFBGControl>();
-		private IFBGControl mouseCaptureControl = null;
-		private IFBGControl keyboardCaptureControl = null;
+		protected IFBGControl mouseCaptureControl = null;
+		protected IFBGControl keyboardCaptureControl = null;
 		private Rectangle childarea = Rectangle.Empty;
 		public Rectangle ClientRectangle { get { return childarea; } protected set { childarea = value; Invalidate(); } }
 		public FBGContainerControl(IFBGContainerControl parent) : base(parent) { }
@@ -512,10 +512,10 @@
 		private FBGCursor cursor = null;
 		private Point cursorposition = Point.Empty;
 		public IFramebuffer Framebuffer { get; private set; }
-		private Bitmap Frontbuffer;
-		private Object RenderLock = new object();
+		private Bitmap Frontbuffer = null;
+		protected Object RenderLock = new object();
 		public event EventHandler<InvalidateEventArgs> Painted;
-		private Size size;
+		protected Size size = Size.Empty;
 		private ThreadingTimer PaintTimer = null;
 		private Boolean PaintScheduled = false;
 		private int PaintDelay = 0;
@@ -588,6 +588,9 @@
 			BackColor = SystemColors.Control;
 			size = Frontbuffer.Size;
 		}
+		protected FBGRenderer() : base(null) {
+			BackColor = SystemColors.Control;
+		}
 		public override void Invalidate(Rectangle rect) {
 			if (rect.Width == 0 || rect.Height == 0) return;
 			lock (RenderLock) {
@@ -611,15 +614,17 @@
 				}
 			} catch { }
 		}
-		private void Refresh(Rectangle rect) {
+		protected virtual void Refresh(Rectangle rect) {
 			lock (RenderLock) {
 				rect.Intersect(Bounds);
 				if (rect.Width == 0 || rect.Height == 0) return;
-				using (Graphics g = Graphics.FromImage(Frontbuffer)) {
-					g.SetClip(rect);
-					Paint(g);
+				if (Frontbuffer != null) {
+					using (Graphics g = Graphics.FromImage(Frontbuffer)) {
+						g.SetClip(rect);
+						Paint(g);
+					}
+					if (Framebuffer != null) Framebuffer.DrawImage(Frontbuffer, rect, rect.Location);
 				}
-				if (Framebuffer != null) Framebuffer.DrawImage(Frontbuffer, rect, rect.Location);
 				RaiseEvent(Painted, new InvalidateEventArgs(rect));
 			}
 		}
@@ -637,7 +642,7 @@
 		protected override Boolean CaptureKeyboard(bool capture) {
 			return true;
 		}
-		public void Dispose() {
+		public virtual void Dispose() {
 			lock (RenderLock) {
 				if (PaintTimer != null) PaintTimer.Dispose();
 				PaintTimer = null;