// Authors:
// Jackson Harper (jackson@ximian.com)
-// TODO: Eventually we need to handle the cursor and resizing the parent
-
using System;
using System.Drawing;
#region Local Variables
private bool redraw;
private Point capture_point;
+ private Control captured_control;
private int window_w;
private int window_h;
private bool show_grip;
#endregion // Constructors
#region Properties
+
+ public Control CapturedControl {
+ get {
+ if (captured_control != null)
+ return captured_control;
+ else
+ return Parent;
+ }
+ set {
+ captured_control = value;
+ }
+ }
+
public bool ShowGrip {
get {
return show_grip;
#region Methods
protected override void OnPaint (PaintEventArgs pe) {
- base.OnPaint (pe);
-
- if (redraw) {
- if (show_grip) {
- ControlPaint.DrawSizeGrip(DeviceContext, BackColor, ClientRectangle);
- }
+ if (redraw && show_grip) {
+ pe.Graphics.FillRectangle (new SolidBrush (ThemeEngine.Current.ColorControl), ClientRectangle);
+ ControlPaint.DrawSizeGrip (pe.Graphics, BackColor, ClientRectangle);
}
-
- pe.Graphics.DrawImage(ImageBuffer, pe.ClipRectangle, pe.ClipRectangle, GraphicsUnit.Pixel);
+ base.OnPaint (pe);
}
protected override void OnSizeChanged (EventArgs e) {
redraw = true;
}
- protected override void OnMouseDown(MouseEventArgs e) {\r
- Capture = true;\r
- \r
- capture_point = Control.MousePosition;\r
-\r
- window_w = parent.Width;\r
- window_h = parent.Height;\r
- }\r
-\r
- protected override void OnMouseMove(MouseEventArgs e) {\r
- if (this.is_captured) {\r
- int delta_x;\r
- int delta_y;\r
- Point current_point;\r
-\r
- current_point = Control.MousePosition;\r
-\r
- delta_x = current_point.X - capture_point.X;\r
- delta_y = current_point.Y - capture_point.Y;\r
-\r
- this.parent.Size = new Size(window_w + delta_x, window_h + delta_y);\r
- XplatUI.DoEvents();\r
- }\r
- }\r
-
- protected override void OnMouseUp(MouseEventArgs e) {\r
- if (Capture) {\r
- Capture = false;\r
- if (hide_pending) {\r
- Hide();\r
- hide_pending = false;\r
- }\r
- }\r
- }\r
-\r
-\r
- protected override void SetVisibleCore(bool value) {\r
- if (Capture) {\r
- if (value == false) {\r
- hide_pending = true;\r
- } else {\r
- hide_pending = false;\r
- }\r
- return;\r
- }\r
- base.SetVisibleCore (value);\r
- }\r
-\r
- #endregion // Methods\r
+ protected override void OnMouseDown(MouseEventArgs e) {
+ Capture = true;
+
+ capture_point = Control.MousePosition;
+
+ window_w = CapturedControl.Width;
+ window_h = CapturedControl.Height;
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e) {
+ if (Capture) {
+ int delta_x;
+ int delta_y;
+ Point current_point;
+
+ current_point = Control.MousePosition;
+
+ delta_x = current_point.X - capture_point.X;
+ delta_y = current_point.Y - capture_point.Y;
+
+ CapturedControl.Size = new Size(window_w + delta_x, window_h + delta_y);
+ XplatUI.DoEvents();
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e) {
+ if (Capture) {
+ Capture = false;
+ if (hide_pending) {
+ Hide();
+ hide_pending = false;
+ }
+ }
+ }
+
+
+ protected override void SetVisibleCore(bool value) {
+ if (Capture) {
+ if (value == false) {
+ hide_pending = true;
+ } else {
+ hide_pending = false;
+ }
+ return;
+ }
+ base.SetVisibleCore (value);
+ }
+
+ #endregion // Methods
}
}