2005-06-05 Peter Bartok <pbartok@novell.com>
[mono.git] / mcs / class / Managed.Windows.Forms / Design
1       Design of new implementation of SWF
2       ===================================
3
4 0. About SWF:
5 =============
6
7 SWF stands for System.Windows.Forms. This is a class library that
8 provides a set of controls for designing application UI.
9
10
11 1. Architecture:
12 ================
13
14 The new implementation of SWF is based on drivers providing access to
15 the native windowing system of the host OS. The old implementation was
16 based on Wine library. The motivation for new implementation comes from
17 the problems faced with the Wine approach:
18 - Wine was missing features that .NET provided over Win32; to add those
19   features we would have had to write the controls managed anyway
20 - Installation became much more difficult due to the Wine dependencies
21   and the relatively akward way we had to initialize Wine.
22
23 The new implementation takes advantage of Win32 APIs on Windows and
24 emulates the same on Linux using X11 for window management and events.
25 Following gives a high level idea of the new implementation of SWF.
26
27          -------------------------------------
28          |             Managed SWF           |
29          -------------------------------------
30          |      XplatUI Driver Interface     |
31          -------------------------------------
32          | X11 Driver|Win32 Driver|OSX Driver|
33          |           |            |          |
34          |  Mono on  |  Mono on   | Mono on  |
35          | Linux/Mac |  Windows   | Mac OS/X |
36          -------------------------------------
37
38 The above picture explains how the window management is done in the new
39 implementation. For drawing the controls System.Drawing library is used.
40 To handle some special needs for different platforms, there are a few 
41 limited patches to System.Drawing to deal with calls from System.Windows.Forms
42
43
44 2. Design:
45 ==========
46
47 The new design of SWF makes porting of the library to Linux/Windows/Mac
48 very easy.
49 All the controls in SWF inherit from Control class and most of the painting
50 operations are done using ControlPaint class. At the low level, XplatUI class
51 provides the abstraction over the underlying window management system. It
52 contains a XplatUIDriver for providing the window management. XplatUIDriver
53 is an abstract class which is implemented by XplatX11 and XplatWin32 classes
54 respectively for Linux/Mac and Windows platforms. Support for any new platform
55 can be added simply by implementing XplatUIDriver for the new platform.
56
57
58 2a. Double Buffering:
59 =====================
60
61 For drawing controls double buffering used, so that a better performance
62 can be achieved. Every controls maintains a bitmap image of itself. This
63 image is used for painting the screen when a paint event is raised. When
64 a control property changes the look of the control, it redraws the bitmap
65 image. [Please see the guidelines document]
66
67
68 2b. Themes:
69 ===========
70
71 The look of any control is supposed to be controlled by the chosen theme.
72 All control drawing needs to be done by the currently selected theme class.
73 The ThemeEngine class manages the themes. All the themes implement 
74 Theme abstract class. The Theme class provides the drawing primitives for 
75 all controls. The current implementation supports the Windows Classic theme 
76 through the ThemeWin32Classic class and the Gnome theme through the ThemeGtk
77 class. Gnome support is still very incomplete (even more incomplete than SWF
78 itself)
79
80
81 2c. Multi-threading:
82 ====================
83
84    As of this writing, multi-threading was fully supported, provided the 
85    standard Microsoft implementation guidelines involving Invoke() are
86    followed.
87
88
89
90 2d. Issues:
91 ===========
92
93    - To be added when MWF reaches completion
94