// Constructor. public DrawingWindowBuffer(IToolkitWindow windowToBuffer) { toolkit = windowToBuffer.Toolkit; widget = windowToBuffer as InputOutputWidget; buffer = null; graphics = null; }
// Create the toolkit window underlying this control. internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow parent) { CreateParams cp = CreateParams; int x = cp.X + ToolkitDrawOrigin.X; int y = cp.Y + ToolkitDrawOrigin.Y; int width = cp.Width - ToolkitDrawSize.Width; int height = cp.Height - ToolkitDrawSize.Height; if (parent != null) { // Use the parent's toolkit to create. if (Parent is Form) { // use ControlToolkitManager to create the window thread safe return(ControlToolkitManager.CreateMdiClient(this, parent, x, y, width, height)); } else { // use ControlToolkitManager to create the window thread safe return(ControlToolkitManager.CreateMdiClient(this, parent, x + Parent.ClientOrigin.X, y + Parent.ClientOrigin.Y, width, height)); } } else { // Use the default toolkit to create. // use ControlToolkitManager to create the window thread safe return(ControlToolkitManager.CreateMdiClient(this, null, x, y, width, height)); } }
// Create a top-level dialog shell. public IToolkitWindow CreateTopLevelDialog (int width, int height, bool modal, bool resizable, IToolkitWindow dialogParent, IToolkitEventSink sink) { DrawingTopLevelWindow window; ValidateWindowSize(ref width, ref height); window = new DrawingTopLevelWindow (this, String.Empty, width, height, sink); if (dialogParent is TopLevelWindow) { window.TransientFor = (TopLevelWindow)dialogParent; } if (modal) { window.InputType = MotifInputType.ApplicationModal; } else { window.InputType = MotifInputType.Modeless; } if (!resizable) { window.Decorations = MotifDecorations.Border | MotifDecorations.Title | MotifDecorations.Menu; window.Functions = MotifFunctions.Move | MotifFunctions.Close; } return(window); }
// Create a top-level dialog shell. public IToolkitWindow CreateTopLevelDialog (int width, int height, bool modal, bool resizable, IToolkitWindow dialogParent, IToolkitEventSink sink) { DrawingTopLevelWindow window; window = new DrawingTopLevelWindow (this, String.Empty, width, height, sink); /*if(dialogParent is TopLevelWindow) * { * window.TransientFor = (TopLevelWindow)dialogParent; * } * if(modal) * { * window.InputType = MotifInputType.ApplicationModal; * } * else * { * window.InputType = MotifInputType.Modeless; * } * if(!resizable) * { * window.Decorations = MotifDecorations.Border | * MotifDecorations.Title | * MotifDecorations.Menu; * window.Functions = MotifFunctions.Move | * MotifFunctions.Close; * }*/ AddWindow(window, dialogParent as DrawingWindow); window.CreateWindow(); return(window); }
// Reparent this window to underneath a new parent. If there is no parent then the parent is the desktop and the control is not visible. void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y) { if (parent != this.parent) { // window with no parent cant be visible if (parent == null || (parent as DrawingWindow).hwnd == IntPtr.Zero) { IsMapped = false; } bool parented = (this.parent != null && this.parent.hwnd != IntPtr.Zero); // Adjust the heirararchy of parents and top of hierarchy ReparentOwn(parent as DrawingWindow); suspendExternalMoveResizeNotify = true; Win32.Api.SetParent(hwnd, parentHwnd); suspendExternalMoveResizeNotify = false; // Reposition this window on the client (this as IToolkitWindow).MoveResize(x, y, dimensions.Width, dimensions.Height); if (visible && !parented) { SetVisible(); } } //Console.WriteLine("DrawingWindow.Reparent, " + sink); }
// Convert a screen point for a window into a client point. public Point ScreenToClient(IToolkitWindow window, Point point) { Win32.Api.POINT p; p.x = point.X; p.y = point.Y; Win32.Api.ScreenToClient((window as DrawingWindow).hwnd, ref p); return(new Point(p.x, p.y)); }
public void ToolkitMdiActivate(IToolkitWindow child) { IToolkitEventSink co = this.mControlWeakRef.Target as IToolkitEventSink; if (null != co) { co.ToolkitMdiActivate(child); } }
// Move this window to below one of its siblings. void IToolkitWindow.MoveToBelow(IToolkitWindow sibling) { DrawingWindow toWindow = sibling as DrawingWindow; MoveWindowTo(this, toWindow); // Make the same changes in win32. Win32.Api.SetWindowPos(hwnd, toWindow.hwnd, 0, 0, 0, 0, Win32.Api.SetWindowsPosFlags.SWP_NOMOVE | Win32.Api.SetWindowsPosFlags.SWP_NOSIZE | Win32.Api.SetWindowsPosFlags.SWP_NOACTIVATE); //Console.WriteLine("DrawingWindow.MoveToBelow, " + sink +", " + sibling); }
internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow parent) { CreateParams cp = CreateParams; // use ControlToolkitManager to create the window thread safe return ControlToolkitManager.CreatePopupWindow( this, cp.X + ToolkitDrawOrigin.X, cp.Y + ToolkitDrawOrigin.Y, cp.Width - ToolkitDrawSize.Width, cp.Height - ToolkitDrawSize.Height); }
internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow parent) { CreateParams cp = CreateParams; // use ControlToolkitManager to create the window thread safe return(ControlToolkitManager.CreatePopupWindow(this, cp.X + ToolkitDrawOrigin.X, cp.Y + ToolkitDrawOrigin.Y, cp.Width - ToolkitDrawSize.Width, cp.Height - ToolkitDrawSize.Height)); }
protected internal override void MouseMove(int msg, int wParam, int lParam) { // Another popup window could grab the capture from this control. When we move back onto this control, we need to make sure that we regain the capture. IToolkitWindow window = (this as IToolkitWindow); if (window.Capture != visible) { window.Capture = base.IsMapped; } base.MouseMove(msg, wParam, lParam); }
// Reparent this window to underneath a new parent. void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y) { if (parent == null) { Reparent(((DrawingToolkit)Toolkit).placeholder, x, y); } else { Reparent((Widget)parent, x, y); } }
// Set this cursor on a toolkit window. internal void SetCursorOnWindow(IToolkitWindow window) { if (icon != null) { window.SetCursor(type, ToolkitManager.GetImageFrame(icon)); } else { window.SetCursor(type, null); } }
// Convert a screen point for a window into a client point. public System.Drawing.Point ScreenToClient (IToolkitWindow window, System.Drawing.Point point) { Widget widget = (window as Widget); if (widget != null) { Xsharp.Point pt = widget.ScreenToWidget(point.X, point.Y); return(new System.Drawing.Point(pt.x, pt.y)); } else { return(point); } }
// Create a child window. If "parent" is null, then the child // does not yet have a "real" parent - it will be reparented later. public IToolkitWindow CreateChildWindow (IToolkitWindow parent, int x, int y, int width, int height, IToolkitEventSink sink) { Widget wparent; if (parent is Widget) { wparent = ((Widget)parent); } else { wparent = placeholder; } ValidateWindowPosition(ref x, ref y); ValidateWindowSize(ref width, ref height); return(new DrawingWindow(this, wparent, x, y, width, height, sink)); }
internal void Activate(IToolkitWindow child) { if (child == null) { activeChild = null; } else { activeChild = null; foreach (Form form in controls) { if (form.toolkitWindow == child) { activeChild = form; break; } } } }
// Create a child window. If "parent" is null, then the child // does not yet have a "real" parent - it will be reparented later. public IToolkitWindow CreateChildWindow (IToolkitWindow parent, int x, int y, int width, int height, IToolkitEventSink sink) { DrawingWindow dparent; if (parent is DrawingWindow) { dparent = ((DrawingWindow)parent); } else { dparent = null; } DrawingWindow window = new DrawingControlWindow(this, "", dparent, x, y, width, height, sink); AddWindow(window, parent as DrawingWindow); window.CreateWindow(); return(window); }
IToolkitWindow InternalCreateMdiClient(Control control, IToolkitWindow parent, int x, int y, int w, int h) { // be ThreadSafe if (IsInvokeRequired) { return((IToolkitTopLevelWindow)Invoke( new DelegateCreateMdiClient(this.InternalCreateMdiClient), new object[] { control, parent, x, y, w, h } )); } if (null != parent) { return(parent.Toolkit.CreateMdiClient(parent, x, y, w, h, new ControlWeakRef(control))); } else { return(ToolkitManager.Toolkit.CreateMdiClient(null, x, y, w, h, new ControlWeakRef(control))); } }
// Reparent this window to underneath a new parent. If there is no parent then the parent is the desktop and the control is not visible. void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y) { if (parent != this.parent) { // window with no parent cant be visible if (parent == null || (parent as DrawingWindow).hwnd == IntPtr.Zero) IsMapped = false; bool parented = (this.parent != null && this.parent.hwnd != IntPtr.Zero); // Adjust the heirararchy of parents and top of hierarchy ReparentOwn(parent as DrawingWindow); suspendExternalMoveResizeNotify = true; Win32.Api.SetParent( hwnd, parentHwnd); suspendExternalMoveResizeNotify = false; // Reposition this window on the client (this as IToolkitWindow).MoveResize(x, y, dimensions.Width, dimensions.Height); if (visible && !parented) SetVisible(); } //Console.WriteLine("DrawingWindow.Reparent, " + sink); }
private IToolkitWindow InternalCreateChildWindow( Control control, IToolkitWindow parent, int x, int y, int w, int h ) { // be ThreadSafe if( IsInvokeRequired ) { return (IToolkitWindow) Invoke( new DelegateCreateChildWindow( this.InternalCreateChildWindow), new object[] { control, parent, x, y, w, h } ); } // Check parent Toolkit too, might be null in some difficult cases. if(parent != null && parent.Toolkit != null ) { return parent.Toolkit.CreateChildWindow (parent, x, y, w, h, new ControlWeakRef(control) ); } else { // Use the default toolkit to create. return ToolkitManager.Toolkit.CreateChildWindow (null, x, y, w, h, new ControlWeakRef(control) ); } }
private IToolkitWindow InternalCreateChildWindow(Control control, IToolkitWindow parent, int x, int y, int w, int h) { // be ThreadSafe if (IsInvokeRequired) { return((IToolkitWindow)Invoke( new DelegateCreateChildWindow(this.InternalCreateChildWindow), new object[] { control, parent, x, y, w, h } )); } // Check parent Toolkit too, might be null in some difficult cases. if (parent != null && parent.Toolkit != null) { return(parent.Toolkit.CreateChildWindow (parent, x, y, w, h, new ControlWeakRef(control))); } else { // Use the default toolkit to create. return(ToolkitManager.Toolkit.CreateChildWindow (null, x, y, w, h, new ControlWeakRef(control))); } }
internal void Activate(IToolkitWindow child) { if(child == null) { activeChild = null; } else { activeChild = null; foreach(Form form in controls) { if(form.toolkitWindow == child) { activeChild = form; break; } } } }
internal static IToolkitWindow CreateChildWindow(Control control, IToolkitWindow parent, int x, int y, int w, int h ) { return Instance.InternalCreateChildWindow(control, parent, x, y, w, h ); }
// Move this window to below one of its siblings. void IToolkitWindow.MoveToBelow(IToolkitWindow sibling) { return; }
// Create an MDI client area. public IToolkitMdiClient CreateMdiClient (IToolkitWindow parent, int x, int y, int width, int height, IToolkitEventSink sink) { Widget wparent; if(parent is Widget) { wparent = ((Widget)parent); } else { wparent = placeholder; } ValidateWindowPosition(ref x, ref y); ValidateWindowSize(ref width, ref height); return new DrawingMdiClient (this, wparent, x, y, width, height, sink); }
// Receive notification that a particular child was activated. internal override void MdiActivate(IToolkitWindow child) { Activate(child); }
void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y) { throw new NotSupportedException("TopLevelWindow can't have a parent"); }
// Create a new window buffer. public IToolkitWindowBuffer CreateWindowBuffer(IToolkitWindow window) { return new DrawingWindowBuffer(window); }
protected virtual void CreateHandle() { if( toolkitWindow != null ) return; // already created // Cannot create the control if it has been disposed. if(GetControlFlag(ControlFlags.Disposed)) { throw new ObjectDisposedException ("control", S._("SWF_ControlDisposed")); } // Create the handle using the toolkit. if(parent != null) { toolkitWindow = CreateToolkitWindow(parent.toolkitWindow); // Mark this control as requiring a reparent, if needed. if(parent.toolkitWindow == null) { SetControlFlag(ControlFlags.NeedReparent, true); } } else { toolkitWindow = CreateToolkitWindow(null); } // Dont think we need this - Neil //toolkitWindow.Lower(); // Copy color information into the toolkit window. toolkitWindow.SetForeground(ForeColor); toolkitWindow.SetBackground(BackColor); // TODO: background images // Set the initial cursor if we aren't inheriting our parent. if(cursor != null) { cursor.SetCursorOnWindow(toolkitWindow); } // createThread = Thread.CurrentThread; not needed anymore // Reparent the children which require it. for(int i = 0; i < numChildren; ++i) { if(children[i].GetControlFlag(ControlFlags.NeedReparent)) { children[i].Reparent(this); } } // Notify subclasses that the handle has been created. OnHandleCreated(EventArgs.Empty); }
// Move this window to above one of its siblings. void IToolkitWindow.MoveToAbove(IToolkitWindow sibling) { return; }
// Create a new window buffer. public IToolkitWindowBuffer CreateWindowBuffer(IToolkitWindow window) { return(new DrawingWindowBuffer(window)); }
public DrawingWindowBuffer(IToolkitWindow windowToBuffer) { window = windowToBuffer as DrawingWindow; CreateBuffer(windowToBuffer.Dimensions.Size); }
internal static IToolkitWindow CreateChildWindow(Control control, IToolkitWindow parent, int x, int y, int w, int h) { return(Instance.InternalCreateChildWindow(control, parent, x, y, w, h)); }
internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow parent) { // When a Form is reparented to a normal container control // which does work on Win32 unfortunately. if(mdiParent == null && (!TopLevel)) { return base.CreateToolkitWindow(parent); } CreateParams cp = CreateParams; // Create the window and set its initial caption. IToolkitTopLevelWindow window; if(mdiParent == null) { // use ControlToolkitManager to create the window thread safe window = ControlToolkitManager.CreateTopLevelWindow( this, cp.Width - ToolkitDrawSize.Width, cp.Height - ToolkitDrawSize.Height); } else { mdiParent.mdiClient.CreateControl(); IToolkitMdiClient mdi = (mdiParent.mdiClient.toolkitWindow as IToolkitMdiClient); // use ControlToolkitManager to create the window thread safe window = ControlToolkitManager.CreateMdiChildWindow( this, mdi, cp.X, cp.Y, cp.Width - ToolkitDrawSize.Width, cp.Height - ToolkitDrawSize.Height); } window.SetTitle(cp.Caption); // Win32 requires this because if the window is maximized, the windows size needs to be set. toolkitWindow = window; // Adjust the window hints to match our requirements. SetWindowFlags(window); if(icon != null) { window.SetIcon(icon); } window.SetMaximumSize(maximumSize); window.SetMinimumSize(minimumSize); #if !CONFIG_COMPACT_FORMS if(windowState == FormWindowState.Minimized) { window.Iconify(); } else #endif if(windowState == FormWindowState.Maximized) { window.Maximize(); } // Center the window on-screen if necessary. if(formStartPosition == FormStartPosition.CenterScreen) { Size screenSize = ToolkitManager.Toolkit.GetScreenSize(); window.MoveResize ((screenSize.Width - cp.Width) / 2, (screenSize.Height - cp.Height) / 2, window.Dimensions.Width, window.Dimensions.Height); } else if(formStartPosition == FormStartPosition.Manual) { window.MoveResize ( cp.X, cp.Y, window.Dimensions.Width, window.Dimensions.Height ); } if(opacity != 1.0) { window.SetOpacity(opacity); } return window; }
// Move this window to above one of its siblings. void IToolkitWindow.MoveToAbove(IToolkitWindow sibling) { throw new NotSupportedException(); //Console.WriteLine("DrawingWindow.MoveToAbove, "+sink); }
public Point ScreenToClient(IToolkitWindow window, Point point) { throw new NotImplementedException(); }
// Create an MDI client area. public IToolkitMdiClient CreateMdiClient (IToolkitWindow parent, int x, int y, int width, int height, IToolkitEventSink sink) { return(null); }
internal virtual void MdiActivate(IToolkitWindow child) {}
// Convert a screen point for a window into a client point. public System.Drawing.Point ScreenToClient (IToolkitWindow window, System.Drawing.Point point) { Widget widget = (window as Widget); if(widget != null) { Xsharp.Point pt = widget.ScreenToWidget(point.X, point.Y); return new System.Drawing.Point(pt.x, pt.y); } else { return point; } }
public IToolkitWindowBuffer CreateWindowBuffer(IToolkitWindow window) { throw new NotImplementedException(); }
// Move this window to below one of its siblings. void IToolkitWindow.MoveToBelow(IToolkitWindow sibling) { // Move this window below the sibling widget. MoveToBelow(sibling as Widget); }
IToolkitWindow InternalCreateMdiClient( Control control, IToolkitWindow parent, int x, int y, int w, int h ) { // be ThreadSafe if( IsInvokeRequired ) { return (IToolkitTopLevelWindow) Invoke( new DelegateCreateMdiClient( this.InternalCreateMdiClient), new object[] { control, parent, x, y, w, h } ); } if( null != parent ) { return parent.Toolkit.CreateMdiClient( parent, x, y, w, h, new ControlWeakRef(control) ); } else { return ToolkitManager.Toolkit.CreateMdiClient(null, x, y, w, h, new ControlWeakRef(control) ); } }
// Create a top-level dialog shell. public IToolkitWindow CreateTopLevelDialog (int width, int height, bool modal, bool resizable, IToolkitWindow dialogParent, IToolkitEventSink sink) { DrawingTopLevelWindow window; ValidateWindowSize(ref width, ref height); window = new DrawingTopLevelWindow (this, String.Empty, width, height, sink); if(dialogParent is TopLevelWindow) { window.TransientFor = (TopLevelWindow)dialogParent; } if(modal) { window.InputType = MotifInputType.ApplicationModal; } else { window.InputType = MotifInputType.Modeless; } if(!resizable) { window.Decorations = MotifDecorations.Border | MotifDecorations.Title | MotifDecorations.Menu; window.Functions = MotifFunctions.Move | MotifFunctions.Close; } return window; }
public void ToolkitMdiActivate(IToolkitWindow child) { IToolkitEventSink co = this.mControlWeakRef.Target as IToolkitEventSink; if( null != co ) { co.ToolkitMdiActivate(child); } }
// Create the toolkit window underlying this control. internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow parent) { CreateParams cp = CreateParams; int x = cp.X + ToolkitDrawOrigin.X; int y = cp.Y + ToolkitDrawOrigin.Y; int width = cp.Width - ToolkitDrawSize.Width; int height = cp.Height - ToolkitDrawSize.Height; if(parent != null) { // Use the parent's toolkit to create. if(Parent is Form) { // use ControlToolkitManager to create the window thread safe return ControlToolkitManager.CreateMdiClient( this, parent, x, y, width, height); } else { // use ControlToolkitManager to create the window thread safe return ControlToolkitManager.CreateMdiClient( this, parent, x + Parent.ClientOrigin.X, y + Parent.ClientOrigin.Y, width, height); } } else { // Use the default toolkit to create. // use ControlToolkitManager to create the window thread safe return ControlToolkitManager.CreateMdiClient (this, null, x, y, width, height); } }
// Reparent this window to underneath a new parent. void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y) { if(parent == null) { Reparent(((DrawingToolkit)Toolkit).placeholder, x, y); } else { Reparent((Widget)parent, x, y); } }
protected virtual void DestroyHandle() { // Bail out if we don't have a handle. if(toolkitWindow == null) { return; } // process all pending InvokeEvents // it could be that a BeginInvoke is waiting for EndInvoke. this.ProcessInvokeEvent( IntPtr.Zero ); // Destroy all of the child controls. int child; for(child = 0; child < numChildren; ++child) { children[child].DestroyHandle(); } // Destroy the toolkit window. if(toolkitWindow != null) { toolkitWindow.Destroy(); toolkitWindow = null; } // Dispose DoubleBuffer too here if( buffer != null ) { buffer.Dispose(); buffer = null; } // Notify event handlers that the handle is destroyed. OnHandleDestroyed(EventArgs.Empty); }
// Event that is called when an MDI child is activated or deactivated. internal override void MdiActivate(IToolkitWindow child) { if(mdiClient != null) { mdiClient.Activate(child); } OnMdiChildActivate(EventArgs.Empty); }
// Create the toolkit window underlying this control. internal virtual IToolkitWindow CreateToolkitWindow(IToolkitWindow parent) { // Because we use owner-draw in this implementation // for all widgets, we are only interested in the // position and size information from "CreateParams". CreateParams cp = CreateParams; // Convert to toolkit coordinates int x = cp.X + ToolkitDrawOrigin.X; int y = cp.Y + ToolkitDrawOrigin.Y; int width = cp.Width - ToolkitDrawSize.Width; int height = cp.Height - ToolkitDrawSize.Height; if(parent != null) { // Offset the co-ordinates to the client origin. // the toolkit co-ordinates must be relative to the draw origin. x += Parent.ClientOrigin.X - Parent.ToolkitDrawOrigin.X; y += Parent.ClientOrigin.Y - Parent.ToolkitDrawOrigin.Y; } // use ControlToolkitManager to create the window thread safe return ControlToolkitManager.CreateChildWindow( this, parent, x, y, width, height ); }
// Set the current state of the window decoration flags on a window. private void SetWindowFlags(IToolkitWindow window) { ((IToolkitTopLevelWindow)window).SetWindowFlags(GetFullFlags()); }
// Event that is emitted when the active MDI child window changes. // The "child" parameter is null if a window has been deactivated. void IToolkitEventSink.ToolkitMdiActivate(IToolkitWindow child) { MdiActivate(child); }