Design 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. Design of new implementation of SWF
  2. ===================================
  3. 0. About SWF:
  4. =============
  5. SWF stands for System.Windows.Forms. This is a class library that
  6. provides a set of controls for designing application UI.
  7. 1. Architecture:
  8. ================
  9. The new implementation of SWF is based on drivers providing access to
  10. the native windowing system of the host OS. The old implementation was
  11. based on Wine library. The motivation for new implementation comes from
  12. the problems faced with the Wine approach:
  13. - Wine was missing features that .NET provided over Win32; to add those
  14. features we would have had to write the controls managed anyway
  15. - Installation became much more difficult due to the Wine dependencies
  16. and the relatively akward way we had to initialize Wine.
  17. The new implementation takes advantage of Win32 APIs on Windows and
  18. emulates the same on Linux using X11 for window management and events.
  19. Following gives a high level idea of the new implementation of SWF.
  20. -------------------------------------
  21. | Managed SWF |
  22. -------------------------------------
  23. | XplatUI Driver Interface |
  24. -------------------------------------
  25. | X11 Driver|Win32 Driver|OSX Driver|
  26. | | | |
  27. | Mono on | Mono on | Mono on |
  28. | Linux/Mac | Windows | Mac OS/X |
  29. -------------------------------------
  30. The above picture explains how the window management is done in the new
  31. implementation. For drawing the controls System.Drawing library is used.
  32. To handle some special needs for different platforms, there are a few
  33. limited patches to System.Drawing to deal with calls from System.Windows.Forms
  34. 2. Design:
  35. ==========
  36. The new design of SWF makes porting of the library to Linux/Windows/Mac
  37. very easy.
  38. All the controls in SWF inherit from Control class and most of the painting
  39. operations are done using ControlPaint class. At the low level, XplatUI class
  40. provides the abstraction over the underlying window management system. It
  41. contains a XplatUIDriver for providing the window management. XplatUIDriver
  42. is an abstract class which is implemented by XplatX11 and XplatWin32 classes
  43. respectively for Linux/Mac and Windows platforms. Support for any new platform
  44. can be added simply by implementing XplatUIDriver for the new platform.
  45. 2b. Themes:
  46. ===========
  47. The look of any control is supposed to be controlled by the chosen theme.
  48. All control drawing needs to be done by the currently selected theme class.
  49. The ThemeEngine class manages the themes. All the themes implement
  50. Theme abstract class. The Theme class provides the drawing primitives for
  51. all controls. The current implementation supports the Windows Classic theme
  52. through the ThemeWin32Classic class and the Gnome theme through the ThemeGtk
  53. class. Gnome support is still very incomplete (even more incomplete than SWF
  54. itself)
  55. 2c. Multi-threading:
  56. ====================
  57. As of this writing, multi-threading was fully supported, provided the
  58. standard Microsoft implementation guidelines involving Invoke() are
  59. followed.
  60. 2d. Issues:
  61. ===========
  62. - To be added when MWF reaches completion