Guidelines 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Guidelines for hacking SWF
  2. ==========================
  3. This document describes some of the minimal coding guidelines
  4. to be followed while hacking the new SWF implementation. These
  5. guidelines are for the sake of consistency.
  6. 1. Please refer to the design document of SWF to understand the
  7. implementation.
  8. 2. Please follow the general coding style described for the Mono
  9. project (/cvs/mcs/class/README).
  10. 3. Method stubbing is highly discouraged. It's recommended to submit
  11. an implemented method instead of just the signature. If you have
  12. to stub a property or method, please use the [MonoTODO ("what")]
  13. attribute to document what still needs to be done.
  14. 4. When you implement the drawing method for a control in a theme, it
  15. should make call to ControlPaint class methods and System.Drawing
  16. classes. If it is not possible to implement a control's draw method
  17. under these restrictions and you need some functionality from
  18. XplatUIDriver, please let us know. We will try to enhance the
  19. driver, if *really* required.
  20. 5. Minimize redraws as much as possible by utilizing the clipRectangle
  21. when possible.
  22. 6. Setting the size of a control raises a resize event even if the
  23. control size is same. Be careful is setting the size and it's better
  24. to avoid changing the control size as much as possible. Wherever
  25. possible try scaling the control bitmap as per the size needs.
  26. 7. Make sure to call the base class event methods when overriding them.
  27. 8. Define regions in your code, as it makes it easy to browse the code
  28. in the editors which can collapse/expand regions. Also, keep the
  29. methods and properties sorted alphabetically.
  30. 9. Last but not the least, please let others on the mono-winforms-list
  31. know about your work, so that duplication can be avoided.
  32. 10. Theme.cs provides Pen and Brush caching. This allows to share
  33. the same brushes and pens between different controls and also to avoid
  34. to create and destroy them in every draw operation. You should not create
  35. Brushes or Pens directly, you should ask the Resource Pool for them. For
  36. example, instead of:
  37. new SolidBrush(button.BackColor);
  38. you should use:
  39. ResPool.GetSolidBrush (button.BackColor);
  40. Look at SystemResPool class for more details.
  41. Happy hacking!