[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Xsharp DrawingToolkit
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Xsharp DrawingToolkit.cs,1.2,1.3 DrawingTopLevelWindow.cs,1.1,1.2 DrawingWindow.cs,1.1,1.2 |
Date: |
Wed, 11 Jun 2003 03:07:21 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Xsharp
In directory subversions:/tmp/cvs-serv17639/System.Drawing.Xsharp
Modified Files:
DrawingToolkit.cs DrawingTopLevelWindow.cs DrawingWindow.cs
Log Message:
Initial check-in of a "System.Windows.Forms" implementation (only "Control"
works right now); changes to Xsharp and System.Drawing to support Forms;
new "FormsHello" sample.
Index: DrawingToolkit.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Xsharp/DrawingToolkit.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** DrawingToolkit.cs 9 Jun 2003 21:25:37 -0000 1.2
--- DrawingToolkit.cs 11 Jun 2003 07:07:18 -0000 1.3
***************
*** 52,55 ****
--- 52,67 ----
}
+ // Process events in the event queue. If "waitForEvent" is true,
+ // then wait for the next event and return "false" if "Quit" was
+ // seen. If "waitForEvent" is false, then process events in the
+ // queue and return "true". If "waitForEvent" is false and there
+ // are no events in the queue, then return "false".
+ public bool ProcessEvents(bool waitForEvent)
+ {
+ // TODO
+ app.Run();
+ return false;
+ }
+
// Send a quit message to the toolkit, which should cause
// it to exit from the "Run" method.
***************
*** 139,145 ****
--- 151,200 ----
}
+ // Validate a window size to ensure that it is in-range for X.
+ internal static void ValidateWindowSize(ref int width, ref int height)
+ {
+ if(width < 1)
+ {
+ width = 1;
+ }
+ else if(width > 32767)
+ {
+ width = 32767;
+ }
+ if(height < 1)
+ {
+ height = 1;
+ }
+ else if(height > 32767)
+ {
+ height = 32767;
+ }
+ }
+
+ // Validate a window position to ensure that it is in-range for X.
+ internal static void ValidateWindowPosition(ref int x, ref int y)
+ {
+ if(x < -32767)
+ {
+ x = -32767;
+ }
+ else if(x > 32767)
+ {
+ x = 32767;
+ }
+ if(y < -32767)
+ {
+ y = -32767;
+ }
+ else if(y > 32767)
+ {
+ y = 32767;
+ }
+ }
+
// Create a top-level application window.
public IToolkitWindow CreateTopLevelWindow(int width, int height)
{
+ ValidateWindowSize(ref width, ref height);
return new DrawingTopLevelWindow
(this, String.Empty, width, height);
***************
*** 152,155 ****
--- 207,211 ----
{
DrawingTopLevelWindow window;
+ ValidateWindowSize(ref width, ref height);
window = new DrawingTopLevelWindow
(this, String.Empty, width, height);
***************
*** 199,202 ****
--- 255,260 ----
wparent = placeholder;
}
+ ValidateWindowPosition(ref x, ref y);
+ ValidateWindowSize(ref width, ref height);
return new DrawingWindow(this, wparent, x, y,
width, height);
}
Index: DrawingTopLevelWindow.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Xsharp/DrawingTopLevelWindow.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** DrawingTopLevelWindow.cs 7 Jun 2003 22:40:58 -0000 1.1
--- DrawingTopLevelWindow.cs 11 Jun 2003 07:07:19 -0000 1.2
***************
*** 32,35 ****
--- 32,36 ----
// Internal state.
private IToolkit toolkit;
+ private IToolkitEventSink sink;
// Constructor.
***************
*** 51,54 ****
--- 52,64 ----
}
+ // Get the toolkit parent window.
+ IToolkitWindow IToolkitWindow.Parent
+ {
+ get
+ {
+ return (IToolkitWindow)Parent;
+ }
+ }
+
// Get the current dimensions of this window.
public System.Drawing.Rectangle Dimensions
***************
*** 73,76 ****
--- 83,95 ----
}
+ // Determine if this window currently has the input focus.
+ bool IToolkitWindow.Focused
+ {
+ get
+ {
+ return Focused;
+ }
+ }
+
// Destroy this window and all of its children.
void IToolkitWindow.Destroy()
***************
*** 82,85 ****
--- 101,106 ----
void IToolkitWindow.MoveResize(int x, int y, int width, int height)
{
+ DrawingToolkit.ValidateWindowPosition(ref x,
ref y);
+ DrawingToolkit.ValidateWindowSize(ref width,
ref height);
Move(x, y);
Resize(width, height);
***************
*** 107,111 ****
void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y)
{
! // TODO
}
--- 128,139 ----
void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y)
{
! if(parent == null)
! {
!
Reparent(((DrawingToolkit)Toolkit).placeholder, x, y);
! }
! else
! {
! Reparent((Widget)parent, x, y);
! }
}
***************
*** 127,130 ****
--- 155,164 ----
}
+ // Set the foreground of the window to a solid color.
+ void IToolkitWindow.SetForeground(System.Drawing.Color color)
+ {
+ Foreground =
DrawingToolkit.DrawingToXColor(color);
+ }
+
// Set the background of the window to a solid color.
void IToolkitWindow.SetBackground(System.Drawing.Color color)
***************
*** 140,158 ****
}
// Handle a paint event from Xsharp.
protected override void OnPaint(Xsharp.Graphics graphics)
{
! if(Expose != null)
{
DrawingGraphics g = new
DrawingGraphics(toolkit, graphics);
System.Drawing.Graphics gr =
ToolkitManager.CreateGraphics(g);
! Expose(gr);
gr.Dispose();
}
}
-
- // Event that is emitted for an expose on this window.
- public event ToolkitExposeHandler Expose;
}; // class DrawingTopLevelWindow
--- 174,347 ----
}
+ // Get the adjustment values for the client area.
+ // On entry, all values are zero.
+ void IToolkitWindow.GetClientAreaAdjust
+ (ref int leftAdjust, ref int topAdjust,
+ ref int rightAdjust, ref int bottomAdjust)
+ {
+ // Nothing to do in this implementation.
+ }
+
+ // Move this window to above one of its siblings.
+ void IToolkitWindow.MoveToAbove(IToolkitWindow sibling)
+ {
+ // TODO
+ }
+
+ // Move this window to below one of its siblings.
+ void IToolkitWindow.MoveToBelow(IToolkitWindow sibling)
+ {
+ // TODO
+ }
+
+ // Get the HWND for this window. IntPtr.Zero if not supported.
+ IntPtr IToolkitWindow.GetHwnd()
+ {
+ return IntPtr.Zero;
+ }
+
+ // Set the event sink to use for this window.
+ void IToolkitWindow.SetEventSink(IToolkitEventSink sink)
+ {
+ this.sink = sink;
+ }
+
+ // Override the button press event from Xsharp.
+ protected override void OnButtonPress(int x, int y, ButtonName button,
+
ModifierMask modifiers)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseDown
+
(DrawingWindow.MapButton(button),
+ DrawingWindow.MapKey
+ (KeyName.XK_VoidSymbol,
modifiers),
+ 1, x, y, 0);
+ }
+ }
+
+ // Override the button release event from Xsharp.
+ protected override void OnButtonRelease(int x, int y, ButtonName button,
+
ModifierMask modifiers)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseUp
+
(DrawingWindow.MapButton(button),
+ DrawingWindow.MapKey
+ (KeyName.XK_VoidSymbol,
modifiers),
+ 1, x, y, 0);
+ }
+ }
+
+ // Override the button double click event from Xsharp.
+ protected override void OnButtonDoubleClick
+ (int x, int y, ButtonName button, ModifierMask
modifiers)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseDown
+
(DrawingWindow.MapButton(button),
+ DrawingWindow.MapKey
+ (KeyName.XK_VoidSymbol,
modifiers),
+ 2, x, y, 0);
+ }
+ }
+
+ // Override the pointer motion event from Xsharp.
+ protected override void OnPointerMotion
+ (int x, int y, ModifierMask modifiers)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseMove
+ (ToolkitMouseButtons.None,
+ DrawingWindow.MapKey
+ (KeyName.XK_VoidSymbol,
modifiers),
+ 0, x, y, 0);
+ }
+ }
+
+ // Override the key press event from Xsharp.
+ protected override bool OnKeyPress(KeyName key,
+
ModifierMask modifiers, String str)
+ {
+ if(sink != null)
+ {
+ // Emit the "KeyDown" event.
+ ToolkitKeys keyData =
DrawingWindow.MapKey(key, modifiers);
+ if(keyData != ToolkitKeys.None)
+ {
+ sink.ToolkitKeyDown(keyData);
+ }
+
+ // Emit the "KeyChar" event if
necessary.
+ if(str != null)
+ {
+ foreach(char ch in str)
+ {
+ sink.ToolkitKeyChar(ch);
+ }
+ }
+ }
+
+ // The key has been processed.
+ return true;
+ }
+
+ // Override the mouse enter event from Xsharp.
+ protected override void OnEnter(Widget child, int x, int y,
+
ModifierMask modifiers,
+
CrossingMode mode,
+
CrossingDetail detail)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseEnter();
+ }
+ }
+
+ // Override the mouse leave event from Xsharp.
+ protected override void OnLeave(Widget child, int x, int y,
+
ModifierMask modifiers,
+
CrossingMode mode,
+
CrossingDetail detail)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseLeave();
+ }
+ }
+
+ // Override the focus enter event from Xsharp.
+ protected override void OnFocusIn(Widget other)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitFocusEnter();
+ }
+ }
+
+ // Override the focus leave event from Xsharp.
+ protected override void OnFocusOut(Widget other)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitFocusLeave();
+ }
+ }
+
// Handle a paint event from Xsharp.
protected override void OnPaint(Xsharp.Graphics graphics)
{
! if(sink != null)
{
DrawingGraphics g = new
DrawingGraphics(toolkit, graphics);
System.Drawing.Graphics gr =
ToolkitManager.CreateGraphics(g);
! sink.ToolkitExpose(gr);
gr.Dispose();
}
}
}; // class DrawingTopLevelWindow
Index: DrawingWindow.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Xsharp/DrawingWindow.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** DrawingWindow.cs 7 Jun 2003 22:40:59 -0000 1.1
--- DrawingWindow.cs 11 Jun 2003 07:07:19 -0000 1.2
***************
*** 32,35 ****
--- 32,36 ----
// Internal state.
private IToolkit toolkit;
+ private IToolkitEventSink sink;
// Constructor.
***************
*** 51,54 ****
--- 52,64 ----
}
+ // Get the toolkit parent window.
+ IToolkitWindow IToolkitWindow.Parent
+ {
+ get
+ {
+ return (IToolkitWindow)Parent;
+ }
+ }
+
// Get the current dimensions of this window.
public System.Drawing.Rectangle Dimensions
***************
*** 73,76 ****
--- 83,95 ----
}
+ // Determine if this window currently has the input focus.
+ bool IToolkitWindow.Focused
+ {
+ get
+ {
+ return Focused;
+ }
+ }
+
// Destroy this window and all of its children.
void IToolkitWindow.Destroy()
***************
*** 82,85 ****
--- 101,106 ----
void IToolkitWindow.MoveResize(int x, int y, int width, int height)
{
+ DrawingToolkit.ValidateWindowPosition(ref x,
ref y);
+ DrawingToolkit.ValidateWindowSize(ref width,
ref height);
Move(x, y);
Resize(width, height);
***************
*** 107,111 ****
void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y)
{
! // TODO
}
--- 128,139 ----
void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y)
{
! if(parent == null)
! {
!
Reparent(((DrawingToolkit)Toolkit).placeholder, x, y);
! }
! else
! {
! Reparent((Widget)parent, x, y);
! }
}
***************
*** 123,126 ****
--- 151,160 ----
}
+ // Set the foreground of the window to a solid color.
+ void IToolkitWindow.SetForeground(System.Drawing.Color color)
+ {
+ Foreground =
DrawingToolkit.DrawingToXColor(color);
+ }
+
// Set the background of the window to a solid color.
void IToolkitWindow.SetBackground(System.Drawing.Color color)
***************
*** 136,154 ****
}
// Handle a paint event from Xsharp.
protected override void OnPaint(Xsharp.Graphics graphics)
{
! if(Expose != null)
{
DrawingGraphics g = new
DrawingGraphics(toolkit, graphics);
System.Drawing.Graphics gr =
ToolkitManager.CreateGraphics(g);
! Expose(gr);
gr.Dispose();
}
}
-
- // Event that is emitted for an expose on this window.
- public event ToolkitExposeHandler Expose;
}; // class DrawingWindow
--- 170,366 ----
}
+ // Get the adjustment values for the client area.
+ // On entry, all values are zero.
+ void IToolkitWindow.GetClientAreaAdjust
+ (ref int leftAdjust, ref int topAdjust,
+ ref int rightAdjust, ref int bottomAdjust)
+ {
+ // Nothing to do in this implementation.
+ }
+
+ // Move this window to above one of its siblings.
+ void IToolkitWindow.MoveToAbove(IToolkitWindow sibling)
+ {
+ // TODO
+ }
+
+ // Move this window to below one of its siblings.
+ void IToolkitWindow.MoveToBelow(IToolkitWindow sibling)
+ {
+ // TODO
+ }
+
+ // Get the HWND for this window. IntPtr.Zero if not supported.
+ IntPtr IToolkitWindow.GetHwnd()
+ {
+ return IntPtr.Zero;
+ }
+
+ // Set the event sink to use for this window.
+ void IToolkitWindow.SetEventSink(IToolkitEventSink sink)
+ {
+ this.sink = sink;
+ }
+
+ // Map an Xsharp key description into a "ToolkitKeys" value.
+ internal static ToolkitKeys MapKey(KeyName key, ModifierMask modifiers)
+ {
+ // TODO
+ return ToolkitKeys.None;
+ }
+
+ // Map an Xsharp button name into a "ToolkitMouseButtons" value.
+ internal static ToolkitMouseButtons MapButton(ButtonName button)
+ {
+ switch(button)
+ {
+ case ButtonName.Button1:
+ return ToolkitMouseButtons.Left;
+ case ButtonName.Button2:
+ return
ToolkitMouseButtons.Middle;
+ case ButtonName.Button3:
+ return
ToolkitMouseButtons.Right;
+ case ButtonName.Button4:
+ return
ToolkitMouseButtons.XButton1;
+ case ButtonName.Button5:
+ return
ToolkitMouseButtons.XButton2;
+ default:
+ return ToolkitMouseButtons.None;
+ }
+ }
+
+ // Override the button press event from Xsharp.
+ protected override void OnButtonPress(int x, int y, ButtonName button,
+
ModifierMask modifiers)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseDown
+ (MapButton(button),
+ MapKey(KeyName.XK_VoidSymbol,
modifiers),
+ 1, x, y, 0);
+ }
+ }
+
+ // Override the button release event from Xsharp.
+ protected override void OnButtonRelease(int x, int y, ButtonName button,
+
ModifierMask modifiers)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseUp
+ (MapButton(button),
+ MapKey(KeyName.XK_VoidSymbol,
modifiers),
+ 1, x, y, 0);
+ }
+ }
+
+ // Override the button double click event from Xsharp.
+ protected override void OnButtonDoubleClick
+ (int x, int y, ButtonName button, ModifierMask
modifiers)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseDown
+ (MapButton(button),
+ MapKey(KeyName.XK_VoidSymbol,
modifiers),
+ 2, x, y, 0);
+ }
+ }
+
+ // Override the pointer motion event from Xsharp.
+ protected override void OnPointerMotion
+ (int x, int y, ModifierMask modifiers)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseMove
+ (ToolkitMouseButtons.None,
+ MapKey(KeyName.XK_VoidSymbol,
modifiers),
+ 0, x, y, 0);
+ }
+ }
+
+ // Override the key press event from Xsharp.
+ protected override bool OnKeyPress(KeyName key,
+
ModifierMask modifiers, String str)
+ {
+ if(sink != null)
+ {
+ // Emit the "KeyDown" event.
+ ToolkitKeys keyData = MapKey(key,
modifiers);
+ if(keyData != ToolkitKeys.None)
+ {
+ sink.ToolkitKeyDown(keyData);
+ }
+
+ // Emit the "KeyChar" event if
necessary.
+ if(str != null)
+ {
+ foreach(char ch in str)
+ {
+ sink.ToolkitKeyChar(ch);
+ }
+ }
+ }
+
+ // The key has been processed.
+ return true;
+ }
+
+ // Override the mouse enter event from Xsharp.
+ protected override void OnEnter(Widget child, int x, int y,
+
ModifierMask modifiers,
+
CrossingMode mode,
+
CrossingDetail detail)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseEnter();
+ }
+ }
+
+ // Override the mouse leave event from Xsharp.
+ protected override void OnLeave(Widget child, int x, int y,
+
ModifierMask modifiers,
+
CrossingMode mode,
+
CrossingDetail detail)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitMouseLeave();
+ }
+ }
+
+ // Override the focus enter event from Xsharp.
+ protected override void OnFocusIn(Widget other)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitFocusEnter();
+ }
+ }
+
+ // Override the focus leave event from Xsharp.
+ protected override void OnFocusOut(Widget other)
+ {
+ if(sink != null)
+ {
+ sink.ToolkitFocusLeave();
+ }
+ }
+
// Handle a paint event from Xsharp.
protected override void OnPaint(Xsharp.Graphics graphics)
{
! if(sink != null)
{
DrawingGraphics g = new
DrawingGraphics(toolkit, graphics);
System.Drawing.Graphics gr =
ToolkitManager.CreateGraphics(g);
! sink.ToolkitExpose(gr);
gr.Dispose();
}
}
}; // class DrawingWindow
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Xsharp DrawingToolkit.cs,1.2,1.3 DrawingTopLevelWindow.cs,1.1,1.2 DrawingWindow.cs,1.1,1.2,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.1016,1.1017 Makefile.am,1.21,1.22 configure.in,1.78,1.79
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing/Toolkit IToolkitEventSink.cs,NONE,1.1 README,NONE,1.1 ToolkitKeys.cs,NONE,1.1 ToolkitMouseButtons.cs,NONE,1.1 IToolkit.cs,1.2,1.3 IToolkitWindow.cs,1.1,1.2 ToolkitEventHandlers.cs,1.1,1.2
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.1016,1.1017 Makefile.am,1.21,1.22 configure.in,1.78,1.79
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing/Toolkit IToolkitEventSink.cs,NONE,1.1 README,NONE,1.1 ToolkitKeys.cs,NONE,1.1 ToolkitMouseButtons.cs,NONE,1.1 IToolkit.cs,1.2,1.3 IToolkitWindow.cs,1.1,1.2 ToolkitEventHandlers.cs,1.1,1.2
- Index(es):