comparison dwt/widgets/CoolItem.d @ 90:c7f7f4d7091a

All widgets are ported
author Jacob Carlborg <doob@me.com>
date Tue, 30 Dec 2008 18:54:31 +0100
parents a3f5118c8b37
children 63a09873578e
comparison
equal deleted inserted replaced
89:8e3c85e1733d 90:c7f7f4d7091a
31 31
32 import dwt.widgets.Control; 32 import dwt.widgets.Control;
33 import dwt.widgets.CoolBar; 33 import dwt.widgets.CoolBar;
34 import dwt.widgets.Event; 34 import dwt.widgets.Event;
35 import dwt.widgets.Item; 35 import dwt.widgets.Item;
36 import dwt.widgets.Listener;
36 import dwt.widgets.ToolBar; 37 import dwt.widgets.ToolBar;
37 import dwt.widgets.ToolItem; 38 import dwt.widgets.ToolItem;
38 import dwt.widgets.TypedListener; 39 import dwt.widgets.TypedListener;
39 40
40 /** 41 /**
56 public class CoolItem : Item { 57 public class CoolItem : Item {
57 Control control; 58 Control control;
58 CoolBar parent; 59 CoolBar parent;
59 bool ideal; 60 bool ideal;
60 int preferredWidth, preferredHeight, minimumWidth, minimumHeight, requestedWidth; 61 int preferredWidth, preferredHeight, minimumWidth, minimumHeight, requestedWidth;
61 Rectangle itemBounds = new Rectangle(0, 0, 0, 0); 62 Rectangle itemBounds;
62 63
63 static final int MARGIN_WIDTH = 4; 64 static const int MARGIN_WIDTH = 4;
64 static final int GRABBER_WIDTH = 2; 65 static const int GRABBER_WIDTH = 2;
65 static final int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH; 66 static const int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH;
66 67
67 private int CHEVRON_HORIZONTAL_TRIM = -1; //platform dependent values 68 private int CHEVRON_HORIZONTAL_TRIM = -1; //platform dependent values
68 private int CHEVRON_VERTICAL_TRIM = -1; 69 private int CHEVRON_VERTICAL_TRIM = -1;
69 private static final int CHEVRON_LEFT_MARGIN = 2; 70 private static const int CHEVRON_LEFT_MARGIN = 2;
70 private static final int CHEVRON_IMAGE_WIDTH = 8; //Width to draw the double arrow 71 private static const int CHEVRON_IMAGE_WIDTH = 8; //Width to draw the double arrow
71 72
72 ToolBar chevron; 73 ToolBar chevron;
73 bool wrap; 74 bool wrap;
74 Image arrowImage = null; 75 Image arrowImage = null;
75 76
106 public this (CoolBar parent, int style) { 107 public this (CoolBar parent, int style) {
107 super(parent, style); 108 super(parent, style);
108 this.parent = parent; 109 this.parent = parent;
109 parent.createItem (this, parent.getItemCount()); 110 parent.createItem (this, parent.getItemCount());
110 calculateChevronTrim (); 111 calculateChevronTrim ();
112
113 itemBounds = new Rectangle(0, 0, 0, 0);
111 } 114 }
112 /** 115 /**
113 * Constructs a new instance of this class given its parent 116 * Constructs a new instance of this class given its parent
114 * (which must be a <code>CoolBar</code>), a style value 117 * (which must be a <code>CoolBar</code>), a style value
115 * describing its behavior and appearance, and the index 118 * describing its behavior and appearance, and the index
144 public this (CoolBar parent, int style, int index) { 147 public this (CoolBar parent, int style, int index) {
145 super(parent, style); 148 super(parent, style);
146 this.parent = parent; 149 this.parent = parent;
147 parent.createItem (this, index); 150 parent.createItem (this, index);
148 calculateChevronTrim (); 151 calculateChevronTrim ();
152
153 itemBounds = new Rectangle(0, 0, 0, 0);
149 } 154 }
150 /** 155 /**
151 * Adds the listener to the collection of listeners that will 156 * Adds the listener to the collection of listeners that will
152 * be notified when the control is selected by the user, by sending it one 157 * be notified when the control is selected by the user, by sending it one
153 * of the messages defined in the <code>SelectionListener</code> 158 * of the messages defined in the <code>SelectionListener</code>
635 if (chevron is null) { 640 if (chevron is null) {
636 chevron = new ToolBar (parent, DWT.FLAT | DWT.NO_FOCUS); 641 chevron = new ToolBar (parent, DWT.FLAT | DWT.NO_FOCUS);
637 ToolItem toolItem = new ToolItem (chevron, DWT.PUSH); 642 ToolItem toolItem = new ToolItem (chevron, DWT.PUSH);
638 toolItem.addListener (DWT.Selection, new class () Listener { 643 toolItem.addListener (DWT.Selection, new class () Listener {
639 public void handleEvent (Event event) { 644 public void handleEvent (Event event) {
640 CoolItem.outer.onSelection (event); 645 this.outer.onSelection (event);
641 } 646 }
642 }); 647 });
643 } 648 }
644 int controlHeight, currentImageHeight = 0; 649 int controlHeight, currentImageHeight = 0;
645 if ((parent.style & DWT.VERTICAL) !is 0) { 650 if ((parent.style & DWT.VERTICAL) !is 0) {