1 Guidelines for hacking SWF
2 ==========================
4 This document describes some of the minimal coding guidelines
5 to be followed while hacking the new SWF implementation. These
6 guidelines are for the sake of consistency.
8 1. Please refer to the design document of SWF to understand the
11 2. Please follow the general coding style described for the Mono
12 project (/cvs/mcs/class/README).
14 3. Method stubbing is highly discouraged. It's recommended to submit
15 an implemented method instead of just the signature. If you have
16 to stub a property or method, please use the [MonoTODO ("what")]
17 attribute to document what still needs to be done.
19 4. When you implement the drawing method for a control in a theme, it
20 should make call to ControlPaint class methods and System.Drawing
21 classes. If it is not possible to implment a control's draw method
22 under these restrictions and you need some functionality from
23 XplatUIDriver, please let us know. We will try to enhance the
24 driver, if *really* required.
26 5. As mentioned in the design doc also, double buffering must be used
27 by any new controls being added. Whenever a property or method that
28 changes the look of the control is called, the bitmap representing
29 the control should be updated. The Paint method should only copy
30 the bitmap to the screen, and *not* recalculate or paint the control.
31 To aid in double-buffering, the Control class provides the
32 Control.DeviceContext and Control.ImageBuffer properties.
34 A typical OnPaint will look like this:
36 protected override void OnPaint (PaintEventArgs pevent) {
37 pevent.Graphics.DrawImage (this.ImageBuffer,
43 The ImageBuffer bitmap is supposed to contain the representation
44 of the control, often drawn when a property is set, similar to this:
46 public Color RectColor {
53 internal void Redraw () {
54 this.DeviceContext.FillRectangle (sb, this.ClientRectangle);
58 6. Minimize redraws as much as possible by utilizing the clipRectangle
61 7. Setting the size of a control raises a resize event even if the
62 control size is same. Be careful is setting the size and it's better
63 to avoid changing the control size as much as possible. Wherever
64 possible try scaling the control bitmap as per the size needs.
66 8. Make sure to call the base class event methods when overriding them.
68 9. Define regions in your code, as it makes it easy to browse the code
69 in the editors which can collapse/expand regions.
71 10. Last but not the least, please let others on the mono-winforms-list
72 know about your work, so that duplication can be avoided.